wined3d: Always pass a non-NULL box to context->ops->map().
Signed-off-by: Zebediah Figura <z.figura12@gmail.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
e275504859
commit
236afee0da
|
@ -875,21 +875,8 @@ static HRESULT buffer_resource_sub_resource_map(struct wined3d_resource *resourc
|
||||||
TRACE("resource %p, sub_resource_idx %u, map_desc %p, box %s, flags %#x.\n",
|
TRACE("resource %p, sub_resource_idx %u, map_desc %p, box %s, flags %#x.\n",
|
||||||
resource, sub_resource_idx, map_desc, debug_box(box), flags);
|
resource, sub_resource_idx, map_desc, debug_box(box), flags);
|
||||||
|
|
||||||
if (sub_resource_idx)
|
offset = box->left;
|
||||||
{
|
size = box->right - box->left;
|
||||||
WARN("Invalid sub_resource_idx %u.\n", sub_resource_idx);
|
|
||||||
return E_INVALIDARG;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (box)
|
|
||||||
{
|
|
||||||
offset = box->left;
|
|
||||||
size = box->right - box->left;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
offset = size = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
map_desc->row_pitch = map_desc->slice_pitch = resource->size;
|
map_desc->row_pitch = map_desc->slice_pitch = resource->size;
|
||||||
|
|
||||||
|
|
|
@ -4834,6 +4834,9 @@ HRESULT CDECL wined3d_device_context_map(struct wined3d_device_context *context,
|
||||||
struct wined3d_resource *resource, unsigned int sub_resource_idx,
|
struct wined3d_resource *resource, unsigned int sub_resource_idx,
|
||||||
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, unsigned int flags)
|
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, unsigned int flags)
|
||||||
{
|
{
|
||||||
|
struct wined3d_sub_resource_desc desc;
|
||||||
|
struct wined3d_box b;
|
||||||
|
|
||||||
TRACE("context %p, resource %p, sub_resource_idx %u, map_desc %p, box %s, flags %#x.\n",
|
TRACE("context %p, resource %p, sub_resource_idx %u, map_desc %p, box %s, flags %#x.\n",
|
||||||
context, resource, sub_resource_idx, map_desc, debug_box(box), flags);
|
context, resource, sub_resource_idx, map_desc, debug_box(box), flags);
|
||||||
|
|
||||||
|
@ -4857,6 +4860,15 @@ HRESULT CDECL wined3d_device_context_map(struct wined3d_device_context *context,
|
||||||
|
|
||||||
flags = sanitise_map_flags(resource, flags);
|
flags = sanitise_map_flags(resource, flags);
|
||||||
|
|
||||||
|
if (FAILED(wined3d_resource_get_sub_resource_desc(resource, sub_resource_idx, &desc)))
|
||||||
|
return E_INVALIDARG;
|
||||||
|
|
||||||
|
if (!box)
|
||||||
|
{
|
||||||
|
wined3d_box_set(&b, 0, 0, desc.width, desc.height, 0, desc.depth);
|
||||||
|
box = &b;
|
||||||
|
}
|
||||||
|
|
||||||
return context->ops->map(context, resource, sub_resource_idx, map_desc, box, flags);
|
return context->ops->map(context, resource, sub_resource_idx, map_desc, box, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3532,11 +3532,10 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour
|
||||||
resource, sub_resource_idx, map_desc, debug_box(box), flags);
|
resource, sub_resource_idx, map_desc, debug_box(box), flags);
|
||||||
|
|
||||||
texture = texture_from_resource(resource);
|
texture = texture_from_resource(resource);
|
||||||
if (!(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx)))
|
sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx);
|
||||||
return E_INVALIDARG;
|
|
||||||
|
|
||||||
texture_level = sub_resource_idx % texture->level_count;
|
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");
|
WARN("Map box is invalid.\n");
|
||||||
if (((fmt_flags & WINED3DFMT_FLAG_BLOCKS) && !(resource->access & WINED3D_RESOURCE_ACCESS_CPU))
|
if (((fmt_flags & WINED3DFMT_FLAG_BLOCKS) && !(resource->access & WINED3D_RESOURCE_ACCESS_CPU))
|
||||||
|
@ -3605,38 +3604,28 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour
|
||||||
wined3d_texture_get_pitch(texture, texture_level, &map_desc->row_pitch, &map_desc->slice_pitch);
|
wined3d_texture_get_pitch(texture, texture_level, &map_desc->row_pitch, &map_desc->slice_pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!box)
|
if ((fmt_flags & (WINED3DFMT_FLAG_BLOCKS | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_BLOCKS)
|
||||||
{
|
{
|
||||||
map_desc->data = 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_desc->data = base_memory
|
||||||
|
+ (box->front * map_desc->slice_pitch)
|
||||||
|
+ ((box->top / format->block_height) * map_desc->row_pitch)
|
||||||
|
+ ((box->left / format->block_width) * format->block_byte_count);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ((fmt_flags & (WINED3DFMT_FLAG_BLOCKS | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_BLOCKS)
|
map_desc->data = base_memory
|
||||||
{
|
+ (box->front * map_desc->slice_pitch)
|
||||||
/* Compressed textures are block based, so calculate the offset of
|
+ (box->top * map_desc->row_pitch)
|
||||||
* the block that contains the top-left pixel of the mapped box. */
|
+ (box->left * format->byte_count);
|
||||||
map_desc->data = base_memory
|
|
||||||
+ (box->front * map_desc->slice_pitch)
|
|
||||||
+ ((box->top / format->block_height) * map_desc->row_pitch)
|
|
||||||
+ ((box->left / format->block_width) * format->block_byte_count);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
map_desc->data = base_memory
|
|
||||||
+ (box->front * map_desc->slice_pitch)
|
|
||||||
+ (box->top * map_desc->row_pitch)
|
|
||||||
+ (box->left * format->byte_count);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (texture->swapchain && texture->swapchain->front_buffer == texture)
|
if (texture->swapchain && texture->swapchain->front_buffer == texture)
|
||||||
{
|
{
|
||||||
RECT *r = &texture->swapchain->front_buffer_update;
|
RECT *r = &texture->swapchain->front_buffer_update;
|
||||||
|
|
||||||
if (!box)
|
SetRect(r, box->left, box->top, box->right, box->bottom);
|
||||||
SetRect(r, 0, 0, resource->width, resource->height);
|
|
||||||
else
|
|
||||||
SetRect(r, box->left, box->top, box->right, box->bottom);
|
|
||||||
TRACE("Mapped front buffer %s.\n", wine_dbgstr_rect(r));
|
TRACE("Mapped front buffer %s.\n", wine_dbgstr_rect(r));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue