[PATCH 4/8] wined3d: Introduce general helper function to get sample count for resource.

Józef Kucia jkucia at codeweavers.com
Sun Mar 3 12:55:23 CST 2019


For Vulkan backend.

Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
 dlls/wined3d/resource.c        | 32 ++++++++++++++++++++++++++++++
 dlls/wined3d/texture.c         | 36 ++--------------------------------
 dlls/wined3d/wined3d_private.h |  1 +
 3 files changed, 35 insertions(+), 34 deletions(-)

diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c
index ba71df1e323d..2897ab143c1f 100644
--- a/dlls/wined3d/resource.c
+++ b/dlls/wined3d/resource.c
@@ -509,3 +509,35 @@ const struct wined3d_format *wined3d_resource_get_decompress_format(const struct
         return wined3d_get_format(adapter, WINED3DFMT_B8G8R8A8_UNORM_SRGB, resource->bind_flags);
     return wined3d_get_format(adapter, WINED3DFMT_B8G8R8A8_UNORM, resource->bind_flags);
 }
+
+unsigned int wined3d_resource_get_sample_count(const struct wined3d_resource *resource)
+{
+    const struct wined3d_format *format = resource->format;
+
+    /* TODO: NVIDIA expose their Coverage Sample Anti-Aliasing (CSAA)
+     * feature through type == MULTISAMPLE_XX and quality != 0. This could
+     * be mapped to GL_NV_framebuffer_multisample_coverage.
+     *
+     * AMD have a similar feature called Enhanced Quality Anti-Aliasing
+     * (EQAA), but it does not have an equivalent OpenGL extension. */
+
+    /* We advertise as many WINED3D_MULTISAMPLE_NON_MASKABLE quality
+     * levels as the count of advertised multisample types for the texture
+     * format. */
+    if (resource->multisample_type == WINED3D_MULTISAMPLE_NON_MASKABLE)
+    {
+        unsigned int i, count = 0;
+
+        for (i = 0; i < sizeof(format->multisample_types) * CHAR_BIT; ++i)
+        {
+            if (format->multisample_types & 1u << i)
+            {
+                if (resource->multisample_quality == count++)
+                    break;
+            }
+        }
+        return i + 1;
+    }
+
+    return resource->multisample_type;
+}
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index cb9ac2aa4ffb..55c9543f30b1 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -530,38 +530,6 @@ static void gltexture_delete(struct wined3d_device *device, const struct wined3d
     tex->name = 0;
 }
 
-static unsigned int wined3d_texture_get_gl_sample_count(const struct wined3d_texture *texture)
-{
-    const struct wined3d_format *format = texture->resource.format;
-
-    /* TODO: NVIDIA expose their Coverage Sample Anti-Aliasing (CSAA)
-     * feature through type == MULTISAMPLE_XX and quality != 0. This could
-     * be mapped to GL_NV_framebuffer_multisample_coverage.
-     *
-     * AMD have a similar feature called Enhanced Quality Anti-Aliasing
-     * (EQAA), but it does not have an equivalent OpenGL extension. */
-
-    /* We advertise as many WINED3D_MULTISAMPLE_NON_MASKABLE quality
-     * levels as the count of advertised multisample types for the texture
-     * format. */
-    if (texture->resource.multisample_type == WINED3D_MULTISAMPLE_NON_MASKABLE)
-    {
-        unsigned int i, count = 0;
-
-        for (i = 0; i < sizeof(format->multisample_types) * CHAR_BIT; ++i)
-        {
-            if (format->multisample_types & 1u << i)
-            {
-                if (texture->resource.multisample_quality == count++)
-                    break;
-            }
-        }
-        return i + 1;
-    }
-
-    return texture->resource.multisample_type;
-}
-
 /* Context activation is done by the caller. */
 /* The caller is responsible for binding the correct texture. */
 static void wined3d_texture_gl_allocate_mutable_storage(struct wined3d_texture_gl *texture_gl,
@@ -624,7 +592,7 @@ static void wined3d_texture_gl_allocate_mutable_storage(struct wined3d_texture_g
 static void wined3d_texture_gl_allocate_immutable_storage(struct wined3d_texture_gl *texture_gl,
         GLenum gl_internal_format, const struct wined3d_gl_info *gl_info)
 {
-    unsigned int samples = wined3d_texture_get_gl_sample_count(&texture_gl->t);
+    unsigned int samples = wined3d_resource_get_sample_count(&texture_gl->t.resource);
     GLsizei height = wined3d_texture_get_level_pow2_height(&texture_gl->t, 0);
     GLsizei width = wined3d_texture_get_level_pow2_width(&texture_gl->t, 0);
     GLboolean standard_pattern = texture_gl->t.resource.multisample_type != WINED3D_MULTISAMPLE_NON_MASKABLE
@@ -1813,7 +1781,7 @@ static void wined3d_texture_gl_prepare_rb(struct wined3d_texture_gl *texture_gl,
         if (texture_gl->rb_multisample)
             return;
 
-        samples = wined3d_texture_get_gl_sample_count(&texture_gl->t);
+        samples = wined3d_resource_get_sample_count(&texture_gl->t.resource);
 
         gl_info->fbo_ops.glGenRenderbuffers(1, &texture_gl->rb_multisample);
         gl_info->fbo_ops.glBindRenderbuffer(GL_RENDERBUFFER, texture_gl->rb_multisample);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index cc5902a8e75c..3d51a90e1b94 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -3227,6 +3227,7 @@ BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource) DECLSPE
 void wined3d_resource_free_sysmem(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
 const struct wined3d_format *wined3d_resource_get_decompress_format(
         const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
+unsigned int wined3d_resource_get_sample_count(const struct wined3d_resource *resource) DECLSPEC_HIDDEN;
 GLbitfield wined3d_resource_gl_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
 GLenum wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
 BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
-- 
2.19.2




More information about the wine-devel mailing list