Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- In d3d8 there was no vertex shader texture fetch.
dlls/d3d8/device.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/dlls/d3d8/device.c b/dlls/d3d8/device.c index 869a6a2dd0d..9793eda0c36 100644 --- a/dlls/d3d8/device.c +++ b/dlls/d3d8/device.c @@ -2159,10 +2159,7 @@ static HRESULT WINAPI d3d8_device_GetTexture(IDirect3DDevice8 *iface, DWORD stag if (!texture) return D3DERR_INVALIDCALL;
- if (stage >= WINED3DVERTEXTEXTURESAMPLER0 && stage <= WINED3DVERTEXTEXTURESAMPLER3) - stage -= (WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS); - - if (stage >= WINED3D_MAX_COMBINED_SAMPLERS) + if (stage >= WINED3D_MAX_FRAGMENT_SAMPLERS) { WARN("Ignoring invalid stage %u.\n", stage); *texture = NULL; @@ -2253,10 +2250,7 @@ static HRESULT WINAPI d3d8_device_GetTextureStageState(IDirect3DDevice8 *iface,
TRACE("iface %p, stage %u, state %#x, value %p.\n", iface, stage, state, value);
- if (stage >= WINED3DVERTEXTEXTURESAMPLER0 && stage <= WINED3DVERTEXTEXTURESAMPLER3) - stage -= (WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS); - - if (stage >= WINED3D_MAX_COMBINED_SAMPLERS) + if (stage >= WINED3D_MAX_FRAGMENT_SAMPLERS) { WARN("Invalid stage %u.\n", stage); *value = 0;
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/wined3d/adapter_gl.c | 2 +- dlls/wined3d/adapter_vk.c | 4 ++-- dlls/wined3d/buffer.c | 20 ++++++++++---------- dlls/wined3d/context.c | 4 ++-- dlls/wined3d/directx.c | 2 +- dlls/wined3d/surface.c | 6 +++--- dlls/wined3d/texture.c | 4 ++-- dlls/wined3d/wined3d_private.h | 14 +++++++------- 8 files changed, 28 insertions(+), 28 deletions(-)
diff --git a/dlls/wined3d/adapter_gl.c b/dlls/wined3d/adapter_gl.c index a59edf4e368..3ad64754ec6 100644 --- a/dlls/wined3d/adapter_gl.c +++ b/dlls/wined3d/adapter_gl.c @@ -4617,7 +4617,7 @@ static void *adapter_gl_map_bo_address(struct wined3d_context *context, }
static void adapter_gl_unmap_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data, - uint32_t bind_flags, unsigned int range_count, const struct wined3d_map_range *ranges) + uint32_t bind_flags, unsigned int range_count, const struct wined3d_range *ranges) { struct wined3d_context_gl *context_gl; GLenum binding; diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index 87e21b0b41f..85dfa6c987c 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -538,7 +538,7 @@ static void *adapter_vk_map_bo_address(struct wined3d_context *context, }
static void adapter_vk_unmap_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data, - uint32_t bind_flags, unsigned int range_count, const struct wined3d_map_range *ranges) + uint32_t bind_flags, unsigned int range_count, const struct wined3d_range *ranges) { const struct wined3d_vk_info *vk_info; struct wined3d_device_vk *device_vk; @@ -556,7 +556,7 @@ static void adapter_vk_copy_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *dst, uint32_t dst_bind_flags, const struct wined3d_bo_address *src, uint32_t src_bind_flags, size_t size) { - struct wined3d_map_range range; + struct wined3d_range range; void *dst_ptr, *src_ptr;
src_ptr = adapter_vk_map_bo_address(context, src, size, src_bind_flags, WINED3D_MAP_READ); diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index 4f3c28fe0b1..427b1a26493 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -611,7 +611,7 @@ static void wined3d_buffer_unload_location(struct wined3d_buffer *buffer, BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer, struct wined3d_context *context, DWORD location) { - struct wined3d_map_range range; + struct wined3d_range range;
TRACE("buffer %p, context %p, location %s.\n", buffer, context, wined3d_debug_location(location)); @@ -1215,7 +1215,7 @@ void wined3d_buffer_copy(struct wined3d_buffer *dst_buffer, unsigned int dst_off void wined3d_buffer_upload_data(struct wined3d_buffer *buffer, struct wined3d_context *context, const struct wined3d_box *box, const void *data) { - struct wined3d_map_range range; + struct wined3d_range range;
if (box) { @@ -1406,13 +1406,13 @@ static void wined3d_buffer_no3d_unload_location(struct wined3d_buffer *buffer, }
static void wined3d_buffer_no3d_upload_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context, - const void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_map_range *ranges) + const void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges) { FIXME("Not implemented.\n"); }
static void wined3d_buffer_no3d_download_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context, - void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_map_range *ranges) + void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges) { FIXME("Not implemented.\n"); } @@ -1482,12 +1482,12 @@ static void wined3d_buffer_gl_unload_location(struct wined3d_buffer *buffer,
/* Context activation is done by the caller. */ static void wined3d_buffer_gl_upload_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context, - const void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_map_range *ranges) + const void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges) { struct wined3d_context_gl *context_gl = wined3d_context_gl(context); struct wined3d_buffer_gl *buffer_gl = wined3d_buffer_gl(buffer); const struct wined3d_gl_info *gl_info = context_gl->gl_info; - const struct wined3d_map_range *range; + const struct wined3d_range *range;
wined3d_buffer_gl_bind(buffer_gl, context_gl);
@@ -1502,12 +1502,12 @@ static void wined3d_buffer_gl_upload_ranges(struct wined3d_buffer *buffer, struc
/* Context activation is done by the caller. */ static void wined3d_buffer_gl_download_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context, - void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_map_range *ranges) + void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges) { struct wined3d_context_gl *context_gl = wined3d_context_gl(context); struct wined3d_buffer_gl *buffer_gl = wined3d_buffer_gl(buffer); const struct wined3d_gl_info *gl_info = context_gl->gl_info; - const struct wined3d_map_range *range; + const struct wined3d_range *range;
wined3d_buffer_gl_bind(buffer_gl, context_gl);
@@ -1636,13 +1636,13 @@ static void wined3d_buffer_vk_unload_location(struct wined3d_buffer *buffer, }
static void wined3d_buffer_vk_upload_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context, - const void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_map_range *ranges) + const void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges) { FIXME("Not implemented.\n"); }
static void wined3d_buffer_vk_download_ranges(struct wined3d_buffer *buffer, struct wined3d_context *context, - void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_map_range *ranges) + void *data, unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges) { FIXME("Not implemented.\n"); } diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 27c9d37f5df..af2b00f88e0 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -2931,7 +2931,7 @@ void *wined3d_context_gl_map_bo_address(struct wined3d_context_gl *context_gl, }
void wined3d_context_gl_unmap_bo_address(struct wined3d_context_gl *context_gl, const struct wined3d_bo_address *data, - GLenum binding, unsigned int range_count, const struct wined3d_map_range *ranges) + GLenum binding, unsigned int range_count, const struct wined3d_range *ranges) { const struct wined3d_gl_info *gl_info; unsigned int i; @@ -2960,7 +2960,7 @@ void wined3d_context_gl_copy_bo_address(struct wined3d_context_gl *context_gl, const struct wined3d_bo_address *src, GLenum src_binding, size_t size) { const struct wined3d_gl_info *gl_info; - struct wined3d_map_range range; + struct wined3d_range range; BYTE *dst_ptr, *src_ptr;
gl_info = context_gl->gl_info; diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 7167f208e95..4d6f63c2ffb 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -2463,7 +2463,7 @@ static void *adapter_no3d_map_bo_address(struct wined3d_context *context, }
static void adapter_no3d_unmap_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data, - uint32_t bind_flags, unsigned int range_count, const struct wined3d_map_range *ranges) + uint32_t bind_flags, unsigned int range_count, const struct wined3d_range *ranges) { if (data->buffer_object) ERR("Unsupported buffer object %#lx.\n", data->buffer_object); diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index ebf2e3afdf3..c0f28099cfc 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -649,7 +649,7 @@ static struct wined3d_texture *surface_convert_format(struct wined3d_texture *sr { unsigned int dst_row_pitch, dst_slice_pitch; struct wined3d_bo_address dst_data; - struct wined3d_map_range range; + struct wined3d_range range; const BYTE *src; BYTE *dst;
@@ -1638,8 +1638,8 @@ static HRESULT surface_cpu_blt(struct wined3d_texture *dst_texture, unsigned int unsigned int src_fmt_flags, dst_fmt_flags; struct wined3d_map_desc dst_map, src_map; unsigned int x, sx, xinc, y, sy, yinc; - struct wined3d_map_range dst_range; struct wined3d_context *context; + struct wined3d_range dst_range; unsigned int texture_level; HRESULT hr = WINED3D_OK; BOOL same_sub_resource; @@ -2157,8 +2157,8 @@ static void surface_cpu_blt_colour_fill(struct wined3d_rendertarget_view *view, struct wined3d_context *context; struct wined3d_texture *texture; struct wined3d_bo_address data; - struct wined3d_map_range range; struct wined3d_map_desc map; + struct wined3d_range range; DWORD map_binding; uint8_t *dst; DWORD c; diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 03372504bc6..b663a44fbb1 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -761,9 +761,9 @@ static void wined3d_texture_destroy_dc(void *object) struct wined3d_texture *texture; struct wined3d_dc_info *dc_info; struct wined3d_bo_address data; - struct wined3d_map_range range; unsigned int sub_resource_idx; struct wined3d_device *device; + struct wined3d_range range; NTSTATUS status;
texture = idx->texture; @@ -3219,7 +3219,7 @@ static HRESULT texture_resource_sub_resource_unmap(struct wined3d_resource *reso struct wined3d_context *context; struct wined3d_texture *texture; struct wined3d_bo_address data; - struct wined3d_map_range range; + struct wined3d_range range;
TRACE("resource %p, sub_resource_idx %u.\n", resource, sub_resource_idx);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 932f35d14ef..b6042cd6179 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1899,7 +1899,7 @@ struct wined3d_gl_view GLuint name; };
-struct wined3d_map_range +struct wined3d_range { unsigned int offset; unsigned int size; @@ -2158,7 +2158,7 @@ void wined3d_context_gl_texture_update(struct wined3d_context_gl *context_gl, const struct wined3d_texture_gl *texture_gl) DECLSPEC_HIDDEN; void wined3d_context_gl_unload_tex_coords(const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN; void wined3d_context_gl_unmap_bo_address(struct wined3d_context_gl *context_gl, const struct wined3d_bo_address *data, - GLenum binding, unsigned int range_count, const struct wined3d_map_range *ranges) DECLSPEC_HIDDEN; + GLenum binding, unsigned int range_count, const struct wined3d_range *ranges) DECLSPEC_HIDDEN; void wined3d_context_gl_update_stream_sources(struct wined3d_context_gl *context_gl, const struct wined3d_state *state) DECLSPEC_HIDDEN;
@@ -2858,7 +2858,7 @@ struct wined3d_adapter_ops void *(*adapter_map_bo_address)(struct wined3d_context *context, const struct wined3d_bo_address *data, size_t size, uint32_t bind_flags, uint32_t map_flags); void (*adapter_unmap_bo_address)(struct wined3d_context *context, const struct wined3d_bo_address *data, - uint32_t bind_flags, unsigned int range_count, const struct wined3d_map_range *ranges); + uint32_t bind_flags, unsigned int range_count, const struct wined3d_range *ranges); void (*adapter_copy_bo_address)(struct wined3d_context *context, const struct wined3d_bo_address *dst, uint32_t dst_bind_flags, const struct wined3d_bo_address *src, uint32_t src_bind_flags, size_t size); @@ -4172,9 +4172,9 @@ struct wined3d_buffer_ops void (*buffer_unload_location)(struct wined3d_buffer *buffer, struct wined3d_context *context, unsigned int location); void (*buffer_upload_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, const void *data, - unsigned int data_offset, unsigned int range_count, const struct wined3d_map_range *ranges); + unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges); void (*buffer_download_ranges)(struct wined3d_buffer *buffer, struct wined3d_context *context, void *data, - unsigned int data_offset, unsigned int range_count, const struct wined3d_map_range *ranges); + unsigned int data_offset, unsigned int range_count, const struct wined3d_range *ranges); };
struct wined3d_buffer @@ -4188,7 +4188,7 @@ struct wined3d_buffer void *map_ptr; uintptr_t buffer_object;
- struct wined3d_map_range *maps; + struct wined3d_range *maps; SIZE_T maps_size, modified_areas; struct wined3d_fence *fence;
@@ -5270,7 +5270,7 @@ static inline void *wined3d_context_map_bo_address(struct wined3d_context *conte
static inline void wined3d_context_unmap_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data, uint32_t bind_flags, - unsigned int range_count, const struct wined3d_map_range *ranges) + unsigned int range_count, const struct wined3d_range *ranges) { context->device->adapter->adapter_ops->adapter_unmap_bo_address(context, data, bind_flags, range_count, ranges); }
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v2: Introduce wined3d_bitmap_ffs() and wined3d_bitmap_ffz(), implement wined3d_apply_shader_constants() on top of them. Tweak a few additional details while at it, mostly to reduce the amount of changes necessary when using the same function for wined3d_stateblock_capture() and wined3d_stateblock_apply() in followup patches. v3: Introduce wined3d_bitmap_get_range(), get rid of wined3d_apply_shader_constants(), simplify wined3d_bitmap_ffs(), make both wined3d_bitmap_ffs() and wined3d_bitmap_ffz() use the same common code. (Thanks Henri!)
dlls/wined3d/device.c | 105 ++++++++++++--------------------- dlls/wined3d/wined3d_private.h | 74 +++++++++++++++++++---- 2 files changed, 101 insertions(+), 78 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 3cf621ff46e..fa675f57290 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3835,13 +3835,14 @@ struct wined3d_texture * CDECL wined3d_device_get_texture(const struct wined3d_d void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, struct wined3d_stateblock *stateblock) { - const struct wined3d_d3d_info *d3d_info = &stateblock->device->adapter->d3d_info; const struct wined3d_stateblock_state *state = &stateblock->stateblock_state; const struct wined3d_saved_states *changed = &stateblock->changed; struct wined3d_blend_state *blend_state; struct wined3d_color colour; - unsigned int i, j, count; + struct wined3d_range range; + unsigned int i, j, start; BOOL set_blend_state; + DWORD map;
TRACE("device %p, stateblock %p.\n", device, stateblock);
@@ -3850,89 +3851,57 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, if (changed->pixelShader) wined3d_device_set_pixel_shader(device, state->ps);
- count = 0; - for (i = 0; i < d3d_info->limits.vs_uniform_count; ++i) + for (start = 0; ; start = range.offset + range.size) { - if (wined3d_bitmap_is_set(changed->vs_consts_f, i)) - ++count; - else if (count) - { - wined3d_device_set_vs_consts_f(device, i - count, count, state->vs_consts_f + i - count); - count = 0; - } + if (!wined3d_bitmap_get_range(changed->vs_consts_f, WINED3D_MAX_VS_CONSTS_F, start, &range)) + break; + + wined3d_device_set_vs_consts_f(device, range.offset, range.size, &state->vs_consts_f[range.offset]); } - if (count) - wined3d_device_set_vs_consts_f(device, i - count, count, state->vs_consts_f + i - count);
- count = 0; - for (i = 0; i < WINED3D_MAX_CONSTS_B; ++i) + map = changed->vertexShaderConstantsI; + for (start = 0; ; start = range.offset + range.size) { - if (changed->vertexShaderConstantsB & (1u << i)) - ++count; - else if (count) - { - wined3d_device_set_vs_consts_b(device, i - count, count, state->vs_consts_b + i - count); - count = 0; - } + if (!wined3d_bitmap_get_range(&map, WINED3D_MAX_CONSTS_I, start, &range)) + break; + + wined3d_device_set_vs_consts_i(device, range.offset, range.size, &state->vs_consts_i[range.offset]); } - if (count) - wined3d_device_set_vs_consts_b(device, i - count, count, state->vs_consts_b + i - count);
- count = 0; - for (i = 0; i < WINED3D_MAX_CONSTS_I; ++i) + map = changed->vertexShaderConstantsB; + for (start = 0; ; start = range.offset + range.size) { - if (changed->vertexShaderConstantsI & (1u << i)) - ++count; - else if (count) - { - wined3d_device_set_vs_consts_i(device, i - count, count, state->vs_consts_i + i - count); - count = 0; - } + if (!wined3d_bitmap_get_range(&map, WINED3D_MAX_CONSTS_B, start, &range)) + break; + + wined3d_device_set_vs_consts_b(device, range.offset, range.size, &state->vs_consts_b[range.offset]); } - if (count) - wined3d_device_set_vs_consts_i(device, i - count, count, state->vs_consts_i + i - count);
- count = 0; - for (i = 0; i < d3d_info->limits.ps_uniform_count; ++i) + for (start = 0; ; start = range.offset + range.size) { - if (wined3d_bitmap_is_set(changed->ps_consts_f, i)) - ++count; - else if (count) - { - wined3d_device_set_ps_consts_f(device, i - count, count, state->ps_consts_f + i - count); - count = 0; - } + if (!wined3d_bitmap_get_range(changed->ps_consts_f, WINED3D_MAX_PS_CONSTS_F, start, &range)) + break; + + wined3d_device_set_ps_consts_f(device, range.offset, range.size, &state->ps_consts_f[range.offset]); } - if (count) - wined3d_device_set_ps_consts_f(device, i - count, count, state->ps_consts_f + i - count);
- count = 0; - for (i = 0; i < WINED3D_MAX_CONSTS_B; ++i) + map = changed->pixelShaderConstantsI; + for (start = 0; ; start = range.offset + range.size) { - if (changed->pixelShaderConstantsB & (1u << i)) - ++count; - else if (count) - { - wined3d_device_set_ps_consts_b(device, i - count, count, state->ps_consts_b + i - count); - count = 0; - } + if (!wined3d_bitmap_get_range(&map, WINED3D_MAX_CONSTS_I, start, &range)) + break; + + wined3d_device_set_ps_consts_i(device, range.offset, range.size, &state->ps_consts_i[range.offset]); } - if (count) - wined3d_device_set_ps_consts_b(device, i - count, count, state->ps_consts_b + i - count);
- count = 0; - for (i = 0; i < WINED3D_MAX_CONSTS_I; ++i) + map = changed->pixelShaderConstantsB; + for (start = 0; ; start = range.offset + range.size) { - if (changed->pixelShaderConstantsI & (1u << i)) - ++count; - else if (count) - { - wined3d_device_set_ps_consts_i(device, i - count, count, state->ps_consts_i + i - count); - count = 0; - } + if (!wined3d_bitmap_get_range(&map, WINED3D_MAX_CONSTS_B, start, &range)) + break; + + wined3d_device_set_ps_consts_b(device, range.offset, range.size, &state->ps_consts_b[range.offset]); } - if (count) - wined3d_device_set_ps_consts_i(device, i - count, count, state->ps_consts_i + i - count);
for (i = 0; i < ARRAY_SIZE(state->light_state->light_map); ++i) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index b6042cd6179..15e376c8328 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3196,13 +3196,13 @@ struct wined3d_state struct wined3d_shader_resource_view *shader_resource_view[WINED3D_SHADER_TYPE_COUNT][MAX_SHADER_RESOURCE_VIEWS]; struct wined3d_unordered_access_view *unordered_access_view[WINED3D_PIPELINE_COUNT][MAX_UNORDERED_ACCESS_VIEWS];
- BOOL vs_consts_b[WINED3D_MAX_CONSTS_B]; - struct wined3d_ivec4 vs_consts_i[WINED3D_MAX_CONSTS_I]; struct wined3d_vec4 vs_consts_f[WINED3D_MAX_VS_CONSTS_F]; + struct wined3d_ivec4 vs_consts_i[WINED3D_MAX_CONSTS_I]; + BOOL vs_consts_b[WINED3D_MAX_CONSTS_B];
- BOOL ps_consts_b[WINED3D_MAX_CONSTS_B]; - struct wined3d_ivec4 ps_consts_i[WINED3D_MAX_CONSTS_I]; struct wined3d_vec4 ps_consts_f[WINED3D_MAX_PS_CONSTS_F]; + struct wined3d_ivec4 ps_consts_i[WINED3D_MAX_CONSTS_I]; + BOOL ps_consts_b[WINED3D_MAX_CONSTS_B];
struct wined3d_texture *textures[WINED3D_MAX_COMBINED_SAMPLERS]; DWORD sampler_states[WINED3D_MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1]; @@ -3914,6 +3914,12 @@ struct wined3d_vertex_declaration
struct wined3d_saved_states { + DWORD vs_consts_f[WINED3D_MAX_VS_CONSTS_F >> 5]; + WORD vertexShaderConstantsI; /* WINED3D_MAX_CONSTS_I, 16 */ + WORD vertexShaderConstantsB; /* WINED3D_MAX_CONSTS_B, 16 */ + DWORD ps_consts_f[WINED3D_MAX_PS_CONSTS_F >> 5]; + WORD pixelShaderConstantsI; /* WINED3D_MAX_CONSTS_I, 16 */ + WORD pixelShaderConstantsB; /* WINED3D_MAX_CONSTS_B, 16 */ DWORD transform[(WINED3D_HIGHEST_TRANSFORM_STATE >> 5) + 1]; WORD streamSource; /* WINED3D_MAX_STREAMS, 16 */ WORD streamFreq; /* WINED3D_MAX_STREAMS, 16 */ @@ -3921,12 +3927,6 @@ struct wined3d_saved_states DWORD textureState[WINED3D_MAX_TEXTURES]; /* WINED3D_HIGHEST_TEXTURE_STATE + 1, 18 */ WORD samplerState[WINED3D_MAX_COMBINED_SAMPLERS]; /* WINED3D_HIGHEST_SAMPLER_STATE + 1, 14 */ DWORD clipplane; /* WINED3D_MAX_USER_CLIP_PLANES, 32 */ - WORD pixelShaderConstantsB; /* WINED3D_MAX_CONSTS_B, 16 */ - WORD pixelShaderConstantsI; /* WINED3D_MAX_CONSTS_I, 16 */ - DWORD ps_consts_f[WINED3D_MAX_PS_CONSTS_F >> 5]; - WORD vertexShaderConstantsB; /* WINED3D_MAX_CONSTS_B, 16 */ - WORD vertexShaderConstantsI; /* WINED3D_MAX_CONSTS_I, 16 */ - DWORD vs_consts_f[WINED3D_MAX_VS_CONSTS_F >> 5]; DWORD textures : 20; /* WINED3D_MAX_COMBINED_SAMPLERS, 20 */ DWORD indices : 1; DWORD material : 1; @@ -5325,6 +5325,60 @@ static inline BOOL wined3d_bitmap_is_set(const uint32_t *map, unsigned int idx) return map[idx >> 5] & (1u << (idx & 0x1f)); }
+static inline unsigned int wined3d_bitmap_ffs_xor(const uint32_t *bitmap, unsigned int bit_count, + unsigned int start, uint32_t xor_mask) +{ + const unsigned int word_bit_count = sizeof(*bitmap) * CHAR_BIT; + const uint32_t *ptr, *end_ptr; + uint32_t map, mask; + + assert(bit_count < word_bit_count || !(bit_count % word_bit_count)); + + ptr = bitmap + start / word_bit_count; + end_ptr = bitmap + (bit_count + word_bit_count - 1) / word_bit_count; + + if (ptr >= end_ptr) + return ~0u; + + mask = ~0u << start % word_bit_count; + map = (*ptr ^ xor_mask) & mask; + while (!map) + { + if (++ptr == end_ptr) + return ~0u; + map = *ptr ^ xor_mask; + } + return (ptr - bitmap) * word_bit_count + wined3d_bit_scan(&map); +} + +static inline unsigned int wined3d_bitmap_ffs(const uint32_t *bitmap, unsigned int bit_count, unsigned int start) +{ + return wined3d_bitmap_ffs_xor(bitmap, bit_count, start, 0); +} + +static inline unsigned int wined3d_bitmap_ffz(const uint32_t *bitmap, unsigned int bit_count, unsigned int start) +{ + return wined3d_bitmap_ffs_xor(bitmap, bit_count, start, ~0u); +} + +static inline BOOL wined3d_bitmap_get_range(const DWORD *bitmap, unsigned int bit_count, + unsigned int start, struct wined3d_range *range) +{ + unsigned int range_start, range_end; + + range_start = wined3d_bitmap_ffs(bitmap, bit_count, start); + if (range_start == ~0u) + return FALSE; + + range_end = wined3d_bitmap_ffz(bitmap, bit_count, range_start + 1); + if (range_end == ~0u) + range_end = bit_count; + + range->offset = range_start; + range->size = range_end - range_start; + return TRUE; +} + /* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */ #define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/wined3d/device.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index fa675f57290..64cc80780d5 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3837,10 +3837,11 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, { const struct wined3d_stateblock_state *state = &stateblock->stateblock_state; const struct wined3d_saved_states *changed = &stateblock->changed; + const unsigned int word_bit_count = sizeof(DWORD) * CHAR_BIT; struct wined3d_blend_state *blend_state; + unsigned int i, j, start, idx; struct wined3d_color colour; struct wined3d_range range; - unsigned int i, j, start; BOOL set_blend_state; DWORD map;
@@ -3968,10 +3969,15 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, } }
- for (i = 0; i < ARRAY_SIZE(state->transforms); ++i) + for (i = 0; i < ARRAY_SIZE(changed->transform); ++i) { - if (wined3d_bitmap_is_set(changed->transform, i)) - wined3d_device_set_transform(device, i, &state->transforms[i]); + map = changed->transform[i]; + while (map) + { + j = wined3d_bit_scan(&map); + idx = i * word_bit_count + j; + wined3d_device_set_transform(device, idx, &state->transforms[idx]); + } }
if (changed->indices)
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/wined3d/device.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 64cc80780d5..e706c830d31 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3929,22 +3929,25 @@ void CDECL wined3d_device_apply_stateblock(struct wined3d_device *device, wined3d_device_set_blend_state(device, blend_state, &colour); }
- for (i = 0; i < ARRAY_SIZE(state->rs); ++i) + for (i = 0; i < ARRAY_SIZE(changed->renderState); ++i) { - if (!wined3d_bitmap_is_set(changed->renderState, i)) - continue; - - if (i != WINED3D_RS_BLENDFACTOR) + map = changed->renderState[i]; + while (map) { - wined3d_device_set_render_state(device, i, state->rs[i]); - continue; - } + j = wined3d_bit_scan(&map); + idx = i * word_bit_count + j; + if (idx != WINED3D_RS_BLENDFACTOR) + { + wined3d_device_set_render_state(device, idx, state->rs[idx]); + continue; + }
- if (!set_blend_state) - { - blend_state = wined3d_device_get_blend_state(device, &colour); - wined3d_color_from_d3dcolor(&colour, state->rs[i]); - wined3d_device_set_blend_state(device, blend_state, &colour); + if (!set_blend_state) + { + blend_state = wined3d_device_get_blend_state(device, &colour); + wined3d_color_from_d3dcolor(&colour, state->rs[idx]); + wined3d_device_set_blend_state(device, blend_state, &colour); + } } }
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com