diff options
author | Jason Ekstrand <[email protected]> | 2015-11-06 15:14:10 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-11-06 15:14:12 -0800 |
commit | 399d5314f679921f0e383171bb01a3d259b04754 (patch) | |
tree | 09b22a6ea79b1eab91be49b0f019c6b3d2c40613 /src/vulkan/anv_cmd_buffer.c | |
parent | 1b5c7e7ecd43d3526c0a6831ff6c1edfab4529af (diff) |
anv/cmd_buffer: Rework the way we emit UBO surface state
The new mechanism should be able to handle SSBOs as well as properly handle
emitting surface state on gen7 where we need different strides depending on
shader stage.
Diffstat (limited to 'src/vulkan/anv_cmd_buffer.c')
-rw-r--r-- | src/vulkan/anv_cmd_buffer.c | 43 |
1 files changed, 40 insertions, 3 deletions
diff --git a/src/vulkan/anv_cmd_buffer.c b/src/vulkan/anv_cmd_buffer.c index 77471941071..6763278c5ef 100644 --- a/src/vulkan/anv_cmd_buffer.c +++ b/src/vulkan/anv_cmd_buffer.c @@ -548,6 +548,41 @@ add_surface_state_reloc(struct anv_cmd_buffer *cmd_buffer, state.offset + dword * 4, bo, offset); } +static void +fill_descriptor_buffer_surface_state(struct anv_device *device, void *state, + VkShaderStage stage, VkDescriptorType type, + uint32_t offset, uint32_t range) +{ + VkFormat format; + uint32_t stride; + + switch (type) { + case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER: + case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC: + if (anv_is_scalar_shader_stage(device->instance->physicalDevice.compiler, + stage)) { + stride = 4; + } else { + stride = 16; + } + format = VK_FORMAT_R32G32B32A32_SFLOAT; + break; + + case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER: + case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC: + stride = 1; + format = VK_FORMAT_UNDEFINED; + break; + + default: + unreachable("Invalid descriptor type"); + } + + anv_fill_buffer_surface_state(device, state, + anv_format_for_vk_format(format), + offset, range, stride); +} + VkResult anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer, VkShaderStage stage, struct anv_state *bt_state) @@ -623,9 +658,11 @@ anv_cmd_buffer_emit_binding_table(struct anv_cmd_buffer *cmd_buffer, surface_state = anv_cmd_buffer_alloc_surface_state(cmd_buffer); - anv_fill_buffer_surface_state(cmd_buffer->device, surface_state.map, - anv_format_for_vk_format(VK_FORMAT_R32G32B32A32_SFLOAT), - bo_offset, desc->range); + + fill_descriptor_buffer_surface_state(cmd_buffer->device, + surface_state.map, + stage, desc->type, + bo_offset, desc->range); break; } |