Hello all!

Unfortunately, this patch creates too-long lines, but i really prefer symbolic 
names, when they defined everywhere else.

Studying  texture combiners, i  created two tables, they probably has some 
errors, but I want to be pointed at errors before i even start to code, so 
please comment on them:



sources:
[1] http://www.opengl.org/sdk/docs/man/xhtml/glTexEnv.xml
[2] http://www.gamecareerguide.com/features/19981009/multitexturing_01.htm
[3] IRC talk 
[4] 
http://people.freedesktop.org/~idr/2007Q4-VGP351/20071106%20-%20Texture%20mapping,
%20part%203.pdf

From f8726c6e190466d91b588c1ad7409da506663218 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <randrianas...@gmail.com>
Date: Wed, 15 Sep 2010 19:40:16 +0400
Subject: [PATCH] nv0x: demagic nv04_state_raster.c and nv04_state_tex.c
 Unfortunately, lines go over 80 char limit

---
 src/mesa/drivers/dri/nouveau/nv04_state_raster.c |   30 +++++++++++-----------
 src/mesa/drivers/dri/nouveau/nv04_state_tex.c    |   22 ++++++++--------
 2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/src/mesa/drivers/dri/nouveau/nv04_state_raster.c b/src/mesa/drivers/dri/nouveau/nv04_state_raster.c
index c191571..51aacba 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_state_raster.c
+++ b/src/mesa/drivers/dri/nouveau/nv04_state_raster.c
@@ -176,13 +176,13 @@ nv04_emit_control(GLcontext *ctx, int emit)
 		if (ctx->Depth.Mask)
 			ctrl0 |= NV04_MULTITEX_TRIANGLE_CONTROL0_Z_WRITE;
 
-		ctrl0 |= get_comparison_op(ctx->Depth.Func) << 16;
+		ctrl0 |= get_comparison_op(ctx->Depth.Func) << NV04_MULTITEX_TRIANGLE_CONTROL0_Z_FUNC_SHIFT;
 
 		/* Alpha test. */
 		if (ctx->Color.AlphaEnabled)
 			ctrl0 |= NV04_MULTITEX_TRIANGLE_CONTROL0_ALPHA_ENABLE;
 
-		ctrl0 |= get_comparison_op(ctx->Color.AlphaFunc) << 8 |
+		ctrl0 |= get_comparison_op(ctx->Color.AlphaFunc) << NV04_MULTITEX_TRIANGLE_CONTROL0_ALPHA_FUNC_SHIFT |
 			FLOAT_TO_UBYTE(ctx->Color.AlphaRef);
 
 		/* Stencil test. */
@@ -192,13 +192,13 @@ nv04_emit_control(GLcontext *ctx, int emit)
 		if (ctx->Stencil.Enabled)
 			ctrl1 |= NV04_MULTITEX_TRIANGLE_CONTROL1_STENCIL_ENABLE;
 
-		ctrl1 |= get_comparison_op(ctx->Stencil.Function[0]) << 4 |
-			ctx->Stencil.Ref[0] << 8 |
-			ctx->Stencil.ValueMask[0] << 16 |
-			ctx->Stencil.WriteMask[0] << 24;
+		ctrl1 |= get_comparison_op(ctx->Stencil.Function[0]) << NV04_MULTITEX_TRIANGLE_CONTROL1_STENCIL_FUNC_SHIFT |
+			ctx->Stencil.Ref[0] << NV04_MULTITEX_TRIANGLE_CONTROL1_STENCIL_REF_SHIFT |
+			ctx->Stencil.ValueMask[0] << NV04_MULTITEX_TRIANGLE_CONTROL1_STENCIL_MASK_READ_SHIFT |
+			ctx->Stencil.WriteMask[0] << NV04_MULTITEX_TRIANGLE_CONTROL1_STENCIL_MASK_WRITE_SHIFT;
 
-		ctrl2 |= get_stencil_op(ctx->Stencil.ZPassFunc[0]) << 8 |
-			get_stencil_op(ctx->Stencil.ZFailFunc[0]) << 4 |
+		ctrl2 |= get_stencil_op(ctx->Stencil.ZPassFunc[0]) << NV04_MULTITEX_TRIANGLE_CONTROL2_STENCIL_OP_ZPASS_SHIFT |
+			get_stencil_op(ctx->Stencil.ZFailFunc[0]) << NV04_MULTITEX_TRIANGLE_CONTROL2_STENCIL_OP_ZFAIL_SHIFT |
 			get_stencil_op(ctx->Stencil.FailFunc[0]);
 
 		BEGIN_RING(chan, fahrenheit, NV04_MULTITEX_TRIANGLE_CONTROL0, 3);
