Mesa (nvfx-next-5): nv30: support ARB_texture_rectangle

Luca Barbieri lb at kemper.freedesktop.org
Thu Apr 15 00:53:10 PDT 2010


Module: Mesa
Branch: nvfx-next-5
Commit: 48c56ece6d1be189ff1b034ee608ee5858f918a7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=48c56ece6d1be189ff1b034ee608ee5858f918a7

Author: Luca Barbieri <luca at luca-barbieri.com>
Date:   Thu Mar 11 18:06:28 2010 +0100

nv30: support ARB_texture_rectangle

This uses nv30's _RECT formats.

Note: only an older version was tested on nv30.

---

 src/gallium/drivers/nvfx/nv30_fragtex.c |   21 +++++++++++++++++++--
 src/gallium/drivers/nvfx/nvfx_miptree.c |    3 ++-
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/src/gallium/drivers/nvfx/nv30_fragtex.c b/src/gallium/drivers/nvfx/nv30_fragtex.c
index 319f638..f2f8410 100644
--- a/src/gallium/drivers/nvfx/nv30_fragtex.c
+++ b/src/gallium/drivers/nvfx/nv30_fragtex.c
@@ -37,6 +37,7 @@ nv30_sampler_state_init(struct pipe_context *pipe,
 #define _(m,tf,ts0x,ts0y,ts0z,ts0w,ts1x,ts1y,ts1z,ts1w)                        \
 [PIPE_FORMAT_##m] = {                                                                              \
   NV34TCL_TX_FORMAT_FORMAT_##tf,                                               \
+  NV34TCL_TX_FORMAT_FORMAT_##tf##_RECT,                                               \
   (NV34TCL_TX_SWIZZLE_S0_X_##ts0x | NV34TCL_TX_SWIZZLE_S0_Y_##ts0y |           \
    NV34TCL_TX_SWIZZLE_S0_Z_##ts0z | NV34TCL_TX_SWIZZLE_S0_W_##ts0w |           \
    NV34TCL_TX_SWIZZLE_S1_X_##ts1x | NV34TCL_TX_SWIZZLE_S1_Y_##ts1y |           \
@@ -45,12 +46,17 @@ nv30_sampler_state_init(struct pipe_context *pipe,
 
 struct nv30_texture_format {
 	int     format;
+	int     rect_format;
 	int     swizzle;
 };
 
+#define NV34TCL_TX_FORMAT_FORMAT_DXT1_RECT NV34TCL_TX_FORMAT_FORMAT_DXT1
+#define NV34TCL_TX_FORMAT_FORMAT_DXT3_RECT NV34TCL_TX_FORMAT_FORMAT_DXT3
+#define NV34TCL_TX_FORMAT_FORMAT_DXT5_RECT NV34TCL_TX_FORMAT_FORMAT_DXT5
+
 static struct nv30_texture_format
 nv30_texture_formats[PIPE_FORMAT_COUNT] = {
-	[0 ... PIPE_FORMAT_COUNT - 1] = {-1, 0},
+	[0 ... PIPE_FORMAT_COUNT - 1] = {-1, 0, 0},
 	_(B8G8R8X8_UNORM, A8R8G8B8,   S1,   S1,   S1,  ONE, X, Y, Z, W),
 	_(B8G8R8A8_UNORM, A8R8G8B8,   S1,   S1,   S1,   S1, X, Y, Z, W),
 	_(B5G5R5A1_UNORM, A1R5G5B5,   S1,   S1,   S1,   S1, X, Y, Z, W),
@@ -84,7 +90,15 @@ nv30_fragtex_set(struct nvfx_context *nvfx, int unit)
 	tf = &nv30_texture_formats[pt->format];
 	assert(tf->format >= 0);
 
-	txf  = tf->format;
+	{
+		static int warned = 0;
+		if(!warned && !ps->fmt == !(pt->flags & NVFX_RESOURCE_FLAG_LINEAR)) {
+			warned = 1;
+			fprintf(stderr, "Coordinate normalization mismatch: are you using a non-OpenGL state tracker?\n");
+		}
+	}
+
+	txf  = (pt->flags & NVFX_RESOURCE_FLAG_LINEAR) ? tf->rect_format : tf->format;
 	txf |= ((pt->last_level>0) ? NV34TCL_TX_FORMAT_MIPMAP : 0);
 	txf |= log2i(pt->width0) << NV34TCL_TX_FORMAT_BASE_SIZE_U_SHIFT;
 	txf |= log2i(pt->height0) << NV34TCL_TX_FORMAT_BASE_SIZE_V_SHIFT;
@@ -112,6 +126,9 @@ nv30_fragtex_set(struct nvfx_context *nvfx, int unit)
 	/* FIXME: specify whether textures are swizzled or not somehow */
 	txs = tf->swizzle;
 
+	if(mt->linear_pitch)
+		txs |= mt->linear_pitch << NV34TCL_TX_SWIZZLE_RECT_PITCH_SHIFT;
+
 	MARK_RING(chan, 9, 2);
 	OUT_RING(chan, RING_3D(NV34TCL_TX_OFFSET(unit), 8));
 	OUT_RELOC(chan, bo, 0, tex_flags | NOUVEAU_BO_LOW, 0, 0);
diff --git a/src/gallium/drivers/nvfx/nvfx_miptree.c b/src/gallium/drivers/nvfx/nvfx_miptree.c
index 8e7655a..59133b3 100644
--- a/src/gallium/drivers/nvfx/nvfx_miptree.c
+++ b/src/gallium/drivers/nvfx/nvfx_miptree.c
@@ -6,7 +6,7 @@
 #include "util/u_math.h"
 
 #include "nouveau/nouveau_winsys.h"
-#include "nouveau/nouveau_screen.h"
+#include "nvfx_screen.h"
 #include "nvfx_resource.h"
 #include "nvfx_transfer.h"
 #include "state_tracker/drm_api.h"
@@ -31,6 +31,7 @@ nvfx_miptree_choose_format(struct nvfx_miptree *mt)
 		|| (pt->_usage & PIPE_USAGE_DYNAMIC)
 		|| util_format_is_s3tc(pt->format)
 		|| no_swizzle
+		|| (~((struct nvfx_screen*)pt->screen)->is_nv4x & (pt->flags & PIPE_RESOURCE_FLAG_UNNORMALIZED_COORDS_HINT))
 	)
 		mt->base.base.flags |= NVFX_RESOURCE_FLAG_LINEAR;
 



More information about the mesa-commit mailing list