Skip to content

Commit bf02bf0

Browse files
authored
DirectX Graphics Samples Build Break Fixes (#946)
1 parent 278d789 commit bf02bf0

7 files changed

Lines changed: 39 additions & 19 deletions

File tree

Samples/Desktop/D3D12HDR/src/D3D12HDR.cpp

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@
1414
#include "UILayer.h"
1515
#include <dxgidebug.h>
1616

17-
// Precompiled shaders.
18-
#include "gradientVS.hlsl.h"
19-
#include "gradientPS.hlsl.h"
20-
#include "paletteVS.hlsl.h"
21-
#include "palettePS.hlsl.h"
22-
#include "presentVS.hlsl.h"
23-
#include "presentPS.hlsl.h"
24-
2517
const float D3D12HDR::ClearColor[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
2618

2719
extern "C" { __declspec(dllexport) extern const UINT D3D12SDKVersion = 618; }
@@ -216,6 +208,13 @@ void D3D12HDR::LoadAssets()
216208
// as well as the intermediate blend step.
217209
{
218210
// Create the pipeline state for the scene geometry.
211+
UINT8* pGradientVertexShaderData = nullptr;
212+
UINT8* pGradientPixelShaderData = nullptr;
213+
UINT gradientVertexShaderDataLength = 0;
214+
UINT gradientPixelShaderDataLength = 0;
215+
216+
ThrowIfFailed(ReadDataFromFile(GetAssetFullPath(L"gradientVS.cso").c_str(), &pGradientVertexShaderData, &gradientVertexShaderDataLength));
217+
ThrowIfFailed(ReadDataFromFile(GetAssetFullPath(L"gradientPS.cso").c_str(), &pGradientPixelShaderData, &gradientPixelShaderDataLength));
219218

220219
D3D12_INPUT_ELEMENT_DESC gradientElementDescs[] =
221220
{
@@ -227,8 +226,8 @@ void D3D12HDR::LoadAssets()
227226
D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc = {};
228227
psoDesc.InputLayout = { gradientElementDescs, _countof(gradientElementDescs) };
229228
psoDesc.pRootSignature = m_rootSignature.Get();
230-
psoDesc.VS = CD3DX12_SHADER_BYTECODE(g_gradientVS, sizeof(g_gradientVS));
231-
psoDesc.PS = CD3DX12_SHADER_BYTECODE(g_gradientPS, sizeof(g_gradientPS));
229+
psoDesc.VS = CD3DX12_SHADER_BYTECODE(pGradientVertexShaderData, gradientVertexShaderDataLength);
230+
psoDesc.PS = CD3DX12_SHADER_BYTECODE(pGradientPixelShaderData, gradientPixelShaderDataLength);
232231
psoDesc.RasterizerState = CD3DX12_RASTERIZER_DESC(D3D12_DEFAULT);
233232
psoDesc.BlendState = CD3DX12_BLEND_DESC(D3D12_DEFAULT);
234233
psoDesc.DepthStencilState.DepthEnable = FALSE;
@@ -242,6 +241,13 @@ void D3D12HDR::LoadAssets()
242241
ThrowIfFailed(m_device->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&m_pipelineStates[GradientPSO])));
243242

244243
// Create pipeline state for the color space triangles.
244+
UINT8* pPaletteVertexShaderData = nullptr;
245+
UINT8* pPalettePixelShaderData = nullptr;
246+
UINT paletteVertexShaderDataLength = 0;
247+
UINT palettePixelShaderDataLength = 0;
248+
249+
ThrowIfFailed(ReadDataFromFile(GetAssetFullPath(L"paletteVS.cso").c_str(), &pPaletteVertexShaderData, &paletteVertexShaderDataLength));
250+
ThrowIfFailed(ReadDataFromFile(GetAssetFullPath(L"palettePS.cso").c_str(), &pPalettePixelShaderData, &palettePixelShaderDataLength));
245251

246252
D3D12_INPUT_ELEMENT_DESC colorElementDescs[] =
247253
{
@@ -250,14 +256,21 @@ void D3D12HDR::LoadAssets()
250256
};
251257

252258
psoDesc.InputLayout = { colorElementDescs, _countof(colorElementDescs) };
253-
psoDesc.VS = CD3DX12_SHADER_BYTECODE(g_paletteVS, sizeof(g_paletteVS));
254-
psoDesc.PS = CD3DX12_SHADER_BYTECODE(g_palettePS, sizeof(g_palettePS));
259+
psoDesc.VS = CD3DX12_SHADER_BYTECODE(pPaletteVertexShaderData, paletteVertexShaderDataLength);
260+
psoDesc.PS = CD3DX12_SHADER_BYTECODE(pPalettePixelShaderData, palettePixelShaderDataLength);
255261
psoDesc.RTVFormats[0] = m_intermediateRenderTargetFormat;
256262

257263
ThrowIfFailed(m_device->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&m_pipelineStates[PalettePSO])));
258264

