Skip to content

Commit 7502e1d

Browse files
committed
Merge remote-tracking branch 'intorr/intorr_dev' into xd_dev
2 parents eddb4aa + b9a6593 commit 7502e1d

37 files changed

+795
-2916
lines changed

src/editors/xrWeatherEditor/pch.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88

99
#pragma once
1010

11+
// Конфликт при использовании встроенного в движок аллокатора
12+
#define NO_XRNEW
13+
1114
#pragma managed(push, off)
1215
#include "Common/Common.hpp"
1316
#include "xrCommon/inlining_macros.h"
17+
#include "xrCore/xrMemory.h"
1418
#include "xrCore/xrstring.h"
1519
#pragma managed(pop)
1620

src/utils/xrAI/StdAfx.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "utils/xrLCUtil/ILevelCompilerLogger.hpp"
1414
#include "utils/xrLCUtil/xrThread.hpp"
1515

16+
#define NUM_THREADS 8
17+
1618
extern ILevelCompilerLogger& Logger;
1719
extern CThread::LogFunc ProxyMsg;
1820
extern CThreadManager::ReportStatusFunc ProxyStatus;

src/utils/xrAI/compiler_cover.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,6 @@ void compute_non_covers()
526526
delete_data(nearest);
527527
}
528528

529-
#define NUM_THREADS 3
530529
extern void mem_Optimize();
531530
void xrCover(bool pure_covers)
532531
{

src/utils/xrAI/compiler_load.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ void xrLoad(LPCSTR name, bool draft_mode)
147147
IReader* THM = FS.r_open("$game_textures$", N);
148148
R_ASSERT2(THM, N);
149149

150+
// version
151+
//u32 version = 0;
152+
//R_ASSERT2(THM->r_chunk(THM_CHUNK_VERSION, &version), N);
153+
//if (version != THM_CURRENT_VERSION) FATAL("Unsupported version of THM file.");
154+
150155
// analyze thumbnail information
151156
BT.THM.Load(*THM);
152157
BOOL bLOD = FALSE;
@@ -169,8 +174,8 @@ void xrLoad(LPCSTR name, bool draft_mode)
169174
if ((w != BT.dwWidth) || (h != BT.dwHeight))
170175
{
171176
Msg("! THM doesn't correspond to the texture: %dx%d -> %dx%d", BT.dwWidth, BT.dwHeight, w, h);
172-
BT.dwWidth = w;
173-
BT.dwHeight = h;
177+
BT.dwWidth = BT.THM.width = w;
178+
BT.dwHeight = BT.THM.height = h;
174179
}
175180
BT.Vflip();
176181
}

src/utils/xrDXT/DXT.cpp

