gallium: expose ARB_map_buffer_alignment on Radeon
authorMarek Olšák <maraeo@gmail.com>
Sun, 28 Oct 2012 16:52:48 +0000 (17:52 +0100)
committerMarek Olšák <maraeo@gmail.com>
Wed, 31 Oct 2012 00:53:50 +0000 (01:53 +0100)
Reviewed-by: Brian Paul <brianp@vmware.com>
v2: update relnotes-9.1
v3: use align_malloc and align_free for malloced buffers in r300g
v4: document the new CAP in the docs

16 files changed:
docs/GL3.txt
docs/relnotes-9.1.html
src/gallium/docs/source/screen.rst
src/gallium/drivers/i915/i915_screen.c
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/nv30/nv30_screen.c
src/gallium/drivers/nv50/nv50_screen.c
src/gallium/drivers/nvc0/nvc0_screen.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/r300/r300_screen_buffer.c
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/radeonsi/radeonsi_pipe.c
src/gallium/drivers/softpipe/sp_screen.c
src/gallium/drivers/svga/svga_screen.c
src/gallium/include/pipe/p_defines.h
src/mesa/state_tracker/st_extensions.c

index 4efe4bfebf37f1d80fa09090c3b9bc7262973468..4f44764c2c58a631f997e643290fd91c00a1f8dc 100644 (file)
@@ -127,7 +127,7 @@ GL_ARB_shader_image_load_store                       not started
 GL_ARB_conservative_depth                            DONE (softpipe)
 GL_ARB_shading_language_420pack                      not started
 GL_ARB_internalformat_query                          not started
-GL_ARB_map_buffer_alignment                          not started
+GL_ARB_map_buffer_alignment                          DONE (r300, r600, radeonsi)
 
 
 GL 4.3:
index 19bea7facd3d1b4ca0a8ddf93fa64e3b4ce92a0c..5bf9d8c137de64d40ab7d4d02a5bb18ef10dbe2b 100644 (file)
@@ -44,7 +44,7 @@ Note: some of the new features are only available with certain drivers.
 </p>
 
 <ul>
-<li>tbd</li>
+<li>GL_ARB_map_buffer_alignment</li>
 </ul>
 
 
index 7a5568477f042299221b2b7803515fb298495533..6c89171cd7311158bea043d4523c80d2f23d7632 100644 (file)
@@ -130,6 +130,12 @@ The integer capabilities:
   pipe_draw_info::start_instance.
 * ``PIPE_CAP_QUERY_TIMESTAMP``: Whether PIPE_QUERY_TIMESTAMP and
   the pipe_screen::get_timestamp hook are implemented.
+* ``PIPE_CAP_TEXTURE_MULTISAMPLE``: Whether all MSAA resources supported
+  for rendering are also supported for texturing.
+* ``PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT``: The minimum alignment that should be
+  expected for a pointer returned by transfer_map if the resource is
+  PIPE_BUFFER. In other words, the pointer returned by transfer_map is
+  always aligned to this value.
 
 
 .. _pipe_capf:
index 1c82474bb1760b70127369769f556cb6c54b50ee..45f48c2a4fba4f12a398b0c7c67852b21d5b9b7b 100644 (file)
@@ -209,6 +209,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
    case PIPE_CAP_START_INSTANCE:
    case PIPE_CAP_QUERY_TIMESTAMP:
    case PIPE_CAP_TEXTURE_MULTISAMPLE:
+   case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
       return 0;
 
    case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT:
index b64a6c0f36c5d2b441aab0957d467fb28ec39567..19ffd4ee9aee2a76f19bb0b0481a9053f321661a 100644 (file)
@@ -212,6 +212,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_START_INSTANCE:
    case PIPE_CAP_QUERY_TIMESTAMP:
    case PIPE_CAP_TEXTURE_MULTISAMPLE:
+   case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
       return 0;
    }
    /* should only get here on unhandled cases */
index 18ad3a87461ba631b5cfd6cc47b2b609261f0c31..4733661863d8274718e18cc83d70191f65be468f 100644 (file)
@@ -119,6 +119,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    case PIPE_CAP_MIXED_COLORBUFFER_FORMATS:
    case PIPE_CAP_START_INSTANCE:
    case PIPE_CAP_TEXTURE_MULTISAMPLE:
+   case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
       return 0;
    case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
    case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
