diff options
author | Roland Scheidegger <[email protected]> | 2010-04-30 15:27:13 +0200 |
---|---|---|
committer | Roland Scheidegger <[email protected]> | 2010-04-30 15:27:13 +0200 |
commit | 7662e3519bef3802024da3050b886068281e02b1 (patch) | |
tree | bc5bf675e67febffaf9e4d1fadd139e8c253ae32 /src/mesa/state_tracker | |
parent | 9a966b93c03aecac8eb72e6133aa9a2f2c7673f3 (diff) | |
parent | 7c769bef052fc1936d7ab33e291bb4646dc5b0d1 (diff) |
Merge commit 'origin/master' into gallium-msaa
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_cb_texture.c | 5 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_debug.c | 1 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_format.c | 163 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_gen_mipmap.c | 20 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_program.c | 21 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_texture.c | 36 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_texture.h | 12 |
7 files changed, 119 insertions, 139 deletions
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 613fff019d9..3457214ca4c 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -974,7 +974,10 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level, PIPE_TRANSFER_READ, 0, 0, stImage->base.Width, stImage->base.Height); - texImage->RowStride = stImage->transfer->stride / util_format_get_blocksize(stImage->pt->format); + /* compute stride in texels from stride in bytes */ + texImage->RowStride = stImage->transfer->stride + * util_format_get_blockwidth(stImage->pt->format) + / util_format_get_blocksize(stImage->pt->format); } else { /* Otherwise, the image should actually be stored in diff --git a/src/mesa/state_tracker/st_debug.c b/src/mesa/state_tracker/st_debug.c index 175bf9e6f97..2da27fc4bd1 100644 --- a/src/mesa/state_tracker/st_debug.c +++ b/src/mesa/state_tracker/st_debug.c @@ -47,6 +47,7 @@ int ST_DEBUG = 0; static const struct debug_named_value st_debug_flags[] = { { "mesa", DEBUG_MESA }, { "tgsi", DEBUG_TGSI }, + { "constants",DEBUG_CONSTANTS }, { "pipe", DEBUG_PIPE }, { "tex", DEBUG_TEX }, { "fallback", DEBUG_FALLBACK }, diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index c149c5cf0b8..d7d2be6d454 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -389,56 +389,64 @@ default_srgba_format(struct pipe_screen *screen, /** * Given an OpenGL internalFormat value for a texture or surface, return * the best matching PIPE_FORMAT_x, or PIPE_FORMAT_NONE if there's no match. + * This is called during glTexImage2D, for example. + * + * The bindings parameter typically has PIPE_BIND_SAMPLER_VIEW set, plus + * either PIPE_BINDING_RENDER_TARGET or PIPE_BINDING_DEPTH_STENCIL if + * we want render-to-texture ability. + * + * \param internalFormat the user value passed to glTexImage2D * \param target one of PIPE_TEXTURE_x - * \param tex_usage either PIPE_BIND_RENDER_TARGET - * or PIPE_BIND_SAMPLER_VIEW + * \param bindings bitmask of PIPE_BIND_x flags. */ enum pipe_format st_choose_format(struct pipe_screen *screen, GLenum internalFormat, - enum pipe_texture_target target, unsigned tex_usage) + enum pipe_texture_target target, unsigned bindings) { - unsigned geom_flags = 0; + unsigned geom_flags = 0; /* we don't care about POT vs. NPOT here, yet */ switch (internalFormat) { case 4: case GL_RGBA: - case GL_COMPRESSED_RGBA: case GL_RGBA8: case GL_RGB10_A2: case GL_RGBA12: - return default_rgba_format( screen, target, tex_usage, geom_flags ); + return default_rgba_format( screen, target, bindings, geom_flags ); case 3: case GL_RGB: - case GL_COMPRESSED_RGB: - return default_rgb_format( screen, target, tex_usage, geom_flags ); + return default_rgb_format( screen, target, bindings, geom_flags ); case GL_RGBA16: - return default_rgba_format( screen, target, tex_usage, geom_flags ); + return default_rgba_format( screen, target, bindings, geom_flags ); case GL_RGBA4: case GL_RGBA2: - if (screen->is_format_supported( screen, PIPE_FORMAT_B4G4R4A4_UNORM, target, tex_usage, geom_flags )) + if (screen->is_format_supported( screen, PIPE_FORMAT_B4G4R4A4_UNORM, + target, bindings, geom_flags )) return PIPE_FORMAT_B4G4R4A4_UNORM; - return default_rgba_format( screen, target, tex_usage, geom_flags ); + return default_rgba_format( screen, target, bindings, geom_flags ); case GL_RGB5_A1: - if (screen->is_format_supported( screen, PIPE_FORMAT_B5G5R5A1_UNORM, target, tex_usage, geom_flags )) + if (screen->is_format_supported( screen, PIPE_FORMAT_B5G5R5A1_UNORM, + target, bindings, geom_flags )) return PIPE_FORMAT_B5G5R5A1_UNORM; - return default_rgba_format( screen, target, tex_usage, geom_flags ); + return default_rgba_format( screen, target, bindings, geom_flags ); case GL_RGB8: case GL_RGB10: case GL_RGB12: case GL_RGB16: - return default_rgb_format( screen, target, tex_usage, geom_flags ); + return default_rgb_format( screen, target, bindings, geom_flags ); case GL_RGB5: case GL_RGB4: case GL_R3_G3_B2: - if (screen->is_format_supported( screen, PIPE_FORMAT_B5G6R5_UNORM, target, tex_usage, geom_flags )) + if (screen->is_format_supported( screen, PIPE_FORMAT_B5G6R5_UNORM, + target, bindings, geom_flags )) return PIPE_FORMAT_B5G6R5_UNORM; - if (screen->is_format_supported( screen, PIPE_FORMAT_B5G5R5A1_UNORM, target, tex_usage, geom_flags )) + if (screen->is_format_supported( screen, PIPE_FORMAT_B5G5R5A1_UNORM, + target, bindings, geom_flags )) return PIPE_FORMAT_B5G5R5A1_UNORM; - return default_rgba_format( screen, target, tex_usage, geom_flags ); + return default_rgba_format( screen, target, bindings, geom_flags ); case GL_ALPHA: case GL_ALPHA4: @@ -446,9 +454,10 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_ALPHA12: case GL_ALPHA16: case GL_COMPRESSED_ALPHA: - if (screen->is_format_supported( screen, PIPE_FORMAT_A8_UNORM, target, tex_usage, geom_flags )) + if (screen->is_format_supported( screen, PIPE_FORMAT_A8_UNORM, target, + bindings, geom_flags )) return PIPE_FORMAT_A8_UNORM; - return default_rgba_format( screen, target, tex_usage, geom_flags ); + return default_rgba_format( screen, target, bindings, geom_flags ); case 1: case GL_LUMINANCE: @@ -457,9 +466,10 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_LUMINANCE12: case GL_LUMINANCE16: case GL_COMPRESSED_LUMINANCE: - if (screen->is_format_supported( screen, PIPE_FORMAT_L8_UNORM, target, tex_usage, geom_flags )) + if (screen->is_format_supported( screen, PIPE_FORMAT_L8_UNORM, target, + bindings, geom_flags )) return PIPE_FORMAT_L8_UNORM; - return default_rgba_format( screen, target, tex_usage, geom_flags ); + return default_rgba_format( screen, target, bindings, geom_flags ); case 2: case GL_LUMINANCE_ALPHA: @@ -470,9 +480,10 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_LUMINANCE12_ALPHA12: case GL_LUMINANCE16_ALPHA16: case GL_COMPRESSED_LUMINANCE_ALPHA: - if (screen->is_format_supported( screen, PIPE_FORMAT_L8A8_UNORM, target, tex_usage, geom_flags )) + if (screen->is_format_supported( screen, PIPE_FORMAT_L8A8_UNORM, target, + bindings, geom_flags )) return PIPE_FORMAT_L8A8_UNORM; - return default_rgba_format( screen, target, tex_usage, geom_flags ); + return default_rgba_format( screen, target, bindings, geom_flags ); case GL_INTENSITY: case GL_INTENSITY4: @@ -480,36 +491,73 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_INTENSITY12: case GL_INTENSITY16: case GL_COMPRESSED_INTENSITY: - if (screen->is_format_supported( screen, PIPE_FORMAT_I8_UNORM, target, tex_usage, geom_flags )) + if (screen->is_format_supported( screen, PIPE_FORMAT_I8_UNORM, target, + bindings, geom_flags )) return PIPE_FORMAT_I8_UNORM; - return default_rgba_format( screen, target, tex_usage, geom_flags ); + return default_rgba_format( screen, target, bindings, geom_flags ); case GL_YCBCR_MESA: if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY, - target, tex_usage, geom_flags)) { + target, bindings, geom_flags)) { return PIPE_FORMAT_UYVY; } if (screen->is_format_supported(screen, PIPE_FORMAT_YUYV, - target, tex_usage, geom_flags)) { + target, bindings, geom_flags)) { return PIPE_FORMAT_YUYV; } return PIPE_FORMAT_NONE; + case GL_COMPRESSED_RGB: + /* can only sample from compressed formats */ + if (bindings & ~PIPE_BIND_SAMPLER_VIEW) + return PIPE_FORMAT_NONE; + else if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGB, + target, bindings, geom_flags)) + return PIPE_FORMAT_DXT1_RGB; + else + return default_rgb_format(screen, target, bindings, geom_flags); + + case GL_COMPRESSED_RGBA: + /* can only sample from compressed formats */ + if (bindings & ~PIPE_BIND_SAMPLER_VIEW) + return PIPE_FORMAT_NONE; + else if (screen->is_format_supported(screen, PIPE_FORMAT_DXT3_RGBA, + target, bindings, geom_flags)) + return PIPE_FORMAT_DXT3_RGBA; + else + return default_rgba_format(screen, target, bindings, geom_flags); + case GL_RGB_S3TC: case GL_RGB4_S3TC: case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: - return PIPE_FORMAT_DXT1_RGB; + if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGB, + target, bindings, geom_flags)) + return PIPE_FORMAT_DXT1_RGB; + else + return PIPE_FORMAT_NONE; case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: - return PIPE_FORMAT_DXT1_RGBA; + if (screen->is_format_supported(screen, PIPE_FORMAT_DXT1_RGBA, + target, bindings, geom_flags)) + return PIPE_FORMAT_DXT1_RGBA; + else + return PIPE_FORMAT_NONE; case GL_RGBA_S3TC: case GL_RGBA4_S3TC: case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: - return PIPE_FORMAT_DXT3_RGBA; + if (screen->is_format_supported(screen, PIPE_FORMAT_DXT3_RGBA, + target, bindings, geom_flags)) + return PIPE_FORMAT_DXT3_RGBA; + else + return PIPE_FORMAT_NONE; case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: - return PIPE_FORMAT_DXT5_RGBA; + if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA, + target, bindings, geom_flags)) + return PIPE_FORMAT_DXT5_RGBA; + else + return PIPE_FORMAT_NONE; #if 0 case GL_COMPRESSED_RGB_FXT1_3DFX: @@ -519,17 +567,21 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, #endif case GL_DEPTH_COMPONENT16: - if (screen->is_format_supported( screen, PIPE_FORMAT_Z16_UNORM, target, tex_usage, geom_flags )) + if (screen->is_format_supported(screen, PIPE_FORMAT_Z16_UNORM, target, + bindings, geom_flags)) return PIPE_FORMAT_Z16_UNORM; /* fall-through */ case GL_DEPTH_COMPONENT24: - if (screen->is_format_supported( screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, target, tex_usage, geom_flags )) + if (screen->is_format_supported(screen, PIPE_FORMAT_Z24_UNORM_S8_USCALED, + target, bindings, geom_flags)) return PIPE_FORMAT_Z24_UNORM_S8_USCALED; - if (screen->is_format_supported( screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, target, tex_usage, geom_flags )) + if (screen->is_format_supported(screen, PIPE_FORMAT_S8_USCALED_Z24_UNORM, + target, bindings, geom_flags)) return PIPE_FORMAT_S8_USCALED_Z24_UNORM; /* fall-through */ case GL_DEPTH_COMPONENT32: - if (screen->is_format_supported( screen, PIPE_FORMAT_Z32_UNORM, target, tex_usage, geom_flags )) + if (screen->is_format_supported(screen, PIPE_FORMAT_Z32_UNORM, + target, bindings, geom_flags)) return PIPE_FORMAT_Z32_UNORM; /* fall-through */ case GL_DEPTH_COMPONENT: @@ -541,7 +593,7 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, PIPE_FORMAT_S8_USCALED_Z24_UNORM }; return find_supported_format(screen, formats, Elements(formats), - target, tex_usage, geom_flags); + target, bindings, geom_flags); } case GL_STENCIL_INDEX: @@ -556,7 +608,7 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, PIPE_FORMAT_S8_USCALED_Z24_UNORM }; return find_supported_format(screen, formats, Elements(formats), - target, tex_usage, geom_flags); + target, bindings, geom_flags); } case GL_DEPTH_STENCIL_EXT: @@ -567,7 +619,7 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, PIPE_FORMAT_S8_USCALED_Z24_UNORM }; return find_supported_format(screen, formats, Elements(formats), - target, tex_usage, geom_flags); + target, bindings, geom_flags); } case GL_SRGB_EXT: @@ -576,7 +628,7 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_COMPRESSED_SRGB_ALPHA_EXT: case GL_SRGB_ALPHA_EXT: case GL_SRGB8_ALPHA8_EXT: - return default_srgba_format( screen, target, tex_usage, geom_flags ); + return default_srgba_format( screen, target, bindings, geom_flags ); case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT: return PIPE_FORMAT_DXT1_SRGB; case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT: @@ -590,15 +642,17 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_SLUMINANCE8_ALPHA8_EXT: case GL_COMPRESSED_SLUMINANCE_EXT: case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: - if (screen->is_format_supported( screen, PIPE_FORMAT_L8A8_SRGB, target, tex_usage, geom_flags )) + if (screen->is_format_supported(screen, PIPE_FORMAT_L8A8_SRGB, + target, bindings, geom_flags)) return PIPE_FORMAT_L8A8_SRGB; - return default_srgba_format( screen, target, tex_usage, geom_flags ); + return default_srgba_format( screen, target, bindings, geom_flags ); case GL_SLUMINANCE_EXT: case GL_SLUMINANCE8_EXT: - if (screen->is_format_supported( screen, PIPE_FORMAT_L8_SRGB, target, tex_usage, geom_flags )) + if (screen->is_format_supported(screen, PIPE_FORMAT_L8_SRGB, + target, bindings, geom_flags)) return PIPE_FORMAT_L8_SRGB; - return default_srgba_format( screen, target, tex_usage, geom_flags ); + return default_srgba_format( screen, target, bindings, geom_flags ); default: return PIPE_FORMAT_NONE; @@ -606,27 +660,6 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, } -static GLboolean -is_depth_or_stencil_format(GLenum internalFormat) -{ - switch (internalFormat) { - case GL_DEPTH_COMPONENT: - case GL_DEPTH_COMPONENT16: - case GL_DEPTH_COMPONENT24: - case GL_DEPTH_COMPONENT32: - case GL_STENCIL_INDEX: - case GL_STENCIL_INDEX1_EXT: - case GL_STENCIL_INDEX4_EXT: - case GL_STENCIL_INDEX8_EXT: - case GL_STENCIL_INDEX16_EXT: - case GL_DEPTH_STENCIL_EXT: - case GL_DEPTH24_STENCIL8_EXT: - return GL_TRUE; - default: - return GL_FALSE; - } -} - /** * Called by FBO code to choose a PIPE_FORMAT_ for drawing surfaces. */ @@ -635,7 +668,7 @@ st_choose_renderbuffer_format(struct pipe_screen *screen, GLenum internalFormat) { uint usage; - if (is_depth_or_stencil_format(internalFormat)) + if (_mesa_is_depth_or_stencil_format(internalFormat)) usage = PIPE_BIND_DEPTH_STENCIL; else usage = PIPE_BIND_RENDER_TARGET; diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index d6b024d8b8c..b8b75c7de62 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -104,14 +104,8 @@ decompress_image(enum pipe_format format, unsigned width, unsigned height) { const struct util_format_description *desc = util_format_description(format); - const uint bw = util_format_get_blockwidth(format); - const uint src_stride = align(width, bw) / util_format_get_blocksize(format); const uint dst_stride = 4 * width; - - /* - printf("decompress %s %d x %d %d -> %d\n", - util_format_name(format), width, height, src_stride, dst_stride); - */ + const uint src_stride = util_format_get_stride(format, width); desc->unpack_rgba_8unorm(dst, dst_stride, src, src_stride, width, height); } @@ -127,14 +121,8 @@ compress_image(enum pipe_format format, unsigned width, unsigned height) { const struct util_format_description *desc = util_format_description(format); - const uint bw = util_format_get_blockwidth(format); + const uint dst_stride = util_format_get_stride(format, width); const uint src_stride = 4 * width; - const uint dst_stride = align(width, bw) / util_format_get_blocksize(format); - - /* - printf("compress %s %d x %d %d -> %d\n", - util_format_name(format), width, height, src_stride, dst_stride); - */ desc->pack_rgba_8unorm(dst, dst_stride, src, src_stride, width, height); } @@ -389,7 +377,9 @@ st_generate_mipmap(GLcontext *ctx, GLenum target, dstImage->TexFormat = srcImage->TexFormat; - stImage = (struct st_texture_image *) dstImage; + stImage = st_texture_image(dstImage); + stImage->level = dstLevel; + pipe_resource_reference(&stImage->pt, pt); } } diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 6e8c446f783..772a2ee17c9 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -217,6 +217,12 @@ st_translate_vertex_program(struct st_context *st, num_outputs++; } + if (ST_DEBUG & DEBUG_MESA) { + _mesa_print_program(&stvp->Base.Base); + _mesa_print_program_parameters(st->ctx, &stvp->Base.Base); + debug_printf("\n"); + } + error = st_translate_mesa_program(st->ctx, TGSI_PROCESSOR_VERTEX, @@ -246,11 +252,6 @@ st_translate_vertex_program(struct st_context *st, vpv->driver_shader = pipe->create_vs_state(pipe, &vpv->tgsi); - if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) { - _mesa_print_program(&stvp->Base.Base); - debug_printf("\n"); - } - if (ST_DEBUG & DEBUG_TGSI) { tgsi_dump( vpv->tgsi.tokens, 0 ); debug_printf("\n"); @@ -423,6 +424,11 @@ st_translate_fragment_program(struct st_context *st, if (ureg == NULL) return; + if (ST_DEBUG & DEBUG_MESA) { + _mesa_print_program(&stfp->Base.Base); + _mesa_print_program_parameters(st->ctx, &stfp->Base.Base); + debug_printf("\n"); + } error = st_translate_mesa_program(st->ctx, @@ -445,11 +451,6 @@ st_translate_fragment_program(struct st_context *st, ureg_destroy( ureg ); stfp->driver_shader = pipe->create_fs_state(pipe, &stfp->tgsi); - if ((ST_DEBUG & DEBUG_TGSI) && (ST_DEBUG & DEBUG_MESA)) { - _mesa_print_program(&stfp->Base.Base); - debug_printf("\n"); - } - if (ST_DEBUG & DEBUG_TGSI) { tgsi_dump( stfp->tgsi.tokens, 0/*TGSI_DUMP_VERBOSE*/ ); debug_printf("\n"); diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index 70ba239d07b..1b52e77b7d9 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -142,42 +142,6 @@ st_texture_match_image(const struct pipe_resource *pt, } -#if 000 -/* Although we use the image_offset[] array to store relative offsets - * to cube faces, Mesa doesn't know anything about this and expects - * each cube face to be treated as a separate image. - * - * These functions present that view to mesa: - */ -const GLuint * -st_texture_depth_offsets(struct pipe_resource *pt, GLuint level) -{ - static const GLuint zero = 0; - - if (pt->target != PIPE_TEXTURE_3D || pt->level[level].nr_images == 1) - return &zero; - else - return pt->level[level].image_offset; -} - - -/** - * Return the offset to the given mipmap texture image within the - * texture memory buffer, in bytes. - */ -GLuint -st_texture_image_offset(const struct pipe_resource * pt, - GLuint face, GLuint level) -{ - if (pt->target == PIPE_TEXTURE_CUBE) - return (pt->level[level].level_offset + - pt->level[level].image_offset[face] * pt->cpp); - else - return pt->level[level].level_offset; -} -#endif - - /** * Map a teximage in a mipmap texture. * \param row_stride returns row stride in bytes diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h index 416468478b1..d0298817ded 100644 --- a/src/mesa/state_tracker/st_texture.h +++ b/src/mesa/state_tracker/st_texture.h @@ -185,18 +185,6 @@ extern const GLuint * st_texture_depth_offsets(struct pipe_resource *pt, GLuint level); -/* Return the linear offset of an image relative to the start of its region. - */ -extern GLuint -st_texture_image_offset(const struct pipe_resource *pt, - GLuint face, GLuint level); - -extern GLuint -st_texture_texel_offset(const struct pipe_resource * pt, - GLuint face, GLuint level, - GLuint col, GLuint row, GLuint img); - - /* Upload an image into a texture */ extern void |