Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autodesk: WaitUntilCompleted on Metal #2794

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pxr/imaging/hgiMetal/computeCmds.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ class HgiMetalComputeCmds final : public HgiComputeCmds
id<MTLBuffer> _argumentBuffer;
id<MTLComputeCommandEncoder> _encoder;
bool _secondaryCommandBuffer;
bool _hasWork;
HgiComputeDispatch _dispatchMethod;
};

Expand Down
8 changes: 3 additions & 5 deletions pxr/imaging/hgiMetal/computeCmds.mm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
, _argumentBuffer(nil)
, _encoder(nil)
, _secondaryCommandBuffer(false)
, _hasWork(false)
, _dispatchMethod(desc.dispatchMethod)
{
_CreateEncoder();
Expand Down Expand Up @@ -152,7 +151,8 @@
threadsPerThreadgroup:MTLSizeMake(MIN(thread_width, dimX),
MIN(thread_height, dimY), 1)];

_hasWork = true;
if(!_secondaryCommandBuffer)
_hgi->SetHasWork();
_argumentBuffer = nil;
}

Expand Down Expand Up @@ -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) {
Expand All @@ -221,7 +219,7 @@
_commandBuffer = nil;
_argumentBuffer = nil;

return submittedWork;
return true;
}

HGIMETAL_API
Expand Down
1 change: 0 additions & 1 deletion pxr/imaging/hgiMetal/graphicsCmds.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 5 additions & 4 deletions pxr/imaging/hgiMetal/graphicsCmds.mm
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
, _primitiveIndexSize(0)
, _drawBufferBindingIndex(0)
, _debugLabel(nil)
, _hasWork(false)
, _viewportSet(false)
, _scissorRectSet(false)
, _enableParallelEncoder(false)
Expand Down Expand Up @@ -566,7 +565,7 @@
}
}

_hasWork = true;
_hgi->SetHasWork();
}

void
Expand Down Expand Up @@ -636,6 +635,7 @@
});
}
});
_hgi->SetHasWork();
}

void
Expand Down Expand Up @@ -685,7 +685,7 @@
baseInstance:baseInstance];
}

_hasWork = true;
_hgi->SetHasWork();
}

void
Expand Down Expand Up @@ -778,6 +778,7 @@
});
}
});
_hgi->SetHasWork();
}

void
Expand Down Expand Up @@ -875,7 +876,7 @@
_encoders.clear();
_CachedEncState.ResetCachedEncoderState();

return _hasWork;
return true;
}

PXR_NAMESPACE_CLOSE_SCOPE
2 changes: 2 additions & 0 deletions pxr/imaging/hgiMetal/hgi.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ class HgiMetal final : public Hgi
HGIMETAL_API
id<MTLBuffer> GetArgBuffer();

inline void SetHasWork() { _workToFlush = true; }

protected:
HGIMETAL_API
bool _SubmitCmds(HgiCmds* cmds, HgiSubmitWaitType wait) override;
Expand Down
2 changes: 1 addition & 1 deletion pxr/imaging/hgiMetal/hgi.mm
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@
TRACE_FUNCTION();

if (cmds) {
_workToFlush = Hgi::_SubmitCmds(cmds, wait);
Hgi::_SubmitCmds(cmds, wait);
if (cmds == _currentCmds) {
_currentCmds = nullptr;
}
Expand Down