gallium: put u_vbuf_get_caps return values into u_vbuf_caps
[mesa.git] / src / gallium / auxiliary / cso_cache / cso_context.c
index e3d46f3c8deb3d91e9d0ac804b3c3adf426f0a36..ae98a5c89cc6b681ea8545c63b6d580097a798f8 100644 (file)
@@ -160,7 +160,7 @@ static boolean delete_depth_stencil_state(struct cso_context *ctx, void *state)
    return TRUE;
 }
 
-static boolean delete_sampler_state(struct cso_context *ctx, void *state)
+static boolean delete_sampler_state(UNUSED struct cso_context *ctx, void *state)
 {
    struct cso_sampler *cso = (struct cso_sampler *)state;
    if (cso->delete_state)
@@ -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 );
@@ -329,7 +334,8 @@ cso_create_context(struct pipe_context *pipe, unsigned u_vbuf_flags)
       int supported_irs =
          pipe->screen->get_shader_param(pipe->screen, PIPE_SHADER_COMPUTE,
                                         PIPE_SHADER_CAP_SUPPORTED_IRS);
-      if (supported_irs & (1 << PIPE_SHADER_IR_TGSI)) {
+      if (supported_irs & ((1 << PIPE_SHADER_IR_TGSI) |
+                           (1 << PIPE_SHADER_IR_NIR))) {
          ctx->has_compute_shader = TRUE;
       }
    }
@@ -1147,6 +1153,9 @@ void cso_set_vertex_buffers(struct cso_context *ctx,
 {
    struct u_vbuf *vbuf = ctx->vbuf;
 
+   if (!count)
+      return;
+
    if (vbuf) {
       u_vbuf_set_vertex_buffers(vbuf, start_slot, count, buffers);
       return;