}
if (!sbuf->swbuf && !svga_buffer_has_hw_storage(sbuf)) {
- if (svga_buffer_create_hw_storage(ss, sbuf) != PIPE_OK) {
+ if (svga_buffer_create_hw_storage(ss, sbuf, sbuf->bind_flags) != PIPE_OK) {
/*
* We can't create a hardware buffer big enough, so create a malloc
* buffer instead.
{
struct svga_screen *ss = svga_screen(screen);
struct svga_buffer *sbuf;
+ unsigned bind_flags;
SVGA_STATS_TIME_PUSH(ss->sws, SVGA_STATS_TIME_CREATEBUFFER);
sbuf->b.vtbl = &svga_buffer_vtbl;
pipe_reference_init(&sbuf->b.b.reference, 1);
sbuf->b.b.screen = screen;
- sbuf->bind_flags = template->bind;
+ bind_flags = template->bind;
- if (template->bind & PIPE_BIND_CONSTANT_BUFFER) {
+ if (bind_flags & PIPE_BIND_CONSTANT_BUFFER) {
/* Constant buffers can only have the PIPE_BIND_CONSTANT_BUFFER
* flag set.
*/
if (ss->sws->have_vgpu10) {
- sbuf->bind_flags = PIPE_BIND_CONSTANT_BUFFER;
+ bind_flags = PIPE_BIND_CONSTANT_BUFFER;
/* Constant buffer size needs to be in multiples of 16. */
sbuf->b.b.width0 = align(sbuf->b.b.width0, 16);
}
}
- if (svga_buffer_needs_hw_storage(template->bind)) {
+ if (svga_buffer_needs_hw_storage(bind_flags)) {
/* If the buffer will be used for vertex/index/stream data, set all
* the flags so that the buffer will be accepted for all those uses.
/* Not a constant buffer. The buffer may be used for vertex data,
* indexes or stream-out.
*/
- sbuf->bind_flags |= (PIPE_BIND_VERTEX_BUFFER |
- PIPE_BIND_INDEX_BUFFER);
+ bind_flags |= (PIPE_BIND_VERTEX_BUFFER |
+ PIPE_BIND_INDEX_BUFFER);
if (ss->sws->have_vgpu10)
- sbuf->bind_flags |= PIPE_BIND_STREAM_OUTPUT;
+ bind_flags |= PIPE_BIND_STREAM_OUTPUT;
}
- if (svga_buffer_create_host_surface(ss, sbuf) != PIPE_OK)
+ if (svga_buffer_create_host_surface(ss, sbuf, bind_flags) != PIPE_OK)
goto error2;
}
else {
debug_reference(&sbuf->b.b.reference,
(debug_reference_descriptor)debug_describe_resource, 0);
+ sbuf->bind_flags = bind_flags;
sbuf->size = util_resource_size(&sbuf->b.b);
ss->hud.total_resource_bytes += sbuf->size;
*/
enum pipe_error
svga_buffer_create_hw_storage(struct svga_screen *ss,
- struct svga_buffer *sbuf)
+ struct svga_buffer *sbuf,
+ unsigned bind_flags)
{
assert(!sbuf->user);
if (ss->sws->have_gb_objects) {
assert(sbuf->handle || !sbuf->dma.pending);
- return svga_buffer_create_host_surface(ss, sbuf);
+ return svga_buffer_create_host_surface(ss, sbuf, bind_flags);
}
if (!sbuf->hwbuf) {
struct svga_winsys_screen *sws = ss->sws;
*/
enum pipe_error
svga_buffer_create_host_surface(struct svga_screen *ss,
- struct svga_buffer *sbuf)
+ struct svga_buffer *sbuf,
+ unsigned bind_flags)
{
assert(!sbuf->user);
sbuf->key.flags = 0;
sbuf->key.format = SVGA3D_BUFFER;
- if (sbuf->bind_flags & PIPE_BIND_VERTEX_BUFFER) {
+ if (bind_flags & PIPE_BIND_VERTEX_BUFFER) {
sbuf->key.flags |= SVGA3D_SURFACE_HINT_VERTEXBUFFER;
sbuf->key.flags |= SVGA3D_SURFACE_BIND_VERTEX_BUFFER;
}
- if (sbuf->bind_flags & PIPE_BIND_INDEX_BUFFER) {
+ if (bind_flags & PIPE_BIND_INDEX_BUFFER) {
sbuf->key.flags |= SVGA3D_SURFACE_HINT_INDEXBUFFER;
sbuf->key.flags |= SVGA3D_SURFACE_BIND_INDEX_BUFFER;
}
- if (sbuf->bind_flags & PIPE_BIND_CONSTANT_BUFFER)
+ if (bind_flags & PIPE_BIND_CONSTANT_BUFFER)
sbuf->key.flags |= SVGA3D_SURFACE_BIND_CONSTANT_BUFFER;
- if (sbuf->bind_flags & PIPE_BIND_STREAM_OUTPUT)
+ if (bind_flags & PIPE_BIND_STREAM_OUTPUT)
sbuf->key.flags |= SVGA3D_SURFACE_BIND_STREAM_OUTPUT;
- if (sbuf->bind_flags & PIPE_BIND_SAMPLER_VIEW)
+ if (bind_flags & PIPE_BIND_SAMPLER_VIEW)
sbuf->key.flags |= SVGA3D_SURFACE_BIND_SHADER_RESOURCE;
- if (!sbuf->bind_flags && sbuf->b.b.usage == PIPE_USAGE_STAGING) {
+ if (!bind_flags && sbuf->b.b.usage == PIPE_USAGE_STAGING) {
/* This surface is to be used with the
* SVGA3D_CMD_DX_TRANSFER_FROM_BUFFER command, and no other
* bind flags are allowed to be set for this surface.
SVGA_DBG(DEBUG_DMA, "surface_create for buffer sz %d\n",
sbuf->b.b.width0);
- sbuf->handle = svga_screen_surface_create(ss, sbuf->b.b.bind,
+ sbuf->handle = svga_screen_surface_create(ss, bind_flags,
sbuf->b.b.usage,
&validated, &sbuf->key);
if (!sbuf->handle)
* Copy the contents of the malloc buffer to a hardware buffer.
*/
static enum pipe_error
-svga_buffer_update_hw(struct svga_context *svga, struct svga_buffer *sbuf)
+svga_buffer_update_hw(struct svga_context *svga, struct svga_buffer *sbuf,
+ unsigned bind_flags)
{
assert(!sbuf->user);
if (!svga_buffer_has_hw_storage(sbuf)) {
if (!sbuf->swbuf)
return PIPE_ERROR;
- ret = svga_buffer_create_hw_storage(svga_screen(sbuf->b.b.screen), sbuf);
+ ret = svga_buffer_create_hw_storage(svga_screen(sbuf->b.b.screen), sbuf,
+ bind_flags);
if (ret != PIPE_OK)
return ret;
if (!sbuf->handle) {
/* This call will set sbuf->handle */
if (svga_have_gb_objects(svga)) {
- ret = svga_buffer_update_hw(svga, sbuf);
+ ret = svga_buffer_update_hw(svga, sbuf, sbuf->bind_flags);
} else {
- ret = svga_buffer_create_host_surface(ss, sbuf);
+ ret = svga_buffer_create_host_surface(ss, sbuf, sbuf->bind_flags);
}
if (ret != PIPE_OK)
return NULL;
/* No pending DMA/update commands yet. */
/* Migrate the data from swbuf -> hwbuf if necessary */
- ret = svga_buffer_update_hw(svga, sbuf);
+ ret = svga_buffer_update_hw(svga, sbuf, sbuf->bind_flags);
if (ret == PIPE_OK) {
/* Emit DMA or UpdateGBImage commands */
ret = svga_buffer_upload_command(svga, sbuf);