=?UTF-8?Q?J=C3=B3zef=20Kucia=20?=: wined3d: Create wined3d sampler for default sampler.

Alexandre Julliard julliard at winehq.org
Mon Mar 20 17:16:46 CDT 2017


Module: wine
Branch: master
Commit: a7dadf2f95d0cc1e38f76a53b35c75d3075f3b2a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a7dadf2f95d0cc1e38f76a53b35c75d3075f3b2a

Author: Józef Kucia <jkucia at codeweavers.com>
Date:   Mon Mar 20 12:13:04 2017 +0100

wined3d: Create wined3d sampler for default sampler.

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/context.c         |  2 +-
 dlls/wined3d/device.c          | 46 +++++++++++++++++++++++++++++-------------
 dlls/wined3d/wined3d_private.h |  2 +-
 3 files changed, 34 insertions(+), 16 deletions(-)

diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 8029de0..b554b00 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -3429,7 +3429,7 @@ static void context_bind_shader_resources(struct wined3d_context *context,
         }
 
         if (entry->sampler_idx == WINED3D_SAMPLER_DEFAULT)
-            sampler_name = device->default_sampler;
+            sampler_name = device->default_sampler->name;
         else if ((sampler = state->sampler[shader_type][entry->sampler_idx]))
             sampler_name = sampler->name;
         else
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index eef9818..ba30d20 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -776,20 +776,38 @@ static void destroy_dummy_textures(struct wined3d_device *device, struct wined3d
 static void create_default_samplers(struct wined3d_device *device, struct wined3d_context *context)
 {
     const struct wined3d_gl_info *gl_info = context->gl_info;
+    struct wined3d_sampler_desc desc;
+    HRESULT hr;
 
-    if (gl_info->supported[ARB_SAMPLER_OBJECTS])
+    desc.address_u = WINED3D_TADDRESS_WRAP;
+    desc.address_v = WINED3D_TADDRESS_WRAP;
+    desc.address_w = WINED3D_TADDRESS_WRAP;
+    memset(desc.border_color, 0, sizeof(desc.border_color));
+    desc.mag_filter = WINED3D_TEXF_POINT;
+    desc.min_filter = WINED3D_TEXF_POINT;
+    desc.mip_filter = WINED3D_TEXF_NONE;
+    desc.lod_bias = 0.0f;
+    desc.min_lod = -1000.0f;
+    desc.max_lod =  1000.0f;
+    desc.max_anisotropy = 1;
+    desc.compare = FALSE;
+    desc.comparison_func = WINED3D_CMP_NEVER;
+    desc.srgb_decode = TRUE;
+
+    /* In SM4+ shaders there is a separation between resources and samplers. Some shader
+     * instructions allow access to 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 (FAILED(hr = wined3d_sampler_create(device, &desc, NULL, &device->default_sampler)))
     {
-        /* In SM4+ shaders there is a separation between resources and samplers. Some shader
-         * instructions allow access to 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.
-         */
-        GL_EXTCALL(glGenSamplers(1, &device->default_sampler));
-        GL_EXTCALL(glSamplerParameteri(device->default_sampler, GL_TEXTURE_MAG_FILTER, GL_NEAREST));
-        GL_EXTCALL(glSamplerParameteri(device->default_sampler, GL_TEXTURE_MIN_FILTER, GL_NEAREST));
-        checkGLcall("Create default sampler");
+        ERR("Failed to create default sampler, hr %#x.\n", hr);
+        device->default_sampler = NULL;
+    }
 
+    if (gl_info->supported[ARB_SAMPLER_OBJECTS])
+    {
         /* In D3D10+, a NULL sampler maps to the default sampler state. */
         GL_EXTCALL(glGenSamplers(1, &device->null_sampler));
         GL_EXTCALL(glSamplerParameteri(device->null_sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR));
@@ -800,7 +818,6 @@ static void create_default_samplers(struct wined3d_device *device, struct wined3
     }
     else
     {
-        device->default_sampler = 0;
         device->null_sampler = 0;
     }
 }
@@ -810,14 +827,15 @@ static void destroy_default_samplers(struct wined3d_device *device, struct wined
 {
     const struct wined3d_gl_info *gl_info = context->gl_info;
 
+    wined3d_sampler_decref(device->default_sampler);
+    device->default_sampler = NULL;
+
     if (gl_info->supported[ARB_SAMPLER_OBJECTS])
     {
-        GL_EXTCALL(glDeleteSamplers(1, &device->default_sampler));
         GL_EXTCALL(glDeleteSamplers(1, &device->null_sampler));
         checkGLcall("glDeleteSamplers");
     }
 
-    device->default_sampler = 0;
     device->null_sampler = 0;
 }
 
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 64e669b..6b683aa 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2688,7 +2688,7 @@ struct wined3d_device
     } dummy_textures;
 
     /* Default sampler used to emulate the direct resource access without using wined3d_sampler */
-    GLuint default_sampler;
+    struct wined3d_sampler *default_sampler;
     GLuint null_sampler;
 
     /* Command stream */




More information about the wine-cvs mailing list