@@ -2676,8 +2676,8 @@ template <typename ContextInternalState> class MTLD3D11DeviceContextImplBase : p
26762676
26772677 auto &SRVs = state_.ShaderStages [Stage].SRVs ;
26782678
2679- // TODO: iterate _hazard_ set rather than _bound_ set (former is a subset)
2680- for ( const auto & [Slot, Bound] : SRVs) {
2679+ for ( auto it = SRVs. hazard_begin (); it != SRVs. hazard_end (); it++) {
2680+ const auto & [Slot, Bound] = *it;
26812681 if (CheckOverlap (Bound.SRV .ptr (), pViewOrBuffer)) {
26822682 if (SRVs.unbind (Slot)) {
26832683 EmitST ([=](ArgumentEncodingContext& enc) {
@@ -2710,8 +2710,9 @@ template <typename ContextInternalState> class MTLD3D11DeviceContextImplBase : p
27102710 }
27112711
27122712 if (pViewOrBuffer->bindFlags () & D3D11_BIND_VERTEX_BUFFER) {
2713- // TODO: iterate _hazard_ set rather than _bound_ set (former is a subset)
2714- for (const auto &[Slot, Bound] : state_.InputAssembler .VertexBuffers ) {
2713+ for (auto it = state_.InputAssembler .VertexBuffers .hazard_begin ();
2714+ it != state_.InputAssembler .VertexBuffers .hazard_end (); it++) {
2715+ const auto &[Slot, Bound] = *it;
27152716 if (CheckOverlap (Bound.Buffer .ptr (), pViewOrBuffer)) {
27162717 if (state_.InputAssembler .VertexBuffers .unbind (Slot)) {
27172718 EmitST ([=](ArgumentEncodingContext &enc) { enc.bindVertexBuffer (Slot, 0 , 0 , {}); });
@@ -3492,7 +3493,7 @@ template <typename ContextInternalState> class MTLD3D11DeviceContextImplBase : p
34923493 auto pView = static_cast <D3D11ShaderResourceView *>(ppShaderResourceViews[slot - StartSlot]);
34933494 if (pView && ValidateSRVHazard<Stage>(pView)) {
34943495 bool replaced = false ;
3495- auto &entry = ShaderStage.SRVs .bind (slot, {pView}, replaced);
3496+ auto &entry = ShaderStage.SRVs .bind (slot, {pView}, replaced, !pView-> hazardsFree () );
34963497 if (!replaced)
34973498 continue ;
34983499 entry.SRV = pView;
@@ -3641,7 +3642,7 @@ template <typename ContextInternalState> class MTLD3D11DeviceContextImplBase : p
36413642 auto pVertexBuffer = reinterpret_cast <D3D11ResourceCommon *>(ppVertexBuffers[slot - StartSlot]);
36423643 if (pVertexBuffer && (pVertexBuffer->bindFlags () & D3D11_BIND_VERTEX_BUFFER) && ValidateIAHazard (pVertexBuffer)) {
36433644 bool replaced = false ;
3644- auto &entry = VertexBuffers.bind (slot, {pVertexBuffer}, replaced);
3645+ auto &entry = VertexBuffers.bind (slot, {pVertexBuffer}, replaced, !pVertexBuffer-> hazardsFree () );
36453646 if (!replaced) {
36463647 if (pStrides && pStrides[slot - StartSlot] != entry.Stride ) {
36473648 VertexBuffers.set_dirty (slot);
0 commit comments