make dependency on d3dcompiler optional

This commit is contained in:
Adam Jensen 2022-08-07 21:25:41 +01:00
parent 11486b08ff
commit 6c74f814c5
3 changed files with 18 additions and 2 deletions

View File

@ -15,6 +15,7 @@ option(ENABLE_STEAM "Build with Steam integration" OFF)
option(ENABLE_MCE "Build with Windows Media Center integration" OFF)
option(ENABLE_GCS "Build with whatever GCS is" OFF)
option(ENABLE_IMGUI "Build with ImGui" ON)
option(ENABLE_D3DCOMPILER "Build with d3dcompiler dependency" ON)
add_compile_options(-g -target ${triple}
-Wno-ignored-pragma-intrinsic
@ -40,7 +41,11 @@ target_link_directories(dxhr PRIVATE
../winsdk/sdk/lib/um/x86
../winsdk/sdk/lib/ucrt/x86)
target_link_libraries(dxhr PRIVATE
-luser32 -ld3d11 -ld3dcompiler)
-luser32 -ld3d11)
if (ENABLE_D3DCOMPILER)
target_link_libraries(dxhr PRIVATE
-ld3dcompiler)
endif()
set_target_properties(dxhr PROPERTIES
OUTPUT_NAME dxhr.exe
CXX_STANDARD 17)

View File

@ -2,3 +2,4 @@
#cmakedefine01 ENABLE_MCE
#cmakedefine01 ENABLE_GCS
#cmakedefine01 ENABLE_IMGUI
#cmakedefine01 ENABLE_D3DCOMPILER

View File

@ -3,12 +3,14 @@
#include <functional>
#include <iterator>
#include <memory>
#include "config.h" // for ENABLE_IMGUI and ENABLE_D3DCOMPILER
#include <windows.h>
#include <d3d11_1.h>
#if ENABLE_D3DCOMPILER
#include <d3dcompiler.h>
#endif
#include "config.h" // for ENABLE_IMGUI
#include "spinnycube.h"
#include "types.h"
#include "mainloop.h" // for buildUnitsUI
@ -380,6 +382,8 @@ int spinnyCube(HWND window,
///////////////////////////////////////////////////////////////////////////////////////////////
#if ENABLE_D3DCOMPILER
ID3DBlob* vsBlob;
D3DCompile(shaders, sizeof(shaders), "shaders.hlsl", nullptr, nullptr, "vs_main", "vs_5_0", 0, 0, &vsBlob, nullptr);
@ -427,6 +431,8 @@ int spinnyCube(HWND window,
/*takeCopy=*/false,
/*isWrapped=*/false);
#endif // ENABLE_D3DCOMPILER
///////////////////////////////////////////////////////////////////////////////////////////////
D3D11_RASTERIZER_DESC1 rasterizerDesc = {};
@ -606,6 +612,7 @@ int spinnyCube(HWND window,
cubePass.keepAlphaBlend = keepAlphaBlend;
renderDevice->setPassCallback(0, &cubePass);
#if ENABLE_D3DCOMPILER
SpinnyCubeDrawable cubeDrawable;
cubeDrawable.renderDevice = renderDevice;
cubeDrawable.stateManager = &stateManager;
@ -616,6 +623,7 @@ int spinnyCube(HWND window,
cubeDrawable.streamDecl = &streamDecl;
cubeDrawable.cdcVertexBuffer = &cdcVertexBuffer;
cubeDrawable.texture = bottleTexture;
#endif
ImGuiDrawable imGuiDrawable;
@ -720,7 +728,9 @@ int spinnyCube(HWND window,
float lightAccumulation[4] = {0.0f, 0.0f, 0.0f, 1.0f};
renderDevice->clearRenderTarget(10, /*mask=*/ 1, 0.0f, backgroundColor, 1.0f, 0);
#if ENABLE_D3DCOMPILER
renderDevice->recordDrawable(&cubeDrawable, /*mask=*/ 1, /*addToParent=*/ 0);
#endif
renderDevice->clearRenderTarget(2, /*mask=*/ 0x2000, 0.0f, lightAccumulation, 1.0f, 0); // deferred shading buffer
static_cast<cdc::PCDX11RenderModelInstance*>(lightRenderModelInstance)->baseMask = 0x2000; // deferred lighting