On 2/25/22 08:22, Henri Verbeet wrote:
On Fri, 25 Feb 2022 at 03:22, Zebediah Figura zfigura@codeweavers.com wrote:
@@ -3186,6 +3194,28 @@ static bool wined3d_cs_map_upload_bo(struct wined3d_device_context *context, str return true; }
- if (!(flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE)))
- {
struct wined3d_client_resource *client = &resource->client;
const struct wined3d_format *format = resource->format;
size_t size;
wined3d_format_calculate_pitch(format, 1, box->right - box->left,
box->bottom - box->top, &map_desc->row_pitch, &map_desc->slice_pitch);
size = (box->back - box->front - 1) * map_desc->slice_pitch
+ ((box->bottom - box->top - 1) / format->block_height) * map_desc->row_pitch
+ ((box->right - box->left + format->block_width - 1) / format->block_width) * format->block_byte_count;
if (!(map_desc->data = heap_alloc(size)))
return false;
client->mapped_upload.addr.buffer_object = 0;
client->mapped_upload.addr.addr = map_desc->data;
client->mapped_upload.flags = UPLOAD_BO_UPLOAD_ON_UNMAP | UPLOAD_BO_FREE_ON_UNMAP;
client->mapped_box = *box;
return true;
- }
}return false;
It's not the worst thing, but note that the "flags" check here is redundant; if either DISCARD or NOOVERWRITE was set, we would have returned from the preceding block. That also means the final "return false;" should be unreachable though, and that makes the next patch in the series slightly weird.
Indeed. These patches may be a little older...