-
Notifications
You must be signed in to change notification settings - Fork 31
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
implemented indirect dispatch #66
Changes from 6 commits
bcdef6e
8d9f88e
0ad586c
7a49739
ef83032
eb74d55
8fdbfee
f5d3ce3
cbaeeb4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -360,6 +360,11 @@ void MtCommandBuffer::dispatch(size_t x, size_t y, size_t z) { | |
encComp->dispatchThreadgroups(MTL::Size(x,y,z), localSize); | ||
} | ||
|
||
void MtCommandBuffer::dispatchIndirect(const AbstractGraphicsApi::Buffer& indirect, size_t offset) { | ||
auto& ind = reinterpret_cast<const MtBuffer&>(indirect); | ||
encDraw->dispatchThreadgroups(ind.impl.get(), offset, localSize); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
} | ||
|
||
void MtCommandBuffer::implSetBytes(const void* bytes, size_t sz) { | ||
auto& mtl = curLay->bindPush; | ||
auto& l = curLay->pb; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -459,6 +459,17 @@ void VCommandBuffer::dispatch(size_t x, size_t y, size_t z) { | |
vkCmdDispatch(impl,uint32_t(x),uint32_t(y),uint32_t(z)); | ||
} | ||
|
||
void VCommandBuffer::dispatchIndirect(const AbstractGraphicsApi::Buffer& indirect, size_t offset) { | ||
const VBuffer& ind = reinterpret_cast<const VBuffer&>(indirect); | ||
|
||
curUniforms->ssboBarriers(resState, PipelineStage::S_Compute); | ||
// block future writers | ||
resState.onUavUsage(ind.nonUniqId, NonUniqResId::I_None, PipelineStage::S_Indirect); | ||
resState.flush(*this); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What barrier will be emitted, if buffer is in used by both shader and indirect argument? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created test that simulates this situation: Propably stupid question :) but does read-state here refer to the condition that previous memory accesses for the buffer are available and visible for reading (i.e. that required barrier exists)? My first thought was about some internal state in the engine but couldn't find it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean Basically in scenario
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added subsequent write access to the test, works fine: Despite clearing |
||
|
||
vkCmdDispatchIndirect(impl, ind.impl, VkDeviceSize(offset)); | ||
} | ||
|
||
void VCommandBuffer::setBytes(AbstractGraphicsApi::CompPipeline& p, const void* data, size_t size) { | ||
VCompPipeline& px=reinterpret_cast<VCompPipeline&>(p); | ||
assert(size<=px.pushSize); | ||
|
@@ -509,7 +520,7 @@ void VCommandBuffer::drawIndirect(const AbstractGraphicsApi::Buffer& indirect, s | |
const VBuffer& ind = reinterpret_cast<const VBuffer&>(indirect); | ||
|
||
// block future writers | ||
resState.onUavUsage(ind.nonUniqId, NonUniqResId::I_None, PipelineStage::S_Graphics); | ||
resState.onUavUsage(ind.nonUniqId, NonUniqResId::I_None, PipelineStage::S_Indirect); | ||
//resState.flush(*this); | ||
vkCmdDrawIndirect(impl, ind.impl, VkDeviceSize(offset), 1, 0); | ||
} | ||
|
@@ -522,7 +533,7 @@ void VCommandBuffer::dispatchMeshIndirect(const AbstractGraphicsApi::Buffer& ind | |
const VBuffer& ind = reinterpret_cast<const VBuffer&>(indirect); | ||
|
||
// block future writers | ||
resState.onUavUsage(ind.nonUniqId, NonUniqResId::I_None, PipelineStage::S_Graphics); | ||
resState.onUavUsage(ind.nonUniqId, NonUniqResId::I_None, PipelineStage::S_Indirect); | ||
//resState.flush(*this); | ||
device.vkCmdDrawMeshTasksIndirect(impl, ind.impl, VkDeviceSize(offset), 1, 0); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are 2 issues with this code:
onUavUsage
)