From: Mike Blumenkrantz Date: Tue, 30 Jun 2020 12:55:07 +0000 (-0400) Subject: zink: use ZINK_SHADER_COUNT instead of PIPE_SHADER_TYPES - 1 everywhere X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=76d3645dd2e1737ecac3244d687d0eadab8456d2;p=mesa.git zink: use ZINK_SHADER_COUNT instead of PIPE_SHADER_TYPES - 1 everywhere this is just for convenience and consistency Reviewed-by: Erik Faye-Lund Part-of: --- diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 823c19efb7e..9098765bb9c 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -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 diff --git a/src/gallium/drivers/zink/zink_context.h b/src/gallium/drivers/zink/zink_context.h index 42dd4ca880f..b403bc92a85 100644 --- a/src/gallium/drivers/zink/zink_context.h +++ b/src/gallium/drivers/zink/zink_context.h @@ -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; diff --git a/src/gallium/drivers/zink/zink_pipeline.c b/src/gallium/drivers/zink/zink_pipeline.c index 1d45b825830..af38c84aeaf 100644 --- a/src/gallium/drivers/zink/zink_pipeline.c +++ b/src/gallium/drivers/zink/zink_pipeline.c @@ -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; diff --git a/src/gallium/drivers/zink/zink_program.c b/src/gallium/drivers/zink/zink_program.c index 830cf5e9229..ee735a810d2 100644 --- a/src/gallium/drivers/zink/zink_program.c +++ b/src/gallium/drivers/zink/zink_program.c @@ -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]) diff --git a/src/gallium/drivers/zink/zink_program.h b/src/gallium/drivers/zink/zink_program.h index bd6f7dbaa7a..1d4aaa0cfdc 100644 --- a/src/gallium/drivers/zink/zink_program.h +++ b/src/gallium/drivers/zink/zink_program.h @@ -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,