wined3d: Make context_resource_released() responsible for activating a different GL context.
In case lastActiveRenderTarget is destroyed.
This commit is contained in:
parent
964f4b0157
commit
94cd8656ea
|
@ -426,6 +426,53 @@ void context_resource_released(IWineD3DDevice *iface, IWineD3DResource *resource
|
|||
{
|
||||
case WINED3DRTYPE_SURFACE:
|
||||
{
|
||||
if ((IWineD3DSurface *)resource == This->lastActiveRenderTarget)
|
||||
{
|
||||
IWineD3DSwapChainImpl *swapchain;
|
||||
|
||||
TRACE("Last active render target destroyed.\n");
|
||||
|
||||
/* Find a replacement surface for the currently active back
|
||||
* buffer. The context manager does not do NULL checks, so
|
||||
* switch to a valid target as long as the currently set
|
||||
* surface is still valid. Use the surface of the implicit
|
||||
* swpchain. If that is the same as the destroyed surface the
|
||||
* device is destroyed and the lastActiveRenderTarget member
|
||||
* shouldn't matter. */
|
||||
swapchain = This->swapchains ? (IWineD3DSwapChainImpl *)This->swapchains[0] : NULL;
|
||||
if (swapchain)
|
||||
{
|
||||
if (swapchain->backBuffer && swapchain->backBuffer[0] != (IWineD3DSurface *)resource)
|
||||
{
|
||||
TRACE("Activating primary back buffer.\n");
|
||||
ActivateContext(This, swapchain->backBuffer[0], CTXUSAGE_RESOURCELOAD);
|
||||
}
|
||||
else if (!swapchain->backBuffer && swapchain->frontBuffer != (IWineD3DSurface *)resource)
|
||||
{
|
||||
/* Single buffering environment */
|
||||
TRACE("Activating primary front buffer.\n");
|
||||
|
||||
ActivateContext(This, swapchain->frontBuffer, CTXUSAGE_RESOURCELOAD);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Implicit render target destroyed, that means the
|
||||
* device is being destroyed whatever we set here, it
|
||||
* shouldn't matter. */
|
||||
TRACE("Device is being destroyed, setting lastActiveRenderTarget to 0xdeadbabe.\n");
|
||||
|
||||
This->lastActiveRenderTarget = (IWineD3DSurface *) 0xdeadbabe;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN("Render target set, but swapchain does not exist!\n");
|
||||
|
||||
/* May happen during ddraw uninitialization. */
|
||||
This->lastActiveRenderTarget = (IWineD3DSurface *)0xdeadcafe;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < This->numContexts; ++i)
|
||||
{
|
||||
WineD3DContext *context = This->contexts[i];
|
||||
|
|
|
@ -7327,39 +7327,8 @@ void device_resource_released(IWineD3DDeviceImpl *This, IWineD3DResource *resour
|
|||
case WINED3DRTYPE_SURFACE: {
|
||||
unsigned int i;
|
||||
|
||||
/* Cleanup any FBO attachments if d3d is enabled */
|
||||
if(This->d3d_initialized) {
|
||||
if((IWineD3DSurface *)resource == This->lastActiveRenderTarget) {
|
||||
IWineD3DSwapChainImpl *swapchain = This->swapchains ? (IWineD3DSwapChainImpl *) This->swapchains[0] : NULL;
|
||||
|
||||
TRACE("Last active render target destroyed\n");
|
||||
/* Find a replacement surface for the currently active back buffer. The context manager does not do NULL
|
||||
* checks, so switch to a valid target as long as the currently set surface is still valid. Use the
|
||||
* surface of the implicit swpchain. If that is the same as the destroyed surface the device is destroyed
|
||||
* and the lastActiveRenderTarget member shouldn't matter
|
||||
*/
|
||||
if(swapchain) {
|
||||
if(swapchain->backBuffer && swapchain->backBuffer[0] != (IWineD3DSurface *)resource) {
|
||||
TRACE("Activating primary back buffer\n");
|
||||
ActivateContext(This, swapchain->backBuffer[0], CTXUSAGE_RESOURCELOAD);
|
||||
} else if(!swapchain->backBuffer && swapchain->frontBuffer != (IWineD3DSurface *)resource) {
|
||||
/* Single buffering environment */
|
||||
TRACE("Activating primary front buffer\n");
|
||||
ActivateContext(This, swapchain->frontBuffer, CTXUSAGE_RESOURCELOAD);
|
||||
} else {
|
||||
TRACE("Device is being destroyed, setting lastActiveRenderTarget = 0xdeadbabe\n");
|
||||
/* Implicit render target destroyed, that means the device is being destroyed
|
||||
* whatever we set here, it shouldn't matter
|
||||
*/
|
||||
This->lastActiveRenderTarget = (IWineD3DSurface *) 0xdeadbabe;
|
||||
}
|
||||
} else {
|
||||
/* May happen during ddraw uninitialization */
|
||||
TRACE("Render target set, but swapchain does not exist!\n");
|
||||
This->lastActiveRenderTarget = (IWineD3DSurface *) 0xdeadcafe;
|
||||
}
|
||||
}
|
||||
|
||||
if (This->d3d_initialized)
|
||||
{
|
||||
for (i = 0; i < GL_LIMITS(buffers); ++i) {
|
||||
if (This->render_targets[i] == (IWineD3DSurface *)resource) {
|
||||
This->render_targets[i] = NULL;
|
||||
|
|
Loading…
Reference in New Issue