summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-06-30 14:55:40 +1000
committerTimothy Arceri <[email protected]>2016-06-30 16:51:25 +1000
commit1fb8c6df884c2a17cf980c4ea32db4c214903b55 (patch)
treea21b0de699816ce28de37dd61531a025cc984114 /src/mesa
parent378f07ccb5bff7857d87a4fe5dff0b5e83f99895 (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')
-rw-r--r--src/mesa/drivers/common/meta.c2
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.c5
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.h8
-rw-r--r--src/mesa/drivers/dri/i965/brw_gs.c5
-rw-r--r--src/mesa/drivers/dri/i965/brw_link.cpp24
-rw-r--r--src/mesa/drivers/dri/i965/brw_program.c2
-rw-r--r--src/mesa/drivers/dri/i965/brw_program.h2
-rw-r--r--src/mesa/drivers/dri/i965/brw_shader.cpp4
-rw-r--r--src/mesa/drivers/dri/i965/brw_shader.h3
-rw-r--r--src/mesa/drivers/dri/i965/brw_tcs.c2
-rw-r--r--src/mesa/drivers/dri/i965/brw_tes.c3
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_surface_state.c6
-rw-r--r--src/mesa/main/api_validate.c6
-rw-r--r--src/mesa/main/dd.h3
-rw-r--r--src/mesa/main/ff_fragment_shader.cpp2
-rw-r--r--src/mesa/main/mtypes.h143
-rw-r--r--src/mesa/main/shader_query.cpp2
-rw-r--r--src/mesa/main/shaderapi.c19
-rw-r--r--src/mesa/main/shaderobj.c32
-rw-r--r--src/mesa/main/shaderobj.h7
-rw-r--r--src/mesa/main/uniform_query.cpp4
-rw-r--r--src/mesa/main/uniforms.c2
-rw-r--r--src/mesa/program/ir_to_mesa.cpp4
-rw-r--r--src/mesa/program/ir_to_mesa.h2
-rw-r--r--src/mesa/program/prog_print.c2
-rw-r--r--src/mesa/program/prog_print.h2
-rw-r--r--src/mesa/state_tracker/st_atom_constbuf.c2
-rw-r--r--src/mesa/state_tracker/st_atom_image.c2
-rw-r--r--src/mesa/state_tracker/st_atom_storagebuf.c2
-rw-r--r--src/mesa/state_tracker/st_glsl_to_nir.cpp2
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp6
-rw-r--r--src/mesa/state_tracker/st_nir.h2
-rw-r--r--src/mesa/state_tracker/st_program.c7
33 files changed, 225 insertions, 94 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index be671b4b629..df57c87fa3f 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -129,7 +129,7 @@ meta_compile_shader_with_debug(struct gl_context *ctx, gl_shader_stage stage,
const GLuint name = ~0;
struct gl_shader *sh;
- sh = ctx->Driver.NewShader(ctx, name, stage);
+ sh = _mesa_new_shader(ctx, name, stage);
sh->Source = strdup(source);
sh->CompileStatus = false;
_mesa_compile_shader(ctx, sh);
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)
{
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 8efbf50c092..c0962241f84 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -207,7 +207,8 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
GLenum mode_before_gs = mode;
if (tes) {
- struct gl_shader *tes_sh = tes->_LinkedShaders[MESA_SHADER_TESS_EVAL];
+ struct gl_linked_shader *tes_sh =
+ tes->_LinkedShaders[MESA_SHADER_TESS_EVAL];
if (tes_sh->TessEval.PointMode)
mode_before_gs = GL_POINTS;
else if (tes_sh->TessEval.PrimitiveMode == GL_ISOLINES)
@@ -324,7 +325,8 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
else if (ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL]) {
struct gl_shader_program *tes =
ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
- struct gl_shader *tes_sh = tes->_LinkedShaders[MESA_SHADER_TESS_EVAL];
+ struct gl_linked_shader *tes_sh =
+ tes->_LinkedShaders[MESA_SHADER_TESS_EVAL];
if (tes_sh->TessEval.PointMode)
pass = ctx->TransformFeedback.Mode == GL_POINTS;
else if (tes_sh->TessEval.PrimitiveMode == GL_ISOLINES)
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index f918bb6f717..4891e2a3728 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -783,8 +783,7 @@ struct dd_function_table {
* \name GLSL-related functions (ARB extensions and OpenGL 2.x)
*/
/*@{*/
- struct gl_shader *(*NewShader)(struct gl_context *ctx,
- GLuint name, gl_shader_stage stage);
+ struct gl_linked_shader *(*NewShader)(gl_shader_stage stage);
void (*UseProgram)(struct gl_context *ctx, struct gl_shader_program *shProg);
/*@}*/
diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index d0def7c5f70..f90d31ae7e9 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -1203,7 +1203,7 @@ create_new_program(struct gl_context *ctx, struct state_key *key)
_mesa_glsl_parse_state *state;
p.mem_ctx = ralloc_context(NULL);
- p.shader = ctx->Driver.NewShader(ctx, 0, MESA_SHADER_FRAGMENT);
+ p.shader = _mesa_new_shader(ctx, 0, MESA_SHADER_FRAGMENT);
p.shader->ir = new(p.shader) exec_list;
state = new(p.shader) _mesa_glsl_parse_state(ctx, MESA_SHADER_FRAGMENT,
p.shader);
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 73ae55d83eb..fdd445f6857 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2235,30 +2235,13 @@ struct gl_subroutine_function
};
/**
- * A GLSL vertex or fragment shader object.
+ * A linked GLSL shader object.
*/
-struct gl_shader
+struct gl_linked_shader
{
- /** GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB ||
- * GL_TESS_CONTROL_SHADER || GL_TESS_EVALUATION_SHADER.
- * Must be the first field.
- */
- GLenum Type;
gl_shader_stage Stage;
- GLuint Name; /**< AKA the handle */
- GLint RefCount; /**< Reference count */
- GLchar *Label; /**< GL_KHR_debug */
- GLboolean DeletePending;
- GLboolean CompileStatus;
- bool IsES; /**< True if this shader uses GLSL ES */
-
- GLuint SourceChecksum; /**< for debug/logging purposes */
- const GLchar *Source; /**< Source code string */
struct gl_program *Program; /**< Post-compile assembly code */
- GLchar *InfoLog;
-
- unsigned Version; /**< GLSL version used for linking */
/**
* \name Sampler tracking
@@ -2450,6 +2433,126 @@ struct gl_shader
struct gl_subroutine_function *SubroutineFunctions;
};
+/**
+ * A GLSL shader object.
+ */
+struct gl_shader
+{
+ /** GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB ||
+ * GL_TESS_CONTROL_SHADER || GL_TESS_EVALUATION_SHADER.
+ * Must be the first field.
+ */
+ GLenum Type;
+ gl_shader_stage Stage;
+ GLuint Name; /**< AKA the handle */
+ GLint RefCount; /**< Reference count */
+ GLchar *Label; /**< GL_KHR_debug */
+ GLboolean DeletePending;
+ GLboolean CompileStatus;
+ bool IsES; /**< True if this shader uses GLSL ES */
+
+ GLuint SourceChecksum; /**< for debug/logging purposes */
+ const GLchar *Source; /**< Source code string */
+
+ GLchar *InfoLog;
+
+ unsigned Version; /**< GLSL version used for linking */
+
+ struct exec_list *ir;
+ struct glsl_symbol_table *symbols;
+
+ bool uses_builtin_functions;
+ bool uses_gl_fragcoord;
+ bool redeclares_gl_fragcoord;
+ bool ARB_fragment_coord_conventions_enable;
+
+ /**
+ * Fragment shader state from GLSL 1.50 layout qualifiers.
+ */
+ bool origin_upper_left;
+ bool pixel_center_integer;
+
+ struct {
+ /** Global xfb_stride out qualifier if any */
+ GLuint BufferStride[MAX_FEEDBACK_BUFFERS];
+ } TransformFeedback;
+
+ /**
+ * Tessellation Control shader state from layout qualifiers.
+ */
+ struct {
+ /**
+ * 0 - vertices not declared in shader, or
+ * 1 .. GL_MAX_PATCH_VERTICES
+ */
+ GLint VerticesOut;
+ } TessCtrl;
+
+ /**
+ * Tessellation Evaluation shader state from layout qualifiers.
+ */
+ struct {
+ /**
+ * GL_TRIANGLES, GL_QUADS, GL_ISOLINES or PRIM_UNKNOWN if it's not set
+ * in this shader.
+ */
+ GLenum PrimitiveMode;
+ /**
+ * GL_EQUAL, GL_FRACTIONAL_ODD, GL_FRACTIONAL_EVEN, or 0 if it's not set
+ * in this shader.
+ */
+ GLenum Spacing;
+ /**
+ * GL_CW, GL_CCW, or 0 if it's not set in this shader.
+ */
+ GLenum VertexOrder;
+ /**
+ * 1, 0, or -1 if it's not set in this shader.
+ */
+ int PointMode;
+ } TessEval;
+
+ /**
+ * Geometry shader state from GLSL 1.50 layout qualifiers.
+ */
+ struct {
+ GLint VerticesOut;
+ /**
+ * 0 - Invocations count not declared in shader, or
+ * 1 .. MAX_GEOMETRY_SHADER_INVOCATIONS
+ */
+ GLint Invocations;
+ /**
+ * GL_POINTS, GL_LINES, GL_LINES_ADJACENCY, GL_TRIANGLES, or
+ * GL_TRIANGLES_ADJACENCY, or PRIM_UNKNOWN if it's not set in this
+ * shader.
+ */
+ GLenum InputType;
+ /**
+ * GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP, or PRIM_UNKNOWN if
+ * it's not set in this shader.
+ */
+ GLenum OutputType;
+ } Geom;
+
+ /**
+ * Whether early fragment tests are enabled as defined by
+ * ARB_shader_image_load_store.
+ */
+ bool EarlyFragmentTests;
+
+ /**
+ * Compute shader state from ARB_compute_shader layout qualifiers.
+ */
+ struct {
+ /**
+ * Size specified using local_size_{x,y,z}, or all 0's to indicate that
+ * it's not set in this shader.
+ */
+ unsigned LocalSize[3];
+ } Comp;
+};
+
struct gl_uniform_buffer_variable
{
@@ -2834,7 +2937,7 @@ struct gl_shader_program
* \c MESA_SHADER_* defines. Entries for non-existent stages will be
* \c NULL.
*/
- struct gl_shader *_LinkedShaders[MESA_SHADER_STAGES];
+ struct gl_linked_shader *_LinkedShaders[MESA_SHADER_STAGES];
/** List of all active resources after linking. */
struct gl_program_resource *ProgramResourceList;
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 5956ce4976d..b5e1a44417f 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -1264,7 +1264,7 @@ _mesa_program_resource_prop(struct gl_shader_program *shProg,
return 1;
case GL_COMPATIBLE_SUBROUTINES: {
const struct gl_uniform_storage *uni;
- struct gl_shader *sh;
+ struct gl_linked_shader *sh;
unsigned count, i;
int j;
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 142e75089df..962b42e62ae 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -2175,7 +2175,8 @@ _mesa_copy_linked_program_data(gl_shader_stage type,
case MESA_SHADER_TESS_EVAL: {
struct gl_tess_eval_program *dst_tep =
(struct gl_tess_eval_program *) dst;
- struct gl_shader *tes_sh = src->_LinkedShaders[MESA_SHADER_TESS_EVAL];
+ struct gl_linked_shader *tes_sh =
+ src->_LinkedShaders[MESA_SHADER_TESS_EVAL];
dst_tep->PrimitiveMode = tes_sh->TessEval.PrimitiveMode;
dst_tep->Spacing = tes_sh->TessEval.Spacing;
@@ -2187,7 +2188,8 @@ _mesa_copy_linked_program_data(gl_shader_stage type,
}
case MESA_SHADER_GEOMETRY: {
struct gl_geometry_program *dst_gp = (struct gl_geometry_program *) dst;
- struct gl_shader *geom_sh = src->_LinkedShaders[MESA_SHADER_GEOMETRY];
+ struct gl_linked_shader *geom_sh =
+ src->_LinkedShaders[MESA_SHADER_GEOMETRY];
dst_gp->VerticesIn = src->Geom.VerticesIn;
dst_gp->VerticesOut = geom_sh->Geom.VerticesOut;
@@ -2420,7 +2422,7 @@ _mesa_GetActiveSubroutineUniformiv(GLuint program, GLenum shadertype,
GET_CURRENT_CONTEXT(ctx);
const char *api_name = "glGetActiveSubroutineUniformiv";
struct gl_shader_program *shProg;
- struct gl_shader *sh;
+ struct gl_linked_shader *sh;
gl_shader_stage stage;
struct gl_program_resource *res;
const struct gl_uniform_storage *uni;
@@ -2585,7 +2587,7 @@ _mesa_UniformSubroutinesuiv(GLenum shadertype, GLsizei count,
GET_CURRENT_CONTEXT(ctx);
const char *api_name = "glUniformSubroutinesuiv";
struct gl_shader_program *shProg;
- struct gl_shader *sh;
+ struct gl_linked_shader *sh;
gl_shader_stage stage;
int i;
@@ -2683,7 +2685,7 @@ _mesa_GetUniformSubroutineuiv(GLenum shadertype, GLint location,
GET_CURRENT_CONTEXT(ctx);
const char *api_name = "glGetUniformSubroutineuiv";
struct gl_shader_program *shProg;
- struct gl_shader *sh;
+ struct gl_linked_shader *sh;
gl_shader_stage stage;
if (!_mesa_has_shader_subroutine(ctx)) {
@@ -2730,7 +2732,7 @@ _mesa_GetProgramStageiv(GLuint program, GLenum shadertype,
GET_CURRENT_CONTEXT(ctx);
const char *api_name = "glGetProgramStageiv";
struct gl_shader_program *shProg;
- struct gl_shader *sh;
+ struct gl_linked_shader *sh;
gl_shader_stage stage;
if (!_mesa_has_shader_subroutine(ctx)) {
@@ -2812,7 +2814,8 @@ _mesa_GetProgramStageiv(GLuint program, GLenum shadertype,
}
static int
-find_compat_subroutine(struct gl_shader *sh, const struct glsl_type *type)
+find_compat_subroutine(struct gl_linked_shader *sh,
+ const struct glsl_type *type)
{
int i, j;
@@ -2827,7 +2830,7 @@ find_compat_subroutine(struct gl_shader *sh, const struct glsl_type *type)
}
static void
-_mesa_shader_init_subroutine_defaults(struct gl_shader *sh)
+_mesa_shader_init_subroutine_defaults(struct gl_linked_shader *sh)
{
int i, j;
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index f3d5c2ee5ba..93fdc669f2f 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -99,7 +99,6 @@ _mesa_init_shader(struct gl_context *ctx, struct gl_shader *shader)
/**
* Allocate a new gl_shader object, initialize it.
- * Called via ctx->Driver.NewShader()
*/
struct gl_shader *
_mesa_new_shader(struct gl_context *ctx, GLuint name, gl_shader_stage stage)
@@ -116,6 +115,22 @@ _mesa_new_shader(struct gl_context *ctx, GLuint name, gl_shader_stage stage)
/**
+ * Allocate a new gl_linked_shader object.
+ * Called via ctx->Driver.NewShader()
+ */
+struct gl_linked_shader *
+_mesa_new_linked_shader(gl_shader_stage stage)
+{
+ struct gl_linked_shader *shader;
+ shader = rzalloc(NULL, struct gl_linked_shader);
+ if (shader) {
+ shader->Stage = stage;
+ }
+ return shader;
+}
+
+
+/**
* Delete a shader object.
*/
void
@@ -123,6 +138,17 @@ _mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh)
{
free((void *)sh->Source);
free(sh->Label);
+ ralloc_free(sh);
+}
+
+
+/**
+ * Delete a shader object.
+ */
+void
+_mesa_delete_linked_shader(struct gl_context *ctx,
+ struct gl_linked_shader *sh)
+{
_mesa_reference_program(ctx, &sh->Program, NULL);
ralloc_free(sh);
}
@@ -360,7 +386,7 @@ _mesa_free_shader_program_data(struct gl_context *ctx,
for (sh = 0; sh < MESA_SHADER_STAGES; sh++) {
if (shProg->_LinkedShaders[sh] != NULL) {
- _mesa_delete_shader(ctx, shProg->_LinkedShaders[sh]);
+ _mesa_delete_linked_shader(ctx, shProg->_LinkedShaders[sh]);
shProg->_LinkedShaders[sh] = NULL;
}
}
@@ -436,6 +462,6 @@ _mesa_lookup_shader_program_err(struct gl_context *ctx, GLuint name,
void
_mesa_init_shader_object_functions(struct dd_function_table *driver)
{
- driver->NewShader = _mesa_new_shader;
+ driver->NewShader = _mesa_new_linked_shader;
driver->LinkShader = _mesa_ir_link_shader;
}
diff --git a/src/mesa/main/shaderobj.h b/src/mesa/main/shaderobj.h
index 3abd597a58c..f331db11664 100644
--- a/src/mesa/main/shaderobj.h
+++ b/src/mesa/main/shaderobj.h
@@ -82,9 +82,16 @@ _mesa_init_shader(struct gl_context *ctx, struct gl_shader *shader);
extern struct gl_shader *
_mesa_new_shader(struct gl_context *ctx, GLuint name, gl_shader_stage type);
+extern struct gl_linked_shader *
+_mesa_new_linked_shader(gl_shader_stage type);
+
extern void
_mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh);
+extern void
+_mesa_delete_linked_shader(struct gl_context *ctx,
+ struct gl_linked_shader *sh);
+
extern struct gl_shader_program *
_mesa_lookup_shader_program(struct gl_context *ctx, GLuint name);
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 127f097fe1f..67375a17f48 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -824,7 +824,7 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
if (uni->type->is_sampler()) {
bool flushed = false;
for (int i = 0; i < MESA_SHADER_STAGES; i++) {
- struct gl_shader *const sh = shProg->_LinkedShaders[i];
+ struct gl_linked_shader *const sh = shProg->_LinkedShaders[i];
/* If the shader stage doesn't use the sampler uniform, skip this.
*/
@@ -876,7 +876,7 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
if (uni->type->is_image()) {
for (int i = 0; i < MESA_SHADER_STAGES; i++) {
if (uni->opaque[i].active) {
- struct gl_shader *sh = shProg->_LinkedShaders[i];
+ struct gl_linked_shader *sh = shProg->_LinkedShaders[i];
for (int j = 0; j < count; j++)
sh->ImageUnits[uni->opaque[i].index + offset + j] =
diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index d02f92ee0a5..3921644892c 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -68,7 +68,7 @@ _mesa_update_shader_textures_used(struct gl_shader_program *shProg,
struct gl_program *prog)
{
GLbitfield mask = prog->SamplersUsed;
- struct gl_shader *shader =
+ struct gl_linked_shader *shader =
shProg->_LinkedShaders[_mesa_program_enum_to_shader_stage(prog->Target)];
assert(shader);
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index cf47c0d9348..e74d94f84f7 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2469,7 +2469,7 @@ add_uniform_to_shader::visit_field(const glsl_type *type, const char *name,
void
_mesa_generate_parameters_list_for_uniforms(struct gl_shader_program
*shader_program,
- struct gl_shader *sh,
+ struct gl_linked_shader *sh,
struct gl_program_parameter_list
*params)
{
@@ -2779,7 +2779,7 @@ ir_to_mesa_visitor::copy_propagate(void)
static struct gl_program *
get_mesa_program(struct gl_context *ctx,
struct gl_shader_program *shader_program,
- struct gl_shader *shader)
+ struct gl_linked_shader *shader)
{
ir_to_mesa_visitor v;
struct prog_instruction *mesa_instructions, *mesa_inst;
diff --git a/src/mesa/program/ir_to_mesa.h b/src/mesa/program/ir_to_mesa.h
index a70f575bb5c..be45ba0ebca 100644
--- a/src/mesa/program/ir_to_mesa.h
+++ b/src/mesa/program/ir_to_mesa.h
@@ -39,7 +39,7 @@ GLboolean _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program
void
_mesa_generate_parameters_list_for_uniforms(struct gl_shader_program
*shader_program,
- struct gl_shader *sh,
+ struct gl_linked_shader *sh,
struct gl_program_parameter_list
*params);
void
diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c
index 570b2f5800a..b8d7cca2f3b 100644
--- a/src/mesa/program/prog_print.c
+++ b/src/mesa/program/prog_print.c
@@ -1005,7 +1005,7 @@ _mesa_write_shader_to_file(const struct gl_shader *shader)
* _mesa_write_shader_to_file function.
*/
void
-_mesa_append_uniforms_to_file(const struct gl_shader *shader)
+_mesa_append_uniforms_to_file(const struct gl_linked_shader *shader)
{
const struct gl_program *const prog = shader->Program;
const char *type;
diff --git a/src/mesa/program/prog_print.h b/src/mesa/program/prog_print.h
index 9058dfa7688..7b1e1fe3b18 100644
--- a/src/mesa/program/prog_print.h
+++ b/src/mesa/program/prog_print.h
@@ -118,7 +118,7 @@ extern void
_mesa_write_shader_to_file(const struct gl_shader *shader);
extern void
-_mesa_append_uniforms_to_file(const struct gl_shader *shader);
+_mesa_append_uniforms_to_file(const struct gl_linked_shader *shader);
#ifdef __cplusplus
diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c
index a980dbedac5..594db1e9f12 100644
--- a/src/mesa/state_tracker/st_atom_constbuf.c
+++ b/src/mesa/state_tracker/st_atom_constbuf.c
@@ -265,7 +265,7 @@ const struct st_tracked_state st_update_cs_constants = {
};
static void st_bind_ubos(struct st_context *st,
- struct gl_shader *shader,
+ struct gl_linked_shader *shader,
unsigned shader_type)
{
unsigned i;
diff --git a/src/mesa/state_tracker/st_atom_image.c b/src/mesa/state_tracker/st_atom_image.c
index f8a0044c242..bc9344e51b2 100644
--- a/src/mesa/state_tracker/st_atom_image.c
+++ b/src/mesa/state_tracker/st_atom_image.c
@@ -45,7 +45,7 @@
#include "st_format.h"
static void
-st_bind_images(struct st_context *st, struct gl_shader *shader,
+st_bind_images(struct st_context *st, struct gl_linked_shader *shader,
unsigned shader_type)
{
unsigned i;
diff --git a/src/mesa/state_tracker/st_atom_storagebuf.c b/src/mesa/state_tracker/st_atom_storagebuf.c
index 37b4c4d256d..0f96e6d79b3 100644
--- a/src/mesa/state_tracker/st_atom_storagebuf.c
+++ b/src/mesa/state_tracker/st_atom_storagebuf.c
@@ -41,7 +41,7 @@
#include "st_program.h"
static void
-st_bind_ssbos(struct st_context *st, struct gl_shader *shader,
+st_bind_ssbos(struct st_context *st, struct gl_linked_shader *shader,
unsigned shader_type)
{
unsigned i;
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index a8805645b6e..52470a0021a 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -347,7 +347,7 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog, nir_shader *nir)
struct gl_program *
st_nir_get_mesa_program(struct gl_context *ctx,
struct gl_shader_program *shader_program,
- struct gl_shader *shader)
+ struct gl_linked_shader *shader)
{
struct gl_program *prog;
GLenum target = _mesa_shader_stage_to_program(shader->Stage);
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 07ec91a7e4f..931515324a3 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -376,7 +376,7 @@ public:
struct gl_context *ctx;
struct gl_program *prog;
struct gl_shader_program *shader_program;
- struct gl_shader *shader;
+ struct gl_linked_shader *shader;
struct gl_shader_compiler_options *options;
int next_temp;
@@ -6452,7 +6452,7 @@ out:
static struct gl_program *
get_mesa_program_tgsi(struct gl_context *ctx,
struct gl_shader_program *shader_program,
- struct gl_shader *shader)
+ struct gl_linked_shader *shader)
{
glsl_to_tgsi_visitor* v;
struct gl_program *prog;
@@ -6663,7 +6663,7 @@ get_mesa_program_tgsi(struct gl_context *ctx,
static struct gl_program *
get_mesa_program(struct gl_context *ctx,
struct gl_shader_program *shader_program,
- struct gl_shader *shader)
+ struct gl_linked_shader *shader)
{
struct pipe_screen *pscreen = ctx->st->pipe->screen;
unsigned ptarget = st_shader_stage_to_ptarget(shader->Stage);
diff --git a/src/mesa/state_tracker/st_nir.h b/src/mesa/state_tracker/st_nir.h
index 49ba573df2d..19e2d2d97ff 100644
--- a/src/mesa/state_tracker/st_nir.h
+++ b/src/mesa/state_tracker/st_nir.h
@@ -43,7 +43,7 @@ void st_finalize_nir(struct st_context *st, struct gl_program *prog, nir_shader
struct gl_program *
st_nir_get_mesa_program(struct gl_context *ctx,
struct gl_shader_program *shader_program,
- struct gl_shader *shader);
+ struct gl_linked_shader *shader);
#ifdef __cplusplus
}
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index f2b55379923..57b09354487 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -1756,10 +1756,6 @@ destroy_shader_program_variants_cb(GLuint key, void *data, void *userData)
struct gl_shader_program *shProg = (struct gl_shader_program *) data;
GLuint i;
- for (i = 0; i < shProg->NumShaders; i++) {
- destroy_program_variants(st, shProg->Shaders[i]->Program);
- }
-
for (i = 0; i < ARRAY_SIZE(shProg->_LinkedShaders); i++) {
if (shProg->_LinkedShaders[i])
destroy_program_variants(st, shProg->_LinkedShaders[i]->Program);
@@ -1772,9 +1768,6 @@ destroy_shader_program_variants_cb(GLuint key, void *data, void *userData)
case GL_TESS_CONTROL_SHADER:
case GL_TESS_EVALUATION_SHADER:
case GL_COMPUTE_SHADER:
- {
- destroy_program_variants(st, shader->Program);
- }
break;
default:
assert(0);