Skip to content

Commit 54d31d7

Browse files
committed
Clean up the for loop
1 parent 88a2b0f commit 54d31d7

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

tools/clang/unittests/HLSLExec/LongVectors.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,6 @@ void configureLoadAndStoreShaderOp(const Operation &Operation,
477477

478478
DXASSERT_NOMSG(LoadAndStoreOpTypes.count(Operation.Type) > 0);
479479

480-
const bool IsSB = IsStructuredBufferLoadAndStoreOp(Operation.Type);
481-
482480
st::ShaderOp *ShaderOp = ShaderOpSet->GetShaderOp(Operation.ShaderName);
483481
DXASSERT(ShaderOp, "Invalid ShaderOp name");
484482

@@ -490,28 +488,32 @@ void configureLoadAndStoreShaderOp(const Operation &Operation,
490488
UINT StructureByteStride = static_cast<UINT>(ElementSize * VectorSize);
491489
StructureByteStride = (StructureByteStride + 3) & ~3; // Must align to 4 bytes
492490

491+
const bool IsSB = IsStructuredBufferLoadAndStoreOp(Operation.Type);
493492
if (!ShaderOp->DescriptorHeaps.empty()) {
494493
DXASSERT(ShaderOp->DescriptorHeaps.size() == 1,
495-
""
496494
"Programmer error: Expecting a single descriptor heap for "
497495
"LoadAndStore tests");
498496

499497
for (auto &D : ShaderOp->DescriptorHeaps[0].Descriptors) {
500-
if (_stricmp(D.Kind, "UAV") == 0) {
501-
if (IsSB) {
498+
const bool IsUAV = (_stricmp(D.Kind, "UAV") == 0);
499+
DXASSERT(IsUAV || (_stricmp(D.Kind, "SRV") == 0),
500+
"Programmer error: Expecting UAV or SRV descriptors only");
501+
502+
if (IsSB) {
503+
if (IsUAV) {
502504
D.UavDesc.Format = DXGI_FORMAT_UNKNOWN;
503505
D.UavDesc.Buffer.NumElements = 1; // One StructuredBuffer
504506
D.UavDesc.Buffer.StructureByteStride = StructureByteStride;
505507
} else {
506-
D.UavDesc.Format = DXGI_FORMAT_R32_TYPELESS;
507-
D.UavDesc.Buffer.NumElements = Num32BitElements;
508-
D.UavDesc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_RAW;
509-
}
510-
} else if (_stricmp(D.Kind, "SRV") == 0) {
511-
if (IsSB) {
512508
D.SrvDesc.Format = DXGI_FORMAT_UNKNOWN;
513509
D.SrvDesc.Buffer.NumElements = 1; // One StructuredBuffer
514510
D.SrvDesc.Buffer.StructureByteStride = StructureByteStride;
511+
}
512+
} else { // Raw buffer
513+
if (IsUAV) {
514+
D.UavDesc.Format = DXGI_FORMAT_R32_TYPELESS;
515+
D.UavDesc.Buffer.NumElements = Num32BitElements;
516+
D.UavDesc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_RAW;
515517
} else {
516518
D.SrvDesc.Format = DXGI_FORMAT_R32_TYPELESS;
517519
D.SrvDesc.Buffer.NumElements = Num32BitElements;

0 commit comments

Comments
 (0)