Commit e318f8c8 authored by Józef Kucia's avatar Józef Kucia Committed by Alexandre Julliard

wined3d: Replace presentation interval flags with enum.

parent 0554d176
......@@ -208,6 +208,27 @@ static D3DSWAPEFFECT d3dswapeffect_from_wined3dswapeffect(enum wined3d_swap_effe
}
}
static DWORD d3dpresentationinterval_from_wined3dswapinterval(enum wined3d_swap_interval interval)
{
switch (interval)
{
case WINED3D_SWAP_INTERVAL_IMMEDIATE:
return D3DPRESENT_INTERVAL_IMMEDIATE;
case WINED3D_SWAP_INTERVAL_ONE:
return D3DPRESENT_INTERVAL_ONE;
case WINED3D_SWAP_INTERVAL_TWO:
return D3DPRESENT_INTERVAL_TWO;
case WINED3D_SWAP_INTERVAL_THREE:
return D3DPRESENT_INTERVAL_THREE;
case WINED3D_SWAP_INTERVAL_FOUR:
return D3DPRESENT_INTERVAL_FOUR;
default:
ERR("Invalid swap interval %#x.\n", interval);
case WINED3D_SWAP_INTERVAL_DEFAULT:
return D3DPRESENT_INTERVAL_DEFAULT;
}
}
static void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS *present_parameters,
const struct wined3d_swapchain_desc *swapchain_desc)
{
......@@ -224,7 +245,8 @@ static void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS
= d3dformat_from_wined3dformat(swapchain_desc->auto_depth_stencil_format);
present_parameters->Flags = swapchain_desc->flags & D3DPRESENTFLAGS_MASK;
present_parameters->FullScreen_RefreshRateInHz = swapchain_desc->refresh_rate;
present_parameters->FullScreen_PresentationInterval = swapchain_desc->swap_interval;
present_parameters->FullScreen_PresentationInterval
= d3dpresentationinterval_from_wined3dswapinterval(swapchain_desc->swap_interval);
}
static enum wined3d_swap_effect wined3dswapeffect_from_d3dswapeffect(D3DSWAPEFFECT effect)
......@@ -245,6 +267,27 @@ static enum wined3d_swap_effect wined3dswapeffect_from_d3dswapeffect(D3DSWAPEFFE
}
}
static enum wined3d_swap_interval wined3dswapinterval_from_d3dpresentationinterval(DWORD interval)
{
switch (interval)
{
case D3DPRESENT_INTERVAL_IMMEDIATE:
return WINED3D_SWAP_INTERVAL_IMMEDIATE;
case D3DPRESENT_INTERVAL_ONE:
return WINED3D_SWAP_INTERVAL_ONE;
case D3DPRESENT_INTERVAL_TWO:
return WINED3D_SWAP_INTERVAL_TWO;
case D3DPRESENT_INTERVAL_THREE:
return WINED3D_SWAP_INTERVAL_THREE;
case D3DPRESENT_INTERVAL_FOUR:
return WINED3D_SWAP_INTERVAL_FOUR;
default:
FIXME("Unhandled presentation interval %#x.\n", interval);
case D3DPRESENT_INTERVAL_DEFAULT:
return WINED3D_SWAP_INTERVAL_DEFAULT;
}
}
static BOOL wined3d_swapchain_desc_from_present_parameters(struct wined3d_swapchain_desc *swapchain_desc,
const D3DPRESENT_PARAMETERS *present_parameters)
{
......@@ -278,7 +321,8 @@ static BOOL wined3d_swapchain_desc_from_present_parameters(struct wined3d_swapch
swapchain_desc->flags
= (present_parameters->Flags & D3DPRESENTFLAGS_MASK) | WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH;
swapchain_desc->refresh_rate = present_parameters->FullScreen_RefreshRateInHz;
swapchain_desc->swap_interval = present_parameters->FullScreen_PresentationInterval;
swapchain_desc->swap_interval
= wined3dswapinterval_from_d3dpresentationinterval(present_parameters->FullScreen_PresentationInterval);
swapchain_desc->auto_restore_display_mode = TRUE;
if (present_parameters->Flags & ~D3DPRESENTFLAGS_MASK)
......
......@@ -230,6 +230,27 @@ static D3DSWAPEFFECT d3dswapeffect_from_wined3dswapeffect(enum wined3d_swap_effe
}
}
static DWORD d3dpresentationinterval_from_wined3dswapinterval(enum wined3d_swap_interval interval)
{
switch (interval)
{
case WINED3D_SWAP_INTERVAL_IMMEDIATE:
return D3DPRESENT_INTERVAL_IMMEDIATE;
case WINED3D_SWAP_INTERVAL_ONE:
return D3DPRESENT_INTERVAL_ONE;
case WINED3D_SWAP_INTERVAL_TWO:
return D3DPRESENT_INTERVAL_TWO;
case WINED3D_SWAP_INTERVAL_THREE:
return D3DPRESENT_INTERVAL_THREE;
case WINED3D_SWAP_INTERVAL_FOUR:
return D3DPRESENT_INTERVAL_FOUR;
default:
ERR("Invalid swap interval %#x.\n", interval);
case WINED3D_SWAP_INTERVAL_DEFAULT:
return D3DPRESENT_INTERVAL_DEFAULT;
}
}
void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS *present_parameters,
const struct wined3d_swapchain_desc *swapchain_desc)
{
......@@ -247,7 +268,8 @@ void present_parameters_from_wined3d_swapchain_desc(D3DPRESENT_PARAMETERS *prese
= d3dformat_from_wined3dformat(swapchain_desc->auto_depth_stencil_format);
present_parameters->Flags = swapchain_desc->flags & D3DPRESENTFLAGS_MASK;
present_parameters->FullScreen_RefreshRateInHz = swapchain_desc->refresh_rate;
present_parameters->PresentationInterval = swapchain_desc->swap_interval;
present_parameters->PresentationInterval
= d3dpresentationinterval_from_wined3dswapinterval(swapchain_desc->swap_interval);
}
static enum wined3d_swap_effect wined3dswapeffect_from_d3dswapeffect(D3DSWAPEFFECT effect)
......@@ -270,6 +292,27 @@ static enum wined3d_swap_effect wined3dswapeffect_from_d3dswapeffect(D3DSWAPEFFE
}
}
static enum wined3d_swap_interval wined3dswapinterval_from_d3dpresentationinterval(DWORD interval)
{
switch (interval)
{
case D3DPRESENT_INTERVAL_IMMEDIATE:
return WINED3D_SWAP_INTERVAL_IMMEDIATE;
case D3DPRESENT_INTERVAL_ONE:
return WINED3D_SWAP_INTERVAL_ONE;
case D3DPRESENT_INTERVAL_TWO:
return WINED3D_SWAP_INTERVAL_TWO;
case D3DPRESENT_INTERVAL_THREE:
return WINED3D_SWAP_INTERVAL_THREE;
case D3DPRESENT_INTERVAL_FOUR:
return WINED3D_SWAP_INTERVAL_FOUR;
default:
FIXME("Unhandled presentation interval %#x.\n", interval);
case D3DPRESENT_INTERVAL_DEFAULT:
return WINED3D_SWAP_INTERVAL_DEFAULT;
}
}
static BOOL wined3d_swapchain_desc_from_present_parameters(struct wined3d_swapchain_desc *swapchain_desc,
const D3DPRESENT_PARAMETERS *present_parameters, BOOL extended)
{
......@@ -305,7 +348,8 @@ static BOOL wined3d_swapchain_desc_from_present_parameters(struct wined3d_swapch
swapchain_desc->flags
= (present_parameters->Flags & D3DPRESENTFLAGS_MASK) | WINED3D_SWAPCHAIN_ALLOW_MODE_SWITCH;
swapchain_desc->refresh_rate = present_parameters->FullScreen_RefreshRateInHz;
swapchain_desc->swap_interval = present_parameters->PresentationInterval;
swapchain_desc->swap_interval
= wined3dswapinterval_from_d3dpresentationinterval(present_parameters->PresentationInterval);
swapchain_desc->auto_restore_display_mode = TRUE;
if (present_parameters->Flags & ~D3DPRESENTFLAGS_MASK)
......
......@@ -333,7 +333,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_factory_CreateSwapChainForHwnd(IWineDXGIFa
wined3d_desc.auto_depth_stencil_format = 0;
wined3d_desc.flags = wined3d_swapchain_flags_from_dxgi(swapchain_desc->Flags);
wined3d_desc.refresh_rate = fullscreen_desc ? dxgi_rational_to_uint(&fullscreen_desc->RefreshRate) : 0;
wined3d_desc.swap_interval = WINED3DPRESENT_INTERVAL_DEFAULT;
wined3d_desc.swap_interval = WINED3D_SWAP_INTERVAL_DEFAULT;
wined3d_desc.auto_restore_display_mode = TRUE;
hr = IWineDXGIDevice_create_swapchain(dxgi_device, &wined3d_desc, FALSE, &wined3d_swapchain);
......
......@@ -683,34 +683,13 @@ static void wined3d_swapchain_update_swap_interval_cs(void *object)
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;
}
swap_interval = swapchain->desc.swap_interval > 4 ? 1 : swapchain->desc.swap_interval;
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());
ERR("wglSwapIntervalEXT failed to set swap interval %d for context %p, last error %#x.\n",
swap_interval, context, GetLastError());
}
context_release(context);
......
......@@ -515,6 +515,16 @@ enum wined3d_swap_effect
WINED3D_SWAP_EFFECT_OVERLAY,
};
enum wined3d_swap_interval
{
WINED3D_SWAP_INTERVAL_IMMEDIATE = 0,
WINED3D_SWAP_INTERVAL_ONE = 1,
WINED3D_SWAP_INTERVAL_TWO = 2,
WINED3D_SWAP_INTERVAL_THREE = 3,
WINED3D_SWAP_INTERVAL_FOUR = 4,
WINED3D_SWAP_INTERVAL_DEFAULT = ~0u,
};
enum wined3d_sampler_state
{
WINED3D_SAMP_ADDRESS_U = 1,
......@@ -574,7 +584,7 @@ enum wined3d_texture_stage_state
WINED3D_TSS_ALPHA_ARG0 = 15,
WINED3D_TSS_RESULT_ARG = 16,
WINED3D_TSS_CONSTANT = 17,
WINED3D_TSS_INVALID = ~0U,
WINED3D_TSS_INVALID = ~0u,
};
#define WINED3D_HIGHEST_TEXTURE_STATE WINED3D_TSS_CONSTANT
......@@ -923,13 +933,6 @@ enum wined3d_shader_byte_code_format
#define WINED3DPRESENT_RATE_DEFAULT 0x00000000
#define WINED3DPRESENT_INTERVAL_DEFAULT 0x00000000
#define WINED3DPRESENT_INTERVAL_ONE 0x00000001
#define WINED3DPRESENT_INTERVAL_TWO 0x00000002
#define WINED3DPRESENT_INTERVAL_THREE 0x00000004
#define WINED3DPRESENT_INTERVAL_FOUR 0x00000008
#define WINED3DPRESENT_INTERVAL_IMMEDIATE 0x80000000
#define WINED3DCLIPPLANE0 (1u << 0)
#define WINED3DCLIPPLANE1 (1u << 1)
#define WINED3DCLIPPLANE2 (1u << 2)
......@@ -1724,7 +1727,7 @@ struct wined3d_swapchain_desc
enum wined3d_format_id auto_depth_stencil_format;
DWORD flags;
UINT refresh_rate;
UINT swap_interval;
enum wined3d_swap_interval swap_interval;
BOOL auto_restore_display_mode;
};
......
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