Module: Mesa
Branch: master
Commit: d8988f048fd963eeddf33c682d64ebdfaa2de9ae
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=d8988f048fd963eeddf33c682d64ebdfaa2de9ae

Author: Lucas Stach <d...@lynxeye.de>
Date:   Wed Oct 31 16:31:12 2012 +0100

nv50,nvc0: expose ARB_map_buffer_alignment

All HW buffers (also suballocated ones) are already aligned.
Just make sure that also the initial sysram buffers have proper
alignment.

---

 src/gallium/drivers/nouveau/nouveau_buffer.c |    6 +++---
 src/gallium/drivers/nouveau/nouveau_mm.c     |    2 +-
 src/gallium/drivers/nv50/nv50_screen.c       |    3 ++-
 src/gallium/drivers/nvc0/nvc0_screen.c       |    3 ++-
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/gallium/drivers/nouveau/nouveau_buffer.c 
b/src/gallium/drivers/nouveau/nouveau_buffer.c
index fb929d6..0ecd53a 100644
--- a/src/gallium/drivers/nouveau/nouveau_buffer.c
+++ b/src/gallium/drivers/nouveau/nouveau_buffer.c
@@ -43,7 +43,7 @@ nouveau_buffer_allocate(struct nouveau_screen *screen,
    }
    if (domain != NOUVEAU_BO_GART) {
       if (!buf->data) {
-         buf->data = MALLOC(buf->base.width0);
+         buf->data = align_malloc(buf->base.width0, 64);
          if (!buf->data)
             return FALSE;
       }
@@ -92,7 +92,7 @@ nouveau_buffer_destroy(struct pipe_screen *pscreen,
    nouveau_buffer_release_gpu_storage(res);
 
    if (res->data && !(res->status & NOUVEAU_BUFFER_STATUS_USER_MEMORY))
-      FREE(res->data);
+      align_free(res->data);
 
    nouveau_fence_ref(NULL, &res->fence);
    nouveau_fence_ref(NULL, &res->fence_wr);
@@ -457,7 +457,7 @@ nouveau_buffer_migrate(struct nouveau_context *nv,
       if (ret)
          return ret;
       memcpy((uint8_t *)buf->bo->map + buf->offset, buf->data, size);
-      FREE(buf->data);
+      align_free(buf->data);
    } else
    if (old_domain != 0 && new_domain != 0) {
       struct nouveau_mm_allocation *mm = buf->mm;
diff --git a/src/gallium/drivers/nouveau/nouveau_mm.c 
b/src/gallium/drivers/nouveau/nouveau_mm.c
index 4207084..6045af6 100644
--- a/src/gallium/drivers/nouveau/nouveau_mm.c
+++ b/src/gallium/drivers/nouveau/nouveau_mm.c
@@ -9,7 +9,7 @@
 #include "nouveau_screen.h"
 #include "nouveau_mm.h"
 
-#define MM_MIN_ORDER 7
+#define MM_MIN_ORDER 7 /* >= 6 to not violate ARB_map_buffer_alignment */
 #define MM_MAX_ORDER 20
 
 #define MM_NUM_BUCKETS (MM_MAX_ORDER - MM_MIN_ORDER + 1)
diff --git a/src/gallium/drivers/nv50/nv50_screen.c 
b/src/gallium/drivers/nv50/nv50_screen.c
index 9461af9..d0a0295 100644
--- a/src/gallium/drivers/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nv50/nv50_screen.c
@@ -170,11 +170,12 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
       return 1;
    case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT:
       return 256;
+   case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
+      return 64;
    case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
    case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
    case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
    case PIPE_CAP_TEXTURE_MULTISAMPLE:
-   case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
       return 0;
    default:
       NOUVEAU_ERR("unknown PIPE_CAP %d\n", param);
diff --git a/src/gallium/drivers/nvc0/nvc0_screen.c 
b/src/gallium/drivers/nvc0/nvc0_screen.c
index 0e0b666..3bf2191 100644
--- a/src/gallium/drivers/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nvc0/nvc0_screen.c
@@ -148,11 +148,12 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum 
pipe_cap param)
       return 1;
    case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT:
       return 256;
+   case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
+      return 64;
    case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
    case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
    case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
    case PIPE_CAP_TEXTURE_MULTISAMPLE:
-   case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
       return 0;
    default:
       NOUVEAU_ERR("unknown PIPE_CAP %d\n", param);

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to