aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/r300
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2010-04-11 05:06:27 +0200
committerMarek Olšák <[email protected]>2010-04-11 06:40:46 +0200
commit2e7785be22181d6c6a10d2fd665bc41f8912b027 (patch)
treecc0e0865150feb6780095fdec8d0940830b913d9 /src/gallium/drivers/r300
parente1208bbeaeefd12a445cef84cbd12b7dc346531f (diff)
r300g: fix mipmapped 3D textures
This is a bug in the CS checker causing CS being rejected.
Diffstat (limited to 'src/gallium/drivers/r300')
-rw-r--r--src/gallium/drivers/r300/r300_texture.c24
-rw-r--r--src/gallium/drivers/r300/r300_winsys.h3
2 files changed, 26 insertions, 1 deletions
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
index 8ed28eb11a6..4439e35d670 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -759,6 +759,29 @@ static unsigned r300_texture_get_nblocksy(struct r300_texture* tex,
return util_format_get_nblocksy(tex->b.b.format, height);
}
+static void r300_texture_3d_fix_mipmapping(struct r300_screen *screen,
+ struct r300_texture *tex)
+{
+ /* The kernels <= 2.6.34-rc3 compute the size of mipmapped 3D textures
+ * incorrectly. This is a workaround to prevent CS from being rejected. */
+
+ unsigned i, size;
+
+ if (screen->rws->get_value(screen->rws, R300_VID_TEX3D_MIP_BUG) &&
+ tex->b.b.target == PIPE_TEXTURE_3D &&
+ tex->b.b.last_level > 0) {
+ size = 0;
+
+ for (i = 0; i <= tex->b.b.last_level; i++) {
+ size += r300_texture_get_stride(screen, tex, i) *
+ r300_texture_get_nblocksy(tex, i);
+ }
+
+ size *= tex->b.b.depth0;
+ tex->size = size;
+ }
+}
+
static void r300_setup_miptree(struct r300_screen* screen,
struct r300_texture* tex)
{
@@ -930,6 +953,7 @@ struct pipe_resource* r300_texture_create(struct pipe_screen* screen,
r300_setup_tiling(screen, tex);
}
r300_setup_miptree(rscreen, tex);
+ r300_texture_3d_fix_mipmapping(rscreen, tex);
r300_texture_setup_immutable_state(rscreen, tex);
r300_texture_setup_fb_state(rscreen, tex);
diff --git a/src/gallium/drivers/r300/r300_winsys.h b/src/gallium/drivers/r300/r300_winsys.h
index 80abaef4ba7..5ac997c8680 100644
--- a/src/gallium/drivers/r300/r300_winsys.h
+++ b/src/gallium/drivers/r300/r300_winsys.h
@@ -50,7 +50,8 @@ enum r300_value_id {
R300_VID_PCI_ID,
R300_VID_GB_PIPES,
R300_VID_Z_PIPES,
- R300_VID_SQUARE_TILING_SUPPORT
+ R300_VID_SQUARE_TILING_SUPPORT,
+ R300_VID_TEX3D_MIP_BUG,
};
struct r300_winsys_screen {