[3/4] WINED3D: Move the vshader_ins and pshader_ins arrays into their respective objects

H. Verbeet hverbeet at gmail.com
Tue Mar 28 13:10:44 CST 2006


This is mainly usefull for merging the pixel and vertex shader code.

Changelog:
  - Move the vshader_ins and pshader_ins arrays into their respective objects
-------------- next part --------------
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index ec38313..58a0df4 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1620,6 +1620,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_Create
     IWineD3DVertexShaderImpl *object;  /* NOTE: impl usage is ok, this is a create */
     HRESULT hr = D3D_OK;
     D3DCREATEOBJECTINSTANCE(object, VertexShader)
+    object->shader_ins = IWineD3DVertexShaderImpl_shader_ins;
 
     TRACE("(%p) : Created Vertex shader %p\n", This, *ppVertexShader);
 
@@ -1664,6 +1665,7 @@ HRESULT WINAPI IWineD3DDeviceImpl_Create
     HRESULT hr = D3D_OK;
 
     D3DCREATEOBJECTINSTANCE(object, PixelShader)
+    object->shader_ins = IWineD3DPixelShaderImpl_shader_ins;
     hr = IWineD3DPixelShader_SetFunction(*ppPixelShader, pFunction);
     if (D3D_OK == hr) {
         TRACE("(%p) : Created Pixel shader %p\n", This, *ppPixelShader);
diff --git a/dlls/wined3d/pixelshader.c b/dlls/wined3d/pixelshader.c
index 64fe501..89fe4b9 100644
--- a/dlls/wined3d/pixelshader.c
+++ b/dlls/wined3d/pixelshader.c
@@ -629,7 +629,7 @@ void pshader_breakp(WINED3DSHADERVECTOR*
 /**
  * log, exp, frc, m*x* seems to be macros ins ... to see
  */
-static CONST SHADER_OPCODE pshader_ins [] = {
+CONST SHADER_OPCODE IWineD3DPixelShaderImpl_shader_ins[] = {
     {D3DSIO_NOP,  "nop", "NOP", 0, pshader_nop, 0, 0},
     {D3DSIO_MOV,  "mov", "MOV", 2, pshader_mov, 0, 0},
     {D3DSIO_ADD,  "add", "ADD", 3, pshader_add, 0, 0},
@@ -746,12 +746,14 @@ inline static const SHADER_OPCODE* pshad
     DWORD i = 0;
     DWORD version = This->version;
     DWORD hex_version = D3DPS_VERSION(version/10, version%10);
+    const SHADER_OPCODE *shader_ins = This->shader_ins;
+
     /** TODO: use dichotomic search */
-    while (NULL != pshader_ins[i].name) {
-        if (((code & D3DSI_OPCODE_MASK) == pshader_ins[i].opcode) &&
-            (((hex_version >= pshader_ins[i].min_version) && (hex_version <= pshader_ins[i].max_version)) ||
-            ((pshader_ins[i].min_version == 0) && (pshader_ins[i].max_version == 0)))) {
-            return &pshader_ins[i];
+    while (NULL != shader_ins[i].name) {
+        if (((code & D3DSI_OPCODE_MASK) == shader_ins[i].opcode) &&
+            (((hex_version >= shader_ins[i].min_version) && (hex_version <= shader_ins[i].max_version)) ||
+            ((shader_ins[i].min_version == 0) && (shader_ins[i].max_version == 0)))) {
+            return &shader_ins[i];
         }
         ++i;
     }
diff --git a/dlls/wined3d/vertexshader.c b/dlls/wined3d/vertexshader.c
index cfa8f2e..0fd74e3 100644
--- a/dlls/wined3d/vertexshader.c
+++ b/dlls/wined3d/vertexshader.c
@@ -582,7 +582,7 @@ void vshader_breakp(WINED3DSHADERVECTOR*
 /**
  * log, exp, frc, m*x* seems to be macros ins ... to see
  */
-static CONST SHADER_OPCODE vshader_ins [] = {
+CONST SHADER_OPCODE IWineD3DVertexShaderImpl_shader_ins[] = {
     {D3DSIO_NOP,  "nop", "NOP", 0, vshader_nop, 0, 0},
     {D3DSIO_MOV,  "mov", "MOV", 2, vshader_mov, 0, 0},
     {D3DSIO_ADD,  "add", "ADD", 3, vshader_add, 0, 0},
@@ -691,12 +691,14 @@ static CONST SHADER_OPCODE vshader_ins [
 };
 
 
-inline static const SHADER_OPCODE* vshader_program_get_opcode(const DWORD code) {
+inline static const SHADER_OPCODE* vshader_program_get_opcode(IWineD3DVertexShaderImpl *This, const DWORD code) {
     DWORD i = 0;
+    const SHADER_OPCODE *shader_ins = This->shader_ins;
+
     /** TODO: use dichotomic search or hash table */
-    while (NULL != vshader_ins[i].name) {
-        if ((code & D3DSI_OPCODE_MASK) == vshader_ins[i].opcode) {
-            return &vshader_ins[i];
+    while (NULL != shader_ins[i].name) {
+        if ((code & D3DSI_OPCODE_MASK) == shader_ins[i].opcode) {
+            return &shader_ins[i];
         }
         ++i;
     }
@@ -1305,7 +1307,7 @@ inline static VOID IWineD3DVertexShaderI
                 pToken += comment_len;
                 continue;
             }
-            curOpcode = vshader_program_get_opcode(*pToken);
+            curOpcode = vshader_program_get_opcode(This, *pToken);
             ++pToken;
             /* TODO: dcl's */
             /* TODO: Consts */
@@ -1485,7 +1487,7 @@ inline static VOID IWineD3DVertexShaderI
             continue;
       }
 
-      curOpcode = vshader_program_get_opcode(*pToken);
+      curOpcode = vshader_program_get_opcode(This, *pToken);
       ++pToken;
       if (NULL == curOpcode) {
         /* unknown current opcode ... (shouldn't be any!) */
@@ -1781,7 +1783,7 @@ HRESULT WINAPI IWineD3DVertexShaderImpl_
             pToken += comment_len;
             continue ;
         }
-        curOpcode = vshader_program_get_opcode(*pToken);
+        curOpcode = vshader_program_get_opcode(This, *pToken);
         ++pToken;
         if (NULL == curOpcode) {
             i = 0;
@@ -2129,7 +2131,7 @@ HRESULT WINAPI IWineD3DVertexShaderImpl_
                 len += comment_len + 1;
                 continue;
             }
-            curOpcode = vshader_program_get_opcode(*pToken);
+            curOpcode = vshader_program_get_opcode(This, *pToken);
             ++pToken;
             ++len;
             if (NULL == curOpcode) {
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index b199f18..9ba09a2 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1181,6 +1181,7 @@ typedef struct IWineD3DVertexShaderImpl 
     IWineD3DDeviceImpl          *wineD3DDevice;
 
     /* IWineD3DVertexShaderImpl */
+    CONST SHADER_OPCODE         *shader_ins;
     CONST DWORD                 *function;
     UINT                         functionLength;
 
@@ -1204,6 +1205,7 @@ typedef struct IWineD3DVertexShaderImpl 
     VSHADEROUTPUTDATA output;
 #endif
 } IWineD3DVertexShaderImpl;
+extern const SHADER_OPCODE IWineD3DVertexShaderImpl_shader_ins[];
 extern const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl;
 
 /*****************************************************************************
@@ -1218,6 +1220,7 @@ typedef struct IWineD3DPixelShaderImpl {
     IWineD3DDeviceImpl         *wineD3DDevice;
 
     /* IWineD3DPixelShaderImpl */
+    const SHADER_OPCODE         *shader_ins;
     CONST DWORD                *function;
     UINT                        functionLength;
     DWORD                       version;
@@ -1233,5 +1236,6 @@ typedef struct IWineD3DPixelShaderImpl {
 #endif
 } IWineD3DPixelShaderImpl;
 
+extern const SHADER_OPCODE IWineD3DPixelShaderImpl_shader_ins[];
 extern const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl;
 #endif



More information about the wine-patches mailing list