From c9f2af3df719c5ed608ef72b09f6907e1015079c Mon Sep 17 00:00:00 2001
From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?=
Date: Sun, 28 Oct 2012 17:52:48 +0100
Subject: [PATCH] gallium: expose ARB_map_buffer_alignment on Radeon
Reviewed-by: Brian Paul
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
---
docs/GL3.txt | 2 +-
docs/relnotes-9.1.html | 2 +-
src/gallium/docs/source/screen.rst | 6 ++++++
src/gallium/drivers/i915/i915_screen.c | 1 +
src/gallium/drivers/llvmpipe/lp_screen.c | 1 +
src/gallium/drivers/nv30/nv30_screen.c | 1 +
src/gallium/drivers/nv50/nv50_screen.c | 1 +
src/gallium/drivers/nvc0/nvc0_screen.c | 1 +
src/gallium/drivers/r300/r300_screen.c | 3 +++
src/gallium/drivers/r300/r300_screen_buffer.c | 4 ++--
src/gallium/drivers/r600/r600_pipe.c | 3 +++
src/gallium/drivers/radeonsi/radeonsi_pipe.c | 3 +++
src/gallium/drivers/softpipe/sp_screen.c | 1 +
src/gallium/drivers/svga/svga_screen.c | 1 +
src/gallium/include/pipe/p_defines.h | 3 ++-
src/mesa/state_tracker/st_extensions.c | 6 ++++++
16 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/docs/GL3.txt b/docs/GL3.txt
index 4efe4bfebf3..4f44764c2c5 100644
--- a/docs/GL3.txt
+++ b/docs/GL3.txt
@@ -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:
diff --git a/docs/relnotes-9.1.html b/docs/relnotes-9.1.html
index 19bea7facd3..5bf9d8c137d 100644
--- a/docs/relnotes-9.1.html
+++ b/docs/relnotes-9.1.html
@@ -44,7 +44,7 @@ Note: some of the new features are only available with certain drivers.
-- tbd
+- GL_ARB_map_buffer_alignment
diff --git a/src/gallium/docs/source/screen.rst b/src/gallium/docs/source/screen.rst
index 7a5568477f0..6c89171cd73 100644
--- a/src/gallium/docs/source/screen.rst
+++ b/src/gallium/docs/source/screen.rst
@@ -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:
diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c
index 1c82474bb17..45f48c2a4fb 100644
--- a/src/gallium/drivers/i915/i915_screen.c
+++ b/src/gallium/drivers/i915/i915_screen.c
@@ -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:
diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c
index b64a6c0f36c..19ffd4ee9ae 100644
--- a/src/gallium/drivers/llvmpipe/lp_screen.c
+++ b/src/gallium/drivers/llvmpipe/lp_screen.c
@@ -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 */
diff --git a/src/gallium/drivers/nv30/nv30_screen.c b/src/gallium/drivers/nv30/nv30_screen.c
index 18ad3a87461..4733661863d 100644
--- a/src/gallium/drivers/nv30/nv30_screen.c
+++ b/src/gallium/drivers/nv30/nv30_screen.c
@@ -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:
diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c
index 168f3785863..9461af92556 100644
--- a/src/gallium/drivers/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nv50/nv50_screen.c
@@ -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);
diff --git a/src/gallium/drivers/nvc0/nvc0_screen.c b/src/gallium/drivers/nvc0/nvc0_screen.c
index 4ff2f992e6f..0e0b6661b69 100644
--- a/src/gallium/drivers/nvc0/nvc0_screen.c
+++ b/src/gallium/drivers/nvc0/nvc0_screen.c
@@ -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);
diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
index 42904390c29..36b5dc78db9 100644
--- a/src/gallium/drivers/r300/r300_screen.c
+++ b/src/gallium/drivers/r300/r300_screen.c
@@ -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;
diff --git a/src/gallium/drivers/r300/r300_screen_buffer.c b/src/gallium/drivers/r300/r300_screen_buffer.c
index 652d757db5d..41a979cbf3a 100644
--- a/src/gallium/drivers/r300/r300_screen_buffer.c
+++ b/src/gallium/drivers/r300/r300_screen_buffer.c
@@ -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;
}
diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
index 7a1e1353553..b5280e32160 100644
--- a/src/gallium/drivers/r600/r600_pipe.c
+++ b/src/gallium/drivers/r600/r600_pipe.c
@@ -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;
diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.c b/src/gallium/drivers/radeonsi/radeonsi_pipe.c
index e069f1f2203..fa16f4c5dde 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.c
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.c
@@ -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;
diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
index 445e31c1564..5051462bf12 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -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;
diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c
index 4f7970df45c..e2ca188b551 100644
--- a/src/gallium/drivers/svga/svga_screen.c
+++ b/src/gallium/drivers/svga/svga_screen.c
@@ -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;
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index b145bc0e8ee..184136e4725 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -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
};
/**
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 0560f3a8a39..bcc700d955e 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -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;
+ }
}
--
2.30.2