diff --git a/pxr/imaging/hgiMetal/computeCmds.h b/pxr/imaging/hgiMetal/computeCmds.h index 41a5cdad1d..64fde0fcf2 100644 --- a/pxr/imaging/hgiMetal/computeCmds.h +++ b/pxr/imaging/hgiMetal/computeCmds.h @@ -101,7 +101,6 @@ class HgiMetalComputeCmds final : public HgiComputeCmds id _argumentBuffer; id _encoder; bool _secondaryCommandBuffer; - bool _hasWork; HgiComputeDispatch _dispatchMethod; }; diff --git a/pxr/imaging/hgiMetal/computeCmds.mm b/pxr/imaging/hgiMetal/computeCmds.mm index c7713ff494..d501e578fa 100644 --- a/pxr/imaging/hgiMetal/computeCmds.mm +++ b/pxr/imaging/hgiMetal/computeCmds.mm @@ -44,7 +44,6 @@ , _argumentBuffer(nil) , _encoder(nil) , _secondaryCommandBuffer(false) - , _hasWork(false) , _dispatchMethod(desc.dispatchMethod) { _CreateEncoder(); @@ -152,7 +151,8 @@ threadsPerThreadgroup:MTLSizeMake(MIN(thread_width, dimX), MIN(thread_height, dimY), 1)]; - _hasWork = true; + if(!_secondaryCommandBuffer) + _hgi->SetHasWork(); _argumentBuffer = nil; } @@ -191,11 +191,9 @@ bool HgiMetalComputeCmds::_Submit(Hgi* hgi, HgiSubmitWaitType wait) { - bool submittedWork = false; if (_encoder) { [_encoder endEncoding]; _encoder = nil; - submittedWork = true; HgiMetal::CommitCommandBufferWaitType waitType; switch(wait) { @@ -221,7 +219,7 @@ _commandBuffer = nil; _argumentBuffer = nil; - return submittedWork; + return true; } HGIMETAL_API diff --git a/pxr/imaging/hgiMetal/graphicsCmds.h b/pxr/imaging/hgiMetal/graphicsCmds.h index 8694387c07..e9a6db5348 100644 --- a/pxr/imaging/hgiMetal/graphicsCmds.h +++ b/pxr/imaging/hgiMetal/graphicsCmds.h @@ -170,7 +170,6 @@ class HgiMetalGraphicsCmds final : public HgiGraphicsCmds uint32_t _primitiveIndexSize; uint32_t _drawBufferBindingIndex; NSString* _debugLabel; - bool _hasWork; bool _viewportSet; bool _scissorRectSet; bool _enableParallelEncoder; diff --git a/pxr/imaging/hgiMetal/graphicsCmds.mm b/pxr/imaging/hgiMetal/graphicsCmds.mm index ce64a298f5..4c8411b314 100644 --- a/pxr/imaging/hgiMetal/graphicsCmds.mm +++ b/pxr/imaging/hgiMetal/graphicsCmds.mm @@ -85,7 +85,6 @@ , _primitiveIndexSize(0) , _drawBufferBindingIndex(0) , _debugLabel(nil) - , _hasWork(false) , _viewportSet(false) , _scissorRectSet(false) , _enableParallelEncoder(false) @@ -566,7 +565,7 @@ } } - _hasWork = true; + _hgi->SetHasWork(); } void @@ -636,6 +635,7 @@ }); } }); + _hgi->SetHasWork(); } void @@ -685,7 +685,7 @@ baseInstance:baseInstance]; } - _hasWork = true; + _hgi->SetHasWork(); } void @@ -778,6 +778,7 @@ }); } }); + _hgi->SetHasWork(); } void @@ -875,7 +876,7 @@ _encoders.clear(); _CachedEncState.ResetCachedEncoderState(); - return _hasWork; + return true; } PXR_NAMESPACE_CLOSE_SCOPE diff --git a/pxr/imaging/hgiMetal/hgi.h b/pxr/imaging/hgiMetal/hgi.h index 2655c9d50a..a69fcf0150 100644 --- a/pxr/imaging/hgiMetal/hgi.h +++ b/pxr/imaging/hgiMetal/hgi.h @@ -204,6 +204,8 @@ class HgiMetal final : public Hgi HGIMETAL_API id GetArgBuffer(); + inline void SetHasWork() { _workToFlush = true; } + protected: HGIMETAL_API bool _SubmitCmds(HgiCmds* cmds, HgiSubmitWaitType wait) override; diff --git a/pxr/imaging/hgiMetal/hgi.mm b/pxr/imaging/hgiMetal/hgi.mm index 9f7e64cd9d..423225386b 100644 --- a/pxr/imaging/hgiMetal/hgi.mm +++ b/pxr/imaging/hgiMetal/hgi.mm @@ -515,7 +515,7 @@ TRACE_FUNCTION(); if (cmds) { - _workToFlush = Hgi::_SubmitCmds(cmds, wait); + Hgi::_SubmitCmds(cmds, wait); if (cmds == _currentCmds) { _currentCmds = nullptr; }