Commit 9de53720 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Introduce a function to update a swapchain's render_to_fbo field.

parent 7b19efd9
......@@ -5879,31 +5879,7 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
stateblock_init_default_state(device->stateBlock);
if(wined3d_settings.offscreen_rendering_mode == ORM_FBO)
{
RECT client_rect;
GetClientRect(swapchain->win_handle, &client_rect);
if(!swapchain->presentParms.BackBufferCount)
{
TRACE("Single buffered rendering\n");
swapchain->render_to_fbo = FALSE;
}
else if(swapchain->presentParms.BackBufferWidth != client_rect.right ||
swapchain->presentParms.BackBufferHeight != client_rect.bottom )
{
TRACE("Rendering to FBO. Backbuffer %ux%u, window %ux%u\n",
swapchain->presentParms.BackBufferWidth,
swapchain->presentParms.BackBufferHeight,
client_rect.right, client_rect.bottom);
swapchain->render_to_fbo = TRUE;
}
else
{
TRACE("Rendering directly to GL_BACK\n");
swapchain->render_to_fbo = FALSE;
}
}
swapchain_update_render_to_fbo(swapchain);
hr = create_primary_opengl_context(device, swapchain);
wined3d_swapchain_decref(swapchain);
......
......@@ -803,6 +803,39 @@ static const struct wined3d_swapchain_ops swapchain_gdi_ops =
swapchain_gdi_present,
};
void swapchain_update_render_to_fbo(struct wined3d_swapchain *swapchain)
{
RECT client_rect;
if (wined3d_settings.offscreen_rendering_mode != ORM_FBO)
return;
if (!swapchain->presentParms.BackBufferCount)
{
TRACE("Single buffered rendering.\n");
swapchain->render_to_fbo = FALSE;
return;
}
GetClientRect(swapchain->win_handle, &client_rect);
TRACE("Backbuffer %ux%u, window %ux%u.\n",
swapchain->presentParms.BackBufferWidth,
swapchain->presentParms.BackBufferHeight,
client_rect.right, client_rect.bottom);
if (swapchain->presentParms.BackBufferWidth == client_rect.right
&& swapchain->presentParms.BackBufferHeight == client_rect.bottom)
{
TRACE("Backbuffer dimensions match window dimensions, rendering onscreen.\n");
swapchain->render_to_fbo = FALSE;
return;
}
TRACE("Rendering to FBO.\n");
swapchain->render_to_fbo = TRUE;
}
/* Do not call while under the GL lock. */
static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, WINED3DSURFTYPE surface_type,
struct wined3d_device *device, WINED3DPRESENT_PARAMETERS *present_parameters,
......@@ -885,18 +918,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, WINED3DSURFTY
}
}
swapchain->presentParms = *present_parameters;
if (wined3d_settings.offscreen_rendering_mode == ORM_FBO
&& present_parameters->BackBufferCount
&& (present_parameters->BackBufferWidth != client_rect.right
|| present_parameters->BackBufferHeight != client_rect.bottom))
{
TRACE("Rendering to FBO. Backbuffer %ux%u, window %ux%u.\n",
present_parameters->BackBufferWidth,
present_parameters->BackBufferHeight,
client_rect.right, client_rect.bottom);
swapchain->render_to_fbo = TRUE;
}
swapchain_update_render_to_fbo(swapchain);
TRACE("Creating front buffer.\n");
hr = device->device_parent->ops->create_rendertarget(device->device_parent, parent,
......
......@@ -2441,6 +2441,7 @@ void x11_copy_to_screen(const struct wined3d_swapchain *swapchain, const RECT *r
struct wined3d_context *swapchain_get_context(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
void swapchain_destroy_contexts(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
HDC swapchain_get_backup_dc(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
void swapchain_update_render_to_fbo(struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
#define DEFAULT_REFRESH_RATE 0
......
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