@@ -209,7 +209,7 @@ nv04_emit_control(GLcontext *ctx, int emit)
 	} else {
 		int cull_mode = ctx->Polygon.CullFaceMode;
 		int front_face = ctx->Polygon.FrontFace;
-		uint32_t ctrl = 1 << 30 |
+		uint32_t ctrl = 1 << 30 /* Probably Z buffer format */ |
 			NV04_TEXTURED_TRIANGLE_CONTROL_ORIGIN;
 
 		/* Dithering. */
@@ -232,13 +232,13 @@ nv04_emit_control(GLcontext *ctx, int emit)
 		if (ctx->Depth.Mask)
 			ctrl |= NV04_TEXTURED_TRIANGLE_CONTROL_Z_WRITE;
 
-		ctrl |= get_comparison_op(ctx->Depth.Func) << 16;
+		ctrl |= get_comparison_op(ctx->Depth.Func) << NV04_TEXTURED_TRIANGLE_CONTROL_Z_FUNC_SHIFT;
 
 		/* Alpha test. */
 		if (ctx->Color.AlphaEnabled)
 			ctrl |= NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_ENABLE;
 
-		ctrl |= get_comparison_op(ctx->Color.AlphaFunc) << 8 |
+		ctrl |= get_comparison_op(ctx->Color.AlphaFunc) << NV04_TEXTURED_TRIANGLE_CONTROL_ALPHA_FUNC_SHIFT |
 			FLOAT_TO_UBYTE(ctx->Color.AlphaRef);
 
 		BEGIN_RING(chan, fahrenheit, NV04_TEXTURED_TRIANGLE_CONTROL, 1);
@@ -263,8 +263,8 @@ nv04_emit_blend(GLcontext *ctx, int emit)
 			NV04_MULTITEX_TRIANGLE_BLEND_TEXTURE_PERSPECTIVE_ENABLE;
 
 		/* Alpha blending. */
-		blend |= get_blend_func(ctx->Color.BlendDstRGB) << 28 |
-			get_blend_func(ctx->Color.BlendSrcRGB) << 24;
+		blend |= get_blend_func(ctx->Color.BlendDstRGB) << NV04_MULTITEX_TRIANGLE_BLEND_DST_SHIFT |
+			get_blend_func(ctx->Color.BlendSrcRGB) << NV04_MULTITEX_TRIANGLE_BLEND_SRC_SHIFT;
 
 		if (ctx->Color.BlendEnabled)
 			blend |= NV04_MULTITEX_TRIANGLE_BLEND_BLEND_ENABLE;
@@ -295,8 +295,8 @@ nv04_emit_blend(GLcontext *ctx, int emit)
 			NV04_TEXTURED_TRIANGLE_BLEND_TEXTURE_PERSPECTIVE_ENABLE;
 
 		/* Alpha blending. */
-		blend |= get_blend_func(ctx->Color.BlendDstRGB) << 28 |
-			get_blend_func(ctx->Color.BlendSrcRGB) << 24;
+		blend |= get_blend_func(ctx->Color.BlendDstRGB) << NV04_TEXTURED_TRIANGLE_BLEND_DST_SHIFT |
+			get_blend_func(ctx->Color.BlendSrcRGB) << NV04_TEXTURED_TRIANGLE_BLEND_SRC_SHIFT<;
 
 		if (ctx->Color.BlendEnabled)
 			blend |= NV04_TEXTURED_TRIANGLE_BLEND_BLEND_ENABLE;
diff --git a/src/mesa/drivers/dri/nouveau/nv04_state_tex.c b/src/mesa/drivers/dri/nouveau/nv04_state_tex.c
index 6d8762b..80b70ee 100644
--- a/src/mesa/drivers/dri/nouveau/nv04_state_tex.c
+++ b/src/mesa/drivers/dri/nouveau/nv04_state_tex.c
@@ -106,25 +106,25 @@ nv04_emit_tex_obj(GLcontext *ctx, int emit)
 					 t->LodBias, 0, 15);
 		}
 
-		format |= get_wrap_mode(t->WrapT) << 28 |
-			get_wrap_mode(t->WrapS) << 24 |
-			ti->HeightLog2 << 20 |
-			ti->WidthLog2 << 16 |
-			lod_max << 12 |
+		format |= get_wrap_mode(t->WrapT) << NV04_MULTITEX_TRIANGLE_FORMAT_ADDRESSV_SHIFT |
+			get_wrap_mode(t->WrapS) << NV04_MULTITEX_TRIANGLE_FORMAT_ADDRESSU_SHIFT |
+			ti->HeightLog2 << NV04_MULTITEX_TRIANGLE_FORMAT_BASE_SIZE_V_SHIFT |
+			ti->WidthLog2 << NV04_MULTITEX_TRIANGLE_FORMAT_BASE_SIZE_U_SHIFT |
+			lod_max << NV04_MULTITEX_TRIANGLE_FORMAT_MIPMAP_LEVELS_SHIFT |
 			get_tex_format(ti);
 
