Mesa (master): nvfx: support rendering to more formats

Luca Barbieri lb at kemper.freedesktop.org
Sat Sep 4 21:01:23 UTC 2010


Module: Mesa
Branch: master
Commit: 20bf5037d6006329b362fe501cc8a3594a0cab24
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=20bf5037d6006329b362fe501cc8a3594a0cab24

Author: Luca Barbieri <luca at luca-barbieri.com>
Date:   Sat Sep  4 21:29:43 2010 +0200

nvfx: support rendering to more formats

---

 src/gallium/drivers/nouveau/nouveau_class.h |    4 +++-
 src/gallium/drivers/nvfx/nvfx_screen.c      |   20 +++++++++++++++++++-
 src/gallium/drivers/nvfx/nvfx_screen.h      |    2 ++
 src/gallium/drivers/nvfx/nvfx_state_fb.c    |    6 ++++++
 4 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nouveau_class.h b/src/gallium/drivers/nouveau/nouveau_class.h
index 79681d2..72ddf9b 100644
--- a/src/gallium/drivers/nouveau/nouveau_class.h
+++ b/src/gallium/drivers/nouveau/nouveau_class.h
@@ -5003,7 +5003,9 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define    NV34TCL_RT_FORMAT_COLOR_X8R8G8B8						0x00000005
 #define    NV34TCL_RT_FORMAT_COLOR_A8R8G8B8						0x00000008
 #define    NV34TCL_RT_FORMAT_COLOR_B8							0x00000009
-#define    NV34TCL_RT_FORMAT_COLOR_UNKNOWN						0x0000000d
+#define    NV34TCL_RT_FORMAT_COLOR_A16B16G16R16_FLOAT					0x0000000b
+#define    NV34TCL_RT_FORMAT_COLOR_A32B32G32R32_FLOAT					0x0000000c
+#define    NV34TCL_RT_FORMAT_COLOR_R32_FLOAT						0x0000000d
 #define    NV34TCL_RT_FORMAT_COLOR_X8B8G8R8						0x0000000f
 #define    NV34TCL_RT_FORMAT_COLOR_A8B8G8R8						0x00000010
 #define  NV34TCL_COLOR0_PITCH								0x0000020c
diff --git a/src/gallium/drivers/nvfx/nvfx_screen.c b/src/gallium/drivers/nvfx/nvfx_screen.c
index e01b2a6..9056a56 100644
--- a/src/gallium/drivers/nvfx/nvfx_screen.c
+++ b/src/gallium/drivers/nvfx/nvfx_screen.c
@@ -168,6 +168,14 @@ nvfx_screen_is_format_supported(struct pipe_screen *pscreen,
 		case PIPE_FORMAT_B8G8R8X8_UNORM:
 		case PIPE_FORMAT_B5G6R5_UNORM:
 			break;
+		case PIPE_FORMAT_R16G16B16A16_FLOAT:
+			if(!screen->advertise_fp16)
+				return FALSE;
+			break;
+		case PIPE_FORMAT_R32G32B32A32_FLOAT:
+			if(!screen->advertise_fp32)
+				return FALSE;
+			break;
 		default:
 			return FALSE;
 		}
@@ -188,7 +196,10 @@ nvfx_screen_is_format_supported(struct pipe_screen *pscreen,
 		struct nvfx_texture_format* tf = &nvfx_texture_formats[format];
 		if(util_format_is_s3tc(format) && !util_format_s3tc_enabled)
 			return FALSE;
-
+		if(format == PIPE_FORMAT_R16G16B16A16_FLOAT && !screen->advertise_fp16)
+			return FALSE;
+		if(format == PIPE_FORMAT_R32G32B32A32_FLOAT && !screen->advertise_fp32)
+			return FALSE;
 		if(screen->is_nv4x)
 		{
 			if(tf->fmt[4] < 0)
@@ -428,6 +439,13 @@ nvfx_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
 	screen->inline_cost_per_hardware_cost = atof(debug_get_option("NVFX_INLINE_COST_PER_HARDWARE_COST", "1.0"));
 	screen->static_reuse_threshold = atof(debug_get_option("NVFX_STATIC_REUSE_THRESHOLD", "2.0"));
 
+	/* We don't advertise these by default because filtering and blending doesn't work as
+	 * it should, due to several restrictions.
+	 * The only exception is fp16 on nv40.
+	 */
+	screen->advertise_fp16 = debug_get_bool_option("NVFX_FP16", !!screen->is_nv4x);
+	screen->advertise_fp32 = debug_get_bool_option("NVFX_FP32", 0);
+
 	screen->vertex_buffer_reloc_flags = nvfx_screen_get_vertex_buffer_flags(screen);
 
 	/* surely both nv3x and nv44 support index buffers too: find out how and test that */
diff --git a/src/gallium/drivers/nvfx/nvfx_screen.h b/src/gallium/drivers/nvfx/nvfx_screen.h
index 1b79235..566fcb1 100644
--- a/src/gallium/drivers/nvfx/nvfx_screen.h
+++ b/src/gallium/drivers/nvfx/nvfx_screen.h
@@ -19,6 +19,8 @@ struct nvfx_screen {
 	boolean trace_draw;
 	unsigned vertex_buffer_reloc_flags;
 	unsigned index_buffer_reloc_flags;
+	unsigned advertise_fp16;
+	unsigned advertise_fp32;
 
 	/* HW graphics objects */
 	struct nouveau_grobj *eng3d;
diff --git a/src/gallium/drivers/nvfx/nvfx_state_fb.c b/src/gallium/drivers/nvfx/nvfx_state_fb.c
index 667b084..4b82c68 100644
--- a/src/gallium/drivers/nvfx/nvfx_state_fb.c
+++ b/src/gallium/drivers/nvfx/nvfx_state_fb.c
@@ -143,6 +143,12 @@ nvfx_framebuffer_validate(struct nvfx_context *nvfx, unsigned prepare_result)
 		case PIPE_FORMAT_B5G6R5_UNORM:
 			rt_format |= NV34TCL_RT_FORMAT_COLOR_R5G6B5;
 			break;
+		case PIPE_FORMAT_R32G32B32A32_FLOAT:
+			rt_format |= NV34TCL_RT_FORMAT_COLOR_A32B32G32R32_FLOAT;
+			break;
+		case PIPE_FORMAT_R16G16B16A16_FLOAT:
+			rt_format |= NV34TCL_RT_FORMAT_COLOR_A16B16G16R16_FLOAT;
+			break;
 		default:
 			assert(0);
 		}




More information about the mesa-commit mailing list