diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/auxiliary/draw/draw_pt.c | 2 | ||||
-rw-r--r-- | src/gallium/auxiliary/draw/draw_pt_varray.c | 11 | ||||
-rw-r--r-- | src/gallium/auxiliary/tgsi/tgsi_dump.c | 6 | ||||
-rw-r--r-- | src/mesa/main/api_validate.c | 10 | ||||
-rw-r--r-- | src/mesa/main/uniforms.c | 29 | ||||
-rw-r--r-- | src/mesa/program/prog_instruction.h | 16 | ||||
-rw-r--r-- | src/mesa/program/prog_print.c | 14 | ||||
-rw-r--r-- | src/mesa/program/prog_uniform.c | 18 | ||||
-rw-r--r-- | src/mesa/slang/slang_builtin.c | 66 | ||||
-rw-r--r-- | src/mesa/slang/slang_builtin.h | 3 | ||||
-rw-r--r-- | src/mesa/slang/slang_codegen.c | 25 | ||||
-rw-r--r-- | src/mesa/slang/slang_emit.c | 11 | ||||
-rw-r--r-- | src/mesa/slang/slang_ir.c | 34 | ||||
-rw-r--r-- | src/mesa/slang/slang_ir.h | 9 | ||||
-rw-r--r-- | src/mesa/slang/slang_link.c | 12 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_mesa_to_tgsi.c | 11 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_program.c | 3 |
17 files changed, 217 insertions, 63 deletions
diff --git a/src/gallium/auxiliary/draw/draw_pt.c b/src/gallium/auxiliary/draw/draw_pt.c index 6234272d6ce..32bd3d99cce 100644 --- a/src/gallium/auxiliary/draw/draw_pt.c +++ b/src/gallium/auxiliary/draw/draw_pt.c @@ -102,7 +102,7 @@ draw_pt_arrays(struct draw_context *draw, opt |= PT_SHADE; } - if (draw->pt.middle.llvm && !draw->gs.geometry_shader) { + if (draw->pt.middle.llvm) { middle = draw->pt.middle.llvm; } else { if (opt == 0) diff --git a/src/gallium/auxiliary/draw/draw_pt_varray.c b/src/gallium/auxiliary/draw/draw_pt_varray.c index d89d5cd20f4..cd7bb7bf253 100644 --- a/src/gallium/auxiliary/draw/draw_pt_varray.c +++ b/src/gallium/auxiliary/draw/draw_pt_varray.c @@ -120,17 +120,21 @@ static void varray_fan_segment(struct varray_frontend *varray, #define FUNC varray_run #include "draw_pt_varray_tmp_linear.h" -static unsigned decompose_prim[PIPE_PRIM_POLYGON + 1] = { +static unsigned decompose_prim[PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY + 1] = { PIPE_PRIM_POINTS, PIPE_PRIM_LINES, PIPE_PRIM_LINE_STRIP, /* decomposed LINELOOP */ PIPE_PRIM_LINE_STRIP, PIPE_PRIM_TRIANGLES, PIPE_PRIM_TRIANGLE_STRIP, - PIPE_PRIM_TRIANGLE_FAN, + PIPE_PRIM_TRIANGLE_FAN, PIPE_PRIM_QUADS, PIPE_PRIM_QUAD_STRIP, - PIPE_PRIM_POLYGON + PIPE_PRIM_POLYGON, + PIPE_PRIM_LINES_ADJACENCY, + PIPE_PRIM_LINE_STRIP_ADJACENCY, + PIPE_PRIM_TRIANGLES_ADJACENCY, + PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY }; @@ -145,6 +149,7 @@ static void varray_prepare(struct draw_pt_front_end *frontend, varray->base.run = varray_run; varray->input_prim = in_prim; + assert(in_prim < Elements(decompose_prim)); varray->output_prim = decompose_prim[in_prim]; varray->middle = middle; diff --git a/src/gallium/auxiliary/tgsi/tgsi_dump.c b/src/gallium/auxiliary/tgsi/tgsi_dump.c index 9fcc28f4c96..f71ffb70308 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_dump.c +++ b/src/gallium/auxiliary/tgsi/tgsi_dump.c @@ -176,7 +176,11 @@ static const char *primitive_names[] = "TRIANGLE_FAN", "QUADS", "QUAD_STRIP", - "POLYGON" + "POLYGON", + "LINES_ADJACENCY", + "LINE_STRIP_ADJACENCY", + "TRIANGLES_ADJACENCY", + "TRIANGLE_STRIP_ADJACENCY" }; static const char *fs_coord_origin_names[] = diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c index 150bc3886cf..b3b5c6cc053 100644 --- a/src/mesa/main/api_validate.c +++ b/src/mesa/main/api_validate.c @@ -193,7 +193,7 @@ _mesa_validate_DrawElements(GLcontext *ctx, return GL_FALSE; } - if (mode > GL_POLYGON) { + if (mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) { _mesa_error(ctx, GL_INVALID_ENUM, "glDrawElements(mode)" ); return GL_FALSE; } @@ -250,7 +250,7 @@ _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode, return GL_FALSE; } - if (mode > GL_POLYGON) { + if (mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) { _mesa_error(ctx, GL_INVALID_ENUM, "glDrawRangeElements(mode)" ); return GL_FALSE; } @@ -309,7 +309,7 @@ _mesa_validate_DrawArrays(GLcontext *ctx, return GL_FALSE; } - if (mode > GL_POLYGON) { + if (mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) { _mesa_error(ctx, GL_INVALID_ENUM, "glDrawArrays(mode)" ); return GL_FALSE; } @@ -339,7 +339,7 @@ _mesa_validate_DrawArraysInstanced(GLcontext *ctx, GLenum mode, GLint first, return GL_FALSE; } - if (mode > GL_POLYGON) { + if (mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) { _mesa_error(ctx, GL_INVALID_ENUM, "glDrawArraysInstanced(mode=0x%x)", mode); return GL_FALSE; @@ -384,7 +384,7 @@ _mesa_validate_DrawElementsInstanced(GLcontext *ctx, return GL_FALSE; } - if (mode > GL_POLYGON) { + if (mode > GL_TRIANGLE_STRIP_ADJACENCY_ARB) { _mesa_error(ctx, GL_INVALID_ENUM, "glDrawElementsInstanced(mode = 0x%x)", mode); return GL_FALSE; diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c index c869942d2eb..d68a7768df5 100644 --- a/src/mesa/main/uniforms.c +++ b/src/mesa/main/uniforms.c @@ -132,6 +132,11 @@ get_uniform_parameter(const struct gl_shader_program *shProg, GLuint index) progPos = shProg->Uniforms->Uniforms[index].FragPos; if (progPos >= 0) { prog = &shProg->FragmentProgram->Base; + } else { + progPos = shProg->Uniforms->Uniforms[index].GeomPos; + if (progPos >= 0) { + prog = &shProg->GeometryProgram->Base; + } } } @@ -315,6 +320,11 @@ lookup_uniform_parameter(GLcontext *ctx, GLuint program, GLint location, progPos = shProg->Uniforms->Uniforms[location].FragPos; if (progPos >= 0) { prog = &shProg->FragmentProgram->Base; + } else { + progPos = shProg->Uniforms->Uniforms[location].GeomPos; + if (progPos >= 0) { + prog = &shProg->GeometryProgram->Base; + } } } } @@ -829,6 +839,15 @@ _mesa_uniform(GLcontext *ctx, GLint location, GLsizei count, } } + if (shProg->GeometryProgram) { + /* convert uniform location to program parameter index */ + GLint index = uniform->GeomPos; + if (index >= 0) { + set_program_uniform(ctx, &shProg->GeometryProgram->Base, + index, offset, type, count, elems, values); + } + } + uniform->Initialized = GL_TRUE; } @@ -962,6 +981,16 @@ _mesa_uniform_matrix(GLcontext *ctx, GLint cols, GLint rows, } } + if (shProg->GeometryProgram) { + /* convert uniform location to program parameter index */ + GLint index = uniform->GeomPos; + if (index >= 0) { + set_program_uniform_matrix(ctx, &shProg->GeometryProgram->Base, + index, offset, + count, rows, cols, transpose, values); + } + } + uniform->Initialized = GL_TRUE; } diff --git a/src/mesa/program/prog_instruction.h b/src/mesa/program/prog_instruction.h index bc980c6a7f6..dacbc33704b 100644 --- a/src/mesa/program/prog_instruction.h +++ b/src/mesa/program/prog_instruction.h @@ -271,6 +271,22 @@ struct prog_src_register * instruction which allows per-component negation. */ GLuint Negate:4; + + /** + * Is the register two-dimensional. + * Two dimensional registers are of the + * REGISTER[index][index2] format. + * They are used by the geometry shaders where + * the first index is the index within an array + * and the second index is the semantic of the + * array, e.g. gl_PositionIn[index] would become + * INPUT[index][gl_PositionIn] + */ + GLuint HasIndex2:1; + GLuint RelAddr2:1; + GLint Index2:(INST_INDEX_BITS+1); /**< Extra bit here for sign bit. + * May be negative for relative + * addressing. */ }; diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c index 80c9203e31f..6ab199aa02b 100644 --- a/src/mesa/program/prog_print.c +++ b/src/mesa/program/prog_print.c @@ -265,7 +265,8 @@ arb_output_attrib_string(GLint index, GLenum progType) */ static const char * reg_string(gl_register_file f, GLint index, gl_prog_print_mode mode, - GLboolean relAddr, const struct gl_program *prog) + GLboolean relAddr, const struct gl_program *prog, + GLboolean hasIndex2, GLboolean relAddr2, GLint index2) { static char str[100]; const char *addr = relAddr ? "ADDR+" : ""; @@ -275,6 +276,11 @@ reg_string(gl_register_file f, GLint index, gl_prog_print_mode mode, switch (mode) { case PROG_PRINT_DEBUG: sprintf(str, "%s[%s%d]", file_string(f, mode), addr, index); + if (hasIndex2) { + int offset = strlen(str); + const char *addr2 = relAddr2 ? "ADDR+" : ""; + sprintf(str+offset, "[%s%d]", addr2, index2); + } break; case PROG_PRINT_ARB: @@ -478,7 +484,8 @@ fprint_dst_reg(FILE * f, { fprintf(f, "%s%s", reg_string((gl_register_file) dstReg->File, - dstReg->Index, mode, dstReg->RelAddr, prog), + dstReg->Index, mode, dstReg->RelAddr, prog, + GL_FALSE, GL_FALSE, 0), _mesa_writemask_string(dstReg->WriteMask)); if (dstReg->CondMask != COND_TR) { @@ -508,7 +515,8 @@ fprint_src_reg(FILE *f, fprintf(f, "%s%s%s%s", abs, reg_string((gl_register_file) srcReg->File, - srcReg->Index, mode, srcReg->RelAddr, prog), + srcReg->Index, mode, srcReg->RelAddr, prog, + srcReg->HasIndex2, srcReg->RelAddr2, srcReg->Index2), _mesa_swizzle_string(srcReg->Swizzle, srcReg->Negate, GL_FALSE), abs); diff --git a/src/mesa/program/prog_uniform.c b/src/mesa/program/prog_uniform.c index c408a8492c6..5aa9878d43c 100644 --- a/src/mesa/program/prog_uniform.c +++ b/src/mesa/program/prog_uniform.c @@ -61,7 +61,8 @@ _mesa_append_uniform(struct gl_uniform_list *list, GLint index; assert(target == GL_VERTEX_PROGRAM_ARB || - target == GL_FRAGMENT_PROGRAM_ARB); + target == GL_FRAGMENT_PROGRAM_ARB || + target == MESA_GEOMETRY_PROGRAM); index = _mesa_lookup_uniform(list, name); if (index < 0) { @@ -90,6 +91,7 @@ _mesa_append_uniform(struct gl_uniform_list *list, uniform->Name = _mesa_strdup(name); uniform->VertPos = -1; uniform->FragPos = -1; + uniform->GeomPos = -1; uniform->Initialized = GL_FALSE; list->NumUniforms++; @@ -106,13 +108,18 @@ _mesa_append_uniform(struct gl_uniform_list *list, return GL_FALSE; } uniform->VertPos = progPos; - } - else { + } else if (target == GL_FRAGMENT_PROGRAM_ARB) { if (uniform->FragPos != -1) { /* this uniform is already in the list - that shouldn't happen */ return GL_FALSE; } uniform->FragPos = progPos; + } else { + if (uniform->GeomPos != -1) { + /* this uniform is already in the list - that shouldn't happen */ + return GL_FALSE; + } + uniform->GeomPos = progPos; } return uniform; @@ -156,10 +163,11 @@ _mesa_print_uniforms(const struct gl_uniform_list *list) GLuint i; printf("Uniform list %p:\n", (void *) list); for (i = 0; i < list->NumUniforms; i++) { - printf("%d: %s %d %d\n", + printf("%d: %s %d %d %d\n", i, list->Uniforms[i].Name, list->Uniforms[i].VertPos, - list->Uniforms[i].FragPos); + list->Uniforms[i].FragPos, + list->Uniforms[i].GeomPos); } } diff --git a/src/mesa/slang/slang_builtin.c b/src/mesa/slang/slang_builtin.c index e3ac7d38e2d..a7e0efcb7b5 100644 --- a/src/mesa/slang/slang_builtin.c +++ b/src/mesa/slang/slang_builtin.c @@ -756,47 +756,48 @@ struct input_info GLuint Attrib; GLenum Type; GLuint Swizzle; + GLboolean Array; }; /** Predefined vertex shader inputs/attributes */ static const struct input_info vertInputs[] = { - { "gl_Vertex", VERT_ATTRIB_POS, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_Normal", VERT_ATTRIB_NORMAL, GL_FLOAT_VEC3, SWIZZLE_NOOP }, - { "gl_Color", VERT_ATTRIB_COLOR0, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_SecondaryColor", VERT_ATTRIB_COLOR1, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_FogCoord", VERT_ATTRIB_FOG, GL_FLOAT, SWIZZLE_XXXX }, - { "gl_MultiTexCoord0", VERT_ATTRIB_TEX0, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_MultiTexCoord1", VERT_ATTRIB_TEX1, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_MultiTexCoord2", VERT_ATTRIB_TEX2, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_MultiTexCoord3", VERT_ATTRIB_TEX3, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_MultiTexCoord4", VERT_ATTRIB_TEX4, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_MultiTexCoord5", VERT_ATTRIB_TEX5, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_MultiTexCoord6", VERT_ATTRIB_TEX6, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_MultiTexCoord7", VERT_ATTRIB_TEX7, GL_FLOAT_VEC4, SWIZZLE_NOOP } + { "gl_Vertex", VERT_ATTRIB_POS, GL_FLOAT_VEC4, SWIZZLE_NOOP, GL_FALSE }, + { "gl_Normal", VERT_ATTRIB_NORMAL, GL_FLOAT_VEC3, SWIZZLE_NOOP, GL_FALSE }, + { "gl_Color", VERT_ATTRIB_COLOR0, GL_FLOAT_VEC4, SWIZZLE_NOOP, GL_FALSE }, + { "gl_SecondaryColor", VERT_ATTRIB_COLOR1, GL_FLOAT_VEC4, SWIZZLE_NOOP, GL_FALSE }, + { "gl_FogCoord", VERT_ATTRIB_FOG, GL_FLOAT, SWIZZLE_XXXX, GL_FALSE }, + { "gl_MultiTexCoord0", VERT_ATTRIB_TEX0, GL_FLOAT_VEC4, SWIZZLE_NOOP, GL_FALSE }, + { "gl_MultiTexCoord1", VERT_ATTRIB_TEX1, GL_FLOAT_VEC4, SWIZZLE_NOOP, GL_FALSE }, + { "gl_MultiTexCoord2", VERT_ATTRIB_TEX2, GL_FLOAT_VEC4, SWIZZLE_NOOP, GL_FALSE }, + { "gl_MultiTexCoord3", VERT_ATTRIB_TEX3, GL_FLOAT_VEC4, SWIZZLE_NOOP, GL_FALSE }, + { "gl_MultiTexCoord4", VERT_ATTRIB_TEX4, GL_FLOAT_VEC4, SWIZZLE_NOOP, GL_FALSE }, + { "gl_MultiTexCoord5", VERT_ATTRIB_TEX5, GL_FLOAT_VEC4, SWIZZLE_NOOP, GL_FALSE }, + { "gl_MultiTexCoord6", VERT_ATTRIB_TEX6, GL_FLOAT_VEC4, SWIZZLE_NOOP, GL_FALSE }, + { "gl_MultiTexCoord7", VERT_ATTRIB_TEX7, GL_FLOAT_VEC4, SWIZZLE_NOOP, GL_FALSE } }; static const struct input_info geomInputs[] = { - { "gl_PrimitiveIDIn", GEOM_ATTRIB_PRIMITIVE_ID, GL_FLOAT, SWIZZLE_NOOP }, - { "gl_FrontColorIn", GEOM_ATTRIB_COLOR0, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_BackColorIn", GEOM_ATTRIB_COLOR1, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_FrontSecondaryColorIn", GEOM_ATTRIB_SECONDARY_COLOR0, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_BackSecondaryColorIn", GEOM_ATTRIB_SECONDARY_COLOR1, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_TexCoordIn", GEOM_ATTRIB_TEX_COORD, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_FogFragCoordIn", GEOM_ATTRIB_FOG_FRAG_COORD, GL_FLOAT, SWIZZLE_NOOP }, - { "gl_PositionIn", GEOM_ATTRIB_POSITION, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_ClipVertexIn", GEOM_ATTRIB_CLIP_VERTEX, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_PointSizeIn", GEOM_ATTRIB_POINT_SIZE, GL_FLOAT, SWIZZLE_NOOP } + { "gl_PrimitiveIDIn", GEOM_ATTRIB_PRIMITIVE_ID, GL_FLOAT, SWIZZLE_NOOP, GL_FALSE }, + { "gl_FrontColorIn", GEOM_ATTRIB_COLOR0, GL_FLOAT_VEC4, SWIZZLE_NOOP, GL_TRUE }, + { "gl_BackColorIn", GEOM_ATTRIB_COLOR1, GL_FLOAT_VEC4, SWIZZLE_NOOP, GL_TRUE }, + { "gl_FrontSecondaryColorIn", GEOM_ATTRIB_SECONDARY_COLOR0, GL_FLOAT_VEC4, SWIZZLE_NOOP, GL_TRUE }, + { "gl_BackSecondaryColorIn", GEOM_ATTRIB_SECONDARY_COLOR1, GL_FLOAT_VEC4, SWIZZLE_NOOP, GL_TRUE }, + { "gl_TexCoordIn", GEOM_ATTRIB_TEX_COORD, GL_FLOAT_VEC4, SWIZZLE_NOOP, GL_TRUE }, + { "gl_FogFragCoordIn", GEOM_ATTRIB_FOG_FRAG_COORD, GL_FLOAT, SWIZZLE_NOOP, GL_TRUE }, + { "gl_PositionIn", GEOM_ATTRIB_POSITION, GL_FLOAT_VEC4, SWIZZLE_NOOP, GL_TRUE }, + { "gl_ClipVertexIn", GEOM_ATTRIB_CLIP_VERTEX, GL_FLOAT_VEC4, SWIZZLE_NOOP, GL_TRUE }, + { "gl_PointSizeIn", GEOM_ATTRIB_POINT_SIZE, GL_FLOAT, SWIZZLE_NOOP, GL_TRUE } }; /** Predefined fragment shader inputs */ static const struct input_info fragInputs[] = { - { "gl_FragCoord", FRAG_ATTRIB_WPOS, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_Color", FRAG_ATTRIB_COL0, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_SecondaryColor", FRAG_ATTRIB_COL1, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_TexCoord", FRAG_ATTRIB_TEX0, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_FogFragCoord", FRAG_ATTRIB_FOGC, GL_FLOAT, SWIZZLE_XXXX }, - { "gl_FrontFacing", FRAG_ATTRIB_FACE, GL_FLOAT, SWIZZLE_XXXX }, - { "gl_PointCoord", FRAG_ATTRIB_PNTC, GL_FLOAT_VEC2, SWIZZLE_XYZW } + { "gl_FragCoord", FRAG_ATTRIB_WPOS, GL_FLOAT_VEC4, SWIZZLE_NOOP, GL_FALSE }, + { "gl_Color", FRAG_ATTRIB_COL0, GL_FLOAT_VEC4, SWIZZLE_NOOP, GL_FALSE }, + { "gl_SecondaryColor", FRAG_ATTRIB_COL1, GL_FLOAT_VEC4, SWIZZLE_NOOP, GL_FALSE }, + { "gl_TexCoord", FRAG_ATTRIB_TEX0, GL_FLOAT_VEC4, SWIZZLE_NOOP, GL_FALSE }, + { "gl_FogFragCoord", FRAG_ATTRIB_FOGC, GL_FLOAT, SWIZZLE_XXXX, GL_FALSE }, + { "gl_FrontFacing", FRAG_ATTRIB_FACE, GL_FLOAT, SWIZZLE_XXXX, GL_FALSE }, + { "gl_PointCoord", FRAG_ATTRIB_PNTC, GL_FLOAT_VEC2, SWIZZLE_XYZW, GL_FALSE } }; @@ -807,7 +808,8 @@ static const struct input_info fragInputs[] = { * XXX return size too */ GLint -_slang_input_index(const char *name, GLenum target, GLuint *swizzleOut) +_slang_input_index(const char *name, GLenum target, GLuint *swizzleOut, + GLboolean *is_array) { const struct input_info *inputs; GLuint i, n; @@ -836,6 +838,8 @@ _slang_input_index(const char *name, GLenum target, GLuint *swizzleOut) if (strcmp(inputs[i].Name, name) == 0) { /* found */ *swizzleOut = inputs[i].Swizzle; + if (is_array) + *is_array = inputs[i].Array; return inputs[i].Attrib; } } diff --git a/src/mesa/slang/slang_builtin.h b/src/mesa/slang/slang_builtin.h index cef18afdd55..ed9ae80b3c3 100644 --- a/src/mesa/slang/slang_builtin.h +++ b/src/mesa/slang/slang_builtin.h @@ -38,7 +38,8 @@ _slang_alloc_statevar(slang_ir_node *n, extern GLint -_slang_input_index(const char *name, GLenum target, GLuint *swizzleOut); +_slang_input_index(const char *name, GLenum target, GLuint *swizzleOut, + GLboolean *is_array); extern GLint _slang_output_index(const char *name, GLenum target); diff --git a/src/mesa/slang/slang_codegen.c b/src/mesa/slang/slang_codegen.c index 79072cb3569..11a9074d1ec 100644 --- a/src/mesa/slang/slang_codegen.c +++ b/src/mesa/slang/slang_codegen.c @@ -5155,7 +5155,7 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var, /* fragment program input */ GLuint swizzle; GLint index = _slang_input_index(varName, GL_FRAGMENT_PROGRAM_ARB, - &swizzle); + &swizzle, NULL); assert(index >= 0); assert(index < FRAG_ATTRIB_MAX); store = _slang_new_ir_storage_swz(PROGRAM_INPUT, index, @@ -5171,9 +5171,10 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var, size, swizzle); } else { /* geometry program input */ + GLboolean is_array = GL_FALSE; GLuint swizzle; GLint index = _slang_input_index(varName, MESA_GEOMETRY_PROGRAM, - &swizzle); + &swizzle, &is_array); if (index < 0) { /* geometry program output */ index = _slang_output_index(varName, MESA_GEOMETRY_PROGRAM); @@ -5187,8 +5188,12 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var, } else { assert(index >= 0); /* assert(index < GEOM_ATTRIB_MAX); */ - store = _slang_new_ir_storage_swz(PROGRAM_INPUT, index, - size, swizzle); + if (is_array) + store = _slang_new_ir_storage_2d(PROGRAM_INPUT, 0, index, + size, swizzle); + else + store = _slang_new_ir_storage_swz(PROGRAM_INPUT, index, + size, swizzle); } } if (dbg) printf("V/F "); @@ -5217,7 +5222,7 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var, } else { /* pre-defined vertex attrib */ - index = _slang_input_index(varName, GL_VERTEX_PROGRAM_ARB, &swizzle); + index = _slang_input_index(varName, GL_VERTEX_PROGRAM_ARB, &swizzle, NULL); assert(index >= 0); } store = _slang_new_ir_storage_swz(PROGRAM_INPUT, index, size, swizzle); @@ -5227,12 +5232,16 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var, GLuint swizzle = SWIZZLE_XYZW; /* silence compiler warning */ if (type == SLANG_UNIT_FRAGMENT_BUILTIN) { GLint index = _slang_input_index(varName, GL_FRAGMENT_PROGRAM_ARB, - &swizzle); + &swizzle, NULL); store = _slang_new_ir_storage_swz(PROGRAM_INPUT, index, size, swizzle); } else if (type == SLANG_UNIT_GEOMETRY_BUILTIN) { + GLboolean is_array; GLint index = _slang_input_index(varName, MESA_GEOMETRY_PROGRAM, - &swizzle); - store = _slang_new_ir_storage_swz(PROGRAM_INPUT, index, size, swizzle); + &swizzle, &is_array); + if (is_array) + store = _slang_new_ir_storage_2d(PROGRAM_INPUT, 0, index, size, swizzle); + else + store = _slang_new_ir_storage_swz(PROGRAM_INPUT, index, size, swizzle); } if (dbg) printf("INPUT "); } diff --git a/src/mesa/slang/slang_emit.c b/src/mesa/slang/slang_emit.c index 127c6725542..a9aa6fe1c3a 100644 --- a/src/mesa/slang/slang_emit.c +++ b/src/mesa/slang/slang_emit.c @@ -379,6 +379,9 @@ storage_to_src_reg(struct prog_src_register *src, const slang_ir_storage *st) assert(GET_SWZ(swizzle, 3) <= SWIZZLE_W); src->Swizzle = swizzle; + src->HasIndex2 = st->Is2D; + src->Index2 = st->Index2; + src->RelAddr = relAddr; } @@ -2317,7 +2320,13 @@ emit_var_ref(slang_emit_info *emitInfo, slang_ir_node *n) } else if (n->Store->File == PROGRAM_INPUT) { assert(n->Store->Index >= 0); - emitInfo->prog->InputsRead |= (1 << n->Store->Index); + /* geometry shaders have the input index in the second + * index */ + if (emitInfo->prog->Target == MESA_GEOMETRY_PROGRAM && + n->Store->Is2D) { + emitInfo->prog->InputsRead |= (1 << n->Store->Index2); + } else + emitInfo->prog->InputsRead |= (1 << n->Store->Index); } if (n->Store->Index < 0) { diff --git a/src/mesa/slang/slang_ir.c b/src/mesa/slang/slang_ir.c index d78ba52505a..078c9369a89 100644 --- a/src/mesa/slang/slang_ir.c +++ b/src/mesa/slang/slang_ir.c @@ -133,6 +133,8 @@ _slang_init_ir_storage(slang_ir_storage *st, st->Swizzle = swizzle; st->Parent = NULL; st->IsIndirect = GL_FALSE; + st->Is2D = GL_FALSE; + st->Index2 = 0; } @@ -151,6 +153,8 @@ _slang_new_ir_storage(gl_register_file file, GLint index, GLint size) st->Swizzle = SWIZZLE_NOOP; st->Parent = NULL; st->IsIndirect = GL_FALSE; + st->Is2D = GL_FALSE; + st->Index2 = 0; } return st; } @@ -172,10 +176,36 @@ _slang_new_ir_storage_swz(gl_register_file file, GLint index, GLint size, st->Swizzle = swizzle; st->Parent = NULL; st->IsIndirect = GL_FALSE; + st->Is2D = GL_FALSE; + st->Index2 = 0; } return st; } +/** + * Return a new slang_ir_storage object. + */ +slang_ir_storage * +_slang_new_ir_storage_2d(gl_register_file file, + GLint index, GLint index2, + GLint size, GLuint swizzle) +{ + slang_ir_storage *st; + st = (slang_ir_storage *) _slang_alloc(sizeof(slang_ir_storage)); + if (st) { + st->File = file; + st->Index = index; + st->Size = size; + st->Swizzle = swizzle; + st->Parent = NULL; + st->IsIndirect = GL_FALSE; + st->Is2D = GL_TRUE; + st->Index2 = index2; + } + return st; +} + + /** * Return a new slang_ir_storage object. @@ -193,6 +223,8 @@ _slang_new_ir_storage_relative(GLint index, GLint size, st->Swizzle = SWIZZLE_NOOP; st->Parent = parent; st->IsIndirect = GL_FALSE; + st->Is2D = GL_FALSE; + st->Index2 = 0; } return st; } @@ -217,6 +249,8 @@ _slang_new_ir_storage_indirect(gl_register_file file, st->IndirectFile = indirectFile; st->IndirectIndex = indirectIndex; st->IndirectSwizzle = indirectSwizzle; + st->Is2D = GL_FALSE; + st->Index2 = 0; } return st; } diff --git a/src/mesa/slang/slang_ir.h b/src/mesa/slang/slang_ir.h index e9af079a1e3..b7a373746b4 100644 --- a/src/mesa/slang/slang_ir.h +++ b/src/mesa/slang/slang_ir.h @@ -189,6 +189,11 @@ struct slang_ir_storage_ GLuint IndirectSwizzle; GLuint TexTarget; /**< If File==PROGRAM_SAMPLER, one of TEXTURE_x_INDEX */ + /* Is the register two-dimensional and + * if so what's the second index */ + GLboolean Is2D; + GLint Index2; + /** If Parent is non-null, Index is relative to parent. * The other fields are ignored. */ @@ -252,6 +257,10 @@ _slang_new_ir_storage_swz(gl_register_file file, GLint index, GLint size, GLuint swizzle); extern slang_ir_storage * +_slang_new_ir_storage_2d(gl_register_file file, GLint index, GLint index2d, + GLint size, GLuint swizzle); + +extern slang_ir_storage * _slang_new_ir_storage_relative(GLint index, GLint size, slang_ir_storage *parent); diff --git a/src/mesa/slang/slang_link.c b/src/mesa/slang/slang_link.c index bc2bd31fda5..955ee79ed86 100644 --- a/src/mesa/slang/slang_link.c +++ b/src/mesa/slang/slang_link.c @@ -761,9 +761,15 @@ _slang_update_inputs_outputs(struct gl_program *prog) const GLuint numSrc = _mesa_num_inst_src_regs(inst->Opcode); for (j = 0; j < numSrc; j++) { if (inst->SrcReg[j].File == PROGRAM_INPUT) { - prog->InputsRead |= get_inputs_read_mask(prog->Target, - inst->SrcReg[j].Index, - inst->SrcReg[j].RelAddr); + if (prog->Target == MESA_GEOMETRY_PROGRAM && + inst->SrcReg[j].HasIndex2) + prog->InputsRead |= get_inputs_read_mask(prog->Target, + inst->SrcReg[j].Index2, + inst->SrcReg[j].RelAddr2); + else + prog->InputsRead |= get_inputs_read_mask(prog->Target, + inst->SrcReg[j].Index, + inst->SrcReg[j].RelAddr); } else if (inst->SrcReg[j].File == PROGRAM_ADDRESS) { maxAddrReg = MAX2(maxAddrReg, (GLuint) (inst->SrcReg[j].Index + 1)); diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index fdf023d6ae3..bacd091853b 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -176,7 +176,7 @@ dst_register( struct st_translate *t, else if (t->procType == TGSI_PROCESSOR_FRAGMENT) assert(index < FRAG_RESULT_MAX); else - assert(0 && "geom shaders not handled in dst_register() yet"); + assert(index < GEOM_RESULT_MAX); assert(t->outputMapping[index] < Elements(t->outputs)); @@ -305,6 +305,15 @@ translate_src( struct st_translate *t, { struct ureg_src src = src_register( t, SrcReg->File, SrcReg->Index ); + if (t->procType == TGSI_PROCESSOR_GEOMETRY && SrcReg->HasIndex2) { + src = src_register( t, SrcReg->File, SrcReg->Index2 ); + if (SrcReg->RelAddr2) + src = ureg_src_dimension_indirect( src, ureg_src(t->address[0]), + SrcReg->Index); + else + src = ureg_src_dimension( src, SrcReg->Index); + } + src = ureg_swizzle( src, GET_SWZ( SrcReg->Swizzle, 0 ) & 0x3, GET_SWZ( SrcReg->Swizzle, 1 ) & 0x3, diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 1d748965f80..6f3ecdbce11 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -492,6 +492,9 @@ st_translate_geometry_program(struct st_context *st, /* which vertex output goes to the first geometry input */ vslot = 0; + memset(inputMapping, 0, sizeof(inputMapping)); + memset(outputMapping, 0, sizeof(outputMapping)); + /* * Convert Mesa program inputs to TGSI input register semantics. */ |