gallium: use PIPE_CAP_CONSTBUF0_FLAGS
authorMarek Olšák <marek.olsak@amd.com>
Sat, 27 Jan 2018 01:05:23 +0000 (02:05 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Sat, 17 Feb 2018 03:20:55 +0000 (04:20 +0100)
src/gallium/auxiliary/util/u_inlines.h
src/gallium/auxiliary/vl/vl_compositor.c
src/gallium/drivers/radeonsi/si_pipe.c
src/gallium/state_trackers/xa/xa_renderer.c

index 4ba6ad72b6274f18d2eb909dab92d71318348508..4bd9b7e3c62b6ada4ba317cc18f3ea80083ca70d 100644 (file)
@@ -284,6 +284,27 @@ pipe_buffer_create( struct pipe_screen *screen,
 }
 
 
+static inline struct pipe_resource *
+pipe_buffer_create_const0(struct pipe_screen *screen,
+                          unsigned bind,
+                          enum pipe_resource_usage usage,
+                          unsigned size)
+{
+   struct pipe_resource buffer;
+   memset(&buffer, 0, sizeof buffer);
+   buffer.target = PIPE_BUFFER;
+   buffer.format = PIPE_FORMAT_R8_UNORM;
+   buffer.bind = bind;
+   buffer.usage = usage;
+   buffer.flags = screen->get_param(screen, PIPE_CAP_CONSTBUF0_FLAGS);
+   buffer.width0 = size;
+   buffer.height0 = 1;
+   buffer.depth0 = 1;
+   buffer.array_size = 1;
+   return screen->resource_create(screen, &buffer);
+}
+
+
 /**
  * Map a range of a resource.
  * \param offset  start of region, in bytes 
index 67ad7f5beea79608faf0e17a0a9fd6777a0215ca..725bfd9126e7654848221dd23f66af276ab3d096 100644 (file)
@@ -1437,7 +1437,7 @@ vl_compositor_init_state(struct vl_compositor_state *s, struct pipe_context *pip
     * Const buffer contains the color conversion matrix and bias vectors
     */
    /* XXX: Create with IMMUTABLE/STATIC... although it does change every once in a long while... */
-   s->csc_matrix = pipe_buffer_create
+   s->csc_matrix = pipe_buffer_create_const0
    (
       pipe->screen,
       PIPE_BIND_CONSTANT_BUFFER,
index 3180557484274c37904f947701a106c70d3605e1..11915453082696613d1f356b7adbeef29275362b 100644 (file)
@@ -587,7 +587,7 @@ static void si_test_vmfault(struct si_screen *sscreen)
        struct pipe_context *ctx = sscreen->aux_context;
        struct si_context *sctx = (struct si_context *)ctx;
        struct pipe_resource *buf =
-               pipe_buffer_create(&sscreen->b, 0, PIPE_USAGE_DEFAULT, 64);
+               pipe_buffer_create_const0(&sscreen->b, 0, PIPE_USAGE_DEFAULT, 64);
 
        if (!buf) {
                puts("Buffer allocation failed.");
index bc55f877c4872e034cdd25061b111fcc8767bdb5..27497d3d659f3695655f0e9d18f8b56850b2ad79 100644 (file)
@@ -393,9 +393,10 @@ renderer_set_constants(struct xa_context *r,
        &r->fs_const_buffer;
 
     pipe_resource_reference(cbuf, NULL);
-    *cbuf = pipe_buffer_create(r->pipe->screen,
-                              PIPE_BIND_CONSTANT_BUFFER, PIPE_USAGE_DEFAULT,
-                              param_bytes);
+    *cbuf = pipe_buffer_create_const0(r->pipe->screen,
+                                      PIPE_BIND_CONSTANT_BUFFER,
+                                      PIPE_USAGE_DEFAULT,
+                                      param_bytes);
 
     if (*cbuf) {
        pipe_buffer_write(r->pipe, *cbuf, 0, param_bytes, params);