-		filter |= log2i(t->MaxAnisotropy) << 31 |
-			nvgl_filter_mode(t->MagFilter) << 28 |
-			log2i(t->MaxAnisotropy) << 27 |
-			nvgl_filter_mode(t->MinFilter) << 24 |
-			lod_bias << 16;
+		filter |= log2i(t->MaxAnisotropy) << NV04_MULTITEX_TRIANGLE_FILTER_ANISOTROPIC_MAGNIFY_ENABLE |
+			nvgl_filter_mode(t->MagFilter) << NV04_MULTITEX_TRIANGLE_FILTER_MAGNIFY_SHIFT |
+			log2i(t->MaxAnisotropy) << NV04_MULTITEX_TRIANGLE_FILTER_ANISOTROPIC_MINIFY_ENABLE |
+			nvgl_filter_mode(t->MinFilter) << NV04_MULTITEX_TRIANGLE_FILTER_MINIFY_SHIFT |
+			lod_bias << NV04_MULTITEX_TRIANGLE_FILTER_MIPMAP_LODBIAS_SHIFT;
 
 	} else {
 		s = &to_nv04_context(ctx)->dummy_texture;
 
 		format |= NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSU_REPEAT |
 			NV04_TEXTURED_TRIANGLE_FORMAT_ADDRESSV_REPEAT |
-			1 << 12 |
+			1 << NV04_TEXTURED_TRIANGLE_FORMAT_MIPMAP_LEVELS_SHIFT |
 			NV04_TEXTURED_TRIANGLE_FORMAT_COLOR_A8R8G8B8;
 
 		filter |= NV04_TEXTURED_TRIANGLE_FILTER_MINIFY_NEAREST |
-- 
1.7.0.2

Title: gl_blend_table
http://www.opengl.org/sdk/docs/man/xhtml/glTexEnv.xml



GL_BLEND as tn2 combiner input bindings

case  GL_RGB
ALPHA = GL_ALPHA_PREVIOUS.
alpha_input = [previous, 1, ZERO, 0]
RGB = RGB_previous * (INV  RGB_SOURCE) + RGB_CONST * RGB_SOURCE
rgb_input = [INV (texture), previous, const, texture]

case RGBA
ALPHA = ALPHA_PREVIOUS * ALPHA_SOURCE
alpha_input = [previous, 1,  texture, 1]
RGBA = RGB_previous * (INV RGB_SOURCE) + RGB_CONST * RGB_SOURCE
rgb_input = [INV (texture), previous, const, texture]
Title: texture_environment_combiners_NV_ATI_ARB
case GL_SUBTRACT:
<------> color_combine = (R200_TXC_ARG_B_ZERO |
<------><------><------>  R200_TXC_COMP_ARG_B |.
<------><------><------>  R200_TXC_NEG_ARG_C |
<------><------><------>  R200_TXC_OP_MADD);
<------> R200_COLOR_ARG( 0, A );
<------> R200_COLOR_ARG( 1, C );

<airlied> AndrewR: generally you have a negative bit, so you just feed in arg1 and negative arg2 and arg0 == 1
R200_TXC_NEG_ARG_A (1 << 19)

<AndrewR> so, for four-component input one can just set arg0 == arg3 == 1, then negate arg 2 and freed arg 1, and execute add (NV version)


case GL_ADD:
<------> color_combine = (R200_TXC_ARG_B_ZERO |
<------><------><------>  R200_TXC_COMP_ARG_B |.
<------><------><------>  R200_TXC_OP_MADD);
<------> R200_COLOR_ARG( 0, A );
<------> R200_COLOR_ARG( 1, C );

ARB_texture_env_combine operations in terms of NV_texture_env_combine4 NV extension:
REPLACE                 Arg0 = 
ADD Arg0 * Arg1 + Arg2 * Arg3 (arg0, 1, 1, 0)


MODULATE Arg0 * Arg1 =
ADD Arg0 * Arg1 + Arg2 * Arg3 (arg0, arg1, 1, 0)

ADD Arg0 + Arg1 =
ADD Arg0 * Arg1 + Arg2 * Arg3 (arg0, 1, arg1, 1)

ADD_SIGNED_ARB Arg0 + Arg1 - 0.5 =
ADD_SIGNED_EXT Arg0 * Arg1 + Arg2 * Arg3 - 0.5 (arg0, 1, 1, arg1)

SUBTRACT_ARB Arg0 - Arg1 =
ADD Arg0 * Arg1 + Arg2 * Arg3 (arg0, 1, INV(arg1), 1)

MODULATE_ADD_ATI Arg0 * Arg2 + Arg1 =
ADD Arg0 * Arg1 + Arg2 * Arg3 (arg0, arg1, arg1, 1)

MODULATE_SIGNED_ADD_ATI Arg0 * Arg2 + Arg1 - 0.5 =
ADD_SIGNED_EXT Arg0 * Arg1 + Arg2 * Arg3 - 0.5 (arg0, arg2, arg1, 1)


MODULATE_SUBTRACT_ATI Arg0 * Arg2 - Arg1 =
ADD Arg0 * Arg1 + Arg2 * Arg3 (arg0, arg2, INV(arg1), 1)


INTERPOLATE_ARB Arg0 * (Arg2) + Arg1 * (1-Arg2) =
ADD Arg0 * Arg1 + Arg2 * Arg3 (arg0, arg2, arg1, INV(arg2))


_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/nouveau

Reply via email to