wined3d: Maintain default sampler per device.

Signed-off-by: Józef Kucia <jkucia@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Józef Kucia 2016-01-05 21:52:30 +01:00 committed by Alexandre Julliard
parent 67014b7cf9
commit 3193505f9f
2 changed files with 48 additions and 0 deletions

View File

@ -773,6 +773,49 @@ static void destroy_dummy_textures(struct wined3d_device *device, const struct w
memset(device->dummy_texture_2d, 0, count * sizeof(*device->dummy_texture_2d));
}
/* Context activation is done by the caller. */
static void create_default_sampler(struct wined3d_device *device)
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
/*
* In SM4+ shaders there is a separation between resources and samplers. Some of shader
* instructions allow to access resources without using samplers.
* In GLSL resources are always accessed through sampler or image variables. The default
* sampler object is used to emulate the direct resource access when there is no sampler state
* to use.
*/
if (gl_info->supported[ARB_SAMPLER_OBJECTS])
{
GL_EXTCALL(glGenSamplers(1, &device->default_sampler));
checkGLcall("glGenSamplers");
if (gl_info->supported[EXT_TEXTURE_SRGB_DECODE])
{
GL_EXTCALL(glSamplerParameteri(device->default_sampler, GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT));
checkGLcall("glSamplerParamteri");
}
}
else
{
device->default_sampler = 0;
}
}
/* Context activation is done by the caller. */
static void destroy_default_sampler(struct wined3d_device *device)
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
if (gl_info->supported[ARB_SAMPLER_OBJECTS])
{
GL_EXTCALL(glDeleteSamplers(1, &device->default_sampler));
checkGLcall("glDeleteSamplers");
}
device->default_sampler = 0;
}
static LONG fullscreen_style(LONG style)
{
/* Make sure the window is managed, otherwise we won't get keyboard input. */
@ -972,6 +1015,7 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
surface_from_resource(wined3d_texture_get_sub_resource(swapchain->front_buffer, 0)));
create_dummy_textures(device, context);
create_default_sampler(device);
device->contexts[0]->last_was_rhw = 0;
@ -1119,6 +1163,7 @@ HRESULT CDECL wined3d_device_uninit_3d(struct wined3d_device *device)
device->blitter->free_private(device);
device->shader_backend->shader_free_private(device);
destroy_dummy_textures(device, gl_info);
destroy_default_sampler(device);
/* Release the context again as soon as possible. In particular,
* releasing the render target views below may release the last reference

View File

@ -2128,6 +2128,9 @@ struct wined3d_device
UINT dummy_texture_3d[MAX_COMBINED_SAMPLERS];
UINT dummy_texture_cube[MAX_COMBINED_SAMPLERS];
/* Default sampler used to emulate the direct resource access without using wined3d_sampler */
GLuint default_sampler;
/* Command stream */
struct wined3d_cs *cs;