zink: use ZINK_SHADER_COUNT instead of PIPE_SHADER_TYPES - 1 everywhere
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Tue, 30 Jun 2020 12:55:07 +0000 (08:55 -0400)
committerMarge Bot <eric+marge@anholt.net>
Fri, 7 Aug 2020 12:36:59 +0000 (12:36 +0000)
this is just for convenience and consistency

Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5970>

src/gallium/drivers/zink/zink_context.c
src/gallium/drivers/zink/zink_context.h
src/gallium/drivers/zink/zink_pipeline.c
src/gallium/drivers/zink/zink_program.c
src/gallium/drivers/zink/zink_program.h

index 823c19efb7eb85852756b2097aa5514772c1ab4b..9098765bb9c1a3d93adb70801cc8c4859352aeaf 100644 (file)
@@ -839,13 +839,13 @@ zink_shader_stage(enum pipe_shader_type type)
 static uint32_t
 hash_gfx_program(const void *key)
 {
-   return _mesa_hash_data(key, sizeof(struct zink_shader *) * (PIPE_SHADER_TYPES - 1));
+   return _mesa_hash_data(key, sizeof(struct zink_shader *) * (ZINK_SHADER_COUNT));
 }
 
 static bool
 equals_gfx_program(const void *a, const void *b)
 {
-   return memcmp(a, b, sizeof(struct zink_shader *) * (PIPE_SHADER_TYPES - 1)) == 0;
+   return memcmp(a, b, sizeof(struct zink_shader *) * (ZINK_SHADER_COUNT)) == 0;
 }
 
 static uint32_t
index 42dd4ca880f2780b9a9649c0ba04cf1f33e05909..b403bc92a85303d2db5dbaca4792560f34a155aa 100644 (file)
@@ -71,6 +71,8 @@ zink_so_target(struct pipe_stream_output_target *so_target)
    return (struct zink_so_target *)so_target;
 }
 
