wined3d: Kill pbuffer offscreen rendering support.

Our pbuffer support is broken, nobody cares.
This commit is contained in:
Henri Verbeet 2010-03-14 21:53:23 +01:00 committed by Alexandre Julliard
parent a8b76781bf
commit 8a107bc63a
8 changed files with 147 additions and 327 deletions

View File

@ -772,15 +772,7 @@ static void context_destroy_gl_resources(struct wined3d_context *context)
ERR("Failed to disable GL context.\n");
}
if (context->pbuffer)
{
GL_EXTCALL(wglReleasePbufferDCARB(context->pbuffer, context->hdc));
GL_EXTCALL(wglDestroyPbufferARB(context->pbuffer));
}
else
{
ReleaseDC(context->win_handle, context->hdc);
}
ReleaseDC(context->win_handle, context->hdc);
if (!pwglDeleteContext(context->glCtx))
{
@ -941,11 +933,10 @@ static void Context_MarkStateDirty(struct wined3d_context *context, DWORD state,
* This: Device to add the context for
* hdc: device context
* glCtx: WGL context to add
* pbuffer: optional pbuffer used with this context
*
*****************************************************************************/
static struct wined3d_context *AddContextToArray(IWineD3DDeviceImpl *This,
HWND win_handle, HDC hdc, HGLRC glCtx, HPBUFFERARB pbuffer)
HWND win_handle, HDC hdc, HGLRC glCtx)
{
struct wined3d_context **oldArray = This->contexts;
DWORD state;
@ -970,7 +961,6 @@ static struct wined3d_context *AddContextToArray(IWineD3DDeviceImpl *This,
This->contexts[This->numContexts]->hdc = hdc;
This->contexts[This->numContexts]->glCtx = glCtx;
This->contexts[This->numContexts]->pbuffer = pbuffer;
This->contexts[This->numContexts]->win_handle = win_handle;
HeapFree(GetProcessHeap(), 0, oldArray);
@ -989,7 +979,7 @@ static struct wined3d_context *AddContextToArray(IWineD3DDeviceImpl *This,
/* This function takes care of WineD3D pixel format selection. */
static int WineD3D_ChoosePixelFormat(IWineD3DDeviceImpl *This, HDC hdc,
const struct GlPixelFormatDesc *color_format_desc, const struct GlPixelFormatDesc *ds_format_desc,
BOOL auxBuffers, int numSamples, BOOL pbuffer, BOOL findCompatible)
BOOL auxBuffers, int numSamples, BOOL findCompatible)
{
int iPixelFormat=0;
unsigned int matchtry;
@ -1019,9 +1009,9 @@ static int WineD3D_ChoosePixelFormat(IWineD3DDeviceImpl *This, HDC hdc,
int i = 0;
int nCfgs = This->adapter->nCfgs;
TRACE("ColorFormat=%s, DepthStencilFormat=%s, auxBuffers=%d, numSamples=%d, pbuffer=%d, findCompatible=%d\n",
TRACE("ColorFormat=%s, DepthStencilFormat=%s, auxBuffers=%d, numSamples=%d, findCompatible=%d\n",
debug_d3dformat(color_format_desc->format), debug_d3dformat(ds_format_desc->format),
auxBuffers, numSamples, pbuffer, findCompatible);
auxBuffers, numSamples, findCompatible);
if (!getColorBits(color_format_desc, &redBits, &greenBits, &blueBits, &alphaBits, &colorBits))
{
@ -1059,18 +1049,14 @@ static int WineD3D_ChoosePixelFormat(IWineD3DDeviceImpl *This, HDC hdc,
if(cfg->iPixelType != WGL_TYPE_RGBA_ARB)
continue;
/* In window mode (!pbuffer) we need a window drawable format and double buffering. */
if(!pbuffer && !(cfg->windowDrawable && cfg->doubleBuffer))
/* In window mode we need a window drawable format and double buffering. */
if(!(cfg->windowDrawable && cfg->doubleBuffer))
continue;
/* We like to have aux buffers in backbuffer mode */
if(auxBuffers && !cfg->auxBuffers && matches[matchtry].require_aux)
continue;
/* In pbuffer-mode we need a pbuffer-capable format but we don't want double buffering */
if(pbuffer && (!cfg->pbufferDrawable || cfg->doubleBuffer))
continue;
if(matches[matchtry].exact_color) {
if(cfg->redSize != redBits)
continue;
@ -1167,173 +1153,143 @@ static int WineD3D_ChoosePixelFormat(IWineD3DDeviceImpl *This, HDC hdc,
/*****************************************************************************
* context_create
*
* Creates a new context for a window, or a pbuffer context.
* Creates a new context.
*
* * Params:
* This: Device to activate the context for
* target: Surface this context will render to
* win_handle: handle to the window which we are drawing to
* create_pbuffer: tells whether to create a pbuffer or not
* pPresentParameters: contains the pixelformats to use for onscreen rendering
*
*****************************************************************************/
struct wined3d_context *context_create(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target,
HWND win_handle, BOOL create_pbuffer, const WINED3DPRESENT_PARAMETERS *pPresentParms)
HWND win_handle, const WINED3DPRESENT_PARAMETERS *pPresentParms)
{
const struct wined3d_gl_info *gl_info = &This->adapter->gl_info;
const struct GlPixelFormatDesc *color_format_desc;
const struct GlPixelFormatDesc *ds_format_desc;
struct wined3d_context *ret = NULL;
HPBUFFERARB pbuffer = NULL;
PIXELFORMATDESCRIPTOR pfd;
BOOL auxBuffers = FALSE;
int numSamples = 0;
int pixel_format;
unsigned int s;
HGLRC ctx;
HDC hdc;
int res;
TRACE("(%p): Creating a %s context for render target %p\n", This, create_pbuffer ? "offscreen" : "onscreen", target);
TRACE("device %p, target %p, window %p, present parameters %p.\n",
This, target, win_handle, pPresentParms);
if(create_pbuffer) {
HDC hdc_parent = GetDC(win_handle);
int iPixelFormat = 0;
if (!(hdc = GetDC(win_handle)))
{
ERR("Failed to retrieve a device context.\n");
goto out;
}
IWineD3DSurface *StencilSurface = This->stencilBufferTarget;
const struct GlPixelFormatDesc *ds_format_desc = StencilSurface
? ((IWineD3DSurfaceImpl *)StencilSurface)->resource.format_desc
: getFormatDescEntry(WINED3DFMT_UNKNOWN, &This->adapter->gl_info);
ds_format_desc = getFormatDescEntry(WINED3DFMT_UNKNOWN, gl_info);
color_format_desc = target->resource.format_desc;
/* Try to find a pixel format with pbuffer support. */
iPixelFormat = WineD3D_ChoosePixelFormat(This, hdc_parent, target->resource.format_desc,
ds_format_desc, FALSE /* auxBuffers */, 0 /* numSamples */, TRUE /* PBUFFER */,
FALSE /* findCompatible */);
if(!iPixelFormat) {
TRACE("Trying to locate a compatible pixel format because an exact match failed.\n");
/* In case of ORM_BACKBUFFER, make sure to request an alpha component for
* X4R4G4B4/X8R8G8B8 as we might need it for the backbuffer. */
if (wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER)
{
auxBuffers = TRUE;
/* For some reason we weren't able to find a format, try to find something instead of crashing.
* A reason for failure could have been wglChoosePixelFormatARB strictness. */
iPixelFormat = WineD3D_ChoosePixelFormat(This, hdc_parent, target->resource.format_desc,
ds_format_desc, FALSE /* auxBuffer */, 0 /* numSamples */, TRUE /* PBUFFER */,
TRUE /* findCompatible */);
}
/* This shouldn't happen as ChoosePixelFormat always returns something */
if(!iPixelFormat) {
ERR("Unable to locate a pixel format for a pbuffer\n");
ReleaseDC(win_handle, hdc_parent);
goto out;
}
TRACE("Creating a pBuffer drawable for the new context\n");
pbuffer = GL_EXTCALL(wglCreatePbufferARB(hdc_parent, iPixelFormat, target->currentDesc.Width, target->currentDesc.Height, 0));
if(!pbuffer) {
ERR("Cannot create a pbuffer\n");
ReleaseDC(win_handle, hdc_parent);
goto out;
}
/* In WGL a pbuffer is 'wrapped' inside a HDC to 'fool' wglMakeCurrent */
hdc = GL_EXTCALL(wglGetPbufferDCARB(pbuffer));
if(!hdc) {
ERR("Cannot get a HDC for pbuffer (%p)\n", pbuffer);
GL_EXTCALL(wglDestroyPbufferARB(pbuffer));
ReleaseDC(win_handle, hdc_parent);
goto out;
}
ReleaseDC(win_handle, hdc_parent);
} else {
PIXELFORMATDESCRIPTOR pfd;
int iPixelFormat;
int res;
const struct GlPixelFormatDesc *color_format_desc = target->resource.format_desc;
const struct GlPixelFormatDesc *ds_format_desc = getFormatDescEntry(WINED3DFMT_UNKNOWN,
&This->adapter->gl_info);
BOOL auxBuffers = FALSE;
int numSamples = 0;
hdc = GetDC(win_handle);
if(hdc == NULL) {
ERR("Cannot retrieve a device context!\n");
goto out;
}
/* In case of ORM_BACKBUFFER, make sure to request an alpha component for X4R4G4B4/X8R8G8B8 as we might need it for the backbuffer. */
if(wined3d_settings.offscreen_rendering_mode == ORM_BACKBUFFER) {
auxBuffers = TRUE;
if (color_format_desc->format == WINED3DFMT_B4G4R4X4_UNORM)
color_format_desc = getFormatDescEntry(WINED3DFMT_B4G4R4A4_UNORM, &This->adapter->gl_info);
else if (color_format_desc->format == WINED3DFMT_B8G8R8X8_UNORM)
color_format_desc = getFormatDescEntry(WINED3DFMT_B8G8R8A8_UNORM, &This->adapter->gl_info);
}
/* DirectDraw supports 8bit paletted render targets and these are used by old games like Starcraft and C&C.
* Most modern hardware doesn't support 8bit natively so we perform some form of 8bit -> 32bit conversion.
* The conversion (ab)uses the alpha component for storing the palette index. For this reason we require
* a format with 8bit alpha, so request A8R8G8B8. */
if (color_format_desc->format == WINED3DFMT_P8_UINT)
if (color_format_desc->format == WINED3DFMT_B4G4R4X4_UNORM)
color_format_desc = getFormatDescEntry(WINED3DFMT_B4G4R4A4_UNORM, &This->adapter->gl_info);
else if (color_format_desc->format == WINED3DFMT_B8G8R8X8_UNORM)
color_format_desc = getFormatDescEntry(WINED3DFMT_B8G8R8A8_UNORM, &This->adapter->gl_info);
}
/* Retrieve the depth stencil format from the present parameters.
* The choice of the proper format can give a nice performance boost
* in case of GPU limited programs. */
if(pPresentParms->EnableAutoDepthStencil) {
TRACE("pPresentParms->EnableAutoDepthStencil=enabled; using AutoDepthStencilFormat=%s\n", debug_d3dformat(pPresentParms->AutoDepthStencilFormat));
ds_format_desc = getFormatDescEntry(pPresentParms->AutoDepthStencilFormat, &This->adapter->gl_info);
/* DirectDraw supports 8bit paletted render targets and these are used by
* old games like Starcraft and C&C. Most modern hardware doesn't support
* 8bit natively so we perform some form of 8bit -> 32bit conversion. The
* conversion (ab)uses the alpha component for storing the palette index.
* For this reason we require a format with 8bit alpha, so request
* A8R8G8B8. */
if (color_format_desc->format == WINED3DFMT_P8_UINT)
color_format_desc = getFormatDescEntry(WINED3DFMT_B8G8R8A8_UNORM, &This->adapter->gl_info);
/* Retrieve the depth stencil format from the present parameters.
* The choice of the proper format can give a nice performance boost
* in case of GPU limited programs. */
if (pPresentParms->EnableAutoDepthStencil)
{
TRACE("Auto depth stencil enabled, using format %s.\n",
debug_d3dformat(pPresentParms->AutoDepthStencilFormat));
ds_format_desc = getFormatDescEntry(pPresentParms->AutoDepthStencilFormat, &This->adapter->gl_info);
}
/* D3D only allows multisampling when SwapEffect is set to WINED3DSWAPEFFECT_DISCARD. */
if (pPresentParms->MultiSampleType && (pPresentParms->SwapEffect == WINED3DSWAPEFFECT_DISCARD))
{
if (!gl_info->supported[ARB_MULTISAMPLE])
WARN("The application is requesting multisampling without support.\n");
else
{
TRACE("Requesting multisample type %#x.\n", pPresentParms->MultiSampleType);
numSamples = pPresentParms->MultiSampleType;
}
}
/* D3D only allows multisampling when SwapEffect is set to WINED3DSWAPEFFECT_DISCARD */
if(pPresentParms->MultiSampleType && (pPresentParms->SwapEffect == WINED3DSWAPEFFECT_DISCARD)) {
if (!gl_info->supported[ARB_MULTISAMPLE])
ERR("The program is requesting multisampling without support!\n");
else
/* Try to find a pixel format which matches our requirements. */
pixel_format = WineD3D_ChoosePixelFormat(This, hdc, color_format_desc, ds_format_desc,
auxBuffers, numSamples, FALSE /* findCompatible */);
/* Try to locate a compatible format if we weren't able to find anything. */
if (!pixel_format)
{
TRACE("Trying to locate a compatible pixel format because an exact match failed.\n");
pixel_format = WineD3D_ChoosePixelFormat(This, hdc, color_format_desc, ds_format_desc,
auxBuffers, 0 /* numSamples */, TRUE /* findCompatible */);
}
/* If we still don't have a pixel format, something is very wrong as ChoosePixelFormat barely fails */
if (!pixel_format)
{
ERR("Can't find a suitable pixel format.\n");
return NULL;
}
DescribePixelFormat(hdc, pixel_format, sizeof(pfd), &pfd);
res = SetPixelFormat(hdc, pixel_format, NULL);
if (!res)
{
int oldPixelFormat = GetPixelFormat(hdc);
/* By default WGL doesn't allow pixel format adjustments but we need
* it here. For this reason there is a WINE-specific wglSetPixelFormat
* which allows you to set the pixel format multiple times. Only use
* it when it is really needed. */
if (oldPixelFormat == pixel_format)
{
/* We don't have to do anything as the formats are the same :) */
}
else if (oldPixelFormat && gl_info->supported[WGL_WINE_PIXEL_FORMAT_PASSTHROUGH])
{
res = GL_EXTCALL(wglSetPixelFormatWINE(hdc, pixel_format, NULL));
if (!res)
{
TRACE("Requesting multisample type %#x.\n", pPresentParms->MultiSampleType);
numSamples = pPresentParms->MultiSampleType;
}
}
/* Try to find a pixel format which matches our requirements */
iPixelFormat = WineD3D_ChoosePixelFormat(This, hdc, color_format_desc, ds_format_desc,
auxBuffers, numSamples, FALSE /* PBUFFER */, FALSE /* findCompatible */);
/* Try to locate a compatible format if we weren't able to find anything */
if(!iPixelFormat) {
TRACE("Trying to locate a compatible pixel format because an exact match failed.\n");
iPixelFormat = WineD3D_ChoosePixelFormat(This, hdc, color_format_desc, ds_format_desc,
auxBuffers, 0 /* numSamples */, FALSE /* PBUFFER */, TRUE /* findCompatible */ );
}
/* If we still don't have a pixel format, something is very wrong as ChoosePixelFormat barely fails */
if(!iPixelFormat) {
ERR("Can't find a suitable iPixelFormat\n");
return NULL;
}
DescribePixelFormat(hdc, iPixelFormat, sizeof(pfd), &pfd);
res = SetPixelFormat(hdc, iPixelFormat, NULL);
if(!res) {
int oldPixelFormat = GetPixelFormat(hdc);
/* By default WGL doesn't allow pixel format adjustments but we need it here.
* For this reason there is a WINE-specific wglSetPixelFormat which allows you to
* set the pixel format multiple times. Only use it when it is really needed. */
if(oldPixelFormat == iPixelFormat) {
/* We don't have to do anything as the formats are the same :) */
}
else if (oldPixelFormat && gl_info->supported[WGL_WINE_PIXEL_FORMAT_PASSTHROUGH])
{
res = GL_EXTCALL(wglSetPixelFormatWINE(hdc, iPixelFormat, NULL));
if(!res) {
ERR("wglSetPixelFormatWINE failed on HDC=%p for iPixelFormat=%d\n", hdc, iPixelFormat);
return NULL;
}
} else if(oldPixelFormat) {
/* OpenGL doesn't allow pixel format adjustments. Print an error and continue using the old format.
* There's a big chance that the old format works although with a performance hit and perhaps rendering errors. */
ERR("HDC=%p is already set to iPixelFormat=%d and OpenGL doesn't allow changes!\n", hdc, oldPixelFormat);
} else {
ERR("SetPixelFormat failed on HDC=%p for iPixelFormat=%d\n", hdc, iPixelFormat);
ERR("wglSetPixelFormatWINE failed on HDC %p for pixel_format %d.\n", hdc, pixel_format);
return NULL;
}
}
else if (oldPixelFormat)
{
/* OpenGL doesn't allow pixel format adjustments. Print an error
* and continue using the old format. There's a big chance that
* the old format works although with a performance hit and perhaps
* rendering errors. */
ERR("HDC %p is already set to pixel_format %d and OpenGL doesn't allow changes.\n", hdc, oldPixelFormat);
}
else
{
ERR("SetPixelFormat failed on HDC %p for pixel format %d.\n", hdc, pixel_format);
return NULL;
}
}
ctx = pwglCreateContext(hdc);
@ -1349,13 +1305,9 @@ struct wined3d_context *context_create(IWineD3DDeviceImpl *This, IWineD3DSurface
if(!ctx) {
ERR("Failed to create a WGL context\n");
if(create_pbuffer) {
GL_EXTCALL(wglReleasePbufferDCARB(pbuffer, hdc));
GL_EXTCALL(wglDestroyPbufferARB(pbuffer));
}
goto out;
}
ret = AddContextToArray(This, win_handle, hdc, ctx, pbuffer);
ret = AddContextToArray(This, win_handle, hdc, ctx);
if(!ret) {
ERR("Failed to add the newly created context to the context list\n");
if (!pwglDeleteContext(ctx))
@ -1363,10 +1315,6 @@ struct wined3d_context *context_create(IWineD3DDeviceImpl *This, IWineD3DSurface
DWORD err = GetLastError();
ERR("wglDeleteContext(%p) failed, last error %#x.\n", ctx, err);
}
if(create_pbuffer) {
GL_EXTCALL(wglReleasePbufferDCARB(pbuffer, hdc));
GL_EXTCALL(wglDestroyPbufferARB(pbuffer));
}
goto out;
}
ret->valid = 1;
@ -1922,78 +1870,26 @@ static struct wined3d_context *FindContext(IWineD3DDeviceImpl *This, IWineD3DSur
old_render_offscreen = context->render_offscreen;
context->render_offscreen = surface_is_offscreen(target);
/* The context != This->activeContext will catch a NOP context change. This can occur
* if we are switching back to swapchain rendering in case of FBO or Back Buffer offscreen
* rendering. No context change is needed in that case
*/
if(wined3d_settings.offscreen_rendering_mode == ORM_PBUFFER) {
if(This->pbufferContext && tid == This->pbufferContext->tid) {
This->pbufferContext->tid = 0;
}
}
IWineD3DSwapChain_Release(swapchain);
}
else
{
TRACE("Rendering offscreen\n");
retry:
if (wined3d_settings.offscreen_rendering_mode == ORM_PBUFFER)
/* Stay with the currently active context. */
if (current_context && ((IWineD3DSurfaceImpl *)current_context->surface)->resource.device == This)
{
IWineD3DSurfaceImpl *targetimpl = (IWineD3DSurfaceImpl *)target;
if (!This->pbufferContext
|| This->pbufferWidth < targetimpl->currentDesc.Width
|| This->pbufferHeight < targetimpl->currentDesc.Height)
{
if (This->pbufferContext) context_destroy(This, This->pbufferContext);
/* The display is irrelevant here, the window is 0. But
* context_create() needs a valid X connection. Create the context
* on the same server as the primary swapchain. The primary
* swapchain is exists at this point. */
This->pbufferContext = context_create(This, targetimpl,
((IWineD3DSwapChainImpl *)This->swapchains[0])->context[0]->win_handle,
TRUE /* pbuffer */, &((IWineD3DSwapChainImpl *)This->swapchains[0])->presentParms);
This->pbufferWidth = targetimpl->currentDesc.Width;
This->pbufferHeight = targetimpl->currentDesc.Height;
if (This->pbufferContext) context_release(This->pbufferContext);
}
if (This->pbufferContext)
{
if (This->pbufferContext->tid && This->pbufferContext->tid != tid)
{
FIXME("The PBuffer context is only supported for one thread for now!\n");
}
This->pbufferContext->tid = tid;
context = This->pbufferContext;
}
else
{
ERR("Failed to create a buffer context and drawable, falling back to back buffer offscreen rendering.\n");
wined3d_settings.offscreen_rendering_mode = ORM_BACKBUFFER;
goto retry;
}
context = current_context;
}
else
{
/* Stay with the currently active context. */
if (current_context
&& ((IWineD3DSurfaceImpl *)current_context->surface)->resource.device == This)
{
context = current_context;
}
else
{
/* This may happen if the app jumps straight into offscreen rendering
* Start using the context of the primary swapchain. tid == 0 is no problem
* for findThreadContextForSwapChain.
*
* Can also happen on thread switches - in that case findThreadContextForSwapChain
* is perfect to call. */
context = findThreadContextForSwapChain(This->swapchains[0], tid);
}
/* This may happen if the app jumps straight into offscreen rendering
* Start using the context of the primary swapchain. tid == 0 is no problem
* for findThreadContextForSwapChain.
*
* Can also happen on thread switches - in that case findThreadContextForSwapChain
* is perfect to call. */
context = findThreadContextForSwapChain(This->swapchains[0], tid);
}
old_render_offscreen = context->render_offscreen;

View File

@ -1583,10 +1583,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface,
This->offscreenBuffer = GL_COLOR_ATTACHMENT0;
break;
case ORM_PBUFFER:
This->offscreenBuffer = GL_BACK;
break;
case ORM_BACKBUFFER:
{
if (context_get_current()->aux_buffers > 0)
@ -1720,9 +1716,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface,
}
}
/* Delete the pbuffer context if there is any */
if(This->pbufferContext) context_destroy(This, This->pbufferContext);
/* Delete the mouse cursor texture */
if(This->cursorTexture) {
ENTER_GL();
@ -6387,7 +6380,7 @@ HRESULT create_primary_opengl_context(IWineD3DDevice *iface, IWineD3DSwapChain *
}
target = (IWineD3DSurfaceImpl *)(swapchain->backBuffer ? swapchain->backBuffer[0] : swapchain->frontBuffer);
context = context_create(This, target, swapchain->win_handle, FALSE, &swapchain->presentParms);
context = context_create(This, target, swapchain->win_handle, &swapchain->presentParms);
if (!context)
{
WARN("Failed to create context.\n");
@ -7090,14 +7083,6 @@ void IWineD3DDeviceImpl_MarkStateDirty(IWineD3DDeviceImpl *This, DWORD state) {
}
}
void get_drawable_size_pbuffer(struct wined3d_context *context, UINT *width, UINT *height)
{
IWineD3DDeviceImpl *device = ((IWineD3DSurfaceImpl *)context->current_rt)->resource.device;
/* The drawable size of a pbuffer render target is the current pbuffer size. */
*width = device->pbufferWidth;
*height = device->pbufferHeight;
}
void get_drawable_size_fbo(struct wined3d_context *context, UINT *width, UINT *height)
{
IWineD3DSurfaceImpl *surface = (IWineD3DSurfaceImpl *)context->current_rt;

View File

@ -2522,10 +2522,6 @@ static BOOL IWineD3DImpl_FillGLCaps(struct wined3d_adapter *adapter)
ThisExtn[len] = '\0';
TRACE_(d3d_caps)("- %s\n", debugstr_a(ThisExtn));
if (!strcmp(ThisExtn, "WGL_ARB_pbuffer")) {
gl_info->supported[WGL_ARB_PBUFFER] = TRUE;
TRACE_(d3d_caps)("FOUND: WGL_ARB_pbuffer support\n");
}
if (!strcmp(ThisExtn, "WGL_ARB_pixel_format")) {
gl_info->supported[WGL_ARB_PIXEL_FORMAT] = TRUE;
TRACE_(d3d_caps)("FOUND: WGL_ARB_pixel_format support\n");
@ -3204,23 +3200,9 @@ static BOOL CheckRenderTargetCapability(struct wined3d_adapter *adapter,
return TRUE;
}
}
} else if(wined3d_settings.offscreen_rendering_mode == ORM_PBUFFER) {
/* We can probably use this function in FBO mode too on some drivers to get some basic indication of the capabilities. */
WineD3D_PixelFormat *cfgs = adapter->cfgs;
int it;
/* Check if there is a WGL pixel format matching the requirements, the pixel format should also be usable with pbuffers */
for (it = 0; it < adapter->nCfgs; ++it)
{
if (cfgs[it].pbufferDrawable && IWineD3DImpl_IsPixelFormatCompatibleWithRenderFmt(&adapter->gl_info,
&cfgs[it], check_format_desc))
{
TRACE_(d3d_caps)("iPixelFormat=%d is compatible with CheckFormat=%s\n",
cfgs[it].iPixelFormat, debug_d3dformat(check_format_desc->format));
return TRUE;
}
}
} else if(wined3d_settings.offscreen_rendering_mode == ORM_FBO){
}
else if(wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
/* For now return TRUE for FBOs until we have some proper checks.
* Note that this function will only be called when the format is around for texturing. */
return TRUE;
@ -5120,17 +5102,6 @@ BOOL InitAdapters(IWineD3DImpl *This)
cfgs->doubleBuffer = values[9];
cfgs->auxBuffers = values[10];
cfgs->pbufferDrawable = FALSE;
/* Check for pbuffer support when it is around as
* wglGetPixelFormatAttribiv fails for unknown attributes. */
if (gl_info->supported[WGL_ARB_PBUFFER])
{
int attrib = WGL_DRAW_TO_PBUFFER_ARB;
int value;
if(GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc, iPixelFormat, 0, 1, &attrib, &value)))
cfgs->pbufferDrawable = value;
}
cfgs->numSamples = 0;
/* Check multisample support */
if (gl_info->supported[ARB_MULTISAMPLE])
@ -5145,7 +5116,11 @@ BOOL InitAdapters(IWineD3DImpl *This)
}
}
TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, depth=%d, stencil=%d, samples=%d, windowDrawable=%d, pbufferDrawable=%d\n", cfgs->iPixelFormat, cfgs->iPixelType, cfgs->doubleBuffer, cfgs->redSize, cfgs->greenSize, cfgs->blueSize, cfgs->alphaSize, cfgs->depthSize, cfgs->stencilSize, cfgs->numSamples, cfgs->windowDrawable, cfgs->pbufferDrawable);
TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
"depth=%d, stencil=%d, samples=%d, windowDrawable=%d\n",
cfgs->iPixelFormat, cfgs->iPixelType, cfgs->doubleBuffer,
cfgs->redSize, cfgs->greenSize, cfgs->blueSize, cfgs->alphaSize,
cfgs->depthSize, cfgs->stencilSize, cfgs->numSamples, cfgs->windowDrawable);
cfgs++;
}
}
@ -5182,14 +5157,17 @@ BOOL InitAdapters(IWineD3DImpl *This)
cfgs->colorSize = ppfd.cColorBits;
cfgs->depthSize = ppfd.cDepthBits;
cfgs->stencilSize = ppfd.cStencilBits;
cfgs->pbufferDrawable = 0;
cfgs->windowDrawable = (ppfd.dwFlags & PFD_DRAW_TO_WINDOW) ? 1 : 0;
cfgs->iPixelType = (ppfd.iPixelType == PFD_TYPE_RGBA) ? WGL_TYPE_RGBA_ARB : WGL_TYPE_COLORINDEX_ARB;
cfgs->doubleBuffer = (ppfd.dwFlags & PFD_DOUBLEBUFFER) ? 1 : 0;
cfgs->auxBuffers = ppfd.cAuxBuffers;
cfgs->numSamples = 0;
TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, depth=%d, stencil=%d, windowDrawable=%d, pbufferDrawable=%d\n", cfgs->iPixelFormat, cfgs->iPixelType, cfgs->doubleBuffer, cfgs->redSize, cfgs->greenSize, cfgs->blueSize, cfgs->alphaSize, cfgs->depthSize, cfgs->stencilSize, cfgs->windowDrawable, cfgs->pbufferDrawable);
TRACE("iPixelFormat=%d, iPixelType=%#x, doubleBuffer=%d, RGBA=%d/%d/%d/%d, "
"depth=%d, stencil=%d, windowDrawable=%d\n",
cfgs->iPixelFormat, cfgs->iPixelType, cfgs->doubleBuffer,
cfgs->redSize, cfgs->greenSize, cfgs->blueSize, cfgs->alphaSize,
cfgs->depthSize, cfgs->stencilSize, cfgs->windowDrawable);
cfgs++;
adapter->nCfgs++;
}

View File

@ -4458,7 +4458,6 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_PrivateSetup(IWineD3DSurface *iface) {
if(This->resource.usage & WINED3DUSAGE_RENDERTARGET) {
switch(wined3d_settings.offscreen_rendering_mode) {
case ORM_FBO: This->get_drawable_size = get_drawable_size_fbo; break;
case ORM_PBUFFER: This->get_drawable_size = get_drawable_size_pbuffer; break;
case ORM_BACKBUFFER: This->get_drawable_size = get_drawable_size_backbuffer; break;
}
}
@ -5056,7 +5055,6 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_SetContainer(IWineD3DSurface *iface, I
} else if(This->resource.usage & WINED3DUSAGE_RENDERTARGET) {
switch(wined3d_settings.offscreen_rendering_mode) {
case ORM_FBO: This->get_drawable_size = get_drawable_size_fbo; break;
case ORM_PBUFFER: This->get_drawable_size = get_drawable_size_pbuffer; break;
case ORM_BACKBUFFER: This->get_drawable_size = get_drawable_size_backbuffer; break;
}
}

View File

@ -547,7 +547,7 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_SetDestWindowOverride(IWineD3DSwapCh
context_destroy(This->device, This->context[0]);
This->context[0] = context_create(This->device, (IWineD3DSurfaceImpl *)This->frontBuffer,
This->win_handle, FALSE /* pbuffer */, &This->presentParms);
This->win_handle, &This->presentParms);
context_release(This->context[0]);
IWineD3DSurface_LockRect(This->backBuffer[0], &r, NULL, WINED3DLOCK_DISCARD);
@ -817,7 +817,7 @@ HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface
if (surface_type == SURFACE_OPENGL)
{
swapchain->context[0] = context_create(device, (IWineD3DSurfaceImpl *)swapchain->frontBuffer,
window, FALSE /* pbuffer */, present_parameters);
window, present_parameters);
if (!swapchain->context[0])
{
WARN("Failed to create context.\n");
@ -936,7 +936,7 @@ struct wined3d_context *swapchain_create_context_for_thread(IWineD3DSwapChain *i
TRACE("Creating a new context for swapchain %p, thread %d\n", This, GetCurrentThreadId());
ctx = context_create(This->device, (IWineD3DSurfaceImpl *)This->frontBuffer,
This->context[0]->win_handle, FALSE /* pbuffer */, &This->presentParms);
This->context[0]->win_handle, &This->presentParms);
if (!ctx)
{
ERR("Failed to create a new context for the swapchain\n");

View File

@ -1829,7 +1829,6 @@ typedef enum wined3d_gl_extension
SGIS_GENERATE_MIPMAP,
SGI_VIDEO_SYNC,
/* WGL extensions */
WGL_ARB_PBUFFER,
WGL_ARB_PIXEL_FORMAT,
WGL_WINE_PIXEL_FORMAT_PASSTHROUGH,
/* Internally used */
@ -3680,26 +3679,6 @@ typedef const char *(WINAPI *WINED3D_PFNWGLGETEXTENSIONSSTRINGARBPROC)(HDC hdc);
#define WGL_SAMPLES_ARB 0x2042
#endif
/* WGL_ARB_pbuffer */
#ifndef WGL_ARB_pbuffer
#define WGL_ARB_pbuffer 1
#define WGL_DRAW_TO_PBUFFER_ARB 0x202d
#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202e
#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202f
#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030
#define WGL_PBUFFER_LARGEST_ARB 0x2033
#define WGL_PBUFFER_WIDTH_ARB 0x2034
#define WGL_PBUFFER_HEIGHT_ARB 0x2035
#define WGL_PBUFFER_LOST_ARB 0x2036
#endif
DECLARE_HANDLE(HPBUFFERARB);
typedef HPBUFFERARB (WINAPI *WINED3D_PFNWGLCREATEPBUFFERARBPROC)(HDC hDC, int iPixelFormat,
int iWidth, int iHeight, const int *piAttribList);
typedef HDC (WINAPI *WINED3D_PFNWGLGETPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer);
typedef int (WINAPI *WINED3D_PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer, HDC hDC);
typedef BOOL (WINAPI *WINED3D_PFNWGLDESTROYPBUFFERARBPROC)(HPBUFFERARB hPbuffer);
typedef BOOL (WINAPI *WINED3D_PFNWGLQUERYPBUFFERARBPROC)(HPBUFFERARB hPbuffer, int iAttribute, int *piValue);
/* WGL_ARB_pixel_format */
#ifndef WGL_ARB_pixel_format
#define WGL_ARB_pixel_format 1
@ -4489,11 +4468,6 @@ typedef BOOL (WINAPI *WINED3D_PFNWGLSETPIXELFORMATWINE)(HDC hdc, int iPixelForma
USE_GL_FUNC(WINED3D_PFNWGLGETPIXELFORMATATTRIBIVARBPROC, wglGetPixelFormatAttribivARB, 0, NULL) \
USE_GL_FUNC(WINED3D_PFNWGLGETPIXELFORMATATTRIBFVARBPROC, wglGetPixelFormatAttribfvARB, 0, NULL) \
USE_GL_FUNC(WINED3D_PFNWGLCHOOSEPIXELFORMATARBPROC, wglChoosePixelFormatARB, 0, NULL) \
USE_GL_FUNC(WINED3D_PFNWGLCREATEPBUFFERARBPROC, wglCreatePbufferARB, 0, NULL) \
USE_GL_FUNC(WINED3D_PFNWGLGETPBUFFERDCARBPROC, wglGetPbufferDCARB, 0, NULL) \
USE_GL_FUNC(WINED3D_PFNWGLRELEASEPBUFFERDCARBPROC, wglReleasePbufferDCARB, 0, NULL) \
USE_GL_FUNC(WINED3D_PFNWGLDESTROYPBUFFERARBPROC, wglDestroyPbufferARB, 0, NULL) \
USE_GL_FUNC(WINED3D_PFNWGLQUERYPBUFFERARBPROC, wglQueryPbufferARB, 0, NULL) \
USE_GL_FUNC(WINED3D_PFNWGLSETPIXELFORMATWINE, wglSetPixelFormatWINE, 0, NULL)
#endif /* __WINE_WINED3D_GL */

View File

@ -236,11 +236,6 @@ static BOOL wined3d_init(HINSTANCE hInstDLL)
TRACE("Using the backbuffer for offscreen rendering\n");
wined3d_settings.offscreen_rendering_mode = ORM_BACKBUFFER;
}
else if (!strcmp(buffer,"pbuffer"))
{
TRACE("Using PBuffers for offscreen rendering\n");
wined3d_settings.offscreen_rendering_mode = ORM_PBUFFER;
}
else if (!strcmp(buffer,"fbo"))
{
TRACE("Using FBOs for offscreen rendering\n");

View File

@ -234,8 +234,7 @@ static inline float float_24_to_32(DWORD in)
#define VBO_HW 1
#define ORM_BACKBUFFER 0
#define ORM_PBUFFER 1
#define ORM_FBO 2
#define ORM_FBO 1
#define SHADER_ARB 1
#define SHADER_GLSL 2
@ -1089,7 +1088,6 @@ struct wined3d_context
HGLRC glCtx;
HWND win_handle;
HDC hdc;
HPBUFFERARB pbuffer;
GLint aux_buffers;
/* FBOs */
@ -1201,8 +1199,8 @@ void context_attach_depth_stencil_fbo(struct wined3d_context *context,
GLenum fbo_target, IWineD3DSurface *depth_stencil, BOOL use_render_buffer) DECLSPEC_HIDDEN;
void context_attach_surface_fbo(const struct wined3d_context *context,
GLenum fbo_target, DWORD idx, IWineD3DSurface *surface) DECLSPEC_HIDDEN;
struct wined3d_context *context_create(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target, HWND win,
BOOL create_pbuffer, const WINED3DPRESENT_PARAMETERS *present_parameters) DECLSPEC_HIDDEN;
struct wined3d_context *context_create(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *target,
HWND win, const WINED3DPRESENT_PARAMETERS *present_parameters) DECLSPEC_HIDDEN;
void context_destroy(IWineD3DDeviceImpl *This, struct wined3d_context *context) DECLSPEC_HIDDEN;
void context_free_event_query(struct wined3d_event_query *query) DECLSPEC_HIDDEN;
void context_free_occlusion_query(struct wined3d_occlusion_query *query) DECLSPEC_HIDDEN;
@ -1251,7 +1249,6 @@ typedef struct WineD3D_PixelFormat
int redSize, greenSize, blueSize, alphaSize, colorSize;
int depthSize, stencilSize;
BOOL windowDrawable;
BOOL pbufferDrawable;
BOOL doubleBuffer;
int auxBuffers;
int numSamples;
@ -1705,8 +1702,6 @@ struct IWineD3DDeviceImpl
/* Context management */
struct wined3d_context **contexts;
UINT numContexts;
struct wined3d_context *pbufferContext; /* The context that has a pbuffer as drawable */
DWORD pbufferWidth, pbufferHeight; /* Size of the buffer drawable */
/* High level patch management */
#define PATCHMAP_SIZE 43
@ -2153,7 +2148,6 @@ const void *WINAPI IWineD3DBaseSurfaceImpl_GetData(IWineD3DSurface *iface) DECLS
void get_drawable_size_swapchain(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
void get_drawable_size_backbuffer(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
void get_drawable_size_pbuffer(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
void get_drawable_size_fbo(struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
void flip_surface(IWineD3DSurfaceImpl *front, IWineD3DSurfaceImpl *back) DECLSPEC_HIDDEN;