summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-10-28 21:24:11 -0600
committerBrian Paul <brianp@vmware.com>2009-10-28 21:24:11 -0600
commit1f196b786d6bd0c6a5dbdc638574ff716cc3d4de (patch)
tree5ae2753b99070f8b35c51576bd39e52df63879d6 /src/mesa/state_tracker
parent0ea575d721821262a862ceef010db9b1a8b4a6d9 (diff)
parent086f9fc0e2aef27f54eda87c733685500555bf20 (diff)
Merge branch 'texformat-rework'
Conflicts: src/mesa/drivers/dri/radeon/radeon_fbo.c src/mesa/drivers/dri/s3v/s3v_tex.c src/mesa/drivers/dri/s3v/s3v_xmesa.c src/mesa/drivers/dri/trident/trident_context.c src/mesa/main/debug.c src/mesa/main/mipmap.c src/mesa/main/texformat.c src/mesa/main/texgetimage.c
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_atom_sampler.c2
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c13
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c28
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c14
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c131
-rw-r--r--src/mesa/state_tracker/st_format.c165
-rw-r--r--src/mesa/state_tracker/st_format.h10
-rw-r--r--src/mesa/state_tracker/st_texture.c5
8 files changed, 215 insertions, 153 deletions
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index 50ce82811c..6611956ae8 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -209,7 +209,7 @@ update_samplers(struct st_context *st)
}
xlate_border_color(texobj->BorderColor,
- teximg ? teximg->TexFormat->BaseFormat : GL_RGBA,
+ teximg ? teximg->_BaseFormat : GL_RGBA,
sampler->border_color);
sampler->max_anisotropy = texobj->MaxAnisotropy;
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 36510720a4..e83b6c92ef 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -34,6 +34,7 @@
*/
#include "main/glheader.h"
+#include "main/formats.h"
#include "main/macros.h"
#include "shader/prog_instruction.h"
#include "st_context.h"
@@ -311,10 +312,14 @@ check_clear_color_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
static INLINE GLboolean
check_clear_depth_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
{
- const GLuint stencilMax = (1 << rb->StencilBits) - 1;
+ const GLuint stencilMax = 0xff;
GLboolean maskStencil
= (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax;
+ assert(rb->Format == MESA_FORMAT_S8 ||
+ rb->Format == MESA_FORMAT_Z24_S8 ||
+ rb->Format == MESA_FORMAT_S8_Z24);
+
if (ctx->Scissor.Enabled &&
(ctx->Scissor.X != 0 ||
ctx->Scissor.Y != 0 ||
@@ -361,10 +366,14 @@ check_clear_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
{
const struct st_renderbuffer *strb = st_renderbuffer(rb);
const GLboolean isDS = pf_is_depth_and_stencil(strb->surface->format);
- const GLuint stencilMax = (1 << rb->StencilBits) - 1;
+ const GLuint stencilMax = 0xff;
const GLboolean maskStencil
= (ctx->Stencil.WriteMask[0] & stencilMax) != stencilMax;
+ assert(rb->Format == MESA_FORMAT_S8 ||
+ rb->Format == MESA_FORMAT_Z24_S8 ||
+ rb->Format == MESA_FORMAT_S8_Z24);
+
if (maskStencil)
return TRUE;
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index be44577117..0a6bfcd3d1 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -35,6 +35,7 @@
#include "main/bufferobj.h"
#include "main/macros.h"
#include "main/texformat.h"
+#include "main/texstore.h"
#include "main/state.h"
#include "shader/program.h"
#include "shader/prog_parameter.h"
@@ -339,7 +340,7 @@ make_texture(struct st_context *st,
GLcontext *ctx = st->ctx;
struct pipe_context *pipe = st->pipe;
struct pipe_screen *screen = pipe->screen;
- const struct gl_texture_format *mformat;
+ gl_format mformat;
struct pipe_texture *pt;
enum pipe_format pipeFormat;
GLuint cpp;
@@ -351,7 +352,7 @@ make_texture(struct st_context *st,
mformat = st_ChooseTextureFormat(ctx, baseFormat, format, type);
assert(mformat);
- pipeFormat = st_mesa_format_to_pipe_format(mformat->MesaFormat);
+ pipeFormat = st_mesa_format_to_pipe_format(mformat);
assert(pipeFormat);
cpp = st_sizeof_format(pipeFormat);
@@ -404,21 +405,22 @@ make_texture(struct st_context *st,
/* map texture transfer */
dest = screen->transfer_map(screen, transfer);
+
/* Put image into texture transfer.
* Note that the image is actually going to be upside down in
* the texture. We deal with that with texcoords.
*/
- success = mformat->StoreImage(ctx, 2, /* dims */
- baseFormat, /* baseInternalFormat */
- mformat, /* gl_texture_format */
- dest, /* dest */
- 0, 0, 0, /* dstX/Y/Zoffset */
- transfer->stride, /* dstRowStride, bytes */
- &dstImageOffsets, /* dstImageOffsets */
- width, height, 1, /* size */
- format, type, /* src format/type */
- pixels, /* data source */
- unpack);
+ success = _mesa_texstore(ctx, 2, /* dims */
+ baseFormat, /* baseInternalFormat */
+ mformat, /* gl_format */
+ dest, /* dest */
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ transfer->stride, /* dstRowStride, bytes */
+ &dstImageOffsets, /* dstImageOffsets */
+ width, height, 1, /* size */
+ format, type, /* src format/type */
+ pixels, /* data source */
+ unpack);
/* unmap */
screen->transfer_unmap(screen, transfer);
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index 73aa65955b..65ce12ccd4 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -65,13 +65,7 @@ init_renderbuffer_bits(struct st_renderbuffer *strb,
assert( 0 );
}
- strb->Base._ActualFormat = info.base_format;
- strb->Base.RedBits = info.red_bits;
- strb->Base.GreenBits = info.green_bits;
- strb->Base.BlueBits = info.blue_bits;
- strb->Base.AlphaBits = info.alpha_bits;
- strb->Base.DepthBits = info.depth_bits;
- strb->Base.StencilBits = info.stencil_bits;
+ strb->Base.Format = info.mesa_format;
strb->Base.DataType = st_format_datatype(pipeFormat);
return info.size;
@@ -271,30 +265,24 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw)
case PIPE_FORMAT_A4R4G4B4_UNORM:
case PIPE_FORMAT_R5G6B5_UNORM:
strb->Base.InternalFormat = GL_RGBA;
- strb->Base._BaseFormat = GL_RGBA;
break;
case PIPE_FORMAT_Z16_UNORM:
strb->Base.InternalFormat = GL_DEPTH_COMPONENT16;
- strb->Base._BaseFormat = GL_DEPTH_COMPONENT;
break;
case PIPE_FORMAT_Z32_UNORM:
strb->Base.InternalFormat = GL_DEPTH_COMPONENT32;
- strb->Base._BaseFormat = GL_DEPTH_COMPONENT;
break;
case PIPE_FORMAT_S8Z24_UNORM:
case PIPE_FORMAT_Z24S8_UNORM:
case PIPE_FORMAT_X8Z24_UNORM:
case PIPE_FORMAT_Z24X8_UNORM:
strb->Base.InternalFormat = GL_DEPTH24_STENCIL8_EXT;
- strb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT;
break;
case PIPE_FORMAT_S8_UNORM:
strb->Base.InternalFormat = GL_STENCIL_INDEX8_EXT;
- strb->Base._BaseFormat = GL_STENCIL_INDEX;
break;
case PIPE_FORMAT_R16G16B16A16_SNORM:
strb->Base.InternalFormat = GL_RGBA16;
- strb->Base._BaseFormat = GL_RGBA;
break;
default:
_mesa_problem(NULL,
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index a1953342b4..878a40fae9 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -31,12 +31,14 @@
#include "main/convolve.h"
#endif
#include "main/enums.h"
+#include "main/formats.h"
#include "main/image.h"
#include "main/imports.h"
#include "main/macros.h"
#include "main/mipmap.h"
#include "main/pixel.h"
#include "main/texcompress.h"
+#include "main/texfetch.h"
#include "main/texformat.h"
#include "main/texgetimage.h"
#include "main/teximage.h"
@@ -96,9 +98,9 @@ gl_target_to_pipe(GLenum target)
* format.
*/
static GLuint
-compressed_num_bytes(GLuint mesaFormat)
+compressed_num_bytes(gl_format format)
{
- switch(mesaFormat) {
+ switch (format) {
#if FEATURE_texture_fxt1
case MESA_FORMAT_RGB_FXT1:
case MESA_FORMAT_RGBA_FXT1:
@@ -118,9 +120,9 @@ compressed_num_bytes(GLuint mesaFormat)
static GLboolean
-is_compressed_mesa_format(const struct gl_texture_format *format)
+is_compressed_mesa_format(gl_format format)
{
- switch (format->MesaFormat) {
+ switch (format) {
case MESA_FORMAT_RGB_DXT1:
case MESA_FORMAT_RGBA_DXT1:
case MESA_FORMAT_RGBA_DXT3:
@@ -342,7 +344,7 @@ guess_and_alloc_texture(struct st_context *st,
lastLevel = firstLevel + MAX2(MAX2(l2width, l2height), l2depth);
}
- fmt = st_mesa_format_to_pipe_format(stImage->base.TexFormat->MesaFormat);
+ fmt = st_mesa_format_to_pipe_format(stImage->base.TexFormat);
usage = default_usage(fmt);
@@ -415,14 +417,13 @@ compress_with_blit(GLcontext * ctx,
const GLuint dstImageOffsets[1] = {0};
struct st_texture_image *stImage = st_texture_image(texImage);
struct pipe_screen *screen = ctx->st->pipe->screen;
- const struct gl_texture_format *mesa_format;
+ gl_format mesa_format;
struct pipe_texture templ;
struct pipe_texture *src_tex;
struct pipe_surface *dst_surface;
struct pipe_transfer *tex_xfer;
void *map;
-
if (!stImage->pt) {
/* XXX: Can this happen? Should we assert? */
return GL_FALSE;
@@ -448,7 +449,7 @@ compress_with_blit(GLcontext * ctx,
*/
memset(&templ, 0, sizeof(templ));
templ.target = PIPE_TEXTURE_2D;
- templ.format = st_mesa_format_to_pipe_format(mesa_format->MesaFormat);
+ templ.format = st_mesa_format_to_pipe_format(mesa_format);
pf_get_block(templ.format, &templ.block);
templ.width[0] = width;
templ.height[0] = height;
@@ -468,15 +469,15 @@ compress_with_blit(GLcontext * ctx,
0, 0, width, height); /* x, y, w, h */
map = screen->transfer_map(screen, tex_xfer);
- mesa_format->StoreImage(ctx, 2, GL_RGBA, mesa_format,
- map, /* dest ptr */
- 0, 0, 0, /* dest x/y/z offset */
- tex_xfer->stride, /* dest row stride (bytes) */
- dstImageOffsets, /* image offsets (for 3D only) */
- width, height, 1, /* size */
- format, type, /* source format/type */
- pixels, /* source data */
- unpack); /* source data packing */
+ _mesa_texstore(ctx, 2, GL_RGBA, mesa_format,
+ map, /* dest ptr */
+ 0, 0, 0, /* dest x/y/z offset */
+ tex_xfer->stride, /* dest row stride (bytes) */
+ dstImageOffsets, /* image offsets (for 3D only) */
+ width, height, 1, /* size */
+ format, type, /* source format/type */
+ pixels, /* source data */
+ unpack); /* source data packing */
screen->transfer_unmap(screen, tex_xfer);
screen->tex_transfer_destroy(tex_xfer);
@@ -558,23 +559,14 @@ st_TexImage(GLcontext * ctx,
}
#endif
- /* choose the texture format */
- texImage->TexFormat = st_ChooseTextureFormat(ctx, internalFormat,
- format, type);
-
_mesa_set_fetch_functions(texImage, dims);
- if (texImage->TexFormat->TexelBytes == 0) {
+ if (_mesa_is_format_compressed(texImage->TexFormat)) {
/* must be a compressed format */
texelBytes = 0;
- texImage->IsCompressed = GL_TRUE;
- texImage->CompressedSize =
- ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
- texImage->Height, texImage->Depth,
- texImage->TexFormat->MesaFormat);
}
else {
- texelBytes = texImage->TexFormat->TexelBytes;
+ texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
/* Minimum pitch of 32 bytes */
if (postConvWidth * texelBytes < 32) {
@@ -701,10 +693,12 @@ st_TexImage(GLcontext * ctx,
}
else {
/* Allocate regular memory and store the image there temporarily. */
- if (texImage->IsCompressed) {
- sizeInBytes = texImage->CompressedSize;
- dstRowStride =
- _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width);
+ if (_mesa_is_format_compressed(texImage->TexFormat)) {
+ sizeInBytes = _mesa_format_image_size(texImage->TexFormat,
+ texImage->Width,
+ texImage->Height,
+ texImage->Depth);
+ dstRowStride = _mesa_format_row_stride(texImage->TexFormat, width);
assert(dims != 3);
}
else {
@@ -740,15 +734,15 @@ st_TexImage(GLcontext * ctx,
const GLubyte *src = (const GLubyte *) pixels;
for (i = 0; i < depth; i++) {
- if (!texImage->TexFormat->StoreImage(ctx, dims,
- texImage->_BaseFormat,
- texImage->TexFormat,
- texImage->Data,
- 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- texImage->ImageOffsets,
- width, height, 1,
- format, type, src, unpack)) {
+ if (!_mesa_texstore(ctx, dims,
+ texImage->_BaseFormat,
+ texImage->TexFormat,
+ texImage->Data,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ texImage->ImageOffsets,
+ width, height, 1,
+ format, type, src, unpack)) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
}
@@ -1114,14 +1108,14 @@ st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
dstRowStride = stImage->transfer->stride;
for (i = 0; i < depth; i++) {
- if (!texImage->TexFormat->StoreImage(ctx, dims, texImage->_BaseFormat,
- texImage->TexFormat,
- texImage->Data,
- 0, 0, 0,
- dstRowStride,
- texImage->ImageOffsets,
- width, height, 1,
- format, type, src, packing)) {
+ if (!_mesa_texstore(ctx, dims, texImage->_BaseFormat,
+ texImage->TexFormat,
+ texImage->Data,
+ 0, 0, 0,
+ dstRowStride,
+ texImage->ImageOffsets,
+ width, height, 1,
+ format, type, src, packing)) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage");
}
@@ -1380,16 +1374,16 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level,
* is actually RGBA but the user created the texture as GL_RGB we
* need to fill-in/override the alpha channel with 1.0.
*/
- texImage->TexFormat->StoreImage(ctx, dims,
- texImage->_BaseFormat,
- texImage->TexFormat,
- texDest,
- 0, 0, 0,
- dstRowStride,
- texImage->ImageOffsets,
- width, height, 1,
- GL_RGBA, GL_FLOAT, tempSrc, /* src */
- &unpack);
+ _mesa_texstore(ctx, dims,
+ texImage->_BaseFormat,
+ texImage->TexFormat,
+ texDest,
+ 0, 0, 0,
+ dstRowStride,
+ texImage->ImageOffsets,
+ width, height, 1,
+ GL_RGBA, GL_FLOAT, tempSrc, /* src */
+ &unpack);
}
else {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage");
@@ -1408,8 +1402,8 @@ static unsigned
compatible_src_dst_formats(const struct gl_renderbuffer *src,
const struct gl_texture_image *dst)
{
- const GLenum srcFormat = src->_BaseFormat;
- const GLenum dstLogicalFormat = dst->_BaseFormat;
+ const GLenum srcFormat = _mesa_get_format_base_format(src->Format);
+ const GLenum dstLogicalFormat = _mesa_get_format_base_format(dst->TexFormat);
if (srcFormat == dstLogicalFormat) {
/* This is the same as matching_base_formats, which should
@@ -1541,7 +1535,9 @@ st_copy_texsubimage(GLcontext *ctx,
* framebuffer's alpha values). We can't do that with the blit or
* textured-quad paths.
*/
- matching_base_formats = (strb->Base._BaseFormat == texImage->_BaseFormat);
+ matching_base_formats =
+ (_mesa_get_format_base_format(strb->Base.Format) ==
+ _mesa_get_format_base_format(texImage->TexFormat));
format_writemask = compatible_src_dst_formats(&strb->Base, texImage);
if (ctx->_ImageTransferState == 0x0) {
@@ -1801,11 +1797,11 @@ st_finalize_texture(GLcontext *ctx,
}
/* FIXME: determine format block instead of cpp */
- if (firstImage->base.IsCompressed) {
- cpp = compressed_num_bytes(firstImage->base.TexFormat->MesaFormat);
+ if (_mesa_is_format_compressed(firstImage->base.TexFormat)) {
+ cpp = compressed_num_bytes(firstImage->base.TexFormat);
}
else {
- cpp = firstImage->base.TexFormat->TexelBytes;
+ cpp = _mesa_get_format_bytes(firstImage->base.TexFormat);
}
/* If we already have a gallium texture, check that it matches the texture
@@ -1813,7 +1809,7 @@ st_finalize_texture(GLcontext *ctx,
*/
if (stObj->pt) {
const enum pipe_format fmt =
- st_mesa_format_to_pipe_format(firstImage->base.TexFormat->MesaFormat);
+ st_mesa_format_to_pipe_format(firstImage->base.TexFormat);
if (stObj->pt->target != gl_target_to_pipe(stObj->base.Target) ||
stObj->pt->format != fmt ||
stObj->pt->last_level < stObj->lastLevel ||
@@ -1832,7 +1828,7 @@ st_finalize_texture(GLcontext *ctx,
*/
if (!stObj->pt) {
const enum pipe_format fmt =
- st_mesa_format_to_pipe_format(firstImage->base.TexFormat->MesaFormat);
+ st_mesa_format_to_pipe_format(firstImage->base.TexFormat);
GLuint usage = default_usage(fmt);
stObj->pt = st_texture_create(ctx->st,
@@ -1949,7 +1945,6 @@ st_init_texture_functions(struct dd_function_table *functions)
/* compressed texture functions */
functions->CompressedTexImage2D = st_CompressedTexImage2D;
functions->GetCompressedTexImage = st_GetCompressedTexImage;
- functions->CompressedTextureSize = _mesa_compressed_texture_size;
functions->NewTextureObject = st_NewTextureObject;
functions->NewTextureImage = st_NewTextureImage;
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 3e0db37414..0be2737272 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -99,10 +99,11 @@ st_get_format_info(enum pipe_format format, struct pipe_format_info *pinfo)
if (format == PIPE_FORMAT_A1R5G5B5_UNORM || format == PIPE_FORMAT_R5G6B5_UNORM) {
pinfo->datatype = GL_UNSIGNED_SHORT;
}
+ else if (format == PIPE_FORMAT_S8Z24_UNORM) {
+ pinfo->datatype = GL_UNSIGNED_INT_24_8;
+ }
else {
- GLuint size;
-
- size = format_max_bits( info );
+ const GLuint size = format_max_bits( info );
if (size == 8) {
if (pf_type(info) == PIPE_FORMAT_TYPE_UNORM)
pinfo->datatype = GL_UNSIGNED_BYTE;
@@ -150,24 +151,10 @@ st_get_format_info(enum pipe_format format, struct pipe_format_info *pinfo)
pinfo->red_bits = 0;
}
- /* Base format */
- if (pinfo->depth_bits) {
- if (pinfo->stencil_bits) {
- pinfo->base_format = GL_DEPTH_STENCIL_EXT;
- }
- else {
- pinfo->base_format = GL_DEPTH_COMPONENT;
- }
- }
- else if (pinfo->stencil_bits) {
- pinfo->base_format = GL_STENCIL_INDEX;
- }
- else {
- pinfo->base_format = GL_RGBA;
- }
+ pinfo->mesa_format = st_pipe_format_to_mesa_format(format);
}
else if (pf_layout(format) == PIPE_FORMAT_LAYOUT_YCBCR) {
- pinfo->base_format = GL_YCBCR_MESA;
+ pinfo->mesa_format = MESA_FORMAT_YCBCR;
pinfo->datatype = GL_UNSIGNED_SHORT;
pinfo->size = 2; /* two bytes per "texel" */
}
@@ -224,7 +211,7 @@ st_format_datatype(enum pipe_format format)
enum pipe_format
-st_mesa_format_to_pipe_format(GLuint mesaFormat)
+st_mesa_format_to_pipe_format(gl_format mesaFormat)
{
switch (mesaFormat) {
/* fix this */
@@ -293,6 +280,82 @@ st_mesa_format_to_pipe_format(GLuint mesaFormat)
}
}
+
+gl_format
+st_pipe_format_to_mesa_format(enum pipe_format pipeFormat)
+{
+ switch (pipeFormat) {
+ case PIPE_FORMAT_A8R8G8B8_UNORM:
+ return MESA_FORMAT_ARGB8888;
+ case PIPE_FORMAT_A1R5G5B5_UNORM:
+ return MESA_FORMAT_ARGB1555;
+ case PIPE_FORMAT_A4R4G4B4_UNORM:
+ return MESA_FORMAT_ARGB4444;
+ case PIPE_FORMAT_R5G6B5_UNORM:
+ return MESA_FORMAT_RGB565;
+ case PIPE_FORMAT_A8L8_UNORM:
+ return MESA_FORMAT_AL88;
+ case PIPE_FORMAT_A8_UNORM:
+ return MESA_FORMAT_A8;
+ case PIPE_FORMAT_L8_UNORM:
+ return MESA_FORMAT_L8;
+ case PIPE_FORMAT_I8_UNORM:
+ return MESA_FORMAT_I8;
+ case PIPE_FORMAT_Z16_UNORM:
+ return MESA_FORMAT_Z16;
+ case PIPE_FORMAT_Z32_UNORM:
+ return MESA_FORMAT_Z32;
+ case PIPE_FORMAT_Z24S8_UNORM:
+ return MESA_FORMAT_Z24_S8;
+ case PIPE_FORMAT_S8Z24_UNORM:
+ return MESA_FORMAT_S8_Z24;
+ case PIPE_FORMAT_S8_UNORM:
+ return MESA_FORMAT_S8;
+
+ case PIPE_FORMAT_YCBCR:
+ return MESA_FORMAT_YCBCR;
+ case PIPE_FORMAT_R16G16B16A16_SNORM:
+ return MESA_FORMAT_SIGNED_RGBA_16;
+
+#if FEATURE_texture_s3tc
+ case PIPE_FORMAT_DXT1_RGB:
+ return MESA_FORMAT_RGB_DXT1;
+ case PIPE_FORMAT_DXT1_RGBA:
+ return MESA_FORMAT_RGBA_DXT1;
+ case PIPE_FORMAT_DXT3_RGBA:
+ return MESA_FORMAT_RGBA_DXT3;
+ case PIPE_FORMAT_DXT5_RGBA:
+ return MESA_FORMAT_RGBA_DXT5;
+#if FEATURE_EXT_texture_sRGB
+ case PIPE_FORMAT_DXT1_SRGB:
+ return MESA_FORMAT_SRGB_DXT1;
+ case PIPE_FORMAT_DXT1_SRGBA:
+ return MESA_FORMAT_SRGBA_DXT1;
+ case PIPE_FORMAT_DXT3_SRGBA:
+ return MESA_FORMAT_SRGBA_DXT3;
+ case PIPE_FORMAT_DXT5_SRGBA:
+ return MESA_FORMAT_SRGBA_DXT5;
+#endif
+#endif
+#if FEATURE_EXT_texture_sRGB
+ case PIPE_FORMAT_A8L8_SRGB:
+ return MESA_FORMAT_SLA8;
+ case PIPE_FORMAT_L8_SRGB:
+ return MESA_FORMAT_SL8;
+ case PIPE_FORMAT_R8G8B8_SRGB:
+ return MESA_FORMAT_SRGB8;
+ case PIPE_FORMAT_R8G8B8A8_SRGB:
+ return MESA_FORMAT_SRGBA8;
+ case PIPE_FORMAT_A8R8G8B8_SRGB:
+ return MESA_FORMAT_SARGB8;
+#endif
+ default:
+ assert(0);
+ return 0;
+ }
+}
+
+
/**
* Find an RGBA format supported by the context/winsys.
*/
@@ -629,74 +692,74 @@ st_choose_renderbuffer_format(struct pipe_screen *screen,
}
-static const struct gl_texture_format *
+static gl_format
translate_gallium_format_to_mesa_format(enum pipe_format format)
{
switch (format) {
case PIPE_FORMAT_A8R8G8B8_UNORM:
- return &_mesa_texformat_argb8888;
+ return MESA_FORMAT_ARGB8888;
case PIPE_FORMAT_A1R5G5B5_UNORM:
- return &_mesa_texformat_argb1555;
+ return MESA_FORMAT_ARGB1555;
case PIPE_FORMAT_A4R4G4B4_UNORM:
- return &_mesa_texformat_argb4444;
+ return MESA_FORMAT_ARGB4444;
case PIPE_FORMAT_R5G6B5_UNORM:
- return &_mesa_texformat_rgb565;
+ return MESA_FORMAT_RGB565;
case PIPE_FORMAT_A8L8_UNORM:
- return &_mesa_texformat_al88;
+ return MESA_FORMAT_AL88;
case PIPE_FORMAT_A8_UNORM:
- return &_mesa_texformat_a8;
+ return MESA_FORMAT_A8;
case PIPE_FORMAT_L8_UNORM:
- return &_mesa_texformat_l8;
+ return MESA_FORMAT_L8;
case PIPE_FORMAT_I8_UNORM:
- return &_mesa_texformat_i8;
+ return MESA_FORMAT_I8;
case PIPE_FORMAT_Z16_UNORM:
- return &_mesa_texformat_z16;
+ return MESA_FORMAT_Z16;
case PIPE_FORMAT_Z32_UNORM:
- return &_mesa_texformat_z32;
+ return MESA_FORMAT_Z32;
case PIPE_FORMAT_Z24S8_UNORM:
- return &_mesa_texformat_z24_s8;
+ return MESA_FORMAT_Z24_S8;
case PIPE_FORMAT_S8Z24_UNORM:
- return &_mesa_texformat_s8_z24;
+ return MESA_FORMAT_S8_Z24;
case PIPE_FORMAT_YCBCR:
- return &_mesa_texformat_ycbcr;
+ return MESA_FORMAT_YCBCR;
case PIPE_FORMAT_YCBCR_REV:
- return &_mesa_texformat_ycbcr_rev;
+ return MESA_FORMAT_YCBCR_REV;
#if FEATURE_texture_s3tc
case PIPE_FORMAT_DXT1_RGB:
- return &_mesa_texformat_rgb_dxt1;
+ return MESA_FORMAT_RGB_DXT1;
case PIPE_FORMAT_DXT1_RGBA:
- return &_mesa_texformat_rgba_dxt1;
+ return MESA_FORMAT_RGBA_DXT1;
case PIPE_FORMAT_DXT3_RGBA:
- return &_mesa_texformat_rgba_dxt3;
+ return MESA_FORMAT_RGBA_DXT3;
case PIPE_FORMAT_DXT5_RGBA:
- return &_mesa_texformat_rgba_dxt5;
+ return MESA_FORMAT_RGBA_DXT5;
#if FEATURE_EXT_texture_sRGB
case PIPE_FORMAT_DXT1_SRGB:
- return &_mesa_texformat_srgb_dxt1;
+ return MESA_FORMAT_SRGB_DXT1;
case PIPE_FORMAT_DXT1_SRGBA:
- return &_mesa_texformat_srgba_dxt1;
+ return MESA_FORMAT_SRGBA_DXT1;
case PIPE_FORMAT_DXT3_SRGBA:
- return &_mesa_texformat_srgba_dxt3;
+ return MESA_FORMAT_SRGBA_DXT3;
case PIPE_FORMAT_DXT5_SRGBA:
- return &_mesa_texformat_srgba_dxt5;
+ return MESA_FORMAT_SRGBA_DXT5;
#endif
#endif
#if FEATURE_EXT_texture_sRGB
case PIPE_FORMAT_A8L8_SRGB:
- return &_mesa_texformat_sla8;
+ return MESA_FORMAT_SLA8;
case PIPE_FORMAT_L8_SRGB:
- return &_mesa_texformat_sl8;
+ return MESA_FORMAT_SL8;
case PIPE_FORMAT_R8G8B8_SRGB:
- return &_mesa_texformat_srgb8;
+ return MESA_FORMAT_SRGB8;
case PIPE_FORMAT_R8G8B8A8_SRGB:
- return &_mesa_texformat_srgba8;
+ return MESA_FORMAT_SRGBA8;
case PIPE_FORMAT_A8R8G8B8_SRGB:
- return &_mesa_texformat_sargb8;
+ return MESA_FORMAT_SARGB8;
#endif
/* XXX add additional cases */
default:
assert(0);
- return NULL;
+ return MESA_FORMAT_NONE;
}
}
@@ -704,7 +767,7 @@ translate_gallium_format_to_mesa_format(enum pipe_format format)
/**
* Called via ctx->Driver.chooseTextureFormat().
*/
-const struct gl_texture_format *
+gl_format
st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
GLenum format, GLenum type)
{
@@ -716,7 +779,7 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
pFormat = st_choose_format(ctx->st->pipe->screen, internalFormat,
PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER);
if (pFormat == PIPE_FORMAT_NONE)
- return NULL;
+ return MESA_FORMAT_NONE;
return translate_gallium_format_to_mesa_format(pFormat);
}
diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h
index e4a788c89b..7cddf5aa66 100644
--- a/src/mesa/state_tracker/st_format.h
+++ b/src/mesa/state_tracker/st_format.h
@@ -29,11 +29,12 @@
#ifndef ST_FORMAT_H
#define ST_FORMAT_H
+#include "main/formats.h"
struct pipe_format_info
{
enum pipe_format format;
- GLenum base_format;
+ gl_format mesa_format;
GLenum datatype;
GLubyte red_bits;
GLubyte green_bits;
@@ -60,7 +61,10 @@ st_format_datatype(enum pipe_format format);
extern enum pipe_format
-st_mesa_format_to_pipe_format(GLuint mesaFormat);
+st_mesa_format_to_pipe_format(gl_format mesaFormat);
+
+extern gl_format
+st_pipe_format_to_mesa_format(enum pipe_format pipeFormat);
extern enum pipe_format
@@ -72,7 +76,7 @@ st_choose_renderbuffer_format(struct pipe_screen *screen,
GLenum internalFormat);
-extern const struct gl_texture_format *
+extern gl_format
st_ChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
GLenum format, GLenum type);
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c
index 3f30137747..3945822f66 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -32,8 +32,9 @@
#include "st_cb_fbo.h"
#include "st_inlines.h"
#include "main/enums.h"
-#include "main/texobj.h"
+#include "main/texfetch.h"
#include "main/teximage.h"
+#include "main/texobj.h"
#include "main/texstore.h"
#undef Elements /* fix re-defined macro warning */
@@ -128,7 +129,7 @@ st_texture_match_image(const struct pipe_texture *pt,
/* Check if this image's format matches the established texture's format.
*/
- if (st_mesa_format_to_pipe_format(image->TexFormat->MesaFormat) != pt->format)
+ if (st_mesa_format_to_pipe_format(image->TexFormat) != pt->format)
return GL_FALSE;
/* Test if this image's size matches what's expected in the