Signed-off-by: Henri Verbeet hverbeet@codeweavers.com --- dlls/wined3d/adapter_gl.c | 45 ++++++++++++++++++++++++++ dlls/wined3d/adapter_vk.c | 28 +++++++++++++++++ dlls/wined3d/directx.c | 16 ++++++++++ dlls/wined3d/sampler.c | 71 ++++++++++++++++++++---------------------- dlls/wined3d/wined3d_private.h | 11 +++++++ 5 files changed, 133 insertions(+), 38 deletions(-)
diff --git a/dlls/wined3d/adapter_gl.c b/dlls/wined3d/adapter_gl.c index 0b7fcf47297..c031242b0ea 100644 --- a/dlls/wined3d/adapter_gl.c +++ b/dlls/wined3d/adapter_gl.c @@ -5024,6 +5024,49 @@ static void adapter_gl_destroy_unordered_access_view(struct wined3d_unordered_ac wined3d_device_decref(device); }
+static HRESULT adapter_gl_create_sampler(struct wined3d_device *device, const struct wined3d_sampler_desc *desc, + void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_sampler **sampler) +{ + struct wined3d_sampler *sampler_gl; + + TRACE("device %p, desc %p, parent %p, parent_ops %p, sampler %p.\n", + device, desc, parent, parent_ops, sampler); + + if (!(sampler_gl = heap_alloc_zero(sizeof(*sampler_gl)))) + return E_OUTOFMEMORY; + + wined3d_sampler_gl_init(sampler_gl, device, desc, parent, parent_ops); + + TRACE("Created sampler %p.\n", sampler_gl); + *sampler = sampler_gl; + + return WINED3D_OK; +} + +static void wined3d_sampler_gl_destroy_object(void *object) +{ + struct wined3d_sampler *sampler_gl = object; + const struct wined3d_gl_info *gl_info; + struct wined3d_context *context; + + if (sampler_gl->name) + { + context = context_acquire(sampler_gl->device, NULL, 0); + gl_info = wined3d_context_gl(context)->gl_info; + GL_EXTCALL(glDeleteSamplers(1, &sampler_gl->name)); + context_release(context); + } + + heap_free(sampler_gl); +} + +static void adapter_gl_destroy_sampler(struct wined3d_sampler *sampler) +{ + TRACE("sampler %p.\n", sampler); + + wined3d_cs_destroy_object(sampler->device->cs, wined3d_sampler_gl_destroy_object, sampler); +} + static const struct wined3d_adapter_ops wined3d_adapter_gl_ops = { adapter_gl_destroy, @@ -5047,6 +5090,8 @@ static const struct wined3d_adapter_ops wined3d_adapter_gl_ops = adapter_gl_destroy_shader_resource_view, adapter_gl_create_unordered_access_view, adapter_gl_destroy_unordered_access_view, + adapter_gl_create_sampler, + adapter_gl_destroy_sampler, };
static BOOL wined3d_adapter_gl_init(struct wined3d_adapter_gl *adapter_gl, diff --git a/dlls/wined3d/adapter_vk.c b/dlls/wined3d/adapter_vk.c index f203e0f52e1..afe222a031e 100644 --- a/dlls/wined3d/adapter_vk.c +++ b/dlls/wined3d/adapter_vk.c @@ -733,6 +733,32 @@ static void adapter_vk_destroy_unordered_access_view(struct wined3d_unordered_ac wined3d_device_decref(device); }
+static HRESULT adapter_vk_create_sampler(struct wined3d_device *device, const struct wined3d_sampler_desc *desc, + void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_sampler **sampler) +{ + struct wined3d_sampler *sampler_vk; + + TRACE("device %p, desc %p, parent %p, parent_ops %p, sampler %p.\n", + device, desc, parent, parent_ops, sampler); + + if (!(sampler_vk = heap_alloc_zero(sizeof(*sampler_vk)))) + return E_OUTOFMEMORY; + + wined3d_sampler_vk_init(sampler_vk, device, desc, parent, parent_ops); + + TRACE("Created sampler %p.\n", sampler_vk); + *sampler = sampler_vk; + + return WINED3D_OK; +} + +static void adapter_vk_destroy_sampler(struct wined3d_sampler *sampler) +{ + TRACE("sampler %p.\n", sampler); + + wined3d_cs_destroy_object(sampler->device->cs, heap_free, sampler); +} + static const struct wined3d_adapter_ops wined3d_adapter_vk_ops = { adapter_vk_destroy, @@ -756,6 +782,8 @@ static const struct wined3d_adapter_ops wined3d_adapter_vk_ops = adapter_vk_destroy_shader_resource_view, adapter_vk_create_unordered_access_view, adapter_vk_destroy_unordered_access_view, + adapter_vk_create_sampler, + adapter_vk_destroy_sampler, };
static unsigned int wined3d_get_wine_vk_version(void) diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 3c18e0e402e..4c9773a0b26 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -2554,6 +2554,20 @@ static void adapter_no3d_destroy_unordered_access_view(struct wined3d_unordered_ TRACE("view %p.\n", view); }
+static HRESULT adapter_no3d_create_sampler(struct wined3d_device *device, const struct wined3d_sampler_desc *desc, + void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_sampler **sampler) +{ + TRACE("device %p, desc %p, parent %p, parent_ops %p, sampler %p.\n", + device, desc, parent, parent_ops, sampler); + + return E_NOTIMPL; +} + +static void adapter_no3d_destroy_sampler(struct wined3d_sampler *sampler) +{ + TRACE("sampler %p.\n", sampler); +} + static const struct wined3d_adapter_ops wined3d_adapter_no3d_ops = { adapter_no3d_destroy, @@ -2577,6 +2591,8 @@ static const struct wined3d_adapter_ops wined3d_adapter_no3d_ops = adapter_no3d_destroy_shader_resource_view, adapter_no3d_create_unordered_access_view, adapter_no3d_destroy_unordered_access_view, + adapter_no3d_create_sampler, + adapter_no3d_destroy_sampler, };
static void wined3d_adapter_no3d_init_d3d_info(struct wined3d_adapter *adapter, unsigned int wined3d_creation_flags) diff --git a/dlls/wined3d/sampler.c b/dlls/wined3d/sampler.c index 9b729353538..5a9170b6d4d 100644 --- a/dlls/wined3d/sampler.c +++ b/dlls/wined3d/sampler.c @@ -33,23 +33,6 @@ ULONG CDECL wined3d_sampler_incref(struct wined3d_sampler *sampler) return refcount; }
-static void wined3d_sampler_destroy_object(void *object) -{ - struct wined3d_sampler *sampler = object; - const struct wined3d_gl_info *gl_info; - struct wined3d_context *context; - - if (sampler->name) - { - context = context_acquire(sampler->device, NULL, 0); - gl_info = wined3d_context_gl(context)->gl_info; - GL_EXTCALL(glDeleteSamplers(1, &sampler->name)); - context_release(context); - } - - heap_free(sampler); -} - ULONG CDECL wined3d_sampler_decref(struct wined3d_sampler *sampler) { ULONG refcount = InterlockedDecrement(&sampler->refcount); @@ -59,7 +42,7 @@ ULONG CDECL wined3d_sampler_decref(struct wined3d_sampler *sampler) if (!refcount) { sampler->parent_ops->wined3d_object_destroyed(sampler->parent); - wined3d_cs_destroy_object(sampler->device->cs, wined3d_sampler_destroy_object, sampler); + sampler->device->adapter->adapter_ops->adapter_destroy_sampler(sampler); }
return refcount; @@ -72,7 +55,20 @@ void * CDECL wined3d_sampler_get_parent(const struct wined3d_sampler *sampler) return sampler->parent; }
-static void wined3d_sampler_cs_init(void *object) +static void wined3d_sampler_init(struct wined3d_sampler *sampler, struct wined3d_device *device, + const struct wined3d_sampler_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops) +{ + TRACE("sampler %p, device %p, desc %p, parent %p, parent_ops %p.\n", + sampler, device, desc, parent, parent_ops); + + sampler->refcount = 1; + sampler->device = device; + sampler->parent = parent; + sampler->parent_ops = parent_ops; + sampler->desc = *desc; +} + +static void wined3d_sampler_gl_cs_init(void *object) { struct wined3d_sampler *sampler = object; const struct wined3d_sampler_desc *desc; @@ -114,25 +110,32 @@ static void wined3d_sampler_cs_init(void *object) context_release(context); }
-static void wined3d_sampler_init(struct wined3d_sampler *sampler, struct wined3d_device *device, +void wined3d_sampler_gl_init(struct wined3d_sampler *sampler_gl, struct wined3d_device *device, const struct wined3d_sampler_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops) { - sampler->refcount = 1; - sampler->device = device; - sampler->parent = parent; - sampler->parent_ops = parent_ops; - sampler->desc = *desc; + TRACE("sampler_gl %p, device %p, desc %p, parent %p, parent_ops %p.\n", + sampler_gl, device, desc, parent, parent_ops); + + wined3d_sampler_init(sampler_gl, device, desc, parent, parent_ops);
if (device->adapter->gl_info.supported[ARB_SAMPLER_OBJECTS]) - wined3d_cs_init_object(device->cs, wined3d_sampler_cs_init, sampler); + wined3d_cs_init_object(device->cs, wined3d_sampler_gl_cs_init, sampler_gl); +} + +void wined3d_sampler_vk_init(struct wined3d_sampler *sampler_vk, struct wined3d_device *device, + const struct wined3d_sampler_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops) +{ + TRACE("sampler_vk %p, device %p, desc %p, parent %p, parent_ops %p.\n", + sampler_vk, device, desc, parent, parent_ops); + + wined3d_sampler_init(sampler_vk, device, desc, parent, parent_ops); }
HRESULT CDECL wined3d_sampler_create(struct wined3d_device *device, const struct wined3d_sampler_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_sampler **sampler) { - struct wined3d_sampler *object; - - TRACE("device %p, desc %p, parent %p, sampler %p.\n", device, desc, parent, sampler); + TRACE("device %p, desc %p, parent %p, parent_ops %p, sampler %p.\n", + device, desc, parent, parent_ops, sampler);
if (desc->address_u < WINED3D_TADDRESS_WRAP || desc->address_u > WINED3D_TADDRESS_MIRROR_ONCE || desc->address_v < WINED3D_TADDRESS_WRAP || desc->address_v > WINED3D_TADDRESS_MIRROR_ONCE @@ -144,15 +147,7 @@ HRESULT CDECL wined3d_sampler_create(struct wined3d_device *device, const struct || desc->mip_filter > WINED3D_TEXF_LINEAR) return WINED3DERR_INVALIDCALL;
- if (!(object = heap_alloc_zero(sizeof(*object)))) - return E_OUTOFMEMORY; - - wined3d_sampler_init(object, device, desc, parent, parent_ops); - - TRACE("Created sampler %p.\n", object); - *sampler = object; - - return WINED3D_OK; + return device->adapter->adapter_ops->adapter_create_sampler(device, desc, parent, parent_ops, sampler); }
static void texture_gl_apply_base_level(struct wined3d_texture_gl *texture_gl, diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 80ed41bb845..ca2d417c4e0 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2805,6 +2805,9 @@ struct wined3d_adapter_ops struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_unordered_access_view **view); void (*adapter_destroy_unordered_access_view)(struct wined3d_unordered_access_view *view); + HRESULT (*adapter_create_sampler)(struct wined3d_device *device, const struct wined3d_sampler_desc *desc, + void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_sampler **sampler); + void (*adapter_destroy_sampler)(struct wined3d_sampler *sampler); };
/* The adapter structure */ @@ -3800,6 +3803,14 @@ struct wined3d_sampler void wined3d_sampler_bind(struct wined3d_sampler *sampler, unsigned int unit, struct wined3d_texture_gl *texture_gl, const struct wined3d_context_gl *context_gl) DECLSPEC_HIDDEN;
+void wined3d_sampler_gl_init(struct wined3d_sampler *sampler_gl, + struct wined3d_device *device, const struct wined3d_sampler_desc *desc, + void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN; + +void wined3d_sampler_vk_init(struct wined3d_sampler *sampler_vk, + struct wined3d_device *device, const struct wined3d_sampler_desc *desc, + void *parent, const struct wined3d_parent_ops *parent_ops) DECLSPEC_HIDDEN; + struct wined3d_vertex_declaration_element { const struct wined3d_format *format;
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=55489
Your paranoid android.
=== debian10 (32 bit report) ===
ddraw: ddraw1: Timeout ddraw2.c:9763: Test failed: Test 0 shading has color1 000000ff, expected 0000ff00. ddraw2: Timeout ddraw4: Timeout ddraw7: Timeout ddrawmodes: Timeout
=== debian10 (build log) ===
Task errors: The task timed out
=== debian10 (32 bit WoW report) ===
ddraw: ddraw1: Timeout ddraw2: Timeout ddraw4: Timeout ddraw7.c:11549: Test failed: Test 0 shading has color1 000000ff, expected 0000ff00. ddraw7.c:14486: Test failed: Expected unsynchronised map for flags 0x1000. ddraw7.c:14486: Test failed: Expected unsynchronised map for flags 0x3000. ddraw7: Timeout ddrawmodes: Timeout dsurface: Timeout
=== debian10 (build log) ===
Task errors: The task timed out