[PATCH 5/5] wined3d: Always pass a non-NULL box to context->ops->map().
Zebediah Figura
z.figura12 at gmail.com
Wed Jun 23 16:38:51 CDT 2021
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
dlls/wined3d/buffer.c | 11 ++---------
dlls/wined3d/device.c | 7 +++++++
dlls/wined3d/texture.c | 36 +++++++++++++-----------------------
3 files changed, 22 insertions(+), 32 deletions(-)
diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c
index 5e98a1eb3df..a37071a5b9c 100644
--- a/dlls/wined3d/buffer.c
+++ b/dlls/wined3d/buffer.c
@@ -853,15 +853,8 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc
TRACE("resource %p, sub_resource_idx %u, map_ptr %p, box %s, flags %#x.\n",
resource, sub_resource_idx, map_ptr, debug_box(box), flags);
- if (box)
- {
- offset = box->left;
- size = box->right - box->left;
- }
- else
- {
- offset = size = 0;
- }
+ offset = box->left;
+ size = box->right - box->left;
count = ++resource->map_count;
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index b93959089dd..aa26e1528fb 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -4843,6 +4843,7 @@ HRESULT CDECL wined3d_device_context_map(struct wined3d_device_context *context,
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, unsigned int flags)
{
struct wined3d_sub_resource *sub_resource;
+ struct wined3d_box b;
HRESULT hr;
TRACE("context %p, resource %p, sub_resource_idx %u, map_desc %p, box %s, flags %#x.\n",
@@ -4874,6 +4875,12 @@ HRESULT CDECL wined3d_device_context_map(struct wined3d_device_context *context,
return E_INVALIDARG;
}
+ if (!box)
+ {
+ wined3d_box_set(&b, 0, 0, sub_resource->width, sub_resource->height, 0, sub_resource->depth);
+ box = &b;
+ }
+
if (SUCCEEDED(hr = context->ops->map(context, resource, sub_resource_idx, &map_desc->data, box, flags)))
{
map_desc->row_pitch = sub_resource->map_row_pitch;
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index c5074ed7c21..470bbc677bc 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -3559,7 +3559,7 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour
sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx);
texture_level = sub_resource_idx % texture->level_count;
- if (box && FAILED(wined3d_texture_check_box_dimensions(texture, texture_level, box)))
+ if (FAILED(wined3d_texture_check_box_dimensions(texture, texture_level, box)))
{
WARN("Map box is invalid.\n");
if (((fmt_flags & WINED3DFMT_FLAG_BLOCKS) && !(resource->access & WINED3D_RESOURCE_ACCESS_CPU))
@@ -3621,38 +3621,28 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour
row_pitch = sub_resource->sub_resource.map_row_pitch;
slice_pitch = sub_resource->sub_resource.map_slice_pitch;
- if (!box)
+ if ((fmt_flags & (WINED3DFMT_FLAG_BLOCKS | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_BLOCKS)
{
- *map_ptr = base_memory;
+ /* Compressed textures are block based, so calculate the offset of
+ * the block that contains the top-left pixel of the mapped box. */
+ *map_ptr = base_memory
+ + (box->front * slice_pitch)
+ + ((box->top / format->block_height) * row_pitch)
+ + ((box->left / format->block_width) * format->block_byte_count);
}
else
{
- if ((fmt_flags & (WINED3DFMT_FLAG_BLOCKS | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_BLOCKS)
- {
- /* Compressed textures are block based, so calculate the offset of
- * the block that contains the top-left pixel of the mapped box. */
- *map_ptr = base_memory
- + (box->front * slice_pitch)
- + ((box->top / format->block_height) * row_pitch)
- + ((box->left / format->block_width) * format->block_byte_count);
- }
- else
- {
- *map_ptr = base_memory
- + (box->front * slice_pitch)
- + (box->top * row_pitch)
- + (box->left * format->byte_count);
- }
+ *map_ptr = base_memory
+ + (box->front * slice_pitch)
+ + (box->top * row_pitch)
+ + (box->left * format->byte_count);
}
if (texture->swapchain && texture->swapchain->front_buffer == texture)
{
RECT *r = &texture->swapchain->front_buffer_update;
- if (!box)
- SetRect(r, 0, 0, resource->width, resource->height);
- else
- SetRect(r, box->left, box->top, box->right, box->bottom);
+ SetRect(r, box->left, box->top, box->right, box->bottom);
TRACE("Mapped front buffer %s.\n", wine_dbgstr_rect(r));
}
--
2.30.2
More information about the wine-devel
mailing list