svga_buffer_create_hw_storage(struct svga_screen *ss,
struct svga_buffer *sbuf)
{
+ assert(!sbuf->user);
+
if(!sbuf->hwbuf) {
unsigned alignment = sbuf->base.alignment;
unsigned usage = 0;
if(sbuf->handle)
svga_buffer_destroy_host_surface(ss, sbuf);
+ if(sbuf->uploaded.buffer)
+ pipe_buffer_reference(&sbuf->uploaded.buffer, NULL);
+
if(sbuf->hwbuf)
svga_buffer_destroy_hw_storage(ss, sbuf);
/**
- * Copy the contents of the user buffer / malloc buffer to a hardware buffer.
+ * Copy the contents of the malloc buffer to a hardware buffer.
*/
static INLINE enum pipe_error
svga_buffer_update_hw(struct svga_screen *ss, struct svga_buffer *sbuf)
{
+ assert(!sbuf->user);
if(!sbuf->hwbuf) {
enum pipe_error ret;
void *map;
sbuf = svga_buffer(buf);
assert(!sbuf->map.count);
+ assert(!sbuf->user);
if(!sbuf->handle) {
ret = svga_buffer_create_host_surface(ss, sbuf);
{
if (svga_buffer_is_user_buffer(svga->curr.vb[i].buffer))
{
- struct pipe_buffer *upload_buffer = NULL;
- unsigned offset = /*svga->curr.vb[i].buffer_offset*/ 0;
- unsigned size = svga->curr.vb[i].buffer->size /*- offset*/;
- unsigned upload_offset;
-
- ret = u_upload_buffer( svga->upload_vb,
- offset,
- size,
- svga->curr.vb[i].buffer,
- &upload_offset,
- &upload_buffer );
- if (ret)
- return ret;
-
- if (0)
- debug_printf("%s: %d: orig buf %p upl buf %p ofs %d sz %d\n",
- __FUNCTION__,
- i,
- svga->curr.vb[i].buffer,
- upload_buffer, upload_offset, size);
-
- /* Make sure we release the old buffer and end up with the
- * correct refcount on the uploaded buffer.
- */
- pipe_buffer_reference( &svga->curr.vb[i].buffer, NULL );
- svga->curr.vb[i].buffer = upload_buffer;
- svga->curr.vb[i].buffer_offset = upload_offset;
+ struct svga_buffer *buffer = svga_buffer(svga->curr.vb[i].buffer);
+
+ if (!buffer->uploaded.buffer) {
+ ret = u_upload_buffer( svga->upload_vb,
+ 0,
+ buffer->base.size,
+ &buffer->base,
+ &buffer->uploaded.offset,
+ &buffer->uploaded.buffer );
+ if (ret)
+ return ret;
+
+ if (0)
+ debug_printf("%s: %d: orig buf %p upl buf %p ofs %d sz %d\n",
+ __FUNCTION__,
+ i,
+ buffer,
+ buffer->uploaded.buffer,
+ buffer->uploaded.offset,
+ buffer->base.size);
+ }
+
+ pipe_buffer_reference( &svga->curr.vb[i].buffer, buffer->uploaded.buffer );
+ svga->curr.vb[i].buffer_offset = buffer->uploaded.offset;
}
}