mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 00:00:11 +01:00
freedreno/ir3: Add ir3_shader_state
Initially just a wrapper for ir3_shader, but this is where we'll hook in the bookkeeping for async compile. Signed-off-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8795>
This commit is contained in:
parent
378c14331b
commit
6fdd1d30f6
11 changed files with 71 additions and 25 deletions
|
|
@ -143,7 +143,7 @@ fd3_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info,
|
|||
.sprite_coord_mode = ctx->rasterizer->sprite_coord_mode,
|
||||
};
|
||||
|
||||
if (fd3_needs_manual_clipping(ctx->prog.vs, ctx->rasterizer))
|
||||
if (fd3_needs_manual_clipping(ir3_get_shader(ctx->prog.vs), ctx->rasterizer))
|
||||
emit.key.ucp_enables = ctx->rasterizer->clip_plane_enable;
|
||||
|
||||
fixup_shader_state(ctx, &emit.key);
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ static inline const struct ir3_shader_variant *
|
|||
fd3_emit_get_vp(struct fd3_emit *emit)
|
||||
{
|
||||
if (!emit->vs) {
|
||||
struct ir3_shader *shader = emit->prog->vs;
|
||||
struct ir3_shader *shader = ir3_get_shader(emit->prog->vs);
|
||||
emit->vs = ir3_shader_variant(shader, emit->key,
|
||||
emit->binning_pass, emit->debug);
|
||||
}
|
||||
|
|
@ -80,7 +80,7 @@ fd3_emit_get_fp(struct fd3_emit *emit)
|
|||
static const struct ir3_shader_variant binning_fs = {};
|
||||
emit->fs = &binning_fs;
|
||||
} else {
|
||||
struct ir3_shader *shader = emit->prog->fs;
|
||||
struct ir3_shader *shader = ir3_get_shader(emit->prog->fs);
|
||||
emit->fs = ir3_shader_variant(shader, emit->key,
|
||||
false, emit->debug);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ static inline const struct ir3_shader_variant *
|
|||
fd4_emit_get_vp(struct fd4_emit *emit)
|
||||
{
|
||||
if (!emit->vs) {
|
||||
struct ir3_shader *shader = emit->prog->vs;
|
||||
struct ir3_shader *shader = ir3_get_shader(emit->prog->vs);
|
||||
emit->vs = ir3_shader_variant(shader, emit->key,
|
||||
emit->binning_pass, emit->debug);
|
||||
}
|
||||
|
|
@ -88,7 +88,7 @@ fd4_emit_get_fp(struct fd4_emit *emit)
|
|||
static const struct ir3_shader_variant binning_fs = {};
|
||||
emit->fs = &binning_fs;
|
||||
} else {
|
||||
struct ir3_shader *shader = emit->prog->fs;
|
||||
struct ir3_shader *shader = ir3_get_shader(emit->prog->fs);
|
||||
emit->fs = ir3_shader_variant(shader, emit->key,
|
||||
false, emit->debug);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ fd5_launch_grid(struct fd_context *ctx, const struct pipe_grid_info *info)
|
|||
struct fd_ringbuffer *ring = ctx->batch->draw;
|
||||
unsigned nglobal = 0;
|
||||
|
||||
v = ir3_shader_variant(ctx->compute, key, false, &ctx->debug);
|
||||
v = ir3_shader_variant(ir3_get_shader(ctx->compute), key, false, &ctx->debug);
|
||||
if (!v)
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ static inline const struct ir3_shader_variant *
|
|||
fd5_emit_get_vp(struct fd5_emit *emit)
|
||||
{
|
||||
if (!emit->vs) {
|
||||
struct ir3_shader *shader = emit->prog->vs;
|
||||
struct ir3_shader *shader = ir3_get_shader(emit->prog->vs);
|
||||
emit->vs = ir3_shader_variant(shader, emit->key,
|
||||
emit->binning_pass, emit->debug);
|
||||
}
|
||||
|
|
@ -96,7 +96,7 @@ fd5_emit_get_fp(struct fd5_emit *emit)
|
|||
static const struct ir3_shader_variant binning_fs = {};
|
||||
emit->fs = &binning_fs;
|
||||
} else {
|
||||
struct ir3_shader *shader = emit->prog->fs;
|
||||
struct ir3_shader *shader = ir3_get_shader(emit->prog->fs);
|
||||
emit->fs = ir3_shader_variant(shader, emit->key,
|
||||
false, emit->debug);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ fd6_launch_grid(struct fd_context *ctx, const struct pipe_grid_info *info)
|
|||
struct fd_ringbuffer *ring = ctx->batch->draw;
|
||||
unsigned nglobal = 0;
|
||||
|
||||
v = ir3_shader_variant(ctx->compute, key, false, &ctx->debug);
|
||||
v = ir3_shader_variant(ir3_get_shader(ctx->compute), key, false, &ctx->debug);
|
||||
if (!v)
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ fd6_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info,
|
|||
unsigned index_offset)
|
||||
{
|
||||
struct fd6_context *fd6_ctx = fd6_context(ctx);
|
||||
struct ir3_shader *gs = ctx->prog.gs;
|
||||
struct shader_info *gs_info = ir3_get_shader_info(ctx->prog.gs);
|
||||
struct fd6_emit emit = {
|
||||
.ctx = ctx,
|
||||
.vtx = &ctx->vtx,
|
||||
|
|
@ -195,7 +195,7 @@ fd6_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info,
|
|||
.fsaturate_s = fd6_ctx->fsaturate_s,
|
||||
.fsaturate_t = fd6_ctx->fsaturate_t,
|
||||
.fsaturate_r = fd6_ctx->fsaturate_r,
|
||||
.layer_zero = !gs || !(gs->nir->info.outputs_written & VARYING_BIT_LAYER),
|
||||
.layer_zero = !gs_info || !(gs_info->outputs_written & VARYING_BIT_LAYER),
|
||||
.vsamples = ctx->tex[PIPE_SHADER_VERTEX].samples,
|
||||
.fsamples = ctx->tex[PIPE_SHADER_FRAGMENT].samples,
|
||||
.sample_shading = (ctx->min_samples > 1),
|
||||
|
|
@ -218,7 +218,7 @@ fd6_draw_vbo(struct fd_context *ctx, const struct pipe_draw_info *info,
|
|||
if (!(ctx->prog.hs && ctx->prog.ds))
|
||||
return false;
|
||||
|
||||
shader_info *ds_info = &emit.key.ds->nir->info;
|
||||
struct shader_info *ds_info = ir3_get_shader_info(emit.key.ds);
|
||||
emit.key.key.tessellation = ir3_tess_mode(ds_info->tess.primitive_mode);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -97,11 +97,11 @@ ir3_cache_lookup(struct ir3_cache *cache, const struct ir3_cache_key *key,
|
|||
debug_assert(key->ds);
|
||||
|
||||
struct ir3_shader *shaders[MESA_SHADER_STAGES] = {
|
||||
[MESA_SHADER_VERTEX] = key->vs,
|
||||
[MESA_SHADER_TESS_CTRL] = key->hs,
|
||||
[MESA_SHADER_TESS_EVAL] = key->ds,
|
||||
[MESA_SHADER_GEOMETRY] = key->gs,
|
||||
[MESA_SHADER_FRAGMENT] = key->fs,
|
||||
[MESA_SHADER_VERTEX] = ir3_get_shader(key->vs),
|
||||
[MESA_SHADER_TESS_CTRL] = ir3_get_shader(key->hs),
|
||||
[MESA_SHADER_TESS_EVAL] = ir3_get_shader(key->ds),
|
||||
[MESA_SHADER_GEOMETRY] = ir3_get_shader(key->gs),
|
||||
[MESA_SHADER_FRAGMENT] = ir3_get_shader(key->fs),
|
||||
};
|
||||
|
||||
struct ir3_shader_variant *variants[MESA_SHADER_STAGES];
|
||||
|
|
@ -119,7 +119,8 @@ ir3_cache_lookup(struct ir3_cache *cache, const struct ir3_cache_key *key,
|
|||
}
|
||||
}
|
||||
|
||||
uint32_t safe_constlens = ir3_trim_constlen(variants, key->vs->compiler);
|
||||
struct ir3_compiler *compiler = shaders[MESA_SHADER_VERTEX]->compiler;
|
||||
uint32_t safe_constlens = ir3_trim_constlen(variants, compiler);
|
||||
shader_key.safe_constlen = true;
|
||||
|
||||
for (gl_shader_stage stage = MESA_SHADER_VERTEX;
|
||||
|
|
@ -136,7 +137,7 @@ ir3_cache_lookup(struct ir3_cache *cache, const struct ir3_cache_key *key,
|
|||
|
||||
if (ir3_has_binning_vs(&key->key)) {
|
||||
shader_key.safe_constlen = !!(safe_constlens & (1 << MESA_SHADER_VERTEX));
|
||||
bs = ir3_shader_variant(key->vs, key->key, true, debug);
|
||||
bs = ir3_shader_variant(shaders[MESA_SHADER_VERTEX], key->key, true, debug);
|
||||
if (!bs)
|
||||
return NULL;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
|
||||
/* key into program state cache */
|
||||
struct ir3_cache_key {
|
||||
struct ir3_shader *vs, *hs, *ds, *gs, *fs; // 5 pointers
|
||||
struct ir3_shader_state *vs, *hs, *ds, *gs, *fs; // 5 pointers
|
||||
struct ir3_shader_key key; // 7 dwords
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,16 @@
|
|||
#include "ir3/ir3_compiler.h"
|
||||
#include "ir3/ir3_nir.h"
|
||||
|
||||
/**
|
||||
* The hardware cso for shader state
|
||||
*
|
||||
* Initially just a container for the ir3_shader, but this is where we'll
|
||||
* plumb in async compile.
|
||||
*/
|
||||
struct ir3_shader_state {
|
||||
struct ir3_shader *shader;
|
||||
};
|
||||
|
||||
static void
|
||||
dump_shader_info(struct ir3_shader_variant *v, struct pipe_debug_callback *debug)
|
||||
{
|
||||
|
|
@ -246,7 +256,7 @@ ir3_shader_create(struct ir3_compiler *compiler,
|
|||
/* a bit annoying that compute-shader and normal shader state objects
|
||||
* aren't a bit more aligned.
|
||||
*/
|
||||
static struct ir3_shader *
|
||||
static struct ir3_shader_state *
|
||||
ir3_shader_create_compute(struct ir3_compiler *compiler,
|
||||
const struct pipe_compute_state *cso,
|
||||
struct pipe_debug_callback *debug,
|
||||
|
|
@ -275,7 +285,10 @@ ir3_shader_create_compute(struct ir3_compiler *compiler,
|
|||
|
||||
shader->initial_variants_done = true;
|
||||
|
||||
return shader;
|
||||
struct ir3_shader_state *hwcso = calloc(1, sizeof(*hwcso));
|
||||
hwcso->shader = shader;
|
||||
|
||||
return hwcso;
|
||||
}
|
||||
|
||||
void *
|
||||
|
|
@ -304,13 +317,18 @@ ir3_shader_state_create(struct pipe_context *pctx, const struct pipe_shader_stat
|
|||
{
|
||||
struct fd_context *ctx = fd_context(pctx);
|
||||
struct ir3_compiler *compiler = ctx->screen->compiler;
|
||||
return ir3_shader_create(compiler, cso, &ctx->debug, pctx->screen);
|
||||
struct ir3_shader_state *hwcso = calloc(1, sizeof(*hwcso));
|
||||
|
||||
hwcso->shader = ir3_shader_create(compiler, cso, &ctx->debug, pctx->screen);
|
||||
|
||||
return hwcso;
|
||||
}
|
||||
|
||||
void
|
||||
ir3_shader_state_delete(struct pipe_context *pctx, void *hwcso)
|
||||
ir3_shader_state_delete(struct pipe_context *pctx, void *_hwcso)
|
||||
{
|
||||
struct ir3_shader *so = hwcso;
|
||||
struct ir3_shader_state *hwcso = _hwcso;
|
||||
struct ir3_shader *so = hwcso->shader;
|
||||
|
||||
/* free the uploaded shaders, since this is handled outside of the
|
||||
* shared ir3 code (ie. not used by turnip):
|
||||
|
|
@ -326,6 +344,23 @@ ir3_shader_state_delete(struct pipe_context *pctx, void *hwcso)
|
|||
}
|
||||
|
||||
ir3_shader_destroy(so);
|
||||
free(hwcso);
|
||||
}
|
||||
|
||||
struct ir3_shader *
|
||||
ir3_get_shader(struct ir3_shader_state *hwcso)
|
||||
{
|
||||
if (!hwcso)
|
||||
return NULL;
|
||||
return hwcso->shader;
|
||||
}
|
||||
|
||||
struct shader_info *
|
||||
ir3_get_shader_info(struct ir3_shader_state *hwcso)
|
||||
{
|
||||
if (!hwcso)
|
||||
return NULL;
|
||||
return &hwcso->shader->nir->info;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -35,6 +35,13 @@ struct ir3_shader * ir3_shader_create(struct ir3_compiler *compiler,
|
|||
const struct pipe_shader_state *cso,
|
||||
struct pipe_debug_callback *debug,
|
||||
struct pipe_screen *screen);
|
||||
|
||||
/**
|
||||
* The ir3 hwcso type, use ir3_get_shader() to dereference the
|
||||
* underlying ir3_shader
|
||||
*/
|
||||
struct ir3_shader_state;
|
||||
|
||||
struct ir3_shader_variant * ir3_shader_variant(struct ir3_shader *shader,
|
||||
struct ir3_shader_key key, bool binning_pass,
|
||||
struct pipe_debug_callback *debug);
|
||||
|
|
@ -44,6 +51,9 @@ void * ir3_shader_compute_state_create(struct pipe_context *pctx,
|
|||
void * ir3_shader_state_create(struct pipe_context *pctx, const struct pipe_shader_state *cso);
|
||||
void ir3_shader_state_delete(struct pipe_context *pctx, void *hwcso);
|
||||
|
||||
struct ir3_shader * ir3_get_shader(struct ir3_shader_state *hwcso);
|
||||
struct shader_info * ir3_get_shader_info(struct ir3_shader_state *hwcso);
|
||||
|
||||
void ir3_prog_init(struct pipe_context *pctx);
|
||||
void ir3_screen_init(struct pipe_screen *pscreen);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue