gallivm: make lp_build_float_to_r11g11b10 take a const src
[mesa.git] / src / gallium / auxiliary / util / u_suballoc.c
index 8c463c9fdd058d80c664c315c4f02f064bab94a2..d54026edf9e45bf6cc76d8bb7404249b89badfa7 100644 (file)
@@ -43,6 +43,7 @@ struct u_suballocator {
    unsigned size;          /* Size of the whole buffer, in bytes. */
    unsigned bind;          /* Bitmask of PIPE_BIND_* flags. */
    enum pipe_resource_usage usage;
+   unsigned flags;         /* bitmask of PIPE_RESOURCE_FLAG_x */
    boolean zero_buffer_memory; /* If the buffer contents should be zeroed. */
 
    struct pipe_resource *buffer;   /* The buffer we suballocate from. */
@@ -53,12 +54,14 @@ struct u_suballocator {
 /**
  * Create a suballocator.
  *
- * \p zero_buffer_memory determines whether the buffer contents should be
- * cleared to 0 after the allocation.
+ * \param flags               bitmask of PIPE_RESOURCE_FLAG_x
+ * \param zero_buffer_memory  determines whether the buffer contents should be
+ *                            cleared to 0 after the allocation.
+ *
  */
 struct u_suballocator *
 u_suballocator_create(struct pipe_context *pipe, unsigned size, unsigned bind,
-                      enum pipe_resource_usage usage,
+                      enum pipe_resource_usage usage, unsigned flags,
                      boolean zero_buffer_memory)
 {
    struct u_suballocator *allocator = CALLOC_STRUCT(u_suballocator);
@@ -69,6 +72,7 @@ u_suballocator_create(struct pipe_context *pipe, unsigned size, unsigned bind,
    allocator->size = size;
    allocator->bind = bind;
    allocator->usage = usage;
+   allocator->flags = flags;
    allocator->zero_buffer_memory = zero_buffer_memory;
    return allocator;
 }
@@ -97,9 +101,21 @@ u_suballocator_alloc(struct u_suballocator *allocator, unsigned size,
       /* Allocate a new buffer. */
       pipe_resource_reference(&allocator->buffer, NULL);
       allocator->offset = 0;
-      allocator->buffer =
-         pipe_buffer_create(allocator->pipe->screen, allocator->bind,
-                            allocator->usage, allocator->size);
+
+      struct pipe_resource templ;
+      memset(&templ, 0, sizeof(templ));
+      templ.target = PIPE_BUFFER;
+      templ.format = PIPE_FORMAT_R8_UNORM;
+      templ.bind = allocator->bind;
+      templ.usage = allocator->usage;
+      templ.flags = allocator->flags;
+      templ.width0 = allocator->size;
+      templ.height0 = 1;
+      templ.depth0 = 1;
+      templ.array_size = 1;
+
+      struct pipe_screen *screen = allocator->pipe->screen;
+      allocator->buffer = screen->resource_create(screen, &templ);
       if (!allocator->buffer)
          goto fail;