Mesa (master): gallium: put u_vbuf_get_caps return values into u_vbuf_caps
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jan 8 18:42:53 UTC 2020
Module: Mesa
Branch: master
Commit: ce648b913f83b968eb6ba1ad33fdcf86d5942fe5
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ce648b913f83b968eb6ba1ad33fdcf86d5942fe5
Author: Marek Olšák <marek.olsak at amd.com>
Date: Sun Dec 29 22:02:28 2019 -0500
gallium: put u_vbuf_get_caps return values into u_vbuf_caps
Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
---
src/gallium/auxiliary/cso_cache/cso_context.c | 13 +++++++++----
src/gallium/auxiliary/cso_cache/cso_context.h | 4 +++-
src/gallium/auxiliary/util/u_vbuf.c | 19 +++++++++----------
src/gallium/auxiliary/util/u_vbuf.h | 8 ++++----
src/mesa/state_tracker/st_context.c | 6 +++---
5 files changed, 28 insertions(+), 22 deletions(-)
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index d9e1309c5cc..ae98a5c89cc 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -287,15 +287,20 @@ sanitize_hash(struct cso_hash *hash, enum cso_cache_type type,
static void cso_init_vbuf(struct cso_context *cso, unsigned flags)
{
struct u_vbuf_caps caps;
+ bool uses_user_vertex_buffers = !(flags & CSO_NO_USER_VERTEX_BUFFERS);
- /* Install u_vbuf if there is anything unsupported. */
- if (u_vbuf_get_caps(cso->pipe->screen, &caps, flags)) {
+ u_vbuf_get_caps(cso->pipe->screen, &caps);
+
+ /* Enable u_vbuf if needed. */
+ if (caps.fallback_always ||
+ (uses_user_vertex_buffers &&
+ caps.fallback_only_for_user_vbuffers)) {
cso->vbuf = u_vbuf_create(cso->pipe, &caps);
}
}
struct cso_context *
-cso_create_context(struct pipe_context *pipe, unsigned u_vbuf_flags)
+cso_create_context(struct pipe_context *pipe, unsigned flags)
{
struct cso_context *ctx = CALLOC_STRUCT(cso_context);
if (!ctx)
@@ -311,7 +316,7 @@ cso_create_context(struct pipe_context *pipe, unsigned u_vbuf_flags)
ctx->pipe = pipe;
ctx->sample_mask = ~0;
- cso_init_vbuf(ctx, u_vbuf_flags);
+ cso_init_vbuf(ctx, flags);
/* Enable for testing: */
if (0) cso_set_maximum_cache_size( ctx->cache, 4 );
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h
index d3501fb92e9..de8c60fd2c1 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.h
+++ b/src/gallium/auxiliary/cso_cache/cso_context.h
@@ -41,8 +41,10 @@ extern "C" {
struct cso_context;
struct u_vbuf;
+#define CSO_NO_USER_VERTEX_BUFFERS (1 << 0)
+
struct cso_context *cso_create_context(struct pipe_context *pipe,
- unsigned u_vbuf_flags);
+ unsigned flags);
void cso_destroy_context( struct cso_context *cso );
struct pipe_context *cso_get_pipe_context(struct cso_context *cso);
diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c
index 8d50092b4c4..9bed8d45230 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -255,11 +255,11 @@ static const struct {
{ PIPE_FORMAT_R8G8B8A8_SSCALED, PIPE_FORMAT_R32G32B32A32_FLOAT },
};
-boolean u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps,
- unsigned flags)
+void u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps)
{
unsigned i;
- boolean fallback = FALSE;
+
+ memset(caps, 0, sizeof(*caps));
/* I'd rather have a bitfield of which formats are supported and a static
* table of the translations indexed by format, but since we don't have C99
@@ -275,7 +275,7 @@ boolean u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps,
if (!screen->is_format_supported(screen, format, PIPE_BUFFER, 0, 0,
PIPE_BIND_VERTEX_BUFFER)) {
caps->format_translation[format] = vbuf_format_fallbacks[i].to;
- fallback = TRUE;
+ caps->fallback_always = true;
}
}
@@ -295,16 +295,15 @@ boolean u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps,
/* OpenGL 2.0 requires a minimum of 16 vertex buffers */
if (caps->max_vertex_buffers < 16)
- fallback = TRUE;
+ caps->fallback_always = true;
if (!caps->buffer_offset_unaligned ||
!caps->buffer_stride_unaligned ||
- !caps->velem_src_offset_unaligned ||
- (!(flags & U_VBUF_FLAG_NO_USER_VBOS) && !caps->user_vertex_buffers)) {
- fallback = TRUE;
- }
+ !caps->velem_src_offset_unaligned)
+ caps->fallback_always = true;
- return fallback;
+ if (!caps->fallback_always && !caps->user_vertex_buffers)
+ caps->fallback_only_for_user_vbuffers = true;
}
struct u_vbuf *
diff --git a/src/gallium/auxiliary/util/u_vbuf.h b/src/gallium/auxiliary/util/u_vbuf.h
index 797fbb7681f..3e64d067e62 100644
--- a/src/gallium/auxiliary/util/u_vbuf.h
+++ b/src/gallium/auxiliary/util/u_vbuf.h
@@ -40,8 +40,6 @@
struct cso_context;
struct u_vbuf;
-#define U_VBUF_FLAG_NO_USER_VBOS (1 << 0)
-
/* Hardware vertex fetcher limitations can be described by this structure. */
struct u_vbuf_caps {
enum pipe_format format_translation[PIPE_FORMAT_COUNT];
@@ -57,11 +55,13 @@ struct u_vbuf_caps {
/* Maximum number of vertex buffers */
unsigned max_vertex_buffers:6;
+
+ bool fallback_always;
+ bool fallback_only_for_user_vbuffers;
};
-boolean u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps,
- unsigned flags);
+void u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps);
struct u_vbuf *
u_vbuf_create(struct pipe_context *pipe, struct u_vbuf_caps *caps);
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 72e1a50bca3..e6a5b65dc22 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -586,9 +586,9 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe,
* profile, so that u_vbuf is bypassed completely if there is nothing else
* to do.
*/
- unsigned vbuf_flags =
- ctx->API == API_OPENGL_CORE ? U_VBUF_FLAG_NO_USER_VBOS : 0;
- st->cso_context = cso_create_context(pipe, vbuf_flags);
+ unsigned cso_flags =
+ ctx->API == API_OPENGL_CORE ? CSO_NO_USER_VERTEX_BUFFERS : 0;
+ st->cso_context = cso_create_context(pipe, cso_flags);
st_init_atoms(st);
st_init_clear(st);
More information about the mesa-commit
mailing list