mesa/glsl: set and get gs layouts directly to and from shader_info

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
This commit is contained in:
Timothy Arceri 2016-11-22 21:45:16 +11:00
parent cbeba6bd48
commit b96bddae67
2 changed files with 41 additions and 41 deletions

View File

@ -748,7 +748,8 @@ validate_geometry_shader_executable(struct gl_shader_program *prog,
if (shader == NULL) if (shader == NULL)
return; return;
unsigned num_vertices = vertices_per_prim(shader->info.Geom.InputType); unsigned num_vertices =
vertices_per_prim(shader->Program->info.gs.input_primitive);
prog->Geom.VerticesIn = num_vertices; prog->Geom.VerticesIn = num_vertices;
analyze_clip_cull_usage(prog, shader, ctx, analyze_clip_cull_usage(prog, shader, ctx,
@ -803,7 +804,8 @@ validate_geometry_shader_emissions(struct gl_context *ctx,
* EmitStreamVertex() or EmitEndPrimitive() are called with a non-zero * EmitStreamVertex() or EmitEndPrimitive() are called with a non-zero
* stream. * stream.
*/ */
if (prog->Geom.UsesStreams && sh->info.Geom.OutputType != GL_POINTS) { if (prog->Geom.UsesStreams &&
sh->Program->info.gs.output_primitive != GL_POINTS) {
linker_error(prog, "EmitStreamVertex(n) and EndStreamPrimitive(n) " linker_error(prog, "EmitStreamVertex(n) and EndStreamPrimitive(n) "
"with n>0 requires point output\n"); "with n>0 requires point output\n");
} }
@ -1893,22 +1895,23 @@ link_fs_inout_layout_qualifiers(struct gl_shader_program *prog,
*/ */
static void static void
link_gs_inout_layout_qualifiers(struct gl_shader_program *prog, link_gs_inout_layout_qualifiers(struct gl_shader_program *prog,
struct gl_linked_shader *linked_shader, struct gl_program *gl_prog,
struct gl_shader **shader_list, struct gl_shader **shader_list,
unsigned num_shaders) unsigned num_shaders)
{ {
linked_shader->info.Geom.VerticesOut = -1;
linked_shader->info.Geom.Invocations = 0;
linked_shader->info.Geom.InputType = PRIM_UNKNOWN;
linked_shader->info.Geom.OutputType = PRIM_UNKNOWN;
/* No in/out qualifiers defined for anything but GLSL 1.50+ /* No in/out qualifiers defined for anything but GLSL 1.50+
* geometry shaders so far. * geometry shaders so far.
*/ */
if (linked_shader->Stage != MESA_SHADER_GEOMETRY || if (gl_prog->info.stage != MESA_SHADER_GEOMETRY ||
prog->data->Version < 150) prog->data->Version < 150)
return; return;
int vertices_out = -1;
gl_prog->info.gs.invocations = 0;
gl_prog->info.gs.input_primitive = PRIM_UNKNOWN;
gl_prog->info.gs.output_primitive = PRIM_UNKNOWN;
/* From the GLSL 1.50 spec, page 46: /* From the GLSL 1.50 spec, page 46:
* *
* "All geometry shader output layout declarations in a program * "All geometry shader output layout declarations in a program
@ -1923,51 +1926,49 @@ link_gs_inout_layout_qualifiers(struct gl_shader_program *prog,
struct gl_shader *shader = shader_list[i]; struct gl_shader *shader = shader_list[i];
if (shader->info.Geom.InputType != PRIM_UNKNOWN) { if (shader->info.Geom.InputType != PRIM_UNKNOWN) {
if (linked_shader->info.Geom.InputType != PRIM_UNKNOWN && if (gl_prog->info.gs.input_primitive != PRIM_UNKNOWN &&
linked_shader->info.Geom.InputType != gl_prog->info.gs.input_primitive !=
shader->info.Geom.InputType) { shader->info.Geom.InputType) {
linker_error(prog, "geometry shader defined with conflicting " linker_error(prog, "geometry shader defined with conflicting "
"input types\n"); "input types\n");
return; return;
} }
linked_shader->info.Geom.InputType = shader->info.Geom.InputType; gl_prog->info.gs.input_primitive = shader->info.Geom.InputType;
} }
if (shader->info.Geom.OutputType != PRIM_UNKNOWN) { if (shader->info.Geom.OutputType != PRIM_UNKNOWN) {
if (linked_shader->info.Geom.OutputType != PRIM_UNKNOWN && if (gl_prog->info.gs.output_primitive != PRIM_UNKNOWN &&
linked_shader->info.Geom.OutputType != gl_prog->info.gs.output_primitive !=
shader->info.Geom.OutputType) { shader->info.Geom.OutputType) {
linker_error(prog, "geometry shader defined with conflicting " linker_error(prog, "geometry shader defined with conflicting "
"output types\n"); "output types\n");
return; return;
} }
linked_shader->info.Geom.OutputType = shader->info.Geom.OutputType; gl_prog->info.gs.output_primitive = shader->info.Geom.OutputType;
} }
if (shader->info.Geom.VerticesOut != -1) { if (shader->info.Geom.VerticesOut != -1) {
if (linked_shader->info.Geom.VerticesOut != -1 && if (vertices_out != -1 &&
linked_shader->info.Geom.VerticesOut != vertices_out != shader->info.Geom.VerticesOut) {
shader->info.Geom.VerticesOut) {
linker_error(prog, "geometry shader defined with conflicting " linker_error(prog, "geometry shader defined with conflicting "
"output vertex count (%d and %d)\n", "output vertex count (%d and %d)\n",
linked_shader->info.Geom.VerticesOut, vertices_out, shader->info.Geom.VerticesOut);
shader->info.Geom.VerticesOut);
return; return;
} }
linked_shader->info.Geom.VerticesOut = shader->info.Geom.VerticesOut; vertices_out = shader->info.Geom.VerticesOut;
} }
if (shader->info.Geom.Invocations != 0) { if (shader->info.Geom.Invocations != 0) {
if (linked_shader->info.Geom.Invocations != 0 && if (gl_prog->info.gs.invocations != 0 &&
linked_shader->info.Geom.Invocations != gl_prog->info.gs.invocations !=
shader->info.Geom.Invocations) { (unsigned) shader->info.Geom.Invocations) {
linker_error(prog, "geometry shader defined with conflicting " linker_error(prog, "geometry shader defined with conflicting "
"invocation count (%d and %d)\n", "invocation count (%d and %d)\n",
linked_shader->info.Geom.Invocations, gl_prog->info.gs.invocations,
shader->info.Geom.Invocations); shader->info.Geom.Invocations);
return; return;
} }
linked_shader->info.Geom.Invocations = shader->info.Geom.Invocations; gl_prog->info.gs.invocations = shader->info.Geom.Invocations;
} }
} }
@ -1975,26 +1976,28 @@ link_gs_inout_layout_qualifiers(struct gl_shader_program *prog,
* since we already know we're in the right type of shader program * since we already know we're in the right type of shader program
* for doing it. * for doing it.
*/ */
if (linked_shader->info.Geom.InputType == PRIM_UNKNOWN) { if (gl_prog->info.gs.input_primitive == PRIM_UNKNOWN) {
linker_error(prog, linker_error(prog,
"geometry shader didn't declare primitive input type\n"); "geometry shader didn't declare primitive input type\n");
return; return;
} }
if (linked_shader->info.Geom.OutputType == PRIM_UNKNOWN) { if (gl_prog->info.gs.output_primitive == PRIM_UNKNOWN) {
linker_error(prog, linker_error(prog,
"geometry shader didn't declare primitive output type\n"); "geometry shader didn't declare primitive output type\n");
return; return;
} }
if (linked_shader->info.Geom.VerticesOut == -1) { if (vertices_out == -1) {
linker_error(prog, linker_error(prog,
"geometry shader didn't declare max_vertices\n"); "geometry shader didn't declare max_vertices\n");
return; return;
} else {
gl_prog->info.gs.vertices_out = vertices_out;
} }
if (linked_shader->info.Geom.Invocations == 0) if (gl_prog->info.gs.invocations == 0)
linked_shader->info.Geom.Invocations = 1; gl_prog->info.gs.invocations = 1;
} }
@ -2208,7 +2211,7 @@ link_intrastage_shaders(void *mem_ctx,
link_fs_inout_layout_qualifiers(prog, linked, shader_list, num_shaders); link_fs_inout_layout_qualifiers(prog, linked, shader_list, num_shaders);
link_tcs_out_layout_qualifiers(prog, gl_prog, shader_list, num_shaders); link_tcs_out_layout_qualifiers(prog, gl_prog, shader_list, num_shaders);
link_tes_in_layout_qualifiers(prog, gl_prog, shader_list, num_shaders); link_tes_in_layout_qualifiers(prog, gl_prog, shader_list, num_shaders);
link_gs_inout_layout_qualifiers(prog, linked, shader_list, num_shaders); link_gs_inout_layout_qualifiers(prog, gl_prog, shader_list, num_shaders);
link_cs_input_layout_qualifiers(prog, linked, shader_list, num_shaders); link_cs_input_layout_qualifiers(prog, linked, shader_list, num_shaders);
link_xfb_stride_layout_qualifiers(ctx, prog, linked, shader_list, link_xfb_stride_layout_qualifiers(ctx, prog, linked, shader_list,
num_shaders); num_shaders);
@ -2285,7 +2288,8 @@ link_intrastage_shaders(void *mem_ctx,
/* Set the size of geometry shader input arrays */ /* Set the size of geometry shader input arrays */
if (linked->Stage == MESA_SHADER_GEOMETRY) { if (linked->Stage == MESA_SHADER_GEOMETRY) {
unsigned num_vertices = vertices_per_prim(linked->info.Geom.InputType); unsigned num_vertices =
vertices_per_prim(gl_prog->info.gs.input_primitive);
array_resize_visitor input_resize_visitor(num_vertices, prog, array_resize_visitor input_resize_visitor(num_vertices, prog,
MESA_SHADER_GEOMETRY); MESA_SHADER_GEOMETRY);
foreach_in_list(ir_instruction, ir, linked->ir) { foreach_in_list(ir_instruction, ir, linked->ir) {

View File

@ -719,7 +719,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
break; break;
if (check_gs_query(ctx, shProg)) { if (check_gs_query(ctx, shProg)) {
*params = shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]-> *params = shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->
info.Geom.VerticesOut; Program->info.gs.vertices_out;
} }
return; return;
case GL_GEOMETRY_SHADER_INVOCATIONS: case GL_GEOMETRY_SHADER_INVOCATIONS:
@ -727,7 +727,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
break; break;
if (check_gs_query(ctx, shProg)) { if (check_gs_query(ctx, shProg)) {
*params = shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]-> *params = shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->
info.Geom.Invocations; Program->info.gs.invocations;
} }
return; return;
case GL_GEOMETRY_INPUT_TYPE: case GL_GEOMETRY_INPUT_TYPE:
@ -735,7 +735,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
break; break;
if (check_gs_query(ctx, shProg)) { if (check_gs_query(ctx, shProg)) {
*params = shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]-> *params = shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->
info.Geom.InputType; Program->info.gs.input_primitive;
} }
return; return;
case GL_GEOMETRY_OUTPUT_TYPE: case GL_GEOMETRY_OUTPUT_TYPE:
@ -743,7 +743,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname,
break; break;
if (check_gs_query(ctx, shProg)) { if (check_gs_query(ctx, shProg)) {
*params = shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]-> *params = shProg->_LinkedShaders[MESA_SHADER_GEOMETRY]->
info.Geom.OutputType; Program->info.gs.output_primitive;
} }
return; return;
case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: { case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: {
@ -2204,10 +2204,6 @@ _mesa_copy_linked_program_data(const struct gl_shader_program *src,
switch (dst_sh->Stage) { switch (dst_sh->Stage) {
case MESA_SHADER_GEOMETRY: { case MESA_SHADER_GEOMETRY: {
dst->info.gs.vertices_in = src->Geom.VerticesIn; dst->info.gs.vertices_in = src->Geom.VerticesIn;
dst->info.gs.vertices_out = dst_sh->info.Geom.VerticesOut;
dst->info.gs.invocations = dst_sh->info.Geom.Invocations;
dst->info.gs.input_primitive = dst_sh->info.Geom.InputType;
dst->info.gs.output_primitive = dst_sh->info.Geom.OutputType;
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;