[PATCH 5/5] wined3d: Factor out wined3d_texture_get_gl_sample_count() function.
Józef Kucia
jkucia at codeweavers.com
Tue Feb 6 04:40:06 CST 2018
For creating multisample textures.
Signed-off-by: Józef Kucia <jkucia at codeweavers.com>
---
dlls/wined3d/texture.c | 47 ++++++++++++++++++++++++++---------------------
1 file changed, 26 insertions(+), 21 deletions(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 29c496382e47..ed1ca21117f0 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -456,6 +456,31 @@ 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;
+
+ /* 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_allocate_gl_mutable_storage(struct wined3d_texture *texture,
@@ -1484,27 +1509,7 @@ static void wined3d_texture_prepare_rb(struct wined3d_texture *texture,
* 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) * 8; ++i)
- {
- if (format->multisample_types & 1u << i)
- {
- if (texture->resource.multisample_quality == count++)
- break;
- }
- }
- samples = i + 1;
- }
- else
- {
- samples = texture->resource.multisample_type;
- }
+ samples = wined3d_texture_get_gl_sample_count(texture);
gl_info->fbo_ops.glGenRenderbuffers(1, &texture->rb_multisample);
gl_info->fbo_ops.glBindRenderbuffer(GL_RENDERBUFFER, texture->rb_multisample);
--
2.13.6
More information about the wine-devel
mailing list