{
struct svga_screen *svgascreen = svga_screen(svga->pipe.screen);
struct pipe_fence_handle *fence = NULL;
- enum pipe_error ret;
svga->curr.nr_fbs = 0;
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)
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;
#define SVGA_NEW_ZERO_STRIDE 0x2000000
#define SVGA_NEW_TEXTURE_FLAGS 0x4000000
#define SVGA_NEW_STENCIL_REF 0x8000000
-#define SVGA_NEW_COMMAND_BUFFER 0x10000000
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,
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);
{
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;
pipe_surface_reference(&hw->zsbuf, curr->zsbuf);
}
+ svga->rebind.rendertargets = FALSE;
return 0;
}
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]);
}
}
+ svga->rebind.rendertargets = FALSE;
+
return PIPE_OK;
}
struct svga_tracked_state svga_hw_framebuffer =
{
"hw framebuffer state",
- SVGA_NEW_FRAME_BUFFER |
- SVGA_NEW_COMMAND_BUFFER,
+ SVGA_NEW_FRAME_BUFFER,
emit_framebuffer
};
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 );
SVGA_FIFOCommitAll( svga->swc );
}
+ svga->rebind.texture_samplers = FALSE;
+
return 0;
fail:
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++) {
SVGA_FIFOCommitAll(svga->swc);
}
+ svga->rebind.texture_samplers = FALSE;
+
return PIPE_OK;
}
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
};