Skip to content

Commit e1f8c6a

Browse files
author
Greg Roth
authored
Correctly copy to resource_desc1 in rawgather test (#4467)
The previous approach was assigning garbage to the final field of desc1 due to alignment padding in desc0 where that field would be. This just duplicates the utility function behavior to copy one desc to the new one
1 parent 6f1d6d9 commit e1f8c6a

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

tools/clang/unittests/HLSL/ExecutionTest.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,23 @@ class ExecutionTest {
908908
}
909909
}
910910

911+
#if defined(NTDDI_WIN10_CU) && WDK_NTDDI_VERSION >= NTDDI_WIN10_CU
912+
// Copy common fields from desc0 to desc1 and zero out the new one
913+
void CopyDesc0ToDesc1(D3D12_RESOURCE_DESC1 &desc1, const D3D12_RESOURCE_DESC1 &desc0) {
914+
desc1.Dimension = desc0.Dimension;
915+
desc1.Alignment = desc0.Alignment;
916+
desc1.Width = desc0.Width;
917+
desc1.Height = desc0.Height;
918+
desc1.DepthOrArraySize = desc0.DepthOrArraySize;
919+
desc1.MipLevels = desc0.MipLevels;
920+
desc1.Format = desc0.Format;
921+
desc1.SampleDesc = desc0.SampleDesc;
922+
desc1.Layout = desc0.Layout;
923+
desc1.Flags = desc0.Flags;
924+
desc1.SamplerFeedbackMipRegion = {};
925+
}
926+
#endif
927+
911928
// Create resources for the given <resDesc> described main resource
912929
// creating and returning the resource, the upload resource,
913930
// and the readback resource if requested, populating with <values> of size
@@ -939,7 +956,7 @@ class ExecutionTest {
939956
CComPtr<ID3D12Device10> pDevice10;
940957
// Copy resDesc0 to resDesc1 zeroing anything new
941958
D3D12_RESOURCE_DESC1 resDesc1 = {0};
942-
memcpy(&resDesc1, &resDesc, sizeof(resDesc));
959+
CopyDesc0ToDesc1(resDesc1, resDesc) {
943960
VERIFY_SUCCEEDED(pDevice->QueryInterface(IID_PPV_ARGS(&pDevice10)));
944961
VERIFY_SUCCEEDED(pDevice10->CreateCommittedResource3(
945962
&defaultHeapProperties,
@@ -4634,7 +4651,7 @@ void ExecutionTest::DoRawGatherTest(ID3D12Device *pDevice, RawGatherTexture *raw
46344651
for (UINT y = 0; y < yDim; y++)
46354652
for (UINT x = 0; x < xDim; x++)
46364653
rawTex->SetElement(ix++, x, y);
4637-
D3D12_RESOURCE_DESC tex2dDesc = CD3DX12_RESOURCE_DESC::Tex2D(resFormat, xDim, yDim);
4654+
D3D12_RESOURCE_DESC tex2dDesc = CD3DX12_RESOURCE_DESC::Tex2D(resFormat, xDim, yDim, 1/* sampCt */, 1/* mipCt */);
46384655

46394656
CreateTestResources(pDevice, pCommandList, rawTex->GetElements(), valueSizeInBytes, tex2dDesc,
46404657
&pTexResource, &pTexUploadResource,

0 commit comments

Comments
 (0)