[Mesa-dev] [PATCH 5/5] UNTESTED: Enable NV_fog_distance on NV10 and NV20 hardware

Nicholas Miell nmiell at gmail.com
Mon Sep 19 02:48:40 PDT 2011


This has not been tested on real hardware. I have no idea if it works.

Add support for NV_fog_distance to the NV10 and NV20 drivers.
---
 src/mesa/drivers/dri/nouveau/nv10_context.c   |    1 +
 src/mesa/drivers/dri/nouveau/nv10_state_tnl.c |   14 +++++++++++---
 src/mesa/drivers/dri/nouveau/nv20_context.c   |    1 +
 src/mesa/drivers/dri/nouveau/nv20_state_tnl.c |   14 +++++++++++---
 4 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/src/mesa/drivers/dri/nouveau/nv10_context.c b/src/mesa/drivers/dri/nouveau/nv10_context.c
index da0ef2b..c4dc1c5 100644
--- a/src/mesa/drivers/dri/nouveau/nv10_context.c
+++ b/src/mesa/drivers/dri/nouveau/nv10_context.c
@@ -435,6 +435,7 @@ nv10_context_create(struct nouveau_screen *screen, const struct gl_config *visua
 	ctx->Extensions.ARB_texture_env_crossbar = true;
 	ctx->Extensions.ARB_texture_env_combine = true;
 	ctx->Extensions.ARB_texture_env_dot3 = true;
+	ctx->Extensions.NV_fog_distance = true;
 	ctx->Extensions.NV_texture_rectangle = true;
 
 	/* GL constants. */
diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c b/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c
index 96d1b32..aa261ec 100644
--- a/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c
+++ b/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c
@@ -80,13 +80,21 @@ get_fog_mode(unsigned mode)
 }
 
 static unsigned
-get_fog_source(unsigned source)
+get_fog_source_and_distance_mode(unsigned source, unsigned distance_mode)
 {
 	switch (source) {
 	case GL_FOG_COORDINATE_EXT:
 		return NV10_3D_FOG_COORD_FOG;
 	case GL_FRAGMENT_DEPTH_EXT:
-		return NV10_3D_FOG_COORD_DIST_ORTHOGONAL_ABS;
+		switch (distance_mode) {
+			case GL_EYE_PLANE_ABSOLUTE_NV:
+				return NV10_3D_FOG_COORD_DIST_ORTHOGONAL_ABS;
+			case GL_EYE_PLANE:
+				return NV10_3D_FOG_COORD_DIST_ORTHOGONAL;
+			case GL_EYE_RADIAL_NV:
+				return NV10_3D_FOG_COORD_DIST_RADIAL;
+		default: assert(0);
+		}
 	default:
 		assert(0);
 	}
@@ -135,7 +143,7 @@ nv10_emit_fog(struct gl_context *ctx, int emit)
 
 	BEGIN_RING(chan, celsius, NV10_3D_FOG_MODE, 4);
 	OUT_RING(chan, get_fog_mode(f->Mode));
-	OUT_RING(chan, get_fog_source(source));
+	OUT_RING(chan, get_fog_source_and_distance_mode(source, f->FogDistanceMode));
 	OUT_RINGb(chan, f->Enabled);
 	OUT_RING(chan, pack_rgba_f(MESA_FORMAT_RGBA8888_REV, f->Color));
 
diff --git a/src/mesa/drivers/dri/nouveau/nv20_context.c b/src/mesa/drivers/dri/nouveau/nv20_context.c
index 87a6db1..2a883e3 100644
--- a/src/mesa/drivers/dri/nouveau/nv20_context.c
+++ b/src/mesa/drivers/dri/nouveau/nv20_context.c
@@ -449,6 +449,7 @@ nv20_context_create(struct nouveau_screen *screen, const struct gl_config *visua
 	ctx->Extensions.ARB_texture_env_crossbar = true;
 	ctx->Extensions.ARB_texture_env_combine = true;
 	ctx->Extensions.ARB_texture_env_dot3 = true;
+	ctx->Extensions.NV_fog_distance = true;
 	ctx->Extensions.NV_texture_rectangle = true;
 
 	/* GL constants. */
diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c b/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c
index 4f7ddd8..eaaec44 100644
--- a/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c
+++ b/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c
@@ -127,13 +127,21 @@ get_fog_mode_unsigned(unsigned mode)
 }
 
 static unsigned
-get_fog_source(unsigned source)
+get_fog_source_and_distance_mode(unsigned source, unsigned distance_mode)
 {
 	switch (source) {
 	case GL_FOG_COORDINATE_EXT:
 		return NV20_3D_FOG_COORD_FOG;
 	case GL_FRAGMENT_DEPTH_EXT:
-		return NV20_3D_FOG_COORD_DIST_ORTHOGONAL_ABS;
+		switch (distance_mode) {
+			case GL_EYE_PLANE_ABSOLUTE_NV:
+				return NV20_3D_FOG_COORD_DIST_ORTHOGONAL_ABS;
+			case GL_EYE_PLANE:
+				return NV20_3D_FOG_COORD_DIST_ORTHOGONAL;
+			case GL_EYE_RADIAL_NV:
+				return NV20_3D_FOG_COORD_DIST_RADIAL;
+		default: assert(0);
+		}
 	default:
 		assert(0);
 	}
@@ -156,7 +164,7 @@ nv20_emit_fog(struct gl_context *ctx, int emit)
 	OUT_RING(chan, (source == GL_FOG_COORDINATE_EXT ?
 			get_fog_mode_signed(f->Mode) :
 			get_fog_mode_unsigned(f->Mode)));
-	OUT_RING(chan, get_fog_source(source));
+	OUT_RING(chan, get_fog_source_and_distance_mode(source, f->FogDistanceMode));
 	OUT_RINGb(chan, f->Enabled);
 	OUT_RING(chan, pack_rgba_f(MESA_FORMAT_RGBA8888_REV, f->Color));
 
-- 
1.7.6.2



More information about the mesa-dev mailing list