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
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;
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;
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;
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;
}
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];
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);
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);
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])
#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;
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;
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,