Skip to content
Snippets Groups Projects
Commit 6b95cfb0 authored by Jose Fonseca's avatar Jose Fonseca
Browse files

svga: Rebind framebuffer and tss bindings strictly when necessary.

The earlier change to ensure rendertargets and textures are always
rebound at every command buffer start had the downside of making
successive flushes no longer no-ops, as a command buffer with merely
the rebinding commands were being unnecessarily sent to the vGPU.

This change only re-emits the bindings when necessary, by keeping track
of the need to rebind outside of the dirty state update mechanism.
parent e338a1b0
No related branches found
No related tags found
No related merge requests found
......@@ -204,7 +204,6 @@ void svga_context_flush( struct svga_context *svga,
{
struct svga_screen *svgascreen = svga_screen(svga->pipe.screen);
struct pipe_fence_handle *fence = NULL;
enum pipe_error ret;
svga->curr.nr_fbs = 0;
......@@ -219,25 +218,11 @@ void svga_context_flush( struct svga_context *svga,
svga_screen_cache_flush(svgascreen, fence);
/* To force the reemission of rendertargets and texture bindings at
* the beginning of every command buffer.
*/
svga->dirty |= SVGA_NEW_COMMAND_BUFFER;
/*
* We must reemit the surface bindings here, because svga_update_state
* will always flush the primitives before processing the
* SVGA_NEW_COMMAND_BUFFER state change.
*
* TODO: Refactor this.
/* To force the re-emission of rendertargets and texture sampler bindings on
* the next command buffer.
*/
ret = svga_reemit_framebuffer_bindings(svga);
assert(ret == PIPE_OK);
ret = svga_reemit_tss_bindings(svga);
assert(ret == PIPE_OK);
svga->dirty &= ~SVGA_NEW_COMMAND_BUFFER;
svga->rebind.rendertargets = TRUE;
svga->rebind.texture_samplers = TRUE;
if (SVGA_DEBUG & DEBUG_SYNC) {
if (fence)
......
......@@ -358,6 +358,11 @@ struct svga_context
struct svga_state curr; /* state from the state tracker */
unsigned dirty; /* statechanges since last update_state() */
struct {
unsigned rendertargets:1;
unsigned texture_samplers:1;
} rebind;
struct u_upload_mgr *upload_ib;
struct u_upload_mgr *upload_vb;
struct svga_hwtnl *hwtnl;
......@@ -402,7 +407,6 @@ struct svga_context
#define SVGA_NEW_ZERO_STRIDE 0x2000000
#define SVGA_NEW_TEXTURE_FLAGS 0x4000000
#define SVGA_NEW_STENCIL_REF 0x8000000
#define SVGA_NEW_COMMAND_BUFFER 0x10000000
......
......@@ -170,6 +170,20 @@ svga_hwtnl_flush( struct svga_hwtnl *hwtnl )
ib_handle[i] = handle;
}
if (svga->rebind.rendertargets) {
ret = svga_reemit_framebuffer_bindings(svga);
if (ret != PIPE_OK) {
return ret;
}
}
if (svga->rebind.texture_samplers) {
ret = svga_reemit_tss_bindings(svga);
if (ret != PIPE_OK) {
return ret;
}
}
SVGA_DBG(DEBUG_DMA, "draw to sid %p, %d prims\n",
svga->curr.framebuffer.cbufs[0] ?
svga_surface(svga->curr.framebuffer.cbufs[0])->handle : NULL,
......
......@@ -52,6 +52,13 @@ try_clear(struct svga_context *svga,
if (ret)
return ret;
if (svga->rebind.rendertargets) {
ret = svga_reemit_framebuffer_bindings(svga);
if (ret != PIPE_OK) {
return ret;
}
}
if ((buffers & PIPE_CLEAR_COLOR) && fb->cbufs[0]) {
flags |= SVGA3D_CLEAR_COLOR;
util_pack_color(rgba, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
......
......@@ -43,7 +43,7 @@ static int emit_framebuffer( struct svga_context *svga,
{
const struct pipe_framebuffer_state *curr = &svga->curr.framebuffer;
struct pipe_framebuffer_state *hw = &svga->state.hw_clear.framebuffer;
boolean reemit = !!(dirty & SVGA_NEW_COMMAND_BUFFER);
boolean reemit = svga->rebind.rendertargets;
unsigned i;
enum pipe_error ret;
......@@ -88,6 +88,7 @@ static int emit_framebuffer( struct svga_context *svga,
pipe_surface_reference(&hw->zsbuf, curr->zsbuf);
}
svga->rebind.rendertargets = FALSE;
return 0;
}
......@@ -108,6 +109,8 @@ svga_reemit_framebuffer_bindings(struct svga_context *svga)
unsigned i;
enum pipe_error ret;
assert(svga->rebind.rendertargets);
for (i = 0; i < MIN2(PIPE_MAX_COLOR_BUFS, 8); ++i) {
if (hw->cbufs[i]) {
ret = SVGA3D_SetRenderTarget(svga->swc, SVGA3D_RT_COLOR0 + i, hw->cbufs[i]);
......@@ -138,6 +141,8 @@ svga_reemit_framebuffer_bindings(struct svga_context *svga)
}
}
svga->rebind.rendertargets = FALSE;
return PIPE_OK;
}
......@@ -145,8 +150,7 @@ svga_reemit_framebuffer_bindings(struct svga_context *svga)
struct svga_tracked_state svga_hw_framebuffer =
{
"hw framebuffer state",
SVGA_NEW_FRAME_BUFFER |
SVGA_NEW_COMMAND_BUFFER,
SVGA_NEW_FRAME_BUFFER,
emit_framebuffer
};
......
......@@ -66,7 +66,7 @@ static int
update_tss_binding(struct svga_context *svga,
unsigned dirty )
{
boolean reemit = !!(dirty & SVGA_NEW_COMMAND_BUFFER);
boolean reemit = svga->rebind.texture_samplers;
unsigned i;
unsigned count = MAX2( svga->curr.num_sampler_views,
svga->state.hw_draw.num_views );
......@@ -159,6 +159,8 @@ update_tss_binding(struct svga_context *svga,
SVGA_FIFOCommitAll( svga->swc );
}
svga->rebind.texture_samplers = FALSE;
return 0;
fail:
......@@ -181,6 +183,8 @@ svga_reemit_tss_bindings(struct svga_context *svga)
enum pipe_error ret;
struct bind_queue queue;
assert(svga->rebind.texture_samplers);
queue.bind_count = 0;
for (i = 0; i < svga->state.hw_draw.num_views; i++) {
......@@ -220,6 +224,8 @@ svga_reemit_tss_bindings(struct svga_context *svga)
SVGA_FIFOCommitAll(svga->swc);
}
svga->rebind.texture_samplers = FALSE;
return PIPE_OK;
}
......@@ -227,8 +233,7 @@ svga_reemit_tss_bindings(struct svga_context *svga)
struct svga_tracked_state svga_hw_tss_binding = {
"texture binding emit",
SVGA_NEW_TEXTURE_BINDING |
SVGA_NEW_SAMPLER |
SVGA_NEW_COMMAND_BUFFER,
SVGA_NEW_SAMPLER,
update_tss_binding
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment