Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
June 2021
- 82 participants
- 1899 messages
Re: [PATCH v3 5/6] wined3d: Implement NOOVERWRITE maps in wined3d_deferred_context_prepare_upload_bo().
by Marvin
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=93395
Your paranoid android.
=== w2008s64 (32 bit report) ===
d3d11:
d3d11.c:6246: Test failed: Got unexpected NumPrimitivesWritten: 4293910286.
d3d11.c:6249: Test failed: Got unexpected PrimitivesStorageNeeded: 4294967295.
=== w1064v1809 (32 bit report) ===
d3d11:
d3d11.c:5916: Test failed: Got unexpected IAVertices count: 0.
d3d11.c:5917: Test failed: Got unexpected IAPrimitives count: 0.
d3d11.c:5918: Test failed: Got unexpected VSInvocations count: 0.
d3d11.c:5921: Test failed: Got unexpected CInvocations count: 0.
d3d11.c:5922: Test failed: Got unexpected CPrimitives count: 0.
=== w10pro64 (32 bit report) ===
d3d11:
d3d11.c:5916: Test failed: Got unexpected IAVertices count: 0.
d3d11.c:5917: Test failed: Got unexpected IAPrimitives count: 0.
d3d11.c:5918: Test failed: Got unexpected VSInvocations count: 0.
d3d11.c:5921: Test failed: Got unexpected CInvocations count: 0.
d3d11.c:5922: Test failed: Got unexpected CPrimitives count: 0.
d3d11.c:5763: Test failed: Got unexpected query result 0x0000000000000000.
=== debiant2 (32 bit Hebrew:Israel report) ===
d3d11:
d3d11.c:9766: Test failed: d3d11.c:15127: Test marked todo: Got hr 0 for WRITE.
=== debiant2 (32 bit Chinese:China report) ===
d3d11:
d3d11.c:5922: Test failed: Test marked todo: Got unexpected hr 0x8876086a for query type 11.
d3d11.c:9766: Test failed: d3d11.c:15127: Test marked todo: Got hr 0 for WRITE.
=== debiant2 (32 bit WoW report) ===
d3d11:
d3d11.c:16624: Test failed: d3d11.c:16409: Test marked todo: Got 0xdeadbeef, expected 0xfefefefe or 0x80808080 at 128, uvec4 0xfefefefe, 0xfefefefe, 0xfefefefe, 0xfefefefe.
June 30, 2021
Re: [PATCH v3 4/6] wined3d: Use context->ops->prepare_upload_bo() in wined3d_device_context_map() if possible.
by Marvin
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=93394
Your paranoid android.
=== w1064v1809 (32 bit report) ===
d3d11:
d3d11.c:5916: Test failed: Got unexpected IAVertices count: 0.
d3d11.c:5917: Test failed: Got unexpected IAPrimitives count: 0.
d3d11.c:5918: Test failed: Got unexpected VSInvocations count: 0.
d3d11.c:5921: Test failed: Got unexpected CInvocations count: 0.
d3d11.c:5922: Test failed: Got unexpected CPrimitives count: 0.
=== w1064 (32 bit report) ===
d3d11:
d3d11.c:5916: Test failed: Got unexpected IAVertices count: 0.
d3d11.c:5917: Test failed: Got unexpected IAPrimitives count: 0.
d3d11.c:5918: Test failed: Got unexpected VSInvocations count: 0.
d3d11.c:5921: Test failed: Got unexpected CInvocations count: 0.
d3d11.c:5922: Test failed: Got unexpected CPrimitives count: 0.
=== w1064v1507 (64 bit report) ===
d3d11:
0eac:d3d11: unhandled exception c0000005 at 00007FF5FFEB51A2
=== debiant2 (32 bit Hebrew:Israel report) ===
d3d11:
d3d11.c:9766: Test failed: d3d11.c:15127: Test marked todo: Test 60: Got unexpected color 0xff000000 at (3, 2).
d3d11.c:9766: Test failed: Got hr 0 for WRITE.
=== debiant2 (32 bit Chinese:China report) ===
d3d11:
d3d11.c:9766: Test failed: d3d11.c:15127: Test marked todo: Test 60: Got unexpected color 0xff00ffff at (1, 0).
d3d11.c:9766: Test failed: Got hr 0 for WRITE.
=== debiant2 (32 bit WoW report) ===
d3d11:
d3d11.c:9766: Test failed: d3d11.c:15149: Test marked todo: Got hr 0 for WRITE_DISCARD.
June 30, 2021
Re: [PATCH v3 3/6] d3d11: Forbid map types other than DISCARD and NOOVERWRITE on a deferred context.
by Marvin
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=93393
Your paranoid android.
=== w1064 (32 bit report) ===
d3d11:
d3d11.c:5916: Test failed: Got unexpected IAVertices count: 0.
d3d11.c:5917: Test failed: Got unexpected IAPrimitives count: 0.
d3d11.c:5918: Test failed: Got unexpected VSInvocations count: 0.
d3d11.c:5921: Test failed: Got unexpected CInvocations count: 0.
d3d11.c:5922: Test failed: Got unexpected CPrimitives count: 0.
=== debiant2 (32 bit German report) ===
d3d11:
d3d11.c:9766: Test failed: d3d11.c:15149: Test marked todo: Got hr 0 for WRITE_DISCARD.
=== debiant2 (32 bit Hindi:India report) ===
d3d11:
d3d11.c:9766: Test failed: d3d11.c:15127: Test marked todo: Got hr 0 for WRITE_DISCARD.
=== debiant2 (32 bit Japanese:Japan report) ===
d3d11:
d3d11.c:9766: Test failed: d3d11.c:15127: Test marked todo: Got hr 0 for WRITE_DISCARD.
June 30, 2021
[PATCH v3 6/6] wined3d: No longer queue WINED3D_CS_QUEUE_MAP operations through wined3d_device_context_ops.
by Zebediah Figura
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
v3: New patch.
dlls/wined3d/cs.c | 83 ++++++----------------------------
dlls/wined3d/device.c | 4 +-
dlls/wined3d/wined3d_private.h | 11 +----
3 files changed, 18 insertions(+), 80 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index d099d3bc9da..00cf2f2f1d7 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -2455,6 +2455,8 @@ HRESULT wined3d_device_context_emit_map(struct wined3d_device_context *context,
{
struct wined3d_const_bo_address addr;
unsigned int row_pitch, slice_pitch;
+ struct wined3d_cs_map *op;
+ HRESULT hr;
wined3d_resource_get_sub_resource_map_pitch(resource, sub_resource_idx, &row_pitch, &slice_pitch);
@@ -2466,23 +2468,14 @@ HRESULT wined3d_device_context_emit_map(struct wined3d_device_context *context,
return WINED3D_OK;
}
- return context->ops->map(context, resource, sub_resource_idx, map_ptr, box, flags);
-}
-
-static HRESULT wined3d_cs_map(struct wined3d_device_context *context, struct wined3d_resource *resource,
- unsigned int sub_resource_idx, void **map_ptr, const struct wined3d_box *box, unsigned int flags)
-{
- struct wined3d_cs *cs = wined3d_cs_from_context(context);
- struct wined3d_cs_map *op;
- HRESULT hr;
-
/* Mapping resources from the worker thread isn't an issue by itself, but
* increasing the map count would be visible to applications. */
- wined3d_not_from_cs(cs);
+ wined3d_not_from_cs(context->device);
wined3d_resource_wait_idle(resource);
- op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_MAP);
+ if (!(op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_MAP)))
+ return E_OUTOFMEMORY;
op->opcode = WINED3D_CS_OP_MAP;
op->resource = resource;
op->sub_resource_idx = sub_resource_idx;
@@ -2492,7 +2485,7 @@ static HRESULT wined3d_cs_map(struct wined3d_device_context *context, struct win
op->hr = &hr;
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_MAP);
- wined3d_cs_finish(cs, WINED3D_CS_QUEUE_MAP);
+ wined3d_device_context_finish(context, WINED3D_CS_QUEUE_MAP);
return hr;
}
@@ -2509,7 +2502,9 @@ HRESULT wined3d_device_context_emit_unmap(struct wined3d_device_context *context
struct wined3d_resource *resource, unsigned int sub_resource_idx)
{
struct wined3d_const_bo_address addr;
+ struct wined3d_cs_unmap *op;
struct wined3d_box box;
+ HRESULT hr;
if (context->ops->get_upload_bo(context, resource, sub_resource_idx, &box, &addr))
{
@@ -2520,17 +2515,7 @@ HRESULT wined3d_device_context_emit_unmap(struct wined3d_device_context *context
return WINED3D_OK;
}
- return context->ops->unmap(context, resource, sub_resource_idx);
-}
-
-static HRESULT wined3d_cs_unmap(struct wined3d_device_context *context, struct wined3d_resource *resource,
- unsigned int sub_resource_idx)
-{
- struct wined3d_cs *cs = wined3d_cs_from_context(context);
- struct wined3d_cs_unmap *op;
- HRESULT hr;
-
- wined3d_not_from_cs(cs);
+ wined3d_not_from_cs(context->device);
op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_MAP);
op->opcode = WINED3D_CS_OP_UNMAP;
@@ -2539,7 +2524,7 @@ static HRESULT wined3d_cs_unmap(struct wined3d_device_context *context, struct w
op->hr = &hr;
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_MAP);
- wined3d_cs_finish(cs, WINED3D_CS_QUEUE_MAP);
+ wined3d_device_context_finish(context, WINED3D_CS_QUEUE_MAP);
return hr;
}
@@ -2728,6 +2713,7 @@ void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_conte
struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box,
const void *data, unsigned int row_pitch, unsigned int slice_pitch)
{
+ struct wined3d_cs_update_sub_resource *op;
struct wined3d_const_bo_address src_addr;
void *map_ptr;
@@ -2737,18 +2723,8 @@ void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_conte
wined3d_format_copy_data(resource->format, data, row_pitch, slice_pitch, map_ptr, row_pitch, slice_pitch,
box->right - box->left, box->bottom - box->top, box->back - box->front);
wined3d_device_context_upload_bo(context, resource, sub_resource_idx, box, &src_addr, row_pitch, slice_pitch);
+ return;
}
- else
- {
- context->ops->update_sub_resource(context, resource, sub_resource_idx, box, data, row_pitch, slice_pitch);
- }
-}
-
-static void wined3d_cs_update_sub_resource(struct wined3d_device_context *context,
- struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box,
- const void *data, unsigned int row_pitch, unsigned int slice_pitch)
-{
- struct wined3d_cs_update_sub_resource *op;
wined3d_resource_wait_idle(resource);
@@ -3063,9 +3039,6 @@ static const struct wined3d_device_context_ops wined3d_cs_st_ops =
wined3d_cs_st_push_constants,
wined3d_cs_prepare_upload_bo,
wined3d_cs_get_upload_bo,
- wined3d_cs_map,
- wined3d_cs_unmap,
- wined3d_cs_update_sub_resource,
wined3d_cs_issue_query,
wined3d_cs_flush,
wined3d_cs_acquire_resource,
@@ -3193,9 +3166,6 @@ static const struct wined3d_device_context_ops wined3d_cs_mt_ops =
wined3d_cs_mt_push_constants,
wined3d_cs_prepare_upload_bo,
wined3d_cs_get_upload_bo,
- wined3d_cs_map,
- wined3d_cs_unmap,
- wined3d_cs_update_sub_resource,
wined3d_cs_issue_query,
wined3d_cs_flush,
wined3d_cs_acquire_resource,
@@ -3434,7 +3404,8 @@ static void *wined3d_deferred_context_require_space(struct wined3d_device_contex
struct wined3d_cs_packet *packet;
size_t header_size, packet_size;
- assert(queue_id == WINED3D_CS_QUEUE_DEFAULT);
+ if (queue_id != WINED3D_CS_QUEUE_DEFAULT)
+ return NULL;
header_size = offsetof(struct wined3d_cs_packet, data[0]);
packet_size = offsetof(struct wined3d_cs_packet, data[size]);
@@ -3564,29 +3535,6 @@ static bool wined3d_deferred_context_get_upload_bo(struct wined3d_device_context
return false;
}
-static HRESULT wined3d_deferred_context_map(struct wined3d_device_context *context, struct wined3d_resource *resource,
- unsigned int sub_resource_idx, void **map_ptr, const struct wined3d_box *box, unsigned int flags)
-{
- FIXME("context %p, resource %p, sub_resource_idx %u, map_ptr %p, box %p, flags %#x, stub!\n",
- context, resource, sub_resource_idx, map_ptr, box, flags);
- return E_NOTIMPL;
-}
-
-static HRESULT wined3d_deferred_context_unmap(struct wined3d_device_context *context,
- struct wined3d_resource *resource, unsigned int sub_resource_idx)
-{
- FIXME("context %p, resource %p, sub_resource_idx %u, stub!\n", context, resource, sub_resource_idx);
- return E_NOTIMPL;
-}
-
-static void wined3d_deferred_context_update_sub_resource(struct wined3d_device_context *context,
- struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box,
- const void *data, unsigned int row_pitch, unsigned int slice_pitch)
-{
- FIXME("context %p, resource %p, sub_resource_idx %u, box %s, data %p, row_pitch %u, slice_pitch %u, stub!\n",
- context, resource, sub_resource_idx, debug_box(box), data, row_pitch, slice_pitch);
-}
-
static void wined3d_deferred_context_issue_query(struct wined3d_device_context *context,
struct wined3d_query *query, unsigned int flags)
{
@@ -3643,9 +3591,6 @@ static const struct wined3d_device_context_ops wined3d_deferred_context_ops =
wined3d_deferred_context_push_constants,
wined3d_deferred_context_prepare_upload_bo,
wined3d_deferred_context_get_upload_bo,
- wined3d_deferred_context_map,
- wined3d_deferred_context_unmap,
- wined3d_deferred_context_update_sub_resource,
wined3d_deferred_context_issue_query,
wined3d_deferred_context_flush,
wined3d_deferred_context_acquire_resource,
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 508c9459ba8..131c53a4099 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -5534,7 +5534,7 @@ void device_resource_add(struct wined3d_device *device, struct wined3d_resource
{
TRACE("device %p, resource %p.\n", device, resource);
- wined3d_not_from_cs(device->cs);
+ wined3d_not_from_cs(device);
list_add_head(&device->resources, &resource->resource_list_entry);
}
@@ -5543,7 +5543,7 @@ static void device_resource_remove(struct wined3d_device *device, struct wined3d
{
TRACE("device %p, resource %p.\n", device, resource);
- wined3d_not_from_cs(device->cs);
+ wined3d_not_from_cs(device);
list_remove(&resource->resource_list_entry);
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 596f940aa79..80e03ad9212 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -4714,13 +4714,6 @@ struct wined3d_device_context_ops
unsigned int slice_pitch, uint32_t flags, struct wined3d_const_bo_address *address);
bool (*get_upload_bo)(struct wined3d_device_context *context, struct wined3d_resource *resource,
unsigned int sub_resource_idx, struct wined3d_box *box, struct wined3d_const_bo_address *address);
- HRESULT (*map)(struct wined3d_device_context *context, struct wined3d_resource *resource,
- unsigned int sub_resource_idx, void **map_ptr, const struct wined3d_box *box, unsigned int flags);
- HRESULT (*unmap)(struct wined3d_device_context *context, struct wined3d_resource *resource,
- unsigned int sub_resource_idx);
- void (*update_sub_resource)(struct wined3d_device_context *context, struct wined3d_resource *resource,
- unsigned int sub_resource_idx, const struct wined3d_box *box,
- const void *data, unsigned int row_pitch, unsigned int slice_pitch);
void (*issue_query)(struct wined3d_device_context *context, struct wined3d_query *query, unsigned int flags);
void (*flush)(struct wined3d_device_context *context);
void (*acquire_resource)(struct wined3d_device_context *context, struct wined3d_resource *resource);
@@ -6047,9 +6040,9 @@ static inline void wined3d_from_cs(const struct wined3d_cs *cs)
assert(cs->thread_id == GetCurrentThreadId());
}
-static inline void wined3d_not_from_cs(struct wined3d_cs *cs)
+static inline void wined3d_not_from_cs(const struct wined3d_device *device)
{
- assert(cs->thread_id != GetCurrentThreadId());
+ assert(device->cs->thread_id != GetCurrentThreadId());
}
static inline enum wined3d_material_color_source validate_material_colour_source(WORD use_map,
--
2.30.2
June 30, 2021
[PATCH v3 5/6] wined3d: Implement NOOVERWRITE maps in wined3d_deferred_context_prepare_upload_bo().
by Zebediah Figura
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
v3: Make use of deferred_context_get_upload().
dlls/d3d11/tests/d3d11.c | 42 +++++++++++++++++-----------------------
dlls/wined3d/cs.c | 17 +++++++++++++++-
2 files changed, 34 insertions(+), 25 deletions(-)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index df1d5a35c6e..fcbe4f4a740 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -33134,38 +33134,32 @@ static void test_deferred_context_map(void)
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
hr = ID3D11DeviceContext_Map(deferred, (ID3D11Resource *)buffer, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &map_desc);
- todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
- if (hr == S_OK)
+ map_data = map_desc.pData;
+ for (i = 0; i < ARRAY_SIZE(data); ++i)
{
- map_data = map_desc.pData;
- for (i = 0; i < ARRAY_SIZE(data); ++i)
- {
- ok(map_data[i] == 2 * i, "Got unexpected value %.8e at %u.\n", map_data[i], i);
- if (i % 2)
- map_data[i] = 3 * i;
- }
- memcpy(data, map_data, sizeof(data));
-
- ID3D11DeviceContext_Unmap(deferred, (ID3D11Resource *)buffer, 0);
+ ok(map_data[i] == 2 * i, "Got unexpected value %.8e at %u.\n", map_data[i], i);
+ if (i % 2)
+ map_data[i] = 3 * i;
}
+ memcpy(data, map_data, sizeof(data));
+
+ ID3D11DeviceContext_Unmap(deferred, (ID3D11Resource *)buffer, 0);
hr = ID3D11DeviceContext_Map(deferred, (ID3D11Resource *)buffer, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &map_desc);
- todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
- if (hr == S_OK)
+ map_data = map_desc.pData;
+ for (i = 0; i < ARRAY_SIZE(data); ++i)
{
- map_data = map_desc.pData;
- for (i = 0; i < ARRAY_SIZE(data); ++i)
- {
- ok(map_data[i] == data[i], "Got unexpected value %.8e at %u.\n", map_data[i], i);
- if (i % 3)
- map_data[i] = 4 * i;
- }
- memcpy(data, map_data, sizeof(data));
-
- ID3D11DeviceContext_Unmap(deferred, (ID3D11Resource *)buffer, 0);
+ ok(map_data[i] == data[i], "Got unexpected value %.8e at %u.\n", map_data[i], i);
+ if (i % 3)
+ map_data[i] = 4 * i;
}
+ memcpy(data, map_data, sizeof(data));
+
+ ID3D11DeviceContext_Unmap(deferred, (ID3D11Resource *)buffer, 0);
hr = ID3D11DeviceContext_FinishCommandList(deferred, FALSE, &list);
ok(hr == S_OK, "Failed to create command list, hr %#x.\n", hr);
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 36b398741b3..d099d3bc9da 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -3505,12 +3505,27 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co
return NULL;
}
- if (flags & ~(WINED3D_MAP_WRITE | WINED3D_MAP_DISCARD))
+ if (flags & ~(WINED3D_MAP_WRITE | WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))
{
FIXME("Unhandled flags %#x.\n", flags);
return NULL;
}
+ if (flags & WINED3D_MAP_NOOVERWRITE)
+ {
+ const struct wined3d_deferred_upload *upload;
+
+ if ((upload = deferred_context_get_upload(deferred, resource, sub_resource_idx)))
+ {
+ map_ptr = (uint8_t *)align((size_t)upload->sysmem, RESOURCE_ALIGNMENT);
+ address->buffer_object = 0;
+ address->addr = map_ptr;
+ return map_ptr;
+ }
+
+ return NULL;
+ }
+
if (!wined3d_array_reserve((void **)&deferred->uploads, &deferred->uploads_capacity,
deferred->upload_count + 1, sizeof(*deferred->uploads)))
return NULL;
--
2.30.2
June 30, 2021
[PATCH v3 4/6] wined3d: Use context->ops->prepare_upload_bo() in wined3d_device_context_map() if possible.
by Zebediah Figura
This has the notable effect of implementing maps on deferred contexts.
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
v3: Separate wined3d_device_context_emit_(un)map() as well as
deferred_context_get_upload().
dlls/d3d11/tests/d3d11.c | 55 ++++++++-------
dlls/wined3d/cs.c | 121 +++++++++++++++++++++++++++++----
dlls/wined3d/device.c | 5 +-
dlls/wined3d/wined3d_private.h | 7 ++
4 files changed, 143 insertions(+), 45 deletions(-)
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index cf51e79b084..df1d5a35c6e 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -33065,15 +33065,7 @@ static void test_deferred_context_map(void)
todo_wine ok(hr == D3D11_ERROR_DEFERRED_CONTEXT_MAP_WITHOUT_INITIAL_DISCARD, "Got unexpected hr %#x.\n", hr);
hr = ID3D11DeviceContext_Map(deferred, (ID3D11Resource *)buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map_desc);
- todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
- if (hr != S_OK)
- {
- ID3D11Buffer_Release(buffer2);
- ID3D11Buffer_Release(buffer);
- ID3D11DeviceContext_Release(deferred);
- release_test_context(&test_context);
- return;
- }
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
map_data = map_desc.pData;
/* The previous contents of map_data are undefined and may in practice be
* uninitialized garbage. */
@@ -33122,13 +33114,14 @@ static void test_deferred_context_map(void)
ID3D11DeviceContext_Unmap(immediate, (ID3D11Resource *)buffer, 0);
hr = ID3D11DeviceContext_Map(deferred, (ID3D11Resource *)buffer, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &map_desc);
- ok(hr == D3D11_ERROR_DEFERRED_CONTEXT_MAP_WITHOUT_INITIAL_DISCARD, "Got unexpected hr %#x.\n", hr);
+ todo_wine ok(hr == D3D11_ERROR_DEFERRED_CONTEXT_MAP_WITHOUT_INITIAL_DISCARD, "Got unexpected hr %#x.\n", hr);
hr = ID3D11DeviceContext_Map(deferred, (ID3D11Resource *)buffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &map_desc);
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
map_data = map_desc.pData;
for (i = 0; i < ARRAY_SIZE(data); ++i)
map_data[i] = 2 * i;
+ memcpy(data, map_data, sizeof(data));
ID3D11DeviceContext_Unmap(deferred, (ID3D11Resource *)buffer, 0);
hr = ID3D11DeviceContext_Map(deferred, (ID3D11Resource *)buffer, 0, D3D11_MAP_READ, 0, &map_desc);
@@ -33141,32 +33134,38 @@ static void test_deferred_context_map(void)
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
hr = ID3D11DeviceContext_Map(deferred, (ID3D11Resource *)buffer, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &map_desc);
- ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
- map_data = map_desc.pData;
- for (i = 0; i < ARRAY_SIZE(data); ++i)
+ if (hr == S_OK)
{
- ok(map_data[i] == 2 * i, "Got unexpected value %.8e at %u.\n", map_data[i], i);
- if (i % 2)
- map_data[i] = 3 * i;
- }
- memcpy(data, map_data, sizeof(data));
+ map_data = map_desc.pData;
+ for (i = 0; i < ARRAY_SIZE(data); ++i)
+ {
+ ok(map_data[i] == 2 * i, "Got unexpected value %.8e at %u.\n", map_data[i], i);
+ if (i % 2)
+ map_data[i] = 3 * i;
+ }
+ memcpy(data, map_data, sizeof(data));
- ID3D11DeviceContext_Unmap(deferred, (ID3D11Resource *)buffer, 0);
+ ID3D11DeviceContext_Unmap(deferred, (ID3D11Resource *)buffer, 0);
+ }
hr = ID3D11DeviceContext_Map(deferred, (ID3D11Resource *)buffer, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &map_desc);
- ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ todo_wine ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
- map_data = map_desc.pData;
- for (i = 0; i < ARRAY_SIZE(data); ++i)
+ if (hr == S_OK)
{
- ok(map_data[i] == data[i], "Got unexpected value %.8e at %u.\n", map_data[i], i);
- if (i % 3)
- map_data[i] = 4 * i;
- }
- memcpy(data, map_data, sizeof(data));
+ map_data = map_desc.pData;
+ for (i = 0; i < ARRAY_SIZE(data); ++i)
+ {
+ ok(map_data[i] == data[i], "Got unexpected value %.8e at %u.\n", map_data[i], i);
+ if (i % 3)
+ map_data[i] = 4 * i;
+ }
+ memcpy(data, map_data, sizeof(data));
- ID3D11DeviceContext_Unmap(deferred, (ID3D11Resource *)buffer, 0);
+ ID3D11DeviceContext_Unmap(deferred, (ID3D11Resource *)buffer, 0);
+ }
hr = ID3D11DeviceContext_FinishCommandList(deferred, FALSE, &list);
ok(hr == S_OK, "Failed to create command list, hr %#x.\n", hr);
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index ed6bd6e0aaf..36b398741b3 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -31,6 +31,7 @@ struct wined3d_deferred_upload
struct wined3d_resource *resource;
unsigned int sub_resource_idx;
uint8_t *sysmem;
+ struct wined3d_box box;
};
struct wined3d_command_list
@@ -2417,6 +2418,29 @@ void wined3d_cs_emit_unload_resource(struct wined3d_cs *cs, struct wined3d_resou
wined3d_device_context_submit(&cs->c, WINED3D_CS_QUEUE_DEFAULT);
}
+static void wined3d_device_context_upload_bo(struct wined3d_device_context *context,
+ struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box,
+ const struct wined3d_const_bo_address *addr, unsigned int row_pitch, unsigned int slice_pitch)
+{
+ struct wined3d_cs_update_sub_resource *op;
+
+ TRACE("context %p, resource %p, sub_resource_idx %u, box %s, addr %s, row_pitch %u, slice_pitch %u.\n",
+ context, resource, sub_resource_idx, debug_box(box), debug_const_bo_address(addr), row_pitch, slice_pitch);
+
+ op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
+ op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE;
+ op->resource = resource;
+ op->sub_resource_idx = sub_resource_idx;
+ op->box = *box;
+ op->addr = *addr;
+ op->row_pitch = row_pitch;
+ op->slice_pitch = slice_pitch;
+
+ wined3d_device_context_acquire_resource(context, resource);
+
+ wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
+}
+
static void wined3d_cs_exec_map(struct wined3d_cs *cs, const void *data)
{
const struct wined3d_cs_map *op = data;
@@ -2426,6 +2450,25 @@ static void wined3d_cs_exec_map(struct wined3d_cs *cs, const void *data)
op->sub_resource_idx, op->map_ptr, op->box, op->flags);
}
+HRESULT wined3d_device_context_emit_map(struct wined3d_device_context *context, struct wined3d_resource *resource,
+ unsigned int sub_resource_idx, void **map_ptr, const struct wined3d_box *box, unsigned int flags)
+{
+ struct wined3d_const_bo_address addr;
+ unsigned int row_pitch, slice_pitch;
+
+ wined3d_resource_get_sub_resource_map_pitch(resource, sub_resource_idx, &row_pitch, &slice_pitch);
+
+ if ((*map_ptr = context->ops->prepare_upload_bo(context, resource,
+ sub_resource_idx, box, row_pitch, slice_pitch, flags, &addr)))
+ {
+ TRACE("Returning upload bo %s, map pointer %p, row pitch %u, slice pitch %u.\n",
+ debug_const_bo_address(&addr), *map_ptr, row_pitch, slice_pitch);
+ return WINED3D_OK;
+ }
+
+ return context->ops->map(context, resource, sub_resource_idx, map_ptr, box, flags);
+}
+
static HRESULT wined3d_cs_map(struct wined3d_device_context *context, struct wined3d_resource *resource,
unsigned int sub_resource_idx, void **map_ptr, const struct wined3d_box *box, unsigned int flags)
{
@@ -2462,6 +2505,24 @@ static void wined3d_cs_exec_unmap(struct wined3d_cs *cs, const void *data)
*op->hr = resource->resource_ops->resource_sub_resource_unmap(resource, op->sub_resource_idx);
}
+HRESULT wined3d_device_context_emit_unmap(struct wined3d_device_context *context,
+ struct wined3d_resource *resource, unsigned int sub_resource_idx)
+{
+ struct wined3d_const_bo_address addr;
+ struct wined3d_box box;
+
+ if (context->ops->get_upload_bo(context, resource, sub_resource_idx, &box, &addr))
+ {
+ unsigned int row_pitch, slice_pitch;
+
+ wined3d_resource_get_sub_resource_map_pitch(resource, sub_resource_idx, &row_pitch, &slice_pitch);
+ wined3d_device_context_upload_bo(context, resource, sub_resource_idx, &box, &addr, row_pitch, slice_pitch);
+ return WINED3D_OK;
+ }
+
+ return context->ops->unmap(context, resource, sub_resource_idx);
+}
+
static HRESULT wined3d_cs_unmap(struct wined3d_device_context *context, struct wined3d_resource *resource,
unsigned int sub_resource_idx)
{
@@ -2673,23 +2734,9 @@ void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_conte
if ((map_ptr = context->ops->prepare_upload_bo(context, resource, sub_resource_idx, box,
row_pitch, slice_pitch, WINED3D_MAP_WRITE, &src_addr)))
{
- struct wined3d_cs_update_sub_resource *op;
-
wined3d_format_copy_data(resource->format, data, row_pitch, slice_pitch, map_ptr, row_pitch, slice_pitch,
box->right - box->left, box->bottom - box->top, box->back - box->front);
-
- op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
- op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE;
- op->resource = resource;
- op->sub_resource_idx = sub_resource_idx;
- op->box = *box;
- op->addr = src_addr;
- op->row_pitch = row_pitch;
- op->slice_pitch = slice_pitch;
-
- wined3d_device_context_acquire_resource(context, resource);
-
- wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
+ wined3d_device_context_upload_bo(context, resource, sub_resource_idx, box, &src_addr, row_pitch, slice_pitch);
}
else
{
@@ -3002,6 +3049,12 @@ static void *wined3d_cs_prepare_upload_bo(struct wined3d_device_context *context
return NULL;
}
+static bool wined3d_cs_get_upload_bo(struct wined3d_device_context *context, struct wined3d_resource *resource,
+ unsigned int sub_resource_idx, struct wined3d_box *box, struct wined3d_const_bo_address *address)
+{
+ return false;
+}
+
static const struct wined3d_device_context_ops wined3d_cs_st_ops =
{
wined3d_cs_st_require_space,
@@ -3009,6 +3062,7 @@ static const struct wined3d_device_context_ops wined3d_cs_st_ops =
wined3d_cs_st_finish,
wined3d_cs_st_push_constants,
wined3d_cs_prepare_upload_bo,
+ wined3d_cs_get_upload_bo,
wined3d_cs_map,
wined3d_cs_unmap,
wined3d_cs_update_sub_resource,
@@ -3138,6 +3192,7 @@ static const struct wined3d_device_context_ops wined3d_cs_mt_ops =
wined3d_cs_mt_finish,
wined3d_cs_mt_push_constants,
wined3d_cs_prepare_upload_bo,
+ wined3d_cs_get_upload_bo,
wined3d_cs_map,
wined3d_cs_unmap,
wined3d_cs_update_sub_resource,
@@ -3414,6 +3469,22 @@ static void wined3d_deferred_context_push_constants(struct wined3d_device_contex
FIXME("context %p, p %#x, start_idx %u, count %u, constants %p, stub!\n", context, p, start_idx, count, constants);
}
+static const struct wined3d_deferred_upload *deferred_context_get_upload(struct wined3d_deferred_context *deferred,
+ struct wined3d_resource *resource, unsigned int sub_resource_idx)
+{
+ SIZE_T i = deferred->upload_count;
+
+ while (i--)
+ {
+ struct wined3d_deferred_upload *upload = &deferred->uploads[i];
+
+ if (upload->resource == resource && upload->sub_resource_idx == sub_resource_idx)
+ return upload;
+ }
+
+ return NULL;
+}
+
static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_context *context,
struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box,
unsigned int row_pitch, unsigned int slice_pitch, uint32_t flags, struct wined3d_const_bo_address *address)
@@ -3452,6 +3523,7 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co
wined3d_resource_incref(resource);
upload->sub_resource_idx = sub_resource_idx;
upload->sysmem = sysmem;
+ upload->box = *box;
address->buffer_object = 0;
map_ptr = (uint8_t *)align((size_t)sysmem, RESOURCE_ALIGNMENT);
@@ -3459,6 +3531,24 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co
return map_ptr;
}
+static bool wined3d_deferred_context_get_upload_bo(struct wined3d_device_context *context,
+ struct wined3d_resource *resource, unsigned int sub_resource_idx,
+ struct wined3d_box *box, struct wined3d_const_bo_address *address)
+{
+ struct wined3d_deferred_context *deferred = wined3d_deferred_context_from_context(context);
+ const struct wined3d_deferred_upload *upload;
+
+ if ((upload = deferred_context_get_upload(deferred, resource, sub_resource_idx)))
+ {
+ *box = upload->box;
+ address->buffer_object = 0;
+ address->addr = (uint8_t *)align((size_t)upload->sysmem, RESOURCE_ALIGNMENT);
+ return true;
+ }
+
+ return false;
+}
+
static HRESULT wined3d_deferred_context_map(struct wined3d_device_context *context, struct wined3d_resource *resource,
unsigned int sub_resource_idx, void **map_ptr, const struct wined3d_box *box, unsigned int flags)
{
@@ -3537,6 +3627,7 @@ static const struct wined3d_device_context_ops wined3d_deferred_context_ops =
wined3d_deferred_context_finish,
wined3d_deferred_context_push_constants,
wined3d_deferred_context_prepare_upload_bo,
+ wined3d_deferred_context_get_upload_bo,
wined3d_deferred_context_map,
wined3d_deferred_context_unmap,
wined3d_deferred_context_update_sub_resource,
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index e37bf46594c..508c9459ba8 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4878,7 +4878,8 @@ HRESULT CDECL wined3d_device_context_map(struct wined3d_device_context *context,
return WINED3DERR_INVALIDCALL;
}
- if (SUCCEEDED(hr = context->ops->map(context, resource, sub_resource_idx, &map_desc->data, box, flags)))
+ if (SUCCEEDED(hr = wined3d_device_context_emit_map(context, resource,
+ sub_resource_idx, &map_desc->data, box, flags)))
wined3d_resource_get_sub_resource_map_pitch(resource, sub_resource_idx,
&map_desc->row_pitch, &map_desc->slice_pitch);
return hr;
@@ -4889,7 +4890,7 @@ HRESULT CDECL wined3d_device_context_unmap(struct wined3d_device_context *contex
{
TRACE("context %p, resource %p, sub_resource_idx %u.\n", context, resource, sub_resource_idx);
- return context->ops->unmap(context, resource, sub_resource_idx);
+ return wined3d_device_context_emit_unmap(context, resource, sub_resource_idx);
}
void CDECL wined3d_device_context_issue_query(struct wined3d_device_context *context,
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 491445a4f00..596f940aa79 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -4712,6 +4712,8 @@ struct wined3d_device_context_ops
void *(*prepare_upload_bo)(struct wined3d_device_context *context, struct wined3d_resource *resource,
unsigned int sub_resource_idx, const struct wined3d_box *box, unsigned int row_pitch,
unsigned int slice_pitch, uint32_t flags, struct wined3d_const_bo_address *address);
+ bool (*get_upload_bo)(struct wined3d_device_context *context, struct wined3d_resource *resource,
+ unsigned int sub_resource_idx, struct wined3d_box *box, struct wined3d_const_bo_address *address);
HRESULT (*map)(struct wined3d_device_context *context, struct wined3d_resource *resource,
unsigned int sub_resource_idx, void **map_ptr, const struct wined3d_box *box, unsigned int flags);
HRESULT (*unmap)(struct wined3d_device_context *context, struct wined3d_resource *resource,
@@ -4805,6 +4807,9 @@ void wined3d_device_context_emit_draw(struct wined3d_device_context *context,
bool indexed) DECLSPEC_HIDDEN;
void wined3d_device_context_emit_generate_mipmaps(struct wined3d_device_context *context,
struct wined3d_shader_resource_view *view) DECLSPEC_HIDDEN;
+HRESULT wined3d_device_context_emit_map(struct wined3d_device_context *context,
+ struct wined3d_resource *resource, unsigned int sub_resource_idx, void **map_ptr,
+ const struct wined3d_box *box, unsigned int flags) DECLSPEC_HIDDEN;
void wined3d_device_context_emit_reset_state(struct wined3d_device_context *context, bool invalidate) DECLSPEC_HIDDEN;
void wined3d_device_context_emit_set_blend_state(struct wined3d_device_context *context,
struct wined3d_blend_state *state, const struct wined3d_color *blend_factor,
@@ -4866,6 +4871,8 @@ void wined3d_device_context_emit_set_viewports(struct wined3d_device_context *co
void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_context *context,
struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box,
const void *data, unsigned int row_pitch, unsigned int slice_pitch) DECLSPEC_HIDDEN;
+HRESULT wined3d_device_context_emit_unmap(struct wined3d_device_context *context,
+ struct wined3d_resource *resource, unsigned int sub_resource_idx) DECLSPEC_HIDDEN;
static inline void wined3d_resource_wait_idle(struct wined3d_resource *resource)
{
--
2.30.2
June 30, 2021
[PATCH v3 3/6] d3d11: Forbid map types other than DISCARD and NOOVERWRITE on a deferred context.
by Zebediah Figura
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
dlls/d3d11/device.c | 4 ++++
dlls/d3d11/tests/d3d11.c | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d11/device.c b/dlls/d3d11/device.c
index 56f34c70ea1..d043af7051a 100644
--- a/dlls/d3d11/device.c
+++ b/dlls/d3d11/device.c
@@ -744,6 +744,10 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_context_Map(ID3D11DeviceContext1 *
if (map_flags)
FIXME("Ignoring map_flags %#x.\n", map_flags);
+ if (context->type != D3D11_DEVICE_CONTEXT_IMMEDIATE
+ && map_type != D3D11_MAP_WRITE_DISCARD && map_type != D3D11_MAP_WRITE_NO_OVERWRITE)
+ return E_INVALIDARG;
+
wined3d_resource = wined3d_resource_from_d3d11_resource(resource);
wined3d_mutex_lock();
diff --git a/dlls/d3d11/tests/d3d11.c b/dlls/d3d11/tests/d3d11.c
index b81f1f652fe..cf51e79b084 100644
--- a/dlls/d3d11/tests/d3d11.c
+++ b/dlls/d3d11/tests/d3d11.c
@@ -33059,7 +33059,7 @@ static void test_deferred_context_map(void)
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
hr = ID3D11DeviceContext_Map(deferred, (ID3D11Resource *)buffer, 0, D3D11_MAP_WRITE, 0, &map_desc);
- todo_wine ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
+ ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
hr = ID3D11DeviceContext_Map(deferred, (ID3D11Resource *)buffer, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &map_desc);
todo_wine ok(hr == D3D11_ERROR_DEFERRED_CONTEXT_MAP_WITHOUT_INITIAL_DISCARD, "Got unexpected hr %#x.\n", hr);
--
2.30.2
June 30, 2021
[PATCH v3 2/6] wined3d: Implement wined3d_deferred_context_prepare_upload_bo().
by Zebediah Figura
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
v3: Use heap_alloc() directly, and store the original allocation base.
dlls/wined3d/cs.c | 65 ++++++++++++++++++++++++++++++++--
dlls/wined3d/wined3d_private.h | 5 +++
2 files changed, 67 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 700ff17ee96..ed6bd6e0aaf 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -26,6 +26,13 @@ WINE_DECLARE_DEBUG_CHANNEL(fps);
#define WINED3D_INITIAL_CS_SIZE 4096
+struct wined3d_deferred_upload
+{
+ struct wined3d_resource *resource;
+ unsigned int sub_resource_idx;
+ uint8_t *sysmem;
+};
+
struct wined3d_command_list
{
LONG refcount;
@@ -38,6 +45,9 @@ struct wined3d_command_list
SIZE_T resource_count;
struct wined3d_resource **resources;
+ SIZE_T upload_count;
+ struct wined3d_deferred_upload *uploads;
+
/* List of command lists queued for execution on this command list. We might
* be the only thing holding a pointer to another command list, so we need
* to hold a reference here (and in wined3d_deferred_context) as well. */
@@ -48,9 +58,13 @@ struct wined3d_command_list
static void wined3d_command_list_destroy_object(void *object)
{
struct wined3d_command_list *list = object;
+ SIZE_T i;
TRACE("list %p.\n", list);
+ for (i = 0; i < list->upload_count; ++i)
+ heap_free(list->uploads[i].sysmem);
+
heap_free(list->resources);
heap_free(list->data);
heap_free(list);
@@ -3343,6 +3357,9 @@ struct wined3d_deferred_context
SIZE_T resource_count, resources_capacity;
struct wined3d_resource **resources;
+ SIZE_T upload_count, uploads_capacity;
+ struct wined3d_deferred_upload *uploads;
+
/* List of command lists queued for execution on this context. A command
* list can be the only thing holding a pointer to another command list, so
* we need to hold a reference here and in wined3d_command_list as well. */
@@ -3401,9 +3418,45 @@ static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_co
struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box,
unsigned int row_pitch, unsigned int slice_pitch, uint32_t flags, struct wined3d_const_bo_address *address)
{
- FIXME("context %p, resource %p, sub_resource_idx %u, box %p, flags %#x, address %p, stub!\n",
- context, resource, sub_resource_idx, box, flags, address);
- return NULL;
+ struct wined3d_deferred_context *deferred = wined3d_deferred_context_from_context(context);
+ const struct wined3d_format *format = resource->format;
+ struct wined3d_deferred_upload *upload;
+ uint8_t *sysmem, *map_ptr;
+ size_t size;
+
+ size = (box->back - box->front - 1) * slice_pitch
+ + ((box->bottom - box->top - 1) / format->block_height) * row_pitch
+ + ((box->right - box->left + format->block_width - 1) / format->block_width) * format->block_byte_count;
+
+ if (!(flags & WINED3D_MAP_WRITE))
+ {
+ WARN("Flags %#x are not valid on a deferred context.\n", flags);
+ return NULL;
+ }
+
+ if (flags & ~(WINED3D_MAP_WRITE | WINED3D_MAP_DISCARD))
+ {
+ FIXME("Unhandled flags %#x.\n", flags);
+ return NULL;
+ }
+
+ if (!wined3d_array_reserve((void **)&deferred->uploads, &deferred->uploads_capacity,
+ deferred->upload_count + 1, sizeof(*deferred->uploads)))
+ return NULL;
+
+ if (!(sysmem = heap_alloc(size + RESOURCE_ALIGNMENT - 1)))
+ return NULL;
+
+ upload = &deferred->uploads[deferred->upload_count++];
+ upload->resource = resource;
+ wined3d_resource_incref(resource);
+ upload->sub_resource_idx = sub_resource_idx;
+ upload->sysmem = sysmem;
+
+ address->buffer_object = 0;
+ map_ptr = (uint8_t *)align((size_t)sysmem, RESOURCE_ALIGNMENT);
+ address->addr = map_ptr;
+ return map_ptr;
}
static HRESULT wined3d_deferred_context_map(struct wined3d_device_context *context, struct wined3d_resource *resource,
@@ -3527,6 +3580,12 @@ void CDECL wined3d_deferred_context_destroy(struct wined3d_device_context *conte
for (i = 0; i < deferred->resource_count; ++i)
wined3d_resource_decref(deferred->resources[i]);
+
+ for (i = 0; i < deferred->upload_count; ++i)
+ {
+ wined3d_resource_decref(deferred->uploads[i].resource);
+ heap_free(deferred->uploads[i].sysmem);
+ }
heap_free(deferred->resources);
wined3d_state_destroy(deferred->c.state);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 83a0a48471b..491445a4f00 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -63,6 +63,11 @@
#include "wine/rbtree.h"
#include "wine/wgl_driver.h"
+static inline size_t align(size_t addr, size_t alignment)
+{
+ return (addr + (alignment - 1)) & ~(alignment - 1);
+}
+
#define MAKEDWORD_VERSION(maj, min) (((maj & 0xffffu) << 16) | (min & 0xffffu))
/* Driver quirks */
--
2.30.2
June 30, 2021
[PATCH v3 1/6] wined3d: Introduce a prepare_upload_bo device context operation and use it to upload sub-resource data.
by Zebediah Figura
Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com>
---
v3: fix the return value of wined3d_deferred_context_prepare_upload_bo
dlls/wined3d/buffer.c | 2 +-
dlls/wined3d/cs.c | 54 ++++++++++++++++++++++++++++++++++
dlls/wined3d/device.c | 3 +-
dlls/wined3d/texture.c | 2 +-
dlls/wined3d/wined3d_private.h | 6 ++++
5 files changed, 64 insertions(+), 3 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 9d22a909fb6..4c5e2054fe0 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -1063,7 +1063,7 @@ static void wined3d_buffer_init_data(struct wined3d_buffer *buffer,
if (buffer->flags & WINED3D_BUFFER_USE_BO)
{
wined3d_box_set(&box, 0, 0, resource->size, 1, 0, 1);
- device->cs->c.ops->update_sub_resource(&device->cs->c, resource,
+ wined3d_device_context_emit_update_sub_resource(&device->cs->c, resource,
0, &box, data->data, data->row_pitch, data->slice_pitch);
}
else
diff --git a/dlls/wined3d/cs.c b/dlls/wined3d/cs.c
index 47bc36d4cc0..700ff17ee96 100644
--- a/dlls/wined3d/cs.c
+++ b/dlls/wined3d/cs.c
@@ -2649,6 +2649,40 @@ done:
wined3d_resource_release(resource);
}
+void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_context *context,
+ struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box,
+ const void *data, unsigned int row_pitch, unsigned int slice_pitch)
+{
+ struct wined3d_const_bo_address src_addr;
+ void *map_ptr;
+
+ if ((map_ptr = context->ops->prepare_upload_bo(context, resource, sub_resource_idx, box,
+ row_pitch, slice_pitch, WINED3D_MAP_WRITE, &src_addr)))
+ {
+ struct wined3d_cs_update_sub_resource *op;
+
+ wined3d_format_copy_data(resource->format, data, row_pitch, slice_pitch, map_ptr, row_pitch, slice_pitch,
+ box->right - box->left, box->bottom - box->top, box->back - box->front);
+
+ op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_DEFAULT);
+ op->opcode = WINED3D_CS_OP_UPDATE_SUB_RESOURCE;
+ op->resource = resource;
+ op->sub_resource_idx = sub_resource_idx;
+ op->box = *box;
+ op->addr = src_addr;
+ op->row_pitch = row_pitch;
+ op->slice_pitch = slice_pitch;
+
+ wined3d_device_context_acquire_resource(context, resource);
+
+ wined3d_device_context_submit(context, WINED3D_CS_QUEUE_DEFAULT);
+ }
+ else
+ {
+ context->ops->update_sub_resource(context, resource, sub_resource_idx, box, data, row_pitch, slice_pitch);
+ }
+}
+
static void wined3d_cs_update_sub_resource(struct wined3d_device_context *context,
struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box,
const void *data, unsigned int row_pitch, unsigned int slice_pitch)
@@ -2946,12 +2980,21 @@ static void wined3d_cs_st_finish(struct wined3d_device_context *context, enum wi
{
}
+static void *wined3d_cs_prepare_upload_bo(struct wined3d_device_context *context, struct wined3d_resource *resource,
+ unsigned int sub_resource_idx, const struct wined3d_box *box, unsigned int row_pitch,
+ unsigned int slice_pitch, uint32_t flags, struct wined3d_const_bo_address *address)
+{
+ /* FIXME: We would like to return mapped or newly allocated memory here. */
+ return NULL;
+}
+
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_prepare_upload_bo,
wined3d_cs_map,
wined3d_cs_unmap,
wined3d_cs_update_sub_resource,
@@ -3080,6 +3123,7 @@ static const struct wined3d_device_context_ops wined3d_cs_mt_ops =
wined3d_cs_mt_submit,
wined3d_cs_mt_finish,
wined3d_cs_mt_push_constants,
+ wined3d_cs_prepare_upload_bo,
wined3d_cs_map,
wined3d_cs_unmap,
wined3d_cs_update_sub_resource,
@@ -3353,6 +3397,15 @@ static void wined3d_deferred_context_push_constants(struct wined3d_device_contex
FIXME("context %p, p %#x, start_idx %u, count %u, constants %p, stub!\n", context, p, start_idx, count, constants);
}
+static void *wined3d_deferred_context_prepare_upload_bo(struct wined3d_device_context *context,
+ struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box,
+ unsigned int row_pitch, unsigned int slice_pitch, uint32_t flags, struct wined3d_const_bo_address *address)
+{
+ FIXME("context %p, resource %p, sub_resource_idx %u, box %p, flags %#x, address %p, stub!\n",
+ context, resource, sub_resource_idx, box, flags, address);
+ return NULL;
+}
+
static HRESULT wined3d_deferred_context_map(struct wined3d_device_context *context, struct wined3d_resource *resource,
unsigned int sub_resource_idx, void **map_ptr, const struct wined3d_box *box, unsigned int flags)
{
@@ -3430,6 +3483,7 @@ static const struct wined3d_device_context_ops wined3d_deferred_context_ops =
wined3d_deferred_context_submit,
wined3d_deferred_context_finish,
wined3d_deferred_context_push_constants,
+ wined3d_deferred_context_prepare_upload_bo,
wined3d_deferred_context_map,
wined3d_deferred_context_unmap,
wined3d_deferred_context_update_sub_resource,
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 96657141419..e37bf46594c 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4679,7 +4679,8 @@ void CDECL wined3d_device_context_update_sub_resource(struct wined3d_device_cont
return;
}
- context->ops->update_sub_resource(context, resource, sub_resource_idx, box, data, row_pitch, depth_pitch);
+ wined3d_device_context_emit_update_sub_resource(context, resource,
+ sub_resource_idx, box, data, row_pitch, depth_pitch);
}
void CDECL wined3d_device_context_resolve_sub_resource(struct wined3d_device_context *context,
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 62f38a1d592..c1247fbc56b 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -4350,7 +4350,7 @@ HRESULT CDECL wined3d_texture_create(struct wined3d_device *device, const struct
for (i = 0; i < sub_count; ++i)
{
wined3d_texture_get_level_box(*texture, i % (*texture)->level_count, &box);
- device->cs->c.ops->update_sub_resource(&device->cs->c, &(*texture)->resource,
+ wined3d_device_context_emit_update_sub_resource(&device->cs->c, &(*texture)->resource,
i, &box, data[i].data, data[i].row_pitch, data[i].slice_pitch);
}
}
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index c70b0f7c338..83a0a48471b 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -4704,6 +4704,9 @@ 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 *(*prepare_upload_bo)(struct wined3d_device_context *context, struct wined3d_resource *resource,
+ unsigned int sub_resource_idx, const struct wined3d_box *box, unsigned int row_pitch,
+ unsigned int slice_pitch, uint32_t flags, struct wined3d_const_bo_address *address);
HRESULT (*map)(struct wined3d_device_context *context, struct wined3d_resource *resource,
unsigned int sub_resource_idx, void **map_ptr, const struct wined3d_box *box, unsigned int flags);
HRESULT (*unmap)(struct wined3d_device_context *context, struct wined3d_resource *resource,
@@ -4855,6 +4858,9 @@ void wined3d_device_context_emit_set_vertex_declaration(struct wined3d_device_co
struct wined3d_vertex_declaration *declaration) DECLSPEC_HIDDEN;
void wined3d_device_context_emit_set_viewports(struct wined3d_device_context *context, unsigned int viewport_count,
const struct wined3d_viewport *viewports) DECLSPEC_HIDDEN;
+void wined3d_device_context_emit_update_sub_resource(struct wined3d_device_context *context,
+ struct wined3d_resource *resource, unsigned int sub_resource_idx, const struct wined3d_box *box,
+ const void *data, unsigned int row_pitch, unsigned int slice_pitch) DECLSPEC_HIDDEN;
static inline void wined3d_resource_wait_idle(struct wined3d_resource *resource)
{
--
2.30.2
June 30, 2021
Re: [PATCH v2 4/5] wined3d: Use context->ops->prepare_upload_bo() in wined3d_device_context_map() if possible.
by Henri Verbeet
On Wed, 30 Jun 2021 at 22:07, Zebediah Figura (she/her)
<zfigura(a)codeweavers.com> wrote:
> On 6/30/21 2:46 PM, Henri Verbeet wrote:
> > Alternatively, we could do something like this in
> > wined3d_device_context_unmap():
> >
> > ...
> > if (context->ops->get_upload_bo(...))
> > {
> > ...
> > wined3d_device_context_upload_bo(...);
> > return WINED3D_OK;
> > }
> > ...
> > return wined3d_device_context_emit_unmap(...);
>
> Where I'm guessing wined3d_device_context_emit_unmap() contains pretty
> much the entirety of wined3d_cs_unmap()?
>
Right.
> That had occurred to me as well, although I didn't implement it. I
> probably would leave it for a separate patch, though I'm not opposed to
> rolling it into this one.
>
Sure, we could do that in a subsequent patch.
> > which should also work, and may be preferable, because we could
> > implement wined3d_device_context_map() and
> > wined3d_device_context_update_sub_resource() in a similar way. I.e., I
> > think we can make this work with either
> > prepare_upload_bo()/get_upload_bo() or
> > update_sub_resource()/map()/unmap() in the device context ops, but we
> > probably don't need both sets of ops.
>
> I'd agree the second approach outlined in this email looks clearer.
> That, or to just use update_sub_resource/map/unmap. I don't have a
> preference between those two, so I'll leave that decision to the
> maintainer ;-)
I'm leaning towards prepare_upload_bo()/get_upload_bo() because it's
the smaller device context ops interface, and results in fewer levels
of map/unmap API, but it's not a strong preference.
June 30, 2021