Lines changed: 19 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,6 @@
11
#include "stdafx.h"
2-
#include "dxtlib.h"
32
#include <nvtt/nvtt.h>
4-
#include "ETextureParams.h"
5-
//#include "dds.h"
6-
7-
//BOOL APIENTRY DllMain(HANDLE hModule, u32 ul_reason_for_call, LPVOID lpReserved) { return TRUE; }
8-
static HFILE gFileOut;
9-
static HFILE gFileIn;
10-
11-
/*const u32 fcc_DXT1 = MAKEFOURCC('D', 'X', 'T', '1');
12-
const u32 fcc_DXT2 = MAKEFOURCC('D', 'X', 'T', '2');
13-
const u32 fcc_DXT3 = MAKEFOURCC('D', 'X', 'T', '3');
14-
const u32 fcc_DXT4 = MAKEFOURCC('D', 'X', 'T', '4');
15-
const u32 fcc_DXT5 = MAKEFOURCC('D', 'X', 'T', '5');*/
16-
17-
/*void __cdecl WriteDTXnFile(DWORD count, void* buffer, void* userData)
18-
{
19-
if (count == sizeof(DDS_HEADER))
20-
{
21-
DDS_HEADER* hdr = (DDS_HEADER*)buffer;
22-
if (hdr->dwSize == count)
23-
{
24-
switch (hdr->ddspf.dwFourCC)
25-
{
26-
case fcc_DXT1:
27-
case fcc_DXT2:
28-
case fcc_DXT3:
29-
case fcc_DXT4:
30-
case fcc_DXT5: hdr->ddspf.dwRGBBitCount = 0; break;
31-
}
32-
}
33-
}
34-
_write(gFileOut, buffer, count);
35-
}*/
36-
37-
class DDSWriter : public nvtt::OutputHandler
38-
{
39-
public:
40-
HFILE& file;
41-
42-
DDSWriter(HFILE& file);
43-
virtual void beginImage(int size, int width, int height, int depth, int face, int miplevel) override;
44-
virtual bool writeData(const void* data, int size) override;
45-
};
46-
47-
DDSWriter::DDSWriter(HFILE& file) : file(file) {}
48-
void DDSWriter::beginImage(int size, int width, int height, int depth, int face, int miplevel) {}
49-
bool DDSWriter::writeData(const void* data, int size)
50-
{
51-
/*if (size == sizeof(DDS_HEADER))
52-
{
53-
DDS_HEADER* hdr = (DDS_HEADER*)data;
54-
if (hdr->dwSize == size)
55-
{
56-
switch (hdr->ddspf.dwFourCC)
57-
{
58-
case fcc_DXT1:
59-
case fcc_DXT2:
60-
case fcc_DXT3:
61-
case fcc_DXT4:
62-
case fcc_DXT5: hdr->ddspf.dwRGBBitCount = 0; break;
63-
}
64-
}
65-
}*/
66-
_write(file, data, size);
67-
return true;
68-
}
3+
#include "Layers/xrRender/ETextureParams.h"
694

