[WINED3D] Read GL info and load constants into the same device

Ivan Gyurdiev ivg231 at gmail.com
Wed Sep 27 06:15:58 CDT 2006


 
Type: Cleanup/bugfix
 
Why:
The GL info is read from the device obtained by upwards pointer from the 
stateblock.
The constants are loaded into the device obtained by upwards pointer 
from the vertex shader.

This is unnecessarily confused - patch removes all use of upwards 
pointers in that function, and reverts to top-down model of passing data 
from caller to callee. It passes the device as an argument.

-------------- next part --------------
---
 dlls/wined3d/arb_program_shader.c |   10 +++++-----
 dlls/wined3d/drawprim.c           |    4 ++--
 dlls/wined3d/glsl_shader.c        |   13 +++++++------
 dlls/wined3d/wined3d_private.h    |    5 +++--
 4 files changed, 17 insertions(+), 15 deletions(-)

diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c
index 7e6231c..128f900 100644
--- a/dlls/wined3d/arb_program_shader.c
+++ b/dlls/wined3d/arb_program_shader.c
@@ -102,19 +102,19 @@ static void shader_arb_load_constantsF(I
  * worry about the Integers or Booleans
  */
 void shader_arb_load_constants(
-    IWineD3DStateBlock* iface,
+    IWineD3DDevice* device,
     char usePixelShader,
     char useVertexShader) {
-    
-    IWineD3DStateBlockImpl* stateBlock = (IWineD3DStateBlockImpl*) iface;
-    WineD3D_GL_Info *gl_info = &((IWineD3DImpl*)stateBlock->wineD3DDevice->wineD3D)->gl_info;
+   
+    IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) device; 
+    IWineD3DStateBlockImpl* stateBlock = deviceImpl->stateBlock;
+    WineD3D_GL_Info *gl_info = &((IWineD3DImpl*)deviceImpl->wineD3D)->gl_info;
 
     if (useVertexShader) {
         IWineD3DBaseShaderImpl* vshader = (IWineD3DBaseShaderImpl*) stateBlock->vertexShader;
         IWineD3DVertexShaderImpl* vshader_impl = (IWineD3DVertexShaderImpl*) stateBlock->vertexShader;
         IWineD3DVertexDeclarationImpl* vertexDeclaration = 
             (IWineD3DVertexDeclarationImpl*) vshader_impl->vertexDeclaration;
-        IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) vshader->baseShader.device;
 
         if (NULL != vertexDeclaration && NULL != vertexDeclaration->constants) {
             /* Load DirectX 8 float constants for vertex shader */
diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c
index ff465a8..5d05437 100644
--- a/dlls/wined3d/drawprim.c
+++ b/dlls/wined3d/drawprim.c
@@ -1852,9 +1852,9 @@ #undef BUFFER_OR_DATA
        
     /* Load any global constants/uniforms that may have been set by the application */
     if (wined3d_settings.vs_selected_mode == SHADER_GLSL || wined3d_settings.ps_selected_mode == SHADER_GLSL)
-        shader_glsl_load_constants((IWineD3DStateBlock*)This->stateBlock, usePixelShaderFunction, useVertexShaderFunction);
+        shader_glsl_load_constants(iface, usePixelShaderFunction, useVertexShaderFunction);
     else if (wined3d_settings.vs_selected_mode== SHADER_ARB || wined3d_settings.ps_selected_mode == SHADER_ARB)
-        shader_arb_load_constants((IWineD3DStateBlock*)This->stateBlock, usePixelShaderFunction, useVertexShaderFunction); 
+        shader_arb_load_constants(iface, usePixelShaderFunction, useVertexShaderFunction); 
         
     /* Draw vertex-by-vertex */
     if (useDrawStridedSlow)
diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c
index 63d8bfd..b92cecb 100644
--- a/dlls/wined3d/glsl_shader.c
+++ b/dlls/wined3d/glsl_shader.c
@@ -269,12 +269,14 @@ void shader_glsl_load_constantsB(
  * Loads the app-supplied constants into the currently set GLSL program.
  */
 void shader_glsl_load_constants(
-    IWineD3DStateBlock* iface,
+    IWineD3DDevice* device,
     char usePixelShader,
     char useVertexShader) {
-    
-    IWineD3DStateBlockImpl* stateBlock = (IWineD3DStateBlockImpl*) iface;
-    WineD3D_GL_Info *gl_info = &((IWineD3DImpl*)stateBlock->wineD3DDevice->wineD3D)->gl_info;
+   
+    IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) device;
+    IWineD3DStateBlockImpl* stateBlock = deviceImpl->stateBlock;
+    WineD3D_GL_Info *gl_info = &((IWineD3DImpl*) deviceImpl->wineD3D)->gl_info;
+
     GLhandleARB *constant_locations;
     struct list *constant_list;
     GLhandleARB programId;
@@ -288,7 +290,6 @@ void shader_glsl_load_constants(
     if (useVertexShader) {
         IWineD3DBaseShaderImpl* vshader = (IWineD3DBaseShaderImpl*) stateBlock->vertexShader;
         IWineD3DVertexShaderImpl* vshader_impl = (IWineD3DVertexShaderImpl*) vshader;
-        IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) vshader->baseShader.device;
         GLint pos;
 
         IWineD3DVertexDeclarationImpl* vertexDeclaration =
@@ -332,7 +333,7 @@ void shader_glsl_load_constants(
         constant_list = &stateBlock->set_pconstantsF;
 
         /* Load pixel shader samplers */
-        shader_glsl_load_psamplers(gl_info, iface);
+        shader_glsl_load_psamplers(gl_info, (IWineD3DStateBlock*) stateBlock);
 
         /* Load DirectX 9 float constants/uniforms for pixel shader */
         shader_glsl_load_constantsF(pshader, gl_info, GL_LIMITS(pshader_constantsF),
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index e1598f5..1d06252 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1409,6 +1409,7 @@ typedef struct SHADER_OPCODE {
 } SHADER_OPCODE;
 
 typedef struct SHADER_OPCODE_ARG {
+    IWineD3DStateBlock* stateBlock;
     IWineD3DBaseShader* shader;
     shader_reg_maps* reg_maps;
     CONST SHADER_OPCODE* opcode;
@@ -1469,7 +1470,7 @@ extern HRESULT allocate_shader_constants
 
 /* ARB_[vertex/fragment]_program helper functions */
 extern void shader_arb_load_constants(
-    IWineD3DStateBlock* iface,
+    IWineD3DDevice* device,
     char usePixelShader,
     char useVertexShader);
 
@@ -1500,7 +1501,7 @@ extern void vshader_hw_mnxn(SHADER_OPCOD
 extern void set_glsl_shader_program(IWineD3DDevice *iface);
 extern void shader_glsl_add_instruction_modifiers(SHADER_OPCODE_ARG *arg);
 extern void shader_glsl_load_constants(
-    IWineD3DStateBlock* iface,
+    IWineD3DDevice* device,
     char usePixelShader,
     char useVertexShader);
 
-- 
1.4.2



More information about the wine-patches mailing list