st: Pass TextureTiling option from texture to memory obj
authorEduardo Lima Mitev <elima@igalia.com>
Thu, 7 May 2020 15:28:44 +0000 (17:28 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 18 Aug 2020 20:40:40 +0000 (20:40 +0000)
If tiling is linear, also adds the corresponding pipe bind flag
to the resource template when creating a new resource from the
memory object.

Modified TexParameteri to update the TextureTiling option only when the
texObj is not immutable (before TexStorageMem*DEXT is called to create
the texture from external memory).

v2: Ensure that memory object is not NULL before setting the
TextureTiling option (fixes TexStorage*D).

v3: Also add flag PIPE_SHARED to bindings (needed for some gallium
drivers).

v4: Use PIPE_BIND_LINEAR instead of adding a new PIPE_RESOURCE_FLAG
(Marek Olšák)

Co-authored-by: Eduardo Lima Mitev <elima@igalia.com>
Co-authored-by: Eleni Maria Stea <estea@igalia.com>
Co-authored-by: Hyunjun Ko <zzoon@igalia.com>
Reviewed-by: Rohan Garg <rohan.garg@collabora.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4565>

src/mesa/main/texparam.c
src/mesa/state_tracker/st_cb_memoryobjects.h
src/mesa/state_tracker/st_cb_texture.c

index 196ac83cd3841dbebd65a39d587089e8b5c2ed50..7a2829d6a2a57ca42b95cefb8f32c1902cae1591 100644 (file)
@@ -602,8 +602,8 @@ set_tex_parameteri(struct gl_context *ctx,
       goto invalid_pname;
 
    case GL_TEXTURE_TILING_EXT:
       goto invalid_pname;
 
    case GL_TEXTURE_TILING_EXT:
-      if (ctx->Extensions.EXT_memory_object) {
-         texObj->TextureTiling = params[0];
+      if (ctx->Extensions.EXT_memory_object && !texObj->Immutable) {
+            texObj->TextureTiling = params[0];
 
          return GL_TRUE;
       }
 
          return GL_TRUE;
       }
index f05475afbcab52653c2f003ee40481d241dbb390..565768ebad9c51c384677f3479fe9aee5d355913 100644 (file)
@@ -34,6 +34,9 @@ struct st_memory_object
 {
    struct gl_memory_object Base;
    struct pipe_memory_object *memory;
 {
    struct gl_memory_object Base;
    struct pipe_memory_object *memory;
+
+   /* TEXTURE_TILING_EXT param from gl_texture_object */
+   GLuint TextureTiling;
 };
 
 static inline struct st_memory_object *
 };
 
 static inline struct st_memory_object *
index a2d7aa6a6d3ce1dbf4973756ffa4724bf37de52b..d92a48a5fcfeb2752dc0f365fce0c008469cd4f3 100644 (file)
@@ -2907,6 +2907,9 @@ st_texture_create_from_memory(struct st_context *st,
    pt.bind = bind;
    /* only set this for OpenGL textures, not renderbuffers */
    pt.flags = PIPE_RESOURCE_FLAG_TEXTURING_MORE_LIKELY;
    pt.bind = bind;
    /* only set this for OpenGL textures, not renderbuffers */
    pt.flags = PIPE_RESOURCE_FLAG_TEXTURING_MORE_LIKELY;
+   if (memObj->TextureTiling == GL_LINEAR_TILING_EXT)
+      pt.bind |= PIPE_BIND_LINEAR;
+
    pt.nr_samples = nr_samples;
    pt.nr_storage_samples = nr_samples;
 
    pt.nr_samples = nr_samples;
    pt.nr_storage_samples = nr_samples;
 
@@ -2951,6 +2954,11 @@ st_texture_storage(struct gl_context *ctx,
 
    bindings = default_bindings(st, fmt);
 
 
    bindings = default_bindings(st, fmt);
 
+   if (smObj) {
+      smObj->TextureTiling = texObj->TextureTiling;
+      bindings |= PIPE_BIND_SHARED;
+   }
+
    if (num_samples > 0) {
       /* Find msaa sample count which is actually supported.  For example,
        * if the user requests 1x but only 4x or 8x msaa is supported, we'll
    if (num_samples > 0) {
       /* Find msaa sample count which is actually supported.  For example,
        * if the user requests 1x but only 4x or 8x msaa is supported, we'll