mesa/glsl: set {clip,cull}_distance_array_size directly in gl_program

There are some line wrapping violations here but those lines will get
deleted in the following patch.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
This commit is contained in:
Timothy Arceri
2016-11-20 23:05:42 +11:00
parent f86d15ed94
commit fc707f570f
6 changed files with 25 additions and 73 deletions

View File

@@ -169,8 +169,6 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
shader->info->name = ralloc_asprintf(shader, "GLSL%d", shader_prog->Name); shader->info->name = ralloc_asprintf(shader, "GLSL%d", shader_prog->Name);
if (shader_prog->Label) if (shader_prog->Label)
shader->info->label = ralloc_strdup(shader, shader_prog->Label); shader->info->label = ralloc_strdup(shader, shader_prog->Label);
shader->info->clip_distance_array_size = sh->Program->ClipDistanceArraySize;
shader->info->cull_distance_array_size = sh->Program->CullDistanceArraySize;
shader->info->has_transform_feedback_varyings = shader->info->has_transform_feedback_varyings =
shader_prog->TransformFeedback.NumVarying > 0; shader_prog->TransformFeedback.NumVarying > 0;

View File

@@ -634,8 +634,8 @@ analyze_clip_cull_usage(struct gl_shader_program *prog,
/** /**
* Verify that a vertex shader executable meets all semantic requirements. * Verify that a vertex shader executable meets all semantic requirements.
* *
* Also sets prog->Vert.ClipDistanceArraySize and * Also sets info.clip_distance_array_size and
* prog->Vert.CullDistanceArraySize as a side effect. * info.cull_distance_array_size as a side effect.
* *
* \param shader Vertex shader executable to be verified * \param shader Vertex shader executable to be verified
*/ */
@@ -690,8 +690,8 @@ validate_vertex_shader_executable(struct gl_shader_program *prog,
} }
analyze_clip_cull_usage(prog, shader, ctx, analyze_clip_cull_usage(prog, shader, ctx,
&prog->Vert.ClipDistanceArraySize, &shader->Program->info.clip_distance_array_size,
&prog->Vert.CullDistanceArraySize); &shader->Program->info.cull_distance_array_size);
} }
void void
@@ -703,8 +703,8 @@ validate_tess_eval_shader_executable(struct gl_shader_program *prog,
return; return;
analyze_clip_cull_usage(prog, shader, ctx, analyze_clip_cull_usage(prog, shader, ctx,
&prog->TessEval.ClipDistanceArraySize, &shader->Program->info.clip_distance_array_size,
&prog->TessEval.CullDistanceArraySize); &shader->Program->info.cull_distance_array_size);
} }
@@ -735,8 +735,8 @@ validate_fragment_shader_executable(struct gl_shader_program *prog,
/** /**
* Verify that a geometry shader executable meets all semantic requirements * Verify that a geometry shader executable meets all semantic requirements
* *
* Also sets prog->Geom.VerticesIn, and prog->Geom.ClipDistanceArraySize and * Also sets prog->Geom.VerticesIn, and info.clip_distance_array_sizeand
* prog->Geom.CullDistanceArraySize as a side effect. * info.cull_distance_array_size as a side effect.
* *
* \param shader Geometry shader executable to be verified * \param shader Geometry shader executable to be verified
*/ */
@@ -752,8 +752,8 @@ validate_geometry_shader_executable(struct gl_shader_program *prog,
prog->Geom.VerticesIn = num_vertices; prog->Geom.VerticesIn = num_vertices;
analyze_clip_cull_usage(prog, shader, ctx, analyze_clip_cull_usage(prog, shader, ctx,
&prog->Geom.ClipDistanceArraySize, &shader->Program->info.clip_distance_array_size,
&prog->Geom.CullDistanceArraySize); &shader->Program->info.cull_distance_array_size);
} }
/** /**
@@ -4776,14 +4776,14 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
} }
if (num_shaders[MESA_SHADER_GEOMETRY] > 0) { if (num_shaders[MESA_SHADER_GEOMETRY] > 0) {
prog->LastClipDistanceArraySize = prog->Geom.ClipDistanceArraySize; prog->LastClipDistanceArraySize = prog->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program->info.clip_distance_array_size;
prog->LastCullDistanceArraySize = prog->Geom.CullDistanceArraySize; prog->LastCullDistanceArraySize = prog->_LinkedShaders[MESA_SHADER_GEOMETRY]->Program->info.cull_distance_array_size;
} else if (num_shaders[MESA_SHADER_TESS_EVAL] > 0) { } else if (num_shaders[MESA_SHADER_TESS_EVAL] > 0) {
prog->LastClipDistanceArraySize = prog->TessEval.ClipDistanceArraySize; prog->LastClipDistanceArraySize = prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]->Program->info.clip_distance_array_size;
prog->LastCullDistanceArraySize = prog->TessEval.CullDistanceArraySize; prog->LastCullDistanceArraySize = prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]->Program->info.cull_distance_array_size;
} else if (num_shaders[MESA_SHADER_VERTEX] > 0) { } else if (num_shaders[MESA_SHADER_VERTEX] > 0) {
prog->LastClipDistanceArraySize = prog->Vert.ClipDistanceArraySize; prog->LastClipDistanceArraySize = prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program->info.clip_distance_array_size;
prog->LastCullDistanceArraySize = prog->Vert.CullDistanceArraySize; prog->LastCullDistanceArraySize = prog->_LinkedShaders[MESA_SHADER_VERTEX]->Program->info.cull_distance_array_size;
} else { } else {
prog->LastClipDistanceArraySize = 0; /* Not used */ prog->LastClipDistanceArraySize = 0; /* Not used */
prog->LastCullDistanceArraySize = 0; /* Not used */ prog->LastCullDistanceArraySize = 0; /* Not used */

