diff options
author | Christian Gmeiner <[email protected]> | 2017-03-19 17:19:10 +0100 |
---|---|---|
committer | Christian Gmeiner <[email protected]> | 2017-04-05 19:58:10 +0200 |
commit | 7d2a80626633b08a347aa11f85f4d96585958e6a (patch) | |
tree | f7222634ecb2e30c13c915da3d5a00779d4c41c3 /src/gallium/drivers/etnaviv/etnaviv_context.c | |
parent | 9da54fdcb5b591a7d6c96871e92f8b183c0a5130 (diff) |
etnaviv: add etna_shader_key and generate variants if needed
Signed-off-by: Christian Gmeiner <[email protected]>
Diffstat (limited to 'src/gallium/drivers/etnaviv/etnaviv_context.c')
-rw-r--r-- | src/gallium/drivers/etnaviv/etnaviv_context.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c b/src/gallium/drivers/etnaviv/etnaviv_context.c index dfd9e1f73a6..d6734401029 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_context.c +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c @@ -106,6 +106,37 @@ etna_update_state_for_draw(struct etna_context *ctx, const struct pipe_draw_info } } +static bool +etna_get_vs(struct etna_context *ctx, struct etna_shader_key key) +{ + const struct etna_shader_variant *old = ctx->shader.vs; + + ctx->shader.vs = etna_shader_variant(ctx->shader.bind_vs, key, &ctx->debug); + + if (!ctx->shader.vs) + return false; + + if (old != ctx->shader.vs) + ctx->dirty |= ETNA_DIRTY_SHADER; + + return true; +} + +static bool +etna_get_fs(struct etna_context *ctx, struct etna_shader_key key) +{ + const struct etna_shader_variant *old = ctx->shader.fs; + + ctx->shader.fs = etna_shader_variant(ctx->shader.bind_fs, key, &ctx->debug); + + if (!ctx->shader.fs) + return false; + + if (old != ctx->shader.fs) + ctx->dirty |= ETNA_DIRTY_SHADER; + + return true; +} static void etna_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) @@ -152,6 +183,13 @@ etna_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) return; } + struct etna_shader_key key = {}; + + if (!etna_get_vs(ctx, key) || !etna_get_fs(ctx, key)) { + BUG("compiled shaders are not okay"); + return; + } + /* Update any derived state */ if (!etna_state_update(ctx)) return; |