+ bind_flags = template->bind & ~PIPE_BIND_CUSTOM;
+
+ list_inithead(&sbuf->surfaces);
+
+ if (bind_flags & PIPE_BIND_CONSTANT_BUFFER) {
+ /* Constant buffers can only have the PIPE_BIND_CONSTANT_BUFFER
+ * flag set.
+ */
+ if (ss->sws->have_vgpu10) {
+ bind_flags = PIPE_BIND_CONSTANT_BUFFER;
+ }
+ }
+
+ /* Although svga device only requires constant buffer size to be
+ * in multiples of 16, in order to allow bind_flags promotion,
+ * we are mandating all buffer size to be in multiples of 16.
+ */
+ sbuf->b.b.width0 = align(sbuf->b.b.width0, 16);
+
+ 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
+ * accepted for those uses.
+ * Note that the PIPE_BIND_ flags we get from the gallium frontend are
+ * just a hint about how the buffer may be used. And OpenGL buffer
+ * object may be used for many different things.
+ * Also note that we do not unconditionally set the streamout
+ * bind flag since streamout buffer is an output buffer and
+ * might have performance implication.
+ */
+ 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);
+ }