Skip to content

Commit

Permalink
MSL: drawIndirect
Browse files Browse the repository at this point in the history
  • Loading branch information
Try committed Feb 1, 2024
1 parent 2eaff16 commit e49b226
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Engine/gapi/metal/mtcommandbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,11 @@ void MtCommandBuffer::drawIndexed(const AbstractGraphicsApi::Buffer& ivbo, size_
ioffset*mul,instanceCount,voffset,firstInstance);
}

void MtCommandBuffer::drawIndirect(const AbstractGraphicsApi::Buffer& indirect, size_t offset) {
auto& ind = reinterpret_cast<const MtBuffer&>(indirect);
encDraw->drawPrimitives(topology, ind.impl.get(), offset);
}

void MtCommandBuffer::dispatchMesh(size_t x, size_t y, size_t z) {
// NOTE: for taskless pipeline `localSize` must be zero
encDraw->drawMeshThreadgroups(MTL::Size(x,y,z), localSize, localSizeMesh);
Expand Down
3 changes: 3 additions & 0 deletions Engine/gapi/metal/mtcommandbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class MtCommandBuffer : public AbstractGraphicsApi::CommandBuffer {
void drawIndexed (const AbstractGraphicsApi::Buffer& vbo, size_t stride, size_t voffset,
const AbstractGraphicsApi::Buffer &ibo, Detail::IndexClass cls,
size_t ioffset, size_t isize, size_t firstInstance, size_t instanceCount) override;

void drawIndirect(const AbstractGraphicsApi::Buffer& indirect, size_t offset) override;

void dispatchMesh(size_t x, size_t y, size_t z) override;
void dispatch (size_t x, size_t y, size_t z) override;

Expand Down
2 changes: 2 additions & 0 deletions Engine/gapi/metal/mtdescriptorarray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ void MtDescriptorArray::set(size_t id, AbstractGraphicsApi::Texture** tex, size_

std::unique_ptr<uint8_t[]> addr(new uint8_t[bufSz]);
d.args.reserve(cnt);
d.args.clear();
for(size_t i=0; i<cnt; ++i) {
auto* ptr = reinterpret_cast<MTL::ResourceID*>(addr.get());
if(tex[i]==nullptr) {
Expand Down Expand Up @@ -91,6 +92,7 @@ void MtDescriptorArray::set(size_t id, AbstractGraphicsApi::Buffer** buf, size_t

std::unique_ptr<spvBufferDescriptor[]> addr(new spvBufferDescriptor[cnt]);
d.args.reserve(cnt);
d.args.clear();
for(size_t i=0; i<cnt; ++i) {
if(buf[i]==nullptr) {
addr[i].ptr = 0;
Expand Down

0 comments on commit e49b226

Please sign in to comment.