259265
// Create pipeline states for the final blend step.
260266
// There will be one for each swap chain format the sample supports.
267+
UINT8* pPresentVertexShaderData = nullptr;
268+
UINT8* pPresentPixelShaderData = nullptr;
269+
UINT presentVertexShaderDataLength = 0;
270+
UINT presentPixelShaderDataLength = 0;
271+
272+
ThrowIfFailed(ReadDataFromFile(GetAssetFullPath(L"presentVS.cso").c_str(), &pPresentVertexShaderData, &presentVertexShaderDataLength));
273+
ThrowIfFailed(ReadDataFromFile(GetAssetFullPath(L"presentPS.cso").c_str(), &pPresentPixelShaderData, &presentPixelShaderDataLength));
261274

262275
D3D12_INPUT_ELEMENT_DESC quadElementDescs[] =
263276
{
@@ -266,8 +279,8 @@ void D3D12HDR::LoadAssets()
266279
};
267280

268281
psoDesc.InputLayout = { quadElementDescs, _countof(quadElementDescs) };
269-
psoDesc.VS = CD3DX12_SHADER_BYTECODE(g_presentVS, sizeof(g_presentVS));
270-
psoDesc.PS = CD3DX12_SHADER_BYTECODE(g_presentPS, sizeof(g_presentPS));
282+
psoDesc.VS = CD3DX12_SHADER_BYTECODE(pPresentVertexShaderData, presentVertexShaderDataLength);
283+
psoDesc.PS = CD3DX12_SHADER_BYTECODE(pPresentPixelShaderData, presentPixelShaderDataLength);
271284
psoDesc.RTVFormats[0] = m_swapChainFormats[_8];
272285
ThrowIfFailed(m_device->CreateGraphicsPipelineState(&psoDesc, IID_PPV_ARGS(&m_pipelineStates[Present8bitPSO])));
273286

Samples/Desktop/D3D12HelloWorld/src/HelloMeshNodes/D3D12HelloMeshNodes.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
<GenerateDebugInformation>true</GenerateDebugInformation>
9999
<EnableCOMDATFolding>true</EnableCOMDATFolding>
100100
<OptimizeReferences>true</OptimizeReferences>
101-
<AdditionalDependencies>d3d12.lib;dxgi.lib;d3dcompiler.lib;%(AdditionalDependencies)</AdditionalDependencies>
101+
<AdditionalDependencies>dxguid.lib;d3d12.lib;dxgi.lib;d3dcompiler.lib;%(AdditionalDependencies)</AdditionalDependencies>
102102
<DelayLoadDLLs>d3d12.dll</DelayLoadDLLs>
103103
</Link>
104104
<CustomBuildStep>

Samples/Desktop/D3D12HelloWorld/src/HelloVADecode/D3D12HelloVADecode.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
<GenerateDebugInformation>true</GenerateDebugInformation>
109109
<EnableCOMDATFolding>true</EnableCOMDATFolding>
110110
<OptimizeReferences>true</OptimizeReferences>
111-
<AdditionalDependencies>d3d12.lib;dxgi.lib;%(AdditionalDependencies)</AdditionalDependencies>
111+
<AdditionalDependencies>d3d12.lib;dxgi.lib;va.lib;va_win32.lib;%(AdditionalDependencies)</AdditionalDependencies>
112112
<DelayLoadDLLs>d3d12.dll</DelayLoadDLLs>
113113
</Link>
114114
<CustomBuildStep>

