<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 22, 2014 at 4:32 PM, Neil Roberts <span dir="ltr"><<a href="mailto:neil@linux.intel.com" target="_blank">neil@linux.intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I just realised I made regular cube map textures stop working via the<br>
blit path with this patch. Here is a v2 which just adds<br>
GL_TEXTURE_CUBE_MAP to the switch in intel_try_pbo_upload. I've tested<br>
that it still works with a hacky tweak to the piglit test case.<br>
<br>
------- >8 --------------- (use git am --scissors to automatically chop here)<br>
<span class=""><br>
intel_try_pbo_upload now iterates over each slice of the uploaded data and<br>
and does a separate blit for each image. This copies in some fiddly details<br>
store_texsubimage in order to handle the image stride correctly for 1D array<br>
textures.<br>
---<br>
src/mesa/drivers/dri/i965/intel_tex.h | 4 +-<br>
</span> src/mesa/drivers/dri/i965/intel_tex_image.c | 116 ++++++++++++++++++-------<br>
src/mesa/drivers/dri/i965/intel_tex_subimage.c | 7 +-<br>
3 files changed, 88 insertions(+), 39 deletions(-)<br>
<span class=""><br>
diff --git a/src/mesa/drivers/dri/i965/intel_tex.h b/src/mesa/drivers/dri/i965/intel_tex.h<br>
index dfe1b03..f941d26 100644<br>
--- a/src/mesa/drivers/dri/i965/intel_tex.h<br>
+++ b/src/mesa/drivers/dri/i965/intel_tex.h<br>
@@ -71,8 +71,8 @@ intel_texsubimage_tiled_memcpy(struct gl_context *ctx,<br>
bool<br>
intel_try_pbo_upload(struct gl_context *ctx,<br>
struct gl_texture_image *image,<br>
- GLint xoffset, GLint yoffset,<br>
- GLsizei width, GLsizei height,<br>
+ GLint xoffset, GLint yoffset, GLint zoffset,<br>
+ GLsizei width, GLsizei height, GLsizei depth,<br>
const struct gl_pixelstore_attrib *unpack,<br>
GLenum format, GLenum type, const void *pixels,<br>
bool for_glTexImage);<br>
diff --git a/src/mesa/drivers/dri/i965/intel_tex_image.c b/src/mesa/drivers/dri/i965/intel_tex_image.c<br>
</span>index b1b49b9..6b8b953 100644<br>
<span class="">--- a/src/mesa/drivers/dri/i965/intel_tex_image.c<br>
+++ b/src/mesa/drivers/dri/i965/intel_tex_image.c<br>
@@ -88,8 +88,8 @@ intel_miptree_create_for_teximage(struct brw_context *brw,<br>
bool<br>
intel_try_pbo_upload(struct gl_context *ctx,<br>
struct gl_texture_image *image,<br>
- GLint xoffset, GLint yoffset,<br>
- GLsizei width, GLsizei height,<br>
+ GLint xoffset, GLint yoffset, GLint zoffset,<br>
+ GLsizei width, GLsizei height, GLsizei depth,<br>
const struct gl_pixelstore_attrib *unpack,<br>
GLenum format, GLenum type, const void *pixels,<br>
bool for_glTexImage)<br>
@@ -99,6 +99,7 @@ intel_try_pbo_upload(struct gl_context *ctx,<br>
struct intel_buffer_object *pbo = intel_buffer_object(unpack->BufferObj);<br>
GLuint src_offset;<br>
drm_intel_bo *src_buffer;<br>
+ int i;<br>
<br>
if (!_mesa_is_bufferobj(unpack->BufferObj))<br>
return false;<br>
</span>@@ -126,47 +127,96 @@ intel_try_pbo_upload(struct gl_context *ctx,<br>
<span class=""> return false;<br>
}<br>
<br>
- if (image->TexObject->Target == GL_TEXTURE_1D_ARRAY ||<br>
- image->TexObject->Target == GL_TEXTURE_2D_ARRAY) {<br>
- DBG("%s: no support for array textures\n", __FUNCTION__);<br>
- return false;<br>
- }<br>
-<br>
int src_stride =<br>
_mesa_image_row_stride(unpack, width, format, type);<br>
+ int dims, num_slices = 1, slice_offset = 0;<br>
+ int src_image_stride = 0;<br>
+<br>
+ switch (image->TexObject->Target) {<br>
+ case GL_TEXTURE_2D:<br>
+ case GL_TEXTURE_RECTANGLE:<br>
</span>+ case GL_TEXTURE_CUBE_MAP:<br>
<div><div class="h5">+ /* one image slice, nothing special needs to be done */<br>
+ dims = 2;<br>
+ src_image_stride = src_stride * height;<br></div></div></blockquote><div><br></div><div>Any reason you're not using _mesa_image_image_stride here?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
+ break;<br>
+ case GL_TEXTURE_1D:<br>
+ dims = 1;<br>
+ src_image_stride = src_stride * height;<br></div></div></blockquote><div><br></div><div>or here?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
+ break;<br>
+ case GL_TEXTURE_1D_ARRAY:<br>
+ num_slices = height;<br>
+ slice_offset = yoffset;<br>
+ height = 1;<br>
+ yoffset = 0;<br>
+ dims = 2;<br>
+ src_image_stride = src_stride;<br></div></div></blockquote><div><br></div><div>or here?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
+ break;<br>
+ case GL_TEXTURE_2D_ARRAY:<br>
+ num_slices = depth;<br>
+ slice_offset = zoffset;<br>
+ depth = 1;<br>
+ zoffset = 0;<br>
+ dims = 3;<br>
+ src_image_stride = _mesa_image_image_stride(unpack, width, height,<br>
+ format, type);<br>
+ break;<br>
+ case GL_TEXTURE_3D:<br>
+ num_slices = depth;<br>
+ slice_offset = zoffset;<br>
+ dims = 3;<br>
+ src_image_stride = _mesa_image_image_stride(unpack, width, height,<br>
+ format, type);<br>
+ break;<br>
+ case GL_TEXTURE_CUBE_MAP_ARRAY:<br>
+ num_slices = depth;<br>
+ slice_offset = zoffset;<br>
+ dims = 3;<br>
+ src_image_stride = _mesa_image_image_stride(unpack, width, height,<br>
+ format, type);<br>
+ break;<br>
+ default:<br>
+ return false;<br>
+ }<br></div></div></blockquote><div><br></div><div>In general, I find this switch statement a big awkward. You could just have dims passed in and slice_offset and num_slices seem to be the same as zoffset and depth. The only exception here being 1-D array textures which are a bit silly and you would have to move the yoffset and height into zoffset and depth, but I think I'd prefer that to the giant switch.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
<br>
/* note: potential 64-bit ptr to 32-bit int cast */<br>
src_offset = (GLuint) (unsigned long) pixels;<br>
- src_offset += _mesa_image_offset(2,<br>
+ src_offset += _mesa_image_offset(dims,<br>
unpack,<br>
width, height,<br>
format, type,<br>
0, 0, 0 /* img/row/column */);<br>
- src_buffer = intel_bufferobj_buffer(brw, pbo,<br>
- src_offset, src_stride * height);<br>
<br>
- struct intel_mipmap_tree *pbo_mt =<br>
- intel_miptree_create_for_bo(brw,<br>
- src_buffer,<br>
- intelImage->mt->format,<br>
- src_offset,<br>
- width, height,<br>
- src_stride);<br>
- if (!pbo_mt)<br>
- return false;<br>
+ for (i = 0; i < num_slices; i++) {<br>
+ src_buffer = intel_bufferobj_buffer(brw, pbo,<br>
+ src_offset, src_stride * height);<br>
+<br>
+ struct intel_mipmap_tree *pbo_mt =<br>
+ intel_miptree_create_for_bo(brw,<br>
+ src_buffer,<br>
+ intelImage->mt->format,<br>
+ src_offset,<br>
+ width, height,<br>
+ src_stride);<br>
+ if (!pbo_mt)<br>
+ return false;<br>
+<br>
+ if (!intel_miptree_blit(brw,<br>
+ pbo_mt, 0, 0,<br>
+ 0, 0, false,<br>
+ intelImage->mt, image->Level,<br>
+ slice_offset + i + image->Face,<br>
+ xoffset, yoffset, false,<br>
+ width, height, GL_COPY)) {<br>
+ DBG("%s: blit failed\n", __FUNCTION__);<br>
+ intel_miptree_release(&pbo_mt);<br>
+ return false;<br>
+ }<br>
<br>
- if (!intel_miptree_blit(brw,<br>
- pbo_mt, 0, 0,<br>
- 0, 0, false,<br>
- intelImage->mt, image->Level, image->Face,<br>
- xoffset, yoffset, false,<br>
- width, height, GL_COPY)) {<br>
- DBG("%s: blit failed\n", __FUNCTION__);<br>
intel_miptree_release(&pbo_mt);<br>
- return false;<br>
- }<br>
<br>
- intel_miptree_release(&pbo_mt);<br>
+ src_offset += src_image_stride;<br>
+ }<br>
<br>
DBG("%s: success\n", __FUNCTION__);<br>
return true;<br>
</div></div>@@ -199,11 +249,11 @@ intelTexImage(struct gl_context * ctx,<br>
<div class="HOEnZb"><div class="h5"><br>
/* Attempt to use the blitter for PBO image uploads.<br>
*/<br>
- if (dims <= 2 &&<br>
- intel_try_pbo_upload(ctx, texImage,<br>
- 0, 0, /* x,y offsets */<br>
+ if (intel_try_pbo_upload(ctx, texImage,<br>
+ 0, 0, 0, /* x,y,z offsets */<br>
texImage->Width,<br>
texImage->Height,<br>
+ texImage->Depth,<br>
unpack, format, type, pixels,<br>
true /*for_glTexImage*/)) {<br>
return;<br>
diff --git a/src/mesa/drivers/dri/i965/intel_tex_subimage.c b/src/mesa/drivers/dri/i965/intel_tex_subimage.c<br>
index dde1591..692e3ec 100644<br>
--- a/src/mesa/drivers/dri/i965/intel_tex_subimage.c<br>
+++ b/src/mesa/drivers/dri/i965/intel_tex_subimage.c<br>
@@ -693,10 +693,9 @@ intelTexSubImage(struct gl_context * ctx,<br>
<br>
/* Attempt to use the blitter for PBO image uploads.<br>
*/<br>
- if (dims <= 2 &&<br>
- intel_try_pbo_upload(ctx, texImage,<br>
- xoffset, yoffset,<br>
- width, height,<br>
+ if (intel_try_pbo_upload(ctx, texImage,<br>
+ xoffset, yoffset, zoffset,<br>
+ width, height, depth,<br>
packing, format, type, pixels,<br>
false /*for_glTexImage*/)) {<br>
return;<br>
--<br>
1.9.3<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</div></div></blockquote></div><br></div></div>