diff options
author | Timothy Arceri <[email protected]> | 2016-06-30 14:55:40 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2016-06-30 16:51:25 +1000 |
commit | 1fb8c6df884c2a17cf980c4ea32db4c214903b55 (patch) | |
tree | a21b0de699816ce28de37dd61531a025cc984114 /src/mesa/drivers/dri | |
parent | 378f07ccb5bff7857d87a4fe5dff0b5e83f99895 (diff) |
glsl/mesa: split gl_shader in two
There are two distinctly different uses of this struct. The first
is to store GL shader objects. The second is to store information
about a shader stage thats been linked.
The two uses actually share few fields and there is clearly confusion
about their use. For example the linked shaders map one to one with
a program so can simply be destroyed along with the program. However
previously we were calling reference counting on the linked shaders.
We were also creating linked shaders with a name even though it
is always 0 and called the driver version of the _mesa_new_shader()
function unnecessarily for GL shader objects.
Acked-by: Iago Toral Quiroga <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_context.c | 5 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_context.h | 8 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_gs.c | 5 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_link.cpp | 24 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_program.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_program.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_shader.cpp | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_shader.h | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_tcs.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_tes.c | 3 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 6 |
11 files changed, 31 insertions, 33 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index c7a66cb9991..5e3c9d169b3 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -239,8 +239,9 @@ intel_update_state(struct gl_context * ctx, GLuint new_state) /* Resolve color for each active shader image. */ for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { - const struct gl_shader *shader = ctx->_Shader->CurrentProgram[i] ? - ctx->_Shader->CurrentProgram[i]->_LinkedShaders[i] : NULL; + const struct gl_linked_shader *shader = + ctx->_Shader->CurrentProgram[i] ? + ctx->_Shader->CurrentProgram[i]->_LinkedShaders[i] : NULL; if (unlikely(shader && shader->NumImages)) { for (unsigned j = 0; j < shader->NumImages; j++) { diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 9d7a5b45c36..cc032787667 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -366,7 +366,7 @@ struct brw_compute_program { struct brw_shader { - struct gl_shader base; + struct gl_linked_shader base; bool compiled_once; }; @@ -1581,15 +1581,15 @@ brw_update_sol_surface(struct brw_context *brw, uint32_t *out_offset, unsigned num_vector_components, unsigned stride_dwords, unsigned offset_dwords); void brw_upload_ubo_surfaces(struct brw_context *brw, - struct gl_shader *shader, + struct gl_linked_shader *shader, struct brw_stage_state *stage_state, struct brw_stage_prog_data *prog_data); void brw_upload_abo_surfaces(struct brw_context *brw, - struct gl_shader *shader, + struct gl_linked_shader *shader, struct brw_stage_state *stage_state, struct brw_stage_prog_data *prog_data); void brw_upload_image_surfaces(struct brw_context *brw, - struct gl_shader *shader, + struct gl_linked_shader *shader, struct brw_stage_state *stage_state, struct brw_stage_prog_data *prog_data); diff --git a/src/mesa/drivers/dri/i965/brw_gs.c b/src/mesa/drivers/dri/i965/brw_gs.c index 4ac1009447c..1ce74d8b0ef 100644 --- a/src/mesa/drivers/dri/i965/brw_gs.c +++ b/src/mesa/drivers/dri/i965/brw_gs.c @@ -98,7 +98,6 @@ brw_codegen_gs_prog(struct brw_context *brw, struct brw_gs_prog_key *key) { struct brw_compiler *compiler = brw->intelScreen->compiler; - struct gl_shader *shader = prog->_LinkedShaders[MESA_SHADER_GEOMETRY]; struct brw_stage_state *stage_state = &brw->gs.base; struct brw_gs_prog_data prog_data; bool start_busy = false; @@ -117,7 +116,7 @@ brw_codegen_gs_prog(struct brw_context *brw, * padding around uniform values below vec4 size, so the worst case is that * every uniform is a float which gets padded to the size of a vec4. */ - struct gl_shader *gs = prog->_LinkedShaders[MESA_SHADER_GEOMETRY]; + struct gl_linked_shader *gs = prog->_LinkedShaders[MESA_SHADER_GEOMETRY]; struct brw_shader *bgs = (struct brw_shader *) gs; int param_count = gp->program.Base.nir->num_uniforms / 4; @@ -161,7 +160,7 @@ brw_codegen_gs_prog(struct brw_context *brw, char *error_str; const unsigned *program = brw_compile_gs(brw->intelScreen->compiler, brw, mem_ctx, key, - &prog_data, shader->Program->nir, prog, + &prog_data, gs->Program->nir, prog, st_index, &program_size, &error_str); if (program == NULL) { ralloc_free(mem_ctx); diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp b/src/mesa/drivers/dri/i965/brw_link.cpp index 76c580b4648..5374685325c 100644 --- a/src/mesa/drivers/dri/i965/brw_link.cpp +++ b/src/mesa/drivers/dri/i965/brw_link.cpp @@ -43,12 +43,12 @@ static bool brw_shader_precompile(struct gl_context *ctx, struct gl_shader_program *sh_prog) { - struct gl_shader *vs = sh_prog->_LinkedShaders[MESA_SHADER_VERTEX]; - struct gl_shader *tcs = sh_prog->_LinkedShaders[MESA_SHADER_TESS_CTRL]; - struct gl_shader *tes = sh_prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]; - struct gl_shader *gs = sh_prog->_LinkedShaders[MESA_SHADER_GEOMETRY]; - struct gl_shader *fs = sh_prog->_LinkedShaders[MESA_SHADER_FRAGMENT]; - struct gl_shader *cs = sh_prog->_LinkedShaders[MESA_SHADER_COMPUTE]; + struct gl_linked_shader *vs = sh_prog->_LinkedShaders[MESA_SHADER_VERTEX]; + struct gl_linked_shader *tcs = sh_prog->_LinkedShaders[MESA_SHADER_TESS_CTRL]; + struct gl_linked_shader *tes = sh_prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]; + struct gl_linked_shader *gs = sh_prog->_LinkedShaders[MESA_SHADER_GEOMETRY]; + struct gl_linked_shader *fs = sh_prog->_LinkedShaders[MESA_SHADER_FRAGMENT]; + struct gl_linked_shader *cs = sh_prog->_LinkedShaders[MESA_SHADER_COMPUTE]; if (fs && !brw_fs_precompile(ctx, sh_prog, fs->Program)) return false; @@ -89,7 +89,7 @@ static void process_glsl_ir(gl_shader_stage stage, struct brw_context *brw, struct gl_shader_program *shader_prog, - struct gl_shader *shader) + struct gl_linked_shader *shader) { struct gl_context *ctx = &brw->ctx; const struct brw_compiler *compiler = brw->intelScreen->compiler; @@ -186,16 +186,14 @@ process_glsl_ir(gl_shader_stage stage, } } -extern "C" struct gl_shader * -brw_new_shader(struct gl_context *ctx, GLuint name, gl_shader_stage stage) +extern "C" struct gl_linked_shader * +brw_new_shader(gl_shader_stage stage) { struct brw_shader *shader; shader = rzalloc(NULL, struct brw_shader); if (shader) { shader->base.Stage = stage; - shader->base.Name = name; - _mesa_init_shader(ctx, &shader->base); } return &shader->base; @@ -209,13 +207,13 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg) unsigned int stage; for (stage = 0; stage < ARRAY_SIZE(shProg->_LinkedShaders); stage++) { - struct gl_shader *shader = shProg->_LinkedShaders[stage]; + struct gl_linked_shader *shader = shProg->_LinkedShaders[stage]; if (!shader) continue; struct gl_program *prog = ctx->Driver.NewProgram(ctx, _mesa_shader_stage_to_program(stage), - shader->Name); + 0); if (!prog) return false; prog->Parameters = _mesa_new_parameter_list(); diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index a1a81165ab1..aee9467ddb7 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -651,7 +651,7 @@ brw_stage_prog_data_free(const void *p) void brw_dump_ir(const char *stage, struct gl_shader_program *shader_prog, - struct gl_shader *shader, struct gl_program *prog) + struct gl_linked_shader *shader, struct gl_program *prog) { if (shader_prog) { if (shader->ir) { diff --git a/src/mesa/drivers/dri/i965/brw_program.h b/src/mesa/drivers/dri/i965/brw_program.h index 4d6299f0c31..5874d931623 100644 --- a/src/mesa/drivers/dri/i965/brw_program.h +++ b/src/mesa/drivers/dri/i965/brw_program.h @@ -60,7 +60,7 @@ brw_stage_prog_data_free(const void *prog_data); void brw_dump_ir(const char *stage, struct gl_shader_program *shader_prog, - struct gl_shader *shader, struct gl_program *prog); + struct gl_linked_shader *shader, struct gl_program *prog); void brw_upload_tcs_prog(struct brw_context *brw, uint64_t per_vertex_slots, uint32_t per_patch_slots); diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp index 5ce7b82bf5b..f3b54870de7 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.cpp +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp @@ -1158,7 +1158,7 @@ brw_assign_common_binding_table_offsets(gl_shader_stage stage, struct brw_stage_prog_data *stage_prog_data, uint32_t next_binding_table_offset) { - const struct gl_shader *shader = NULL; + const struct gl_linked_shader *shader = NULL; int num_textures = _mesa_fls(prog->SamplersUsed); if (shader_prog) @@ -1320,7 +1320,7 @@ brw_compile_tes(const struct brw_compiler *compiler, char **error_str) { const struct brw_device_info *devinfo = compiler->devinfo; - struct gl_shader *shader = + struct gl_linked_shader *shader = shader_prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]; const bool is_scalar = compiler->scalar_stage[MESA_SHADER_TESS_EVAL]; diff --git a/src/mesa/drivers/dri/i965/brw_shader.h b/src/mesa/drivers/dri/i965/brw_shader.h index d74c6d6af9a..dd9eb2d8867 100644 --- a/src/mesa/drivers/dri/i965/brw_shader.h +++ b/src/mesa/drivers/dri/i965/brw_shader.h @@ -289,8 +289,7 @@ bool brw_cs_precompile(struct gl_context *ctx, struct gl_program *prog); GLboolean brw_link_shader(struct gl_context *ctx, struct gl_shader_program *prog); -struct gl_shader *brw_new_shader(struct gl_context *ctx, GLuint name, - gl_shader_stage stage); +struct gl_linked_shader *brw_new_shader(gl_shader_stage stage); int type_size_scalar(const struct glsl_type *type); int type_size_vec4(const struct glsl_type *type); diff --git a/src/mesa/drivers/dri/i965/brw_tcs.c b/src/mesa/drivers/dri/i965/brw_tcs.c index d488715cac3..3ba9f2c7d74 100644 --- a/src/mesa/drivers/dri/i965/brw_tcs.c +++ b/src/mesa/drivers/dri/i965/brw_tcs.c @@ -197,7 +197,7 @@ brw_codegen_tcs_prog(struct brw_context *brw, * padding around uniform values below vec4 size, so the worst case is that * every uniform is a float which gets padded to the size of a vec4. */ - struct gl_shader *tcs = shader_prog ? + struct gl_linked_shader *tcs = shader_prog ? shader_prog->_LinkedShaders[MESA_SHADER_TESS_CTRL] : NULL; int param_count = nir->num_uniforms / 4; diff --git a/src/mesa/drivers/dri/i965/brw_tes.c b/src/mesa/drivers/dri/i965/brw_tes.c index d7b3e69a269..001655df872 100644 --- a/src/mesa/drivers/dri/i965/brw_tes.c +++ b/src/mesa/drivers/dri/i965/brw_tes.c @@ -150,7 +150,8 @@ brw_codegen_tes_prog(struct brw_context *brw, * padding around uniform values below vec4 size, so the worst case is that * every uniform is a float which gets padded to the size of a vec4. */ - struct gl_shader *tes = shader_prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]; + struct gl_linked_shader *tes = + shader_prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]; int param_count = nir->num_uniforms / 4; prog_data.base.base.param = diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c index eed16acf31c..c101e059647 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c @@ -946,7 +946,7 @@ const struct brw_tracked_state brw_cs_texture_surfaces = { void brw_upload_ubo_surfaces(struct brw_context *brw, - struct gl_shader *shader, + struct gl_linked_shader *shader, struct brw_stage_state *stage_state, struct brw_stage_prog_data *prog_data) { @@ -1064,7 +1064,7 @@ const struct brw_tracked_state brw_cs_ubo_surfaces = { void brw_upload_abo_surfaces(struct brw_context *brw, - struct gl_shader *shader, + struct gl_linked_shader *shader, struct brw_stage_state *stage_state, struct brw_stage_prog_data *prog_data) { @@ -1350,7 +1350,7 @@ update_image_surface(struct brw_context *brw, void brw_upload_image_surfaces(struct brw_context *brw, - struct gl_shader *shader, + struct gl_linked_shader *shader, struct brw_stage_state *stage_state, struct brw_stage_prog_data *prog_data) { |