radeon/r200/r300/r600: add is_format_renderable function
authorMaciej Cencora <m.cencora@gmail.com>
Sun, 7 Mar 2010 13:34:21 +0000 (14:34 +0100)
committerMaciej Cencora <m.cencora@gmail.com>
Tue, 9 Mar 2010 20:50:20 +0000 (21:50 +0100)
src/mesa/drivers/dri/r200/r200_context.c
src/mesa/drivers/dri/r300/r300_context.c
src/mesa/drivers/dri/r300/r300_tex.c
src/mesa/drivers/dri/r300/r300_tex.h
src/mesa/drivers/dri/r600/r600_context.c
src/mesa/drivers/dri/radeon/radeon_common_context.h
src/mesa/drivers/dri/radeon/radeon_context.c
src/mesa/drivers/dri/radeon/radeon_texture.c
src/mesa/drivers/dri/radeon/radeon_texture.h

index dad2580e08b28b58d4be876873e8666c62f6c18c..4f1a56658ccb1843a5d0d970037e1decb0df38ae 100644 (file)
@@ -266,6 +266,7 @@ static void r200_init_vtbl(radeonContextPtr radeon)
    radeon->vtbl.emit_query_finish = r200_emit_query_finish;
    radeon->vtbl.check_blit = r200_check_blit;
    radeon->vtbl.blit = r200_blit;
+   radeon->vtbl.is_format_renderable = radeonIsFormatRenderable;
 }
 
 
index ff35cd52753cb139d8d66bf3372456481e6cdf02..364e0ba6b6147f07e7c36b716a87b196f7a6b41e 100644 (file)
@@ -321,6 +321,12 @@ static void r300_init_vtbl(radeonContextPtr radeon)
 
        radeon->vtbl.check_blit = r300_check_blit;
        radeon->vtbl.blit = r300_blit;
+
+       if (radeon->radeonScreen->chip_family >= CHIP_FAMILY_RV515) {
+               radeon->vtbl.is_format_renderable = r500IsFormatRenderable;
+       } else {
+               radeon->vtbl.is_format_renderable = r300IsFormatRenderable;
+       }
 }
 
 static void r300InitConstValues(GLcontext *ctx, radeonScreenPtr screen)
index 8dd8507395488b07ff074ac642b85c7a9758a7d7..baef206bc26e256563a4a27a3393cb97c77781e0 100644 (file)
@@ -308,6 +308,45 @@ static struct gl_texture_object *r300NewTextureObject(GLcontext * ctx,
        return &t->base;
 }
 