Samples/Desktop/D3D12HelloWorld/src/HelloVAEncode/D3D12HelloVAEncode.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
<GenerateDebugInformation>true</GenerateDebugInformation>
109109
<EnableCOMDATFolding>true</EnableCOMDATFolding>
110110
<OptimizeReferences>true</OptimizeReferences>
111-
<AdditionalDependencies>d3d12.lib;dxgi.lib;%(AdditionalDependencies)</AdditionalDependencies>
111+
<AdditionalDependencies>d3d12.lib;dxgi.lib;va.lib;va_win32.lib;%(AdditionalDependencies)</AdditionalDependencies>
112112
<DelayLoadDLLs>d3d12.dll</DelayLoadDLLs>
113113
</Link>
114114
<CustomBuildStep>

Samples/Desktop/D3D12HelloWorld/src/HelloVAResourceInterop/D3D12HelloVAResourceInterop.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@
108108
<GenerateDebugInformation>true</GenerateDebugInformation>
109109
<EnableCOMDATFolding>true</EnableCOMDATFolding>
110110
<OptimizeReferences>true</OptimizeReferences>
111-
<AdditionalDependencies>d3d12.lib;dxgi.lib;%(AdditionalDependencies)</AdditionalDependencies>
111+
<AdditionalDependencies>d3d12.lib;dxgi.lib;va.lib;va_win32.lib;%(AdditionalDependencies)</AdditionalDependencies>
112112
<DelayLoadDLLs>d3d12.dll</DelayLoadDLLs>
113113
</Link>
114114
<CustomBuildStep>

Samples/Desktop/D3D12StateObjectDatabase/src/StateObjectDatabase Sample.vcxproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,12 @@
122122
<SDLCheck>true</SDLCheck>
123123
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
124124
<ConformanceMode>true</ConformanceMode>
125+
<AdditionalIncludeDirectories>$(OutDir)</AdditionalIncludeDirectories>
125126
</ClCompile>
126127
<Link>
127128
<SubSystem>Console</SubSystem>
128129
<GenerateDebugInformation>true</GenerateDebugInformation>
130+
<AdditionalDependencies>dxcompiler.lib;d3d12.lib;%(AdditionalDependencies)</AdditionalDependencies>
129131
</Link>
130132
</ItemDefinitionGroup>
131133
<ItemGroup>
@@ -276,6 +278,11 @@
276278
<HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(OutDir)\RayTracing.h</HeaderFileOutput>
277279
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Library</ShaderType>
278280
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">6.5</ShaderModel>
281+
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
282+
</EntryPointName>
283+
<ShaderType Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Library</ShaderType>
284+
<ShaderModel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">6.5</ShaderModel>
285+
<HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(OutDir)\RayTracing.h</HeaderFileOutput>
279286
</FxCompile>
280287
<FxCompile Include="RootSignaturePS.hlsl">
281288
<EntryPointName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">RootSignaturePS</EntryPointName>

Samples/Desktop/D3D12VariableRateShading/src/Common.hlsli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,6 @@ float4 CalcUnshadowedAmountPCF2x2(int lightIndex, float4 vPosWorld)
118118
vShadowDepths.w = shadowMap.Sample(sampleClamp, vShadowTexCoord + vTexelUnits).x;
119119
}
120120
// What weighted fraction of the 4 samples are nearer to the light than this pixel?
121-
float4 vShadowTests = (vShadowDepths >= vLightSpaceDepth) ? 1.0f : 0.0f;
121+
float4 vShadowTests = select(vShadowDepths >= vLightSpaceDepth, 1.0f, 0.0f);
122122
return dot(vBilinearWeights, vShadowTests);
123123
}

0 commit comments

Comments
 (0)