Module: wine Branch: master Commit: 3193505f9f52b0cb1fe2ec7539508187dcf8ccce URL: http://source.winehq.org/git/wine.git/?a=commit;h=3193505f9f52b0cb1fe2ec7539...
Author: Józef Kucia jkucia@codeweavers.com Date: Tue Jan 5 21:52:30 2016 +0100
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
---
dlls/wined3d/device.c | 45 ++++++++++++++++++++++++++++++++++++++++++ dlls/wined3d/wined3d_private.h | 3 +++ 2 files changed, 48 insertions(+)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index d8a6462..49480c5 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -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 diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 0c113a1..c591f7d 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -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;