Also, swap vs and fs constructor or so fs comes first. Signed-off-by: Kristian H. Kristensen <hoegsberg@google.com> Reviewed-by: Eric Anholt <eric@anholt.net>tags/19.3-branchpoint
| @@ -38,43 +38,6 @@ | |||
| #include "fd3_texture.h" | |||
| #include "fd3_format.h" | |||
| static struct ir3_shader * | |||
| create_shader_stateobj(struct pipe_context *pctx, const struct pipe_shader_state *cso, | |||
| gl_shader_stage type) | |||
| { | |||
| struct fd_context *ctx = fd_context(pctx); | |||
| struct ir3_compiler *compiler = ctx->screen->compiler; | |||
| return ir3_shader_create(compiler, cso, type, &ctx->debug, pctx->screen); | |||
| } | |||
| static void * | |||
| fd3_fp_state_create(struct pipe_context *pctx, | |||
| const struct pipe_shader_state *cso) | |||
| { | |||
| return create_shader_stateobj(pctx, cso, MESA_SHADER_FRAGMENT); | |||
| } | |||
| static void | |||
| fd3_fp_state_delete(struct pipe_context *pctx, void *hwcso) | |||
| { | |||
| struct ir3_shader *so = hwcso; | |||
| ir3_shader_destroy(so); | |||
| } | |||
| static void * | |||
| fd3_vp_state_create(struct pipe_context *pctx, | |||
| const struct pipe_shader_state *cso) | |||
| { | |||
| return create_shader_stateobj(pctx, cso, MESA_SHADER_VERTEX); | |||
| } | |||
| static void | |||
| fd3_vp_state_delete(struct pipe_context *pctx, void *hwcso) | |||
| { | |||
| struct ir3_shader *so = hwcso; | |||
| ir3_shader_destroy(so); | |||
| } | |||
| bool | |||
| fd3_needs_manual_clipping(const struct ir3_shader *shader, | |||
| const struct pipe_rasterizer_state *rast) | |||
| @@ -485,11 +448,6 @@ fd3_program_emit(struct fd_ringbuffer *ring, struct fd3_emit *emit, | |||
| void | |||
| fd3_prog_init(struct pipe_context *pctx) | |||
| { | |||
| pctx->create_fs_state = fd3_fp_state_create; | |||
| pctx->delete_fs_state = fd3_fp_state_delete; | |||
| pctx->create_vs_state = fd3_vp_state_create; | |||
| pctx->delete_vs_state = fd3_vp_state_delete; | |||
| ir3_prog_init(pctx); | |||
| fd_prog_init(pctx); | |||
| } | |||
| @@ -37,43 +37,6 @@ | |||
| #include "fd4_texture.h" | |||
| #include "fd4_format.h" | |||
| static struct ir3_shader * | |||
| create_shader_stateobj(struct pipe_context *pctx, const struct pipe_shader_state *cso, | |||
| gl_shader_stage type) | |||
| { | |||
| struct fd_context *ctx = fd_context(pctx); | |||
| struct ir3_compiler *compiler = ctx->screen->compiler; | |||
| return ir3_shader_create(compiler, cso, type, &ctx->debug, pctx->screen); | |||
| } | |||
| static void * | |||
| fd4_fp_state_create(struct pipe_context *pctx, | |||
| const struct pipe_shader_state *cso) | |||
| { | |||
| return create_shader_stateobj(pctx, cso, MESA_SHADER_FRAGMENT); | |||
| } | |||
| static void | |||
| fd4_fp_state_delete(struct pipe_context *pctx, void *hwcso) | |||
| { | |||
| struct ir3_shader *so = hwcso; | |||
| ir3_shader_destroy(so); | |||
| } | |||
| static void * | |||
| fd4_vp_state_create(struct pipe_context *pctx, | |||
| const struct pipe_shader_state *cso) | |||
| { | |||
| return create_shader_stateobj(pctx, cso, MESA_SHADER_VERTEX); | |||
| } | |||
| static void | |||
| fd4_vp_state_delete(struct pipe_context *pctx, void *hwcso) | |||
| { | |||
| struct ir3_shader *so = hwcso; | |||
| ir3_shader_destroy(so); | |||
| } | |||
| static void | |||
| emit_shader(struct fd_ringbuffer *ring, const struct ir3_shader_variant *so) | |||
| { | |||
| @@ -569,11 +532,6 @@ fd4_program_emit(struct fd_ringbuffer *ring, struct fd4_emit *emit, | |||
| void | |||
| fd4_prog_init(struct pipe_context *pctx) | |||
| { | |||
| pctx->create_fs_state = fd4_fp_state_create; | |||
| pctx->delete_fs_state = fd4_fp_state_delete; | |||
| pctx->create_vs_state = fd4_vp_state_create; | |||
| pctx->delete_vs_state = fd4_vp_state_delete; | |||
| ir3_prog_init(pctx); | |||
| fd_prog_init(pctx); | |||
| } | |||
| @@ -40,43 +40,6 @@ | |||
| #include "ir3_cache.h" | |||
| static struct ir3_shader * | |||
| create_shader_stateobj(struct pipe_context *pctx, const struct pipe_shader_state *cso, | |||
| gl_shader_stage type) | |||
| { | |||
| struct fd_context *ctx = fd_context(pctx); | |||
| struct ir3_compiler *compiler = ctx->screen->compiler; | |||
| return ir3_shader_create(compiler, cso, type, &ctx->debug, pctx->screen); | |||
| } | |||
| static void * | |||
| fd5_fp_state_create(struct pipe_context *pctx, | |||
| const struct pipe_shader_state *cso) | |||
| { | |||
| return create_shader_stateobj(pctx, cso, MESA_SHADER_FRAGMENT); | |||
| } | |||
| static void | |||
| fd5_fp_state_delete(struct pipe_context *pctx, void *hwcso) | |||
| { | |||
| struct ir3_shader *so = hwcso; | |||
| ir3_shader_destroy(so); | |||
| } | |||
| static void * | |||
| fd5_vp_state_create(struct pipe_context *pctx, | |||
| const struct pipe_shader_state *cso) | |||
| { | |||
| return create_shader_stateobj(pctx, cso, MESA_SHADER_VERTEX); | |||
| } | |||
| static void | |||
| fd5_vp_state_delete(struct pipe_context *pctx, void *hwcso) | |||
| { | |||
| struct ir3_shader *so = hwcso; | |||
| ir3_shader_destroy(so); | |||
| } | |||
| void | |||
| fd5_emit_shader(struct fd_ringbuffer *ring, const struct ir3_shader_variant *so) | |||
| { | |||
| @@ -722,11 +685,6 @@ fd5_program_emit(struct fd_context *ctx, struct fd_ringbuffer *ring, | |||
| void | |||
| fd5_prog_init(struct pipe_context *pctx) | |||
| { | |||
| pctx->create_fs_state = fd5_fp_state_create; | |||
| pctx->delete_fs_state = fd5_fp_state_delete; | |||
| pctx->create_vs_state = fd5_vp_state_create; | |||
| pctx->delete_vs_state = fd5_vp_state_delete; | |||
| ir3_prog_init(pctx); | |||
| fd_prog_init(pctx); | |||
| } | |||
| @@ -39,61 +39,6 @@ | |||
| #include "fd6_texture.h" | |||
| #include "fd6_format.h" | |||
| static struct ir3_shader * | |||
| create_shader_stateobj(struct pipe_context *pctx, const struct pipe_shader_state *cso, | |||
| gl_shader_stage type) | |||
| { | |||
| struct fd_context *ctx = fd_context(pctx); | |||
| struct ir3_compiler *compiler = ctx->screen->compiler; | |||
| struct ir3_shader *shader = | |||
| ir3_shader_create(compiler, cso, type, &ctx->debug, pctx->screen); | |||
| unsigned packets, size; | |||
| /* pre-calculate size required for userconst stateobj: */ | |||
| ir3_user_consts_size(&shader->ubo_state, &packets, &size); | |||
| /* also account for UBO addresses: */ | |||
| packets += 1; | |||
| size += 2 * shader->const_state.num_ubos; | |||
| unsigned sizedwords = (4 * packets) + size; | |||
| shader->ubo_state.cmdstream_size = sizedwords * 4; | |||
| return shader; | |||
| } | |||
| static void * | |||
| fd6_fp_state_create(struct pipe_context *pctx, | |||
| const struct pipe_shader_state *cso) | |||
| { | |||
| return create_shader_stateobj(pctx, cso, MESA_SHADER_FRAGMENT); | |||
| } | |||
| static void | |||
| fd6_fp_state_delete(struct pipe_context *pctx, void *hwcso) | |||
| { | |||
| struct ir3_shader *so = hwcso; | |||
| struct fd_context *ctx = fd_context(pctx); | |||
| ir3_cache_invalidate(fd6_context(ctx)->shader_cache, hwcso); | |||
| ir3_shader_destroy(so); | |||
| } | |||
| static void * | |||
| fd6_vp_state_create(struct pipe_context *pctx, | |||
| const struct pipe_shader_state *cso) | |||
| { | |||
| return create_shader_stateobj(pctx, cso, MESA_SHADER_VERTEX); | |||
| } | |||
| static void | |||
| fd6_vp_state_delete(struct pipe_context *pctx, void *hwcso) | |||
| { | |||
| struct ir3_shader *so = hwcso; | |||
| struct fd_context *ctx = fd_context(pctx); | |||
| ir3_cache_invalidate(fd6_context(ctx)->shader_cache, hwcso); | |||
| ir3_shader_destroy(so); | |||
| } | |||
| void | |||
| fd6_emit_shader(struct fd_ringbuffer *ring, const struct ir3_shader_variant *so) | |||
| { | |||
| @@ -749,6 +694,37 @@ static const struct ir3_cache_funcs cache_funcs = { | |||
| .destroy_state = fd6_program_destroy, | |||
| }; | |||
| static void * | |||
| fd6_shader_state_create(struct pipe_context *pctx, const struct pipe_shader_state *cso) | |||
| { | |||
| struct fd_context *ctx = fd_context(pctx); | |||
| struct ir3_compiler *compiler = ctx->screen->compiler; | |||
| struct ir3_shader *shader = | |||
| ir3_shader_create(compiler, cso, &ctx->debug, pctx->screen); | |||
| unsigned packets, size; | |||
| /* pre-calculate size required for userconst stateobj: */ | |||
| ir3_user_consts_size(&shader->ubo_state, &packets, &size); | |||
| /* also account for UBO addresses: */ | |||
| packets += 1; | |||
| size += 2 * shader->const_state.num_ubos; | |||
| unsigned sizedwords = (4 * packets) + size; | |||
| shader->ubo_state.cmdstream_size = sizedwords * 4; | |||
| return shader; | |||
| } | |||
| static void | |||
| fd6_shader_state_delete(struct pipe_context *pctx, void *hwcso) | |||
| { | |||
| struct ir3_shader *so = hwcso; | |||
| struct fd_context *ctx = fd_context(pctx); | |||
| ir3_cache_invalidate(fd6_context(ctx)->shader_cache, hwcso); | |||
| ir3_shader_destroy(so); | |||
| } | |||
| void | |||
| fd6_prog_init(struct pipe_context *pctx) | |||
| { | |||
| @@ -756,11 +732,11 @@ fd6_prog_init(struct pipe_context *pctx) | |||
| fd6_context(ctx)->shader_cache = ir3_cache_create(&cache_funcs, ctx); | |||
| pctx->create_fs_state = fd6_fp_state_create; | |||
| pctx->delete_fs_state = fd6_fp_state_delete; | |||
| pctx->create_vs_state = fd6_shader_state_create; | |||
| pctx->delete_vs_state = fd6_shader_state_delete; | |||
| pctx->create_vs_state = fd6_vp_state_create; | |||
| pctx->delete_vs_state = fd6_vp_state_delete; | |||
| pctx->create_fs_state = fd6_shader_state_create; | |||
| pctx->delete_fs_state = fd6_shader_state_delete; | |||
| fd_prog_init(pctx); | |||
| } | |||
| @@ -110,7 +110,7 @@ copy_stream_out(struct ir3_stream_output_info *i, | |||
| struct ir3_shader * | |||
| ir3_shader_create(struct ir3_compiler *compiler, | |||
| const struct pipe_shader_state *cso, gl_shader_stage type, | |||
| const struct pipe_shader_state *cso, | |||
| struct pipe_debug_callback *debug, | |||
| struct pipe_screen *screen) | |||
| { | |||
| @@ -689,3 +689,37 @@ ir3_emit_cs_consts(const struct ir3_shader_variant *v, struct fd_ringbuffer *rin | |||
| } | |||
| } | |||
| } | |||
| static void * | |||
| ir3_shader_state_create(struct pipe_context *pctx, const struct pipe_shader_state *cso) | |||
| { | |||
| struct fd_context *ctx = fd_context(pctx); | |||
| struct ir3_compiler *compiler = ctx->screen->compiler; | |||
| return ir3_shader_create(compiler, cso, &ctx->debug, pctx->screen); | |||
| } | |||
| static void | |||
| ir3_shader_state_delete(struct pipe_context *pctx, void *hwcso) | |||
| { | |||
| struct ir3_shader *so = hwcso; | |||
| ir3_shader_destroy(so); | |||
| } | |||
| void | |||
| ir3_prog_init(struct pipe_context *pctx) | |||
| { | |||
| pctx->create_vs_state = ir3_shader_state_create; | |||
| pctx->delete_vs_state = ir3_shader_state_delete; | |||
| pctx->create_tcs_state = ir3_shader_state_create; | |||
| pctx->delete_tcs_state = ir3_shader_state_delete; | |||
| pctx->create_tes_state = ir3_shader_state_create; | |||
| pctx->delete_tes_state = ir3_shader_state_delete; | |||
| pctx->create_gs_state = ir3_shader_state_create; | |||
| pctx->delete_gs_state = ir3_shader_state_delete; | |||
| pctx->create_fs_state = ir3_shader_state_create; | |||
| pctx->delete_fs_state = ir3_shader_state_delete; | |||
| } | |||
| @@ -32,7 +32,7 @@ | |||
| #include "ir3/ir3_shader.h" | |||
| struct ir3_shader * ir3_shader_create(struct ir3_compiler *compiler, | |||
| const struct pipe_shader_state *cso, gl_shader_stage type, | |||
| const struct pipe_shader_state *cso, | |||
| struct pipe_debug_callback *debug, | |||
| struct pipe_screen *screen); | |||
| struct ir3_shader * | |||
| @@ -83,4 +83,6 @@ void ir3_emit_fs_consts(const struct ir3_shader_variant *v, struct fd_ringbuffer | |||
| void ir3_emit_cs_consts(const struct ir3_shader_variant *v, struct fd_ringbuffer *ring, | |||
| struct fd_context *ctx, const struct pipe_grid_info *info); | |||
| void ir3_prog_init(struct pipe_context *pctx); | |||
| #endif /* IR3_GALLIUM_H_ */ | |||