From: Nicolai Hähnle <nicolai.haeh...@amd.com> We will change pipe_context::transfer_map in a subsequent commit. Wrapping it in an inline function makes that subsequent change less noisy. --- src/gallium/auxiliary/util/u_inlines.h | 16 ++++++++++++++++ src/gallium/auxiliary/util/u_surface.c | 4 ++-- src/gallium/auxiliary/util/u_transfer.c | 4 ++-- src/gallium/auxiliary/util/u_transfer_helper.c | 2 +- src/gallium/auxiliary/vl/vl_idct.c | 2 +- src/gallium/auxiliary/vl/vl_mpeg12_decoder.c | 2 +- src/gallium/auxiliary/vl/vl_zscan.c | 4 ++-- src/gallium/drivers/r600/compute_memory_pool.c | 6 +++--- src/gallium/drivers/r600/evergreen_compute.c | 2 +- .../state_trackers/clover/core/resource.cpp | 2 +- src/gallium/state_trackers/nine/buffer9.c | 2 +- src/gallium/state_trackers/nine/device9.c | 6 +++--- src/gallium/state_trackers/nine/nine_state.c | 4 ++-- src/gallium/state_trackers/nine/surface9.c | 6 +++--- src/gallium/state_trackers/nine/volume9.c | 4 ++-- .../state_trackers/omx/bellagio/vid_enc.c | 2 +- src/gallium/state_trackers/osmesa/osmesa.c | 4 ++-- src/gallium/state_trackers/va/buffer.c | 2 +- src/gallium/state_trackers/va/image.c | 4 ++-- src/gallium/state_trackers/va/surface.c | 2 +- src/gallium/state_trackers/vdpau/output.c | 2 +- src/gallium/state_trackers/vdpau/surface.c | 4 ++-- src/gallium/state_trackers/xvmc/subpicture.c | 6 +++--- src/gallium/tests/trivial/compute.c | 4 ++-- src/gallium/tests/trivial/quad-tex.c | 2 +- src/mesa/state_tracker/st_texture.c | 2 +- 26 files changed, 58 insertions(+), 42 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h index 4bd9b7e3c62..b7a28568807 100644 --- a/src/gallium/auxiliary/util/u_inlines.h +++ b/src/gallium/auxiliary/util/u_inlines.h @@ -448,20 +448,36 @@ pipe_buffer_read(struct pipe_context *pipe, PIPE_TRANSFER_READ, &src_transfer); if (!map) return; memcpy(data, map, size); pipe_buffer_unmap(pipe, src_transfer); } +/** + * Map a resource for reading/writing. + */ +static inline void * +pipe_transfer_map_box(struct pipe_context *context, + struct pipe_resource *resource, + unsigned level, + enum pipe_transfer_usage usage, + const struct pipe_box *box, + struct pipe_transfer **out_transfer) +{ + return context->transfer_map(context, resource, level, usage, box, + out_transfer); +} + + /** * Map a resource for reading/writing. * \param access bitmask of PIPE_TRANSFER_x flags */ static inline void * pipe_transfer_map(struct pipe_context *context, struct pipe_resource *resource, unsigned level, unsigned layer, unsigned access, unsigned x, unsigned y, diff --git a/src/gallium/auxiliary/util/u_surface.c b/src/gallium/auxiliary/util/u_surface.c index 5f07eb1cdac..c28c93abd4c 100644 --- a/src/gallium/auxiliary/util/u_surface.c +++ b/src/gallium/auxiliary/util/u_surface.c @@ -330,31 +330,31 @@ util_resource_copy_region(struct pipe_context *pipe, /* check that region boxes are not out of bounds */ assert(src_box.x + src_box.width <= (int)u_minify(src->width0, src_level)); assert(src_box.y + src_box.height <= (int)u_minify(src->height0, src_level)); assert(dst_box.x + dst_box.width <= (int)u_minify(dst->width0, dst_level)); assert(dst_box.y + dst_box.height <= (int)u_minify(dst->height0, dst_level)); /* check that total number of src, dest bytes match */ assert((src_box.width / src_bw) * (src_box.height / src_bh) * src_bs == (dst_box.width / dst_bw) * (dst_box.height / dst_bh) * dst_bs); - src_map = pipe->transfer_map(pipe, + src_map = pipe_transfer_map_box(pipe, src, src_level, PIPE_TRANSFER_READ, &src_box, &src_trans); assert(src_map); if (!src_map) { goto no_src_map; } - dst_map = pipe->transfer_map(pipe, + dst_map = pipe_transfer_map_box(pipe, dst, dst_level, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE, &dst_box, &dst_trans); assert(dst_map); if (!dst_map) { goto no_dst_map; } diff --git a/src/gallium/auxiliary/util/u_transfer.c b/src/gallium/auxiliary/util/u_transfer.c index 3089bcb1f34..0e0c4cc91cd 100644 --- a/src/gallium/auxiliary/util/u_transfer.c +++ b/src/gallium/auxiliary/util/u_transfer.c @@ -20,21 +20,21 @@ void u_default_buffer_subdata(struct pipe_context *pipe, /* buffer_subdata implicitly discards the rewritten buffer range */ if (offset == 0 && size == resource->width0) { usage |= PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE; } else { usage |= PIPE_TRANSFER_DISCARD_RANGE; } u_box_1d(offset, size, &box); - map = pipe->transfer_map(pipe, resource, 0, usage, &box, &transfer); + map = pipe_transfer_map_box(pipe, resource, 0, usage, &box, &transfer); if (!map) return; memcpy(map, data, size); pipe_transfer_unmap(pipe, transfer); } void u_default_texture_subdata(struct pipe_context *pipe, struct pipe_resource *resource, unsigned level, @@ -49,21 +49,21 @@ void u_default_texture_subdata(struct pipe_context *pipe, uint8_t *map = NULL; assert(!(usage & PIPE_TRANSFER_READ)); /* the write flag is implicit by the nature of texture_subdata */ usage |= PIPE_TRANSFER_WRITE; /* texture_subdata implicitly discards the rewritten buffer range */ usage |= PIPE_TRANSFER_DISCARD_RANGE; - map = pipe->transfer_map(pipe, + map = pipe_transfer_map_box(pipe, resource, level, usage, box, &transfer); if (!map) return; util_copy_box(map, resource->format, transfer->stride, /* bytes */ diff --git a/src/gallium/auxiliary/util/u_transfer_helper.c b/src/gallium/auxiliary/util/u_transfer_helper.c index dd31049920f..f69015af519 100644 --- a/src/gallium/auxiliary/util/u_transfer_helper.c +++ b/src/gallium/auxiliary/util/u_transfer_helper.c @@ -201,21 +201,21 @@ transfer_map_msaa(struct pipe_context *pctx, blit.dst.box.width = box->width; blit.dst.box.height = box->height; blit.dst.box.depth = 1; blit.mask = util_format_get_mask(prsc->format); blit.filter = PIPE_TEX_FILTER_NEAREST; pctx->blit(pctx, &blit); } - void *ss_map = pctx->transfer_map(pctx, trans->ss, 0, usage, box, + void *ss_map = pipe_transfer_map_box(pctx, trans->ss, 0, usage, box, &trans->trans); if (!ss_map) { free(trans); return NULL; } *pptrans = ptrans; return ss_map; } diff --git a/src/gallium/auxiliary/vl/vl_idct.c b/src/gallium/auxiliary/vl/vl_idct.c index 3e6f581244e..f69b5fffa37 100644 --- a/src/gallium/auxiliary/vl/vl_idct.c +++ b/src/gallium/auxiliary/vl/vl_idct.c @@ -701,21 +701,21 @@ vl_idct_upload_matrix(struct pipe_context *pipe, float scale) tex_templ.depth0 = 1; tex_templ.array_size = 1; tex_templ.usage = PIPE_USAGE_IMMUTABLE; tex_templ.bind = PIPE_BIND_SAMPLER_VIEW; tex_templ.flags = 0; matrix = pipe->screen->resource_create(pipe->screen, &tex_templ); if (!matrix) goto error_matrix; - f = pipe->transfer_map(pipe, matrix, 0, + f = pipe_transfer_map_box(pipe, matrix, 0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE, &rect, &buf_transfer); if (!f) goto error_map; pitch = buf_transfer->stride / sizeof(float); for(i = 0; i < VL_BLOCK_HEIGHT; ++i) for(j = 0; j < VL_BLOCK_WIDTH; ++j) diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c index 8a2dae34e35..74a12927e95 100644 --- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c +++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c @@ -621,21 +621,21 @@ vl_mpeg12_begin_frame(struct pipe_video_codec *decoder, vl_zscan_upload_quant(zscan, &buf->zscan[i], non_intra_matrix, false); } vl_vb_map(&buf->vertex_stream, dec->context); tex = buf->zscan_source->texture; rect.width = tex->width0; rect.height = tex->height0; buf->texels = - dec->context->transfer_map(dec->context, tex, 0, + pipe_transfer_map_box(dec->context, tex, 0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE, &rect, &buf->tex_transfer); buf->block_num = 0; for (i = 0; i < VL_NUM_COMPONENTS; ++i) { buf->ycbcr_stream[i] = vl_vb_get_ycbcr_stream(&buf->vertex_stream, i); buf->num_ycbcr_blocks[i] = 0; } diff --git a/src/gallium/auxiliary/vl/vl_zscan.c b/src/gallium/auxiliary/vl/vl_zscan.c index 75013c42bfe..0d57c61d234 100644 --- a/src/gallium/auxiliary/vl/vl_zscan.c +++ b/src/gallium/auxiliary/vl/vl_zscan.c @@ -400,21 +400,21 @@ vl_zscan_layout(struct pipe_context *pipe, const int layout[64], unsigned blocks res_tmpl.height0 = VL_BLOCK_HEIGHT; res_tmpl.depth0 = 1; res_tmpl.array_size = 1; res_tmpl.usage = PIPE_USAGE_IMMUTABLE; res_tmpl.bind = PIPE_BIND_SAMPLER_VIEW; res = pipe->screen->resource_create(pipe->screen, &res_tmpl); if (!res) goto error_resource; - f = pipe->transfer_map(pipe, res, + f = pipe_transfer_map_box(pipe, res, 0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE, &rect, &buf_transfer); if (!f) goto error_map; pitch = buf_transfer->stride / sizeof(float); for (i = 0; i < blocks_per_line; ++i) for (y = 0; y < VL_BLOCK_HEIGHT; ++y) for (x = 0; x < VL_BLOCK_WIDTH; ++x) { @@ -566,21 +566,21 @@ vl_zscan_upload_quant(struct vl_zscan *zscan, struct vl_zscan_buffer *buffer, 1 }; assert(buffer); assert(matrix); pipe = zscan->pipe; rect.width *= zscan->blocks_per_line; - data = pipe->transfer_map(pipe, buffer->quant->texture, + data = pipe_transfer_map_box(pipe, buffer->quant->texture, 0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE, &rect, &buf_transfer); if (!data) return; pitch = buf_transfer->stride; for (i = 0; i < zscan->blocks_per_line; ++i) for (y = 0; y < VL_BLOCK_HEIGHT; ++y) diff --git a/src/gallium/drivers/r600/compute_memory_pool.c b/src/gallium/drivers/r600/compute_memory_pool.c index bcda155c71a..37e7188110c 100644 --- a/src/gallium/drivers/r600/compute_memory_pool.c +++ b/src/gallium/drivers/r600/compute_memory_pool.c @@ -533,21 +533,21 @@ void compute_memory_move_item(struct compute_memory_pool *pool, /* The allocation of the temporary resource failed, * falling back to use mappings */ uint32_t *map; int64_t offset; struct pipe_transfer *trans; offset = item->start_in_dw - new_start_in_dw; u_box_1d(new_start_in_dw * 4, (offset + item->size_in_dw) * 4, &box); - map = pipe->transfer_map(pipe, src, 0, PIPE_TRANSFER_READ_WRITE, + map = pipe_transfer_map_box(pipe, src, 0, PIPE_TRANSFER_READ_WRITE, &box, &trans); assert(map); assert(trans); memmove(map, map + offset, item->size_in_dw * 4); pipe->transfer_unmap(pipe, trans); } } @@ -668,29 +668,29 @@ void compute_memory_transfer( struct pipe_transfer *xfer; uint32_t *map; assert(gart); COMPUTE_DBG(pool->screen, "* compute_memory_transfer() device_to_host = %d, " "offset_in_chunk = %d, size = %d\n", device_to_host, offset_in_chunk, size); if (device_to_host) { - map = pipe->transfer_map(pipe, gart, 0, PIPE_TRANSFER_READ, + map = pipe_transfer_map_box(pipe, gart, 0, PIPE_TRANSFER_READ, &(struct pipe_box) { .width = aligned_size * 4, .height = 1, .depth = 1 }, &xfer); assert(xfer); assert(map); memcpy(data, map + internal_offset, size); pipe->transfer_unmap(pipe, xfer); } else { - map = pipe->transfer_map(pipe, gart, 0, PIPE_TRANSFER_WRITE, + map = pipe_transfer_map_box(pipe, gart, 0, PIPE_TRANSFER_WRITE, &(struct pipe_box) { .width = aligned_size * 4, .height = 1, .depth = 1 }, &xfer); assert(xfer); assert(map); memcpy(map + internal_offset, data, size); pipe->transfer_unmap(pipe, xfer); } } /** diff --git a/src/gallium/drivers/r600/evergreen_compute.c b/src/gallium/drivers/r600/evergreen_compute.c index 6cb82122b16..866837dfa6e 100644 --- a/src/gallium/drivers/r600/evergreen_compute.c +++ b/src/gallium/drivers/r600/evergreen_compute.c @@ -525,21 +525,21 @@ static void evergreen_compute_upload_input(struct pipe_context *ctx, } input_size = shader->input_size + 36; if (!shader->kernel_param) { /* Add space for the grid dimensions */ shader->kernel_param = (struct r600_resource *) pipe_buffer_create(ctx->screen, 0, PIPE_USAGE_IMMUTABLE, input_size); } u_box_1d(0, input_size, &box); - num_work_groups_start = ctx->transfer_map(ctx, + num_work_groups_start = pipe_transfer_map_box(ctx, (struct pipe_resource*)shader->kernel_param, 0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE, &box, &transfer); global_size_start = num_work_groups_start + (3 * (sizeof(uint) /4)); local_size_start = global_size_start + (3 * (sizeof(uint)) / 4); kernel_parameters_start = local_size_start + (3 * (sizeof(uint)) / 4); /* Copy the work group size */ memcpy(num_work_groups_start, info->grid, 3 * sizeof(uint)); diff --git a/src/gallium/state_trackers/clover/core/resource.cpp b/src/gallium/state_trackers/clover/core/resource.cpp index 79911771a00..ebf3ee036eb 100644 --- a/src/gallium/state_trackers/clover/core/resource.cpp +++ b/src/gallium/state_trackers/clover/core/resource.cpp @@ -190,21 +190,21 @@ mapping::mapping(command_queue &q, resource &r, cl_map_flags flags, bool blocking, const resource::vector &origin, const resource::vector ®ion) : pctx(q.pipe), pres(NULL) { unsigned usage = ((flags & CL_MAP_WRITE ? PIPE_TRANSFER_WRITE : 0 ) | (flags & CL_MAP_READ ? PIPE_TRANSFER_READ : 0 ) | (flags & CL_MAP_WRITE_INVALIDATE_REGION ? PIPE_TRANSFER_DISCARD_RANGE : 0) | (!blocking ? PIPE_TRANSFER_UNSYNCHRONIZED : 0)); - p = pctx->transfer_map(pctx, r.pipe, 0, usage, + p = pipe_transfer_map_box(pctx, r.pipe, 0, (pipe_transfer_usage)usage, box(origin + r.offset, region), &pxfer); if (!p) { pxfer = NULL; throw error(CL_OUT_OF_RESOURCES); } pipe_resource_reference(&pres, r.pipe); } mapping::mapping(mapping &&m) : pctx(m.pctx), pxfer(m.pxfer), pres(m.pres), p(m.p) { diff --git a/src/gallium/state_trackers/nine/buffer9.c b/src/gallium/state_trackers/nine/buffer9.c index ca4e4380277..f215836c966 100644 --- a/src/gallium/state_trackers/nine/buffer9.c +++ b/src/gallium/state_trackers/nine/buffer9.c @@ -364,21 +364,21 @@ NineBuffer9_Lock( struct NineBuffer9 *This, This->maps[This->nmaps].is_pipe_secondary = TRUE; } } else if (Flags & D3DLOCK_NOOVERWRITE && device->csmt_active) This->maps[This->nmaps].is_pipe_secondary = TRUE; if (This->maps[This->nmaps].is_pipe_secondary) pipe = device->pipe_secondary; else pipe = NineDevice9_GetPipe(device); - data = pipe->transfer_map(pipe, This->base.resource, 0, + data = pipe_transfer_map_box(pipe, This->base.resource, 0, usage, &box, &This->maps[This->nmaps].transfer); if (!data) { DBG("pipe::transfer_map failed\n" " usage = %x\n" " box.x = %u\n" " box.width = %u\n", usage, box.x, box.width); if (Flags & D3DLOCK_DONOTWAIT) diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index 127f2ae195b..e2c75a33589 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -311,21 +311,21 @@ NineDevice9_ctor( struct NineDevice9 *This, tmpl.nr_samples = 0; tmpl.usage = PIPE_USAGE_DEFAULT; tmpl.bind = PIPE_BIND_VERTEX_BUFFER; tmpl.flags = 0; This->dummy_vbo = pScreen->resource_create(pScreen, &tmpl); if (!This->dummy_vbo) return D3DERR_OUTOFVIDEOMEMORY; u_box_1d(0, 16, &box); - data = This->context.pipe->transfer_map(This->context.pipe, This->dummy_vbo, 0, + data = pipe_transfer_map_box(This->context.pipe, This->dummy_vbo, 0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE, &box, &transfer); assert(data); assert(transfer); memset(data, 0, 16); This->context.pipe->transfer_unmap(This->context.pipe, transfer); } This->cursor.software = FALSE; @@ -713,21 +713,21 @@ NineDevice9_SetCursorProperties( struct NineDevice9 *This, This->cursor.h = MIN2(surf->desc.Height, 32); hw_cursor = 1; /* always use hw cursor for windowed mode */ } else { This->cursor.w = MIN2(surf->desc.Width, This->cursor.image->width0); This->cursor.h = MIN2(surf->desc.Height, This->cursor.image->height0); hw_cursor = This->cursor.w == 32 && This->cursor.h == 32; } u_box_origin_2d(This->cursor.w, This->cursor.h, &box); - ptr = pipe->transfer_map(pipe, This->cursor.image, 0, + ptr = pipe_transfer_map_box(pipe, This->cursor.image, 0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE, &box, &transfer); if (!ptr) ret_err("Failed to update cursor image.\n", D3DERR_DRIVERINTERNALERROR); This->cursor.hotspot.x = XHotSpot; This->cursor.hotspot.y = YHotSpot; /* Copy cursor image to internal storage. */ @@ -3037,21 +3037,21 @@ NineDevice9_ProcessVertices( struct NineDevice9 *This, pipe_sw->set_stream_output_targets(pipe_sw, 1, &target, offsets); pipe_sw->draw_vbo(pipe_sw, &draw); pipe_sw->set_stream_output_targets(pipe_sw, 0, NULL, 0); pipe_sw->stream_output_target_destroy(pipe_sw, target); u_box_1d(0, VertexCount * so.stride[0] * 4, &box); - map = pipe_sw->transfer_map(pipe_sw, resource, 0, PIPE_TRANSFER_READ, &box, + map = pipe_transfer_map_box(pipe_sw, resource, 0, PIPE_TRANSFER_READ, &box, &transfer); if (!map) { hr = D3DERR_DRIVERINTERNALERROR; goto out; } hr = NineVertexDeclaration9_ConvertStreamOutput(vdecl, dst, DestIndex, VertexCount, map, &so); if (transfer) diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c index c81a05a952b..bfb71e84fda 100644 --- a/src/gallium/state_trackers/nine/nine_state.c +++ b/src/gallium/state_trackers/nine/nine_state.c @@ -2665,21 +2665,21 @@ CSMT_ITEM_NO_WAIT_WITH_COUNTER(nine_context_box_upload, ARG_COPY_REF(struct pipe_box, src_box)) { struct nine_context *context = &device->context; struct pipe_context *pipe = context->pipe; struct pipe_transfer *transfer = NULL; uint8_t *map; /* We just bind dst for the bind count */ (void)dst; - map = pipe->transfer_map(pipe, + map = pipe_transfer_map_box(pipe, res, level, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE, dst_box, &transfer); if (!map) return; /* Note: if formats are the sames, it will revert * to normal memcpy */ (void) util_format_translate_3d(res->format, @@ -3205,21 +3205,21 @@ update_vertex_buffers_sw(struct NineDevice9 *device, int start_vertice, int num_ vtxbuf = state->vtxbuf[i]; buf = NineVertexBuffer9_GetResource(state->stream[i], &offset); DBG("Locking %p (offset %d, length %d)\n", buf, vtxbuf.buffer_offset, num_vertices * vtxbuf.stride); u_box_1d(vtxbuf.buffer_offset + offset + start_vertice * vtxbuf.stride, num_vertices * vtxbuf.stride, &box); - userbuf = pipe->transfer_map(pipe, buf, 0, PIPE_TRANSFER_READ, &box, + userbuf = pipe_transfer_map_box(pipe, buf, 0, PIPE_TRANSFER_READ, &box, &(sw_internal->transfers_so[i])); vtxbuf.is_user_buffer = true; vtxbuf.buffer.user = userbuf; if (!device->driver_caps.user_sw_vbufs) { vtxbuf.buffer.resource = NULL; vtxbuf.is_user_buffer = false; u_upload_data(device->pipe_sw->stream_uploader, 0, box.width, diff --git a/src/gallium/state_trackers/nine/surface9.c b/src/gallium/state_trackers/nine/surface9.c index d917fa1f868..c0d68cddc8a 100644 --- a/src/gallium/state_trackers/nine/surface9.c +++ b/src/gallium/state_trackers/nine/surface9.c @@ -503,21 +503,21 @@ NineSurface9_LockRect( struct NineSurface9 *This, !(This->base.base.container && p_atomic_read(&This->base.base.container->bind)); DBG("mapping pipe_resource %p (level=%u usage=%x)\n", resource, This->level, usage); /* if the object is not bound internally, there can't be any pending * operation with the surface in the queue */ if (no_refs) pipe = nine_context_get_pipe_acquire(This->base.base.device); else pipe = NineDevice9_GetPipe(This->base.base.device); - pLockedRect->pBits = pipe->transfer_map(pipe, resource, + pLockedRect->pBits = pipe_transfer_map_box(pipe, resource, This->level, usage, &box, &This->transfer); if (no_refs) nine_context_get_pipe_release(This->base.base.device); if (!This->transfer) { DBG("transfer_map failed\n"); if (Flags & D3DLOCK_DONOTWAIT) return D3DERR_WASSTILLDRAWING; return D3DERR_INVALIDCALL; } @@ -549,21 +549,21 @@ NineSurface9_UnlockRect( struct NineSurface9 *This ) if (This->data_conversion) { struct pipe_transfer *transfer; uint8_t *dst = This->data; struct pipe_box box; u_box_origin_2d(This->desc.Width, This->desc.Height, &box); pipe = NineDevice9_GetPipe(This->base.base.device); if (!dst) { - dst = pipe->transfer_map(pipe, + dst = pipe_transfer_map_box(pipe, This->base.resource, This->level, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE, &box, &transfer); if (!dst) return D3D_OK; } (void) util_format_translate(This->base.info.format, @@ -696,21 +696,21 @@ NineSurface9_CopyDefaultToMem( struct NineSurface9 *This, assert(This->desc.Width == From->desc.Width); assert(This->desc.Height == From->desc.Height); u_box_origin_2d(This->desc.Width, This->desc.Height, &src_box); src_box.z = From->layer; if (p_atomic_read(&This->pending_uploads_counter)) nine_csmt_process(This->base.base.device); pipe = NineDevice9_GetPipe(This->base.base.device); - p_src = pipe->transfer_map(pipe, r_src, From->level, + p_src = pipe_transfer_map_box(pipe, r_src, From->level, PIPE_TRANSFER_READ, &src_box, &transfer); p_dst = NineSurface9_GetSystemMemPointer(This, 0, 0); assert (p_src && p_dst); util_copy_rect(p_dst, This->base.info.format, This->stride, 0, 0, This->desc.Width, This->desc.Height, p_src, diff --git a/src/gallium/state_trackers/nine/volume9.c b/src/gallium/state_trackers/nine/volume9.c index 62af3e62251..431b9a1c1da 100644 --- a/src/gallium/state_trackers/nine/volume9.c +++ b/src/gallium/state_trackers/nine/volume9.c @@ -326,21 +326,21 @@ NineVolume9_LockBox( struct NineVolume9 *This, pLockedVolume->pBits = NineVolume9_GetSystemMemPointer(This, box.x, box.y, box.z); } else { bool no_refs = !p_atomic_read(&This->base.bind) && !p_atomic_read(&This->base.container->bind); if (no_refs) pipe = nine_context_get_pipe_acquire(This->base.device); else pipe = NineDevice9_GetPipe(This->base.device); pLockedVolume->pBits = - pipe->transfer_map(pipe, resource, This->level, usage, + pipe_transfer_map_box(pipe, resource, This->level, usage, &box, &This->transfer); if (no_refs) nine_context_get_pipe_release(This->base.device); if (!This->transfer) { if (Flags & D3DLOCK_DONOTWAIT) return D3DERR_WASSTILLDRAWING; return D3DERR_DRIVERINTERNALERROR; } pLockedVolume->RowPitch = This->transfer->stride; pLockedVolume->SlicePitch = This->transfer->layer_stride; @@ -373,21 +373,21 @@ NineVolume9_UnlockBox( struct NineVolume9 *This ) if (This->data_conversion) { struct pipe_transfer *transfer; uint8_t *dst = This->data; struct pipe_box box; u_box_3d(0, 0, 0, This->desc.Width, This->desc.Height, This->desc.Depth, &box); pipe = NineDevice9_GetPipe(This->base.device); if (!dst) { - dst = pipe->transfer_map(pipe, + dst = pipe_transfer_map_box(pipe, This->resource, This->level, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE, &box, &transfer); if (!dst) return D3D_OK; } (void) util_format_translate_3d(This->info.format, diff --git a/src/gallium/state_trackers/omx/bellagio/vid_enc.c b/src/gallium/state_trackers/omx/bellagio/vid_enc.c index 1126c4f583d..be7ea0e6d5b 100644 --- a/src/gallium/state_trackers/omx/bellagio/vid_enc.c +++ b/src/gallium/state_trackers/omx/bellagio/vid_enc.c @@ -301,21 +301,21 @@ static OMX_ERRORTYPE enc_AllocateBackTexture(omx_base_PortType *port, buf_templ.depth0 = 1; buf_templ.array_size = 1; *resource = priv->s_pipe->screen->resource_create(priv->s_pipe->screen, &buf_templ); if (!*resource) return OMX_ErrorInsufficientResources; box.width = (*resource)->width0; box.height = (*resource)->height0; box.depth = (*resource)->depth0; - ptr = priv->s_pipe->transfer_map(priv->s_pipe, *resource, 0, PIPE_TRANSFER_WRITE, &box, transfer); + ptr = pipe_transfer_map_box(priv->s_pipe, *resource, 0, PIPE_TRANSFER_WRITE, &box, transfer); if (map) *map = ptr; return OMX_ErrorNone; } static OMX_ERRORTYPE vid_enc_SetParameter(OMX_HANDLETYPE handle, OMX_INDEXTYPE idx, OMX_PTR param) { OMX_COMPONENTTYPE *comp = handle; vid_enc_PrivateType *priv = comp->pComponentPrivate; diff --git a/src/gallium/state_trackers/osmesa/osmesa.c b/src/gallium/state_trackers/osmesa/osmesa.c index 8baec0a0e44..fe9be40b359 100644 --- a/src/gallium/state_trackers/osmesa/osmesa.c +++ b/src/gallium/state_trackers/osmesa/osmesa.c @@ -337,21 +337,21 @@ osmesa_st_framebuffer_flush_front(struct st_context_iface *stctx, } } } /* run the postprocess stage(s) */ pp_run(osmesa->pp, res, res, zsbuf); } u_box_2d(0, 0, res->width0, res->height0, &box); - map = pipe->transfer_map(pipe, res, 0, PIPE_TRANSFER_READ, &box, + map = pipe_transfer_map_box(pipe, res, 0, PIPE_TRANSFER_READ, &box, &transfer); /* * Copy the color buffer from the resource to the user's buffer. */ bpp = util_format_get_blocksize(osbuffer->visual.color_format); src = map; dst = osbuffer->map; if (osmesa->user_row_length) dst_stride = bpp * osmesa->user_row_length; @@ -920,21 +920,21 @@ OSMesaGetDepthBuffer(OSMesaContext c, GLint *width, GLint *height, * Note: we can't really implement this function with gallium as * we did for swrast. We can't just map the resource and leave it * mapped (and there's no OSMesaUnmapDepthBuffer() function) so * we unmap the buffer here and return a 'stale' pointer. This should * actually be OK in most cases where the caller of this function * immediately uses the pointer. */ u_box_2d(0, 0, res->width0, res->height0, &box); - *buffer = pipe->transfer_map(pipe, res, 0, PIPE_TRANSFER_READ, &box, + *buffer = pipe_transfer_map_box(pipe, res, 0, PIPE_TRANSFER_READ, &box, &transfer); if (!*buffer) { return GL_FALSE; } *width = res->width0; *height = res->height0; *bytesPerValue = util_format_get_blocksize(res->format); pipe->transfer_unmap(pipe, transfer); diff --git a/src/gallium/state_trackers/va/buffer.c b/src/gallium/state_trackers/va/buffer.c index deaeb1939fe..dd21b0a4192 100644 --- a/src/gallium/state_trackers/va/buffer.c +++ b/src/gallium/state_trackers/va/buffer.c @@ -125,21 +125,21 @@ vlVaMapBuffer(VADriverContextP ctx, VABufferID buf_id, void **pbuff) } if (buf->derived_surface.resource) { struct pipe_resource *resource; struct pipe_box box = {}; resource = buf->derived_surface.resource; box.width = resource->width0; box.height = resource->height0; box.depth = resource->depth0; - *pbuff = drv->pipe->transfer_map(drv->pipe, resource, 0, PIPE_TRANSFER_WRITE, + *pbuff = pipe_transfer_map_box(drv->pipe, resource, 0, PIPE_TRANSFER_WRITE, &box, &buf->derived_surface.transfer); mtx_unlock(&drv->mutex); if (!buf->derived_surface.transfer || !*pbuff) return VA_STATUS_ERROR_INVALID_BUFFER; if (buf->type == VAEncCodedBufferType) { ((VACodedBufferSegment*)buf->data)->buf = *pbuff; ((VACodedBufferSegment*)buf->data)->size = buf->coded_size; ((VACodedBufferSegment*)buf->data)->next = NULL; diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c index 3f892c9842c..940f8ffc019 100644 --- a/src/gallium/state_trackers/va/image.c +++ b/src/gallium/state_trackers/va/image.c @@ -400,21 +400,21 @@ vlVaGetImage(VADriverContextP ctx, VASurfaceID surface, int x, int y, } for (i = 0; i < vaimage->num_planes; i++) { unsigned width, height; if (!views[i]) continue; vlVaVideoSurfaceSize(surf, i, &width, &height); for (j = 0; j < views[i]->texture->array_size; ++j) { struct pipe_box box = {0, 0, j, width, height, 1}; struct pipe_transfer *transfer; uint8_t *map; - map = drv->pipe->transfer_map(drv->pipe, views[i]->texture, 0, + map = pipe_transfer_map_box(drv->pipe, views[i]->texture, 0, PIPE_TRANSFER_READ, &box, &transfer); if (!map) { mtx_unlock(&drv->mutex); return VA_STATUS_ERROR_OPERATION_FAILED; } if (i == 1 && convert) { u_copy_nv12_to_yv12(data, pitches, i, j, transfer->stride, views[i]->texture->array_size, map, box.width, box.height); @@ -535,21 +535,21 @@ vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, VAImageID image, vlVaVideoSurfaceSize(surf, i, &width, &height); for (j = 0; j < tex->array_size; ++j) { struct pipe_box dst_box = {0, 0, j, width, height, 1}; if (((format == PIPE_FORMAT_YV12) || (format == PIPE_FORMAT_IYUV)) && (surf->buffer->buffer_format == PIPE_FORMAT_NV12) && i == 1) { struct pipe_transfer *transfer = NULL; uint8_t *map = NULL; - map = drv->pipe->transfer_map(drv->pipe, + map = pipe_transfer_map_box(drv->pipe, tex, 0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE, &dst_box, &transfer); if (map == NULL) { mtx_unlock(&drv->mutex); return VA_STATUS_ERROR_OPERATION_FAILED; } diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c index 86041369444..db6d2f85487 100644 --- a/src/gallium/state_trackers/va/surface.c +++ b/src/gallium/state_trackers/va/surface.c @@ -162,21 +162,21 @@ vlVaQuerySurfaceError(VADriverContextP ctx, VASurfaceID render_target, VAStatus } static void upload_sampler(struct pipe_context *pipe, struct pipe_sampler_view *dst, const struct pipe_box *dst_box, const void *src, unsigned src_stride, unsigned src_x, unsigned src_y) { struct pipe_transfer *transfer; void *map; - map = pipe->transfer_map(pipe, dst->texture, 0, PIPE_TRANSFER_WRITE, + map = pipe_transfer_map_box(pipe, dst->texture, 0, PIPE_TRANSFER_WRITE, dst_box, &transfer); if (!map) return; util_copy_rect(map, dst->texture->format, transfer->stride, 0, 0, dst_box->width, dst_box->height, src, src_stride, src_x, src_y); pipe->transfer_unmap(pipe, transfer); } diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c index 8ef826836c1..7eaebb26a91 100644 --- a/src/gallium/state_trackers/vdpau/output.c +++ b/src/gallium/state_trackers/vdpau/output.c @@ -213,21 +213,21 @@ vlVdpOutputSurfaceGetBitsNative(VdpOutputSurface surface, if (!pipe) return VDP_STATUS_INVALID_HANDLE; if (!destination_data || !destination_pitches) return VDP_STATUS_INVALID_POINTER; mtx_lock(&vlsurface->device->mutex); res = vlsurface->sampler_view->texture; box = RectToPipeBox(source_rect, res); - map = pipe->transfer_map(pipe, res, 0, PIPE_TRANSFER_READ, &box, &transfer); + map = pipe_transfer_map_box(pipe, res, 0, PIPE_TRANSFER_READ, &box, &transfer); if (!map) { mtx_unlock(&vlsurface->device->mutex); return VDP_STATUS_RESOURCES; } util_copy_rect(*destination_data, res->format, *destination_pitches, 0, 0, box.width, box.height, map, transfer->stride, 0, 0); pipe_transfer_unmap(pipe, transfer); mtx_unlock(&vlsurface->device->mutex); diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c index 012d3036411..551fd731756 100644 --- a/src/gallium/state_trackers/vdpau/surface.c +++ b/src/gallium/state_trackers/vdpau/surface.c @@ -253,21 +253,21 @@ vlVdpVideoSurfaceGetBitsYCbCr(VdpVideoSurface surface, vlVdpVideoSurfaceSize(vlsurface, i, &width, &height); for (j = 0; j < sv->texture->array_size; ++j) { struct pipe_box box = { 0, 0, j, width, height, 1 }; struct pipe_transfer *transfer; uint8_t *map; - map = pipe->transfer_map(pipe, sv->texture, 0, + map = pipe_transfer_map_box(pipe, sv->texture, 0, PIPE_TRANSFER_READ, &box, &transfer); if (!map) { mtx_unlock(&vlsurface->device->mutex); return VDP_STATUS_RESOURCES; } if (conversion == CONVERSION_NV12_TO_YV12 && i == 1) { u_copy_nv12_to_yv12(destination_data, destination_pitches, i, j, transfer->stride, sv->texture->array_size, map, box.width, box.height); @@ -393,21 +393,21 @@ vlVdpVideoSurfacePutBitsYCbCr(VdpVideoSurface surface, for (j = 0; j < tex->array_size; ++j) { struct pipe_box dst_box = { 0, 0, j, width, height, 1 }; if (conversion == CONVERSION_YV12_TO_NV12 && i == 1) { struct pipe_transfer *transfer; uint8_t *map; - map = pipe->transfer_map(pipe, tex, 0, usage, + map = pipe_transfer_map_box(pipe, tex, 0, usage, &dst_box, &transfer); if (!map) { mtx_unlock(&p_surf->device->mutex); return VDP_STATUS_RESOURCES; } u_copy_nv12_from_yv12(source_data, source_pitches, i, j, transfer->stride, tex->array_size, map, dst_box.width, dst_box.height); diff --git a/src/gallium/state_trackers/xvmc/subpicture.c b/src/gallium/state_trackers/xvmc/subpicture.c index bc26976e282..3eb809da532 100644 --- a/src/gallium/state_trackers/xvmc/subpicture.c +++ b/src/gallium/state_trackers/xvmc/subpicture.c @@ -203,42 +203,42 @@ static Status Validate(Display *dpy, XvPortID port, int surface_type_id, int xvi } static void upload_sampler(struct pipe_context *pipe, struct pipe_sampler_view *dst, const struct pipe_box *dst_box, const void *src, unsigned src_stride, unsigned src_x, unsigned src_y) { struct pipe_transfer *transfer; void *map; - map = pipe->transfer_map(pipe, dst->texture, 0, PIPE_TRANSFER_WRITE, + map = pipe_transfer_map_box(pipe, dst->texture, 0, PIPE_TRANSFER_WRITE, dst_box, &transfer); if (!map) return; util_copy_rect(map, dst->texture->format, transfer->stride, 0, 0, dst_box->width, dst_box->height, src, src_stride, src_x, src_y); pipe->transfer_unmap(pipe, transfer); } static void upload_sampler_convert(struct pipe_context *pipe, struct pipe_sampler_view *dst, const struct pipe_box *dst_box, const XvImage *image, unsigned src_x, unsigned src_y) { struct pipe_transfer *transfer; int i, j; char *map, *src; - map = pipe->transfer_map(pipe, dst->texture, 0, PIPE_TRANSFER_WRITE, + map = pipe_transfer_map_box(pipe, dst->texture, 0, PIPE_TRANSFER_WRITE, dst_box, &transfer); if (!map) return; src = image->data; src += src_y * image->width + src_x; if (image->id == FOURCC_AI44) { /* The format matches what we want, we just have to insert dummy * bytes. So just copy the same value in twice. */ @@ -388,21 +388,21 @@ Status XvMCClearSubpicture(Display *dpy, XvMCSubpicture *subpicture, short x, sh util_format_read_4f(PIPE_FORMAT_B8G8R8A8_UNORM, uc.f, 1, &color, 4, 0, 0, 1, 1); subpicture_priv = subpicture->privData; context_priv = subpicture_priv->context->privData; pipe = context_priv->pipe; dst = subpicture_priv->sampler; /* TODO: Assert clear rect is within bounds? Or clip? */ - map = pipe->transfer_map(pipe, dst->texture, 0, PIPE_TRANSFER_WRITE, + map = pipe_transfer_map_box(pipe, dst->texture, 0, PIPE_TRANSFER_WRITE, &dst_box, &transfer); if (!map) return XvMCBadSubpicture; util_fill_rect(map, dst->texture->format, transfer->stride, 0, 0, dst_box.width, dst_box.height, &uc); pipe->transfer_unmap(pipe, transfer); return Success; } diff --git a/src/gallium/tests/trivial/compute.c b/src/gallium/tests/trivial/compute.c index 443451e13d2..56d3898d2fe 100644 --- a/src/gallium/tests/trivial/compute.c +++ b/src/gallium/tests/trivial/compute.c @@ -197,21 +197,21 @@ static void init_tex(struct context *ctx, int slot, util_format_get_nblocksx(format, w)); int ny = (target == PIPE_BUFFER ? 1 : util_format_get_nblocksy(format, h)); struct pipe_transfer *xfer; char *map; int x, y; *tex = ctx->screen->resource_create(ctx->screen, &ttex); assert(*tex); - map = pipe->transfer_map(pipe, *tex, 0, PIPE_TRANSFER_WRITE, + map = pipe_transfer_map_box(pipe, *tex, 0, PIPE_TRANSFER_WRITE, &(struct pipe_box) { .width = w, .height = h, .depth = 1 }, &xfer); assert(xfer); assert(map); for (y = 0; y < ny; ++y) { for (x = 0; x < nx; ++x) { init(map + y * dy + x * dx, slot, x, y); } @@ -239,21 +239,21 @@ static void check_tex(struct context *ctx, int slot, int ny = (tex->target == PIPE_BUFFER ? 1 : util_format_get_nblocksy(tex->format, tex->height0)); struct pipe_transfer *xfer; char *map; int x, y, i; int err = 0; if (!check) check = default_check; - map = pipe->transfer_map(pipe, tex, 0, PIPE_TRANSFER_READ, + map = pipe_transfer_map_box(pipe, tex, 0, PIPE_TRANSFER_READ, &(struct pipe_box) { .width = tex->width0, .height = tex->height0, .depth = 1 }, &xfer); assert(xfer); assert(map); for (y = 0; y < ny; ++y) { for (x = 0; x < nx; ++x) { uint32_t exp[4]; uint32_t *res = (uint32_t *)(map + y * dy + x * dx); diff --git a/src/gallium/tests/trivial/quad-tex.c b/src/gallium/tests/trivial/quad-tex.c index 1f29306ec04..8b365df3334 100644 --- a/src/gallium/tests/trivial/quad-tex.c +++ b/src/gallium/tests/trivial/quad-tex.c @@ -169,21 +169,21 @@ static void init_prog(struct program *p) t_tmplt.last_level = 0; t_tmplt.bind = PIPE_BIND_RENDER_TARGET; p->tex = p->screen->resource_create(p->screen, &t_tmplt); memset(&box, 0, sizeof(box)); box.width = 2; box.height = 2; box.depth = 1; - ptr = p->pipe->transfer_map(p->pipe, p->tex, 0, PIPE_TRANSFER_WRITE, &box, &t); + ptr = pipe_transfer_map_box(p->pipe, p->tex, 0, PIPE_TRANSFER_WRITE, &box, &t); ptr[0] = 0xffff0000; ptr[1] = 0xff0000ff; ptr[2] = 0xff00ff00; ptr[3] = 0xffffff00; p->pipe->transfer_unmap(p->pipe, t); u_sampler_view_default_template(&v_tmplt, p->tex, p->tex->format); p->view = p->pipe->create_sampler_view(p->pipe, p->tex, &v_tmplt); } diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c index 7d8303615e9..6dadaa93c40 100644 --- a/src/mesa/state_tracker/st_texture.c +++ b/src/mesa/state_tracker/st_texture.c @@ -327,21 +327,21 @@ print_center_pixel(struct pipe_context *pipe, struct pipe_resource *src) struct pipe_box region; ubyte *map; region.x = src->width0 / 2; region.y = src->height0 / 2; region.z = 0; region.width = 1; region.height = 1; region.depth = 1; - map = pipe->transfer_map(pipe, src, 0, PIPE_TRANSFER_READ, ®ion, &xfer); + map = pipe_transfer_map_box(pipe, src, 0, PIPE_TRANSFER_READ, ®ion, &xfer); printf("center pixel: %d %d %d %d\n", map[0], map[1], map[2], map[3]); pipe->transfer_unmap(pipe, xfer); } /** * Copy the image at level=0 in 'src' to the 'dst' resource at 'dstLevel'. * This is used to copy mipmap images from one texture buffer to another. -- 2.17.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev