| 235 | static Func_D3DX10Compile gFunc_D3DX10Compile; |
| 236 | |
| 237 | static bool LoadDXShader(const StringImpl& filePath, const StringImpl& entry, const StringImpl& profile, ID3D10Blob** outBuffer) |
| 238 | { |
| 239 | HRESULT hr; |
| 240 | String outObj = filePath + "_" + entry + "_" + profile; |
| 241 | |
| 242 | bool useCache = false; |
| 243 | auto srcDate = ::BfpFile_GetTime_LastWrite(filePath.c_str()); |
| 244 | auto cacheDate = ::BfpFile_GetTime_LastWrite(outObj.c_str()); |
| 245 | if ((cacheDate != 0) && (cacheDate >= srcDate)) |
| 246 | useCache = true; |
| 247 | |
| 248 | if (!useCache) |
| 249 | { |
| 250 | if (gFunc_D3DX10CompileFromFileW == NULL) |
| 251 | { |
| 252 | auto lib = LoadLibraryA("D3DCompiler_47.dll"); |
| 253 | if (lib != NULL) |
| 254 | gFunc_D3DX10CompileFromFileW = (Func_D3DX10CompileFromFileW)::GetProcAddress(lib, "D3DCompileFromFile"); |
| 255 | } |
| 256 | |
| 257 | if (gFunc_D3DX10CompileFromFileW == NULL) |
| 258 | useCache = true; |
| 259 | } |
| 260 | |
| 261 | if (!useCache) |
| 262 | { |
| 263 | bool useCompile = true; |
| 264 | |
| 265 | HRESULT dxResult; |
| 266 | ID3D10Blob* errorMessage = NULL; |
| 267 | if (useCompile) |
| 268 | { |
| 269 | if (gFunc_D3DX10Compile == NULL) |
| 270 | { |
| 271 | auto lib = LoadLibraryA("D3DCompiler_47.dll"); |
| 272 | if (lib != NULL) |
| 273 | gFunc_D3DX10Compile = (Func_D3DX10Compile)::GetProcAddress(lib, "D3DCompile"); |
| 274 | } |
| 275 | |
| 276 | int memSize = 0; |
| 277 | uint8* memPtr = LoadBinaryData(filePath, &memSize); |
| 278 | |
| 279 | dxResult = gFunc_D3DX10Compile(memPtr, memSize, "Shader", NULL, NULL, entry.c_str(), profile.c_str(), |
| 280 | D3D10_SHADER_DEBUG | D3D10_SHADER_ENABLE_STRICTNESS, 0, outBuffer, &errorMessage); |
| 281 | } |
| 282 | else |
| 283 | { |
| 284 | if (gFunc_D3DX10CompileFromFileW == NULL) |
| 285 | { |
| 286 | auto lib = LoadLibraryA("D3DCompiler_47.dll"); |
| 287 | if (lib != NULL) |
| 288 | gFunc_D3DX10CompileFromFileW = (Func_D3DX10CompileFromFileW)::GetProcAddress(lib, "D3DCompileFromFile"); |
| 289 | } |
| 290 | |
| 291 | dxResult = gFunc_D3DX10CompileFromFileW(UTF8Decode(filePath).c_str(), NULL, NULL, entry.c_str(), profile.c_str(), |
| 292 | D3D10_SHADER_DEBUG | D3D10_SHADER_ENABLE_STRICTNESS, 0, outBuffer, &errorMessage); |
| 293 | } |
| 294 |
no test coverage detected