summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2016-07-16 21:19:48 +0200
committerMarek Olšák <[email protected]>2016-07-23 13:33:42 +0200
commit1ffe77e7bb2486ea74cda077ed2a9622b758395c (patch)
tree4a04818614fc8c4e086e9dcd32dbadecbac4b6fb /src/gallium/state_trackers
parent0ba7288376dc66f932336862c8a6abb629b47686 (diff)
gallium: split transfer_inline_write into buffer and texture callbacks
to reduce the call indirections with u_resource_vtbl. The worst call tree you could get was: - u_transfer_inline_write_vtbl - u_default_transfer_inline_write - u_transfer_map_vtbl - driver_transfer_map - u_transfer_unmap_vtbl - driver_transfer_unmap That's 6 indirect calls. Some drivers only had 5. The goal is to have 1 indirect call for drivers that care. The resource type can be determined statically at most call sites. The new interface is: pipe_context::buffer_subdata(ctx, resource, usage, offset, size, data) pipe_context::texture_subdata(ctx, resource, level, usage, box, data, stride, layer_stride) v2: fix whitespace, correct ilo's behavior Reviewed-by: Nicolai Hähnle <[email protected]> Acked-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/clover/core/resource.cpp10
-rw-r--r--src/gallium/state_trackers/nine/buffer9.h8
-rw-r--r--src/gallium/state_trackers/nine/nine_state.c11
-rw-r--r--src/gallium/state_trackers/nine/surface9.c4
-rw-r--r--src/gallium/state_trackers/nine/volume9.c4
-rw-r--r--src/gallium/state_trackers/omx/vid_enc.c12
-rw-r--r--src/gallium/state_trackers/va/image.c8
-rw-r--r--src/gallium/state_trackers/vdpau/bitmap.c6
-rw-r--r--src/gallium/state_trackers/vdpau/output.c20
-rw-r--r--src/gallium/state_trackers/vdpau/surface.c10
10 files changed, 48 insertions, 45 deletions
diff --git a/src/gallium/state_trackers/clover/core/resource.cpp b/src/gallium/state_trackers/clover/core/resource.cpp
index 10a29a94eac..83781d39c01 100644
--- a/src/gallium/state_trackers/clover/core/resource.cpp
+++ b/src/gallium/state_trackers/clover/core/resource.cpp
@@ -161,9 +161,13 @@ root_resource::root_resource(clover::device &dev, memory_obj &obj,
box rect { {{ 0, 0, 0 }}, {{ info.width0, info.height0, info.depth0 }} };
unsigned cpp = util_format_get_blocksize(info.format);
- q.pipe->transfer_inline_write(q.pipe, pipe, 0, PIPE_TRANSFER_WRITE,
- rect, data_ptr, cpp * info.width0,
- cpp * info.width0 * info.height0);
+ if (pipe->target == PIPE_BUFFER)
+ q.pipe->buffer_subdata(q.pipe, pipe, PIPE_TRANSFER_WRITE,
+ 0, info.width0, data_ptr);
+ else
+ q.pipe->texture_subdata(q.pipe, pipe, 0, PIPE_TRANSFER_WRITE,
+ rect, data_ptr, cpp * info.width0,
+ cpp * info.width0 * info.height0);
}
}
diff --git a/src/gallium/state_trackers/nine/buffer9.h b/src/gallium/state_trackers/nine/buffer9.h
index 8bdb4326a4c..c109cf66140 100644
--- a/src/gallium/state_trackers/nine/buffer9.h
+++ b/src/gallium/state_trackers/nine/buffer9.h
@@ -88,10 +88,10 @@ NineBuffer9_Upload( struct NineBuffer9 *This )
struct pipe_context *pipe = This->pipe;
assert(This->base.pool == D3DPOOL_MANAGED && This->managed.dirty);
- pipe->transfer_inline_write(pipe, This->base.resource, 0, 0,
- &This->managed.dirty_box,
- (char *)This->managed.data + This->managed.dirty_box.x,
- This->size, This->size);
+ pipe->buffer_subdata(pipe, This->base.resource, 0,
+ This->managed.dirty_box.x,
+ This->managed.dirty_box.width,
+ (char *)This->managed.data + This->managed.dirty_box.x);
This->managed.dirty = FALSE;
}
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index 6aa63250112..fd098ca68ea 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -86,8 +86,7 @@ prepare_ps_constants_userbuf(struct NineDevice9 *device);
DBG("upload ConstantF [%u .. %u]\n", x, (x) + (c) - 1); \
box.x = (p) * 4 * sizeof(float); \
box.width = (c) * 4 * sizeof(float); \
- pipe->transfer_inline_write(pipe, buf, 0, usage, &box, &((d)[p * 4]), \
- 0, 0); \
+ pipe->buffer_subdata(pipe, buf, usage, box.x, box.width, &((d)[p * 4])); \
} while(0)
/* OK, this is a bit ugly ... */
@@ -186,7 +185,7 @@ upload_constants(struct NineDevice9 *device, unsigned shader_type)
box.x = x;
box.width = c * 4;
DBG("upload ConstantB [%u .. %u]\n", x, x + c - 1);
- pipe->transfer_inline_write(pipe, buf, 0, usage, &box, data_b, 0, 0);
+ pipe->buffer_subdata(pipe, buf, usage, box.x, box.width, data_b);
}
/* int4 */
@@ -203,7 +202,7 @@ upload_constants(struct NineDevice9 *device, unsigned shader_type)
box.x += x * 4 * sizeof(int);
box.width = c * 4 * sizeof(int);
c = 0;
- pipe->transfer_inline_write(pipe, buf, 0, usage, &box, data, 0, 0);
+ pipe->buffer_subdata(pipe, buf, usage, box.x, box.width, data);
}
}
if (c) {
@@ -212,7 +211,7 @@ upload_constants(struct NineDevice9 *device, unsigned shader_type)
box.x = buf->width0 - (NINE_MAX_CONST_I * 4 + NINE_MAX_CONST_B) * 4;
box.x += x * 4 * sizeof(int);
box.width = c * 4 * sizeof(int);
- pipe->transfer_inline_write(pipe, buf, 0, usage, &box, data, 0, 0);
+ pipe->buffer_subdata(pipe, buf, usage, box.x, box.width, data);
}
/* TODO: only upload these when shader itself changes */
@@ -224,7 +223,7 @@ upload_constants(struct NineDevice9 *device, unsigned shader_type)
n += r->end - r->bgn;
box.width = (r->end - r->bgn) * 4 * sizeof(float);
data = &lconstf_data[4 * n];
- pipe->transfer_inline_write(pipe, buf, 0, usage, &box, data, 0, 0);
+ pipe->buffer_subdata(pipe, buf, usage, box.x, box.width, data);
r = r->next;
}
}
diff --git a/src/gallium/state_trackers/nine/surface9.c b/src/gallium/state_trackers/nine/surface9.c
index 2606dbfcfa8..6a4a0d9dc74 100644
--- a/src/gallium/state_trackers/nine/surface9.c
+++ b/src/gallium/state_trackers/nine/surface9.c
@@ -673,8 +673,8 @@ NineSurface9_UploadSelf( struct NineSurface9 *This,
ptr = NineSurface9_GetSystemMemPointer(This, box.x, box.y);
- pipe->transfer_inline_write(pipe, res, This->level, 0,
- &box, ptr, This->stride, 0);
+ pipe->texture_subdata(pipe, res, This->level, 0,
+ &box, ptr, This->stride, 0);
return D3D_OK;
}
diff --git a/src/gallium/state_trackers/nine/volume9.c b/src/gallium/state_trackers/nine/volume9.c
index 1fdc6388197..0302b099931 100644
--- a/src/gallium/state_trackers/nine/volume9.c
+++ b/src/gallium/state_trackers/nine/volume9.c
@@ -496,8 +496,8 @@ NineVolume9_UploadSelf( struct NineVolume9 *This,
ptr = NineVolume9_GetSystemMemPointer(This, box.x, box.y, box.z);
- pipe->transfer_inline_write(pipe, res, This->level, 0, &box,
- ptr, This->stride, This->layer_stride);
+ pipe->texture_subdata(pipe, res, This->level, 0, &box,
+ ptr, This->stride, This->layer_stride);
return D3D_OK;
}
diff --git a/src/gallium/state_trackers/omx/vid_enc.c b/src/gallium/state_trackers/omx/vid_enc.c
index 642238e53f0..0d7ab28fb37 100644
--- a/src/gallium/state_trackers/omx/vid_enc.c
+++ b/src/gallium/state_trackers/omx/vid_enc.c
@@ -905,16 +905,16 @@ static OMX_ERRORTYPE enc_LoadImage(omx_base_PortType *port, OMX_BUFFERHEADERTYPE
box.width = def->nFrameWidth;
box.height = def->nFrameHeight;
box.depth = 1;
- priv->s_pipe->transfer_inline_write(priv->s_pipe, views[0]->texture, 0,
- PIPE_TRANSFER_WRITE, &box,
- ptr, def->nStride, 0);
+ priv->s_pipe->texture_subdata(priv->s_pipe, views[0]->texture, 0,
+ PIPE_TRANSFER_WRITE, &box,
+ ptr, def->nStride, 0);
ptr = ((uint8_t*)buf->pBuffer) + (def->nStride * box.height);
box.width = def->nFrameWidth / 2;
box.height = def->nFrameHeight / 2;
box.depth = 1;
- priv->s_pipe->transfer_inline_write(priv->s_pipe, views[1]->texture, 0,
- PIPE_TRANSFER_WRITE, &box,
- ptr, def->nStride, 0);
+ priv->s_pipe->texture_subdata(priv->s_pipe, views[1]->texture, 0,
+ PIPE_TRANSFER_WRITE, &box,
+ ptr, def->nStride, 0);
} else {
struct pipe_blit_info blit;
struct vl_video_buffer *dst_buf = (struct vl_video_buffer *)vbuf;
diff --git a/src/gallium/state_trackers/va/image.c b/src/gallium/state_trackers/va/image.c
index 1b956e36bc1..36b24695edf 100644
--- a/src/gallium/state_trackers/va/image.c
+++ b/src/gallium/state_trackers/va/image.c
@@ -515,10 +515,10 @@ vlVaPutImage(VADriverContextP ctx, VASurfaceID surface, VAImageID image,
vlVaVideoSurfaceSize(surf, i, &width, &height);
for (j = 0; j < views[i]->texture->array_size; ++j) {
struct pipe_box dst_box = {0, 0, j, width, height, 1};
- drv->pipe->transfer_inline_write(drv->pipe, views[i]->texture, 0,
- PIPE_TRANSFER_WRITE, &dst_box,
- data[i] + pitches[i] * j,
- pitches[i] * views[i]->texture->array_size, 0);
+ drv->pipe->texture_subdata(drv->pipe, views[i]->texture, 0,
+ PIPE_TRANSFER_WRITE, &dst_box,
+ data[i] + pitches[i] * j,
+ pitches[i] * views[i]->texture->array_size, 0);
}
}
pipe_mutex_unlock(drv->mutex);
diff --git a/src/gallium/state_trackers/vdpau/bitmap.c b/src/gallium/state_trackers/vdpau/bitmap.c
index 35c8820433d..fd67a986c61 100644
--- a/src/gallium/state_trackers/vdpau/bitmap.c
+++ b/src/gallium/state_trackers/vdpau/bitmap.c
@@ -201,9 +201,9 @@ vlVdpBitmapSurfacePutBitsNative(VdpBitmapSurface surface,
vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL);
dst_box = RectToPipeBox(destination_rect, vlsurface->sampler_view->texture);
- pipe->transfer_inline_write(pipe, vlsurface->sampler_view->texture, 0,
- PIPE_TRANSFER_WRITE, &dst_box, *source_data,
- *source_pitches, 0);
+ pipe->texture_subdata(pipe, vlsurface->sampler_view->texture, 0,
+ PIPE_TRANSFER_WRITE, &dst_box, *source_data,
+ *source_pitches, 0);
pipe_mutex_unlock(vlsurface->device->mutex);
diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c
index 8a064e849b6..0b4f081be3e 100644
--- a/src/gallium/state_trackers/vdpau/output.c
+++ b/src/gallium/state_trackers/vdpau/output.c
@@ -257,9 +257,9 @@ vlVdpOutputSurfacePutBitsNative(VdpOutputSurface surface,
vlVdpResolveDelayedRendering(vlsurface->device, NULL, NULL);
dst_box = RectToPipeBox(destination_rect, vlsurface->sampler_view->texture);
- pipe->transfer_inline_write(pipe, vlsurface->sampler_view->texture, 0,
- PIPE_TRANSFER_WRITE, &dst_box, *source_data,
- *source_pitches, 0);
+ pipe->texture_subdata(pipe, vlsurface->sampler_view->texture, 0,
+ PIPE_TRANSFER_WRITE, &dst_box, *source_data,
+ *source_pitches, 0);
pipe_mutex_unlock(vlsurface->device->mutex);
return VDP_STATUS_OK;
@@ -346,9 +346,9 @@ vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface,
box.height = res->height0;
box.depth = res->depth0;
- context->transfer_inline_write(context, res, 0, PIPE_TRANSFER_WRITE, &box,
- source_data[0], source_pitch[0],
- source_pitch[0] * res->height0);
+ context->texture_subdata(context, res, 0, PIPE_TRANSFER_WRITE, &box,
+ source_data[0], source_pitch[0],
+ source_pitch[0] * res->height0);
memset(&sv_tmpl, 0, sizeof(sv_tmpl));
u_sampler_view_default_template(&sv_tmpl, res, res->format);
@@ -379,8 +379,8 @@ vlVdpOutputSurfacePutBitsIndexed(VdpOutputSurface surface,
box.height = res->height0;
box.depth = res->depth0;
- context->transfer_inline_write(context, res, 0, PIPE_TRANSFER_WRITE, &box, color_table,
- util_format_get_stride(colortbl_format, res->width0), 0);
+ context->texture_subdata(context, res, 0, PIPE_TRANSFER_WRITE, &box, color_table,
+ util_format_get_stride(colortbl_format, res->width0), 0);
memset(&sv_tmpl, 0, sizeof(sv_tmpl));
u_sampler_view_default_template(&sv_tmpl, res, res->format);
@@ -485,8 +485,8 @@ vlVdpOutputSurfacePutBitsYCbCr(VdpOutputSurface surface,
sv->texture->width0, sv->texture->height0, 1
};
- pipe->transfer_inline_write(pipe, sv->texture, 0, PIPE_TRANSFER_WRITE, &dst_box,
- source_data[i], source_pitches[i], 0);
+ pipe->texture_subdata(pipe, sv->texture, 0, PIPE_TRANSFER_WRITE, &dst_box,
+ source_data[i], source_pitches[i], 0);
}
if (!csc_matrix) {
diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c
index 7998527b2d1..6dc479a6726 100644
--- a/src/gallium/state_trackers/vdpau/surface.c
+++ b/src/gallium/state_trackers/vdpau/surface.c
@@ -359,11 +359,11 @@ vlVdpVideoSurfacePutBitsYCbCr(VdpVideoSurface surface,
width, height, 1
};
- pipe->transfer_inline_write(pipe, sv->texture, 0,
- PIPE_TRANSFER_WRITE, &dst_box,
- source_data[i] + source_pitches[i] * j,
- source_pitches[i] * sv->texture->array_size,
- 0);
+ pipe->texture_subdata(pipe, sv->texture, 0,
+ PIPE_TRANSFER_WRITE, &dst_box,
+ source_data[i] + source_pitches[i] * j,
+ source_pitches[i] * sv->texture->array_size,
+ 0);
}
}
pipe_mutex_unlock(p_surf->device->mutex);