@@ -157,9 +157,14 @@ static BufferUsage bufferUsageFromResourceKind(ResourceKind Kind) {
157157 case ResourceKind::ConstantBuffer:
158158 return BufferUsage::ConstantBuffer;
159159 break ;
160- default :
160+ case ResourceKind::Texture2D:
161+ case ResourceKind::RWTexture2D:
162+ case ResourceKind::Sampler:
163+ case ResourceKind::SampledTexture2D:
164+ case ResourceKind::AccelerationStructure:
161165 llvm_unreachable (" Invalid case, ResourceKind is not a buffer." );
162166 }
167+ llvm_unreachable (" All ResourceKind cases handled" );
163168}
164169
165170static BufferShaderAccessType bufferShaderAccessTypeFromResourceKind (
@@ -186,10 +191,15 @@ static BufferShaderAccessType bufferShaderAccessTypeFromResourceKind(
186191 case ResourceKind::RWByteAddressBuffer:
187192 case ResourceKind::ConstantBuffer:
188193 return BufferShaderAccessType::Raw;
189- default :
194+ case ResourceKind::Texture2D:
195+ case ResourceKind::RWTexture2D:
196+ case ResourceKind::Sampler:
197+ case ResourceKind::SampledTexture2D:
198+ case ResourceKind::AccelerationStructure:
190199 llvm_unreachable (
191200 " Invalid case, non-buffers should have been filtered out." );
192201 }
202+ llvm_unreachable (" All ResourceKind cases handled" );
193203}
194204
195205namespace {
@@ -596,28 +606,30 @@ class DXCommandBuffer : public offloadtest::CommandBuffer {
596606 D3D12_RESOURCE_STATES StateBefore,
597607 D3D12_RESOURCE_STATES StateAfter) {
598608
599- for (size_t I = 0 , N = PendingTransitions.size (); I < N; ++I) {
600- auto &Trans = PendingTransitions[I];
601- if (Trans.Transition .pResource == Resource) {
602- assert (StateBefore == Trans.Transition .StateAfter );
603-
604- if (StateAfter == Trans.Transition .StateBefore ) {
605- // We actually need the resource to be in the original state!
606- // Remove the transition from the list of Pending Transitions.
607- PendingTransitions.erase (PendingTransitions.begin () + I);
608-
609- // NOTE: This could cause an execution barrier issue since legacy
610- // barriers don't allow us to express execution barriers, cache
611- // flushes, and layout transitions separately.
612- // As a workaround we add a UAV barrier so an execution barrier and
613- // cache flush is inserted.
614- addPendingUAVBarrier ();
615- } else {
616- Trans.Transition .StateAfter = StateAfter;
617- }
609+ for (auto TransIt = PendingTransitions.begin (),
610+ End = PendingTransitions.end ();
611+ TransIt != End; ++TransIt) {
612+ if (TransIt->Transition .pResource != Resource)
613+ continue ;
614+
615+ assert (StateBefore == TransIt->Transition .StateAfter );
618616
619- return ;
617+ if (StateAfter == TransIt->Transition .StateBefore ) {
618+ // We actually need the resource to be in the original state!
619+ // Remove the transition from the list of Pending Transitions.
620+ PendingTransitions.erase (TransIt);
621+
622+ // NOTE: This could cause an execution barrier issue since legacy
623+ // barriers don't allow us to express execution barriers, cache
624+ // flushes, and layout transitions separately.
625+ // As a workaround we add a UAV barrier so an execution barrier and
626+ // cache flush is inserted.
627+ addPendingUAVBarrier ();
628+ } else {
629+ TransIt->Transition .StateAfter = StateAfter;
620630 }
631+
632+ return ;
621633 }
622634
623635 PendingTransitions.push_back (CD3DX12_RESOURCE_BARRIER::Transition (
@@ -1895,7 +1907,7 @@ class DXDevice : public offloadtest::Device {
18951907 Tex->DSVHandle );
18961908 }
18971909
1898- return std::move ( Tex) ;
1910+ return Tex;
18991911 }
19001912
19011913 uint32_t getTextureUploadRowStrideInBytes (
@@ -2577,7 +2589,9 @@ class DXDevice : public offloadtest::Device {
25772589 std::errc::value_too_large,
25782590 " Root descriptor cannot refer to resource arrays." );
25792591
2580- if (!RootDescIt->second .back ().Buffer ) {
2592+ const DXBuffer *BufferDX =
2593+ llvm::cast_if_present<DXBuffer>(RootDescIt->second .back ().Buffer );
2594+ if (!BufferDX) {
25812595 return llvm::createStringError (
25822596 std::errc::value_too_large,
25832597 " Root descriptor can only refer to buffers." );
@@ -2586,7 +2600,7 @@ class DXDevice : public offloadtest::Device {
25862600 const auto &BufferDX =
25872601 llvm::cast<DXBuffer>(*RootDescIt->second .back ().Buffer );
25882602 const D3D12_GPU_VIRTUAL_ADDRESS VirtualAddress =
2589- BufferDX. Buffer ->GetGPUVirtualAddress ();
2603+ BufferDX-> Buffer ->GetGPUVirtualAddress ();
25902604 switch (getDescriptorKind (RootDescIt->first ->Kind )) {
25912605 case DescriptorKind::SRV :
25922606 IS .CB ->CmdList ->SetComputeRootShaderResourceView (RootParamIndex++,
0 commit comments