drivers: use more mesa format functions
authorBrian Paul <brianp@vmware.com>
Mon, 28 Sep 2009 02:40:35 +0000 (20:40 -0600)
committerBrian Paul <brianp@vmware.com>
Mon, 28 Sep 2009 02:40:35 +0000 (20:40 -0600)
src/mesa/drivers/dri/intel/intel_fbo.c
src/mesa/drivers/dri/intel/intel_tex_image.c
src/mesa/drivers/dri/r300/r300_tex.c
src/mesa/drivers/dri/r300/r300_texstate.c
src/mesa/drivers/dri/r600/r600_tex.c
src/mesa/drivers/dri/radeon/radeon_fbo.c

index 8dfb24290d5c2323818f56c81c088f9c3db86e3d..0a3d0654d7417063899d1de2d4b73ac4769bf8ba 100644 (file)
@@ -466,6 +466,7 @@ intel_update_wrapper(GLcontext *ctx, struct intel_renderbuffer *irb,
                     struct gl_texture_image *texImage)
 {
    irb->texformat = texImage->TexFormat;
+   gl_format texFormat;
 
    if (texImage->TexFormat == &_mesa_texformat_argb8888) {
       irb->Base._ActualFormat = GL_RGBA8;
@@ -509,15 +510,17 @@ intel_update_wrapper(GLcontext *ctx, struct intel_renderbuffer *irb,
       return GL_FALSE;
    }
 
+   texFormat = texImage->TexFormat->MesaFormat;
+
    irb->Base.InternalFormat = irb->Base._ActualFormat;
    irb->Base.Width = texImage->Width;
    irb->Base.Height = texImage->Height;
-   irb->Base.RedBits = texImage->TexFormat->RedBits;
-   irb->Base.GreenBits = texImage->TexFormat->GreenBits;
-   irb->Base.BlueBits = texImage->TexFormat->BlueBits;
-   irb->Base.AlphaBits = texImage->TexFormat->AlphaBits;
-   irb->Base.DepthBits = texImage->TexFormat->DepthBits;
-   irb->Base.StencilBits = texImage->TexFormat->StencilBits;
+   irb->Base.RedBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE);
+   irb->Base.GreenBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE);
+   irb->Base.BlueBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_BLUE_SIZE);
+   irb->Base.AlphaBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_ALPHA_SIZE);
+   irb->Base.DepthBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_DEPTH_SIZE_ARB);
+   irb->Base.StencilBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_STENCIL_SIZE_EXT);
 
    irb->Base.Delete = intel_delete_renderbuffer;
    irb->Base.AllocStorage = intel_nop_alloc_storage;
