for (int i = 0; i < ZINK_SHADER_COUNT; ++i) {
enum pipe_shader_type type = pipe_shader_type_from_mesa(i);
if (dirty[i]) {
- prog->stages[type] = CALLOC_STRUCT(zink_shader_module);
- assert(prog->stages[type]);
- pipe_reference_init(&prog->stages[type]->reference, 1);
- prog->stages[type]->shader = zink_shader_compile(zink_screen(ctx->base.screen), dirty[i]);
+ prog->modules[type] = CALLOC_STRUCT(zink_shader_module);
+ assert(prog->modules[type]);
+ pipe_reference_init(&prog->modules[type]->reference, 1);
+ prog->modules[type]->shader = zink_shader_compile(zink_screen(ctx->base.screen), dirty[i]);
} else if (stages[type]) /* reuse existing shader module */
- zink_shader_module_reference(zink_screen(ctx->base.screen), &prog->stages[type], ctx->curr_program->stages[type]);
+ zink_shader_module_reference(zink_screen(ctx->base.screen), &prog->modules[type], ctx->curr_program->modules[type]);
prog->shaders[type] = stages[type];
}
ctx->dirty_shader_stages = 0;
static uint32_t
hash_gfx_pipeline_state(const void *key)
{
- return _mesa_hash_data(key, sizeof(struct zink_gfx_pipeline_state));
+ return _mesa_hash_data(key, offsetof(struct zink_gfx_pipeline_state, hash));
}
static bool
equals_gfx_pipeline_state(const void *a, const void *b)
{
- return memcmp(a, b, sizeof(struct zink_gfx_pipeline_state)) == 0;
+ return memcmp(a, b, offsetof(struct zink_gfx_pipeline_state, hash)) == 0;
}
struct zink_gfx_program *
}
for (int i = 0; i < ZINK_SHADER_COUNT; ++i) {
- if (prog->stages[i]) {
+ if (prog->modules[i]) {
_mesa_set_add(stages[i]->programs, prog);
zink_gfx_program_reference(screen, NULL, prog);
}
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])
- zink_shader_module_reference(screen, &prog->stages[i], NULL);
+ if (prog->modules[i])
+ zink_shader_module_reference(screen, &prog->modules[i], NULL);
}
/* unref all used render-passes */
case PIPE_PRIM_TRIANGLE_FAN:
return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN;
+ case PIPE_PRIM_LINE_STRIP_ADJACENCY:
+ return VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY;
+
+ case PIPE_PRIM_LINES_ADJACENCY:
+ return VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY;
+
+ case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY:
+ return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY;
+
+ case PIPE_PRIM_TRIANGLES_ADJACENCY:
+ return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY;
+
default:
unreachable("unexpected enum pipe_prim_type");
}
struct zink_gfx_pipeline_state *state,
enum pipe_prim_type mode)
{
- assert(mode <= ARRAY_SIZE(prog->pipelines));
+ VkPrimitiveTopology vkmode = primitive_topology(mode);
+ assert(vkmode <= ARRAY_SIZE(prog->pipelines));
+
+ struct hash_entry *entry = NULL;
+
+ if (!state->hash) {
+ state->hash = hash_gfx_pipeline_state(state);
+ /* make sure the hash is not zero, as we take it as invalid.
+ * TODO: rework this using a separate dirty-bit */
+ assert(state->hash != 0);
+ }
+ entry = _mesa_hash_table_search_pre_hashed(prog->pipelines[vkmode], state->hash, state);
- /* TODO: use pre-hashed versions to save some time (can re-hash only when
- state changes) */
- struct hash_entry *entry = _mesa_hash_table_search(prog->pipelines[mode], state);
if (!entry) {
- VkPrimitiveTopology vkmode = primitive_topology(mode);
VkPipeline pipeline = zink_create_gfx_pipeline(screen, prog,
state, vkmode);
if (pipeline == VK_NULL_HANDLE)
memcpy(&pc_entry->state, state, sizeof(*state));
pc_entry->pipeline = pipeline;
- entry = _mesa_hash_table_insert(prog->pipelines[mode], &pc_entry->state, pc_entry);
+ assert(state->hash);
+ entry = _mesa_hash_table_insert_pre_hashed(prog->pipelines[vkmode], state->hash, state, pc_entry);
assert(entry);
reference_render_pass(screen, prog, state->render_pass);