Commit a637fda7 authored by H. Verbeet's avatar H. Verbeet Committed by Alexandre Julliard

wined3d: Store the current GLSL program in the backend's private data.

parent 95099404
...@@ -369,13 +369,14 @@ void shader_glsl_load_constants( ...@@ -369,13 +369,14 @@ void shader_glsl_load_constants(
char useVertexShader) { char useVertexShader) {
IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) device; IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) device;
struct shader_glsl_priv *priv = (struct shader_glsl_priv *)deviceImpl->shader_priv;
IWineD3DStateBlockImpl* stateBlock = deviceImpl->stateBlock; IWineD3DStateBlockImpl* stateBlock = deviceImpl->stateBlock;
WineD3D_GL_Info *gl_info = &deviceImpl->adapter->gl_info; WineD3D_GL_Info *gl_info = &deviceImpl->adapter->gl_info;
GLhandleARB *constant_locations; GLhandleARB *constant_locations;
struct list *constant_list; struct list *constant_list;
GLhandleARB programId; GLhandleARB programId;
struct glsl_shader_prog_link *prog = stateBlock->glsl_program; struct glsl_shader_prog_link *prog = priv->glsl_program;
unsigned int i; unsigned int i;
if (!prog) { if (!prog) {
...@@ -3145,6 +3146,7 @@ static void hardcode_local_constants(IWineD3DBaseShaderImpl *shader, WineD3D_GL_ ...@@ -3145,6 +3146,7 @@ static void hardcode_local_constants(IWineD3DBaseShaderImpl *shader, WineD3D_GL_
*/ */
static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use_vs) { static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use_vs) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
struct shader_glsl_priv *priv = (struct shader_glsl_priv *)This->shader_priv;
WineD3D_GL_Info *gl_info = &This->adapter->gl_info; WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
IWineD3DPixelShader *pshader = This->stateBlock->pixelShader; IWineD3DPixelShader *pshader = This->stateBlock->pixelShader;
IWineD3DVertexShader *vshader = This->stateBlock->vertexShader; IWineD3DVertexShader *vshader = This->stateBlock->vertexShader;
...@@ -3158,7 +3160,7 @@ static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use ...@@ -3158,7 +3160,7 @@ static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use
GLhandleARB pshader_id = use_ps ? ((IWineD3DBaseShaderImpl*)pshader)->baseShader.prgId : 0; GLhandleARB pshader_id = use_ps ? ((IWineD3DBaseShaderImpl*)pshader)->baseShader.prgId : 0;
entry = get_glsl_program_entry(This, vshader_id, pshader_id); entry = get_glsl_program_entry(This, vshader_id, pshader_id);
if (entry) { if (entry) {
This->stateBlock->glsl_program = entry; priv->glsl_program = entry;
return; return;
} }
...@@ -3175,7 +3177,7 @@ static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use ...@@ -3175,7 +3177,7 @@ static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use
add_glsl_program_entry(This, entry); add_glsl_program_entry(This, entry);
/* Set the current program */ /* Set the current program */
This->stateBlock->glsl_program = entry; priv->glsl_program = entry;
/* Attach GLSL vshader */ /* Attach GLSL vshader */
if (vshader_id) { if (vshader_id) {
...@@ -3356,16 +3358,17 @@ static GLhandleARB create_glsl_blt_shader(WineD3D_GL_Info *gl_info) { ...@@ -3356,16 +3358,17 @@ static GLhandleARB create_glsl_blt_shader(WineD3D_GL_Info *gl_info) {
static void shader_glsl_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) { static void shader_glsl_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
struct shader_glsl_priv *priv = (struct shader_glsl_priv *)This->shader_priv;
WineD3D_GL_Info *gl_info = &This->adapter->gl_info; WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
GLhandleARB program_id = 0; GLhandleARB program_id = 0;
GLenum old_vertex_color_clamp, current_vertex_color_clamp; GLenum old_vertex_color_clamp, current_vertex_color_clamp;
old_vertex_color_clamp = This->stateBlock->glsl_program ? This->stateBlock->glsl_program->vertex_color_clamp : GL_FIXED_ONLY_ARB; old_vertex_color_clamp = priv->glsl_program ? priv->glsl_program->vertex_color_clamp : GL_FIXED_ONLY_ARB;
if (useVS || usePS) set_glsl_shader_program(iface, usePS, useVS); if (useVS || usePS) set_glsl_shader_program(iface, usePS, useVS);
else This->stateBlock->glsl_program = NULL; else priv->glsl_program = NULL;
current_vertex_color_clamp = This->stateBlock->glsl_program ? This->stateBlock->glsl_program->vertex_color_clamp : GL_FIXED_ONLY_ARB; current_vertex_color_clamp = priv->glsl_program ? priv->glsl_program->vertex_color_clamp : GL_FIXED_ONLY_ARB;
if (old_vertex_color_clamp != current_vertex_color_clamp) { if (old_vertex_color_clamp != current_vertex_color_clamp) {
if (GL_SUPPORT(ARB_COLOR_BUFFER_FLOAT)) { if (GL_SUPPORT(ARB_COLOR_BUFFER_FLOAT)) {
...@@ -3376,7 +3379,7 @@ static void shader_glsl_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) { ...@@ -3376,7 +3379,7 @@ static void shader_glsl_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {
} }
} }
program_id = This->stateBlock->glsl_program ? This->stateBlock->glsl_program->programId : 0; program_id = priv->glsl_program ? priv->glsl_program->programId : 0;
if (program_id) TRACE("Using GLSL program %u\n", program_id); if (program_id) TRACE("Using GLSL program %u\n", program_id);
GL_EXTCALL(glUseProgramObjectARB(program_id)); GL_EXTCALL(glUseProgramObjectARB(program_id));
checkGLcall("glUseProgramObjectARB"); checkGLcall("glUseProgramObjectARB");
......
...@@ -170,7 +170,6 @@ void stateblock_copy( ...@@ -170,7 +170,6 @@ void stateblock_copy(
Dest->viewport = This->viewport; Dest->viewport = This->viewport;
Dest->material = This->material; Dest->material = This->material;
Dest->pixelShader = This->pixelShader; Dest->pixelShader = This->pixelShader;
Dest->glsl_program = This->glsl_program;
Dest->scissorRect = This->scissorRect; Dest->scissorRect = This->scissorRect;
/* Lights */ /* Lights */
...@@ -1240,10 +1239,6 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat ...@@ -1240,10 +1239,6 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat
This->textures[i] = NULL; This->textures[i] = NULL;
} }
/* Set default GLSL program to NULL. We won't actually create one
* until the app sets a vertex or pixel shader */
This->glsl_program = NULL;
TRACE("-----------------------> Device defaults now set up...\n"); TRACE("-----------------------> Device defaults now set up...\n");
return WINED3D_OK; return WINED3D_OK;
} }
......
...@@ -312,6 +312,7 @@ extern const shader_backend_t none_shader_backend; ...@@ -312,6 +312,7 @@ extern const shader_backend_t none_shader_backend;
/* GLSL shader private data */ /* GLSL shader private data */
struct shader_glsl_priv { struct shader_glsl_priv {
struct glsl_shader_prog_link *glsl_program;
GLhandleARB depth_blt_glsl_program_id; GLhandleARB depth_blt_glsl_program_id;
}; };
...@@ -1610,9 +1611,6 @@ struct IWineD3DStateBlockImpl ...@@ -1610,9 +1611,6 @@ struct IWineD3DStateBlockImpl
/* Sampler States */ /* Sampler States */
DWORD samplerState[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1]; DWORD samplerState[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
/* Current GLSL Shader Program */
struct glsl_shader_prog_link *glsl_program;
/* Scissor test rectangle */ /* Scissor test rectangle */
RECT scissorRect; RECT scissorRect;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment