summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2017-02-10 01:09:27 +0100
committerMarek Olšák <[email protected]>2017-02-14 21:47:51 +0100
commite0f95ddd3e1217e5710cdd12e733b6440592cc7d (patch)
tree28356a6fbc3fb384b9465e365a8d52f7dda59c13
parent0561b3c75af2e4bb216b686bf62ae9d89c584dc8 (diff)
gallium: let state trackers tell u_vbuf whether user VBOs are possible
This can affect whether u_vbuf will be enabled or not. Reviewed-by: Nicolai Hähnle <[email protected]>
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.c9
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.h3
-rw-r--r--src/gallium/auxiliary/util/u_tests.c8
-rw-r--r--src/gallium/auxiliary/util/u_vbuf.c5
-rw-r--r--src/gallium/auxiliary/util/u_vbuf.h5
-rw-r--r--src/gallium/state_trackers/nine/device9.c4
-rw-r--r--src/gallium/state_trackers/xa/xa_context.c2
-rw-r--r--src/gallium/tests/trivial/quad-tex.c2
-rw-r--r--src/gallium/tests/trivial/tri.c2
-rw-r--r--src/mesa/state_tracker/st_context.c2
10 files changed, 24 insertions, 18 deletions
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index 469ab9cdbc6..0f12304fe50 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -277,18 +277,19 @@ sanitize_hash(struct cso_hash *hash, enum cso_cache_type type,
}
}
-static void cso_init_vbuf(struct cso_context *cso)
+static void cso_init_vbuf(struct cso_context *cso, unsigned flags)
{
struct u_vbuf_caps caps;
/* Install u_vbuf if there is anything unsupported. */
- if (u_vbuf_get_caps(cso->pipe->screen, &caps)) {
+ if (u_vbuf_get_caps(cso->pipe->screen, &caps, flags)) {
cso->vbuf = u_vbuf_create(cso->pipe, &caps,
cso->aux_vertex_buffer_index);
}
}
-struct cso_context *cso_create_context( struct pipe_context *pipe )
+struct cso_context *
+cso_create_context(struct pipe_context *pipe, unsigned u_vbuf_flags)
{
struct cso_context *ctx = CALLOC_STRUCT(cso_context);
if (!ctx)
@@ -306,7 +307,7 @@ struct cso_context *cso_create_context( struct pipe_context *pipe )
ctx->aux_vertex_buffer_index = 0; /* 0 for now */
- cso_init_vbuf(ctx);
+ cso_init_vbuf(ctx, u_vbuf_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 29e5e33171e..2a65354a7f4 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.h
+++ b/src/gallium/auxiliary/cso_cache/cso_context.h
@@ -41,7 +41,8 @@ extern "C" {
struct cso_context;
struct u_vbuf;
-struct cso_context *cso_create_context( struct pipe_context *pipe );
+struct cso_context *cso_create_context(struct pipe_context *pipe,
+ unsigned u_vbuf_flags);
void cso_destroy_context( struct cso_context *cso );
diff --git a/src/gallium/auxiliary/util/u_tests.c b/src/gallium/auxiliary/util/u_tests.c
index c33c1f69e83..687e5118d7c 100644
--- a/src/gallium/auxiliary/util/u_tests.c
+++ b/src/gallium/auxiliary/util/u_tests.c
@@ -304,7 +304,7 @@ tgsi_vs_window_space_position(struct pipe_context *ctx)
return;
}
- cso = cso_create_context(ctx);
+ cso = cso_create_context(ctx, 0);
cb = util_create_texture2d(ctx->screen, 256, 256,
PIPE_FORMAT_R8G8B8A8_UNORM);
util_set_common_states_and_clear(cso, ctx, cb);
@@ -364,7 +364,7 @@ null_sampler_view(struct pipe_context *ctx, unsigned tgsi_tex_target)
return;
}
- cso = cso_create_context(ctx);
+ cso = cso_create_context(ctx, 0);
cb = util_create_texture2d(ctx->screen, 256, 256,
PIPE_FORMAT_R8G8B8A8_UNORM);
util_set_common_states_and_clear(cso, ctx, cb);
@@ -406,7 +406,7 @@ null_constant_buffer(struct pipe_context *ctx)
bool pass = true;
static const float zero[] = {0, 0, 0, 0};
- cso = cso_create_context(ctx);
+ cso = cso_create_context(ctx, 0);
cb = util_create_texture2d(ctx->screen, 256, 256,
PIPE_FORMAT_R8G8B8A8_UNORM);
util_set_common_states_and_clear(cso, ctx, cb);
@@ -462,7 +462,7 @@ null_fragment_shader(struct pipe_context *ctx)
struct pipe_query *query;
union pipe_query_result qresult;
- cso = cso_create_context(ctx);
+ cso = cso_create_context(ctx, 0);
cb = util_create_texture2d(ctx->screen, 256, 256,
PIPE_FORMAT_R8G8B8A8_UNORM);
util_set_common_states_and_clear(cso, ctx, cb);
diff --git a/src/gallium/auxiliary/util/u_vbuf.c b/src/gallium/auxiliary/util/u_vbuf.c
index c26a923c7f3..f040f4a882d 100644
--- a/src/gallium/auxiliary/util/u_vbuf.c
+++ b/src/gallium/auxiliary/util/u_vbuf.c
@@ -255,7 +255,8 @@ 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)
+boolean u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps,
+ unsigned flags)
{
unsigned i;
boolean fallback = FALSE;
@@ -293,7 +294,7 @@ boolean u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps)
if (!caps->buffer_offset_unaligned ||
!caps->buffer_stride_unaligned ||
!caps->velem_src_offset_unaligned ||
- !caps->user_vertex_buffers) {
+ (!(flags & U_VBUF_FLAG_NO_USER_VBOS) && !caps->user_vertex_buffers)) {
fallback = TRUE;
}
diff --git a/src/gallium/auxiliary/util/u_vbuf.h b/src/gallium/auxiliary/util/u_vbuf.h
index 9e8b135fb79..ddfa844d27f 100644
--- a/src/gallium/auxiliary/util/u_vbuf.h
+++ b/src/gallium/auxiliary/util/u_vbuf.h
@@ -40,6 +40,8 @@
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];
@@ -55,7 +57,8 @@ struct u_vbuf_caps {
};
-boolean u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps);
+boolean u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps,
+ unsigned flags);
struct u_vbuf *
u_vbuf_create(struct pipe_context *pipe,
diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index 92bc72ce28d..b9b7a637d70 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -199,9 +199,9 @@ NineDevice9_ctor( struct NineDevice9 *This,
This->pipe_sw = This->screen_sw->context_create(This->screen_sw, NULL, 0);
if (!This->pipe_sw) { return E_OUTOFMEMORY; }
- This->context.cso = cso_create_context(This->context.pipe);
+ This->context.cso = cso_create_context(This->context.pipe, 0);
if (!This->context.cso) { return E_OUTOFMEMORY; } /* also a guess */
- This->cso_sw = cso_create_context(This->pipe_sw);
+ This->cso_sw = cso_create_context(This->pipe_sw, 0);
if (!This->cso_sw) { return E_OUTOFMEMORY; }
/* Create first, it messes up our state. */
diff --git a/src/gallium/state_trackers/xa/xa_context.c b/src/gallium/state_trackers/xa/xa_context.c
index 715b48d7c84..1f4717056a9 100644
--- a/src/gallium/state_trackers/xa/xa_context.c
+++ b/src/gallium/state_trackers/xa/xa_context.c
@@ -57,7 +57,7 @@ xa_context_create(struct xa_tracker *xa)
ctx->xa = xa;
ctx->pipe = xa->screen->context_create(xa->screen, NULL, 0);
- ctx->cso = cso_create_context(ctx->pipe);
+ ctx->cso = cso_create_context(ctx->pipe, 0);
ctx->shaders = xa_shaders_create(ctx);
renderer_init_state(ctx);
diff --git a/src/gallium/tests/trivial/quad-tex.c b/src/gallium/tests/trivial/quad-tex.c
index c72c5fe2391..6e9957aac9c 100644
--- a/src/gallium/tests/trivial/quad-tex.c
+++ b/src/gallium/tests/trivial/quad-tex.c
@@ -101,7 +101,7 @@ static void init_prog(struct program *p)
/* create the pipe driver context and cso context */
p->pipe = p->screen->context_create(p->screen, NULL, 0);
- p->cso = cso_create_context(p->pipe);
+ p->cso = cso_create_context(p->pipe, 0);
/* set clear color */
p->clear_color.f[0] = 0.3;
diff --git a/src/gallium/tests/trivial/tri.c b/src/gallium/tests/trivial/tri.c
index 914f5e75fa9..a2031696f02 100644
--- a/src/gallium/tests/trivial/tri.c
+++ b/src/gallium/tests/trivial/tri.c
@@ -96,7 +96,7 @@ static void init_prog(struct program *p)
/* create the pipe driver context and cso context */
p->pipe = p->screen->context_create(p->screen, NULL, 0);
- p->cso = cso_create_context(p->pipe);
+ p->cso = cso_create_context(p->pipe, 0);
/* set clear color */
p->clear_color.f[0] = 0.3;
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 3d0455f9326..4b9d913f639 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -342,7 +342,7 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe,
st->has_user_constbuf =
screen->get_param(screen, PIPE_CAP_USER_CONSTANT_BUFFERS);
- st->cso_context = cso_create_context(pipe);
+ st->cso_context = cso_create_context(pipe, 0);
st_init_atoms( st );
st_init_clear(st);