Signed-off-by: Christian Gmeiner <christian.gmei...@gmail.com> --- src/gallium/drivers/etnaviv/etnaviv_context.c | 23 ++++++-- src/gallium/drivers/etnaviv/etnaviv_shader.c | 55 +++++++++++++++++-- 2 files changed, 68 insertions(+), 10 deletions(-)
diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c b/src/gallium/drivers/etnaviv/etnaviv_context.c index d78d8941087..3b764f0111b 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_context.c +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c @@ -25,6 +25,8 @@ * Christian Gmeiner <christian.gmei...@gmail.com> */ +#include "etnaviv_eir.h" /* TODO: fix problems with COMPARE_FUNC_NEVER */ + #include "etnaviv_context.h" #include "etnaviv_blend.h" @@ -466,12 +468,21 @@ etna_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) etna_texture_init(pctx); etna_transfer_init(pctx); - ctx->uniform_dirty_flags = etna_uniform_dirty_flags; - ctx->uniforms_write = etna_uniforms_write; - ctx->uniforms_const_count = etna_uniforms_const_count; - ctx->create_shader_variant = etna_shader_variant; - ctx->shader_link = etna_shader_link; - ctx->shader_update_vertex = etna_shader_update_vertex; + if (etna_mesa_debug & ETNA_DBG_NIR) { + ctx->uniform_dirty_flags = eir_uniform_dirty_flags; + ctx->uniforms_write = eir_uniforms_write; + ctx->uniforms_const_count = eir_uniforms_const_count; + ctx->create_shader_variant = eir_shader_variant; + ctx->shader_link = eir_link_shaders; + ctx->shader_update_vertex = eir_shader_update_vertex; + } else { + ctx->uniform_dirty_flags = etna_uniform_dirty_flags; + ctx->uniforms_write = etna_uniforms_write; + ctx->uniforms_const_count = etna_uniforms_const_count; + ctx->create_shader_variant = etna_shader_variant; + ctx->shader_link = etna_shader_link; + ctx->shader_update_vertex = etna_shader_update_vertex; + } ctx->blitter = util_blitter_create(pctx); if (!ctx->blitter) diff --git a/src/gallium/drivers/etnaviv/etnaviv_shader.c b/src/gallium/drivers/etnaviv/etnaviv_shader.c index 34c546c3c66..cec27dcb2f8 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_shader.c +++ b/src/gallium/drivers/etnaviv/etnaviv_shader.c @@ -24,6 +24,7 @@ * Wladimir J. van der Laan <laa...@gmail.com> */ +#include "etnaviv_eir.h" #include "etnaviv_shader.h" #include "etnaviv_compiler.h" @@ -36,6 +37,44 @@ #include "util/u_math.h" #include "util/u_memory.h" +static struct eir_shader * +create_shader_stateobj(struct pipe_context *pctx, const struct pipe_shader_state *cso, + gl_shader_stage type) +{ + struct etna_context *ctx = etna_context(pctx); + struct eir_compiler *compiler = ctx->screen->compiler; + + return eir_shader_create(compiler, cso, type, &ctx->debug, pctx->screen); +} + +static void * +etna_fs_state_create(struct pipe_context *pctx, const struct pipe_shader_state *cso) +{ + return create_shader_stateobj(pctx, cso, MESA_SHADER_FRAGMENT); +} + +static void +etna_fs_state_delete(struct pipe_context *pctx, void *hwcso) +{ + struct eir_shader *so = hwcso; + + eir_shader_destroy(so); +} + +static void * +etna_vs_state_create(struct pipe_context *pctx, const struct pipe_shader_state *cso) +{ + return create_shader_stateobj(pctx, cso, MESA_SHADER_VERTEX); +} + +static void +etna_vs_state_delete(struct pipe_context *pctx, void *hwcso) +{ + struct eir_shader *so = hwcso; + + eir_shader_destroy(so); +} + /* Upload shader code to bo, if not already done */ static bool etna_icache_upload_shader(struct etna_context *ctx, struct etna_shader_variant *v) { @@ -459,10 +498,18 @@ etna_bind_vs_state(struct pipe_context *pctx, void *hwcso) void etna_shader_init(struct pipe_context *pctx) { - pctx->create_fs_state = etna_create_shader_state; + if (etna_mesa_debug & ETNA_DBG_NIR) { + pctx->create_fs_state = etna_fs_state_create; + pctx->delete_fs_state = etna_fs_state_delete; + pctx->create_vs_state = etna_vs_state_create; + pctx->delete_vs_state = etna_vs_state_delete; + } else { + pctx->create_fs_state = etna_create_shader_state; + pctx->delete_fs_state = etna_delete_shader_state; + pctx->create_vs_state = etna_create_shader_state; + pctx->delete_vs_state = etna_delete_shader_state; + } + pctx->bind_fs_state = etna_bind_fs_state; - pctx->delete_fs_state = etna_delete_shader_state; - pctx->create_vs_state = etna_create_shader_state; pctx->bind_vs_state = etna_bind_vs_state; - pctx->delete_vs_state = etna_delete_shader_state; } -- 2.21.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev