Commit 8a6799d4 authored by Oliver Stieber's avatar Oliver Stieber Committed by Alexandre Julliard

Implement render targets using either textures, swapchains or

standalone surfaces.
parent e419cb88
......@@ -374,53 +374,61 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateOffscreenPlainSurface(LPDIRECT3DDEVI
/* TODO: move to wineD3D */
HRESULT WINAPI IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr = S_OK;
IDirect3DSurface9Impl *pSurface = (IDirect3DSurface9Impl*)pRenderTarget;
TRACE("(%p) Relay\n" , This);
return IWineD3DDevice_SetRenderTarget(This->WineD3DDevice,RenderTargetIndex,(IWineD3DSurface*)pSurface->wineD3DSurface);
}
/* If pRenderTarget == NULL, it seems to default to back buffer */
if (pRenderTarget == NULL) pRenderTarget = (IDirect3DSurface9*) This->backBuffer;
/* If we are trying to set what we already have, don't bother */
if ((IDirect3DSurface9Impl*) pRenderTarget == This->renderTarget) {
TRACE("Trying to do a NOP SetRenderTarget operation\n");
} else {
/* Otherwise, set the render target up */
TRACE("(%p) : newRender@%p (default is backbuffer=(%p))\n", This, pRenderTarget, This->backBuffer);
hr = E_FAIL; /* not supported yet */
HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9 **ppRenderTarget) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr = D3D_OK;
IWineD3DSurface *pRenderTarget;
TRACE("(%p) Relay\n" , This);
if (ppRenderTarget == NULL) {
return D3DERR_INVALIDCALL;
}
hr=IWineD3DDevice_GetRenderTarget(This->WineD3DDevice,RenderTargetIndex,&pRenderTarget);
return hr;
if (hr == D3D_OK && pRenderTarget != NULL) {
IWineD3DResource_GetParent((IWineD3DResource *)pRenderTarget,(IUnknown**)ppRenderTarget);
IWineD3DResource_Release((IWineD3DResource *)pRenderTarget);
} else {
FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
*ppRenderTarget = NULL;
}
return hr;
}
/* TODO: move to wineD3D */
HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget) {
HRESULT WINAPI IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pZStencilSurface) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
TRACE("(%p)->returning (%p) default is backbuffer=(%p)\n", This, This->renderTarget, This->backBuffer);
*ppRenderTarget = (LPDIRECT3DSURFACE9) This->renderTarget;
IDirect3DSurface9Impl_AddRef((LPDIRECT3DSURFACE9) *ppRenderTarget);
return D3D_OK;
IDirect3DSurface9Impl *pSurface;
TRACE("(%p) Relay\n" , This);
pSurface = (IDirect3DSurface9Impl*)pZStencilSurface;
return IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice,NULL==pSurface?NULL:(IWineD3DSurface*)pSurface->wineD3DSurface);
}
/* TODO: move to wineD3D */
HRESULT WINAPI IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pZStencilSurface) {
HRESULT WINAPI IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9 **ppZStencilSurface) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr = S_OK;
/* If we are trying to set what we already have, don't bother */
if ((IDirect3DSurface9Impl*) pZStencilSurface == This->stencilBufferTarget) {
TRACE("Trying to do a NOP SetDepthStencilSurface operation\n");
} else {
/* Otherwise, set the target up */
TRACE("(%p) : newDepthStencil@%p (default is stencilbuffer=(%p))\n", This, pZStencilSurface, This->depthStencilBuffer);
hr = E_FAIL; /* not supported yet */
HRESULT hr = D3D_OK;
IWineD3DSurface *pZStencilSurface;
TRACE("(%p) Relay\n" , This);
if(ppZStencilSurface == NULL){
return D3DERR_INVALIDCALL;
}
return D3D_OK;
}
/* TODO: move to wineD3D */
HRESULT WINAPI IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9** ppZStencilSurface) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
TRACE("(%p)->returning (%p) default is stencilbuffer=(%p)\n", This, This->stencilBufferTarget, This->depthStencilBuffer);
*ppZStencilSurface = (LPDIRECT3DSURFACE9) This->stencilBufferTarget;
if (NULL != *ppZStencilSurface) IDirect3DSurface9Impl_AddRef((LPDIRECT3DSURFACE9) *ppZStencilSurface);
hr=IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice,&pZStencilSurface);
if(hr == D3D_OK && pZStencilSurface != NULL){
IWineD3DResource_GetParent((IWineD3DResource *)pZStencilSurface,(IUnknown**)ppZStencilSurface);
IWineD3DResource_Release((IWineD3DResource *)pZStencilSurface);
}else{
FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
*ppZStencilSurface = NULL;
}
return D3D_OK;
}
......
......@@ -1572,7 +1572,6 @@ HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, D3DDEV
object->createParms.BehaviorFlags = BehaviourFlags;
/* Initialize other useful values */
object->presentParms.BackBufferCount = 1; /* Opengl only supports one? */
object->adapterNo = Adapter;
object->devType = DeviceType;
......
......@@ -1761,4 +1761,138 @@ SHORT D3DFmtGetBpp(IWineD3DDeviceImpl* This, D3DFORMAT fmt) {
TRACE("bytes/Pxl for fmt(%u,%s) = %d\n", fmt, debug_d3dformat(fmt), retVal);
return retVal;
}
/* Convertes a D3D format into a OpenGL configuration format */
int D3DFmtMakeGlCfg(D3DFORMAT BackBufferFormat, D3DFORMAT StencilBufferFormat, int *attribs, int* nAttribs, BOOL alternate){
#define PUSH1(att) attribs[(*nAttribs)++] = (att);
#define PUSH2(att,value) attribs[(*nAttribs)++] = (att); attribs[(*nAttribs)++] = (value);
/*We need to do some Card specific stuff in here at some point,
D3D now support floating point format buffers, and their are a number of different OpelGl ways on managing thease e.g.
GLX_ATI_pixel_format_float
*/
switch (BackBufferFormat) {
/* color buffer */
case WINED3DFMT_P8:
PUSH2(GLX_RENDER_TYPE, GLX_COLOR_INDEX_BIT);
PUSH2(GLX_BUFFER_SIZE, 8);
PUSH2(GLX_DOUBLEBUFFER, TRUE);
break;
case WINED3DFMT_R3G3B2:
PUSH2(GLX_RENDER_TYPE, GLX_RGBA_BIT);
PUSH2(GLX_RED_SIZE, 3);
PUSH2(GLX_GREEN_SIZE, 3);
PUSH2(GLX_BLUE_SIZE, 2);
break;
case WINED3DFMT_A1R5G5B5:
PUSH2(GLX_ALPHA_SIZE, 1);
case WINED3DFMT_X1R5G5B5:
PUSH2(GLX_RED_SIZE, 5);
PUSH2(GLX_GREEN_SIZE, 5);
PUSH2(GLX_BLUE_SIZE, 5);
break;
case WINED3DFMT_R5G6B5:
PUSH2(GLX_RED_SIZE, 5);
PUSH2(GLX_GREEN_SIZE, 6);
PUSH2(GLX_BLUE_SIZE, 5);
break;
case WINED3DFMT_A4R4G4B4:
PUSH2(GLX_ALPHA_SIZE, 4);
case WINED3DFMT_X4R4G4B4:
PUSH2(GLX_RED_SIZE, 4);
PUSH2(GLX_GREEN_SIZE, 4);
PUSH2(GLX_BLUE_SIZE, 4);
break;
case WINED3DFMT_A8R8G8B8:
PUSH2(GLX_ALPHA_SIZE, 8);
case WINED3DFMT_R8G8B8:
case WINED3DFMT_X8R8G8B8:
PUSH2(GLX_RED_SIZE, 8);
PUSH2(GLX_GREEN_SIZE, 8);
PUSH2(GLX_BLUE_SIZE, 8);
break;
default:
break;
}
if(!alternate){
switch (StencilBufferFormat) {
case WINED3DFMT_D16_LOCKABLE:
case WINED3DFMT_D16:
PUSH2(GLX_DEPTH_SIZE, 16);
break;
case WINED3DFMT_D15S1:
PUSH2(GLX_DEPTH_SIZE, 15);
PUSH2(GLX_STENCIL_SIZE, 1);
/*Does openGl support a 1bit stencil?, I've seen it used elsewhere
e.g. http://www.ks.uiuc.edu/Research/vmd/doxygen/OpenGLDisplayDevice_8C-source.html*/
break;
case WINED3DFMT_D24X8:
PUSH2(GLX_DEPTH_SIZE, 24);
break;
case WINED3DFMT_D24X4S4:
PUSH2(GLX_DEPTH_SIZE, 24);
PUSH2(GLX_STENCIL_SIZE, 4);
break;
case WINED3DFMT_D24S8:
PUSH2(GLX_DEPTH_SIZE, 24);
PUSH2(GLX_STENCIL_SIZE, 8);
break;
case WINED3DFMT_D32:
PUSH2(GLX_DEPTH_SIZE, 32);
break;
default:
break;
}
}else{ /* it the device doesn't support the 'exact' format, try to find something close */
switch (StencilBufferFormat) {
case WINED3DFMT_D16_LOCKABLE:
case WINED3DFMT_D16:
PUSH2(GLX_DEPTH_SIZE, 1);
break;
case WINED3DFMT_D15S1:
PUSH2(GLX_DEPTH_SIZE, 1);
PUSH2(GLX_STENCIL_SIZE, 1);
/*Does openGl support a 1bit stencil?, I've seen it used elsewhere
e.g. http://www.ks.uiuc.edu/Research/vmd/doxygen/OpenGLDisplayDevice_8C-source.html*/
break;
case WINED3DFMT_D24X8:
PUSH2(GLX_DEPTH_SIZE, 1);
break;
case WINED3DFMT_D24X4S4:
PUSH2(GLX_DEPTH_SIZE, 1);
PUSH2(GLX_STENCIL_SIZE, 1);
break;
case WINED3DFMT_D24S8:
PUSH2(GLX_DEPTH_SIZE, 1);
PUSH2(GLX_STENCIL_SIZE, 1);
break;
case WINED3DFMT_D32:
PUSH2(GLX_DEPTH_SIZE, 1);
break;
default:
break;
}
}
return *nAttribs;
}
#undef GLINFO_LOCATION
......@@ -394,7 +394,6 @@ typedef struct IWineD3DDeviceImpl
/* Internal use fields */
D3DDEVICE_CREATION_PARAMETERS createParms;
D3DPRESENT_PARAMETERS presentParms;
UINT adapterNo;
D3DDEVTYPE devType;
......@@ -403,8 +402,6 @@ typedef struct IWineD3DDeviceImpl
int numberOfSwapChains;
/* Render Target Support */
IWineD3DSurface *frontBuffer;
IWineD3DSurface *backBuffer;
IWineD3DSurface *depthStencilBuffer;
IWineD3DSurface *renderTarget;
......@@ -850,6 +847,9 @@ GLenum D3DFmt2GLFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
GLenum D3DFmt2GLType(IWineD3DDeviceImpl *This, D3DFORMAT fmt);
GLint D3DFmt2GLIntFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
int D3DFmtMakeGlCfg(D3DFORMAT BackBufferFormat, D3DFORMAT StencilBufferFormat, int *attribs, int* nAttribs, BOOL alternate);
/*****************************************************************************
* To enable calling of inherited functions, requires prototypes
*
......
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