705
class DDSErrorHandler : public nvtt::ErrorHandler
716
{
@@ -75,29 +10,10 @@ class DDSErrorHandler : public nvtt::ErrorHandler
7510

7611
void DDSErrorHandler::error(nvtt::Error e)
7712
{
78-
const char* msg;
79-
switch (e)
80-
{
81-
default:
82-
case nvtt::Error_Unknown: msg = "Unknown error"; break;
83-
case nvtt::Error_InvalidInput: msg = "Invalid input"; break;
84-
case nvtt::Error_UnsupportedFeature: msg = "Unsupported feature"; break;
85-
case nvtt::Error_CudaError: msg = "CUDA error"; break;
86-
case nvtt::Error_FileOpen: msg = "File open error"; break;
87-
case nvtt::Error_FileWrite: msg = "File write error"; break;
88-
}
89-
MessageBox(0, msg, "DXT compress error", MB_ICONERROR | MB_OK);
13+
MessageBox(0, nvtt::errorString(e), "DXT compress error", MB_ICONERROR | MB_OK);
9014
}
9115

92-
/*void __cdecl ReadDTXnFile(DWORD count, void* buffer, void* userData) { _read(gFileIn, buffer, count); }
93-
HRESULT WriteCompressedData(void* data, int miplevel, u32 size)
94-
{
95-
_write(gFileOut, data, size);
96-
FillMemory(data, size, 0xff);
97-
return 0;
98-
}*/
99-
100-
/*ENGINE_API*/ u32* Build32MipLevel(u32& _w, u32& _h, u32& _p, u32* pdwPixelSrc, STextureParams* fmt, float blend)
16+
u32* Build32MipLevel(u32& _w, u32& _h, u32& _p, u32* pdwPixelSrc, STextureParams* fmt, float blend)
10117
{
10218
R_ASSERT(pdwPixelSrc);
10319
R_ASSERT(_w % 2 == 0);
@@ -184,57 +100,45 @@ void FillRect(u8* data, u8* new_data, u32 offs, u32 pitch, u32 h, u32 full_pitch
184100
int DXTCompressImage(LPCSTR out_name, u8* raw_data, u32 w, u32 h, u32 pitch, STextureParams* fmt, u32 depth)
185101
{
186102
R_ASSERT(0 != w && 0 != h);
187-
gFileOut = _open(out_name, _O_WRONLY | _O_BINARY | _O_CREAT | _O_TRUNC, _S_IWRITE);
188-
if (gFileOut == -1)
189-
{
190-
fprintf(stderr, "Can't open output file %s\n", out_name);
191-
return 0;
192-
}
193103
bool result = false;
194104
nvtt::InputOptions inOpt;
195105
auto layout = fmt->type == STextureParams::ttCubeMap ? nvtt::TextureType_Cube : nvtt::TextureType_2D;
196106
inOpt.setTextureLayout(layout, w, h);
197-
if (fmt->flags.is(STextureParams::flGenerateMipMaps))
198-
inOpt.setMipmapGeneration(true);
199-
else
200-
inOpt.setMipmapGeneration(false);
107+
inOpt.setMipmapGeneration(fmt->flags.is(STextureParams::flGenerateMipMaps));
201108
inOpt.setWrapMode(nvtt::WrapMode_Clamp);
202109
inOpt.setNormalMap(false);
203110
inOpt.setConvertToNormalMap(false);
204111
inOpt.setGamma(2.2f, 2.2f);
205112
inOpt.setNormalizeMipmaps(false);
206113
nvtt::CompressionOptions compOpt;
207114
compOpt.setQuality(nvtt::Quality_Highest);
208-
compOpt.setQuantization(
209-
fmt->flags.is(STextureParams::flDitherColor), false, fmt->flags.is(STextureParams::flBinaryAlpha));
115+
compOpt.setQuantization(fmt->flags.is(STextureParams::flDitherColor), false, fmt->flags.is(STextureParams::flBinaryAlpha));
210116
switch (fmt->fmt)
211117
{
212-
case STextureParams::tfDXT1: compOpt.setFormat(nvtt::Format_DXT1); break;
118+
case STextureParams::tfDXT1: compOpt.setFormat(nvtt::Format_DXT1 ); break;
213119
case STextureParams::tfADXT1: compOpt.setFormat(nvtt::Format_DXT1a); break;
214-
case STextureParams::tfDXT3: compOpt.setFormat(nvtt::Format_DXT3); break;
215-
case STextureParams::tfDXT5: compOpt.setFormat(nvtt::Format_DXT5); break;
216-
case STextureParams::tfRGB: compOpt.setFormat(nvtt::Format_RGB); break;
217-
case STextureParams::tfRGBA: compOpt.setFormat(nvtt::Format_RGBA); break;
120+
case STextureParams::tfDXT3: compOpt.setFormat(nvtt::Format_DXT3 ); break;
121+
case STextureParams::tfDXT5: compOpt.setFormat(nvtt::Format_DXT5 ); break;
122+
case STextureParams::tfRGB: compOpt.setFormat(nvtt::Format_RGB ); break;
123+
case STextureParams::tfRGBA: compOpt.setFormat(nvtt::Format_RGBA ); break;
218124
}
219125
switch (fmt->mip_filter)
220126
{
221127
case STextureParams::kMIPFilterAdvanced: break;
222-
case STextureParams::kMIPFilterBox: inOpt.setMipmapFilter(nvtt::MipmapFilter_Box); break;
128+
case STextureParams::kMIPFilterBox: inOpt.setMipmapFilter(nvtt::MipmapFilter_Box ); break;
223129
case STextureParams::kMIPFilterTriangle: inOpt.setMipmapFilter(nvtt::MipmapFilter_Triangle); break;
224-
case STextureParams::kMIPFilterKaiser: inOpt.setMipmapFilter(nvtt::MipmapFilter_Kaiser); break;
130+
case STextureParams::kMIPFilterKaiser: inOpt.setMipmapFilter(nvtt::MipmapFilter_Kaiser ); break;
225131
}
226132
nvtt::OutputOptions outOpt;
227-
DDSWriter writer(gFileOut);
228-
outOpt.setOutputHandler(&writer);
133+
outOpt.setFileName(out_name);
229134
DDSErrorHandler handler;
230135
outOpt.setErrorHandler(&handler);
231136
if (fmt->flags.is(STextureParams::flGenerateMipMaps) && STextureParams::kMIPFilterAdvanced == fmt->mip_filter)
232137
{
233138
inOpt.setMipmapGeneration(false);
234-
u8* pImagePixels = 0;
235139
int numMipmaps = GetPowerOf2Plus1(__min(w, h));
236140
u32 line_pitch = w * 2 * 4;
237-
pImagePixels = xr_alloc<u8>(line_pitch * h);
141+
u8* pImagePixels = xr_alloc<u8>(line_pitch * h);
238142
u32 w_offs = 0;
239143
u32 dwW = w;
240144
u32 dwH = h;
@@ -255,28 +159,15 @@ int DXTCompressImage(LPCSTR out_name, u8* raw_data, u32 w, u32 h, u32 pitch, STe
255159
w_offs += dwP;
256160
}
257161
xr_free(pLastMip);
258-
RGBAImage pImage(w * 2, h);
259-
rgba_t* pixels = pImage.pixels();
260-
u8* pixel = pImagePixels;
261-
for (u32 k = 0; k < w * 2 * h; k++, pixel += 4)
262-
{
263-
pixels[k].set(pixel[0], pixel[1], pixel[2], pixel[3]);
264-
}
265-
inOpt.setMipmapData(pixels, w, h);
162+
inOpt.setMipmapData(pImagePixels, w, h);
266163
result = nvtt::Compressor().process(inOpt, compOpt, outOpt);
267164
xr_free(pImagePixels);
268165
}
269166
else
270167
{
271-
RGBAImage pImage(w, h);
272-
rgba_t* pixels = pImage.pixels();
273-
u8* pixel = raw_data;
274-
for (u32 k = 0; k < w * h; k++, pixel += 4)
275-
pixels[k].set(pixel[0], pixel[1], pixel[2], pixel[3]);
276-
inOpt.setMipmapData(pixels, w, h);
168+
inOpt.setMipmapData(raw_data, w, h);
277169
result = nvtt::Compressor().process(inOpt, compOpt, outOpt);
278170
}
279-
_close(gFileOut);
280171
if (!result)
281172
{
282173
_unlink(out_name);
@@ -285,21 +176,17 @@ int DXTCompressImage(LPCSTR out_name, u8* raw_data, u32 w, u32 h, u32 pitch, STe
285176
return 1;
286177
}
287178

288-
extern int DXTCompressBump(
289-
LPCSTR out_name, u8* raw_data, u8* normal_map, u32 w, u32 h, u32 pitch, STextureParams* fmt, u32 depth);
179+
extern int DXTCompressBump(LPCSTR out_name, u8* raw_data, u8* normal_map, u32 w, u32 h, u32 pitch, STextureParams* fmt, u32 depth);
290180

291-
extern "C" __declspec(dllexport) int __stdcall DXTCompress(
292-
LPCSTR out_name, u8* raw_data, u8* normal_map, u32 w, u32 h, u32 pitch, STextureParams* fmt, u32 depth)
181+
extern "C" __declspec(dllexport) int __stdcall DXTCompress(LPCSTR out_name, u8* raw_data, u8* normal_map, u32 w, u32 h, u32 pitch, STextureParams* fmt, u32 depth)
293182
{
294183
switch (fmt->type)
295184
{
296185
case STextureParams::ttImage:
297186
case STextureParams::ttCubeMap:
298187
case STextureParams::ttNormalMap:
299188
case STextureParams::ttTerrain: return DXTCompressImage(out_name, raw_data, w, h, pitch, fmt, depth); break;
300-
case STextureParams::ttBumpMap:
301-
return DXTCompressBump(out_name, raw_data, normal_map, w, h, pitch, fmt, depth);
302-
break;
189+
case STextureParams::ttBumpMap: return DXTCompressBump(out_name, raw_data, normal_map, w, h, pitch, fmt, depth); break;
303190
default: NODEFAULT;
304191
}
305192
return -1;

src/utils/xrDXT/DXT.vcxproj

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,23 +131,22 @@
131131
</ClCompile>
132132
</ItemDefinitionGroup>
133133
<ItemGroup>
134+
<ClInclude Include="..\..\Layers\xrRender\ETextureParams.h" />
135+
<ClInclude Include="dds.h" />
134136
<ClInclude Include="dds\ConvertColor.h" />
135137
<ClInclude Include="dds\ddsTypes.h" />
136138
<ClInclude Include="dds\nvErrorCodes.h" />
137139
<ClInclude Include="dds\tPixel.h" />
138140
<ClInclude Include="dds\tVector.h" />
139-
<ClInclude Include="dxtlib.h" />
140-
<ClInclude Include="ETextureParams.h" />
141141
<ClInclude Include="Image_DXTC.h" />
142142
<ClInclude Include="NV_Common.h" />
143143
<ClInclude Include="NVI_Convolution.h" />
144144
<ClInclude Include="NVI_Image.h" />
145-
<ClInclude Include="dds.h" />
146145
<ClInclude Include="StdAfx.h" />
147146
</ItemGroup>
148147
<ItemGroup>
148+
<ClCompile Include="..\..\Layers\xrRender\ETextureParams.cpp" />
149149
<ClCompile Include="DXT.cpp" />
150-
<ClCompile Include="ETextureParams.cpp" />
151150
<ClCompile Include="Image_DXTC.cpp" />
152151
<ClCompile Include="NormalMapGen.cpp" />
153152
<ClCompile Include="NVI_Convolution.cpp" />

src/utils/xrDXT/DXT.vcxproj.filters

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@
1212
</Filter>
1313
</ItemGroup>
1414
<ItemGroup>
15-
<ClInclude Include="ETextureParams.h">
16-
<Filter>Shared</Filter>
17-
</ClInclude>
1815
<ClInclude Include="Image_DXTC.h">
1916
<Filter>NormalMap</Filter>
2017
</ClInclude>
@@ -27,24 +24,21 @@
2724
<ClInclude Include="NVI_Image.h">
2825
<Filter>NormalMap</Filter>
2926
</ClInclude>
30-
<ClInclude Include="dds.h" />
3127
<ClInclude Include="StdAfx.h" />
3228
<ClInclude Include="dds\ConvertColor.h" />
3329
<ClInclude Include="dds\ddsTypes.h" />
3430
<ClInclude Include="dds\nvErrorCodes.h" />
3531
<ClInclude Include="dds\tPixel.h" />
3632
<ClInclude Include="dds\tVector.h" />
37-
<ClInclude Include="dxtlib.h">
38-
<Filter>Convert</Filter>
33+
<ClInclude Include="..\..\Layers\xrRender\ETextureParams.h">
34+
<Filter>Shared</Filter>
3935
</ClInclude>
36+
<ClInclude Include="dds.h" />
4037
</ItemGroup>
4138
<ItemGroup>
4239
<ClCompile Include="DXT.cpp">
4340
<Filter>Convert</Filter>
4441
</ClCompile>
45-
<ClCompile Include="ETextureParams.cpp">
46-
<Filter>Shared</Filter>
47-
</ClCompile>
4842
<ClCompile Include="Image_DXTC.cpp">
4943
<Filter>NormalMap</Filter>
5044
</ClCompile>
@@ -58,5 +52,8 @@
5852
<Filter>NormalMap</Filter>
5953
</ClCompile>
6054
<ClCompile Include="StdAfx.cpp" />
55+
<ClCompile Include="..\..\Layers\xrRender\ETextureParams.cpp">
56+
<Filter>Shared</Filter>
57+
</ClCompile>
6158
</ItemGroup>
6259
</Project>

0 commit comments

Comments
 (0)