+#define ZINK_SHADER_COUNT (PIPE_SHADER_TYPES - 1)
+
 struct zink_context {
    struct pipe_context base;
    struct slab_child_pool transfer_pool;
@@ -88,7 +90,7 @@ struct zink_context {
    struct zink_vertex_elements_state *element_state;
    struct zink_rasterizer_state *rast_state;
 
-   struct zink_shader *gfx_stages[PIPE_SHADER_TYPES - 1];
+   struct zink_shader *gfx_stages[ZINK_SHADER_COUNT];
    struct zink_gfx_pipeline_state gfx_pipeline_state;
    struct hash_table *program_cache;
    struct zink_gfx_program *curr_program;
index 1d45b82583083befa514d0db958fd109843247d6..af38c84aeafadbf784ebd27f6222ebaba8899872 100644 (file)
@@ -140,9 +140,9 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
    pci.pDepthStencilState = &depth_stencil_state;
    pci.pDynamicState = &pipelineDynamicStateCreateInfo;
 
-   VkPipelineShaderStageCreateInfo shader_stages[PIPE_SHADER_TYPES - 1];
+   VkPipelineShaderStageCreateInfo shader_stages[ZINK_SHADER_COUNT];
    uint32_t num_stages = 0;
-   for (int i = 0; i < PIPE_SHADER_TYPES - 1; ++i) {
+   for (int i = 0; i < ZINK_SHADER_COUNT; ++i) {
       if (!prog->stages[i])
          continue;
 
index 830cf5e9229cc9b7bd797f2dc42fdb60233a6de2..ee735a810d28d0dd526790d5a7781248bde21283 100644 (file)
@@ -47,13 +47,13 @@ debug_describe_zink_gfx_program(char *buf, const struct zink_gfx_program *ptr)
 
 static VkDescriptorSetLayout
 create_desc_set_layout(VkDevice dev,
-                       struct zink_shader *stages[PIPE_SHADER_TYPES - 1],
+                       struct zink_shader *stages[ZINK_SHADER_COUNT],
                        unsigned *num_descriptors)
 {
    VkDescriptorSetLayoutBinding bindings[PIPE_SHADER_TYPES * PIPE_MAX_CONSTANT_BUFFERS];
    int num_bindings = 0;
 
-   for (int i = 0; i < PIPE_SHADER_TYPES - 1; i++) {
+   for (int i = 0; i < ZINK_SHADER_COUNT; i++) {
       struct zink_shader *shader = stages[i];
       if (!shader)
          continue;
@@ -108,9 +108,9 @@ create_pipeline_layout(VkDevice dev, VkDescriptorSetLayout dsl)
 }
 
 static void
-update_shader_modules(struct zink_context *ctx, struct zink_shader *stages[PIPE_SHADER_TYPES - 1], struct zink_gfx_program *prog)
+update_shader_modules(struct zink_context *ctx, struct zink_shader *stages[ZINK_SHADER_COUNT], struct zink_gfx_program *prog)
 {
-   for (int i = 0; i < PIPE_SHADER_TYPES - 1; ++i) {
+   for (int i = 0; i < ZINK_SHADER_COUNT; ++i) {
       if (stages[i]) {
          prog->stages[i] = zink_shader_compile(zink_screen(ctx->base.screen), stages[i]);
          prog->shaders[i] = stages[i];
@@ -132,7 +132,7 @@ equals_gfx_pipeline_state(const void *a, const void *b)
 
 struct zink_gfx_program *
 zink_create_gfx_program(struct zink_context *ctx,
-                        struct zink_shader *stages[PIPE_SHADER_TYPES - 1])
+                        struct zink_shader *stages[ZINK_SHADER_COUNT])
 {
    struct zink_screen *screen = zink_screen(ctx->base.screen);
    struct zink_gfx_program *prog = CALLOC_STRUCT(zink_gfx_program);
@@ -151,7 +151,7 @@ zink_create_gfx_program(struct zink_context *ctx,
          goto fail;
    }
 
-   for (int i = 0; i < PIPE_SHADER_TYPES - 1; ++i) {
+   for (int i = 0; i < ZINK_SHADER_COUNT; ++i) {
       if (prog->stages[i]) {
          _mesa_set_add(stages[i]->programs, prog);
          zink_gfx_program_reference(screen, NULL, prog);
@@ -200,7 +200,7 @@ zink_destroy_gfx_program(struct zink_screen *screen,
    if (prog->dsl)
       vkDestroyDescriptorSetLayout(screen->dev, prog->dsl, NULL);
 
-   for (int i = 0; i < PIPE_SHADER_TYPES - 1; ++i) {
+   for (int i = 0; i < ZINK_SHADER_COUNT; ++i) {
       if (prog->shaders[i])
          gfx_program_remove_shader(prog, prog->shaders[i]);
       if (prog->stages[i])
index bd6f7dbaa7a6801a109fc37570883593d7751e41..1d4aaa0cfdc7102ab133fcde4a27b2245ad20536 100644 (file)
@@ -29,7 +29,8 @@
 #include "pipe/p_state.h"
 #include "util/u_inlines.h"
 
-struct zink_context;
+#include "zink_context.h"
+
 struct zink_screen;
 struct zink_shader;
 struct zink_gfx_pipeline_state;
@@ -40,8 +41,8 @@ struct set;
 struct zink_gfx_program {
    struct pipe_reference reference;
 
-   VkShaderModule stages[PIPE_SHADER_TYPES - 1]; // compute stage doesn't belong here
-   struct zink_shader *shaders[PIPE_SHADER_TYPES - 1];
+   VkShaderModule stages[ZINK_SHADER_COUNT]; // compute stage doesn't belong here
+   struct zink_shader *shaders[ZINK_SHADER_COUNT];
    VkDescriptorSetLayout dsl;
    VkPipelineLayout layout;
    unsigned num_descriptors;
@@ -51,7 +52,7 @@ struct zink_gfx_program {
 
 struct zink_gfx_program *
 zink_create_gfx_program(struct zink_context *ctx,
-                        struct zink_shader *stages[PIPE_SHADER_TYPES - 1]);
+                        struct zink_shader *stages[ZINK_SHADER_COUNT]);
 
 void
 zink_destroy_gfx_program(struct zink_screen *screen,