Signed-off-by: Zebediah Figura z.figura12@gmail.com --- v3: Only push modified constants.
This series may not necessarily be safe for code freeze, but I'm submitting it at least to finish the review process.
dlls/wined3d/device.c | 193 ++++++++++++++++++++++++++++++++++++++ dlls/wined3d/wined3d.spec | 1 + include/wine/wined3d.h | 1 + 3 files changed, 195 insertions(+)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 8913420724..8e20e31d3f 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3829,6 +3829,199 @@ struct wined3d_texture * CDECL wined3d_device_get_texture(const struct wined3d_d return device->state.textures[stage]; }
+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; + unsigned int i, j, count; + + TRACE("device %p, stateblock %p.\n", device, stateblock); + + if (stateblock->changed.vertexShader) + wined3d_device_set_vertex_shader(device, state->vs); + if (stateblock->changed.pixelShader) + wined3d_device_set_pixel_shader(device, state->ps); + + count = 0; + for (i = 0; i < d3d_info->limits.vs_uniform_count; ++i) + { + if (stateblock->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 (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) + { + if (stateblock->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 (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) + { + if (stateblock->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 (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) + { + if (stateblock->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 (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) + { + if (stateblock->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 (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) + { + if (stateblock->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 (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) + { + const struct wined3d_light_info *light; + + LIST_FOR_EACH_ENTRY(light, &state->light_state->light_map[i], struct wined3d_light_info, entry) + { + wined3d_device_set_light(device, light->OriginalIndex, &light->OriginalParms); + wined3d_device_set_light_enable(device, light->OriginalIndex, light->glIndex != -1); + } + } + + for (i = 0; i < ARRAY_SIZE(state->rs); ++i) + { + if (stateblock->changed.renderState[i >> 5] & (1u << (i & 0x1f))) + { + if (i == WINED3D_RS_BLENDFACTOR) + { + struct wined3d_color color; + wined3d_color_from_d3dcolor(&color, state->rs[i]); + wined3d_device_set_blend_state(device, NULL, &color); + } + else + wined3d_device_set_render_state(device, i, state->rs[i]); + } + } + + for (i = 0; i < ARRAY_SIZE(state->texture_states); ++i) + { + for (j = 0; j < ARRAY_SIZE(state->texture_states[i]); ++j) + { + if (stateblock->changed.textureState[i] & (1u << j)) + wined3d_device_set_texture_stage_state(device, i, j, state->texture_states[i][j]); + } + } + + for (i = 0; i < ARRAY_SIZE(state->sampler_states); ++i) + { + DWORD stage = i; + if (stage >= WINED3D_MAX_FRAGMENT_SAMPLERS) + stage += WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS; + for (j = 0; j < ARRAY_SIZE(state->sampler_states[j]); ++j) + { + if (stateblock->changed.samplerState[i] & (1 << j)) + wined3d_device_set_sampler_state(device, stage, j, state->sampler_states[i][j]); + } + } + + for (i = 0; i < ARRAY_SIZE(state->transforms); ++i) + { + if (stateblock->changed.transform[i >> 5] & (1u << (i & 0x1f))) + wined3d_device_set_transform(device, i, &state->transforms[i]); + } + + if (stateblock->changed.indices) + wined3d_device_set_index_buffer(device, state->index_buffer, state->index_format, 0); + wined3d_device_set_base_vertex_index(device, state->base_vertex_index); + if (stateblock->changed.vertexDecl) + wined3d_device_set_vertex_declaration(device, state->vertex_declaration); + if (stateblock->changed.material) + wined3d_device_set_material(device, &state->material); + if (stateblock->changed.viewport) + wined3d_device_set_viewports(device, 1, &state->viewport); + if (stateblock->changed.scissorRect) + wined3d_device_set_scissor_rects(device, 1, &state->scissor_rect); + + for (i = 0; i < ARRAY_SIZE(state->streams); ++i) + { + if (stateblock->changed.streamSource & (1u << i)) + wined3d_device_set_stream_source(device, i, state->streams[i].buffer, + state->streams[i].offset, state->streams[i].stride); + if (stateblock->changed.streamFreq & (1u << i)) + wined3d_device_set_stream_source_freq(device, i, + state->streams[i].frequency | state->streams[i].flags); + } + + for (i = 0; i < ARRAY_SIZE(state->textures); ++i) + { + DWORD stage = i; + if (stage >= WINED3D_MAX_FRAGMENT_SAMPLERS) + stage += WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS; + if (stateblock->changed.textures & (1u << i)) + wined3d_device_set_texture(device, stage, state->textures[i]); + } + + for (i = 0; i < ARRAY_SIZE(state->clip_planes); ++i) + { + if (stateblock->changed.clipplane & (1u << i)) + wined3d_device_set_clip_plane(device, i, &state->clip_planes[i]); + } + + memset(&stateblock->changed, 0, sizeof(stateblock->changed)); + + TRACE("Applied stateblock %p.\n", stateblock); +} + HRESULT CDECL wined3d_device_get_device_caps(const struct wined3d_device *device, struct wined3d_caps *caps) { TRACE("device %p, caps %p.\n", device, caps); diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index e03c57055b..c8ef442c72 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -37,6 +37,7 @@ @ cdecl wined3d_buffer_incref(ptr)
@ cdecl wined3d_device_acquire_focus_window(ptr ptr) +@ cdecl wined3d_device_apply_stateblock(ptr ptr) @ cdecl wined3d_device_begin_scene(ptr) @ cdecl wined3d_device_clear(ptr long ptr long ptr float long) @ cdecl wined3d_device_clear_rendertarget_view(ptr ptr ptr long ptr float long) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 9cdf18633c..4306f5ae21 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2289,6 +2289,7 @@ struct wined3d_resource * __cdecl wined3d_buffer_get_resource(struct wined3d_buf ULONG __cdecl wined3d_buffer_incref(struct wined3d_buffer *buffer);
HRESULT __cdecl wined3d_device_acquire_focus_window(struct wined3d_device *device, HWND window); +void __cdecl wined3d_device_apply_stateblock(struct wined3d_device *device, struct wined3d_stateblock *stateblock); HRESULT __cdecl wined3d_device_begin_scene(struct wined3d_device *device); HRESULT __cdecl wined3d_device_clear(struct wined3d_device *device, DWORD rect_count, const RECT *rects, DWORD flags, const struct wined3d_color *color, float z, DWORD stencil);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d9/device.c | 9 +++++++++ 1 file changed, 9 insertions(+)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 82fba25ce7..be9c2a9d5a 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -1821,6 +1821,7 @@ static HRESULT WINAPI d3d9_device_ColorFill(IDirect3DDevice9Ex *iface, return D3DERR_INVALIDCALL; }
+ wined3d_device_apply_stateblock(device->wined3d_device, device->state); rtv = d3d9_surface_acquire_rendertarget_view(surface_impl); hr = wined3d_device_clear_rendertarget_view(device->wined3d_device, rtv, rect, WINED3DCLEAR_TARGET, &c, 0.0f, 0); @@ -2071,6 +2072,7 @@ static HRESULT WINAPI d3d9_device_Clear(IDirect3DDevice9Ex *iface, DWORD rect_co
wined3d_color_from_d3dcolor(&c, color); wined3d_mutex_lock(); + wined3d_device_apply_stateblock(device->wined3d_device, device->state); hr = wined3d_device_clear(device->wined3d_device, rect_count, (const RECT *)rects, flags, &c, z, stencil); if (SUCCEEDED(hr)) d3d9_rts_flag_auto_gen_mipmap(device); @@ -2654,6 +2656,7 @@ static HRESULT WINAPI d3d9_device_ValidateDevice(IDirect3DDevice9Ex *iface, DWOR TRACE("iface %p, pass_count %p.\n", iface, pass_count);
wined3d_mutex_lock(); + wined3d_device_apply_stateblock(device->wined3d_device, device->state); hr = wined3d_device_validate_device(device->wined3d_device, pass_count); wined3d_mutex_unlock();
@@ -2885,6 +2888,7 @@ static HRESULT WINAPI d3d9_device_DrawPrimitive(IDirect3DDevice9Ex *iface, WARN("Called without a valid vertex declaration set.\n"); return D3DERR_INVALIDCALL; } + wined3d_device_apply_stateblock(device->wined3d_device, device->state); vertex_count = vertex_count_from_primitive_count(primitive_type, primitive_count); d3d9_device_upload_sysmem_vertex_buffers(device, 0, start_vertex, vertex_count); d3d9_generate_auto_mipmaps(device); @@ -2917,6 +2921,7 @@ static HRESULT WINAPI d3d9_device_DrawIndexedPrimitive(IDirect3DDevice9Ex *iface WARN("Called without a valid vertex declaration set.\n"); return D3DERR_INVALIDCALL; } + wined3d_device_apply_stateblock(device->wined3d_device, device->state); index_count = vertex_count_from_primitive_count(primitive_type, primitive_count); d3d9_device_upload_sysmem_vertex_buffers(device, base_vertex_idx, min_vertex_idx, vertex_count); d3d9_device_upload_sysmem_index_buffer(device, start_idx, index_count); @@ -3003,6 +3008,7 @@ static HRESULT WINAPI d3d9_device_DrawPrimitiveUP(IDirect3DDevice9Ex *iface, return D3DERR_INVALIDCALL; }
+ wined3d_device_apply_stateblock(device->wined3d_device, device->state); hr = d3d9_device_prepare_vertex_buffer(device, size); if (FAILED(hr)) goto done; @@ -3119,6 +3125,7 @@ static HRESULT WINAPI d3d9_device_DrawIndexedPrimitiveUP(IDirect3DDevice9Ex *ifa return D3DERR_INVALIDCALL; }
+ wined3d_device_apply_stateblock(device->wined3d_device, device->state); hr = d3d9_device_prepare_vertex_buffer(device, vtx_size); if (FAILED(hr)) goto done; @@ -3203,6 +3210,8 @@ static HRESULT WINAPI d3d9_device_ProcessVertices(IDirect3DDevice9Ex *iface,
wined3d_mutex_lock();
+ wined3d_device_apply_stateblock(device->wined3d_device, device->state); + /* Note that an alternative approach would be to simply create these * buffers with WINED3D_RESOURCE_ACCESS_MAP_R and update them here like we * do for draws. In some regards that would be easier, but it seems less
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- v3: fix the call to wined3d_check_device_multisample_type() and move the implementation of resolve_depth_buffer() back to d3d9.
dlls/d3d9/device.c | 30 ++++++++++++++++++++++++++++++ dlls/d3d9/directx.c | 14 ++++++++++++-- include/wine/wined3d.h | 2 ++ 3 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index be9c2a9d5a..14d2a0cc25 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -2299,6 +2299,34 @@ static HRESULT WINAPI d3d9_device_GetClipPlane(IDirect3DDevice9Ex *iface, DWORD return hr; }
+static void resolve_depth_buffer(struct d3d9_device *device) +{ + const struct wined3d_stateblock_state *state = wined3d_stateblock_get_state(device->state); + struct wined3d_rendertarget_view *wined3d_dsv; + struct wined3d_resource *dst_resource; + struct wined3d_texture *dst_texture; + struct wined3d_resource_desc desc; + struct d3d9_surface *d3d9_dsv; + + if (!(dst_texture = state->textures[0])) + return; + dst_resource = wined3d_texture_get_resource(dst_texture); + wined3d_resource_get_desc(dst_resource, &desc); + if (desc.format != WINED3DFMT_D24_UNORM_S8_UINT + && desc.format != WINED3DFMT_X8D24_UNORM + && desc.format != WINED3DFMT_DF16 + && desc.format != WINED3DFMT_DF24 + && desc.format != WINED3DFMT_INTZ) + return; + + if (!(wined3d_dsv = wined3d_device_get_depth_stencil_view(device->wined3d_device))) + return; + d3d9_dsv = wined3d_rendertarget_view_get_sub_resource_parent(wined3d_dsv); + + wined3d_device_resolve_sub_resource(device->wined3d_device, dst_resource, 0, + wined3d_rendertarget_view_get_resource(wined3d_dsv), d3d9_dsv->sub_resource_idx, desc.format); +} + static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_SetRenderState(IDirect3DDevice9Ex *iface, D3DRENDERSTATETYPE state, DWORD value) { @@ -2319,6 +2347,8 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_SetRenderState(IDirect3DDevi else wined3d_device_set_render_state(device->wined3d_device, state, value); } + if (state == D3DRS_POINTSIZE && value == WINED3D_RESZ_CODE) + resolve_depth_buffer(device); wined3d_mutex_unlock();
return D3D_OK; diff --git a/dlls/d3d9/directx.c b/dlls/d3d9/directx.c index 1d3754adf8..fd22259e17 100644 --- a/dlls/d3d9/directx.c +++ b/dlls/d3d9/directx.c @@ -289,8 +289,18 @@ static HRESULT WINAPI d3d9_CheckDeviceFormat(IDirect3D9Ex *iface, UINT adapter, }
wined3d_mutex_lock(); - hr = wined3d_check_device_format(d3d9->wined3d, adapter, device_type, wined3dformat_from_d3dformat(adapter_format), - usage, bind_flags, wined3d_rtype, wined3dformat_from_d3dformat(format)); + if ((enum wined3d_format_id)format == WINED3DFMT_RESZ) + { + DWORD levels; + hr = wined3d_check_device_multisample_type(d3d9->wined3d, adapter, device_type, + WINED3DFMT_D24_UNORM_S8_UINT, FALSE, WINED3D_MULTISAMPLE_NON_MASKABLE, &levels); + if (SUCCEEDED(hr) && !levels) + hr = D3DERR_NOTAVAILABLE; + } + else + hr = wined3d_check_device_format(d3d9->wined3d, adapter, device_type, + wined3dformat_from_d3dformat(adapter_format), usage, bind_flags, + wined3d_rtype, wined3dformat_from_d3dformat(format)); wined3d_mutex_unlock();
return hr; diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 4306f5ae21..d313c7aec8 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -267,6 +267,8 @@ enum wined3d_format_id WINED3DFMT_R16 = WINEMAKEFOURCC(' ','R','1','6'), WINED3DFMT_AL16 = WINEMAKEFOURCC('A','L','1','6'), WINED3DFMT_NV12 = WINEMAKEFOURCC('N','V','1','2'), + WINED3DFMT_DF16 = WINEMAKEFOURCC('D','F','1','6'), + WINED3DFMT_DF24 = WINEMAKEFOURCC('D','F','2','4'),
WINED3DFMT_FORCE_DWORD = 0xffffffff };
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d9/device.c | 11 ----------- 1 file changed, 11 deletions(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index 14d2a0cc25..b77f516546 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -2331,22 +2331,11 @@ static HRESULT WINAPI DECLSPEC_HOTPATCH d3d9_device_SetRenderState(IDirect3DDevi D3DRENDERSTATETYPE state, DWORD value) { struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); - struct wined3d_color factor;
TRACE("iface %p, state %#x, value %#x.\n", iface, state, value);
wined3d_mutex_lock(); wined3d_stateblock_set_render_state(device->update_state, state, value); - if (!device->recording) - { - if (state == D3DRS_BLENDFACTOR) - { - wined3d_color_from_d3dcolor(&factor, value); - wined3d_device_set_blend_state(device->wined3d_device, NULL, &factor); - } - else - wined3d_device_set_render_state(device->wined3d_device, state, value); - } if (state == D3DRS_POINTSIZE && value == WINED3D_RESZ_CODE) resolve_depth_buffer(device); wined3d_mutex_unlock();
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d9/device.c | 4 ---- 1 file changed, 4 deletions(-)
diff --git a/dlls/d3d9/device.c b/dlls/d3d9/device.c index b77f516546..3229008722 100644 --- a/dlls/d3d9/device.c +++ b/dlls/d3d9/device.c @@ -1020,8 +1020,6 @@ static HRESULT d3d9_device_reset(struct d3d9_device *device, device->auto_mipmaps = 0; wined3d_stateblock_set_render_state(device->state, WINED3D_RS_ZENABLE, !!swapchain_desc.enable_auto_depth_stencil); - wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ZENABLE, - !!swapchain_desc.enable_auto_depth_stencil); device_reset_viewport_state(device); }
@@ -4673,8 +4671,6 @@ HRESULT device_init(struct d3d9_device *device, struct d3d9 *parent, struct wine
wined3d_stateblock_set_render_state(device->state, WINED3D_RS_ZENABLE, !!swapchain_desc->enable_auto_depth_stencil); - wined3d_device_set_render_state(device->wined3d_device, - WINED3D_RS_ZENABLE, !!swapchain_desc->enable_auto_depth_stencil); device_reset_viewport_state(device);
if (FAILED(hr = d3d9_device_get_swapchains(device)))
On Fri, Dec 13, 2019 at 10:49 PM Zebediah Figura z.figura12@gmail.com wrote:
Signed-off-by: Zebediah Figura z.figura12@gmail.com
v3: Only push modified constants.
This series may not necessarily be safe for code freeze, but I'm submitting it at least to finish the review process.
dlls/wined3d/device.c | 193 ++++++++++++++++++++++++++++++++++++++ dlls/wined3d/wined3d.spec | 1 + include/wine/wined3d.h | 1 + 3 files changed, 195 insertions(+)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 8913420724..8e20e31d3f 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3829,6 +3829,199 @@ struct wined3d_texture * CDECL wined3d_device_get_texture(const struct wined3d_d return device->state.textures[stage]; }
+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;
- unsigned int i, j, count;
- TRACE("device %p, stateblock %p.\n", device, stateblock);
- if (stateblock->changed.vertexShader)
wined3d_device_set_vertex_shader(device, state->vs);
- if (stateblock->changed.pixelShader)
wined3d_device_set_pixel_shader(device, state->ps);
- count = 0;
- for (i = 0; i < d3d_info->limits.vs_uniform_count; ++i)
- {
if (stateblock->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 (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)
- {
if (stateblock->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 (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)
- {
if (stateblock->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 (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)
- {
if (stateblock->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 (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)
- {
if (stateblock->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 (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)
- {
if (stateblock->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 (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)
- {
const struct wined3d_light_info *light;
LIST_FOR_EACH_ENTRY(light, &state->light_state->light_map[i], struct wined3d_light_info, entry)
{
wined3d_device_set_light(device, light->OriginalIndex, &light->OriginalParms);
wined3d_device_set_light_enable(device, light->OriginalIndex, light->glIndex != -1);
}
- }
- for (i = 0; i < ARRAY_SIZE(state->rs); ++i)
- {
if (stateblock->changed.renderState[i >> 5] & (1u << (i & 0x1f)))
{
if (i == WINED3D_RS_BLENDFACTOR)
{
struct wined3d_color color;
wined3d_color_from_d3dcolor(&color, state->rs[i]);
wined3d_device_set_blend_state(device, NULL, &color);
}
else
wined3d_device_set_render_state(device, i, state->rs[i]);
}
- }
- for (i = 0; i < ARRAY_SIZE(state->texture_states); ++i)
- {
for (j = 0; j < ARRAY_SIZE(state->texture_states[i]); ++j)
{
if (stateblock->changed.textureState[i] & (1u << j))
wined3d_device_set_texture_stage_state(device, i, j, state->texture_states[i][j]);
}
- }
- for (i = 0; i < ARRAY_SIZE(state->sampler_states); ++i)
- {
DWORD stage = i;
if (stage >= WINED3D_MAX_FRAGMENT_SAMPLERS)
stage += WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS;
for (j = 0; j < ARRAY_SIZE(state->sampler_states[j]); ++j)
{
if (stateblock->changed.samplerState[i] & (1 << j))
wined3d_device_set_sampler_state(device, stage, j, state->sampler_states[i][j]);
}
- }
- for (i = 0; i < ARRAY_SIZE(state->transforms); ++i)
- {
if (stateblock->changed.transform[i >> 5] & (1u << (i & 0x1f)))
wined3d_device_set_transform(device, i, &state->transforms[i]);
- }
- if (stateblock->changed.indices)
wined3d_device_set_index_buffer(device, state->index_buffer, state->index_format, 0);
- wined3d_device_set_base_vertex_index(device, state->base_vertex_index);
- if (stateblock->changed.vertexDecl)
wined3d_device_set_vertex_declaration(device, state->vertex_declaration);
- if (stateblock->changed.material)
wined3d_device_set_material(device, &state->material);
- if (stateblock->changed.viewport)
wined3d_device_set_viewports(device, 1, &state->viewport);
- if (stateblock->changed.scissorRect)
wined3d_device_set_scissor_rects(device, 1, &state->scissor_rect);
- for (i = 0; i < ARRAY_SIZE(state->streams); ++i)
- {
if (stateblock->changed.streamSource & (1u << i))
wined3d_device_set_stream_source(device, i, state->streams[i].buffer,
state->streams[i].offset, state->streams[i].stride);
if (stateblock->changed.streamFreq & (1u << i))
wined3d_device_set_stream_source_freq(device, i,
state->streams[i].frequency | state->streams[i].flags);
- }
- for (i = 0; i < ARRAY_SIZE(state->textures); ++i)
- {
DWORD stage = i;
if (stage >= WINED3D_MAX_FRAGMENT_SAMPLERS)
stage += WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS;
if (stateblock->changed.textures & (1u << i))
wined3d_device_set_texture(device, stage, state->textures[i]);
- }
- for (i = 0; i < ARRAY_SIZE(state->clip_planes); ++i)
- {
if (stateblock->changed.clipplane & (1u << i))
wined3d_device_set_clip_plane(device, i, &state->clip_planes[i]);
- }
- memset(&stateblock->changed, 0, sizeof(stateblock->changed));
- TRACE("Applied stateblock %p.\n", stateblock);
+}
HRESULT CDECL wined3d_device_get_device_caps(const struct wined3d_device *device, struct wined3d_caps *caps) { TRACE("device %p, caps %p.\n", device, caps); diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index e03c57055b..c8ef442c72 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -37,6 +37,7 @@ @ cdecl wined3d_buffer_incref(ptr)
@ cdecl wined3d_device_acquire_focus_window(ptr ptr) +@ cdecl wined3d_device_apply_stateblock(ptr ptr) @ cdecl wined3d_device_begin_scene(ptr) @ cdecl wined3d_device_clear(ptr long ptr long ptr float long) @ cdecl wined3d_device_clear_rendertarget_view(ptr ptr ptr long ptr float long) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 9cdf18633c..4306f5ae21 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2289,6 +2289,7 @@ struct wined3d_resource * __cdecl wined3d_buffer_get_resource(struct wined3d_buf ULONG __cdecl wined3d_buffer_incref(struct wined3d_buffer *buffer);
HRESULT __cdecl wined3d_device_acquire_focus_window(struct wined3d_device *device, HWND window); +void __cdecl wined3d_device_apply_stateblock(struct wined3d_device *device, struct wined3d_stateblock *stateblock); HRESULT __cdecl wined3d_device_begin_scene(struct wined3d_device *device); HRESULT __cdecl wined3d_device_clear(struct wined3d_device *device, DWORD rect_count, const RECT *rects, DWORD flags, const struct wined3d_color *color, float z, DWORD stencil); -- 2.24.0
Indeed this is pretty much the same as one of my patches I mentioned in the other email (except yours is complete, mine only changed float constants). Also mine touches wined3d_stateblock_apply() instead. Any reason we can't reuse that and avoid duplication?
On 1/22/20 9:55 AM, Matteo Bruni wrote:
On Fri, Dec 13, 2019 at 10:49 PM Zebediah Figura z.figura12@gmail.com wrote:
Signed-off-by: Zebediah Figura z.figura12@gmail.com
v3: Only push modified constants.
This series may not necessarily be safe for code freeze, but I'm submitting it at least to finish the review process.
dlls/wined3d/device.c | 193 ++++++++++++++++++++++++++++++++++++++ dlls/wined3d/wined3d.spec | 1 + include/wine/wined3d.h | 1 + 3 files changed, 195 insertions(+)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 8913420724..8e20e31d3f 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3829,6 +3829,199 @@ struct wined3d_texture * CDECL wined3d_device_get_texture(const struct wined3d_d return device->state.textures[stage]; }
+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;
- unsigned int i, j, count;
- TRACE("device %p, stateblock %p.\n", device, stateblock);
- if (stateblock->changed.vertexShader)
wined3d_device_set_vertex_shader(device, state->vs);
- if (stateblock->changed.pixelShader)
wined3d_device_set_pixel_shader(device, state->ps);
- count = 0;
- for (i = 0; i < d3d_info->limits.vs_uniform_count; ++i)
- {
if (stateblock->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 (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)
- {
if (stateblock->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 (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)
- {
if (stateblock->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 (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)
- {
if (stateblock->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 (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)
- {
if (stateblock->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 (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)
- {
if (stateblock->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 (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)
- {
const struct wined3d_light_info *light;
LIST_FOR_EACH_ENTRY(light, &state->light_state->light_map[i], struct wined3d_light_info, entry)
{
wined3d_device_set_light(device, light->OriginalIndex, &light->OriginalParms);
wined3d_device_set_light_enable(device, light->OriginalIndex, light->glIndex != -1);
}
- }
- for (i = 0; i < ARRAY_SIZE(state->rs); ++i)
- {
if (stateblock->changed.renderState[i >> 5] & (1u << (i & 0x1f)))
{
if (i == WINED3D_RS_BLENDFACTOR)
{
struct wined3d_color color;
wined3d_color_from_d3dcolor(&color, state->rs[i]);
wined3d_device_set_blend_state(device, NULL, &color);
}
else
wined3d_device_set_render_state(device, i, state->rs[i]);
}
- }
- for (i = 0; i < ARRAY_SIZE(state->texture_states); ++i)
- {
for (j = 0; j < ARRAY_SIZE(state->texture_states[i]); ++j)
{
if (stateblock->changed.textureState[i] & (1u << j))
wined3d_device_set_texture_stage_state(device, i, j, state->texture_states[i][j]);
}
- }
- for (i = 0; i < ARRAY_SIZE(state->sampler_states); ++i)
- {
DWORD stage = i;
if (stage >= WINED3D_MAX_FRAGMENT_SAMPLERS)
stage += WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS;
for (j = 0; j < ARRAY_SIZE(state->sampler_states[j]); ++j)
{
if (stateblock->changed.samplerState[i] & (1 << j))
wined3d_device_set_sampler_state(device, stage, j, state->sampler_states[i][j]);
}
- }
- for (i = 0; i < ARRAY_SIZE(state->transforms); ++i)
- {
if (stateblock->changed.transform[i >> 5] & (1u << (i & 0x1f)))
wined3d_device_set_transform(device, i, &state->transforms[i]);
- }
- if (stateblock->changed.indices)
wined3d_device_set_index_buffer(device, state->index_buffer, state->index_format, 0);
- wined3d_device_set_base_vertex_index(device, state->base_vertex_index);
- if (stateblock->changed.vertexDecl)
wined3d_device_set_vertex_declaration(device, state->vertex_declaration);
- if (stateblock->changed.material)
wined3d_device_set_material(device, &state->material);
- if (stateblock->changed.viewport)
wined3d_device_set_viewports(device, 1, &state->viewport);
- if (stateblock->changed.scissorRect)
wined3d_device_set_scissor_rects(device, 1, &state->scissor_rect);
- for (i = 0; i < ARRAY_SIZE(state->streams); ++i)
- {
if (stateblock->changed.streamSource & (1u << i))
wined3d_device_set_stream_source(device, i, state->streams[i].buffer,
state->streams[i].offset, state->streams[i].stride);
if (stateblock->changed.streamFreq & (1u << i))
wined3d_device_set_stream_source_freq(device, i,
state->streams[i].frequency | state->streams[i].flags);
- }
- for (i = 0; i < ARRAY_SIZE(state->textures); ++i)
- {
DWORD stage = i;
if (stage >= WINED3D_MAX_FRAGMENT_SAMPLERS)
stage += WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS;
if (stateblock->changed.textures & (1u << i))
wined3d_device_set_texture(device, stage, state->textures[i]);
- }
- for (i = 0; i < ARRAY_SIZE(state->clip_planes); ++i)
- {
if (stateblock->changed.clipplane & (1u << i))
wined3d_device_set_clip_plane(device, i, &state->clip_planes[i]);
- }
- memset(&stateblock->changed, 0, sizeof(stateblock->changed));
- TRACE("Applied stateblock %p.\n", stateblock);
+}
HRESULT CDECL wined3d_device_get_device_caps(const struct wined3d_device *device, struct wined3d_caps *caps) { TRACE("device %p, caps %p.\n", device, caps); diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index e03c57055b..c8ef442c72 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -37,6 +37,7 @@ @ cdecl wined3d_buffer_incref(ptr)
@ cdecl wined3d_device_acquire_focus_window(ptr ptr) +@ cdecl wined3d_device_apply_stateblock(ptr ptr) @ cdecl wined3d_device_begin_scene(ptr) @ cdecl wined3d_device_clear(ptr long ptr long ptr float long) @ cdecl wined3d_device_clear_rendertarget_view(ptr ptr ptr long ptr float long) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 9cdf18633c..4306f5ae21 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2289,6 +2289,7 @@ struct wined3d_resource * __cdecl wined3d_buffer_get_resource(struct wined3d_buf ULONG __cdecl wined3d_buffer_incref(struct wined3d_buffer *buffer);
HRESULT __cdecl wined3d_device_acquire_focus_window(struct wined3d_device *device, HWND window); +void __cdecl wined3d_device_apply_stateblock(struct wined3d_device *device, struct wined3d_stateblock *stateblock); HRESULT __cdecl wined3d_device_begin_scene(struct wined3d_device *device); HRESULT __cdecl wined3d_device_clear(struct wined3d_device *device, DWORD rect_count, const RECT *rects, DWORD flags, const struct wined3d_color *color, float z, DWORD stencil); -- 2.24.0
Indeed this is pretty much the same as one of my patches I mentioned in the other email (except yours is complete, mine only changed float constants). Also mine touches wined3d_stateblock_apply() instead. Any reason we can't reuse that and avoid duplication?
I think there's no reason, no. Ultimately, if I'm not mistaken, we could (with a little tweaking) turn wined3d_stateblock_apply() into wined3d_stateblock_capture() + wined3d_device_apply_stateblock(). [It gets a bit hairy around lights, though.]
On 1/22/20 10:04 AM, Zebediah Figura wrote:
On 1/22/20 9:55 AM, Matteo Bruni wrote:
On Fri, Dec 13, 2019 at 10:49 PM Zebediah Figura z.figura12@gmail.com wrote:
Signed-off-by: Zebediah Figura z.figura12@gmail.com
v3: Only push modified constants.
This series may not necessarily be safe for code freeze, but I'm submitting it at least to finish the review process.
dlls/wined3d/device.c | 193 ++++++++++++++++++++++++++++++++++++++ dlls/wined3d/wined3d.spec | 1 + include/wine/wined3d.h | 1 + 3 files changed, 195 insertions(+)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 8913420724..8e20e31d3f 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3829,6 +3829,199 @@ struct wined3d_texture * CDECL wined3d_device_get_texture(const struct wined3d_d return device->state.textures[stage]; }
+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;
- unsigned int i, j, count;
- TRACE("device %p, stateblock %p.\n", device, stateblock);
- if (stateblock->changed.vertexShader)
wined3d_device_set_vertex_shader(device, state->vs);
- if (stateblock->changed.pixelShader)
wined3d_device_set_pixel_shader(device, state->ps);
- count = 0;
- for (i = 0; i < d3d_info->limits.vs_uniform_count; ++i)
- {
if (stateblock->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 (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)
- {
if (stateblock->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 (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)
- {
if (stateblock->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 (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)
- {
if (stateblock->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 (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)
- {
if (stateblock->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 (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)
- {
if (stateblock->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 (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)
- {
const struct wined3d_light_info *light;
LIST_FOR_EACH_ENTRY(light, &state->light_state->light_map[i], struct wined3d_light_info, entry)
{
wined3d_device_set_light(device, light->OriginalIndex, &light->OriginalParms);
wined3d_device_set_light_enable(device, light->OriginalIndex, light->glIndex != -1);
}
- }
- for (i = 0; i < ARRAY_SIZE(state->rs); ++i)
- {
if (stateblock->changed.renderState[i >> 5] & (1u << (i & 0x1f)))
{
if (i == WINED3D_RS_BLENDFACTOR)
{
struct wined3d_color color;
wined3d_color_from_d3dcolor(&color, state->rs[i]);
wined3d_device_set_blend_state(device, NULL, &color);
}
else
wined3d_device_set_render_state(device, i, state->rs[i]);
}
- }
- for (i = 0; i < ARRAY_SIZE(state->texture_states); ++i)
- {
for (j = 0; j < ARRAY_SIZE(state->texture_states[i]); ++j)
{
if (stateblock->changed.textureState[i] & (1u << j))
wined3d_device_set_texture_stage_state(device, i, j, state->texture_states[i][j]);
}
- }
- for (i = 0; i < ARRAY_SIZE(state->sampler_states); ++i)
- {
DWORD stage = i;
if (stage >= WINED3D_MAX_FRAGMENT_SAMPLERS)
stage += WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS;
for (j = 0; j < ARRAY_SIZE(state->sampler_states[j]); ++j)
{
if (stateblock->changed.samplerState[i] & (1 << j))
wined3d_device_set_sampler_state(device, stage, j, state->sampler_states[i][j]);
}
- }
- for (i = 0; i < ARRAY_SIZE(state->transforms); ++i)
- {
if (stateblock->changed.transform[i >> 5] & (1u << (i & 0x1f)))
wined3d_device_set_transform(device, i, &state->transforms[i]);
- }
- if (stateblock->changed.indices)
wined3d_device_set_index_buffer(device, state->index_buffer, state->index_format, 0);
- wined3d_device_set_base_vertex_index(device, state->base_vertex_index);
- if (stateblock->changed.vertexDecl)
wined3d_device_set_vertex_declaration(device, state->vertex_declaration);
- if (stateblock->changed.material)
wined3d_device_set_material(device, &state->material);
- if (stateblock->changed.viewport)
wined3d_device_set_viewports(device, 1, &state->viewport);
- if (stateblock->changed.scissorRect)
wined3d_device_set_scissor_rects(device, 1, &state->scissor_rect);
- for (i = 0; i < ARRAY_SIZE(state->streams); ++i)
- {
if (stateblock->changed.streamSource & (1u << i))
wined3d_device_set_stream_source(device, i, state->streams[i].buffer,
state->streams[i].offset, state->streams[i].stride);
if (stateblock->changed.streamFreq & (1u << i))
wined3d_device_set_stream_source_freq(device, i,
state->streams[i].frequency | state->streams[i].flags);
- }
- for (i = 0; i < ARRAY_SIZE(state->textures); ++i)
- {
DWORD stage = i;
if (stage >= WINED3D_MAX_FRAGMENT_SAMPLERS)
stage += WINED3DVERTEXTEXTURESAMPLER0 - WINED3D_MAX_FRAGMENT_SAMPLERS;
if (stateblock->changed.textures & (1u << i))
wined3d_device_set_texture(device, stage, state->textures[i]);
- }
- for (i = 0; i < ARRAY_SIZE(state->clip_planes); ++i)
- {
if (stateblock->changed.clipplane & (1u << i))
wined3d_device_set_clip_plane(device, i, &state->clip_planes[i]);
- }
- memset(&stateblock->changed, 0, sizeof(stateblock->changed));
- TRACE("Applied stateblock %p.\n", stateblock);
+}
- HRESULT CDECL wined3d_device_get_device_caps(const struct wined3d_device *device, struct wined3d_caps *caps) { TRACE("device %p, caps %p.\n", device, caps);
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index e03c57055b..c8ef442c72 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -37,6 +37,7 @@ @ cdecl wined3d_buffer_incref(ptr)
@ cdecl wined3d_device_acquire_focus_window(ptr ptr) +@ cdecl wined3d_device_apply_stateblock(ptr ptr) @ cdecl wined3d_device_begin_scene(ptr) @ cdecl wined3d_device_clear(ptr long ptr long ptr float long) @ cdecl wined3d_device_clear_rendertarget_view(ptr ptr ptr long ptr float long) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 9cdf18633c..4306f5ae21 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2289,6 +2289,7 @@ struct wined3d_resource * __cdecl wined3d_buffer_get_resource(struct wined3d_buf ULONG __cdecl wined3d_buffer_incref(struct wined3d_buffer *buffer);
HRESULT __cdecl wined3d_device_acquire_focus_window(struct wined3d_device *device, HWND window); +void __cdecl wined3d_device_apply_stateblock(struct wined3d_device *device, struct wined3d_stateblock *stateblock); HRESULT __cdecl wined3d_device_begin_scene(struct wined3d_device *device); HRESULT __cdecl wined3d_device_clear(struct wined3d_device *device, DWORD rect_count, const RECT *rects, DWORD flags, const struct wined3d_color *color, float z, DWORD stencil); -- 2.24.0
Indeed this is pretty much the same as one of my patches I mentioned in the other email (except yours is complete, mine only changed float constants). Also mine touches wined3d_stateblock_apply() instead. Any reason we can't reuse that and avoid duplication?
I think there's no reason, no. Ultimately, if I'm not mistaken, we could (with a little tweaking) turn wined3d_stateblock_apply() into wined3d_stateblock_capture() + wined3d_device_apply_stateblock(). [It gets a bit hairy around lights, though.]
On second thought, I think the reason I didn't do this in the first place is that eventually that code [viz. calling wined3d_device_set_*() in wined3d_stateblock_apply()] would get removed anyway, after all of the client libraries used wined3d_device_apply_stateblock().
Whether to use the v3 or v4 of this patch is not something I care particularly much about.
On Thu, 23 Jan 2020 at 18:22, Zebediah Figura z.figura12@gmail.com wrote:
On second thought, I think the reason I didn't do this in the first place is that eventually that code [viz. calling wined3d_device_set_*() in wined3d_stateblock_apply()] would get removed anyway, after all of the client libraries used wined3d_device_apply_stateblock().
Whether to use the v3 or v4 of this patch is not something I care particularly much about.
It probably would have been best to make that particular change in a separate patch in any case, but I think there's another issue with this. You're calling wined3d_device_apply_stateblock() from wined3d_stateblock_apply() with "device_state" as the "stateblock" parameter. That means it's also going to be using the "changed" information from "device_state", but wined3d_stateblock_apply() doesn't update that information, and it probably shouldn't.
On 1/24/20 8:28 AM, Henri Verbeet wrote:
On Thu, 23 Jan 2020 at 18:22, Zebediah Figura z.figura12@gmail.com wrote:
On second thought, I think the reason I didn't do this in the first place is that eventually that code [viz. calling wined3d_device_set_*() in wined3d_stateblock_apply()] would get removed anyway, after all of the client libraries used wined3d_device_apply_stateblock().
Whether to use the v3 or v4 of this patch is not something I care particularly much about.
It probably would have been best to make that particular change in a separate patch in any case, but I think there's another issue with this. You're calling wined3d_device_apply_stateblock() from wined3d_stateblock_apply() with "device_state" as the "stateblock" parameter. That means it's also going to be using the "changed" information from "device_state", but wined3d_stateblock_apply() doesn't update that information, and it probably shouldn't.
Good point; I'll revert that change then.