Makes sure to zero-init D3D12 descriptors for cache keys.
Fixed: dawn:1471
Change-Id: I2692d3caa9b0d4dabe473b7a7d5249473da80c5b
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/99600
Auto-Submit: Loko Kung <lokokung@google.com>
Commit-Queue: Austin Eng <enga@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/src/dawn/native/d3d12/RenderPipelineD3D12.cpp b/src/dawn/native/d3d12/RenderPipelineD3D12.cpp
index e33d19f..b1da726 100644
--- a/src/dawn/native/d3d12/RenderPipelineD3D12.cpp
+++ b/src/dawn/native/d3d12/RenderPipelineD3D12.cpp
@@ -235,7 +235,7 @@
}
D3D12_RENDER_TARGET_BLEND_DESC ComputeColorDesc(const ColorTargetState* state) {
- D3D12_RENDER_TARGET_BLEND_DESC blendDesc;
+ D3D12_RENDER_TARGET_BLEND_DESC blendDesc = {};
blendDesc.BlendEnable = state->blend != nullptr;
if (blendDesc.BlendEnable) {
blendDesc.SrcBlend = D3D12Blend(state->blend->color.srcFactor);
@@ -273,7 +273,7 @@
}
D3D12_DEPTH_STENCILOP_DESC StencilOpDesc(const StencilFaceState& descriptor) {
- D3D12_DEPTH_STENCILOP_DESC desc;
+ D3D12_DEPTH_STENCILOP_DESC desc = {};
desc.StencilFailOp = StencilOp(descriptor.failOp);
desc.StencilDepthFailOp = StencilOp(descriptor.depthFailOp);
@@ -284,23 +284,23 @@
}
D3D12_DEPTH_STENCIL_DESC ComputeDepthStencilDesc(const DepthStencilState* descriptor) {
- D3D12_DEPTH_STENCIL_DESC mDepthStencilDescriptor;
- mDepthStencilDescriptor.DepthEnable =
+ D3D12_DEPTH_STENCIL_DESC depthStencilDescriptor = {};
+ depthStencilDescriptor.DepthEnable =
(descriptor->depthCompare == wgpu::CompareFunction::Always &&
!descriptor->depthWriteEnabled)
? FALSE
: TRUE;
- mDepthStencilDescriptor.DepthWriteMask =
+ depthStencilDescriptor.DepthWriteMask =
descriptor->depthWriteEnabled ? D3D12_DEPTH_WRITE_MASK_ALL : D3D12_DEPTH_WRITE_MASK_ZERO;
- mDepthStencilDescriptor.DepthFunc = ToD3D12ComparisonFunc(descriptor->depthCompare);
+ depthStencilDescriptor.DepthFunc = ToD3D12ComparisonFunc(descriptor->depthCompare);
- mDepthStencilDescriptor.StencilEnable = StencilTestEnabled(descriptor) ? TRUE : FALSE;
- mDepthStencilDescriptor.StencilReadMask = static_cast<UINT8>(descriptor->stencilReadMask);
- mDepthStencilDescriptor.StencilWriteMask = static_cast<UINT8>(descriptor->stencilWriteMask);
+ depthStencilDescriptor.StencilEnable = StencilTestEnabled(descriptor) ? TRUE : FALSE;
+ depthStencilDescriptor.StencilReadMask = static_cast<UINT8>(descriptor->stencilReadMask);
+ depthStencilDescriptor.StencilWriteMask = static_cast<UINT8>(descriptor->stencilWriteMask);
- mDepthStencilDescriptor.FrontFace = StencilOpDesc(descriptor->stencilFront);
- mDepthStencilDescriptor.BackFace = StencilOpDesc(descriptor->stencilBack);
- return mDepthStencilDescriptor;
+ depthStencilDescriptor.FrontFace = StencilOpDesc(descriptor->stencilFront);
+ depthStencilDescriptor.BackFace = StencilOpDesc(descriptor->stencilBack);
+ return depthStencilDescriptor;
}
D3D12_INDEX_BUFFER_STRIP_CUT_VALUE ComputeIndexBufferStripCutValue(
@@ -402,9 +402,6 @@
static_assert(kMaxColorAttachments == 8);
for (uint8_t i = 0; i < kMaxColorAttachments; i++) {
descriptorD3D12.RTVFormats[i] = DXGI_FORMAT_UNKNOWN;
- descriptorD3D12.BlendState.RenderTarget[i].BlendEnable = false;
- descriptorD3D12.BlendState.RenderTarget[i].RenderTargetWriteMask = 0;
- descriptorD3D12.BlendState.RenderTarget[i].LogicOpEnable = false;
descriptorD3D12.BlendState.RenderTarget[i].LogicOp = D3D12_LOGIC_OP_NOOP;
}
ColorAttachmentIndex highestColorAttachmentIndexPlusOne =