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 ...@@ -374,53 +374,61 @@ HRESULT WINAPI IDirect3DDevice9Impl_CreateOffscreenPlainSurface(LPDIRECT3DDEVI
/* TODO: move to wineD3D */ /* TODO: move to wineD3D */
HRESULT WINAPI IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) { HRESULT WINAPI IDirect3DDevice9Impl_SetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9* pRenderTarget) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; 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 */ HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9 **ppRenderTarget) {
if (pRenderTarget == NULL) pRenderTarget = (IDirect3DSurface9*) This->backBuffer; IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr = D3D_OK;
/* If we are trying to set what we already have, don't bother */ IWineD3DSurface *pRenderTarget;
if ((IDirect3DSurface9Impl*) pRenderTarget == This->renderTarget) {
TRACE("Trying to do a NOP SetRenderTarget operation\n"); TRACE("(%p) Relay\n" , This);
} else {
/* Otherwise, set the render target up */ if (ppRenderTarget == NULL) {
TRACE("(%p) : newRender@%p (default is backbuffer=(%p))\n", This, pRenderTarget, This->backBuffer); return D3DERR_INVALIDCALL;
hr = E_FAIL; /* not supported yet */
} }
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_SetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pZStencilSurface) {
HRESULT WINAPI IDirect3DDevice9Impl_GetRenderTarget(LPDIRECT3DDEVICE9 iface, DWORD RenderTargetIndex, IDirect3DSurface9** ppRenderTarget) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
TRACE("(%p)->returning (%p) default is backbuffer=(%p)\n", This, This->renderTarget, This->backBuffer); IDirect3DSurface9Impl *pSurface;
*ppRenderTarget = (LPDIRECT3DSURFACE9) This->renderTarget;
IDirect3DSurface9Impl_AddRef((LPDIRECT3DSURFACE9) *ppRenderTarget); TRACE("(%p) Relay\n" , This);
return D3D_OK;
pSurface = (IDirect3DSurface9Impl*)pZStencilSurface;
return IWineD3DDevice_SetDepthStencilSurface(This->WineD3DDevice,NULL==pSurface?NULL:(IWineD3DSurface*)pSurface->wineD3DSurface);
} }
/* TODO: move to wineD3D */ HRESULT WINAPI IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9 **ppZStencilSurface) {
HRESULT WINAPI IDirect3DDevice9Impl_SetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9* pZStencilSurface) {
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface;
HRESULT hr = S_OK; HRESULT hr = D3D_OK;
/* If we are trying to set what we already have, don't bother */ IWineD3DSurface *pZStencilSurface;
if ((IDirect3DSurface9Impl*) pZStencilSurface == This->stencilBufferTarget) {
TRACE("Trying to do a NOP SetDepthStencilSurface operation\n"); TRACE("(%p) Relay\n" , This);
} else { if(ppZStencilSurface == NULL){
/* Otherwise, set the target up */ return D3DERR_INVALIDCALL;
TRACE("(%p) : newDepthStencil@%p (default is stencilbuffer=(%p))\n", This, pZStencilSurface, This->depthStencilBuffer);
hr = E_FAIL; /* not supported yet */
} }
return D3D_OK;
}
/* TODO: move to wineD3D */ hr=IWineD3DDevice_GetDepthStencilSurface(This->WineD3DDevice,&pZStencilSurface);
HRESULT WINAPI IDirect3DDevice9Impl_GetDepthStencilSurface(LPDIRECT3DDEVICE9 iface, IDirect3DSurface9** ppZStencilSurface) { if(hr == D3D_OK && pZStencilSurface != NULL){
IDirect3DDevice9Impl *This = (IDirect3DDevice9Impl *)iface; IWineD3DResource_GetParent((IWineD3DResource *)pZStencilSurface,(IUnknown**)ppZStencilSurface);
TRACE("(%p)->returning (%p) default is stencilbuffer=(%p)\n", This, This->stencilBufferTarget, This->depthStencilBuffer); IWineD3DResource_Release((IWineD3DResource *)pZStencilSurface);
*ppZStencilSurface = (LPDIRECT3DSURFACE9) This->stencilBufferTarget; }else{
if (NULL != *ppZStencilSurface) IDirect3DSurface9Impl_AddRef((LPDIRECT3DSURFACE9) *ppZStencilSurface); FIXME("Call to IWineD3DDevice_GetRenderTarget failed\n");
*ppZStencilSurface = NULL;
}
return D3D_OK; return D3D_OK;
} }
......
...@@ -1572,7 +1572,6 @@ HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, D3DDEV ...@@ -1572,7 +1572,6 @@ HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, D3DDEV
object->createParms.BehaviorFlags = BehaviourFlags; object->createParms.BehaviorFlags = BehaviourFlags;
/* Initialize other useful values */ /* Initialize other useful values */
object->presentParms.BackBufferCount = 1; /* Opengl only supports one? */
object->adapterNo = Adapter; object->adapterNo = Adapter;
object->devType = DeviceType; object->devType = DeviceType;
......
...@@ -1761,4 +1761,138 @@ SHORT D3DFmtGetBpp(IWineD3DDeviceImpl* This, D3DFORMAT fmt) { ...@@ -1761,4 +1761,138 @@ SHORT D3DFmtGetBpp(IWineD3DDeviceImpl* This, D3DFORMAT fmt) {
TRACE("bytes/Pxl for fmt(%u,%s) = %d\n", fmt, debug_d3dformat(fmt), retVal); TRACE("bytes/Pxl for fmt(%u,%s) = %d\n", fmt, debug_d3dformat(fmt), retVal);
return 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 #undef GLINFO_LOCATION
...@@ -394,7 +394,6 @@ typedef struct IWineD3DDeviceImpl ...@@ -394,7 +394,6 @@ typedef struct IWineD3DDeviceImpl
/* Internal use fields */ /* Internal use fields */
D3DDEVICE_CREATION_PARAMETERS createParms; D3DDEVICE_CREATION_PARAMETERS createParms;
D3DPRESENT_PARAMETERS presentParms;
UINT adapterNo; UINT adapterNo;
D3DDEVTYPE devType; D3DDEVTYPE devType;
...@@ -403,8 +402,6 @@ typedef struct IWineD3DDeviceImpl ...@@ -403,8 +402,6 @@ typedef struct IWineD3DDeviceImpl
int numberOfSwapChains; int numberOfSwapChains;
/* Render Target Support */ /* Render Target Support */
IWineD3DSurface *frontBuffer;
IWineD3DSurface *backBuffer;
IWineD3DSurface *depthStencilBuffer; IWineD3DSurface *depthStencilBuffer;
IWineD3DSurface *renderTarget; IWineD3DSurface *renderTarget;
...@@ -850,6 +847,9 @@ GLenum D3DFmt2GLFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt); ...@@ -850,6 +847,9 @@ GLenum D3DFmt2GLFmt(IWineD3DDeviceImpl* This, D3DFORMAT fmt);
GLenum D3DFmt2GLType(IWineD3DDeviceImpl *This, D3DFORMAT fmt); GLenum D3DFmt2GLType(IWineD3DDeviceImpl *This, D3DFORMAT fmt);
GLint D3DFmt2GLIntFmt(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 * 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