index 168f37858636b1047962d4c9749384b6fd0cfa76..9461af92556d1e76a9b9be7a65aeb6875d769dfc 100644 (file)
@@ -174,6 +174,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    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);
index 4ff2f992e6f8c03f8e3bfb6b028790b0cf62620b..0e0b6661b6933c90ed74913a6a27fcedd7c7a6a3 100644 (file)
@@ -152,6 +152,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
    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);
index 42904390c294436645700e1c25576d5df62251d7..36b5dc78db93d10af8fe8c3bb69cf59a187c9754 100644 (file)
@@ -107,6 +107,9 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
         case PIPE_CAP_USER_CONSTANT_BUFFERS:
             return 1;
 
+        case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
+            return 64;
+
         case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT:
             return 16;
 
index 652d757db5d7ea1b65ac7eea42c212c0ef2d7f7f..41a979cbf3a9aa9c86800fd3cb0cb083107362a7 100644 (file)
@@ -55,7 +55,7 @@ static void r300_buffer_destroy(struct pipe_screen *screen,
 {
     struct r300_resource *rbuf = r300_resource(buf);
 
-    FREE(rbuf->malloced_buffer);
+    align_free(rbuf->malloced_buffer);
 
     if (rbuf->buf)
         pb_reference(&rbuf->buf, NULL);
@@ -146,7 +146,7 @@ struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,
     if (templ->bind & PIPE_BIND_CONSTANT_BUFFER ||
         (!r300screen->caps.has_tcl &&
          (templ->bind & (PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER)))) {
-        rbuf->malloced_buffer = MALLOC(templ->width0);
+        rbuf->malloced_buffer = align_malloc(templ->width0, 64);
         return &rbuf->b.b;
     }
 
index 7a1e135355335f60249ad3148a4eaf0a1767f01a..b5280e32160ee66e31e6f4fa707b9b01047406c9 100644 (file)
@@ -400,6 +400,9 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
                return 1;
 
+        case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
+                return 64;
+
        case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT:
                return 256;
 
index e069f1f2203b0dca03f5959d7c1b36dc6578d854..fa16f4c5dde9ac026b604cbb2b25f09ccf0922b5 100644 (file)
@@ -326,6 +326,9 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
        case PIPE_CAP_NPOT_TEXTURES:
                return 1;
 
+        case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
+                return 64;
+
        case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT:
                return 256;
 
index 445e31c1564f6c167cc3ce3b52901f3b438c9319..5051462bf12db952fa45d081bdff1ae17b4b918e 100644 (file)
@@ -166,6 +166,7 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
    case PIPE_CAP_START_INSTANCE:
    case PIPE_CAP_TEXTURE_MULTISAMPLE:
+   case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
       return 0;
    case PIPE_CAP_QUERY_TIMESTAMP:
       return 1;
index 4f7970df45cddb143443ccc4ce6aa264f049c1ce..e2ca188b551a23d822f7cb4556b333f04d8ae89f 100644 (file)
@@ -256,6 +256,7 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param)
    case PIPE_CAP_START_INSTANCE:
    case PIPE_CAP_QUERY_TIMESTAMP:
    case PIPE_CAP_TEXTURE_MULTISAMPLE:
+   case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
       return 0;
    case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
       return 1;
index b145bc0e8ee19845aa11ee8edf298d23e738c22d..184136e47251efd5d3ad7ac01e6e71e406ab3025 100644 (file)
@@ -488,7 +488,8 @@ enum pipe_cap {
    PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT = 71,
    PIPE_CAP_START_INSTANCE = 72,
    PIPE_CAP_QUERY_TIMESTAMP = 73,
-   PIPE_CAP_TEXTURE_MULTISAMPLE = 74
+   PIPE_CAP_TEXTURE_MULTISAMPLE = 74,
+   PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT = 75
 };
 
 /**
index 0560f3a8a39eb9bc89fdd74180625657c39d88ee..bcc700d955ebed9654fa9b6cf567fb66768c25ef 100644 (file)
@@ -637,4 +637,10 @@ void st_init_extensions(struct st_context *st)
    }
    if (st->options.force_glsl_extensions_warn)
           ctx->Const.ForceGLSLExtensionsWarn = 1;
+
+   ctx->Const.MinMapBufferAlignment =
+      screen->get_param(screen, PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT);
+   if (ctx->Const.MinMapBufferAlignment >= 64) {
+      ctx->Extensions.ARB_map_buffer_alignment = GL_TRUE;
+   }
 }