summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-06-30 14:44:59 +1000
committerTimothy Arceri <[email protected]>2016-06-30 16:51:25 +1000
commit1591e668e162daf4057a0d44df4e70f19b94fc76 (patch)
tree2d6482014ef8ca198bd15d578d6ffbd2ff32d2da /src/mesa
parentfd2b3da5c8cdbc5b00436185a3c03dfb7b7bd853 (diff)
glsl/mesa: move duplicate shader fields into new struct gl_shader_info
Reviewed-by: Iago Toral Quiroga <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/dri/i965/brw_tcs.c2
-rw-r--r--src/mesa/main/api_validate.c13
-rw-r--r--src/mesa/main/ff_fragment_shader.cpp2
-rw-r--r--src/mesa/main/mtypes.h241
-rw-r--r--src/mesa/main/shaderapi.c38
-rw-r--r--src/mesa/main/shaderobj.c6
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp2
7 files changed, 112 insertions, 192 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_tcs.c b/src/mesa/drivers/dri/i965/brw_tcs.c
index 3ba9f2c7d74..28e2f36f94e 100644
--- a/src/mesa/drivers/dri/i965/brw_tcs.c
+++ b/src/mesa/drivers/dri/i965/brw_tcs.c
@@ -392,7 +392,7 @@ brw_tcs_precompile(struct gl_context *ctx,
/* Guess that the input and output patches have the same dimensionality. */
if (brw->gen < 8) {
key.input_vertices = shader_prog->
- _LinkedShaders[MESA_SHADER_TESS_CTRL]->TessCtrl.VerticesOut;
+ _LinkedShaders[MESA_SHADER_TESS_CTRL]->info.TessCtrl.VerticesOut;
}
key.tes_primitive_mode = brw->tess_eval_program ?
diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index c0962241f84..038b5a9cd73 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -201,7 +201,7 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
if (ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]) {
const GLenum geom_mode =
ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]->
- _LinkedShaders[MESA_SHADER_GEOMETRY]->Geom.InputType;
+ _LinkedShaders[MESA_SHADER_GEOMETRY]->info.Geom.InputType;
struct gl_shader_program *tes =
ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
GLenum mode_before_gs = mode;
@@ -209,9 +209,9 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
if (tes) {
struct gl_linked_shader *tes_sh =
tes->_LinkedShaders[MESA_SHADER_TESS_EVAL];
- if (tes_sh->TessEval.PointMode)
+ if (tes_sh->info.TessEval.PointMode)
mode_before_gs = GL_POINTS;
- else if (tes_sh->TessEval.PrimitiveMode == GL_ISOLINES)
+ else if (tes_sh->info.TessEval.PrimitiveMode == GL_ISOLINES)
mode_before_gs = GL_LINES;
else
/* the GL_QUADS mode generates triangles too */
@@ -308,7 +308,8 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
if(ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]) {
switch (ctx->_Shader->CurrentProgram[MESA_SHADER_GEOMETRY]->
- _LinkedShaders[MESA_SHADER_GEOMETRY]->Geom.OutputType) {
+ _LinkedShaders[MESA_SHADER_GEOMETRY]->
+ info.Geom.OutputType) {
case GL_POINTS:
pass = ctx->TransformFeedback.Mode == GL_POINTS;
break;
@@ -327,9 +328,9 @@ _mesa_valid_prim_mode(struct gl_context *ctx, GLenum mode, const char *name)
ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
struct gl_linked_shader *tes_sh =
tes->_LinkedShaders[MESA_SHADER_TESS_EVAL];
- if (tes_sh->TessEval.PointMode)
+ if (tes_sh->info.TessEval.PointMode)
pass = ctx->TransformFeedback.Mode == GL_POINTS;
- else if (tes_sh->TessEval.PrimitiveMode == GL_ISOLINES)
+ else if (tes_sh->info.TessEval.PrimitiveMode == GL_ISOLINES)
pass = ctx->TransformFeedback.Mode == GL_LINES;
else
pass = ctx->TransformFeedback.Mode == GL_TRIANGLES;
diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp
index 83881e9ccf1..1f9a7cfeadd 100644
--- a/src/mesa/main/ff_fragment_shader.cpp
+++ b/src/mesa/main/ff_fragment_shader.cpp
@@ -1260,7 +1260,7 @@ create_new_program(struct gl_context *ctx, struct state_key *key)
p.shader->CompileStatus = true;
p.shader->Version = state->language_version;
- p.shader->uses_builtin_functions = state->uses_builtin_functions;
+ p.shader->info.uses_builtin_functions = state->uses_builtin_functions;
p.shader_program->Shaders =
(gl_shader **)malloc(sizeof(*p.shader_program->Shaders));
p.shader_program->Shaders[0] = p.shader;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index fdd445f6857..cab315df23d 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2235,62 +2235,10 @@ struct gl_subroutine_function
};
/**
- * A linked GLSL shader object.
+ * Shader information needed by both gl_shader and gl_linked shader.
*/
-struct gl_linked_shader
+struct gl_shader_info
{
- gl_shader_stage Stage;
-
- struct gl_program *Program; /**< Post-compile assembly code */
-
- /**
- * \name Sampler tracking
- *
- * \note Each of these fields is only set post-linking.
- */
- /*@{*/
- unsigned num_samplers; /**< Number of samplers used by this shader. */
- GLbitfield active_samplers; /**< Bitfield of which samplers are used */
- GLbitfield shadow_samplers; /**< Samplers used for shadow sampling. */
- /*@}*/
-
- /**
- * Map from sampler unit to texture unit (set by glUniform1i())
- *
- * A sampler unit is associated with each sampler uniform by the linker.
- * The sampler unit associated with each uniform is stored in the
- * \c gl_uniform_storage::sampler field.
- */
- GLubyte SamplerUnits[MAX_SAMPLERS];
- /** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */
- gl_texture_index SamplerTargets[MAX_SAMPLERS];
-
- /**
- * Number of default uniform block components used by this shader.
- *
- * This field is only set post-linking.
- */
- unsigned num_uniform_components;
-
- /**
- * Number of combined uniform components used by this shader.
- *
- * This field is only set post-linking. It is the sum of the uniform block
- * sizes divided by sizeof(float), and num_uniform_compoennts.
- */
- unsigned num_combined_uniform_components;
-
- unsigned NumUniformBlocks;
- struct gl_uniform_block **UniformBlocks;
-
- unsigned NumShaderStorageBlocks;
- struct gl_uniform_block **ShaderStorageBlocks;
-
- struct exec_list *ir;
- struct exec_list *packed_varyings;
- struct exec_list *fragdata_arrays;
- struct glsl_symbol_table *symbols;
-
bool uses_builtin_functions;
bool uses_gl_fragcoord;
bool redeclares_gl_fragcoord;
@@ -2366,6 +2314,81 @@ struct gl_linked_shader
} 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;
+};
+
+/**
+ * A linked GLSL shader object.
+ */
+struct gl_linked_shader
+{
+ gl_shader_stage Stage;
+
+ struct gl_program *Program; /**< Post-compile assembly code */
+
+ /**
+ * \name Sampler tracking
+ *
+ * \note Each of these fields is only set post-linking.
+ */
+ /*@{*/
+ unsigned num_samplers; /**< Number of samplers used by this shader. */
+ GLbitfield active_samplers; /**< Bitfield of which samplers are used */
+ GLbitfield shadow_samplers; /**< Samplers used for shadow sampling. */
+ /*@}*/
+
+ /**
+ * Map from sampler unit to texture unit (set by glUniform1i())
+ *
+ * A sampler unit is associated with each sampler uniform by the linker.
+ * The sampler unit associated with each uniform is stored in the
+ * \c gl_uniform_storage::sampler field.
+ */
+ GLubyte SamplerUnits[MAX_SAMPLERS];
+ /** Which texture target is being sampled (TEXTURE_1D/2D/3D/etc_INDEX) */
+ gl_texture_index SamplerTargets[MAX_SAMPLERS];
+
+ /**
+ * Number of default uniform block components used by this shader.
+ *
+ * This field is only set post-linking.
+ */
+ unsigned num_uniform_components;
+
+ /**
+ * Number of combined uniform components used by this shader.
+ *
+ * This field is only set post-linking. It is the sum of the uniform block
+ * sizes divided by sizeof(float), and num_uniform_compoennts.
+ */
+ unsigned num_combined_uniform_components;
+
+ unsigned NumUniformBlocks;
+ struct gl_uniform_block **UniformBlocks;
+
+ unsigned NumShaderStorageBlocks;
+ struct gl_uniform_block **ShaderStorageBlocks;
+
+ struct exec_list *ir;
+ struct exec_list *packed_varyings;
+ struct exec_list *fragdata_arrays;
+ struct glsl_symbol_table *symbols;
+
+ /**
* Map from image uniform index to image unit (set by glUniform1i())
*
* An image uniform index is associated with each image uniform by
@@ -2395,23 +2418,6 @@ struct gl_linked_shader
unsigned NumAtomicBuffers;
/**
- * 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;
-
- /**
* Number of types for subroutine uniforms.
*/
GLuint NumSubroutineUniformTypes;
@@ -2431,6 +2437,8 @@ struct gl_linked_shader
GLuint NumSubroutineFunctions;
GLuint MaxSubroutineFunctionIndex;
struct gl_subroutine_function *SubroutineFunctions;
+
+ struct gl_shader_info info;
};
/**
@@ -2461,96 +2469,7 @@ struct gl_shader
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_shader_info info;
};
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index fdfe1e7c6c4..c5c502466e5 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -732,7 +732,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
break;
if (check_gs_query(ctx, shProg)) {
*params = shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->
- Geom.VerticesOut;
+ info.Geom.VerticesOut;
}
return;
case GL_GEOMETRY_SHADER_INVOCATIONS:
@@ -740,7 +740,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
break;
if (check_gs_query(ctx, shProg)) {
*params = shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->
- Geom.Invocations;
+ info.Geom.Invocations;
}
return;
case GL_GEOMETRY_INPUT_TYPE:
@@ -748,7 +748,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
break;
if (check_gs_query(ctx, shProg)) {
*params = shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->
- Geom.InputType;
+ info.Geom.InputType;
}
return;
case GL_GEOMETRY_OUTPUT_TYPE:
@@ -756,7 +756,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
break;
if (check_gs_query(ctx, shProg)) {
*params = shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->
- Geom.OutputType;
+ info.Geom.OutputType;
}
return;
case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: {
@@ -834,7 +834,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
break;
if (check_tcs_query(ctx, shProg)) {
*params = shProg->_LinkedShaders[MESA_SHADER_TESS_CTRL]->
- TessCtrl.VerticesOut;
+ info.TessCtrl.VerticesOut;
}
return;
case GL_TESS_GEN_MODE:
@@ -842,7 +842,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
break;
if (check_tes_query(ctx, shProg)) {
*params = shProg->_LinkedShaders[MESA_SHADER_TESS_EVAL]->
- TessEval.PrimitiveMode;
+ info.TessEval.PrimitiveMode;
}
return;
case GL_TESS_GEN_SPACING:
@@ -850,7 +850,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
break;
if (check_tes_query(ctx, shProg)) {
*params = shProg->_LinkedShaders[MESA_SHADER_TESS_EVAL]->
- TessEval.Spacing;
+ info.TessEval.Spacing;
}
return;
case GL_TESS_GEN_VERTEX_ORDER:
@@ -858,7 +858,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
break;
if (check_tes_query(ctx, shProg)) {
*params = shProg->_LinkedShaders[MESA_SHADER_TESS_EVAL]->
- TessEval.VertexOrder;
+ info.TessEval.VertexOrder;
}
return;
case GL_TESS_GEN_POINT_MODE:
@@ -866,7 +866,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
break;
if (check_tes_query(ctx, shProg)) {
*params = shProg->_LinkedShaders[MESA_SHADER_TESS_EVAL]->
- TessEval.PointMode;
+ info.TessEval.PointMode;
}
return;
default:
@@ -2168,8 +2168,8 @@ _mesa_copy_linked_program_data(gl_shader_stage type,
case MESA_SHADER_TESS_CTRL: {
struct gl_tess_ctrl_program *dst_tcp =
(struct gl_tess_ctrl_program *) dst;
- dst_tcp->VerticesOut =
- src->_LinkedShaders[MESA_SHADER_TESS_CTRL]->TessCtrl.VerticesOut;
+ dst_tcp->VerticesOut = src->_LinkedShaders[MESA_SHADER_TESS_CTRL]->
+ info.TessCtrl.VerticesOut;
break;
}
case MESA_SHADER_TESS_EVAL: {
@@ -2178,10 +2178,10 @@ _mesa_copy_linked_program_data(gl_shader_stage type,
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;
- dst_tep->VertexOrder = tes_sh->TessEval.VertexOrder;
- dst_tep->PointMode = tes_sh->TessEval.PointMode;
+ dst_tep->PrimitiveMode = tes_sh->info.TessEval.PrimitiveMode;
+ dst_tep->Spacing = tes_sh->info.TessEval.Spacing;
+ dst_tep->VertexOrder = tes_sh->info.TessEval.VertexOrder;
+ dst_tep->PointMode = tes_sh->info.TessEval.PointMode;
dst->ClipDistanceArraySize = src->TessEval.ClipDistanceArraySize;
dst->CullDistanceArraySize = src->TessEval.CullDistanceArraySize;
break;
@@ -2192,10 +2192,10 @@ _mesa_copy_linked_program_data(gl_shader_stage type,
src->_LinkedShaders[MESA_SHADER_GEOMETRY];
dst_gp->VerticesIn = src->Geom.VerticesIn;
- dst_gp->VerticesOut = geom_sh->Geom.VerticesOut;
- dst_gp->Invocations = geom_sh->Geom.Invocations;
- dst_gp->InputType = geom_sh->Geom.InputType;
- dst_gp->OutputType = geom_sh->Geom.OutputType;
+ dst_gp->VerticesOut = geom_sh->info.Geom.VerticesOut;
+ dst_gp->Invocations = geom_sh->info.Geom.Invocations;
+ dst_gp->InputType = geom_sh->info.Geom.InputType;
+ dst_gp->OutputType = geom_sh->info.Geom.OutputType;
dst->ClipDistanceArraySize = src->Geom.ClipDistanceArraySize;
dst->CullDistanceArraySize = src->Geom.CullDistanceArraySize;
dst_gp->UsesEndPrimitive = src->Geom.UsesEndPrimitive;
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index 131d6824df0..0075a6d6429 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -92,9 +92,9 @@ static void
_mesa_init_shader(struct gl_shader *shader)
{
shader->RefCount = 1;
- shader->Geom.VerticesOut = -1;
- shader->Geom.InputType = GL_TRIANGLES;
- shader->Geom.OutputType = GL_TRIANGLE_STRIP;
+ shader->info.Geom.VerticesOut = -1;
+ shader->info.Geom.InputType = GL_TRIANGLES;
+ shader->info.Geom.OutputType = GL_TRIANGLE_STRIP;
}
/**
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 931515324a3..197b3af8c04 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -6133,7 +6133,7 @@ st_translate_program(
}
if (procType == PIPE_SHADER_FRAGMENT) {
- if (program->shader->EarlyFragmentTests)
+ if (program->shader->info.EarlyFragmentTests)
ureg_property(ureg, TGSI_PROPERTY_FS_EARLY_DEPTH_STENCIL, 1);
if (proginfo->InputsRead & VARYING_BIT_POS) {