diff options
Diffstat (limited to 'mesalib/src/mesa/state_tracker')
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_cb_readpixels.c | 40 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_format.c | 453 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 44 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_program.c | 9 |
4 files changed, 438 insertions, 108 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_cb_readpixels.c b/mesalib/src/mesa/state_tracker/st_cb_readpixels.c index e2b29fe30..7fa1672fd 100644 --- a/mesalib/src/mesa/state_tracker/st_cb_readpixels.c +++ b/mesalib/src/mesa/state_tracker/st_cb_readpixels.c @@ -387,6 +387,8 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei h GLsizei i, j; GLint yStep, dfStride; GLfloat *df; + GLuint *dui; + GLint *di; struct st_renderbuffer *strb; struct gl_pixelstore_attrib clippedPacking = *pack; struct pipe_transfer *trans; @@ -454,10 +456,13 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei h } else { /* write tile(row) into temp row buffer */ - df = (GLfloat *) temp; + df = (GLfloat *)temp; dfStride = 0; } + dui = (GLuint *)df; + di = (GLint *)df; + if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) { /* convert GL Y to Gallium Y */ y = strb->Base.Height - y - height; @@ -611,7 +616,38 @@ st_readpixels(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei h dst += dstStride; } } - else { + else if (util_format_is_pure_sint(pformat)) { + for (i = 0; i < height; i++) { + if (type == GL_UNSIGNED_INT) + pipe_get_tile_ui_format(pipe, trans, 0, y, width, 1, + pformat, dui); + else + pipe_get_tile_i_format(pipe, trans, 0, y, width, 1, + pformat, di); + y += yStep; + if (!dfStride) { + _mesa_pack_rgba_span_int(ctx, width, (GLuint (*)[4])temp, + format, type, dst); + dst += dstStride; + } + } + } else if (util_format_is_pure_uint(pformat)) { + for (i = 0; i < height; i++) { + if (type == GL_UNSIGNED_INT) + pipe_get_tile_ui_format(pipe, trans, 0, y, width, 1, + pformat, dui); + else + pipe_get_tile_i_format(pipe, trans, 0, y, width, 1, + pformat, di); + y += yStep; + df += dfStride; + if (!dfStride) { + _mesa_pack_rgba_span_int(ctx, width, (GLuint (*)[4])temp, + format, type, dst); + dst += dstStride; + } + } + } else { /* RGBA format */ /* Do a row at a time to flip image data vertically */ for (i = 0; i < height; i++) { diff --git a/mesalib/src/mesa/state_tracker/st_format.c b/mesalib/src/mesa/state_tracker/st_format.c index 6eb8a506b..6e8ab94f4 100644 --- a/mesalib/src/mesa/state_tracker/st_format.c +++ b/mesalib/src/mesa/state_tracker/st_format.c @@ -291,20 +291,112 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) return PIPE_FORMAT_R16G16B16A16_UNORM; /* signed int formats */ + case MESA_FORMAT_ALPHA_UINT8: + return PIPE_FORMAT_A8_UINT; + case MESA_FORMAT_ALPHA_UINT16: + return PIPE_FORMAT_A16_UINT; + case MESA_FORMAT_ALPHA_UINT32: + return PIPE_FORMAT_A32_UINT; + + case MESA_FORMAT_ALPHA_INT8: + return PIPE_FORMAT_A8_SINT; + case MESA_FORMAT_ALPHA_INT16: + return PIPE_FORMAT_A16_SINT; + case MESA_FORMAT_ALPHA_INT32: + return PIPE_FORMAT_A32_SINT; + + case MESA_FORMAT_INTENSITY_UINT8: + return PIPE_FORMAT_I8_UINT; + case MESA_FORMAT_INTENSITY_UINT16: + return PIPE_FORMAT_I16_UINT; + case MESA_FORMAT_INTENSITY_UINT32: + return PIPE_FORMAT_I32_UINT; + + case MESA_FORMAT_INTENSITY_INT8: + return PIPE_FORMAT_I8_SINT; + case MESA_FORMAT_INTENSITY_INT16: + return PIPE_FORMAT_I16_SINT; + case MESA_FORMAT_INTENSITY_INT32: + return PIPE_FORMAT_I32_SINT; + + case MESA_FORMAT_LUMINANCE_UINT8: + return PIPE_FORMAT_L8_UINT; + case MESA_FORMAT_LUMINANCE_UINT16: + return PIPE_FORMAT_L16_UINT; + case MESA_FORMAT_LUMINANCE_UINT32: + return PIPE_FORMAT_L32_UINT; + + case MESA_FORMAT_LUMINANCE_INT8: + return PIPE_FORMAT_L8_SINT; + case MESA_FORMAT_LUMINANCE_INT16: + return PIPE_FORMAT_L16_SINT; + case MESA_FORMAT_LUMINANCE_INT32: + return PIPE_FORMAT_L32_SINT; + + case MESA_FORMAT_LUMINANCE_ALPHA_UINT8: + return PIPE_FORMAT_L8A8_UINT; + case MESA_FORMAT_LUMINANCE_ALPHA_UINT16: + return PIPE_FORMAT_L16A16_UINT; + case MESA_FORMAT_LUMINANCE_ALPHA_UINT32: + return PIPE_FORMAT_L32A32_UINT; + + case MESA_FORMAT_LUMINANCE_ALPHA_INT8: + return PIPE_FORMAT_L8A8_SINT; + case MESA_FORMAT_LUMINANCE_ALPHA_INT16: + return PIPE_FORMAT_L16A16_SINT; + case MESA_FORMAT_LUMINANCE_ALPHA_INT32: + return PIPE_FORMAT_L32A32_SINT; + + case MESA_FORMAT_R_INT8: + return PIPE_FORMAT_R8_SINT; + case MESA_FORMAT_RG_INT8: + return PIPE_FORMAT_R8G8_SINT; + case MESA_FORMAT_RGB_INT8: + return PIPE_FORMAT_R8G8B8_SINT; case MESA_FORMAT_RGBA_INT8: - return PIPE_FORMAT_R8G8B8A8_SSCALED; + return PIPE_FORMAT_R8G8B8A8_SINT; + case MESA_FORMAT_R_INT16: + return PIPE_FORMAT_R16_SINT; + case MESA_FORMAT_RG_INT16: + return PIPE_FORMAT_R16G16_SINT; + case MESA_FORMAT_RGB_INT16: + return PIPE_FORMAT_R16G16B16_SINT; case MESA_FORMAT_RGBA_INT16: - return PIPE_FORMAT_R16G16B16A16_SSCALED; + return PIPE_FORMAT_R16G16B16A16_SINT; + case MESA_FORMAT_R_INT32: + return PIPE_FORMAT_R32_SINT; + case MESA_FORMAT_RG_INT32: + return PIPE_FORMAT_R32G32_SINT; + case MESA_FORMAT_RGB_INT32: + return PIPE_FORMAT_R32G32B32_SINT; case MESA_FORMAT_RGBA_INT32: - return PIPE_FORMAT_R32G32B32A32_SSCALED; + return PIPE_FORMAT_R32G32B32A32_SINT; /* unsigned int formats */ + case MESA_FORMAT_R_UINT8: + return PIPE_FORMAT_R8_UINT; + case MESA_FORMAT_RG_UINT8: + return PIPE_FORMAT_R8G8_UINT; + case MESA_FORMAT_RGB_UINT8: + return PIPE_FORMAT_R8G8B8_UINT; case MESA_FORMAT_RGBA_UINT8: - return PIPE_FORMAT_R8G8B8A8_USCALED; + return PIPE_FORMAT_R8G8B8A8_UINT; + case MESA_FORMAT_R_UINT16: + return PIPE_FORMAT_R16_UINT; + case MESA_FORMAT_RG_UINT16: + return PIPE_FORMAT_R16G16_UINT; + case MESA_FORMAT_RGB_UINT16: + return PIPE_FORMAT_R16G16B16_UINT; case MESA_FORMAT_RGBA_UINT16: - return PIPE_FORMAT_R16G16B16A16_USCALED; + return PIPE_FORMAT_R16G16B16A16_UINT; + case MESA_FORMAT_R_UINT32: + return PIPE_FORMAT_R32_UINT; + case MESA_FORMAT_RG_UINT32: + return PIPE_FORMAT_R32G32_UINT; + case MESA_FORMAT_RGB_UINT32: + return PIPE_FORMAT_R32G32B32_UINT; case MESA_FORMAT_RGBA_UINT32: - return PIPE_FORMAT_R32G32B32A32_USCALED; + return PIPE_FORMAT_R32G32B32A32_UINT; case MESA_FORMAT_RED_RGTC1: return PIPE_FORMAT_RGTC1_UNORM; @@ -519,20 +611,111 @@ st_pipe_format_to_mesa_format(enum pipe_format format) case PIPE_FORMAT_R16G16_UNORM: return MESA_FORMAT_RG1616; - /* signed int formats */ - case PIPE_FORMAT_R8G8B8A8_SSCALED: + case PIPE_FORMAT_A8_UINT: + return MESA_FORMAT_ALPHA_UINT8; + case PIPE_FORMAT_A16_UINT: + return MESA_FORMAT_ALPHA_UINT16; + case PIPE_FORMAT_A32_UINT: + return MESA_FORMAT_ALPHA_UINT32; + case PIPE_FORMAT_A8_SINT: + return MESA_FORMAT_ALPHA_INT8; + case PIPE_FORMAT_A16_SINT: + return MESA_FORMAT_ALPHA_INT16; + case PIPE_FORMAT_A32_SINT: + return MESA_FORMAT_ALPHA_INT32; + + case PIPE_FORMAT_I8_UINT: + return MESA_FORMAT_INTENSITY_UINT8; + case PIPE_FORMAT_I16_UINT: + return MESA_FORMAT_INTENSITY_UINT16; + case PIPE_FORMAT_I32_UINT: + return MESA_FORMAT_INTENSITY_UINT32; + case PIPE_FORMAT_I8_SINT: + return MESA_FORMAT_INTENSITY_INT8; + case PIPE_FORMAT_I16_SINT: + return MESA_FORMAT_INTENSITY_INT16; + case PIPE_FORMAT_I32_SINT: + return MESA_FORMAT_INTENSITY_INT32; + + case PIPE_FORMAT_L8_UINT: + return MESA_FORMAT_LUMINANCE_UINT8; + case PIPE_FORMAT_L16_UINT: + return MESA_FORMAT_LUMINANCE_UINT16; + case PIPE_FORMAT_L32_UINT: + return MESA_FORMAT_LUMINANCE_UINT32; + case PIPE_FORMAT_L8_SINT: + return MESA_FORMAT_LUMINANCE_INT8; + case PIPE_FORMAT_L16_SINT: + return MESA_FORMAT_LUMINANCE_INT16; + case PIPE_FORMAT_L32_SINT: + return MESA_FORMAT_LUMINANCE_INT32; + + case PIPE_FORMAT_L8A8_UINT: + return MESA_FORMAT_LUMINANCE_ALPHA_UINT8; + case PIPE_FORMAT_L16A16_UINT: + return MESA_FORMAT_LUMINANCE_ALPHA_UINT16; + case PIPE_FORMAT_L32A32_UINT: + return MESA_FORMAT_LUMINANCE_ALPHA_UINT32; + case PIPE_FORMAT_L8A8_SINT: + return MESA_FORMAT_LUMINANCE_ALPHA_INT8; + case PIPE_FORMAT_L16A16_SINT: + return MESA_FORMAT_LUMINANCE_ALPHA_INT16; + case PIPE_FORMAT_L32A32_SINT: + return MESA_FORMAT_LUMINANCE_ALPHA_INT32; + + case PIPE_FORMAT_R8_SINT: + return MESA_FORMAT_R_INT8; + case PIPE_FORMAT_R8G8_SINT: + return MESA_FORMAT_RG_INT8; + case PIPE_FORMAT_R8G8B8_SINT: + return MESA_FORMAT_RGB_INT8; + case PIPE_FORMAT_R8G8B8A8_SINT: return MESA_FORMAT_RGBA_INT8; - case PIPE_FORMAT_R16G16B16A16_SSCALED: + + case PIPE_FORMAT_R16_SINT: + return MESA_FORMAT_R_INT16; + case PIPE_FORMAT_R16G16_SINT: + return MESA_FORMAT_RG_INT16; + case PIPE_FORMAT_R16G16B16_SINT: + return MESA_FORMAT_RGB_INT16; + case PIPE_FORMAT_R16G16B16A16_SINT: return MESA_FORMAT_RGBA_INT16; - case PIPE_FORMAT_R32G32B32A32_SSCALED: + + case PIPE_FORMAT_R32_SINT: + return MESA_FORMAT_R_INT32; + case PIPE_FORMAT_R32G32_SINT: + return MESA_FORMAT_RG_INT32; + case PIPE_FORMAT_R32G32B32_SINT: + return MESA_FORMAT_RGB_INT32; + case PIPE_FORMAT_R32G32B32A32_SINT: return MESA_FORMAT_RGBA_INT32; /* unsigned int formats */ - case PIPE_FORMAT_R8G8B8A8_USCALED: + case PIPE_FORMAT_R8_UINT: + return MESA_FORMAT_R_UINT8; + case PIPE_FORMAT_R8G8_UINT: + return MESA_FORMAT_RG_UINT8; + case PIPE_FORMAT_R8G8B8_UINT: + return MESA_FORMAT_RGB_UINT8; + case PIPE_FORMAT_R8G8B8A8_UINT: return MESA_FORMAT_RGBA_UINT8; - case PIPE_FORMAT_R16G16B16A16_USCALED: + + case PIPE_FORMAT_R16_UINT: + return MESA_FORMAT_R_UINT16; + case PIPE_FORMAT_R16G16_UINT: + return MESA_FORMAT_RG_UINT16; + case PIPE_FORMAT_R16G16B16_UINT: + return MESA_FORMAT_RGB_UINT16; + case PIPE_FORMAT_R16G16B16A16_UINT: return MESA_FORMAT_RGBA_UINT16; - case PIPE_FORMAT_R32G32B32A32_USCALED: + + case PIPE_FORMAT_R32_UINT: + return MESA_FORMAT_R_UINT32; + case PIPE_FORMAT_R32G32_UINT: + return MESA_FORMAT_RG_UINT32; + case PIPE_FORMAT_R32G32B32_UINT: + return MESA_FORMAT_RGB_UINT32; + case PIPE_FORMAT_R32G32B32A32_UINT: return MESA_FORMAT_RGBA_UINT32; case PIPE_FORMAT_RGTC1_UNORM: @@ -996,79 +1179,215 @@ static const struct format_mapping format_map[] = { }, /* signed/unsigned integer formats. - * XXX Mesa only has formats for RGBA signed/unsigned integer formats. - * If/when new formats are added this code should be updated. */ { { GL_RED_INTEGER_EXT, GL_GREEN_INTEGER_EXT, GL_BLUE_INTEGER_EXT, - GL_ALPHA_INTEGER_EXT, - GL_RGB_INTEGER_EXT, GL_RGBA_INTEGER_EXT, - GL_BGR_INTEGER_EXT, GL_BGRA_INTEGER_EXT, - GL_LUMINANCE_INTEGER_EXT, - GL_LUMINANCE_ALPHA_INTEGER_EXT, - GL_RGBA8I_EXT, - GL_RGB8I_EXT, - GL_ALPHA8I_EXT, - GL_INTENSITY8I_EXT, - GL_LUMINANCE8I_EXT, + GL_RGBA8I_EXT, 0 }, + { PIPE_FORMAT_R8G8B8A8_SINT, 0 } + }, + { + { GL_RGB_INTEGER_EXT, + GL_BGR_INTEGER_EXT, + GL_RGB8I_EXT, 0 }, + { PIPE_FORMAT_R8G8B8_SINT, + PIPE_FORMAT_R8G8B8A8_SINT, 0 } + }, + { + { GL_ALPHA_INTEGER_EXT, + GL_ALPHA8I_EXT, 0 }, + { PIPE_FORMAT_A8_SINT, 0 } + }, + { + { GL_ALPHA16I_EXT, 0 }, + { PIPE_FORMAT_A16_SINT, 0 } + }, + { + { GL_ALPHA32I_EXT, 0 }, + { PIPE_FORMAT_A32_SINT, 0 } + }, + { + { GL_ALPHA8UI_EXT, 0 }, + { PIPE_FORMAT_A8_UINT, 0 } + }, + { + { GL_ALPHA16UI_EXT, 0 }, + { PIPE_FORMAT_A16_UINT, 0 } + }, + { + { GL_ALPHA32UI_EXT, 0 }, + { PIPE_FORMAT_A32_UINT, 0 } + }, + { + { GL_INTENSITY8I_EXT, 0 }, + { PIPE_FORMAT_I8_SINT, 0 } + }, + { + { GL_INTENSITY16I_EXT, 0 }, + { PIPE_FORMAT_I16_SINT, 0 } + }, + { + { GL_INTENSITY32I_EXT, 0 }, + { PIPE_FORMAT_I32_SINT, 0 } + }, + { + { GL_INTENSITY8UI_EXT, 0 }, + { PIPE_FORMAT_I8_UINT, 0 } + }, + { + { GL_INTENSITY16UI_EXT, 0 }, + { PIPE_FORMAT_I16_UINT, 0 } + }, + { + { GL_INTENSITY32UI_EXT, 0 }, + { PIPE_FORMAT_I32_UINT, 0 } + }, + { + { GL_LUMINANCE8I_EXT, 0 }, + { PIPE_FORMAT_L8_SINT, 0 } + }, + { + { GL_LUMINANCE16I_EXT, 0 }, + { PIPE_FORMAT_L16_SINT, 0 } + }, + { + { GL_LUMINANCE32I_EXT, 0 }, + { PIPE_FORMAT_L32_SINT, 0 } + }, + { + { GL_LUMINANCE_INTEGER_EXT, + GL_LUMINANCE8UI_EXT, 0 }, + { PIPE_FORMAT_L8_UINT, 0 } + }, + { + { GL_LUMINANCE16UI_EXT, 0 }, + { PIPE_FORMAT_L16_UINT, 0 } + }, + { + { GL_LUMINANCE32UI_EXT, 0 }, + { PIPE_FORMAT_L32_UINT, 0 } + }, + { + { GL_LUMINANCE_ALPHA_INTEGER_EXT, GL_LUMINANCE_ALPHA8I_EXT, 0 }, - { PIPE_FORMAT_R8G8B8A8_SSCALED, 0 } + { PIPE_FORMAT_L8A8_SINT, 0 } }, { - { - GL_RGBA16I_EXT, - GL_RGB16I_EXT, - GL_ALPHA16I_EXT, - GL_INTENSITY16I_EXT, - GL_LUMINANCE16I_EXT, - GL_LUMINANCE_ALPHA16I_EXT, 0 }, - { PIPE_FORMAT_R16G16B16A16_SSCALED, 0 }, + { GL_LUMINANCE_ALPHA16I_EXT, 0 }, + { PIPE_FORMAT_L16A16_SINT, 0 } }, { - { - GL_RGBA32I_EXT, - GL_RGB32I_EXT, - GL_ALPHA32I_EXT, - GL_INTENSITY32I_EXT, - GL_LUMINANCE32I_EXT, - GL_LUMINANCE_ALPHA32I_EXT, 0 }, - { PIPE_FORMAT_R32G32B32A32_SSCALED, 0 } + { GL_LUMINANCE_ALPHA32I_EXT, 0 }, + { PIPE_FORMAT_L32A32_SINT, 0 } }, { - { - GL_RGBA8UI_EXT, - GL_RGB8UI_EXT, - GL_ALPHA8UI_EXT, - GL_INTENSITY8UI_EXT, - GL_LUMINANCE8UI_EXT, - GL_LUMINANCE_ALPHA8UI_EXT, 0 }, - { PIPE_FORMAT_R8G8B8A8_USCALED, 0 } + { GL_LUMINANCE_ALPHA8UI_EXT, 0 }, + { PIPE_FORMAT_L8A8_UINT, 0 } }, { - { - GL_RGBA16UI_EXT, - GL_RGB16UI_EXT, - GL_ALPHA16UI_EXT, - GL_INTENSITY16UI_EXT, - GL_LUMINANCE16UI_EXT, - GL_LUMINANCE_ALPHA16UI_EXT, 0 }, - { PIPE_FORMAT_R16G16B16A16_USCALED, 0 } + { GL_LUMINANCE_ALPHA16UI_EXT, 0 }, + { PIPE_FORMAT_L16A16_UINT, 0 } }, { - { - GL_RGBA32UI_EXT, - GL_RGB32UI_EXT, - GL_ALPHA32UI_EXT, - GL_INTENSITY32UI_EXT, - GL_LUMINANCE32UI_EXT, - GL_LUMINANCE_ALPHA32UI_EXT, 0 }, - { PIPE_FORMAT_R32G32B32A32_USCALED, 0 } + { GL_LUMINANCE_ALPHA32UI_EXT, 0 }, + { PIPE_FORMAT_L32A32_UINT, 0 } + }, + { + { GL_RGB16I_EXT, 0 }, + { PIPE_FORMAT_R16G16B16_SINT, + PIPE_FORMAT_R16G16B16A16_SINT, 0 }, + }, + { + { GL_RGBA16I_EXT, 0 }, + { PIPE_FORMAT_R16G16B16A16_SINT, 0 }, + }, + { + { GL_RGB32I_EXT, 0 }, + { PIPE_FORMAT_R32G32B32_SINT, + PIPE_FORMAT_R32G32B32A32_SINT, 0 }, + }, + { + { GL_RGBA32I_EXT, 0 }, + { PIPE_FORMAT_R32G32B32A32_SINT, 0 } + }, + { + { GL_RGBA8UI_EXT, 0 }, + { PIPE_FORMAT_R8G8B8A8_UINT, 0 } + }, + { + { GL_RGB8UI_EXT, 0 }, + { PIPE_FORMAT_R8G8B8_UINT, + PIPE_FORMAT_R8G8B8A8_UINT, 0 } + }, + { + { GL_RGB16UI_EXT, 0 }, + { PIPE_FORMAT_R16G16B16_UINT, + PIPE_FORMAT_R16G16B16A16_UINT, 0 } + }, + { + { GL_RGBA16UI_EXT, 0 }, + { PIPE_FORMAT_R16G16B16A16_UINT, 0 } + }, + { + { GL_RGB32UI_EXT, 0}, + { PIPE_FORMAT_R32G32B32_UINT, + PIPE_FORMAT_R32G32B32A32_UINT, 0 } + }, + { + { GL_RGBA32UI_EXT, 0}, + { PIPE_FORMAT_R32G32B32A32_UINT, 0 } + }, + { + { GL_R8I, 0}, + { PIPE_FORMAT_R8_SINT, 0}, + }, + { + { GL_R16I, 0}, + { PIPE_FORMAT_R16_SINT, 0}, + }, + { + { GL_R32I, 0}, + { PIPE_FORMAT_R32_SINT, 0}, + }, + { + { GL_R8UI, 0}, + { PIPE_FORMAT_R8_UINT, 0}, + }, + { + { GL_R16UI, 0}, + { PIPE_FORMAT_R16_UINT, 0}, + }, + { + { GL_R32UI, 0}, + { PIPE_FORMAT_R32_UINT, 0}, + }, + { + { GL_RG8I, 0}, + { PIPE_FORMAT_R8G8_SINT, 0}, + }, + { + { GL_RG16I, 0}, + { PIPE_FORMAT_R16G16_SINT, 0}, + }, + { + { GL_RG32I, 0}, + { PIPE_FORMAT_R32G32_SINT, 0}, + }, + { + { GL_RG8UI, 0}, + { PIPE_FORMAT_R8G8_UINT, 0}, + }, + { + { GL_RG16UI, 0}, + { PIPE_FORMAT_R16G16_UINT, 0}, + }, + { + { GL_RG32UI, 0}, + { PIPE_FORMAT_R32G32_UINT, 0}, }, - /* signed normalized formats */ { { GL_RED_SNORM, GL_R8_SNORM, 0 }, diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index d8ef8a3ce..fe65ae539 100644 --- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -5180,39 +5180,17 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]); if (linked_prog) { - bool ok = true; - - switch (prog->_LinkedShaders[i]->Type) { - case GL_VERTEX_SHADER: - _mesa_reference_vertprog(ctx, &prog->VertexProgram, - (struct gl_vertex_program *)linked_prog); - ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB, - linked_prog); - if (!ok) { - _mesa_reference_vertprog(ctx, &prog->VertexProgram, NULL); - } - break; - case GL_FRAGMENT_SHADER: - _mesa_reference_fragprog(ctx, &prog->FragmentProgram, - (struct gl_fragment_program *)linked_prog); - ok = ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB, - linked_prog); - if (!ok) { - _mesa_reference_fragprog(ctx, &prog->FragmentProgram, NULL); - } - break; - case GL_GEOMETRY_SHADER: - _mesa_reference_geomprog(ctx, &prog->GeometryProgram, - (struct gl_geometry_program *)linked_prog); - ok = ctx->Driver.ProgramStringNotify(ctx, GL_GEOMETRY_PROGRAM_NV, - linked_prog); - if (!ok) { - _mesa_reference_geomprog(ctx, &prog->GeometryProgram, NULL); - } - break; - } - if (!ok) { - _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program, NULL); + static const GLenum targets[] = { + GL_VERTEX_PROGRAM_ARB, + GL_FRAGMENT_PROGRAM_ARB, + GL_GEOMETRY_PROGRAM_NV + }; + + _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program, + linked_prog); + if (!ctx->Driver.ProgramStringNotify(ctx, targets[i], linked_prog)) { + _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program, + NULL); _mesa_reference_program(ctx, &linked_prog, NULL); return GL_FALSE; } diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c index a4f47edfc..acd3b56b9 100644 --- a/mesalib/src/mesa/state_tracker/st_program.c +++ b/mesalib/src/mesa/state_tracker/st_program.c @@ -1153,12 +1153,9 @@ destroy_shader_program_variants_cb(GLuint key, void *data, void *userData) destroy_program_variants(st, shProg->Shaders[i]->Program); } - destroy_program_variants(st, (struct gl_program *) - shProg->VertexProgram); - destroy_program_variants(st, (struct gl_program *) - shProg->FragmentProgram); - destroy_program_variants(st, (struct gl_program *) - shProg->GeometryProgram); + for (i = 0; i < Elements(shProg->_LinkedShaders); i++) { + destroy_program_variants(st, shProg->_LinkedShaders[i]->Program); + } } break; case GL_VERTEX_SHADER: |