radv: Remove RANGE_SIZE usage
authorJoshua Ashton <joshua@froggi.es>
Mon, 4 May 2020 10:53:03 +0000 (11:53 +0100)
committerMarge Bot <eric+marge@anholt.net>
Tue, 5 May 2020 00:28:00 +0000 (00:28 +0000)
These were removed from the latest Vulkan headers
https://github.com/KhronosGroup/Vulkan-Docs/issues/1230

Reviewed-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4878>

src/amd/vulkan/gfx10_format_table.py
src/amd/vulkan/radv_cmd_buffer.c
src/amd/vulkan/radv_constants.h
src/amd/vulkan/radv_image.c
src/amd/vulkan/radv_private.h

index f55b302bf823cda8a21978ce663b922db19c5f85..d67d7b5aaea87328b286d64f15b43c66911e9673 100644 (file)
@@ -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):
index 38c71dcd3ecac6b39ada7d9c950fedd042b5fe9f..d96b5649976bc35d090a8040dfc62ec149b0a091 100644 (file)
@@ -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;
index b494e5c71e75624d4428d9e75e83aafad4c8d22a..0b0d6714d25da77b9a6d64053560eda49f39ceb9 100644 (file)
@@ -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
index f7818c691c864b82e829124cf5aa2668a59dcb38..44d049351406ee4a22d220685f092d702fff0e7e 100644 (file)
@@ -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};
index a54f0147fbcd9a42984198f897baf0da92b700ce..5da166c7b2f72d1dadec203af7740deee64509e9 100644 (file)
@@ -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;