From 42a9262acf4600c4eb5e5dd6831b80dd9aa9395d Mon Sep 17 00:00:00 2001 From: Ivan Gyurdiev Date: Wed, 27 Sep 2006 07:15:58 -0400 Subject: [PATCH] wined3d: Read GL info and load constants into the same device. --- 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 7e6231ce9b7..128f900871e 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(IWineD3DBaseShaderImpl* This, WineD3D_GL_ * 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 c9b14a033a6..1160037c126 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -1852,9 +1852,9 @@ inline static void drawPrimitiveDrawStrided( /* 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 63d8bfd6147..b92cecbb6b9 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 588f0991765..d2ee68143b2 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1412,6 +1412,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; @@ -1472,7 +1473,7 @@ extern HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object); /* ARB_[vertex/fragment]_program helper functions */ extern void shader_arb_load_constants( - IWineD3DStateBlock* iface, + IWineD3DDevice* device, char usePixelShader, char useVertexShader); @@ -1503,7 +1504,7 @@ extern void vshader_hw_mnxn(SHADER_OPCODE_ARG* arg); 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);