v3d: Put default vertex attribute values into the state uploader as well.
authorEric Anholt <eric@anholt.net>
Fri, 7 Dec 2018 20:36:55 +0000 (12:36 -0800)
committerEric Anholt <eric@anholt.net>
Sat, 8 Dec 2018 00:48:23 +0000 (16:48 -0800)
The default attributes are long-lived (the state struct is cached), and
only 256 bytes each.

src/gallium/drivers/v3d/v3d_context.h
src/gallium/drivers/v3d/v3dx_draw.c
src/gallium/drivers/v3d/v3dx_state.c

index ab4756aa76fcbf70ae084258fc220859bdb3877e..6ffe09a9c1a16411014db995b6a40ca4130bb1c0 100644 (file)
@@ -186,7 +186,8 @@ struct v3d_vertex_stateobj {
         unsigned num_elements;
 
         uint8_t attrs[16 * VC5_MAX_ATTRIBUTES];
-        struct v3d_bo *default_attribute_values;
+        struct pipe_resource *defaults;
+        uint32_t defaults_offset;
 };
 
 struct v3d_streamout_stateobj {
index 2016db7fa81476ba36f3fa4aedccf5ec2d633f27..051907f1250261e976c5887ebc19e4aa3a22585d 100644 (file)
@@ -265,7 +265,8 @@ v3d_emit_gl_shader_state(struct v3d_context *v3d,
                         v3d->prog.vs->prog_data.vs->uses_iid;
 
                 shader.address_of_default_attribute_values =
-                        cl_address(vtx->default_attribute_values, 0);
+                        cl_address(v3d_resource(vtx->defaults)->bo,
+                                   vtx->defaults_offset);
         }
 
         for (int i = 0; i < vtx->num_elements; i++) {
index b20a32df67efda87381f95a0f16719cdaaf9e097..75c81f099ddd87042b8a34e0718addbd5f866236 100644 (file)
@@ -30,6 +30,7 @@
 #include "util/u_memory.h"
 #include "util/u_half.h"
 #include "util/u_helpers.h"
+#include "util/u_upload_mgr.h"
 
 #include "v3d_context.h"
 #include "v3d_tiling.h"
@@ -404,11 +405,11 @@ v3d_vertex_state_create(struct pipe_context *pctx, unsigned num_elements,
         /* Set up the default attribute values in case any of the vertex
          * elements use them.
          */
-        so->default_attribute_values = v3d_bo_alloc(v3d->screen,
-                                                    VC5_MAX_ATTRIBUTES *
-                                                    4 * sizeof(float),
-                                                    "default_attributes");
-        uint32_t *attrs = v3d_bo_map(so->default_attribute_values);
+        uint32_t *attrs;
+        u_upload_alloc(v3d->state_uploader, 0,
+                       VC5_MAX_ATTRIBUTES * 4 * sizeof(float), 16,
+                       &so->defaults_offset, &so->defaults, (void **)&attrs);
+
         for (int i = 0; i < VC5_MAX_ATTRIBUTES; i++) {
                 attrs[i * 4 + 0] = 0;
                 attrs[i * 4 + 1] = 0;
@@ -421,6 +422,7 @@ v3d_vertex_state_create(struct pipe_context *pctx, unsigned num_elements,
                 }
         }
 
+        u_upload_unmap(v3d->state_uploader);
         return so;
 }
 
@@ -429,7 +431,7 @@ v3d_vertex_state_delete(struct pipe_context *pctx, void *hwcso)
 {
         struct v3d_vertex_stateobj *so = hwcso;
 
-        v3d_bo_unreference(&so->default_attribute_values);
+        pipe_resource_reference(&so->defaults, NULL);
         free(so);
 }