summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/vl
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2012-10-08 04:06:42 +0200
committerMarek Olšák <[email protected]>2012-10-11 21:12:16 +0200
commit369e46888904c6d379b8b477d9242cff1608e30e (patch)
tree528b10f900f23af3acd22a0edcf50fde0eeee86e /src/gallium/auxiliary/vl
parentec4c74a9dc10039d97ad24c4f16bd2400517991d (diff)
gallium: unify transfer functions
"get_transfer + transfer_map" becomes "transfer_map". "transfer_unmap + transfer_destroy" becomes "transfer_unmap". transfer_map must create and return the transfer object and transfer_unmap must destroy it. transfer_map is successful if the returned buffer pointer is not NULL. If transfer_map fails, the pointer to the transfer object remains unchanged (i.e. doesn't have to be NULL). Acked-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/vl')
-rw-r--r--src/gallium/auxiliary/vl/vl_idct.c22
-rw-r--r--src/gallium/auxiliary/vl/vl_mpeg12_decoder.c13
-rw-r--r--src/gallium/auxiliary/vl/vl_zscan.c45
3 files changed, 22 insertions, 58 deletions
diff --git a/src/gallium/auxiliary/vl/vl_idct.c b/src/gallium/auxiliary/vl/vl_idct.c
index f848a78d18a..5adc72f7db6 100644
--- a/src/gallium/auxiliary/vl/vl_idct.c
+++ b/src/gallium/auxiliary/vl/vl_idct.c
@@ -713,28 +713,21 @@ vl_idct_upload_matrix(struct pipe_context *pipe, float scale)
if (!matrix)
goto error_matrix;
- buf_transfer = pipe->get_transfer
- (
- pipe, matrix,
- 0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE,
- &rect
- );
- if (!buf_transfer)
- goto error_transfer;
-
- pitch = buf_transfer->stride / sizeof(float);
-
- f = pipe->transfer_map(pipe, buf_transfer);
+ f = pipe->transfer_map(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)
// transpose and scale
f[i * pitch + j] = ((const float (*)[8])const_matrix)[j][i] * scale;
pipe->transfer_unmap(pipe, buf_transfer);
- pipe->transfer_destroy(pipe, buf_transfer);
memset(&sv_templ, 0, sizeof(sv_templ));
u_sampler_view_default_template(&sv_templ, matrix, matrix->format);
@@ -746,9 +739,6 @@ vl_idct_upload_matrix(struct pipe_context *pipe, float scale)
return sv;
error_map:
- pipe->transfer_destroy(pipe, buf_transfer);
-
-error_transfer:
pipe_resource_reference(&matrix, NULL);
error_matrix:
diff --git a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
index 31d96fd316c..4614c8abd37 100644
--- a/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
+++ b/src/gallium/auxiliary/vl/vl_mpeg12_decoder.c
@@ -545,15 +545,13 @@ vl_mpeg12_begin_frame(struct pipe_video_decoder *decoder,
rect.width = tex->width0;
rect.height = tex->height0;
- buf->tex_transfer = dec->base.context->get_transfer
- (
- dec->base.context, tex,
- 0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE,
- &rect
- );
+ buf->texels =
+ dec->base.context->transfer_map(dec->base.context, tex, 0,
+ PIPE_TRANSFER_WRITE |
+ PIPE_TRANSFER_DISCARD_RANGE,
+ &rect, &buf->tex_transfer);
buf->block_num = 0;
- buf->texels = dec->base.context->transfer_map(dec->base.context, buf->tex_transfer);
for (i = 0; i < VL_NUM_COMPONENTS; ++i) {
buf->ycbcr_stream[i] = vl_vb_get_ycbcr_stream(&buf->vertex_stream, i);
@@ -690,7 +688,6 @@ vl_mpeg12_end_frame(struct pipe_video_decoder *decoder,
vl_vb_unmap(&buf->vertex_stream, dec->base.context);
dec->base.context->transfer_unmap(dec->base.context, buf->tex_transfer);
- dec->base.context->transfer_destroy(dec->base.context, buf->tex_transfer);
vb[0] = dec->quads;
vb[1] = dec->pos;
diff --git a/src/gallium/auxiliary/vl/vl_zscan.c b/src/gallium/auxiliary/vl/vl_zscan.c
index 1f0939b1dc3..53c2e801c2d 100644
--- a/src/gallium/auxiliary/vl/vl_zscan.c
+++ b/src/gallium/auxiliary/vl/vl_zscan.c
@@ -381,21 +381,14 @@ vl_zscan_layout(struct pipe_context *pipe, const int layout[64], unsigned blocks
if (!res)
goto error_resource;
- buf_transfer = pipe->get_transfer
- (
- pipe, res,
- 0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE,
- &rect
- );
- if (!buf_transfer)
- goto error_transfer;
-
- pitch = buf_transfer->stride / sizeof(float);
-
- f = pipe->transfer_map(pipe, buf_transfer);
+ f = pipe->transfer_map(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) {
@@ -408,7 +401,6 @@ vl_zscan_layout(struct pipe_context *pipe, const int layout[64], unsigned blocks
}
pipe->transfer_unmap(pipe, buf_transfer);
- pipe->transfer_destroy(pipe, buf_transfer);
memset(&sv_tmpl, 0, sizeof(sv_tmpl));
u_sampler_view_default_template(&sv_tmpl, res, res->format);
@@ -420,9 +412,6 @@ vl_zscan_layout(struct pipe_context *pipe, const int layout[64], unsigned blocks
return sv;
error_map:
- pipe->transfer_destroy(pipe, buf_transfer);
-
-error_transfer:
pipe_resource_reference(&res, NULL);
error_resource:
@@ -560,33 +549,21 @@ vl_zscan_upload_quant(struct vl_zscan *zscan, struct vl_zscan_buffer *buffer,
rect.width *= zscan->blocks_per_line;
- buf_transfer = pipe->get_transfer
- (
- pipe, buffer->quant->texture,
- 0, PIPE_TRANSFER_WRITE | PIPE_TRANSFER_DISCARD_RANGE,
- &rect
- );
- if (!buf_transfer)
- goto error_transfer;
+ data = pipe->transfer_map(pipe, buffer->quant->texture,
+ 0, PIPE_TRANSFER_WRITE |
+ PIPE_TRANSFER_DISCARD_RANGE,
+ &rect, &buf_transfer);
+ if (!data)
+ return;
pitch = buf_transfer->stride;
- data = pipe->transfer_map(pipe, buf_transfer);
- if (!data)
- goto error_map;
-
for (i = 0; i < zscan->blocks_per_line; ++i)
for (y = 0; y < VL_BLOCK_HEIGHT; ++y)
for (x = 0; x < VL_BLOCK_WIDTH; ++x)
data[i * VL_BLOCK_WIDTH + y * pitch + x] = matrix[x + y * VL_BLOCK_WIDTH];
pipe->transfer_unmap(pipe, buf_transfer);
-
-error_map:
- pipe->transfer_destroy(pipe, buf_transfer);
-
-error_transfer:
- return;
}
void