Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/wined3d_private.h | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 05576cd967de..334724514df3 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4352,6 +4352,13 @@ static inline BOOL is_rasterization_disabled(const struct wined3d_shader *geomet && geometry_shader->u.gs.so_desc.rasterizer_stream_idx == WINED3D_NO_RASTERIZER_STREAM; }
+static inline int wined3d_bit_scan(unsigned int *x) +{ + int bit_offset = ffs(*x) - 1; + *x ^= 1u << bit_offset; + return bit_offset; +} + static inline DWORD wined3d_extract_bits(const DWORD *bitstream, unsigned int offset, unsigned int count) {
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/context.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 2e12d7521363..81a0f4fcd1b0 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -2368,16 +2368,16 @@ void context_enable_clip_distances(struct wined3d_context *context, unsigned int context->clip_distance_mask = enable_mask;
enable_mask &= ~current_mask; - for (i = 0; enable_mask; enable_mask >>= 1, ++i) + while (enable_mask) { - if (enable_mask & 1) - gl_info->gl_ops.gl.p_glEnable(GL_CLIP_DISTANCE0 + i); + i = wined3d_bit_scan(&enable_mask); + gl_info->gl_ops.gl.p_glEnable(GL_CLIP_DISTANCE0 + i); } disable_mask &= current_mask; - for (i = 0; disable_mask; disable_mask >>= 1, ++i) + while (disable_mask) { - if (disable_mask & 1) - gl_info->gl_ops.gl.p_glDisable(GL_CLIP_DISTANCE0 + i); + i = wined3d_bit_scan(&disable_mask); + gl_info->gl_ops.gl.p_glDisable(GL_CLIP_DISTANCE0 + i); } checkGLcall("toggle clip distances"); }
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/context.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 81a0f4fcd1b0..ccfe630e1f25 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -3983,7 +3983,7 @@ void context_apply_compute_state(struct wined3d_context *context, { const struct StateEntry *state_table = context->state_table; const struct wined3d_gl_info *gl_info = context->gl_info; - unsigned int state_id, i, j; + unsigned int state_id, i;
context_load_shader_resources(context, state, 1u << WINED3D_SHADER_TYPE_COMPUTE); context_load_unordered_access_resources(context, state->shader[WINED3D_SHADER_TYPE_COMPUTE], @@ -3991,11 +3991,13 @@ void context_apply_compute_state(struct wined3d_context *context,
for (i = 0, state_id = STATE_COMPUTE_OFFSET; i < ARRAY_SIZE(context->dirty_compute_states); ++i) { - for (j = 0; j < sizeof(*context->dirty_compute_states) * CHAR_BIT; ++j, ++state_id) + unsigned int dirty_mask = context->dirty_compute_states[i]; + while (dirty_mask) { - if (context->dirty_compute_states[i] & (1u << j)) - state_table[state_id].apply(context, state, state_id); + unsigned int current_state_id = state_id + wined3d_bit_scan(&dirty_mask); + state_table[current_state_id].apply(context, state, current_state_id); } + state_id += sizeof(*context->dirty_compute_states) * CHAR_BIT; } memset(context->dirty_compute_states, 0, sizeof(*context->dirty_compute_states));
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Józef Kucia jkucia@codeweavers.com --- dlls/wined3d/view.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/dlls/wined3d/view.c b/dlls/wined3d/view.c index a8e025965df8..b06daccca150 100644 --- a/dlls/wined3d/view.c +++ b/dlls/wined3d/view.c @@ -44,15 +44,21 @@ static GLenum get_texture_view_target(const struct wined3d_gl_info *gl_info, } view_types[] = { - {GL_TEXTURE_CUBE_MAP, 0, GL_TEXTURE_CUBE_MAP}, - {GL_TEXTURE_RECTANGLE, 0, GL_TEXTURE_RECTANGLE}, - {GL_TEXTURE_2D, 0, GL_TEXTURE_2D}, - {GL_TEXTURE_2D, WINED3D_VIEW_TEXTURE_ARRAY, GL_TEXTURE_2D_ARRAY}, - {GL_TEXTURE_2D_ARRAY, 0, GL_TEXTURE_2D}, - {GL_TEXTURE_2D_ARRAY, WINED3D_VIEW_TEXTURE_ARRAY, GL_TEXTURE_2D_ARRAY}, - {GL_TEXTURE_2D_ARRAY, WINED3D_VIEW_TEXTURE_CUBE, GL_TEXTURE_CUBE_MAP}, - {GL_TEXTURE_2D_ARRAY, WINED3D_VIEW_CUBE_ARRAY, GL_TEXTURE_CUBE_MAP_ARRAY, ARB_TEXTURE_CUBE_MAP_ARRAY}, - {GL_TEXTURE_3D, 0, GL_TEXTURE_3D}, + {GL_TEXTURE_CUBE_MAP, 0, GL_TEXTURE_CUBE_MAP}, + {GL_TEXTURE_RECTANGLE, 0, GL_TEXTURE_RECTANGLE}, + {GL_TEXTURE_3D, 0, GL_TEXTURE_3D}, + + {GL_TEXTURE_2D, 0, GL_TEXTURE_2D}, + {GL_TEXTURE_2D, WINED3D_VIEW_TEXTURE_ARRAY, GL_TEXTURE_2D_ARRAY}, + {GL_TEXTURE_2D_ARRAY, 0, GL_TEXTURE_2D}, + {GL_TEXTURE_2D_ARRAY, WINED3D_VIEW_TEXTURE_ARRAY, GL_TEXTURE_2D_ARRAY}, + {GL_TEXTURE_2D_ARRAY, WINED3D_VIEW_TEXTURE_CUBE, GL_TEXTURE_CUBE_MAP}, + {GL_TEXTURE_2D_ARRAY, WINED3D_VIEW_CUBE_ARRAY, GL_TEXTURE_CUBE_MAP_ARRAY, ARB_TEXTURE_CUBE_MAP_ARRAY}, + + {GL_TEXTURE_2D_MULTISAMPLE, 0, GL_TEXTURE_2D_MULTISAMPLE}, + {GL_TEXTURE_2D_MULTISAMPLE, WINED3D_VIEW_TEXTURE_ARRAY, GL_TEXTURE_2D_MULTISAMPLE_ARRAY}, + {GL_TEXTURE_2D_MULTISAMPLE_ARRAY, 0, GL_TEXTURE_2D_MULTISAMPLE}, + {GL_TEXTURE_2D_MULTISAMPLE_ARRAY, WINED3D_VIEW_TEXTURE_ARRAY, GL_TEXTURE_2D_MULTISAMPLE_ARRAY}, }; unsigned int i;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
For creating multisample textures.
Signed-off-by: Józef Kucia jkucia@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);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com