On 17.09.2016 13:49, Marek Olšák wrote:
On Tue, Sep 13, 2016 at 11:56 AM, Nicolai Hähnle <nhaeh...@gmail.com> wrote:
From: Nicolai Hähnle <nicolai.haeh...@amd.com>

When passed to winsys->buffer_create, this flag will indicate that we require
a buffer that maps 1:1 with a kernel buffer handle.

This is currently set for all textures, since textures can potentially be
exported to other processes. This is not a huge loss, since the main purpose
of this patch series is to deal with applications that allocate many small
buffers.

A hypothetical application with tons of tiny textures might still benefit
from not setting this flag, but that's not a use case I'm worried about
just now.
---
 src/gallium/drivers/r300/r300_texture.c       | 2 +-
 src/gallium/drivers/radeon/r600_texture.c     | 2 ++
 src/gallium/drivers/radeon/radeon_winsys.h    | 1 +
 src/gallium/winsys/amdgpu/drm/amdgpu_bo.c     | 3 +++
 src/gallium/winsys/radeon/drm/radeon_drm_bo.c | 3 +++
 src/gallium/winsys/radeon/drm/radeon_drm_cs.c | 2 +-
 6 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_texture.c 
b/src/gallium/drivers/r300/r300_texture.c
index 5f459e4..fbac07a 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -1107,21 +1107,21 @@ r300_texture_create_object(struct r300_screen *rscreen,
         tex->domain &= ~RADEON_DOMAIN_GTT;
     }
     /* Just fail if the texture is too large. */
     if (!tex->domain) {
         goto fail;
     }

     /* Create the backing buffer if needed. */
     if (!tex->buf) {
         tex->buf = rws->buffer_create(rws, tex->tex.size_in_bytes, 2048,
-                                      tex->domain, 0);
+                                      tex->domain, RADEON_FLAG_HANDLE);

         if (!tex->buf) {
             goto fail;
         }
     }

     if (SCREEN_DBG_ON(rscreen, DBG_MSAA) && base->nr_samples > 1) {
         fprintf(stderr, "r300: %ix MSAA %s buffer created\n",
                 base->nr_samples,
                 util_format_is_depth_or_stencil(base->format) ? "depth" : 
"color");
diff --git a/src/gallium/drivers/radeon/r600_texture.c 
b/src/gallium/drivers/radeon/r600_texture.c
index 41fd94b..b6e5880 100644
--- a/src/gallium/drivers/radeon/r600_texture.c
+++ b/src/gallium/drivers/radeon/r600_texture.c
@@ -1105,20 +1105,22 @@ r600_texture_create_object(struct pipe_screen *screen,
                        rtex->dcc_offset = align64(rtex->size, 
rtex->surface.dcc_alignment);
                        rtex->size = rtex->dcc_offset + rtex->surface.dcc_size;
                }
        }

        /* Now create the backing buffer. */
        if (!buf) {
                r600_init_resource_fields(rscreen, resource, rtex->size,
                                          rtex->surface.bo_alignment);

+               resource->flags |= RADEON_FLAG_HANDLE;
+
                if (!r600_alloc_resource(rscreen, resource)) {
                        FREE(rtex);
                        return NULL;
                }
        } else {
                resource->buf = buf;
                resource->gpu_address = 
rscreen->ws->buffer_get_virtual_address(resource->buf);
                resource->domains = 
rscreen->ws->buffer_get_initial_domain(resource->buf);
        }

diff --git a/src/gallium/drivers/radeon/radeon_winsys.h 
b/src/gallium/drivers/radeon/radeon_winsys.h
index 809a203..8196358 100644
--- a/src/gallium/drivers/radeon/radeon_winsys.h
+++ b/src/gallium/drivers/radeon/radeon_winsys.h
@@ -45,20 +45,21 @@ enum radeon_bo_layout {
 enum radeon_bo_domain { /* bitfield */
     RADEON_DOMAIN_GTT  = 2,
     RADEON_DOMAIN_VRAM = 4,
     RADEON_DOMAIN_VRAM_GTT = RADEON_DOMAIN_VRAM | RADEON_DOMAIN_GTT
 };

 enum radeon_bo_flag { /* bitfield */
     RADEON_FLAG_GTT_WC =        (1 << 0),
     RADEON_FLAG_CPU_ACCESS =    (1 << 1),
     RADEON_FLAG_NO_CPU_ACCESS = (1 << 2),
+    RADEON_FLAG_HANDLE =        (1 << 3), /* whether get_handle must be 
supported */

But get_handle must always be supported because of inter-API interop.
Maybe the comment should be:
   /* get_handle must return offset=0 */

Or even:
   /* the buffer must not be suballocated */

I'll change the comment.

Nicolai


Marek

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to