wined3d: Avoid updating the swapchain swap interval from outside the command stream.

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Henri Verbeet 2017-04-11 23:24:23 +02:00 committed by Alexandre Julliard
parent 1b034f7fdb
commit c70486c53f
1 changed files with 45 additions and 39 deletions

View File

@ -674,6 +674,49 @@ static void wined3d_swapchain_apply_sample_count_override(const struct wined3d_s
*quality = 0;
}
static void wined3d_swapchain_update_swap_interval_cs(void *object)
{
struct wined3d_swapchain *swapchain = object;
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
int swap_interval;
context = context_acquire(swapchain->device, swapchain->front_buffer, 0);
gl_info = context->gl_info;
switch (swapchain->desc.swap_interval)
{
case WINED3DPRESENT_INTERVAL_IMMEDIATE:
swap_interval = 0;
break;
case WINED3DPRESENT_INTERVAL_DEFAULT:
case WINED3DPRESENT_INTERVAL_ONE:
swap_interval = 1;
break;
case WINED3DPRESENT_INTERVAL_TWO:
swap_interval = 2;
break;
case WINED3DPRESENT_INTERVAL_THREE:
swap_interval = 3;
break;
case WINED3DPRESENT_INTERVAL_FOUR:
swap_interval = 4;
break;
default:
FIXME("Unhandled present interval %#x.\n", swapchain->desc.swap_interval);
swap_interval = 1;
}
if (gl_info->supported[WGL_EXT_SWAP_CONTROL])
{
if (!GL_EXTCALL(wglSwapIntervalEXT(swap_interval)))
ERR("wglSwapIntervalEXT failed to set swap interval %d for context %p, last error %#x\n",
swap_interval, context, GetLastError());
}
context_release(context);
}
static void wined3d_swapchain_cs_init(void *object)
{
struct wined3d_swapchain *swapchain = object;
@ -715,7 +758,7 @@ static void wined3d_swapchain_cs_init(void *object)
context_release(swapchain->context[0]);
swapchain_update_swap_interval(swapchain);
wined3d_swapchain_update_swap_interval_cs(swapchain);
}
static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3d_device *device,
@ -1083,44 +1126,7 @@ void swapchain_update_draw_bindings(struct wined3d_swapchain *swapchain)
void swapchain_update_swap_interval(struct wined3d_swapchain *swapchain)
{
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
int swap_interval;
context = context_acquire(swapchain->device, swapchain->front_buffer, 0);
gl_info = context->gl_info;
switch (swapchain->desc.swap_interval)
{
case WINED3DPRESENT_INTERVAL_IMMEDIATE:
swap_interval = 0;
break;
case WINED3DPRESENT_INTERVAL_DEFAULT:
case WINED3DPRESENT_INTERVAL_ONE:
swap_interval = 1;
break;
case WINED3DPRESENT_INTERVAL_TWO:
swap_interval = 2;
break;
case WINED3DPRESENT_INTERVAL_THREE:
swap_interval = 3;
break;
case WINED3DPRESENT_INTERVAL_FOUR:
swap_interval = 4;
break;
default:
FIXME("Unhandled present interval %#x.\n", swapchain->desc.swap_interval);
swap_interval = 1;
}
if (gl_info->supported[WGL_EXT_SWAP_CONTROL])
{
if (!GL_EXTCALL(wglSwapIntervalEXT(swap_interval)))
ERR("wglSwapIntervalEXT failed to set swap interval %d for context %p, last error %#x\n",
swap_interval, context, GetLastError());
}
context_release(context);
wined3d_cs_init_object(swapchain->device->cs, wined3d_swapchain_update_swap_interval_cs, swapchain);
}
void wined3d_swapchain_activate(struct wined3d_swapchain *swapchain, BOOL activate)