+unsigned r300IsFormatRenderable(gl_format mesa_format)
+{
+       switch (mesa_format)
+       {
+               case MESA_FORMAT_RGB565:
+               case MESA_FORMAT_RGBA5551:
+               case MESA_FORMAT_RGBA8888:
+               case MESA_FORMAT_RGB565_REV:
+               case MESA_FORMAT_RGBA8888_REV:
+               case MESA_FORMAT_ARGB4444:
+               case MESA_FORMAT_ARGB1555:
+               case MESA_FORMAT_XRGB8888:
+               case MESA_FORMAT_ARGB8888:
+               case MESA_FORMAT_ARGB4444_REV:
+               case MESA_FORMAT_ARGB1555_REV:
+               case MESA_FORMAT_XRGB8888_REV:
+               case MESA_FORMAT_ARGB8888_REV:
+               case MESA_FORMAT_SRGBA8:
+               case MESA_FORMAT_SARGB8:
+               case MESA_FORMAT_SL8:
+               case MESA_FORMAT_A8:
+               case MESA_FORMAT_L8:
+               case MESA_FORMAT_I8:
+               case MESA_FORMAT_Z16:
+                       return 1;
+               default:
+                       return 0;
+       }
+}
+
+unsigned r500IsFormatRenderable(gl_format mesa_format)
+{
+       if (mesa_format == MESA_FORMAT_S8_Z24) {
+               return 1;
+       } else {
+               return r300IsFormatRenderable(mesa_format);
+       }
+}
+
 void r300InitTextureFuncs(radeonContextPtr radeon, struct dd_function_table *functions)
 {
        /* Note: we only plug in the functions we implement in the driver
index 9694e703b83480c41d366e671b9e01106d2dccfd..aca44cd76699244d91b9fafffaeb2a4e56801a38 100644 (file)
@@ -53,4 +53,7 @@ extern void r300InitTextureFuncs(radeonContextPtr radeon, struct dd_function_tab
 
 int32_t r300TranslateTexFormat(gl_format mesaFormat);
 
+unsigned r300IsFormatRenderable(gl_format mesaFormat);
+unsigned r500IsFormatRenderable(gl_format mesaFormat);
+
 #endif                         /* __r300_TEX_H__ */
index 134e97e7c3321c907b08bf5086f14673118a87c8..76d5027649e30a1c238dd91b5f81f0b003c59496 100644 (file)
@@ -239,6 +239,7 @@ static void r600_init_vtbl(radeonContextPtr radeon)
        radeon->vtbl.emit_query_finish = r600_emit_query_finish;
        radeon->vtbl.check_blit = r600_check_blit;
        radeon->vtbl.blit = r600_blit;
+       radeon->vtbl.is_format_renderable = radeonIsFormatRenderable;
 }
 
 static void r600InitConstValues(GLcontext *ctx, radeonScreenPtr screen)
index d1a24e265f2e14ba1561fe211ea9df3186c073eb..5156c5d0d0a8bcf5db3e2c9ded72205ef407b82f 100644 (file)
@@ -539,6 +539,7 @@ struct radeon_context {
                         unsigned reg_width,
                         unsigned reg_height,
                         unsigned flip_y);
+          unsigned (*is_format_renderable)(gl_format mesa_format);
    } vtbl;
 };
 
index 878a453bd539cd9b84abc97fadadb5bc80ebeb43..56aba16e9e097f10ed2c146f7d1cc446dc9be3b1 100644 (file)
@@ -200,6 +200,7 @@ static void r100_init_vtbl(radeonContextPtr radeon)
    radeon->vtbl.emit_query_finish = r100_emit_query_finish;
    radeon->vtbl.check_blit = r100_check_blit;
    radeon->vtbl.blit = r100_blit;
+   radeon->vtbl.is_format_renderable = radeonIsFormatRenderable;
 }
 
 /* Create the device specific context.
index 3ccc711253bb725fa08e39ab578d67a561532315..2b655fbd953f8ebcc73c57d0fe18b7845f48fa36 100644 (file)
@@ -1006,3 +1006,19 @@ void radeonTexSubImage3D(GLcontext * ctx, GLenum target, GLint level,
        radeon_texsubimage(ctx, 3, target, level, xoffset, yoffset, zoffset, width, height, depth, 0,
                format, type, pixels, packing, texObj, texImage, 0);
 }
+
+unsigned radeonIsFormatRenderable(gl_format mesa_format)
+{
+       if (mesa_format == _dri_texformat_argb8888 || mesa_format == _dri_texformat_rgb565 ||
+               mesa_format == _dri_texformat_argb1555 || mesa_format == _dri_texformat_argb4444)
+               return 1;
+
+       switch (mesa_format)
+       {
+               case MESA_FORMAT_Z16:
+               case MESA_FORMAT_S8_Z24:
+                       return 1;
+               default:
+                       return 0;
+       }
+}
index f09dd65214229665aaf303e46bd2b4ebd1a33490..4ce639ea34eb5a3ed4e78138fc73291f2e582e68 100644 (file)
@@ -135,4 +135,6 @@ void radeonCopyTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
                        GLint x, GLint y,
                        GLsizei width, GLsizei height);
 
+unsigned radeonIsFormatRenderable(gl_format mesa_format);
+
 #endif