/**
- * Vertex and index buffers need hardware backing. Constant buffers
- * do not. No other types of buffers currently supported.
+ * Determine what buffers eventually need hardware backing.
+ *
+ * Vertex- and index buffers need hardware backing. Constant buffers
+ * do on vgpu10. Staging texture-upload buffers do when they are
+ * supported.
*/
static inline boolean
-svga_buffer_needs_hw_storage(unsigned usage)
+svga_buffer_needs_hw_storage(const struct svga_screen *ss,
+ const struct pipe_resource *template)
{
- return (usage & (PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER |
- PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_STREAM_OUTPUT)) != 0;
-}
+ unsigned bind_mask = (PIPE_BIND_VERTEX_BUFFER | PIPE_BIND_INDEX_BUFFER |
+ PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_STREAM_OUTPUT);
+ if (ss->sws->have_vgpu10) {
+ /*
+ * Driver-created upload const0- and staging texture upload buffers
+ * tagged with PIPE_BIND_CUSTOM
+ */
+ bind_mask |= PIPE_BIND_CUSTOM;
+ /* Uniform buffer objects.
+ * Make sure we don't create hardware storage for state-tracker
+ * const0 buffers, because we frequently map them for reading.
+ * They are distinguished by having PIPE_USAGE_STREAM, but not
+ * PIPE_BIND_CUSTOM.
+ */
+ if (template->usage != PIPE_USAGE_STREAM)
+ bind_mask |= PIPE_BIND_CONSTANT_BUFFER;
+ }
+
+ return !!(template->bind & bind_mask);
+}
/**
* Create a buffer transfer.
sbuf->b.vtbl = &svga_buffer_vtbl;
pipe_reference_init(&sbuf->b.b.reference, 1);
sbuf->b.b.screen = screen;
- bind_flags = template->bind;
+ bind_flags = template->bind & ~PIPE_BIND_CUSTOM;
LIST_INITHEAD(&sbuf->surfaces);
*/
sbuf->b.b.width0 = align(sbuf->b.b.width0, 16);
- if (svga_buffer_needs_hw_storage(bind_flags)) {
+ if (svga_buffer_needs_hw_storage(ss, template)) {
/* If the buffer is not used for constant buffer, set
* the vertex/index bind flags as well so that the buffer will be
* bind flag since streamout buffer is an output buffer and
* might have performance implication.
*/
- if (!(template->bind & PIPE_BIND_CONSTANT_BUFFER)) {
- /* Not a constant buffer. The buffer may be used for vertex data
- * or indexes.
+ if (!(template->bind & PIPE_BIND_CONSTANT_BUFFER) &&
+ !(template->bind & PIPE_BIND_CUSTOM)) {
+ /* Not a constant- or staging buffer.
+ * The buffer may be used for vertex data or indexes.
*/
bind_flags |= (PIPE_BIND_VERTEX_BUFFER |
PIPE_BIND_INDEX_BUFFER);