wined3d: Factor out wined3d_texture_get_gl_sample_count() function.

For creating multisample textures.

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>
This commit is contained in:
Józef Kucia 2018-02-06 11:40:06 +01:00 committed by Alexandre Julliard
parent 7cdf7f5609
commit b5f1d3085f
1 changed files with 26 additions and 21 deletions

View File

@ -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);