index 3bafbba3718361edce278deed4699f22afddf9e5..a9f031a3cb2a72eb2d9a76d6bdac57800dae60d9 100644 (file)
@@ -404,19 +404,18 @@ intelTexImage(GLcontext * ctx,
    } else if (intelImage->base.Border == 0) {
       int comp_byte = 0;
       GLuint texelBytes = _mesa_get_format_bytes(intelImage->base.TexFormat->MesaFormat);
-
+      GLenum baseFormat = _mesa_get_format_base_format(intelImage->base.TexFormat->MesaFormat);
       if (intelImage->base.IsCompressed) {
         comp_byte =
            intel_compressed_num_bytes(intelImage->base.TexFormat->MesaFormat);
       }
 
-
       /* Didn't fit in the object miptree, but it's suitable for inclusion in
        * a miptree, so create one just for our level and store it in the image.
        * It'll get moved into the object miptree at validate time.
        */
       intelImage->mt = intel_miptree_create(intel, target,
-                                           intelImage->base.TexFormat->BaseFormat,
+                                           baseFormat,
                                            internalFormat,
                                            level, level,
                                            width, height, depth,
index 433e5a87d48b2cd79dd535c3a38463b918946dc4..10daeca9e6de60967bc0637d501727880a870c27 100644 (file)
@@ -196,6 +196,7 @@ static void r300TexParameter(GLcontext * ctx, GLenum target,
                             GLenum pname, const GLfloat * params)
 {
        radeonTexObj* t = radeon_tex_obj(texObj);
+       GLenum texBaseFormat;
 
        if (RADEON_DEBUG & (RADEON_STATE | RADEON_TEXTURE)) {
                fprintf(stderr, "%s( %s )\n", __FUNCTION__,
@@ -238,8 +239,10 @@ static void r300TexParameter(GLcontext * ctx, GLenum target,
        case GL_DEPTH_TEXTURE_MODE:
                if (!texObj->Image[0][texObj->BaseLevel])
                        return;
-               if (texObj->Image[0][texObj->BaseLevel]->TexFormat->BaseFormat
-                   == GL_DEPTH_COMPONENT) {
+               texBaseFormat = texObj->Image[0][texObj->BaseLevel]->_BaseFormat;
+
+               if (texBaseFormat == GL_DEPTH_COMPONENT ||
+                       texBaseFormat == GL_DEPTH_STENCIL) {
                        r300SetDepthTexMode(texObj);
                        break;
                } else {
index f030451b282209fe152a7d85a72b90d8e414209f..cc40e0d1dc8ac47d186f028c4f3553ee52566b98 100644 (file)
@@ -209,7 +209,7 @@ static void setup_hardware_state(r300ContextPtr rmesa, radeonTexObj *t)
 
        if (!t->image_override
            && VALID_FORMAT(firstImage->TexFormat->MesaFormat)) {
-               if (firstImage->TexFormat->BaseFormat == GL_DEPTH_COMPONENT) {
+               if (firstImage->_BaseFormat == GL_DEPTH_COMPONENT) {
                        r300SetDepthTexMode(&t->base);
                } else {
                        t->pp_txformat = tx_table[firstImage->TexFormat->MesaFormat].format;
index d105b90cd18562bdb2b46ea77556dec3b80c8eb6..47081c968ef40f724d3f04d9a848ad3c87a1fffd 100644 (file)
@@ -286,6 +286,7 @@ static void r600TexParameter(GLcontext * ctx, GLenum target,
                             GLenum pname, const GLfloat * params)
 {
        radeonTexObj* t = radeon_tex_obj(texObj);
+       GLenum baseFormat;
 
        radeon_print(RADEON_STATE | RADEON_TEXTURE, RADEON_VERBOSE,
                        "%s( %s )\n", __FUNCTION__,
@@ -327,8 +328,9 @@ static void r600TexParameter(GLcontext * ctx, GLenum target,
        case GL_DEPTH_TEXTURE_MODE:
                if (!texObj->Image[0][texObj->BaseLevel])
                        return;
-               if (texObj->Image[0][texObj->BaseLevel]->TexFormat->BaseFormat
-                   == GL_DEPTH_COMPONENT) {
+               baseFormat = texObj->Image[0][texObj->BaseLevel]->_BaseFormat;
+               if (baseFormat == GL_DEPTH_COMPONENT ||
+                   baseFormat == GL_DEPTH_STENCIL) {
                        r600SetDepthTexMode(texObj);
                        break;
                } else {
index 7ac53ec0ca38c7d04887d7ce52dc9ae1bec8d56a..f19170b612301fe13a2999fd25d535b97ab874a1 100644 (file)
@@ -387,6 +387,8 @@ radeon_update_wrapper(GLcontext *ctx, struct radeon_renderbuffer *rrb,
                     struct gl_texture_image *texImage)
 {
        int retry = 0;
+       gl_format texFormat;
+
 restart:
        if (texImage->TexFormat == &_mesa_texformat_argb8888) {
                rrb->cpp = 4;
@@ -438,24 +440,25 @@ restart:
                        return GL_FALSE;
                }
                texImage->TexFormat = radeonChooseTextureFormat(ctx, texImage->InternalFormat, 0,
-                                                               texImage->TexFormat->DataType,
+                                                               _mesa_get_format_datatype(texImage->TexFormat->MesaFormat),
                                                                1);
 
                retry++;
                goto restart;
        }
        
+       texFormat = texImage->TexFormat->MesaFormat;
+
        rrb->pitch = texImage->Width * rrb->cpp;
        rrb->base.InternalFormat = rrb->base._ActualFormat;
        rrb->base.Width = texImage->Width;
        rrb->base.Height = texImage->Height;
-       rrb->base.RedBits = texImage->TexFormat->RedBits;
-       rrb->base.GreenBits = texImage->TexFormat->GreenBits;
-       rrb->base.BlueBits = texImage->TexFormat->BlueBits;
-       rrb->base.AlphaBits = texImage->TexFormat->AlphaBits;
-       rrb->base.DepthBits = texImage->TexFormat->DepthBits;
-       rrb->base.StencilBits = texImage->TexFormat->StencilBits;
-       
+       rrb->Base.RedBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_RED_SIZE);
+       rrb->Base.GreenBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_GREEN_SIZE);
+       rrb->Base.BlueBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_BLUE_SIZE);
+       rrb->Base.AlphaBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_ALPHA_SIZE);
+       rrb->Base.DepthBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_DEPTH_SIZE_ARB);
+       rrb->Base.StencilBits = _mesa_get_format_bits(texFormat, GL_TEXTURE_STENCIL_SIZE_EXT);
        rrb->base.Delete = radeon_delete_renderbuffer;
        rrb->base.AllocStorage = radeon_nop_alloc_storage;