Skip to content

Commit

Permalink
only load dxcompiler.dll when in dx12 mode
Browse files Browse the repository at this point in the history
  • Loading branch information
turanszkij committed Dec 13, 2020
1 parent 5fd6b5a commit f42f9f8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
26 changes: 15 additions & 11 deletions WickedEngine/wiGraphicsDevice_DX12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@
#pragma comment(lib,"Dxgi.lib")
#pragma comment(lib,"dxguid.lib")

#ifdef _WIN64
#ifndef PLATFORM_UWP
#pragma comment(lib,"dxcompiler.lib")
#endif // PLATFORM_UWP
#endif // _X64

#ifdef _DEBUG
#include <d3d12sdklayers.h>
#endif // _DEBUG

static DxcCreateInstanceProc pfn_DxcCreateInstance = nullptr;

#include <sstream>
#include <algorithm>
#include <wincodec.h>
Expand Down Expand Up @@ -2388,6 +2384,18 @@ using namespace DX12_Internal;
assert(SUCCEEDED(hr));
}

if (pfn_DxcCreateInstance == nullptr)
{
#ifdef PLATFORM_UWP
HMODULE dll = LoadPackagedLibrary(L"dxcompiler.dll", 0);
#else
HMODULE dll = LoadLibrary(L"dxcompiler.dll");
#endif // PLATFORM_UWP
assert(dll != NULL);
pfn_DxcCreateInstance = (DxcCreateInstanceProc)GetProcAddress(dll, "DxcCreateInstance");
assert(pfn_DxcCreateInstance != nullptr);
}

wiBackLog::post("Created GraphicsDevice_DX12");
}
GraphicsDevice_DX12::~GraphicsDevice_DX12()
Expand Down Expand Up @@ -2801,8 +2809,6 @@ using namespace DX12_Internal;

if (pShader->rootSignature == nullptr)
{
#ifdef _WIN64 // TODO: Can't use dxcompiler.dll in 32-bit, so can't use shader reflection
#ifndef PLATFORM_UWP // TODO: Can't use dxcompiler.dll in UWP, so can't use shader reflection
struct ShaderBlob : public IDxcBlob
{
LPVOID address;
Expand All @@ -2818,7 +2824,7 @@ using namespace DX12_Internal;
blob.size = BytecodeLength;

ComPtr<IDxcContainerReflection> container_reflection;
hr = DxcCreateInstance(CLSID_DxcContainerReflection, __uuidof(IDxcContainerReflection), (void**)&container_reflection);
hr = pfn_DxcCreateInstance(CLSID_DxcContainerReflection, __uuidof(IDxcContainerReflection), (void**)&container_reflection);
assert(SUCCEEDED(hr));
hr = container_reflection->Load(&blob);
assert(SUCCEEDED(hr));
Expand Down Expand Up @@ -2920,8 +2926,6 @@ using namespace DX12_Internal;
insert_descriptor(desc);
}
}
#endif // PLATFORM_UWP
#endif // _X64


if (stage == CS || stage == SHADERSTAGE_COUNT)
Expand Down
2 changes: 1 addition & 1 deletion WickedEngine/wiVersion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace wiVersion
// minor features, major updates, breaking compatibility changes
const int minor = 51;
// minor bug fixes, alterations, refactors, updates
const int revision = 17;
const int revision = 18;

const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);

Expand Down

0 comments on commit f42f9f8

Please sign in to comment.