[Mesa-dev] [PATCH 10/22] i965: Support direct upload into texture arrays
Chris Wilson
chris at chris-wilson.co.uk
Sat Aug 5 09:40:02 UTC 2017
Iterate the tiled_memcpy for each face so that we can quickly do
synchronous uploads into cube maps etc.
---
src/mesa/drivers/dri/i965/intel_tex_subimage.c | 67 +++++++++++++++-----------
1 file changed, 39 insertions(+), 28 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/intel_tex_subimage.c b/src/mesa/drivers/dri/i965/intel_tex_subimage.c
index c1e365f8f1..56c6cbf7b8 100644
--- a/src/mesa/drivers/dri/i965/intel_tex_subimage.c
+++ b/src/mesa/drivers/dri/i965/intel_tex_subimage.c
@@ -82,7 +82,6 @@ intel_texsubimage_tiled_memcpy(struct gl_context * ctx,
{
struct brw_context *brw = brw_context(ctx);
struct intel_texture_image *image = intel_texture_image(texImage);
- int src_pitch;
/* The miptree's buffer. */
struct brw_bo *bo;
@@ -98,9 +97,7 @@ intel_texsubimage_tiled_memcpy(struct gl_context * ctx,
* with _mesa_image_row_stride. However, before removing the restrictions
* we need tests.
*/
- if (!(texImage->TexObject->Target == GL_TEXTURE_2D ||
- texImage->TexObject->Target == GL_TEXTURE_RECTANGLE) ||
- pixels == NULL ||
+ if (pixels == NULL ||
_mesa_is_bufferobj(packing->BufferObj) ||
packing->SwapBytes ||
packing->LsbFirst ||
@@ -118,10 +115,6 @@ intel_texsubimage_tiled_memcpy(struct gl_context * ctx,
if (mem_copy == NULL)
return false;
- /* If this is a nontrivial texture view, let another path handle it instead. */
- if (texImage->TexObject->MinLayer)
- return false;
-
if (for_glTexImage)
ctx->Driver.AllocTextureImageBuffer(ctx, texImage);
@@ -157,9 +150,6 @@ intel_texsubimage_tiled_memcpy(struct gl_context * ctx,
assert(image->mt->surf.logical_level0_px.depth == 1);
assert(image->mt->surf.logical_level0_px.array_len == 1);
- int level = texImage->Level + texImage->TexObject->MinLevel;
- intel_miptree_access_raw(brw, image->mt, level, 0, true);
-
if (brw_batch_references(&brw->batch, bo)) {
perf_debug("Flushing before mapping a referenced bo.\n");
intel_batchbuffer_flush(brw);
@@ -171,7 +161,7 @@ intel_texsubimage_tiled_memcpy(struct gl_context * ctx,
return false;
}
- src_pitch = _mesa_image_row_stride(packing, width, format, type);
+ int src_pitch = _mesa_image_row_stride(packing, width, format, type);
/* We postponed printing this message until having committed to executing
* the function.
@@ -185,26 +175,47 @@ intel_texsubimage_tiled_memcpy(struct gl_context * ctx,
packing->Alignment, packing->RowLength, packing->SkipPixels,
packing->SkipRows, for_glTexImage);
- /* Adjust x and y offset based on miplevel */
- unsigned level_x, level_y;
- intel_miptree_get_image_offset(image->mt, level, 0, &level_x, &level_y);
- xoffset += level_x;
- yoffset += level_y;
+ int image_height = packing->ImageHeight == 0 ? height : packing->ImageHeight;
+ if (texImage->TexObject->Target == GL_TEXTURE_1D_ARRAY) {
+ assert(depth == 1);
+ assert(zoffset == 0);
+ depth = height;
+ height = 1;
+ image_height = 1;
+ zoffset = yoffset;
+ yoffset = 0;
+ }
pixels = _mesa_image_address(dims, packing, pixels, width, height,
format, type, 0, 0, 0);
-
uint32_t cpp = _mesa_get_format_bytes(texImage->TexFormat);
- linear_to_tiled(
- xoffset * cpp, (xoffset + width) * cpp,
- yoffset, yoffset + height,
- map,
- pixels - (ptrdiff_t) yoffset * src_pitch - (ptrdiff_t) xoffset * cpp,
- image->mt->surf.row_pitch, src_pitch,
- brw->has_swizzling,
- image->mt->surf.tiling,
- mem_copy
- );
+
+ int level = texImage->Level + texImage->TexObject->MinLevel;
+ int slice = texImage->Face + texImage->TexObject->MinLayer + zoffset;
+
+ for (zoffset = 0; depth--; zoffset++) {
+ intel_miptree_access_raw(brw, image->mt, level, slice + zoffset, true);
+
+ /* Adjust x and y offset based on miplevel */
+ unsigned level_x, level_y;
+ intel_miptree_get_image_offset(image->mt, level, slice + zoffset,
+ &level_x, &level_y);
+ level_x += xoffset;
+ level_y += yoffset;
+
+ linear_to_tiled(
+ level_x * cpp, (level_x + width) * cpp,
+ level_y, level_y + height,
+ map,
+ pixels - (ptrdiff_t) level_y * src_pitch - (ptrdiff_t) level_x * cpp,
+ image->mt->surf.row_pitch, src_pitch,
+ brw->has_swizzling,
+ image->mt->surf.tiling,
+ mem_copy
+ );
+
+ pixels += image_height * src_pitch;
+ }
brw_bo_unmap(bo);
return true;
--
2.13.3
More information about the mesa-dev
mailing list