diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/vulkan/anv_cmd_buffer.c | 43 | ||||
-rw-r--r-- | src/vulkan/anv_device.c | 6 | ||||
-rw-r--r-- | src/vulkan/anv_private.h | 9 | ||||
-rw-r--r-- | src/vulkan/gen7_state.c | 8 | ||||
-rw-r--r-- | src/vulkan/gen8_state.c | 4 |
5 files changed, 51 insertions, 19 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; } diff --git a/src/vulkan/anv_device.c b/src/vulkan/anv_device.c index dcb3ef20115..a4b58caab13 100644 --- a/src/vulkan/anv_device.c +++ b/src/vulkan/anv_device.c @@ -1415,14 +1415,14 @@ void anv_DestroyBuffer( void anv_fill_buffer_surface_state(struct anv_device *device, void *state, const struct anv_format *format, - uint32_t offset, uint32_t range) + uint32_t offset, uint32_t range, uint32_t stride) { switch (device->info.gen) { case 7: - gen7_fill_buffer_surface_state(state, format, offset, range); + gen7_fill_buffer_surface_state(state, format, offset, range, stride); break; case 8: - gen8_fill_buffer_surface_state(state, format, offset, range); + gen8_fill_buffer_surface_state(state, format, offset, range, stride); break; default: unreachable("unsupported gen\n"); diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index 631b92cf267..500904713a6 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -1361,12 +1361,15 @@ gen8_image_view_init(struct anv_image_view *iview, void anv_fill_buffer_surface_state(struct anv_device *device, void *state, const struct anv_format *format, - uint32_t offset, uint32_t range); + uint32_t offset, uint32_t range, + uint32_t stride); void gen7_fill_buffer_surface_state(void *state, const struct anv_format *format, - uint32_t offset, uint32_t range); + uint32_t offset, uint32_t range, + uint32_t stride); void gen8_fill_buffer_surface_state(void *state, const struct anv_format *format, - uint32_t offset, uint32_t range); + uint32_t offset, uint32_t range, + uint32_t stride); struct anv_sampler { uint32_t state[4]; diff --git a/src/vulkan/gen7_state.c b/src/vulkan/gen7_state.c index 0d67be4a99b..6f1cb8553e9 100644 --- a/src/vulkan/gen7_state.c +++ b/src/vulkan/gen7_state.c @@ -31,14 +31,8 @@ void gen7_fill_buffer_surface_state(void *state, const struct anv_format *format, - uint32_t offset, uint32_t range) + uint32_t offset, uint32_t range, uint32_t stride) { - /* This assumes RGBA float format. */ - - uint32_t stride = 16; /* Depends on whether accessing shader is simd8 or - * vec4. Will need one of each for buffers that are - * used in both vec4 and simd8. */ - uint32_t num_elements = range / stride; struct GEN7_RENDER_SURFACE_STATE surface_state = { diff --git a/src/vulkan/gen8_state.c b/src/vulkan/gen8_state.c index 61aede99ad4..ce69377fd77 100644 --- a/src/vulkan/gen8_state.c +++ b/src/vulkan/gen8_state.c @@ -31,10 +31,8 @@ void gen8_fill_buffer_surface_state(void *state, const struct anv_format *format, - uint32_t offset, uint32_t range) + uint32_t offset, uint32_t range, uint32_t stride) { - /* This assumes RGBA float format. */ - uint32_t stride = 4; uint32_t num_elements = range / stride; struct GEN8_RENDER_SURFACE_STATE surface_state = { |