View File

@@ -294,7 +294,7 @@ brw_vs_populate_key(struct brw_context *brw,
if (ctx->Transform.ClipPlanesEnabled != 0 && if (ctx->Transform.ClipPlanesEnabled != 0 &&
(ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGLES) && (ctx->API == API_OPENGL_COMPAT || ctx->API == API_OPENGLES) &&
vp->program.ClipDistanceArraySize == 0) { vp->program.info.clip_distance_array_size == 0) {
key->nr_userclip_plane_consts = key->nr_userclip_plane_consts =
_mesa_logbase2(ctx->Transform.ClipPlanesEnabled) + 1; _mesa_logbase2(ctx->Transform.ClipPlanesEnabled) + 1;
} }

View File

@@ -1933,10 +1933,6 @@ struct gl_program
GLbitfield ShadowSamplers; /**< Texture units used for shadow sampling. */ GLbitfield ShadowSamplers; /**< Texture units used for shadow sampling. */
GLbitfield ExternalSamplersUsed; /**< Texture units used for samplerExternalOES */ GLbitfield ExternalSamplersUsed; /**< Texture units used for samplerExternalOES */
/* Vertex and geometry shaders fields */
unsigned ClipDistanceArraySize;
unsigned CullDistanceArraySize;
/* Fragement shader only fields */ /* Fragement shader only fields */
GLboolean OriginUpperLeft; GLboolean OriginUpperLeft;
GLboolean PixelCenterInteger; GLboolean PixelCenterInteger;
@@ -2747,20 +2743,6 @@ struct gl_shader_program
/** Post-link gl_FragDepth layout for ARB_conservative_depth. */ /** Post-link gl_FragDepth layout for ARB_conservative_depth. */
enum gl_frag_depth_layout FragDepthLayout; enum gl_frag_depth_layout FragDepthLayout;
/**
* Tessellation Evaluation shader state from layout qualifiers.
*/
struct {
/**
* True if gl_ClipDistance is written to. Copied into
* gl_program by _mesa_copy_linked_program_data().
*/
GLuint ClipDistanceArraySize; /**< Size of the gl_ClipDistance array, or
0 if not present. */
GLuint CullDistanceArraySize; /**< Size of the gl_CullDistance array, or
0 if not present. */
} TessEval;
/** /**
* Geometry shader state - copied into gl_program by * Geometry shader state - copied into gl_program by
* _mesa_copy_linked_program_data(). * _mesa_copy_linked_program_data().
@@ -2768,30 +2750,10 @@ struct gl_shader_program
struct { struct {
GLint VerticesIn; GLint VerticesIn;
/**
* True if gl_ClipDistance is written to. Copied into
* gl_program by _mesa_copy_linked_program_data().
*/
GLuint ClipDistanceArraySize; /**< Size of the gl_ClipDistance array, or
0 if not present. */
GLuint CullDistanceArraySize; /**< Size of the gl_CullDistance array, or
0 if not present. */
bool UsesEndPrimitive; bool UsesEndPrimitive;
bool UsesStreams; bool UsesStreams;
} Geom; } Geom;
/** Vertex shader state */
struct {
/**
* True if gl_ClipDistance is written to. Copied into gl_program
* by _mesa_copy_linked_program_data().
*/
GLuint ClipDistanceArraySize; /**< Size of the gl_ClipDistance array, or
0 if not present. */
GLuint CullDistanceArraySize; /**< Size of the gl_CullDistance array, or
0 if not present. */
} Vert;
/** /**
* Compute shader state - copied into gl_program by * Compute shader state - copied into gl_program by
* _mesa_copy_linked_program_data(). * _mesa_copy_linked_program_data().

View File

@@ -2202,17 +2202,11 @@ _mesa_copy_linked_program_data(const struct gl_shader_program *src,
dst->info.separate_shader = src->SeparateShader; dst->info.separate_shader = src->SeparateShader;
switch (dst_sh->Stage) { switch (dst_sh->Stage) {
case MESA_SHADER_VERTEX:
dst->ClipDistanceArraySize = src->Vert.ClipDistanceArraySize;
dst->CullDistanceArraySize = src->Vert.CullDistanceArraySize;
break;
case MESA_SHADER_TESS_EVAL: { case MESA_SHADER_TESS_EVAL: {
dst->info.tess.primitive_mode = dst_sh->info.TessEval.PrimitiveMode; dst->info.tess.primitive_mode = dst_sh->info.TessEval.PrimitiveMode;
dst->info.tess.spacing = dst_sh->info.TessEval.Spacing; dst->info.tess.spacing = dst_sh->info.TessEval.Spacing;
dst->info.tess.ccw = dst_sh->info.TessEval.VertexOrder == GL_CCW; dst->info.tess.ccw = dst_sh->info.TessEval.VertexOrder == GL_CCW;
dst->info.tess.point_mode = dst_sh->info.TessEval.PointMode; dst->info.tess.point_mode = dst_sh->info.TessEval.PointMode;
dst->ClipDistanceArraySize = src->TessEval.ClipDistanceArraySize;
dst->CullDistanceArraySize = src->TessEval.CullDistanceArraySize;
break; break;
} }
case MESA_SHADER_GEOMETRY: { case MESA_SHADER_GEOMETRY: {
@@ -2221,8 +2215,6 @@ _mesa_copy_linked_program_data(const struct gl_shader_program *src,
dst->info.gs.invocations = dst_sh->info.Geom.Invocations; dst->info.gs.invocations = dst_sh->info.Geom.Invocations;
dst->info.gs.input_primitive = dst_sh->info.Geom.InputType; dst->info.gs.input_primitive = dst_sh->info.Geom.InputType;
dst->info.gs.output_primitive = dst_sh->info.Geom.OutputType; dst->info.gs.output_primitive = dst_sh->info.Geom.OutputType;
dst->ClipDistanceArraySize = src->Geom.ClipDistanceArraySize;
dst->CullDistanceArraySize = src->Geom.CullDistanceArraySize;
dst->info.gs.uses_end_primitive = src->Geom.UsesEndPrimitive; dst->info.gs.uses_end_primitive = src->Geom.UsesEndPrimitive;
dst->info.gs.uses_streams = src->Geom.UsesStreams; dst->info.gs.uses_streams = src->Geom.UsesStreams;
break; break;

View File

@@ -404,12 +404,12 @@ st_translate_vertex_program(struct st_context *st,
if (ureg == NULL) if (ureg == NULL)
return false; return false;
if (stvp->Base.ClipDistanceArraySize) if (stvp->Base.info.clip_distance_array_size)
ureg_property(ureg, TGSI_PROPERTY_NUM_CLIPDIST_ENABLED, ureg_property(ureg, TGSI_PROPERTY_NUM_CLIPDIST_ENABLED,
stvp->Base.ClipDistanceArraySize); stvp->Base.info.clip_distance_array_size);
if (stvp->Base.CullDistanceArraySize) if (stvp->Base.info.cull_distance_array_size)
ureg_property(ureg, TGSI_PROPERTY_NUM_CULLDIST_ENABLED, ureg_property(ureg, TGSI_PROPERTY_NUM_CULLDIST_ENABLED,
stvp->Base.CullDistanceArraySize); stvp->Base.info.cull_distance_array_size);
if (ST_DEBUG & DEBUG_MESA) { if (ST_DEBUG & DEBUG_MESA) {
_mesa_print_program(&stvp->Base); _mesa_print_program(&stvp->Base);
@@ -1219,12 +1219,12 @@ st_translate_program_common(struct st_context *st,
memset(outputMapping, 0, sizeof(outputMapping)); memset(outputMapping, 0, sizeof(outputMapping));
memset(out_state, 0, sizeof(*out_state)); memset(out_state, 0, sizeof(*out_state));
if (prog->ClipDistanceArraySize) if (prog->info.clip_distance_array_size)
ureg_property(ureg, TGSI_PROPERTY_NUM_CLIPDIST_ENABLED, ureg_property(ureg, TGSI_PROPERTY_NUM_CLIPDIST_ENABLED,
prog->ClipDistanceArraySize); prog->info.clip_distance_array_size);
if (prog->CullDistanceArraySize) if (prog->info.cull_distance_array_size)
ureg_property(ureg, TGSI_PROPERTY_NUM_CULLDIST_ENABLED, ureg_property(ureg, TGSI_PROPERTY_NUM_CULLDIST_ENABLED,
prog->CullDistanceArraySize); prog->info.cull_distance_array_size);
/* /*
* Convert Mesa program inputs to TGSI input register semantics. * Convert Mesa program inputs to TGSI input register semantics.