diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index aa16d9e7be5..7e596b8ee45 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -4948,19 +4948,19 @@ HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfa if (vp->X != 0 || vp->Y != 0 || vp->Width < depth_stencil->currentDesc.Width || vp->Height < depth_stencil->currentDesc.Height) { - surface_load_ds_location(This->stencilBufferTarget, location); + surface_load_ds_location(This->stencilBufferTarget, context, location); } else if (This->stateBlock->renderState[WINED3DRS_SCISSORTESTENABLE] && ( This->stateBlock->scissorRect.left > 0 || This->stateBlock->scissorRect.top > 0 || This->stateBlock->scissorRect.right < depth_stencil->currentDesc.Width || This->stateBlock->scissorRect.bottom < depth_stencil->currentDesc.Height)) { - surface_load_ds_location(This->stencilBufferTarget, location); + surface_load_ds_location(This->stencilBufferTarget, context, location); } else if (Count > 0 && pRects && ( pRects[0].x1 > 0 || pRects[0].y1 > 0 || pRects[0].x2 < depth_stencil->currentDesc.Width || pRects[0].y2 < depth_stencil->currentDesc.Height)) { - surface_load_ds_location(This->stencilBufferTarget, location); + surface_load_ds_location(This->stencilBufferTarget, context, location); } } @@ -6591,8 +6591,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetDepthStencilSurface(IWineD3DDevice * || ((IWineD3DSurfaceImpl *)This->stencilBufferTarget)->Flags & SFLAG_DISCARD) { surface_modify_ds_location(This->stencilBufferTarget, SFLAG_DS_DISCARDED); } else { - ActivateContext(This, This->render_targets[0], CTXUSAGE_RESOURCELOAD); - surface_load_ds_location(This->stencilBufferTarget, SFLAG_DS_OFFSCREEN); + struct WineD3DContext *context = ActivateContext(This, This->render_targets[0], CTXUSAGE_RESOURCELOAD); + surface_load_ds_location(This->stencilBufferTarget, context, SFLAG_DS_OFFSCREEN); surface_modify_ds_location(This->stencilBufferTarget, SFLAG_DS_OFFSCREEN); } } diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index 172228bb8d6..889ef6b0d7e 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -558,6 +558,7 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT numberOfVertice IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; IWineD3DSurfaceImpl *target; + struct WineD3DContext *context; unsigned int i; if (!index_count) return; @@ -579,7 +580,7 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT numberOfVertice /* Signals other modules that a drawing is in progress and the stateblock finalized */ This->isInDraw = TRUE; - ActivateContext(This, This->render_targets[0], CTXUSAGE_DRAWPRIM); + context = ActivateContext(This, This->render_targets[0], CTXUSAGE_DRAWPRIM); if (This->stencilBufferTarget) { /* Note that this depends on the ActivateContext call above to set @@ -590,7 +591,7 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT numberOfVertice DWORD location = This->render_offscreen ? SFLAG_DS_OFFSCREEN : SFLAG_DS_ONSCREEN; if (This->stateBlock->renderState[WINED3DRS_ZWRITEENABLE] || This->stateBlock->renderState[WINED3DRS_ZENABLE]) - surface_load_ds_location(This->stencilBufferTarget, location); + surface_load_ds_location(This->stencilBufferTarget, context, location); if (This->stateBlock->renderState[WINED3DRS_ZWRITEENABLE]) surface_modify_ds_location(This->stencilBufferTarget, location); } diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index cecc460e172..db336759f45 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -4370,7 +4370,8 @@ void surface_modify_ds_location(IWineD3DSurface *iface, DWORD location) { } /* Context activation is done by the caller. */ -void surface_load_ds_location(IWineD3DSurface *iface, DWORD location) { +void surface_load_ds_location(IWineD3DSurface *iface, struct WineD3DContext *context, DWORD location) +{ IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; @@ -4404,7 +4405,7 @@ void surface_load_ds_location(IWineD3DSurface *iface, DWORD location) { /* Note that we use depth_blt here as well, rather than glCopyTexImage2D * directly on the FBO texture. That's because we need to flip. */ - context_bind_fbo(device->activeContext, GL_FRAMEBUFFER_EXT, NULL); + context_bind_fbo(context, GL_FRAMEBUFFER_EXT, NULL); if (This->texture_target == GL_TEXTURE_RECTANGLE_ARB) { glGetIntegerv(GL_TEXTURE_BINDING_RECTANGLE_ARB, &old_binding); @@ -4439,20 +4440,17 @@ void surface_load_ds_location(IWineD3DSurface *iface, DWORD location) { device->depth_blt_rb_h = This->currentDesc.Height; } - context_bind_fbo(device->activeContext, GL_FRAMEBUFFER_EXT, &device->activeContext->dst_fbo); + context_bind_fbo(context, GL_FRAMEBUFFER_EXT, &context->dst_fbo); GL_EXTCALL(glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, device->depth_blt_rb)); checkGLcall("glFramebufferRenderbufferEXT"); - context_attach_depth_stencil_fbo(device->activeContext, GL_FRAMEBUFFER_EXT, iface, FALSE); + context_attach_depth_stencil_fbo(context, GL_FRAMEBUFFER_EXT, iface, FALSE); /* Do the actual blit */ surface_depth_blt(This, device->depth_blt_texture, This->currentDesc.Width, This->currentDesc.Height, bind_target); checkGLcall("depth_blt"); - if (device->activeContext->current_fbo) { - context_bind_fbo(device->activeContext, GL_FRAMEBUFFER_EXT, &device->activeContext->current_fbo->id); - } else { - context_bind_fbo(device->activeContext, GL_FRAMEBUFFER_EXT, NULL); - } + if (context->current_fbo) context_bind_fbo(context, GL_FRAMEBUFFER_EXT, &context->current_fbo->id); + else context_bind_fbo(context, GL_FRAMEBUFFER_EXT, NULL); LEAVE_GL(); } else { @@ -4464,14 +4462,12 @@ void surface_load_ds_location(IWineD3DSurface *iface, DWORD location) { ENTER_GL(); - context_bind_fbo(device->activeContext, GL_FRAMEBUFFER_EXT, NULL); + context_bind_fbo(context, GL_FRAMEBUFFER_EXT, NULL); surface_depth_blt(This, This->texture_name, This->currentDesc.Width, This->currentDesc.Height, This->texture_target); checkGLcall("depth_blt"); - if (device->activeContext->current_fbo) { - context_bind_fbo(device->activeContext, GL_FRAMEBUFFER_EXT, &device->activeContext->current_fbo->id); - } + if (context->current_fbo) context_bind_fbo(context, GL_FRAMEBUFFER_EXT, &context->current_fbo->id); LEAVE_GL(); } else { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 545c33c66da..f2b376affb6 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2533,7 +2533,7 @@ void state_fog_fragpart(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D void surface_add_dirty_rect(IWineD3DSurface *iface, const RECT *dirty_rect); GLenum surface_get_gl_buffer(IWineD3DSurface *iface, IWineD3DSwapChain *swapchain); -void surface_load_ds_location(IWineD3DSurface *iface, DWORD location); +void surface_load_ds_location(IWineD3DSurface *iface, struct WineD3DContext *context, DWORD location); void surface_modify_ds_location(IWineD3DSurface *iface, DWORD location); void surface_set_compatible_renderbuffer(IWineD3DSurface *iface, unsigned int width, unsigned int height); void surface_set_texture_name(IWineD3DSurface *iface, GLuint name, BOOL srgb_name);