mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 15:58:05 +02:00
zink: move gpl input/output funcs to zink_pipeline.c
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21197>
This commit is contained in:
parent
4f8a548af1
commit
ab69cba807
3 changed files with 78 additions and 69 deletions
|
|
@ -803,3 +803,69 @@ zink_create_gfx_pipeline_combined(struct zink_screen *screen, struct zink_gfx_pr
|
|||
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
|
||||
/* vertex input pipeline library states with dynamic vertex input: only the topology matters */
|
||||
struct zink_gfx_input_key *
|
||||
zink_find_or_create_input_dynamic(struct zink_context *ctx, VkPrimitiveTopology vkmode)
|
||||
{
|
||||
uint32_t hash = hash_gfx_input_dynamic(&ctx->gfx_pipeline_state.input);
|
||||
struct set_entry *he = _mesa_set_search_pre_hashed(&ctx->gfx_inputs, hash, &ctx->gfx_pipeline_state.input);
|
||||
if (!he) {
|
||||
struct zink_gfx_input_key *ikey = rzalloc(ctx, struct zink_gfx_input_key);
|
||||
ikey->idx = ctx->gfx_pipeline_state.idx;
|
||||
ikey->pipeline = zink_create_gfx_pipeline_input(zink_screen(ctx->base.screen), &ctx->gfx_pipeline_state, NULL, vkmode);
|
||||
he = _mesa_set_add_pre_hashed(&ctx->gfx_inputs, hash, ikey);
|
||||
}
|
||||
return (struct zink_gfx_input_key *)he->key;
|
||||
}
|
||||
|
||||
/* vertex input pipeline library states without dynamic vertex input: everything is hashed */
|
||||
struct zink_gfx_input_key *
|
||||
zink_find_or_create_input(struct zink_context *ctx, VkPrimitiveTopology vkmode)
|
||||
{
|
||||
uint32_t hash = hash_gfx_input(&ctx->gfx_pipeline_state.input);
|
||||
struct set_entry *he = _mesa_set_search_pre_hashed(&ctx->gfx_inputs, hash, &ctx->gfx_pipeline_state.input);
|
||||
if (!he) {
|
||||
struct zink_gfx_input_key *ikey = rzalloc(ctx, struct zink_gfx_input_key);
|
||||
if (ctx->gfx_pipeline_state.uses_dynamic_stride) {
|
||||
memcpy(ikey, &ctx->gfx_pipeline_state.input, offsetof(struct zink_gfx_input_key, vertex_buffers_enabled_mask));
|
||||
ikey->element_state = ctx->gfx_pipeline_state.element_state;
|
||||
} else {
|
||||
memcpy(ikey, &ctx->gfx_pipeline_state.input, offsetof(struct zink_gfx_input_key, pipeline));
|
||||
}
|
||||
ikey->pipeline = zink_create_gfx_pipeline_input(zink_screen(ctx->base.screen), &ctx->gfx_pipeline_state, ikey->element_state->binding_map, vkmode);
|
||||
he = _mesa_set_add_pre_hashed(&ctx->gfx_inputs, hash, ikey);
|
||||
}
|
||||
return (struct zink_gfx_input_key*)he->key;
|
||||
}
|
||||
|
||||
/* fragment output pipeline library states with dynamic state3 */
|
||||
struct zink_gfx_output_key *
|
||||
zink_find_or_create_output_ds3(struct zink_context *ctx)
|
||||
{
|
||||
uint32_t hash = hash_gfx_output_ds3(&ctx->gfx_pipeline_state);
|
||||
struct set_entry *he = _mesa_set_search_pre_hashed(&ctx->gfx_outputs, hash, &ctx->gfx_pipeline_state);
|
||||
if (!he) {
|
||||
struct zink_gfx_output_key *okey = rzalloc(ctx, struct zink_gfx_output_key);
|
||||
memcpy(okey, &ctx->gfx_pipeline_state, sizeof(uint32_t));
|
||||
okey->pipeline = zink_create_gfx_pipeline_output(zink_screen(ctx->base.screen), &ctx->gfx_pipeline_state);
|
||||
he = _mesa_set_add_pre_hashed(&ctx->gfx_outputs, hash, okey);
|
||||
}
|
||||
return (struct zink_gfx_output_key*)he->key;
|
||||
}
|
||||
|
||||
/* fragment output pipeline library states without dynamic state3 */
|
||||
struct zink_gfx_output_key *
|
||||
zink_find_or_create_output(struct zink_context *ctx)
|
||||
{
|
||||
uint32_t hash = hash_gfx_output(&ctx->gfx_pipeline_state);
|
||||
struct set_entry *he = _mesa_set_search_pre_hashed(&ctx->gfx_outputs, hash, &ctx->gfx_pipeline_state);
|
||||
if (!he) {
|
||||
struct zink_gfx_output_key *okey = rzalloc(ctx, struct zink_gfx_output_key);
|
||||
memcpy(okey, &ctx->gfx_pipeline_state, offsetof(struct zink_gfx_output_key, pipeline));
|
||||
okey->pipeline = zink_create_gfx_pipeline_output(zink_screen(ctx->base.screen), &ctx->gfx_pipeline_state);
|
||||
he = _mesa_set_add_pre_hashed(&ctx->gfx_outputs, hash, okey);
|
||||
}
|
||||
return (struct zink_gfx_output_key*)he->key;
|
||||
}
|
||||
|
|
@ -31,6 +31,14 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct zink_gfx_output_key *
|
||||
zink_find_or_create_output(struct zink_context *ctx);
|
||||
struct zink_gfx_output_key *
|
||||
zink_find_or_create_output_ds3(struct zink_context *ctx);
|
||||
struct zink_gfx_input_key *
|
||||
zink_find_or_create_input(struct zink_context *ctx, VkPrimitiveTopology vkmode);
|
||||
struct zink_gfx_input_key *
|
||||
zink_find_or_create_input_dynamic(struct zink_context *ctx, VkPrimitiveTopology vkmode);
|
||||
|
||||
VkPipeline
|
||||
zink_create_gfx_pipeline(struct zink_screen *screen,
|
||||
|
|
|
|||
|
|
@ -66,71 +66,6 @@ get_pipeline_idx(enum pipe_prim_type mode, VkPrimitiveTopology vkmode)
|
|||
return vkmode;
|
||||
}
|
||||
|
||||
/* vertex input pipeline library states with dynamic vertex input: only the topology matters */
|
||||
static struct zink_gfx_input_key *
|
||||
find_or_create_input_dynamic(struct zink_context *ctx, VkPrimitiveTopology vkmode)
|
||||
{
|
||||
uint32_t hash = hash_gfx_input_dynamic(&ctx->gfx_pipeline_state.input);
|
||||
struct set_entry *he = _mesa_set_search_pre_hashed(&ctx->gfx_inputs, hash, &ctx->gfx_pipeline_state.input);
|
||||
if (!he) {
|
||||
struct zink_gfx_input_key *ikey = rzalloc(ctx, struct zink_gfx_input_key);
|
||||
ikey->idx = ctx->gfx_pipeline_state.idx;
|
||||
ikey->pipeline = zink_create_gfx_pipeline_input(zink_screen(ctx->base.screen), &ctx->gfx_pipeline_state, NULL, vkmode);
|
||||
he = _mesa_set_add_pre_hashed(&ctx->gfx_inputs, hash, ikey);
|
||||
}
|
||||
return (struct zink_gfx_input_key *)he->key;
|
||||
}
|
||||
|
||||
/* vertex input pipeline library states without dynamic vertex input: everything is hashed */
|
||||
static struct zink_gfx_input_key *
|
||||
find_or_create_input(struct zink_context *ctx, VkPrimitiveTopology vkmode)
|
||||
{
|
||||
uint32_t hash = hash_gfx_input(&ctx->gfx_pipeline_state.input);
|
||||
struct set_entry *he = _mesa_set_search_pre_hashed(&ctx->gfx_inputs, hash, &ctx->gfx_pipeline_state.input);
|
||||
if (!he) {
|
||||
struct zink_gfx_input_key *ikey = rzalloc(ctx, struct zink_gfx_input_key);
|
||||
if (ctx->gfx_pipeline_state.uses_dynamic_stride) {
|
||||
memcpy(ikey, &ctx->gfx_pipeline_state.input, offsetof(struct zink_gfx_input_key, vertex_buffers_enabled_mask));
|
||||
ikey->element_state = ctx->gfx_pipeline_state.element_state;
|
||||
} else {
|
||||
memcpy(ikey, &ctx->gfx_pipeline_state.input, offsetof(struct zink_gfx_input_key, pipeline));
|
||||
}
|
||||
ikey->pipeline = zink_create_gfx_pipeline_input(zink_screen(ctx->base.screen), &ctx->gfx_pipeline_state, ikey->element_state->binding_map, vkmode);
|
||||
he = _mesa_set_add_pre_hashed(&ctx->gfx_inputs, hash, ikey);
|
||||
}
|
||||
return (struct zink_gfx_input_key*)he->key;
|
||||
}
|
||||
|
||||
/* fragment output pipeline library states with dynamic state3 */
|
||||
static struct zink_gfx_output_key *
|
||||
find_or_create_output_ds3(struct zink_context *ctx)
|
||||
{
|
||||
uint32_t hash = hash_gfx_output_ds3(&ctx->gfx_pipeline_state);
|
||||
struct set_entry *he = _mesa_set_search_pre_hashed(&ctx->gfx_outputs, hash, &ctx->gfx_pipeline_state);
|
||||
if (!he) {
|
||||
struct zink_gfx_output_key *okey = rzalloc(ctx, struct zink_gfx_output_key);
|
||||
memcpy(okey, &ctx->gfx_pipeline_state, sizeof(uint32_t));
|
||||
okey->pipeline = zink_create_gfx_pipeline_output(zink_screen(ctx->base.screen), &ctx->gfx_pipeline_state);
|
||||
he = _mesa_set_add_pre_hashed(&ctx->gfx_outputs, hash, okey);
|
||||
}
|
||||
return (struct zink_gfx_output_key*)he->key;
|
||||
}
|
||||
|
||||
/* fragment output pipeline library states without dynamic state3 */
|
||||
static struct zink_gfx_output_key *
|
||||
find_or_create_output(struct zink_context *ctx)
|
||||
{
|
||||
uint32_t hash = hash_gfx_output(&ctx->gfx_pipeline_state);
|
||||
struct set_entry *he = _mesa_set_search_pre_hashed(&ctx->gfx_outputs, hash, &ctx->gfx_pipeline_state);
|
||||
if (!he) {
|
||||
struct zink_gfx_output_key *okey = rzalloc(ctx, struct zink_gfx_output_key);
|
||||
memcpy(okey, &ctx->gfx_pipeline_state, offsetof(struct zink_gfx_output_key, pipeline));
|
||||
okey->pipeline = zink_create_gfx_pipeline_output(zink_screen(ctx->base.screen), &ctx->gfx_pipeline_state);
|
||||
he = _mesa_set_add_pre_hashed(&ctx->gfx_outputs, hash, okey);
|
||||
}
|
||||
return (struct zink_gfx_output_key*)he->key;
|
||||
}
|
||||
|
||||
/*
|
||||
VUID-vkCmdBindVertexBuffers2-pStrides-06209
|
||||
If pStrides is not NULL each element of pStrides must be either 0 or greater than or equal
|
||||
|
|
@ -260,11 +195,11 @@ zink_get_gfx_pipeline(struct zink_context *ctx,
|
|||
else
|
||||
gkey = zink_create_pipeline_lib(screen, prog, &ctx->gfx_pipeline_state);
|
||||
struct zink_gfx_input_key *ikey = DYNAMIC_STATE == ZINK_DYNAMIC_VERTEX_INPUT ?
|
||||
find_or_create_input_dynamic(ctx, vkmode) :
|
||||
find_or_create_input(ctx, vkmode);
|
||||
zink_find_or_create_input_dynamic(ctx, vkmode) :
|
||||
zink_find_or_create_input(ctx, vkmode);
|
||||
struct zink_gfx_output_key *okey = DYNAMIC_STATE >= ZINK_DYNAMIC_STATE3 && screen->have_full_ds3 ?
|
||||
find_or_create_output_ds3(ctx) :
|
||||
find_or_create_output(ctx);
|
||||
zink_find_or_create_output_ds3(ctx) :
|
||||
zink_find_or_create_output(ctx);
|
||||
/* partial pipelines are stored to the cache entry for async optimized pipeline compiles */
|
||||
pc_entry->ikey = ikey;
|
||||
pc_entry->gkey = gkey;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue