zink: use ZINK_SHADER_COUNT instead of PIPE_SHADER_TYPES - 1 everywhere
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>
This commit is contained in:

committed by
Marge Bot

parent
0f059d550b
commit
76d3645dd2
@@ -839,13 +839,13 @@ zink_shader_stage(enum pipe_shader_type type)
|
|||||||
static uint32_t
|
static uint32_t
|
||||||
hash_gfx_program(const void *key)
|
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
|
static bool
|
||||||
equals_gfx_program(const void *a, const void *b)
|
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
|
static uint32_t
|
||||||
|
@@ -71,6 +71,8 @@ zink_so_target(struct pipe_stream_output_target *so_target)
|
|||||||
return (struct zink_so_target *)so_target;
|
return (struct zink_so_target *)so_target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define ZINK_SHADER_COUNT (PIPE_SHADER_TYPES - 1)
|
||||||
|
|
||||||
struct zink_context {
|
struct zink_context {
|
||||||
struct pipe_context base;
|
struct pipe_context base;
|
||||||
struct slab_child_pool transfer_pool;
|
struct slab_child_pool transfer_pool;
|
||||||
@@ -88,7 +90,7 @@ struct zink_context {
|
|||||||
struct zink_vertex_elements_state *element_state;
|
struct zink_vertex_elements_state *element_state;
|
||||||
struct zink_rasterizer_state *rast_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 zink_gfx_pipeline_state gfx_pipeline_state;
|
||||||
struct hash_table *program_cache;
|
struct hash_table *program_cache;
|
||||||
struct zink_gfx_program *curr_program;
|
struct zink_gfx_program *curr_program;
|
||||||
|
@@ -140,9 +140,9 @@ zink_create_gfx_pipeline(struct zink_screen *screen,
|
|||||||
pci.pDepthStencilState = &depth_stencil_state;
|
pci.pDepthStencilState = &depth_stencil_state;
|
||||||
pci.pDynamicState = &pipelineDynamicStateCreateInfo;
|
pci.pDynamicState = &pipelineDynamicStateCreateInfo;
|
||||||
|
|
||||||
VkPipelineShaderStageCreateInfo shader_stages[PIPE_SHADER_TYPES - 1];
|
VkPipelineShaderStageCreateInfo shader_stages[ZINK_SHADER_COUNT];
|
||||||
uint32_t num_stages = 0;
|
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])
|
if (!prog->stages[i])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@@ -47,13 +47,13 @@ debug_describe_zink_gfx_program(char *buf, const struct zink_gfx_program *ptr)
|
|||||||
|
|
||||||
static VkDescriptorSetLayout
|
static VkDescriptorSetLayout
|
||||||
create_desc_set_layout(VkDevice dev,
|
create_desc_set_layout(VkDevice dev,
|
||||||
struct zink_shader *stages[PIPE_SHADER_TYPES - 1],
|
struct zink_shader *stages[ZINK_SHADER_COUNT],
|
||||||
unsigned *num_descriptors)
|
unsigned *num_descriptors)
|
||||||
{
|
{
|
||||||
VkDescriptorSetLayoutBinding bindings[PIPE_SHADER_TYPES * PIPE_MAX_CONSTANT_BUFFERS];
|
VkDescriptorSetLayoutBinding bindings[PIPE_SHADER_TYPES * PIPE_MAX_CONSTANT_BUFFERS];
|
||||||
int num_bindings = 0;
|
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];
|
struct zink_shader *shader = stages[i];
|
||||||
if (!shader)
|
if (!shader)
|
||||||
continue;
|
continue;
|
||||||
@@ -108,9 +108,9 @@ create_pipeline_layout(VkDevice dev, VkDescriptorSetLayout dsl)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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]) {
|
if (stages[i]) {
|
||||||
prog->stages[i] = zink_shader_compile(zink_screen(ctx->base.screen), stages[i]);
|
prog->stages[i] = zink_shader_compile(zink_screen(ctx->base.screen), stages[i]);
|
||||||
prog->shaders[i] = 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 *
|
struct zink_gfx_program *
|
||||||
zink_create_gfx_program(struct zink_context *ctx,
|
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_screen *screen = zink_screen(ctx->base.screen);
|
||||||
struct zink_gfx_program *prog = CALLOC_STRUCT(zink_gfx_program);
|
struct zink_gfx_program *prog = CALLOC_STRUCT(zink_gfx_program);
|
||||||
@@ -151,7 +151,7 @@ zink_create_gfx_program(struct zink_context *ctx,
|
|||||||
goto fail;
|
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]) {
|
if (prog->stages[i]) {
|
||||||
_mesa_set_add(stages[i]->programs, prog);
|
_mesa_set_add(stages[i]->programs, prog);
|
||||||
zink_gfx_program_reference(screen, NULL, prog);
|
zink_gfx_program_reference(screen, NULL, prog);
|
||||||
@@ -200,7 +200,7 @@ zink_destroy_gfx_program(struct zink_screen *screen,
|
|||||||
if (prog->dsl)
|
if (prog->dsl)
|
||||||
vkDestroyDescriptorSetLayout(screen->dev, prog->dsl, NULL);
|
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])
|
if (prog->shaders[i])
|
||||||
gfx_program_remove_shader(prog, prog->shaders[i]);
|
gfx_program_remove_shader(prog, prog->shaders[i]);
|
||||||
if (prog->stages[i])
|
if (prog->stages[i])
|
||||||
|
@@ -29,7 +29,8 @@
|
|||||||
#include "pipe/p_state.h"
|
#include "pipe/p_state.h"
|
||||||
#include "util/u_inlines.h"
|
#include "util/u_inlines.h"
|
||||||
|
|
||||||
struct zink_context;
|
#include "zink_context.h"
|
||||||
|
|
||||||
struct zink_screen;
|
struct zink_screen;
|
||||||
struct zink_shader;
|
struct zink_shader;
|
||||||
struct zink_gfx_pipeline_state;
|
struct zink_gfx_pipeline_state;
|
||||||
@@ -40,8 +41,8 @@ struct set;
|
|||||||
struct zink_gfx_program {
|
struct zink_gfx_program {
|
||||||
struct pipe_reference reference;
|
struct pipe_reference reference;
|
||||||
|
|
||||||
VkShaderModule stages[PIPE_SHADER_TYPES - 1]; // compute stage doesn't belong here
|
VkShaderModule stages[ZINK_SHADER_COUNT]; // compute stage doesn't belong here
|
||||||
struct zink_shader *shaders[PIPE_SHADER_TYPES - 1];
|
struct zink_shader *shaders[ZINK_SHADER_COUNT];
|
||||||
VkDescriptorSetLayout dsl;
|
VkDescriptorSetLayout dsl;
|
||||||
VkPipelineLayout layout;
|
VkPipelineLayout layout;
|
||||||
unsigned num_descriptors;
|
unsigned num_descriptors;
|
||||||
@@ -51,7 +52,7 @@ struct zink_gfx_program {
|
|||||||
|
|
||||||
struct zink_gfx_program *
|
struct zink_gfx_program *
|
||||||
zink_create_gfx_program(struct zink_context *ctx,
|
zink_create_gfx_program(struct zink_context *ctx,
|
||||||
struct zink_shader *stages[PIPE_SHADER_TYPES - 1]);
|
struct zink_shader *stages[ZINK_SHADER_COUNT]);
|
||||||
|
|
||||||
void
|
void
|
||||||
zink_destroy_gfx_program(struct zink_screen *screen,
|
zink_destroy_gfx_program(struct zink_screen *screen,
|
||||||
|
Reference in New Issue
Block a user