[PATCH] WineD3D: Give the nvts/nvrc code its own pipeline =

Stefan Doesinger stefan at codeweavers.com
Fri Jul 4 16:15:18 CDT 2008


implementation=0A=
=0A=
This code creates the structures and the pipeline selection, as well as =
the caps filling. It does not yet move the=0A=
actual code around, since this will be a bigger task.=0A=
---=0A=
 dlls/wined3d/Makefile.in             |    1 +=0A=
 dlls/wined3d/directx.c               |    7 ++-=0A=
 dlls/wined3d/nvidia_texture_shader.c |  119 =
++++++++++++++++++++++++++++++++++=0A=
 dlls/wined3d/state.c                 |   19 +-----=0A=
 dlls/wined3d/wined3d_private.h       |    4 +=0A=
 5 files changed, 133 insertions(+), 17 deletions(-)=0A=
 create mode 100644 dlls/wined3d/nvidia_texture_shader.c=0A=
=0A=
diff --git a/dlls/wined3d/Makefile.in b/dlls/wined3d/Makefile.in=0A=
index 61acef9..d09e88b 100644=0A=
--- a/dlls/wined3d/Makefile.in=0A=
+++ b/dlls/wined3d/Makefile.in=0A=
@@ -19,6 +19,7 @@ C_SRCS =3D \=0A=
 	drawprim.c \=0A=
 	glsl_shader.c \=0A=
 	indexbuffer.c \=0A=
+	nvidia_texture_shader.c \=0A=
 	palette.c \=0A=
 	pixelshader.c \=0A=
 	query.c \=0A=
diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c=0A=
index 0a6cec3..4b38291 100644=0A=
--- a/dlls/wined3d/directx.c=0A=
+++ b/dlls/wined3d/directx.c=0A=
@@ -2894,8 +2894,13 @@ static const struct fragment_pipeline =
*select_fragment_implementation(UINT Adapt=0A=
     select_shader_mode(&GLINFO_LOCATION, DeviceType, &ps_selected_mode, =
&vs_selected_mode);=0A=
     if(ps_selected_mode =3D=3D SHADER_ATI) {=0A=
         return &atifs_fragment_pipeline;=0A=
+    } else if(GL_SUPPORT(NV_REGISTER_COMBINERS) && =
GL_SUPPORT(NV_TEXTURE_SHADER2)) {=0A=
+        return &nvts_fragment_pipeline;=0A=
+    } else if(GL_SUPPORT(NV_REGISTER_COMBINERS)) {=0A=
+        return &nvrc_fragment_pipeline;=0A=
+    } else {=0A=
+        return &ffp_fragment_pipeline;=0A=
     }=0A=
-    return &ffp_fragment_pipeline;=0A=
 }=0A=
 =0A=
 /* Note: d3d8 passes in a pointer to a D3DCAPS8 structure, which is a =
true=0A=
diff --git a/dlls/wined3d/nvidia_texture_shader.c =
b/dlls/wined3d/nvidia_texture_shader.c=0A=
new file mode 100644=0A=
index 0000000..5058ab4=0A=
--- /dev/null=0A=
+++ b/dlls/wined3d/nvidia_texture_shader.c=0A=
@@ -0,0 +1,119 @@=0A=
+/*=0A=
+ * Fixed function pipeline replacement using GL_NV_register_combiners=0A=
+ * and GL_NV_texture_shader=0A=
+ *=0A=
+ * Copyright 2006 Henri Verbeet=0A=
+ * Copyright 2008 Stefan D=F6singer(for CodeWeavers)=0A=
+ *=0A=
+ * This library is free software; you can redistribute it and/or=0A=
+ * modify it under the terms of the GNU Lesser General Public=0A=
+ * License as published by the Free Software Foundation; either=0A=
+ * version 2.1 of the License, or (at your option) any later version.=0A=
+ *=0A=
+ * This library is distributed in the hope that it will be useful,=0A=
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of=0A=
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU=0A=
+ * Lesser General Public License for more details.=0A=
+ *=0A=
+ * You should have received a copy of the GNU Lesser General Public=0A=
+ * License along with this library; if not, write to the Free Software=0A=
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA =
02110-1301, USA=0A=
+ */=0A=
+#include "config.h"=0A=
+=0A=
+#include <math.h>=0A=
+#include <stdio.h>=0A=
+=0A=
+#include "wined3d_private.h"=0A=
+=0A=
+WINE_DEFAULT_DEBUG_CHANNEL(d3d);=0A=
+=0A=
+#define GLINFO_LOCATION (*gl_info)=0A=
+static void nvrc_enable(IWineD3DDevice *iface, BOOL enable) { }=0A=
+=0A=
+static void nvts_enable(IWineD3DDevice *iface, BOOL enable) {=0A=
+    if(enable) {=0A=
+        glEnable(GL_TEXTURE_SHADER_NV);=0A=
+        checkGLcall("glEnable(GL_TEXTURE_SHADER_NV)");=0A=
+    } else {=0A=
+        glDisable(GL_TEXTURE_SHADER_NV);=0A=
+        checkGLcall("glDisable(GL_TEXTURE_SHADER_NV)");=0A=
+    }=0A=
+}=0A=
+=0A=
+static void nvrc_fragment_get_caps(WINED3DDEVTYPE devtype, =
WineD3D_GL_Info *gl_info, struct fragment_caps *pCaps) {=0A=
+    pCaps->TextureOpCaps =3D  WINED3DTEXOPCAPS_ADD                      =
  |=0A=
+                            WINED3DTEXOPCAPS_ADDSIGNED                  =
|=0A=
+                            WINED3DTEXOPCAPS_ADDSIGNED2X                =
|=0A=
+                            WINED3DTEXOPCAPS_MODULATE                   =
|=0A=
+                            WINED3DTEXOPCAPS_MODULATE2X                 =
|=0A=
+                            WINED3DTEXOPCAPS_MODULATE4X                 =
|=0A=
+                            WINED3DTEXOPCAPS_SELECTARG1                 =
|=0A=
+                            WINED3DTEXOPCAPS_SELECTARG2                 =
|=0A=
+                            WINED3DTEXOPCAPS_DISABLE                    =
|=0A=
+                            WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA          =
|=0A=
+                            WINED3DTEXOPCAPS_BLENDTEXTUREALPHA          =
|=0A=
+                            WINED3DTEXOPCAPS_BLENDFACTORALPHA           =
|=0A=
+                            WINED3DTEXOPCAPS_BLENDCURRENTALPHA          =
|=0A=
+                            WINED3DTEXOPCAPS_LERP                       =
|=0A=
+                            WINED3DTEXOPCAPS_SUBTRACT                   =
|=0A=
+                            WINED3DTEXOPCAPS_ADDSMOOTH                  =
|=0A=
+                            WINED3DTEXOPCAPS_MULTIPLYADD                =
|=0A=
+                            WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR     =
|=0A=
+                            WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA     =
|=0A=
+                            WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM        =
|=0A=
+                            WINED3DTEXOPCAPS_DOTPRODUCT3                =
|=0A=
+                            WINED3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR  =
|=0A=
+                            WINED3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA;=0A=
+=0A=
+    if(GL_SUPPORT(NV_TEXTURE_SHADER2)) {=0A=
+        /* Bump mapping is supported already in NV_TEXTURE_SHADER, but =
that extension does=0A=
+         * not support 3D textures. This asks for trouble if an app =
uses both bump mapping=0A=
+         * and 3D textures. It also allows us to keep the code simpler =
by having texture=0A=
+         * shaders constantly enabled.=0A=
+         */=0A=
+        pCaps->TextureOpCaps |=3D WINED3DTEXOPCAPS_BUMPENVMAP;=0A=
+        /* TODO: Luminance bump map? */=0A=
+    }=0A=
+=0A=
+#if 0=0A=
+    /* FIXME: Add=0A=
+            pCaps->TextureOpCaps |=3D =
WINED3DTEXOPCAPS_BUMPENVMAPLUMINANCE=0A=
+            WINED3DTEXOPCAPS_PREMODULATE */=0A=
+#endif=0A=
+=0A=
+    pCaps->MaxTextureBlendStages   =3D GL_LIMITS(texture_stages);=0A=
+    pCaps->MaxSimultaneousTextures =3D GL_LIMITS(textures);=0A=
+=0A=
+    pCaps->PrimitiveMiscCaps |=3D  WINED3DPMISCCAPS_TSSARGTEMP;=0A=
+=0A=
+    /* The caps below can be supported but aren't handled yet in =
utils.c 'd3dta_to_combiner_input', disable them until support is fixed */=0A=
+#if 0=0A=
+    if (GL_SUPPORT(NV_REGISTER_COMBINERS2))=0A=
+    pCaps->PrimitiveMiscCaps |=3D  WINED3DPMISCCAPS_PERSTAGECONSTANT;=0A=
+#endif=0A=
+}=0A=
+=0A=
+static HRESULT nvrc_fragment_alloc(IWineD3DDevice *iface) { return =
WINED3D_OK; }=0A=
+static void nvrc_fragment_free(IWineD3DDevice *iface) {}=0A=
+=0A=
+/* Two fixed function pipeline implementations using =
GL_NV_register_combiners and=0A=
+ * GL_NV_texture_shader. The nvts_fragment_pipeline assumes that both =
extensions=0A=
+ * are available(geforce 3 and newer), while nvrc_fragment_pipeline =
uses only the=0A=
+ * register combiners extension(Pre-GF3).=0A=
+ */=0A=
+const struct fragment_pipeline nvts_fragment_pipeline =3D {=0A=
+    nvts_enable,=0A=
+    nvrc_fragment_get_caps,=0A=
+    nvrc_fragment_alloc,=0A=
+    nvrc_fragment_free,=0A=
+    ffp_fragmentstate_template=0A=
+};=0A=
+=0A=
+const struct fragment_pipeline nvrc_fragment_pipeline =3D {=0A=
+    nvrc_enable,=0A=
+    nvrc_fragment_get_caps,=0A=
+    nvrc_fragment_alloc,=0A=
+    nvrc_fragment_free,=0A=
+    ffp_fragmentstate_template=0A=
+};=0A=
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c=0A=
index d1d64fe..56fe01b 100644=0A=
--- a/dlls/wined3d/state.c=0A=
+++ b/dlls/wined3d/state.c=0A=
@@ -4311,7 +4311,7 @@ const struct StateEntryTemplate =
ffp_vertexstate_template[] =3D {=0A=
     {0 /* Terminate */,                                   { 0,          =
                                        0                   }},=0A=
 };=0A=
 =0A=
-static const struct StateEntryTemplate ffp_fragmentstate_template[] =3D =
{=0A=
+const struct StateEntryTemplate ffp_fragmentstate_template[] =3D {=0A=
     { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          { =
STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          tex_colorop         =
}},=0A=
     { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1),        { =
STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          tex_colorop         =
}},=0A=
     { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2),        { =
STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP),          tex_colorop         =
}},=0A=
@@ -4465,20 +4465,7 @@ static const struct StateEntryTemplate =
ffp_fragmentstate_template[] =3D {=0A=
 #undef GLINFO_LOCATION=0A=
 =0A=
 #define GLINFO_LOCATION (*gl_info)=0A=
-static void nvts_enable(IWineD3DDevice *iface, BOOL enable) {=0A=
-    IWineD3DDeviceImpl *This =3D (IWineD3DDeviceImpl *) iface;=0A=
-    WineD3D_GL_Info *gl_info =3D &This->adapter->gl_info;=0A=
-=0A=
-    if(GL_SUPPORT(NV_TEXTURE_SHADER2)) {=0A=
-        if(enable) {=0A=
-            glEnable(GL_TEXTURE_SHADER_NV);=0A=
-            checkGLcall("glEnable(GL_TEXTURE_SHADER_NV)");=0A=
-        } else {=0A=
-            glDisable(GL_TEXTURE_SHADER_NV);=0A=
-            checkGLcall("glDisable(GL_TEXTURE_SHADER_NV)");=0A=
-        }=0A=
-    }=0A=
-}=0A=
+static void ffp_enable(IWineD3DDevice *iface, BOOL enable) { }=0A=
 =0A=
 static void ffp_fragment_get_caps(WINED3DDEVTYPE devtype, =
WineD3D_GL_Info *gl_info, struct fragment_caps *pCaps) {=0A=
     pCaps->TextureOpCaps =3D  WINED3DTEXOPCAPS_ADD         |=0A=
@@ -4556,7 +4543,7 @@ static void ffp_fragment_free(IWineD3DDevice =
*iface) {}=0A=
 #undef GLINFO_LOCATION=0A=
 =0A=
 const struct fragment_pipeline ffp_fragment_pipeline =3D {=0A=
-    nvts_enable,=0A=
+    ffp_enable,=0A=
     ffp_fragment_get_caps,=0A=
     ffp_fragment_alloc,=0A=
     ffp_fragment_free,=0A=
diff --git a/dlls/wined3d/wined3d_private.h =
b/dlls/wined3d/wined3d_private.h=0A=
index 5c067ed..05952d7 100644=0A=
--- a/dlls/wined3d/wined3d_private.h=0A=
+++ b/dlls/wined3d/wined3d_private.h=0A=
@@ -560,6 +560,10 @@ extern const struct StateEntryTemplate =
misc_state_template[];=0A=
 extern const struct StateEntryTemplate ffp_vertexstate_template[];=0A=
 extern const struct fragment_pipeline ffp_fragment_pipeline;=0A=
 extern const struct fragment_pipeline atifs_fragment_pipeline;=0A=
+extern const struct fragment_pipeline nvts_fragment_pipeline;=0A=
+extern const struct fragment_pipeline nvrc_fragment_pipeline;=0A=
+=0A=
+extern const struct StateEntryTemplate ffp_fragmentstate_template[]; /* =
temporary */=0A=
 =0A=
 /* "Base" state table */=0A=
 void compile_state_table(struct StateEntry *StateTable,=0A=
-- =0A=
1.5.4.5=0A=
=0A=

------=_NextPart_000_0021_01C8E33C.8124BAB0--




More information about the wine-patches mailing list