Skip to content

Commit

Permalink
Added draw commands for VK_EXT_mesh_shader
Browse files Browse the repository at this point in the history
  • Loading branch information
corporateshark committed Aug 18, 2024
1 parent bc59917 commit dd49983
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lvk/LVK.h
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,17 @@ class ICommandBuffer {
size_t countBufferOffset,
uint32_t maxDrawCount,
uint32_t stride = 0) = 0;
virtual void cmdDrawMeshTasks(const Dimensions& threadgroupCount) = 0;
virtual void cmdDrawMeshTasksIndirect(BufferHandle indirectBuffer,
size_t indirectBufferOffset,
uint32_t drawCount,
uint32_t stride = 0) = 0;
virtual void cmdDrawMeshTasksIndirectCount(BufferHandle indirectBuffer,
size_t indirectBufferOffset,
BufferHandle countBuffer,
size_t countBufferOffset,
uint32_t maxDrawCount,
uint32_t stride = 0) = 0;

virtual void cmdSetBlendColor(const float color[4]) = 0;
virtual void cmdSetDepthBias(float depthBias, float slopeScale, float clamp) = 0;
Expand Down
46 changes: 46 additions & 0 deletions lvk/vulkan/VulkanClasses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2325,6 +2325,52 @@ void lvk::CommandBuffer::cmdDrawIndexedIndirectCount(BufferHandle indirectBuffer
stride ? stride : sizeof(VkDrawIndexedIndirectCommand));
}

void lvk::CommandBuffer::cmdDrawMeshTasks(const Dimensions& threadgroupCount) {
LVK_PROFILER_FUNCTION();

vkCmdDrawMeshTasksEXT(wrapper_->cmdBuf_, threadgroupCount.width, threadgroupCount.height, threadgroupCount.depth);
}

void lvk::CommandBuffer::cmdDrawMeshTasksIndirect(BufferHandle indirectBuffer,
size_t indirectBufferOffset,
uint32_t drawCount,
uint32_t stride) {
LVK_PROFILER_FUNCTION();

lvk::VulkanBuffer* bufIndirect = ctx_->buffersPool_.get(indirectBuffer);

LVK_ASSERT(bufIndirect);

vkCmdDrawMeshTasksIndirectEXT(wrapper_->cmdBuf_,
bufIndirect->vkBuffer_,
indirectBufferOffset,
drawCount,
stride ? stride : sizeof(VkDrawMeshTasksIndirectCommandEXT));
}

void lvk::CommandBuffer::cmdDrawMeshTasksIndirectCount(BufferHandle indirectBuffer,
size_t indirectBufferOffset,
BufferHandle countBuffer,
size_t countBufferOffset,
uint32_t maxDrawCount,
uint32_t stride) {
LVK_PROFILER_FUNCTION();

lvk::VulkanBuffer* bufIndirect = ctx_->buffersPool_.get(indirectBuffer);
lvk::VulkanBuffer* bufCount = ctx_->buffersPool_.get(countBuffer);

LVK_ASSERT(bufIndirect);
LVK_ASSERT(bufCount);

vkCmdDrawMeshTasksIndirectCountEXT(wrapper_->cmdBuf_,
bufIndirect->vkBuffer_,
indirectBufferOffset,
bufCount->vkBuffer_,
countBufferOffset,
maxDrawCount,
stride ? stride : sizeof(VkDrawMeshTasksIndirectCommandEXT));
}

void lvk::CommandBuffer::cmdSetBlendColor(const float color[4]) {
vkCmdSetBlendConstants(wrapper_->cmdBuf_, color);
}
Expand Down
8 changes: 8 additions & 0 deletions lvk/vulkan/VulkanClasses.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,14 @@ class CommandBuffer final : public ICommandBuffer {
size_t countBufferOffset,
uint32_t maxDrawCount,
uint32_t stride = 0) override;
void cmdDrawMeshTasks(const Dimensions& threadgroupCount) override;
void cmdDrawMeshTasksIndirect(BufferHandle indirectBuffer, size_t indirectBufferOffset, uint32_t drawCount, uint32_t stride = 0) override;
void cmdDrawMeshTasksIndirectCount(BufferHandle indirectBuffer,
size_t indirectBufferOffset,
BufferHandle countBuffer,
size_t countBufferOffset,
uint32_t maxDrawCount,
uint32_t stride = 0) override;

void cmdSetBlendColor(const float color[4]) override;
void cmdSetDepthBias(float depthBias, float slopeScale, float clamp) override;
Expand Down

0 comments on commit dd49983

Please sign in to comment.