Module: Mesa
Branch: master
Commit: 24f9aea770711c8b968177b6e4ff15d8fb8fb48e
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=24f9aea770711c8b968177b6e4ff15d8fb8fb48e

Author: Joshua Ashton <[email protected]>
Date:   Mon May  4 11:53:03 2020 +0100

radv: Remove RANGE_SIZE usage

These were removed from the latest Vulkan headers
https://github.com/KhronosGroup/Vulkan-Docs/issues/1230

Reviewed-by: Eric Engestrom <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
Reviewed-by: Samuel Pitoiset <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4878>

---

 src/amd/vulkan/gfx10_format_table.py | 27 ++++++++++++++++++++-------
 src/amd/vulkan/radv_cmd_buffer.c     |  4 ++--
 src/amd/vulkan/radv_constants.h      |  1 +
 src/amd/vulkan/radv_image.c          |  4 ++--
 src/amd/vulkan/radv_private.h        |  2 +-
 5 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/src/amd/vulkan/gfx10_format_table.py 
b/src/amd/vulkan/gfx10_format_table.py
index f55b302bf82..d67d7b5aaea 100644
--- a/src/amd/vulkan/gfx10_format_table.py
+++ b/src/amd/vulkan/gfx10_format_table.py
@@ -84,15 +84,28 @@ header_template = mako.template.Template("""\
    { .img_format = V_008F0C_IMG_FORMAT_##_img_format, \
      ##__VA_ARGS__ }
 
-static const struct gfx10_format gfx10_format_table[VK_FORMAT_RANGE_SIZE] = {
 % for vk_format, args in formats:
- % if args is not None:
-  [${vk_format}] = FMT(${args}),
- % else:
-/* ${vk_format} is not supported */
- % endif
+    % if args is not None:
+    static const struct gfx10_format gfx10_info_${vk_format} = FMT(${args});
+    % else:
+    /* ${vk_format} is not supported */
+    % endif
 % endfor
-};
+
+static const struct gfx10_format gfx10_unsupported_format = { 0 };
+
+static inline const struct gfx10_format* gfx10_format_description(VkFormat 
format)
+{
+    switch(format)
+    {
+    % for vk_format, args in formats:
+     % if args is not None:
+        case ${vk_format}: return &gfx10_info_${vk_format};
+     % endif
+    % endfor
+        default: return &gfx10_unsupported_format;
+    }
+}
 """)
 
 class Gfx10Format(object):
diff --git a/src/amd/vulkan/radv_cmd_buffer.c b/src/amd/vulkan/radv_cmd_buffer.c
index 38c71dcd3ec..d96b5649976 100644
--- a/src/amd/vulkan/radv_cmd_buffer.c
+++ b/src/amd/vulkan/radv_cmd_buffer.c
@@ -325,7 +325,7 @@ radv_cmd_buffer_destroy(struct radv_cmd_buffer *cmd_buffer)
                
cmd_buffer->device->ws->buffer_destroy(cmd_buffer->upload.upload_bo);
        cmd_buffer->device->ws->cs_destroy(cmd_buffer->cs);
 
-       for (unsigned i = 0; i < VK_PIPELINE_BIND_POINT_RANGE_SIZE; i++)
+       for (unsigned i = 0; i < MAX_BIND_POINTS; i++)
                free(cmd_buffer->descriptors[i].push_set.set.mapped_ptr);
 
        vk_free(&cmd_buffer->pool->alloc, cmd_buffer);
@@ -364,7 +364,7 @@ radv_reset_cmd_buffer(struct radv_cmd_buffer *cmd_buffer)
 
        memset(cmd_buffer->vertex_bindings, 0, 
sizeof(cmd_buffer->vertex_bindings));
 
-       for (unsigned i = 0; i < VK_PIPELINE_BIND_POINT_RANGE_SIZE; i++) {
+       for (unsigned i = 0; i < MAX_BIND_POINTS; i++) {
                cmd_buffer->descriptors[i].dirty = 0;
                cmd_buffer->descriptors[i].valid = 0;
                cmd_buffer->descriptors[i].push_dirty = false;
diff --git a/src/amd/vulkan/radv_constants.h b/src/amd/vulkan/radv_constants.h
index b494e5c71e7..0b0d6714d25 100644
--- a/src/amd/vulkan/radv_constants.h
+++ b/src/amd/vulkan/radv_constants.h
@@ -51,6 +51,7 @@
 #define MAX_SO_OUTPUTS 64
 #define MAX_INLINE_UNIFORM_BLOCK_SIZE (4ull * 1024 * 1024)
 #define MAX_INLINE_UNIFORM_BLOCK_COUNT 64
+#define MAX_BIND_POINTS 2 /* compute + graphics */
 
 #define NUM_DEPTH_CLEAR_PIPELINES 3
 #define NUM_DEPTH_DECOMPRESS_PIPELINES 3
diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c
index f7818c691c8..44d04935140 100644
--- a/src/amd/vulkan/radv_image.c
+++ b/src/amd/vulkan/radv_image.c
@@ -519,7 +519,7 @@ radv_make_buffer_descriptor(struct radv_device *device,
                   S_008F0C_DST_SEL_W(radv_map_swizzle(desc->swizzle[3]));
 
        if (device->physical_device->rad_info.chip_class >= GFX10) {
-               const struct gfx10_format *fmt = &gfx10_format_table[vk_format];
+               const struct gfx10_format *fmt = 
gfx10_format_description(vk_format);
 
                /* OOB_SELECT chooses the out-of-bounds check:
                 *  - 0: (index >= NUM_RECORDS) || (offset >= STRIDE)
@@ -747,7 +747,7 @@ gfx10_make_texture_descriptor(struct radv_device *device,
        unsigned type;
 
        desc = vk_format_description(vk_format);
-       img_format = gfx10_format_table[vk_format].img_format;
+       img_format = gfx10_format_description(vk_format)->img_format;
 
        if (desc->colorspace == VK_FORMAT_COLORSPACE_ZS) {
                const unsigned char swizzle_xxxx[4] = {0, 0, 0, 0};
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index a54f0147fbc..5da166c7b2f 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -1356,7 +1356,7 @@ struct radv_cmd_buffer {
        VkShaderStageFlags push_constant_stages;
        struct radv_descriptor_set meta_push_descriptors;
 
-       struct radv_descriptor_state 
descriptors[VK_PIPELINE_BIND_POINT_RANGE_SIZE];
+       struct radv_descriptor_state descriptors[MAX_BIND_POINTS];
 
        struct radv_cmd_buffer_upload upload;
 

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to