struct fd_ringbuffer *ring = batch->gmem;
struct fd_resource *rsc = fd_resource(psurf->texture);
enum pipe_format format = psurf->format;
+
+ if (!rsc->valid)
+ return;
+
if (stencil) {
rsc = rsc->stencil;
format = rsc->base.format;
}
+
struct fd_resource_slice *slice = fd_resource_slice(rsc, psurf->u.tex.level);
uint32_t offset = fd_resource_offset(rsc, psurf->u.tex.level,
psurf->u.tex.first_layer);
* The 'cleared' bits will be set for buffers which are *entirely*
* cleared, and 'partial_cleared' bits will be set if you must
* check cleared_scissor.
+ *
+ * The 'invalidated' bits are set for cleared buffers, and buffers
+ * where the contents are undefined, ie. what we don't need to restore
+ * to gmem.
*/
enum {
/* align bitmask values w/ PIPE_CLEAR_*.. since that is convenient.. */
FD_BUFFER_DEPTH = PIPE_CLEAR_DEPTH,
FD_BUFFER_STENCIL = PIPE_CLEAR_STENCIL,
FD_BUFFER_ALL = FD_BUFFER_COLOR | FD_BUFFER_DEPTH | FD_BUFFER_STENCIL,
- } cleared, restore, resolve;
+ } invalidated, cleared, restore, resolve;
/* is this a non-draw batch (ie compute/blit which has no pfb state)? */
bool nondraw : 1;
mtx_lock(&ctx->screen->lock);
if (fd_depth_enabled(ctx)) {
- if (fd_resource(pfb->zsbuf->texture)->valid)
+ if (fd_resource(pfb->zsbuf->texture)->valid) {
restore_buffers |= FD_BUFFER_DEPTH;
+ } else {
+ batch->invalidated |= FD_BUFFER_DEPTH;
+ }
buffers |= FD_BUFFER_DEPTH;
resource_written(batch, pfb->zsbuf->texture);
batch->gmem_reason |= FD_GMEM_DEPTH_ENABLED;
}
if (fd_stencil_enabled(ctx)) {
- if (fd_resource(pfb->zsbuf->texture)->valid)
+ if (fd_resource(pfb->zsbuf->texture)->valid) {
restore_buffers |= FD_BUFFER_STENCIL;
+ } else {
+ batch->invalidated |= FD_BUFFER_STENCIL;
+ }
buffers |= FD_BUFFER_STENCIL;
resource_written(batch, pfb->zsbuf->texture);
batch->gmem_reason |= FD_GMEM_STENCIL_ENABLED;
surf = pfb->cbufs[i]->texture;
- resource_written(batch, surf);
-
- if (fd_resource(surf)->valid)
+ if (fd_resource(surf)->valid) {
restore_buffers |= PIPE_CLEAR_COLOR0 << i;
+ } else {
+ batch->invalidated |= PIPE_CLEAR_COLOR0 << i;
+ }
+
+ resource_written(batch, surf);
buffers |= PIPE_CLEAR_COLOR0 << i;
ctx->stats.prims_generated += prims;
/* any buffers that haven't been cleared yet, we need to restore: */
- batch->restore |= restore_buffers & (FD_BUFFER_ALL & ~batch->cleared);
+ batch->restore |= restore_buffers & (FD_BUFFER_ALL & ~batch->invalidated);
/* and any buffers used, need to be resolved: */
batch->resolve |= buffers;
*/
cleared_buffers = buffers & (FD_BUFFER_ALL & ~batch->restore);
batch->cleared |= cleared_buffers;
+ batch->invalidated |= cleared_buffers;
batch->resolve |= buffers;
batch->needs_flush = true;