wined3d: Don't activate a context unless we need one.

This commit is contained in:
Stefan Dösinger 2009-07-17 11:48:32 +02:00 committed by Alexandre Julliard
parent c68a20fb80
commit cd7f43b00d
2 changed files with 10 additions and 4 deletions

View File

@ -4359,8 +4359,6 @@ static void shader_arb_destroy(IWineD3DBaseShader *iface) {
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)baseShader->baseShader.device; IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)baseShader->baseShader.device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
if (shader_is_pshader_version(baseShader->baseShader.reg_maps.shader_version.type)) if (shader_is_pshader_version(baseShader->baseShader.reg_maps.shader_version.type))
{ {
IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *) iface; IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *) iface;
@ -4369,6 +4367,9 @@ static void shader_arb_destroy(IWineD3DBaseShader *iface) {
if(!shader_data) return; /* This can happen if a shader was never compiled */ if(!shader_data) return; /* This can happen if a shader was never compiled */
ENTER_GL(); ENTER_GL();
if(shader_data->num_gl_shaders) ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
for(i = 0; i < shader_data->num_gl_shaders; i++) { for(i = 0; i < shader_data->num_gl_shaders; i++) {
GL_EXTCALL(glDeleteProgramsARB(1, &shader_data->gl_shaders[i].prgId)); GL_EXTCALL(glDeleteProgramsARB(1, &shader_data->gl_shaders[i].prgId));
checkGLcall("GL_EXTCALL(glDeleteProgramsARB(1, &shader_data->gl_shaders[i].prgId))"); checkGLcall("GL_EXTCALL(glDeleteProgramsARB(1, &shader_data->gl_shaders[i].prgId))");
@ -4384,6 +4385,9 @@ static void shader_arb_destroy(IWineD3DBaseShader *iface) {
if(!shader_data) return; /* This can happen if a shader was never compiled */ if(!shader_data) return; /* This can happen if a shader was never compiled */
ENTER_GL(); ENTER_GL();
if(shader_data->num_gl_shaders) ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
for(i = 0; i < shader_data->num_gl_shaders; i++) { for(i = 0; i < shader_data->num_gl_shaders; i++) {
GL_EXTCALL(glDeleteProgramsARB(1, &shader_data->gl_shaders[i].prgId)); GL_EXTCALL(glDeleteProgramsARB(1, &shader_data->gl_shaders[i].prgId));
checkGLcall("GL_EXTCALL(glDeleteProgramsARB(1, &shader_data->gl_shaders[i].prgId))"); checkGLcall("GL_EXTCALL(glDeleteProgramsARB(1, &shader_data->gl_shaders[i].prgId))");

View File

@ -4331,8 +4331,6 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) {
*/ */
char pshader = shader_is_pshader_version(This->baseShader.reg_maps.shader_version.type); char pshader = shader_is_pshader_version(This->baseShader.reg_maps.shader_version.type);
ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
if(pshader) { if(pshader) {
struct glsl_pshader_private *shader_data; struct glsl_pshader_private *shader_data;
ps = (IWineD3DPixelShaderImpl *) This; ps = (IWineD3DPixelShaderImpl *) This;
@ -4344,6 +4342,8 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) {
return; return;
} }
ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
if (priv->glsl_program && (IWineD3DBaseShader *)priv->glsl_program->pshader == iface) if (priv->glsl_program && (IWineD3DBaseShader *)priv->glsl_program->pshader == iface)
{ {
ENTER_GL(); ENTER_GL();
@ -4361,6 +4361,8 @@ static void shader_glsl_destroy(IWineD3DBaseShader *iface) {
return; return;
} }
ActivateContext(device, device->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
if (priv->glsl_program && (IWineD3DBaseShader *)priv->glsl_program->vshader == iface) if (priv->glsl_program && (IWineD3DBaseShader *)priv->glsl_program->vshader == iface)
{ {
ENTER_GL(); ENTER_GL();