diff options
author | Dave Airlie <[email protected]> | 2010-08-11 19:04:05 +1000 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2010-10-02 17:03:15 +1000 |
commit | 71a079fb4ecbd17703ac9b5e6d5ef622fd7bc50f (patch) | |
tree | e25cc06ea21a61404882d3fad27f5c6e3199d614 /src/mesa/state_tracker | |
parent | f31771343259d195ba243ce8d307831e495d5a2c (diff) |
mesa/st: initial attempt at RG support for gallium drivers
passes all piglit RG tests with softpipe.
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_atom_texture.c | 10 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_fbo.c | 12 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_extensions.c | 6 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_format.c | 66 |
4 files changed, 93 insertions, 1 deletions
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c index 981129621c7..029b0403462 100644 --- a/src/mesa/state_tracker/st_atom_texture.c +++ b/src/mesa/state_tracker/st_atom_texture.c @@ -52,7 +52,7 @@ * * \param format PIPE_FORMAT_*. * \param swizzle Texture swizzle, a bitmask computed using MAKE_SWIZZLE4. - * \param depthmode One of GL_LUMINANCE, GL_INTENSITY, GL_ALPHA. + * \param depthmode One of GL_LUMINANCE, GL_INTENSITY, GL_ALPHA, GL_RED. */ static GLuint apply_depthmode(enum pipe_format format, GLuint swizzle, GLenum depthmode) @@ -96,6 +96,14 @@ static GLuint apply_depthmode(enum pipe_format format, else if (swiz[i] < SWIZZLE_W) swiz[i] = SWIZZLE_ZERO; break; + case GL_RED: + /* Rewrite reads W to 1, XYZ to X00 */ + for (i = 0; i < 4; i++) + if (swiz[i] == SWIZZLE_W) + swiz[i] = SWIZZLE_ONE; + else if (swiz[i] == SWIZZLE_Y || swiz[i] == SWIZZLE_Z) + swiz[i] = SWIZZLE_ZERO; + break; } return MAKE_SWIZZLE4(swiz[0], swiz[1], swiz[2], swiz[3]); diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 71bd4729e03..ac1f6812b85 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -260,6 +260,18 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw) case PIPE_FORMAT_R16G16B16A16_SNORM: strb->Base.InternalFormat = GL_RGBA16; break; + case PIPE_FORMAT_R8_UNORM: + strb->Base.InternalFormat = GL_R8; + break; + case PIPE_FORMAT_R8G8_UNORM: + strb->Base.InternalFormat = GL_RG8; + break; + case PIPE_FORMAT_R16_UNORM: + strb->Base.InternalFormat = GL_R16; + break; + case PIPE_FORMAT_R16G16_UNORM: + strb->Base.InternalFormat = GL_RG16; + break; default: _mesa_problem(NULL, "Unexpected format in st_new_renderbuffer_fb"); diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 225f75e3af0..9b09601bbc5 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -373,6 +373,12 @@ void st_init_extensions(struct st_context *st) ctx->Extensions.EXT_texture_sRGB = GL_TRUE; } + if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8_UNORM, + PIPE_TEXTURE_2D, 0, + PIPE_BIND_SAMPLER_VIEW, 0)) { + ctx->Extensions.ARB_texture_rg = GL_TRUE; + } + /* s3tc support */ if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA, PIPE_TEXTURE_2D, 0, diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 95064605d7f..b7c54cef841 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -202,6 +202,14 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) case MESA_FORMAT_SARGB8: return PIPE_FORMAT_B8G8R8A8_SRGB; #endif + case MESA_FORMAT_R8: + return PIPE_FORMAT_R8_UNORM; + case MESA_FORMAT_R16: + return PIPE_FORMAT_R16_UNORM; + case MESA_FORMAT_RG88: + return PIPE_FORMAT_R8G8_UNORM; + case MESA_FORMAT_RG1616: + return PIPE_FORMAT_R16G16_UNORM; default: assert(0); return PIPE_FORMAT_NONE; @@ -299,6 +307,15 @@ st_pipe_format_to_mesa_format(enum pipe_format format) case PIPE_FORMAT_B8G8R8A8_SRGB: return MESA_FORMAT_SARGB8; #endif + + case PIPE_FORMAT_R8_UNORM: + return MESA_FORMAT_R8; + case PIPE_FORMAT_R16_UNORM: + return MESA_FORMAT_R16; + case PIPE_FORMAT_R8G8_UNORM: + return MESA_FORMAT_RG88; + case PIPE_FORMAT_R16G16_UNORM: + return MESA_FORMAT_RG1616; default: assert(0); return MESA_FORMAT_NONE; @@ -688,6 +705,55 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, return default_srgba_format( screen, target, sample_count, bindings, geom_flags ); + case GL_RED: + case GL_R8: + if (screen->is_format_supported(screen, PIPE_FORMAT_R8_UNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_R8_UNORM; + return PIPE_FORMAT_NONE; + case GL_RG: + case GL_RG8: + if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8_UNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_R8G8_UNORM; + return PIPE_FORMAT_NONE; + + case GL_R16: + if (screen->is_format_supported(screen, PIPE_FORMAT_R16_UNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_R16_UNORM; + return PIPE_FORMAT_NONE; + + case GL_RG16: + if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16_UNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_R16G16_UNORM; + return PIPE_FORMAT_NONE; + + case GL_COMPRESSED_RED_RGTC1: + if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC1_UNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_RGTC1_UNORM; + return PIPE_FORMAT_NONE; + + case GL_COMPRESSED_SIGNED_RED_RGTC1: + if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC1_SNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_RGTC1_SNORM; + return PIPE_FORMAT_NONE; + + case GL_COMPRESSED_RG_RGTC2: + if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC2_UNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_RGTC2_UNORM; + return PIPE_FORMAT_NONE; + + case GL_COMPRESSED_SIGNED_RG_RGTC2: + if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC2_SNORM, target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_RGTC2_SNORM; + return PIPE_FORMAT_NONE; + default: return PIPE_FORMAT_NONE; } |