Module: wine Branch: master Commit: e4bf926c3b88ac47c980498f0602887c13967157 URL: https://source.winehq.org/git/wine.git/?a=commit;h=e4bf926c3b88ac47c980498f0...
Author: Józef Kucia jkucia@codeweavers.com Date: Sun Mar 3 19:55:23 2019 +0100
wined3d: Introduce general helper function to get sample count for resource.
For Vulkan backend.
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/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 ba71df1..2897ab1 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 cb9ac2a..55c9543 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 cc5902a..3d51a90 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;