wined3d: Return the map pitch from wined3d_device_context_emit_map().
Partially undoes 61024aa12f
.
We may want to be able to return an existing BO from
context->ops->map_upload_bo(), in which case it is structurally awkward to
request a specific memory layout. We may also want to give map_upload_bo() the
freedom to allocate either a new (smaller) BO, or use an existing (larger) one,
for partial uploads.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b70a7f37bc
commit
4b7beecbeb
|
@ -2489,27 +2489,32 @@ 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)
|
||||
HRESULT wined3d_device_context_emit_map(struct wined3d_device_context *context,
|
||||
struct wined3d_resource *resource, unsigned int sub_resource_idx,
|
||||
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, unsigned int flags)
|
||||
{
|
||||
unsigned int row_pitch, slice_pitch;
|
||||
struct wined3d_cs_map *op;
|
||||
void *map_ptr;
|
||||
HRESULT hr;
|
||||
|
||||
wined3d_resource_get_sub_resource_map_pitch(resource, sub_resource_idx, &row_pitch, &slice_pitch);
|
||||
|
||||
if ((flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))
|
||||
&& (*map_ptr = context->ops->map_upload_bo(context, resource,
|
||||
sub_resource_idx, box, row_pitch, slice_pitch, flags)))
|
||||
{
|
||||
TRACE("Returning map pointer %p, row pitch %u, slice pitch %u.\n", *map_ptr, row_pitch, slice_pitch);
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
/* 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(context->device->cs);
|
||||
|
||||
wined3d_resource_get_sub_resource_map_pitch(resource, sub_resource_idx, &row_pitch, &slice_pitch);
|
||||
|
||||
if ((flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))
|
||||
&& (map_ptr = context->ops->map_upload_bo(context, resource,
|
||||
sub_resource_idx, box, row_pitch, slice_pitch, flags)))
|
||||
{
|
||||
TRACE("Returning map pointer %p, row pitch %u, slice pitch %u.\n", map_ptr, row_pitch, slice_pitch);
|
||||
map_desc->data = map_ptr;
|
||||
map_desc->row_pitch = row_pitch;
|
||||
map_desc->slice_pitch = slice_pitch;
|
||||
return WINED3D_OK;
|
||||
}
|
||||
|
||||
wined3d_resource_wait_idle(resource);
|
||||
|
||||
if (!(op = wined3d_device_context_require_space(context, sizeof(*op), WINED3D_CS_QUEUE_MAP)))
|
||||
|
@ -2517,7 +2522,7 @@ HRESULT wined3d_device_context_emit_map(struct wined3d_device_context *context,
|
|||
op->opcode = WINED3D_CS_OP_MAP;
|
||||
op->resource = resource;
|
||||
op->sub_resource_idx = sub_resource_idx;
|
||||
op->map_ptr = map_ptr;
|
||||
op->map_ptr = &map_ptr;
|
||||
op->box = box;
|
||||
op->flags = flags;
|
||||
op->hr = &hr;
|
||||
|
@ -2525,6 +2530,12 @@ HRESULT wined3d_device_context_emit_map(struct wined3d_device_context *context,
|
|||
wined3d_device_context_submit(context, WINED3D_CS_QUEUE_MAP);
|
||||
wined3d_device_context_finish(context, WINED3D_CS_QUEUE_MAP);
|
||||
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
map_desc->data = map_ptr;
|
||||
map_desc->row_pitch = row_pitch;
|
||||
map_desc->slice_pitch = slice_pitch;
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
|
|
@ -4957,10 +4957,7 @@ HRESULT CDECL wined3d_device_context_map(struct wined3d_device_context *context,
|
|||
}
|
||||
|
||||
wined3d_mutex_lock();
|
||||
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);
|
||||
hr = wined3d_device_context_emit_map(context, resource, sub_resource_idx, map_desc, box, flags);
|
||||
wined3d_mutex_unlock();
|
||||
return hr;
|
||||
}
|
||||
|
|
|
@ -4867,7 +4867,7 @@ void wined3d_device_context_emit_execute_command_list(struct wined3d_device_cont
|
|||
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,
|
||||
struct wined3d_resource *resource, unsigned int sub_resource_idx, struct wined3d_map_desc *map_desc,
|
||||
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,
|
||||
|
|
Loading…
Reference in New Issue