Commit 02407743 by James Dong Committed by Commit Bot

Vulkan: implement indirect dispatch

Implements indirect dispatch for Vulkan backend. Layout of dispatch structure is the same as OpenGL, so we pass in the buffer directly. Test: ./angle_deqp_gles31_no_gtest --deqp-egl-display-type=angle-vulkan -n 'dEQP-GLES31.functional.compute.indirect_dispatch.*' Bug: angleproject:3601 Change-Id: I94c6b1a86d3c24c1ca1bb6a78529b38909a2b91f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1710024Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: James Dong <dongja@google.com>
parent cedea1d9
......@@ -2005,8 +2005,16 @@ angle::Result ContextVk::dispatchCompute(const gl::Context *context,
angle::Result ContextVk::dispatchComputeIndirect(const gl::Context *context, GLintptr indirect)
{
ANGLE_VK_UNREACHABLE(this);
return angle::Result::Stop;
vk::CommandBuffer *commandBuffer;
ANGLE_TRY(setupDispatch(context, &commandBuffer));
gl::Buffer *glBuffer = getState().getTargetBuffer(gl::BufferBinding::DispatchIndirect);
vk::BufferHelper &buffer = vk::GetImpl(glBuffer)->getBuffer();
buffer.onRead(&mDispatcher, VK_ACCESS_INDIRECT_COMMAND_READ_BIT);
commandBuffer->dispatchIndirect(buffer.getBuffer(), indirect);
return angle::Result::Continue;
}
angle::Result ContextVk::memoryBarrier(const gl::Context *context, GLbitfield barriers)
......
......@@ -160,6 +160,13 @@ void SecondaryCommandBuffer::executeCommands(VkCommandBuffer cmdBuffer)
params->groupCountZ);
break;
}
case CommandID::DispatchIndirect:
{
const DispatchIndirectParams *params =
getParamPtr<DispatchIndirectParams>(currentCommand);
vkCmdDispatchIndirect(cmdBuffer, params->buffer, params->offset);
break;
}
case CommandID::Draw:
{
const DrawParams *params = getParamPtr<DrawParams>(currentCommand);
......
......@@ -44,6 +44,7 @@ enum class CommandID : uint16_t
CopyImage,
CopyImageToBuffer,
Dispatch,
DispatchIndirect,
Draw,
DrawIndexed,
DrawIndexedInstanced,
......@@ -216,6 +217,13 @@ struct DispatchParams
};
VERIFY_4_BYTE_ALIGNMENT(DispatchParams)
struct DispatchIndirectParams
{
VkBuffer buffer;
VkDeviceSize offset;
};
VERIFY_4_BYTE_ALIGNMENT(DispatchIndirectParams)
struct FillBufferParams
{
VkBuffer dstBuffer;
......@@ -428,6 +436,8 @@ class SecondaryCommandBuffer final : angle::NonCopyable
void dispatch(uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ);
void dispatchIndirect(const Buffer &buffer, VkDeviceSize offset);
void draw(uint32_t vertexCount, uint32_t firstVertex);
void drawIndexed(uint32_t indexCount);
......@@ -830,6 +840,15 @@ ANGLE_INLINE void SecondaryCommandBuffer::dispatch(uint32_t groupCountX,
paramStruct->groupCountZ = groupCountZ;
}
ANGLE_INLINE void SecondaryCommandBuffer::dispatchIndirect(const Buffer &buffer,
VkDeviceSize offset)
{
DispatchIndirectParams *paramStruct =
initCommand<DispatchIndirectParams>(CommandID::DispatchIndirect);
paramStruct->buffer = buffer.getHandle();
paramStruct->offset = offset;
}
ANGLE_INLINE void SecondaryCommandBuffer::draw(uint32_t vertexCount, uint32_t firstVertex)
{
DrawParams *paramStruct = initCommand<DrawParams>(CommandID::Draw);
......
......@@ -266,6 +266,7 @@ class CommandBuffer : public WrappedObject<CommandBuffer, VkCommandBuffer>
const VkImageCopy *regions);
void dispatch(uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ);
void dispatchIndirect(const Buffer &buffer, VkDeviceSize offset);
void draw(uint32_t vertexCount,
uint32_t instanceCount,
......@@ -944,6 +945,12 @@ ANGLE_INLINE void CommandBuffer::dispatch(uint32_t groupCountX,
vkCmdDispatch(mHandle, groupCountX, groupCountY, groupCountZ);
}
ANGLE_INLINE void CommandBuffer::dispatchIndirect(const Buffer &buffer, VkDeviceSize offset)
{
ASSERT(valid());
vkCmdDispatchIndirect(mHandle, buffer.getHandle(), offset);
}
ANGLE_INLINE void CommandBuffer::bindPipeline(VkPipelineBindPoint pipelineBindPoint,
const Pipeline &pipeline)
{
......
......@@ -632,9 +632,6 @@
3520 VULKAN : dEQP-GLES31.functional.program_interface_query.program_*.resource_list.compute.empty = FAIL
3520 VULKAN : dEQP-GLES31.functional.program_interface_query.shader_storage_block.buffer_data_size.* = FAIL
// Indirect dispatch:
3601 VULKAN : dEQP-GLES31.functional.compute.*indirect* = SKIP
// Shader support:
3569 VULKAN : dEQP-GLES31.functional.shaders.builtin_functions.common.frexp.* = FAIL
3569 VULKAN : dEQP-GLES31.functional.shaders.builtin_functions.common.ldexp.* = FAIL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment