[WINED3D 1/13] Resend: Move program_dump_decl_usage into baseshader

Jason Green jave27 at gmail.com
Tue May 9 21:26:05 CDT 2006


The following 13 patches include 11 previously sent patches, and all
apply directly on top of the latest git tree after Ivan's 5 wined3d
patches that were sent earlier today.  The entire patchset is a no-op
from a functionality standpoint, and only improves tracing and code
organization.  The last two patches set the framework for GLSL
implementation, but that functionality has been disabled with a
"#define USING_GLSL 0".

Changelog
=======

This patch has been modified to include Ivan's TRACE patch that was
also sent today.

Both pixel and vertex shaders use an identical function to display
debug traces of the D3DSIO_DCL opcode.  This consolidates them into a
single function in the new baseshader.c file.  Also, they were passing
a reference to their interface previously which never not used, so
that has been removed.
-------------- next part --------------
Subject: [PATCH 01/13] Move program_dump_decl_usage into baseshader

- Also updates some TRACEs to remove extra whitespaces (from Ivan Gyurdiev's patch)

---

 dlls/wined3d/baseshader.c      |   75 ++++++++++++++++++++++++++++++
 dlls/wined3d/pixelshader.c     |   99 +++++++---------------------------------
 dlls/wined3d/vertexshader.c    |   79 +-------------------------------
 dlls/wined3d/wined3d_private.h |    4 ++
 4 files changed, 100 insertions(+), 157 deletions(-)

180c703b4c3054f967af2c407880729ee086da52
diff --git a/dlls/wined3d/baseshader.c b/dlls/wined3d/baseshader.c
index 1691151..b065336 100644
--- a/dlls/wined3d/baseshader.c
+++ b/dlls/wined3d/baseshader.c
@@ -159,4 +159,79 @@ void shader_get_registers_used(
     }
 }
 
+void shader_program_dump_decl_usage(
+    DWORD decl, 
+    DWORD param) {
+
+    DWORD regtype = shader_get_regtype(param);
+    TRACE("dcl_");
+
+    if (regtype == D3DSPR_SAMPLER) {
+        DWORD ttype = decl & D3DSP_TEXTURETYPE_MASK;
+
+        switch (ttype) {
+            case D3DSTT_2D: TRACE("2d"); break;
+            case D3DSTT_CUBE: TRACE("cube"); break;
+            case D3DSTT_VOLUME: TRACE("volume"); break;
+            default: TRACE("unknown_ttype(%08lx)", ttype); 
+       }
+
+    } else { 
+
+        DWORD usage = decl & D3DSP_DCL_USAGE_MASK;
+        DWORD idx = (decl & D3DSP_DCL_USAGEINDEX_MASK) >> D3DSP_DCL_USAGEINDEX_SHIFT;
+
+        switch(usage) {
+        case D3DDECLUSAGE_POSITION:
+            TRACE("%s%ld", "position", idx);
+            break;
+        case D3DDECLUSAGE_BLENDINDICES:
+            TRACE("%s", "blend");
+            break;
+        case D3DDECLUSAGE_BLENDWEIGHT:
+            TRACE("%s", "weight");
+            break;
+        case D3DDECLUSAGE_NORMAL:
+            TRACE("%s%ld", "normal", idx);
+            break;
+        case D3DDECLUSAGE_PSIZE:
+            TRACE("%s", "psize");
+            break;
+        case D3DDECLUSAGE_COLOR:
+            if(idx == 0)  {
+                TRACE("%s", "color");
+            } else {
+                TRACE("%s%ld", "specular", (idx - 1));
+            }
+            break;
+        case D3DDECLUSAGE_TEXCOORD:
+            TRACE("%s%ld", "texture", idx);
+            break;
+        case D3DDECLUSAGE_TANGENT:
+            TRACE("%s", "tangent");
+            break;
+        case D3DDECLUSAGE_BINORMAL:
+            TRACE("%s", "binormal");
+            break;
+        case D3DDECLUSAGE_TESSFACTOR:
+            TRACE("%s", "tessfactor");
+            break;
+        case D3DDECLUSAGE_POSITIONT:
+            TRACE("%s%ld", "positionT", idx);
+            break;
+        case D3DDECLUSAGE_FOG:
+            TRACE("%s", "fog");
+            break;
+        case D3DDECLUSAGE_DEPTH:
+            TRACE("%s", "depth");
+            break;
+        case D3DDECLUSAGE_SAMPLE:
+            TRACE("%s", "sample");
+            break;
+        default:
+            FIXME("unknown_semantics(%08lx)", usage);
+        }
+    }
+}
+
 /* TODO: Move other shared code here */
diff --git a/dlls/wined3d/pixelshader.c b/dlls/wined3d/pixelshader.c
index e00eebf..4a0ddbe 100644
--- a/dlls/wined3d/pixelshader.c
+++ b/dlls/wined3d/pixelshader.c
@@ -962,7 +962,7 @@ void pshader_set_version(
                    This->baseShader.limits.constant_int = 0;
                    This->baseShader.limits.constant_bool = 0;
                    This->baseShader.limits.texture = 8;
-                   FIXME("Unrecognized pixel shader version %lu!\n", version);
+                   FIXME("Unrecognized pixel shader version %lx!\n", version);
       }
 }
 
@@ -1606,80 +1606,6 @@ inline static void pshader_program_dump_
     }
 }
 
-inline static void pshader_program_dump_decl_usage(
-    IWineD3DPixelShaderImpl *This, DWORD decl, DWORD param) {
-
-    DWORD regtype = shader_get_regtype(param);
-    TRACE("dcl_");
-
-    if (regtype == D3DSPR_SAMPLER) {
-        DWORD ttype = decl & D3DSP_TEXTURETYPE_MASK;
-
-        switch (ttype) {
-            case D3DSTT_2D: TRACE("2d "); break;
-            case D3DSTT_CUBE: TRACE("cube "); break;
-            case D3DSTT_VOLUME: TRACE("volume "); break;
-            default: TRACE("unknown_ttype(%08lx) ", ttype); 
-       }
-
-    } else { 
-
-        DWORD usage = decl & D3DSP_DCL_USAGE_MASK;
-        DWORD idx = (decl & D3DSP_DCL_USAGEINDEX_MASK) >> D3DSP_DCL_USAGEINDEX_SHIFT;
-
-        switch(usage) {
-        case D3DDECLUSAGE_POSITION:
-            TRACE("%s%ld ", "position", idx);
-            break;
-        case D3DDECLUSAGE_BLENDINDICES:
-            TRACE("%s ", "blend");
-            break;
-        case D3DDECLUSAGE_BLENDWEIGHT:
-            TRACE("%s ", "weight");
-            break;
-        case D3DDECLUSAGE_NORMAL:
-            TRACE("%s%ld ", "normal", idx);
-            break;
-        case D3DDECLUSAGE_PSIZE:
-            TRACE("%s ", "psize");
-            break;
-        case D3DDECLUSAGE_COLOR:
-            if(idx == 0)  {
-                TRACE("%s ", "color");
-            } else {
-                TRACE("%s%ld ", "specular", (idx - 1));
-            }
-            break;
-        case D3DDECLUSAGE_TEXCOORD:
-            TRACE("%s%ld ", "texture", idx);
-            break;
-        case D3DDECLUSAGE_TANGENT:
-            TRACE("%s ", "tangent");
-            break;
-        case D3DDECLUSAGE_BINORMAL:
-            TRACE("%s ", "binormal");
-            break;
-        case D3DDECLUSAGE_TESSFACTOR:
-            TRACE("%s ", "tessfactor");
-            break;
-        case D3DDECLUSAGE_POSITIONT:
-            TRACE("%s%ld ", "positionT", idx);
-            break;
-        case D3DDECLUSAGE_FOG:
-            TRACE("%s ", "fog");
-            break;
-        case D3DDECLUSAGE_DEPTH:
-            TRACE("%s ", "depth");
-            break;
-        case D3DDECLUSAGE_SAMPLE:
-            TRACE("%s ", "sample");
-            break;
-        default:
-            FIXME("Unrecognised dcl %08lx", usage);
-        }
-    }
-}
-
 HRESULT WINAPI IWineD3DPixelShaderImpl_SetFunction(IWineD3DPixelShader *iface, CONST DWORD *pFunction) {
     IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface;
     const DWORD* pToken = pFunction;
@@ -1724,12 +1650,23 @@ HRESULT WINAPI IWineD3DPixelShaderImpl_S
 
             } else {
                 if (curOpcode->opcode == D3DSIO_DCL) {
-                    pshader_program_dump_decl_usage(This, *pToken, *(pToken + 1));
-                    ++pToken;
-                    ++len;
-                    pshader_program_dump_ps_param(*pToken, 0);
-                    ++pToken;
-                    ++len;
+                    DWORD usage = *pToken;
+                    DWORD param = *(pToken + 1);
+                    DWORD regtype = shader_get_regtype(param);
+
+                    /* Only print extended declaration for samplers or 3.0 input registers */
+                    if (regtype == D3DSPR_SAMPLER ||
+                        (This->baseShader.version >= 30 && regtype == D3DSPR_INPUT))
+                         shader_program_dump_decl_usage(usage, param);
+                    else
+                         TRACE("dcl");
+
+                    pshader_program_dump_ins_modifiers(param);
+                    TRACE(" ");
+                    pshader_program_dump_ps_param(param, 0);
+                    pToken += 2;
+                    len += 2;
+
                 } else 
                     if (curOpcode->opcode == D3DSIO_DEF) {
                         TRACE("def c%lu = ", *pToken & 0xFF);
diff --git a/dlls/wined3d/vertexshader.c b/dlls/wined3d/vertexshader.c
index 770242c..37ae8f7 100644
--- a/dlls/wined3d/vertexshader.c
+++ b/dlls/wined3d/vertexshader.c
@@ -647,80 +647,6 @@ inline static void vshader_program_dump_
   }
 }
 
-inline static void vshader_program_dump_decl_usage(
-    IWineD3DVertexShaderImpl *This, DWORD decl, DWORD param) {
-    DWORD regtype = shader_get_regtype(param);
-
-    TRACE("dcl_");
-
-    if (regtype == D3DSPR_SAMPLER) {
-        DWORD ttype = decl & D3DSP_TEXTURETYPE_MASK;
-
-        switch (ttype) {
-            case D3DSTT_2D: TRACE("2d "); break;
-            case D3DSTT_CUBE: TRACE("cube "); break;
-            case D3DSTT_VOLUME: TRACE("volume "); break;
-            default: TRACE("unknown_ttype(%08lx) ", ttype);
-       }
-
-    } else {
-
-        DWORD usage = decl & D3DSP_DCL_USAGE_MASK;
-        DWORD idx = (decl & D3DSP_DCL_USAGEINDEX_MASK) >> D3DSP_DCL_USAGEINDEX_SHIFT;
-
-        switch(usage) {
-        case D3DDECLUSAGE_POSITION:
-            TRACE("%s%ld ", "position", idx);
-            break;
-        case D3DDECLUSAGE_BLENDINDICES:
-            TRACE("%s ", "blend");
-            break;
-        case D3DDECLUSAGE_BLENDWEIGHT:
-            TRACE("%s ", "weight");
-            break;
-        case D3DDECLUSAGE_NORMAL:
-            TRACE("%s%ld ", "normal", idx);
-            break;
-        case D3DDECLUSAGE_PSIZE:
-            TRACE("%s ", "psize");
-            break;
-        case D3DDECLUSAGE_COLOR:
-            if(idx == 0)  {
-                TRACE("%s ", "color");
-            } else {
-                TRACE("%s ", "specular");
-            }
-            break;
-        case D3DDECLUSAGE_TEXCOORD:
-            TRACE("%s%ld ", "texture", idx);
-            break;
-        case D3DDECLUSAGE_TANGENT:
-            TRACE("%s ", "tangent");
-            break;
-        case D3DDECLUSAGE_BINORMAL:
-            TRACE("%s ", "binormal");
-            break;
-        case D3DDECLUSAGE_TESSFACTOR:
-            TRACE("%s ", "tessfactor");
-            break;
-        case D3DDECLUSAGE_POSITIONT:
-            TRACE("%s%ld ", "positionT", idx);
-            break;
-        case D3DDECLUSAGE_FOG:
-            TRACE("%s ", "fog");
-            break;
-        case D3DDECLUSAGE_DEPTH:
-            TRACE("%s ", "depth");
-            break;
-        case D3DDECLUSAGE_SAMPLE:
-            TRACE("%s ", "sample");
-            break;
-        default:
-            FIXME("Unrecognised dcl %08lx", usage);
-        }
-    }
-}
-
 inline static BOOL vshader_is_version_token(DWORD token) {
   return 0xFFFE0000 == (token & 0xFFFE0000);
 }
@@ -1069,7 +995,7 @@ void vshader_set_version(
                    This->baseShader.limits.constant_bool = 0;
                    This->baseShader.limits.constant_int = 0;
                    This->baseShader.limits.address = 1;
-                   FIXME("Unrecognized vertex shader version %lu!\n", version);
+                   FIXME("Unrecognized vertex shader version %lx!\n", version);
       }
 }
 
@@ -1821,7 +1747,8 @@ HRESULT WINAPI IWineD3DVertexShaderImpl_
                     DWORD param = *(pToken + 1);
 
                     parse_decl_usage(This, usage, param & D3DSP_REGNUM_MASK);
-                    vshader_program_dump_decl_usage(This, usage, param);
+                    shader_program_dump_decl_usage(usage, param);
+                    TRACE(" ");
                     vshader_program_dump_vs_param(param, 0);
                     pToken += 2;
                     len += 2;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index c6a598c..d02974a 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1275,6 +1275,10 @@ extern void shader_get_registers_used(
     DWORD* tempsUsed,
     DWORD* texUsed);
 
+extern void shader_program_dump_decl_usage(
+    DWORD dcl,
+    DWORD param);
+
 inline static int shader_get_regtype(const DWORD param) {
     return (((param & D3DSP_REGTYPE_MASK) >> D3DSP_REGTYPE_SHIFT) |
             ((param & D3DSP_REGTYPE_MASK2) >> D3DSP_REGTYPE_SHIFT2));
-- 
1.1.3


More information about the wine-patches mailing list