<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Feb 20, 2015 at 4:30 PM, Laura Ekstrand <span dir="ltr"><<a href="mailto:laura@jlekstrand.net" target="_blank">laura@jlekstrand.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Solves bugs related to the driver not setting up the texture miptree<br>
correctly, leading to faulty PBO uploads and downloads.<br>
---<br>
 src/mesa/drivers/common/meta_tex_subimage.c | 13 +++++++++----<br>
 src/mesa/drivers/dri/i965/intel_tex.c       |  3 ++-<br>
 src/mesa/main/dd.h                          |  1 +<br>
 3 files changed, 12 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/common/meta_tex_subimage.c b/src/mesa/drivers/common/meta_tex_subimage.c<br>
index 68c8273..f4f7716 100644<br>
--- a/src/mesa/drivers/common/meta_tex_subimage.c<br>
+++ b/src/mesa/drivers/common/meta_tex_subimage.c<br>
@@ -51,7 +51,7 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo,<br>
 {<br>
    uint32_t pbo_format;<br>
    GLenum internal_format;<br>
-   unsigned row_stride;<br>
+   unsigned row_stride, image_stride;<br>
    struct gl_buffer_object *buffer_obj;<br>
    struct gl_texture_object *tex_obj;<br>
    struct gl_texture_image *tex_image;<br>
@@ -74,6 +74,8 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo,<br>
    pixels = _mesa_image_address3d(packing, pixels,<br>
                                   width, height, format, type, 0, 0, 0);<br>
    row_stride = _mesa_image_row_stride(packing, width, format, type);<br>
+   image_stride = _mesa_image_image_stride(packing, width, height, format,<br>
+                                           type);<br>
<br>
    if (_mesa_is_bufferobj(packing->BufferObj)) {<br>
       *tmp_pbo = 0;<br>
@@ -89,7 +91,7 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo,<br>
        */<br>
       _mesa_BindBuffer(pbo_target, *tmp_pbo);<br>
<br>
-      _mesa_BufferData(pbo_target, row_stride * height, pixels, GL_STREAM_DRAW);<br>
+      _mesa_BufferData(pbo_target, image_stride * depth, pixels, GL_STREAM_DRAW);<br>
<br>
       buffer_obj = ctx->Unpack.BufferObj;<br>
       pixels = NULL;<br>
@@ -99,9 +101,11 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo,<br>
<br>
    _mesa_GenTextures(1, tmp_tex);<br>
    tex_obj = _mesa_lookup_texture(ctx, *tmp_tex);<br>
-   tex_obj->Target = depth > 1 ? GL_TEXTURE_2D_ARRAY : GL_TEXTURE_2D;<br>
-   tex_obj->Immutable = GL_TRUE;<br>
    _mesa_initialize_texture_object(ctx, tex_obj, *tmp_tex, GL_TEXTURE_2D);<br>
+   /* This must be set after _mesa_initialize_texture_object, not before. */<br>
+   tex_obj->Immutable = GL_TRUE;<br>
+   /* This is required for interactions with ARB_texture_view. */<br>
+   tex_obj->NumLayers = 1;<br>
<br>
    internal_format = _mesa_get_format_base_format(pbo_format);<br>
<br>
@@ -114,6 +118,7 @@ create_texture_for_pbo(struct gl_context *ctx, bool create_pbo,<br>
                                                      buffer_obj,<br>
                                                      (intptr_t)pixels,<br>
                                                      row_stride,<br>
+                                                     image_stride,<br>
                                                      read_only)) {<br>
       _mesa_DeleteTextures(1, tmp_tex);<br>
       _mesa_DeleteBuffers(1, tmp_pbo);<br>
diff --git a/src/mesa/drivers/dri/i965/intel_tex.c b/src/mesa/drivers/dri/i965/intel_tex.c<br>
index 2d3009a..3a0c09a 100644<br>
--- a/src/mesa/drivers/dri/i965/intel_tex.c<br>
+++ b/src/mesa/drivers/dri/i965/intel_tex.c<br>
@@ -305,6 +305,7 @@ intel_set_texture_storage_for_buffer_object(struct gl_context *ctx,<br>
                                             struct gl_buffer_object *buffer_obj,<br>
                                             uint32_t buffer_offset,<br>
                                             uint32_t row_stride,<br>
+                                            uint32_t image_stride,<br>
                                             bool read_only)<br>
 {<br>
    struct brw_context *brw = brw_context(ctx);<br>
@@ -334,7 +335,7 @@ intel_set_texture_storage_for_buffer_object(struct gl_context *ctx,<br>
<br>
    drm_intel_bo *bo = intel_bufferobj_buffer(brw, intel_buffer_obj,<br>
                                              buffer_offset,<br>
-                                             row_stride * image->Height);<br>
+                                             image_stride * image->Depth);<br>
    intel_texobj->mt =<br>
       intel_miptree_create_for_bo(brw, bo,<br>
                                   image->TexFormat,<br>
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h<br>
index ec8662b..9de08e2 100644<br>
--- a/src/mesa/main/dd.h<br>
+++ b/src/mesa/main/dd.h<br>
@@ -429,6 +429,7 @@ struct dd_function_table {<br>
                                             struct gl_buffer_object *bufferObj,<br>
                                             uint32_t buffer_offset,<br>
                                             uint32_t row_stride,<br>
+                                            uint32_t image_stride,<br>
                                             bool read_only);<br></blockquote><div><br></div><div>Given that the next patch fixes it to only use 2D textures, we shouldn't need the changes to the DD table.  In fact, we should take all the stuff about array textures out of the DD table entry, comment, and implementation.  However, that should be done as a seperate patch at the end of the series.  For now, just drop these 3 hunks.<br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
    /**<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.1.0<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>
</font></span></blockquote></div><br></div></div>