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(
char useVertexShader) {
IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) device;
struct shader_glsl_priv *priv = (struct shader_glsl_priv *)deviceImpl->shader_priv;
IWineD3DStateBlockImpl* stateBlock = deviceImpl->stateBlock;
WineD3D_GL_Info *gl_info = &deviceImpl->adapter->gl_info;
GLhandleARB *constant_locations;
struct list *constant_list;
GLhandleARB programId;
struct glsl_shader_prog_link *prog = stateBlock->glsl_program;
struct glsl_shader_prog_link *prog = priv->glsl_program;
unsigned int i;
if (!prog) {
......@@ -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) {
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;
IWineD3DPixelShader *pshader = This->stateBlock->pixelShader;
IWineD3DVertexShader *vshader = This->stateBlock->vertexShader;
......@@ -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;
entry = get_glsl_program_entry(This, vshader_id, pshader_id);
if (entry) {
This->stateBlock->glsl_program = entry;
priv->glsl_program = entry;
return;
}
......@@ -3175,7 +3177,7 @@ static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use
add_glsl_program_entry(This, entry);
/* Set the current program */
This->stateBlock->glsl_program = entry;
priv->glsl_program = entry;
/* Attach GLSL vshader */
if (vshader_id) {
......@@ -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) {
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;
GLhandleARB program_id = 0;
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);
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 (GL_SUPPORT(ARB_COLOR_BUFFER_FLOAT)) {
......@@ -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);
GL_EXTCALL(glUseProgramObjectARB(program_id));
checkGLcall("glUseProgramObjectARB");
......
......@@ -170,7 +170,6 @@ void stateblock_copy(
Dest->viewport = This->viewport;
Dest->material = This->material;
Dest->pixelShader = This->pixelShader;
Dest->glsl_program = This->glsl_program;
Dest->scissorRect = This->scissorRect;
/* Lights */
......@@ -1240,10 +1239,6 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat
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");
return WINED3D_OK;
}
......
......@@ -312,6 +312,7 @@ extern const shader_backend_t none_shader_backend;
/* GLSL shader private data */
struct shader_glsl_priv {
struct glsl_shader_prog_link *glsl_program;
GLhandleARB depth_blt_glsl_program_id;
};
......@@ -1610,9 +1611,6 @@ struct IWineD3DStateBlockImpl
/* Sampler States */
DWORD samplerState[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
/* Current GLSL Shader Program */
struct glsl_shader_prog_link *glsl_program;
/* Scissor test rectangle */
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