summaryrefslogtreecommitdiffstats
path: root/src/amd
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2018-10-24 08:50:23 +0200
committerSamuel Pitoiset <[email protected]>2018-10-26 10:50:00 +0200
commit468c33e2f7e517adc7f57a50edbbf41ef7fd0848 (patch)
tree3654cab1a165ab34c421302c2c9b7a0b472ce858 /src/amd
parente60e3e1b3f6d827e296e3bfd6acefebfc08d3005 (diff)
radv: add create_bview_for_r32g32b32() helper
For the special R32G32B32 paths. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Diffstat (limited to 'src/amd')
-rw-r--r--src/amd/vulkan/radv_meta_bufimage.c71
1 files changed, 38 insertions, 33 deletions
diff --git a/src/amd/vulkan/radv_meta_bufimage.c b/src/amd/vulkan/radv_meta_bufimage.c
index 1cfe50fc505..6a5058693f4 100644
--- a/src/amd/vulkan/radv_meta_bufimage.c
+++ b/src/amd/vulkan/radv_meta_bufimage.c
@@ -1387,6 +1387,40 @@ create_buffer_from_image(struct radv_cmd_buffer *cmd_buffer,
}
static void
+create_bview_for_r32g32b32(struct radv_cmd_buffer *cmd_buffer,
+ struct radv_buffer *buffer,
+ unsigned offset,
+ VkFormat src_format,
+ struct radv_buffer_view *bview)
+{
+ VkFormat format;
+
+ switch (src_format) {
+ case VK_FORMAT_R32G32B32_UINT:
+ format = VK_FORMAT_R32_UINT;
+ break;
+ case VK_FORMAT_R32G32B32_SINT:
+ format = VK_FORMAT_R32_SINT;
+ break;
+ case VK_FORMAT_R32G32B32_SFLOAT:
+ format = VK_FORMAT_R32_SFLOAT;
+ break;
+ default:
+ unreachable("invalid R32G32B32 format");
+ }
+
+ radv_buffer_view_init(bview, cmd_buffer->device,
+ &(VkBufferViewCreateInfo) {
+ .sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO,
+ .flags = 0,
+ .buffer = radv_buffer_to_handle(buffer),
+ .format = format,
+ .offset = offset,
+ .range = VK_WHOLE_SIZE,
+ });
+}
+
+static void
itob_bind_descriptors(struct radv_cmd_buffer *cmd_buffer,
struct radv_image_view *src,
struct radv_buffer_view *dst)
@@ -1507,23 +1541,8 @@ radv_meta_buffer_to_image_cs_r32g32b32(struct radv_cmd_buffer *cmd_buffer,
struct radv_buffer_view src_view, dst_view;
unsigned dst_offset = 0;
unsigned stride;
- VkFormat dst_format;
VkBuffer buffer;
- switch (dst->format) {
- case VK_FORMAT_R32G32B32_UINT:
- dst_format = VK_FORMAT_R32_UINT;
- break;
- case VK_FORMAT_R32G32B32_SINT:
- dst_format = VK_FORMAT_R32_SINT;
- break;
- case VK_FORMAT_R32G32B32_SFLOAT:
- dst_format = VK_FORMAT_R32_SFLOAT;
- break;
- default:
- unreachable("invalid R32G32B32 format");
- }
-
/* This special btoi path for R32G32B32 formats will write the linear
* image as a buffer with the same underlying memory. The compute
* shader will clear all components separately using a R32 format.
@@ -1534,8 +1553,8 @@ radv_meta_buffer_to_image_cs_r32g32b32(struct radv_cmd_buffer *cmd_buffer,
create_bview(cmd_buffer, src->buffer, src->offset,
src->format, &src_view);
- create_bview(cmd_buffer, radv_buffer_from_handle(buffer), dst_offset,
- dst_format, &dst_view);
+ create_bview_for_r32g32b32(cmd_buffer, radv_buffer_from_handle(buffer),
+ dst_offset, dst->format, &dst_view);
btoi_r32g32b32_bind_descriptors(cmd_buffer, &src_view, &dst_view);
radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer),
@@ -1766,23 +1785,8 @@ radv_meta_clear_image_cs_r32g32b32(struct radv_cmd_buffer *cmd_buffer,
struct radv_device *device = cmd_buffer->device;
struct radv_buffer_view dst_view;
unsigned stride;
- VkFormat format;
VkBuffer buffer;
- switch (dst->format) {
- case VK_FORMAT_R32G32B32_UINT:
- format = VK_FORMAT_R32_UINT;
- break;
- case VK_FORMAT_R32G32B32_SINT:
- format = VK_FORMAT_R32_SINT;
- break;
- case VK_FORMAT_R32G32B32_SFLOAT:
- format = VK_FORMAT_R32_SFLOAT;
- break;
- default:
- unreachable("invalid R32G32B32 format");
- }
-
/* This special clear path for R32G32B32 formats will write the linear
* image as a buffer with the same underlying memory. The compute
* shader will clear all components separately using a R32 format.
@@ -1791,7 +1795,8 @@ radv_meta_clear_image_cs_r32g32b32(struct radv_cmd_buffer *cmd_buffer,
VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT,
&buffer);
- create_bview(cmd_buffer, radv_buffer_from_handle(buffer), 0, format, &dst_view);
+ create_bview_for_r32g32b32(cmd_buffer, radv_buffer_from_handle(buffer),
+ 0, dst->format, &dst_view);
cleari_r32g32b32_bind_descriptors(cmd_buffer, &dst_view);
radv_CmdBindPipeline(radv_cmd_buffer_to_handle(cmd_buffer),