Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/device.c | 7 +++++++ dlls/wined3d/wined3d.spec | 1 + include/wine/wined3d.h | 1 + 3 files changed, 9 insertions(+)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 06329293261..181f491546a 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -2054,6 +2054,13 @@ struct wined3d_state * CDECL wined3d_device_get_state(struct wined3d_device *dev return device->cs->c.state; }
+struct wined3d_device_context * CDECL wined3d_device_get_immediate_context(struct wined3d_device *device) +{ + TRACE("device %p.\n", device); + + return &device->cs->c; +} + void CDECL wined3d_device_set_vertex_declaration(struct wined3d_device *device, struct wined3d_vertex_declaration *declaration) { diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index f1d477af703..f5fa1d3d7e5 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -84,6 +84,7 @@ @ cdecl wined3d_device_get_hs_resource_view(ptr long) @ cdecl wined3d_device_get_hs_sampler(ptr long) @ cdecl wined3d_device_get_hull_shader(ptr) +@ cdecl wined3d_device_get_immediate_context(ptr) @ cdecl wined3d_device_get_index_buffer(ptr ptr ptr) @ cdecl wined3d_device_get_max_frame_latency(ptr) @ cdecl wined3d_device_get_npatch_mode(ptr) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 030e3fdcb67..ba9e8642ea2 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2414,6 +2414,7 @@ struct wined3d_shader_resource_view * __cdecl wined3d_device_get_hs_resource_vie unsigned int idx); struct wined3d_sampler * __cdecl wined3d_device_get_hs_sampler(const struct wined3d_device *device, unsigned int idx); struct wined3d_shader * __cdecl wined3d_device_get_hull_shader(const struct wined3d_device *device); +struct wined3d_device_context * __cdecl wined3d_device_get_immediate_context(struct wined3d_device *device); struct wined3d_buffer * __cdecl wined3d_device_get_index_buffer(const struct wined3d_device *device, enum wined3d_format_id *format, unsigned int *offset); unsigned int __cdecl wined3d_device_get_max_frame_latency(const struct wined3d_device *device);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/cs.c | 43 +++++++++++++++++++++------------- dlls/wined3d/device.c | 27 ++++++++++++++++++++- dlls/wined3d/wined3d.spec | 2 ++ dlls/wined3d/wined3d_private.h | 4 +++- include/wine/wined3d.h | 2 ++ 5 files changed, 60 insertions(+), 18 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 5176c635cf5..13a034660d3 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -2732,12 +2732,23 @@ static void wined3d_cs_st_finish(struct wined3d_device_context *context, enum wi { }
+static void wined3d_cs_st_destroy(struct wined3d_device_context *context) +{ + struct wined3d_cs *cs = wined3d_cs_from_context(context); + + wined3d_state_destroy(cs->c.state); + state_cleanup(&cs->state); + heap_free(cs->data); + heap_free(cs); +} + static const struct wined3d_device_context_ops wined3d_cs_st_ops = { wined3d_cs_st_require_space, wined3d_cs_st_submit, wined3d_cs_st_finish, wined3d_cs_st_push_constants, + wined3d_cs_st_destroy, };
static BOOL wined3d_cs_queue_is_empty(const struct wined3d_cs *cs, const struct wined3d_cs_queue *queue) @@ -2853,12 +2864,27 @@ static void wined3d_cs_mt_finish(struct wined3d_device_context *context, enum wi YieldProcessor(); }
+static void wined3d_cs_mt_destroy(struct wined3d_device_context *context) +{ + struct wined3d_cs *cs = wined3d_cs_from_context(context); + + wined3d_cs_emit_stop(cs); + CloseHandle(cs->thread); + CloseHandle(cs->event); + + wined3d_state_destroy(cs->c.state); + state_cleanup(&cs->state); + heap_free(cs->data); + heap_free(cs); +} + static const struct wined3d_device_context_ops wined3d_cs_mt_ops = { wined3d_cs_mt_require_space, wined3d_cs_mt_submit, wined3d_cs_mt_finish, wined3d_cs_mt_push_constants, + wined3d_cs_mt_destroy, };
static void poll_queries(struct wined3d_cs *cs) @@ -2994,6 +3020,7 @@ struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device) return NULL; }
+ cs->c.refcount = 1; cs->c.ops = &wined3d_cs_st_ops; cs->c.device = device; cs->serialize_commands = TRACE_ON(d3d_sync) || wined3d_settings.cs_multithreaded & WINED3D_CSMT_SERIALIZE; @@ -3043,19 +3070,3 @@ fail: heap_free(cs); return NULL; } - -void wined3d_cs_destroy(struct wined3d_cs *cs) -{ - if (cs->thread) - { - wined3d_cs_emit_stop(cs); - CloseHandle(cs->thread); - if (!CloseHandle(cs->event)) - ERR("Closing event failed.\n"); - } - - wined3d_state_destroy(cs->c.state); - state_cleanup(&cs->state); - heap_free(cs->data); - heap_free(cs); -} diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 181f491546a..629f8c2c740 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -90,6 +90,30 @@ const struct wined3d_light WINED3D_default_light = 0.0f /* Phi */ };
+ULONG CDECL wined3d_device_context_incref(struct wined3d_device_context *context) +{ + ULONG refcount = InterlockedIncrement(&context->refcount); + + TRACE("%p increasing refcount to %u.\n", context, refcount); + + return refcount; +} + +ULONG CDECL wined3d_device_context_decref(struct wined3d_device_context *context) +{ + ULONG refcount = InterlockedDecrement(&context->refcount); + + TRACE("%p decreasing refcount to %u.\n", context, refcount); + + if (!refcount) + { + context->ops->destroy(context); + TRACE("Destroyed device context %p.\n", context); + } + + return refcount; +} + BOOL device_context_add(struct wined3d_device *device, struct wined3d_context *context) { struct wined3d_context **new_array; @@ -218,7 +242,7 @@ void wined3d_device_cleanup(struct wined3d_device *device) if (device->swapchain_count) wined3d_device_uninit_3d(device);
- wined3d_cs_destroy(device->cs); + wined3d_device_context_decref(&device->cs->c);
for (i = 0; i < ARRAY_SIZE(device->multistate_funcs); ++i) { @@ -2058,6 +2082,7 @@ struct wined3d_device_context * CDECL wined3d_device_get_immediate_context(struc { TRACE("device %p.\n", device);
+ wined3d_device_context_incref(&device->cs->c); return &device->cs->c; }
diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index f5fa1d3d7e5..72f12243add 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -167,6 +167,8 @@ @ cdecl wined3d_device_update_texture(ptr ptr ptr) @ cdecl wined3d_device_validate_device(ptr ptr)
+@ cdecl wined3d_device_context_decref(ptr) +@ cdecl wined3d_device_context_incref(ptr) @ cdecl wined3d_device_context_set_shader(ptr long ptr)
@ cdecl wined3d_output_find_closest_matching_mode(ptr ptr) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index ee00530981c..2c39898d03c 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4676,10 +4676,13 @@ struct wined3d_device_context_ops void (*finish)(struct wined3d_device_context *context, enum wined3d_cs_queue_id queue_id); void (*push_constants)(struct wined3d_device_context *context, enum wined3d_push_constants p, unsigned int start_idx, unsigned int count, const void *constants); + void (*destroy)(struct wined3d_device_context *context); };
struct wined3d_device_context { + LONG refcount; + const struct wined3d_device_context_ops *ops; struct wined3d_device *device; struct wined3d_state *state; @@ -4707,7 +4710,6 @@ struct wined3d_cs };
struct wined3d_cs *wined3d_cs_create(struct wined3d_device *device) DECLSPEC_HIDDEN; -void wined3d_cs_destroy(struct wined3d_cs *cs) DECLSPEC_HIDDEN; void wined3d_cs_destroy_object(struct wined3d_cs *cs, void (*callback)(void *object), void *object) DECLSPEC_HIDDEN; void wined3d_cs_emit_add_dirty_texture_region(struct wined3d_cs *cs, diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index ba9e8642ea2..424ee8e75a5 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2549,6 +2549,8 @@ HRESULT __cdecl wined3d_device_update_texture(struct wined3d_device *device, struct wined3d_texture *src_texture, struct wined3d_texture *dst_texture); HRESULT __cdecl wined3d_device_validate_device(const struct wined3d_device *device, DWORD *num_passes);
+ULONG __cdecl wined3d_device_context_decref(struct wined3d_device_context *context); +ULONG __cdecl wined3d_device_context_incref(struct wined3d_device_context *context); void __cdecl wined3d_device_context_set_shader(struct wined3d_device_context *context, enum wined3d_shader_type type, struct wined3d_shader *shader);
On Sun, 7 Mar 2021 at 23:19, Zebediah Figura z.figura12@gmail.com wrote:
@@ -2058,6 +2082,7 @@ struct wined3d_device_context * CDECL wined3d_device_get_immediate_context(struc { TRACE("device %p.\n", device);
- wined3d_device_context_incref(&device->cs->c); return &device->cs->c;
}
That's inconsistent with the rest of the API. As a rule we don't increment reference counts when returning objects, leaving that to the caller instead if necessary. (And more often than not, it isn't.)
It may also be worth mentioning why device contexts need to be reference counted at all. I assume there's a reason, but it's not obvious to me from this series.
On 3/8/21 5:29 AM, Henri Verbeet wrote:
On Sun, 7 Mar 2021 at 23:19, Zebediah Figura z.figura12@gmail.com wrote:
@@ -2058,6 +2082,7 @@ struct wined3d_device_context * CDECL wined3d_device_get_immediate_context(struc { TRACE("device %p.\n", device);
- wined3d_device_context_incref(&device->cs->c); return &device->cs->c;
}
That's inconsistent with the rest of the API. As a rule we don't increment reference counts when returning objects, leaving that to the caller instead if necessary. (And more often than not, it isn't.)
It may also be worth mentioning why device contexts need to be reference counted at all. I assume there's a reason, but it's not obvious to me from this series.
Mostly because it's then easy to always decref from ID3D11DeviceContext::Release(), though it could certainly be considered easier to check the context type there.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d11/d3d11_private.h | 2 ++ dlls/d3d11/device.c | 40 +++++++++++++++++++++----------------- 2 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/dlls/d3d11/d3d11_private.h b/dlls/d3d11/d3d11_private.h index a64d6975f85..5a812e1b254 100644 --- a/dlls/d3d11/d3d11_private.h +++ b/dlls/d3d11/d3d11_private.h @@ -546,6 +546,8 @@ struct d3d11_immediate_context ID3D11Multithread ID3D11Multithread_iface; LONG refcount;
+ struct wined3d_device_context *wined3d_context; + struct wined3d_private_store private_store; };
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index c8ec35a59c0..ca8a2662460 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -512,7 +512,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetShaderResources(ID3D1 static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetShader(ID3D11DeviceContext1 *iface, ID3D11PixelShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); + struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext1(iface); struct d3d_pixel_shader *ps = unsafe_impl_from_ID3D11PixelShader(shader);
TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n", @@ -522,7 +522,8 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetShader(ID3D11DeviceCo FIXME("Dynamic linking is not implemented yet.\n");
wined3d_mutex_lock(); - wined3d_device_set_pixel_shader(device->wined3d_device, ps ? ps->wined3d_shader : NULL); + wined3d_device_context_set_shader(context->wined3d_context, WINED3D_SHADER_TYPE_PIXEL, + ps ? ps->wined3d_shader : NULL); wined3d_mutex_unlock(); }
@@ -549,7 +550,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetSamplers(ID3D11Device static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetShader(ID3D11DeviceContext1 *iface, ID3D11VertexShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); + struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext1(iface); struct d3d_vertex_shader *vs = unsafe_impl_from_ID3D11VertexShader(shader);
TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n", @@ -559,7 +560,8 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetShader(ID3D11DeviceCo FIXME("Dynamic linking is not implemented yet.\n");
wined3d_mutex_lock(); - wined3d_device_set_vertex_shader(device->wined3d_device, vs ? vs->wined3d_shader : NULL); + wined3d_device_context_set_shader(context->wined3d_context, WINED3D_SHADER_TYPE_VERTEX, + vs ? vs->wined3d_shader : NULL); wined3d_mutex_unlock(); }
@@ -737,7 +739,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetConstantBuffers(ID3D1 static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetShader(ID3D11DeviceContext1 *iface, ID3D11GeometryShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); + struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext1(iface); struct d3d_geometry_shader *gs = unsafe_impl_from_ID3D11GeometryShader(shader);
TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n", @@ -747,7 +749,8 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetShader(ID3D11DeviceCo FIXME("Dynamic linking is not implemented yet.\n");
wined3d_mutex_lock(); - wined3d_device_set_geometry_shader(device->wined3d_device, gs ? gs->wined3d_shader : NULL); + wined3d_device_context_set_shader(context->wined3d_context, WINED3D_SHADER_TYPE_GEOMETRY, + gs ? gs->wined3d_shader : NULL); wined3d_mutex_unlock(); }
@@ -1425,7 +1428,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetShaderResources(ID3D1 static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetShader(ID3D11DeviceContext1 *iface, ID3D11HullShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); + struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext1(iface); struct d3d11_hull_shader *hs = unsafe_impl_from_ID3D11HullShader(shader);
TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n", @@ -1435,7 +1438,8 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetShader(ID3D11DeviceCo FIXME("Dynamic linking is not implemented yet.\n");
wined3d_mutex_lock(); - wined3d_device_set_hull_shader(device->wined3d_device, hs ? hs->wined3d_shader : NULL); + wined3d_device_context_set_shader(context->wined3d_context, WINED3D_SHADER_TYPE_HULL, + hs ? hs->wined3d_shader : NULL); wined3d_mutex_unlock(); }
@@ -1492,7 +1496,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetShaderResources(ID3D1 static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetShader(ID3D11DeviceContext1 *iface, ID3D11DomainShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); + struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext1(iface); struct d3d11_domain_shader *ds = unsafe_impl_from_ID3D11DomainShader(shader);
TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n", @@ -1502,7 +1506,8 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetShader(ID3D11DeviceCo FIXME("Dynamic linking is not implemented yet.\n");
wined3d_mutex_lock(); - wined3d_device_set_domain_shader(device->wined3d_device, ds ? ds->wined3d_shader : NULL); + wined3d_device_context_set_shader(context->wined3d_context, WINED3D_SHADER_TYPE_DOMAIN, + ds ? ds->wined3d_shader : NULL); wined3d_mutex_unlock(); }
@@ -1579,7 +1584,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetUnorderedAccessViews( static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetShader(ID3D11DeviceContext1 *iface, ID3D11ComputeShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); + struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext1(iface); struct d3d11_compute_shader *cs = unsafe_impl_from_ID3D11ComputeShader(shader);
TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n", @@ -1589,7 +1594,8 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetShader(ID3D11DeviceCo FIXME("Dynamic linking is not implemented yet.\n");
wined3d_mutex_lock(); - wined3d_device_set_compute_shader(device->wined3d_device, cs ? cs->wined3d_shader : NULL); + wined3d_device_context_set_shader(context->wined3d_context, WINED3D_SHADER_TYPE_COMPUTE, + cs ? cs->wined3d_shader : NULL); wined3d_mutex_unlock(); }
@@ -2577,6 +2583,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetConstantBuffers(ID3D1
static void STDMETHODCALLTYPE d3d11_immediate_context_ClearState(ID3D11DeviceContext1 *iface) { + struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext1(iface); struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); static const float blend_factor[] = {1.0f, 1.0f, 1.0f, 1.0f}; unsigned int i, j; @@ -2584,12 +2591,6 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_ClearState(ID3D11DeviceCon TRACE("iface %p.\n", iface);
wined3d_mutex_lock(); - wined3d_device_set_vertex_shader(device->wined3d_device, NULL); - wined3d_device_set_hull_shader(device->wined3d_device, NULL); - wined3d_device_set_domain_shader(device->wined3d_device, NULL); - wined3d_device_set_geometry_shader(device->wined3d_device, NULL); - wined3d_device_set_pixel_shader(device->wined3d_device, NULL); - wined3d_device_set_compute_shader(device->wined3d_device, NULL); for (i = 0; i < D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT; ++i) { wined3d_device_set_vs_sampler(device->wined3d_device, i, NULL); @@ -2610,6 +2611,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_ClearState(ID3D11DeviceCon } for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i) { + wined3d_device_context_set_shader(context->wined3d_context, i, NULL); for (j = 0; j < D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++j) wined3d_device_set_constant_buffer(device->wined3d_device, i, j, NULL); } @@ -3106,6 +3108,7 @@ static void d3d11_immediate_context_init(struct d3d11_immediate_context *context static void d3d11_immediate_context_destroy(struct d3d11_immediate_context *context) { wined3d_private_store_cleanup(&context->private_store); + wined3d_device_context_decref(context->wined3d_context); }
/* ID3D11Device methods */ @@ -6458,6 +6461,7 @@ static void CDECL device_parent_wined3d_device_created(struct wined3d_device_par
wined3d_device_incref(wined3d_device); device->wined3d_device = wined3d_device; + device->immediate_context.wined3d_context = wined3d_device_get_immediate_context(wined3d_device);
device->feature_level = d3d_feature_level_from_wined3d(wined3d_device_get_feature_level(wined3d_device));
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=86545
Your paranoid android.
=== debiant2 (64 bit WoW report) ===
d3d11: Unhandled exception: page fault on read access to 0x00000044 in 32-bit code (0x6e953943).
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/cs.c | 8 ++++---- dlls/wined3d/device.c | 9 ++++----- dlls/wined3d/wined3d_private.h | 4 ++-- 3 files changed, 10 insertions(+), 11 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c index 13a034660d3..367d0aeadbb 100644 --- a/dlls/wined3d/cs.c +++ b/dlls/wined3d/cs.c @@ -1414,18 +1414,18 @@ static void wined3d_cs_exec_set_constant_buffer(struct wined3d_cs *cs, const voi device_invalidate_state(cs->c.device, STATE_CONSTANT_BUFFER(op->type)); }
-void wined3d_cs_emit_set_constant_buffer(struct wined3d_cs *cs, enum wined3d_shader_type type, - UINT cb_idx, struct wined3d_buffer *buffer) +void wined3d_device_context_emit_set_constant_buffer(struct wined3d_device_context *context, + enum wined3d_shader_type type, UINT cb_idx, struct wined3d_buffer *buffer) { struct wined3d_cs_set_constant_buffer *op;
- op = wined3d_device_context_require_space(&cs->c, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); + op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT); op->opcode = WINED3D_CS_OP_SET_CONSTANT_BUFFER; op->type = type; op->cb_idx = cb_idx; op->buffer = buffer;
- wined3d_device_context_submit(&cs->c, WINED3D_CS_QUEUE_DEFAULT); + wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT); }
static void wined3d_cs_exec_set_texture(struct wined3d_cs *cs, const void *data) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 629f8c2c740..ea18dd703a2 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1950,6 +1950,7 @@ void CDECL wined3d_device_get_scissor_rects(const struct wined3d_device *device,
void CDECL wined3d_device_set_state(struct wined3d_device *device, struct wined3d_state *state) { + struct wined3d_device_context *context = &device->cs->c; const struct wined3d_light_info *light; unsigned int i, j;
@@ -1983,11 +1984,9 @@ void CDECL wined3d_device_set_state(struct wined3d_device *device, struct wined3
for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i) { - wined3d_device_context_emit_set_shader(&device->cs->c, i, state->shader[i]); + wined3d_device_context_emit_set_shader(context, i, state->shader[i]); for (j = 0; j < MAX_CONSTANT_BUFFERS; ++j) - { - wined3d_cs_emit_set_constant_buffer(device->cs, i, j, state->cb[i][j]); - } + wined3d_device_context_emit_set_constant_buffer(context, i, j, state->cb[i][j]); for (j = 0; j < MAX_SAMPLER_OBJECTS; ++j) { wined3d_cs_emit_set_sampler(device->cs, i, j, state->sampler[i][j]); @@ -2168,7 +2167,7 @@ void CDECL wined3d_device_set_constant_buffer(struct wined3d_device *device, if (buffer) wined3d_buffer_incref(buffer); state->cb[type][idx] = buffer; - wined3d_cs_emit_set_constant_buffer(device->cs, type, idx, buffer); + wined3d_device_context_emit_set_constant_buffer(&device->cs->c, type, idx, buffer); if (prev) wined3d_buffer_decref(prev); } diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 2c39898d03c..a430d4df25b 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -4749,8 +4749,6 @@ void wined3d_cs_emit_set_clip_plane(struct wined3d_cs *cs, UINT plane_idx, const struct wined3d_vec4 *plane) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_color_key(struct wined3d_cs *cs, struct wined3d_texture *texture, WORD flags, const struct wined3d_color_key *color_key) DECLSPEC_HIDDEN; -void wined3d_cs_emit_set_constant_buffer(struct wined3d_cs *cs, enum wined3d_shader_type type, - UINT cb_idx, struct wined3d_buffer *buffer) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_depth_stencil_state(struct wined3d_cs *cs, struct wined3d_depth_stencil_state *state, unsigned int stencil_ref) DECLSPEC_HIDDEN; void wined3d_cs_emit_set_depth_stencil_view(struct wined3d_cs *cs, @@ -4814,6 +4812,8 @@ static inline void wined3d_cs_push_constants(struct wined3d_cs *cs, enum wined3d cs->c.ops->push_constants(&cs->c, p, start_idx, count, constants); }
+void wined3d_device_context_emit_set_constant_buffer(struct wined3d_device_context *context, + enum wined3d_shader_type type, UINT cb_idx, struct wined3d_buffer *buffer) DECLSPEC_HIDDEN; void wined3d_device_context_emit_set_shader(struct wined3d_device_context *context, enum wined3d_shader_type type, struct wined3d_shader *shader) DECLSPEC_HIDDEN;
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/wined3d/device.c | 44 +++++++++++++++++++++++---------------- dlls/wined3d/wined3d.spec | 1 + include/wine/wined3d.h | 2 ++ 3 files changed, 29 insertions(+), 18 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index ea18dd703a2..d780ac92f1f 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -2132,27 +2132,13 @@ void CDECL wined3d_device_context_set_shader(struct wined3d_device_context *cont wined3d_shader_decref(prev); }
-void CDECL wined3d_device_set_vertex_shader(struct wined3d_device *device, struct wined3d_shader *shader) -{ - TRACE("device %p, shader %p.\n", device, shader); - - return wined3d_device_context_set_shader(&device->cs->c, WINED3D_SHADER_TYPE_VERTEX, shader); -} - -struct wined3d_shader * CDECL wined3d_device_get_vertex_shader(const struct wined3d_device *device) -{ - TRACE("device %p.\n", device); - - return device->cs->c.state->shader[WINED3D_SHADER_TYPE_VERTEX]; -} - -void CDECL wined3d_device_set_constant_buffer(struct wined3d_device *device, +void CDECL wined3d_device_context_set_constant_buffer(struct wined3d_device_context *context, enum wined3d_shader_type type, UINT idx, struct wined3d_buffer *buffer) { - struct wined3d_state *state = device->cs->c.state; + struct wined3d_state *state = context->state; struct wined3d_buffer *prev;
- TRACE("device %p, type %#x, idx %u, buffer %p.\n", device, type, idx, buffer); + TRACE("context %p, type %#x, idx %u, buffer %p.\n", context, type, idx, buffer);
if (idx >= MAX_CONSTANT_BUFFERS) { @@ -2167,11 +2153,33 @@ void CDECL wined3d_device_set_constant_buffer(struct wined3d_device *device, if (buffer) wined3d_buffer_incref(buffer); state->cb[type][idx] = buffer; - wined3d_device_context_emit_set_constant_buffer(&device->cs->c, type, idx, buffer); + wined3d_device_context_emit_set_constant_buffer(context, type, idx, buffer); if (prev) wined3d_buffer_decref(prev); }
+void CDECL wined3d_device_set_vertex_shader(struct wined3d_device *device, struct wined3d_shader *shader) +{ + TRACE("device %p, shader %p.\n", device, shader); + + return wined3d_device_context_set_shader(&device->cs->c, WINED3D_SHADER_TYPE_VERTEX, shader); +} + +struct wined3d_shader * CDECL wined3d_device_get_vertex_shader(const struct wined3d_device *device) +{ + TRACE("device %p.\n", device); + + return device->cs->c.state->shader[WINED3D_SHADER_TYPE_VERTEX]; +} + +void CDECL wined3d_device_set_constant_buffer(struct wined3d_device *device, + enum wined3d_shader_type type, UINT idx, struct wined3d_buffer *buffer) +{ + TRACE("device %p, type %#x, idx %u, buffer %p.\n", device, type, idx, buffer); + + return wined3d_device_context_set_constant_buffer(&device->cs->c, type, idx, buffer); +} + struct wined3d_buffer * CDECL wined3d_device_get_constant_buffer(const struct wined3d_device *device, enum wined3d_shader_type shader_type, unsigned int idx) { diff --git a/dlls/wined3d/wined3d.spec b/dlls/wined3d/wined3d.spec index 72f12243add..f8a490f6c02 100644 --- a/dlls/wined3d/wined3d.spec +++ b/dlls/wined3d/wined3d.spec @@ -169,6 +169,7 @@
@ cdecl wined3d_device_context_decref(ptr) @ cdecl wined3d_device_context_incref(ptr) +@ cdecl wined3d_device_context_set_constant_buffer(ptr long long ptr) @ cdecl wined3d_device_context_set_shader(ptr long ptr)
@ cdecl wined3d_output_find_closest_matching_mode(ptr ptr) diff --git a/include/wine/wined3d.h b/include/wine/wined3d.h index 424ee8e75a5..51528ef6513 100644 --- a/include/wine/wined3d.h +++ b/include/wine/wined3d.h @@ -2551,6 +2551,8 @@ HRESULT __cdecl wined3d_device_validate_device(const struct wined3d_device *devi
ULONG __cdecl wined3d_device_context_decref(struct wined3d_device_context *context); ULONG __cdecl wined3d_device_context_incref(struct wined3d_device_context *context); +void __cdecl wined3d_device_context_set_constant_buffer(struct wined3d_device_context *context, + enum wined3d_shader_type type, UINT idx, struct wined3d_buffer *buffer); void __cdecl wined3d_device_context_set_shader(struct wined3d_device_context *context, enum wined3d_shader_type type, struct wined3d_shader *shader);
On Sun, 7 Mar 2021 at 23:19, Zebediah Figura z.figura12@gmail.com wrote:
+void __cdecl wined3d_device_context_set_constant_buffer(struct wined3d_device_context *context,
enum wined3d_shader_type type, UINT idx, struct wined3d_buffer *buffer);
We typically use "unsigned int" instead of "UINT" for new API.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/d3d11/device.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c index ca8a2662460..39d9fb78556 100644 --- a/dlls/d3d11/device.c +++ b/dlls/d3d11/device.c @@ -425,7 +425,7 @@ static void d3d11_immediate_context_get_constant_buffers(ID3D11DeviceContext1 *i static void d3d11_immediate_context_set_constant_buffers(ID3D11DeviceContext1 *iface, enum wined3d_shader_type type, UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); + struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext1(iface); unsigned int i;
wined3d_mutex_lock(); @@ -433,7 +433,7 @@ static void d3d11_immediate_context_set_constant_buffers(ID3D11DeviceContext1 *i { struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]);
- wined3d_device_set_constant_buffer(device->wined3d_device, type, start_slot + i, + wined3d_device_context_set_constant_buffer(context->wined3d_context, type, start_slot + i, buffer ? buffer->wined3d_buffer : NULL); } wined3d_mutex_unlock(); @@ -2613,7 +2613,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_ClearState(ID3D11DeviceCon { wined3d_device_context_set_shader(context->wined3d_context, i, NULL); for (j = 0; j < D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++j) - wined3d_device_set_constant_buffer(device->wined3d_device, i, j, NULL); + wined3d_device_context_set_constant_buffer(context->wined3d_context, i, j, NULL); } for (i = 0; i < D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; ++i) {
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=86548
Your paranoid android.
=== debiant2 (32 bit WoW report) ===
d3d11: d3d11.c:5834: Test failed: d3d11.c:5540: Test marked todo: Got unexpected hr 0x8876086a for query type 15.