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

wined3d: Allow the device to store multiple render targets.

parent 1698c44e
......@@ -2448,6 +2448,8 @@ static HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter,
if (WINED3D_OK != temp_result)
return temp_result;
object->render_targets = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DSurface *) * GL_LIMITS(buffers));
/* set the state of the device to valid */
object->state = WINED3D_OK;
......@@ -2472,9 +2474,9 @@ create_device_error:
IWineD3DStateBlock_Release((IWineD3DStateBlock *)object->stateBlock);
object->stateBlock = NULL;
}
if (object->renderTarget != NULL) {
IWineD3DSurface_Release(object->renderTarget);
object->renderTarget = NULL;
if (object->render_targets[0] != NULL) {
IWineD3DSurface_Release(object->render_targets[0]);
object->render_targets[0] = NULL;
}
if (object->stencilBufferTarget != NULL) {
IWineD3DSurface_Release(object->stencilBufferTarget);
......
......@@ -545,7 +545,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED
if (This->resource.usage & WINED3DUSAGE_RENDERTARGET) {
IWineD3DSurface_GetContainer(iface, &IID_IWineD3DSwapChain, (void **)&swapchain);
if (swapchain != NULL || iface == myDevice->renderTarget || iface == myDevice->depthStencilBuffer) {
if (swapchain != NULL || iface == myDevice->render_targets[0] || iface == myDevice->depthStencilBuffer) {
if(swapchain != NULL) {
int i;
for(i = 0; i < swapchain->presentParms.BackBufferCount; i++) {
......@@ -559,7 +559,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED
TRACE("(%p, backBuffer) : rect@%p flags(%08x), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory);
} else if (swapchain != NULL && iface == swapchain->frontBuffer) {
TRACE("(%p, frontBuffer) : rect@%p flags(%08x), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory);
} else if (iface == myDevice->renderTarget) {
} else if (iface == myDevice->render_targets[0]) {
TRACE("(%p, renderTarget) : rect@%p flags(%08x), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory);
} else if (iface == myDevice->depthStencilBuffer) {
TRACE("(%p, stencilBuffer) : rect@%p flags(%08x), output lockedRect@%p, memory@%p\n", This, pRect, Flags, pLockedRect, This->resource.allocatedMemory);
......@@ -689,15 +689,15 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED
if not, we need to switch contexts and then switchback at the end.
*/
IWineD3DSurface_GetContainer(iface, &IID_IWineD3DSwapChain, (void **)&swapchain);
IWineD3DSurface_GetContainer(myDevice->renderTarget, &IID_IWineD3DSwapChain, (void **)&targetSwapChain);
IWineD3DSurface_GetContainer(myDevice->render_targets[0], &IID_IWineD3DSwapChain, (void **)&targetSwapChain);
/* NOTE: In a shared context environment the renderTarget will use the same context as the implicit swapchain (we're not in a shared environment yet! */
if ((swapchain == targetSwapChain && targetSwapChain != NULL) || iface == myDevice->renderTarget) {
if ((swapchain == targetSwapChain && targetSwapChain != NULL) || iface == myDevice->render_targets[0]) {
if (swapchain && iface == swapchain->frontBuffer) {
TRACE("locking front\n");
glReadBuffer(GL_FRONT);
}
else if (iface == myDevice->renderTarget || backbuf) {
else if (iface == myDevice->render_targets[0] || backbuf) {
TRACE("locking back buffer\n");
glReadBuffer(GL_BACK);
} else if (iface == myDevice->depthStencilBuffer) {
......@@ -1102,7 +1102,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
buffername = "frontBuffer";
} else if (iface == myDevice->depthStencilBuffer) {
buffername = "depthStencilBuffer";
} else if (iface == myDevice->renderTarget) {
} else if (iface == myDevice->render_targets[0]) {
buffername = "renderTarget";
}
}
......@@ -1134,7 +1134,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
IWineD3DSwapChainImpl *implSwapChain;
IWineD3DDevice_GetSwapChain((IWineD3DDevice *)myDevice, 0, (IWineD3DSwapChain **)&implSwapChain);
if (backbuf || iface == implSwapChain->frontBuffer || iface == myDevice->renderTarget) {
if (backbuf || iface == implSwapChain->frontBuffer || iface == myDevice->render_targets[0]) {
int tex;
ENTER_GL();
......@@ -1147,7 +1147,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
if (iface == implSwapChain->frontBuffer) {
glDrawBuffer(GL_FRONT);
checkGLcall("glDrawBuffer GL_FRONT");
} else if (backbuf || iface == myDevice->renderTarget) {
} else if (backbuf || iface == myDevice->render_targets[0]) {
glDrawBuffer(GL_BACK);
checkGLcall("glDrawBuffer GL_BACK");
}
......
......@@ -279,7 +279,7 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
checkGLcall("glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);");
/* If this swapchain is currently the active context then make this swapchain active */
if(IWineD3DSurface_GetContainer(This->wineD3DDevice->renderTarget, &IID_IWineD3DSwapChain, (void **)&tmp) == WINED3D_OK){
if(IWineD3DSurface_GetContainer(This->wineD3DDevice->render_targets[0], &IID_IWineD3DSwapChain, (void **)&tmp) == WINED3D_OK){
if(tmp != (IUnknown *)This){
glXMakeCurrent(This->display, currentDrawable, currentContext);
checkGLcall("glXMakeCurrent");
......
......@@ -574,9 +574,9 @@ typedef struct IWineD3DDeviceImpl
ResourceList *resources; /* a linked list to track resources created by the device */
/* Render Target Support */
IWineD3DSurface **render_targets;
IWineD3DSurface *depthStencilBuffer;
IWineD3DSurface *renderTarget;
IWineD3DSurface *stencilBufferTarget;
/* palettes texture management */
......
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