assert(key->numMipLevels > 0);
assert(key->numFaces > 0);
+ assert(key->arraySize > 0);
if (key->format == SVGA3D_BUFFER) {
/* Special case: we don't want to count vertex/index buffers
total_size += img_size;
}
- total_size *= key->numFaces;
+ total_size *= key->numFaces * key->arraySize * MAX2(1, key->sampleCount);
return total_size;
}
/* It is now safe to invalidate the surface content.
* It will be done using the current context.
*/
- svga->swc->surface_invalidate(svga->swc, entry->handle);
+ if (svga->swc->surface_invalidate(svga->swc, entry->handle) != PIPE_OK) {
+ MAYBE_UNUSED enum pipe_error ret;
+
+ /* Even though surface invalidation here is done after the command
+ * buffer is flushed, it is still possible that it will
+ * fail because there might be just enough of this command that is
+ * filling up the command buffer, so in this case we will call
+ * the winsys flush directly to flush the buffer.
+ * Note, we don't want to call svga_context_flush() here because
+ * this function itself is called inside svga_context_flush().
+ */
+ svga->swc->flush(svga->swc, NULL);
+ ret = svga->swc->surface_invalidate(svga->swc, entry->handle);
+ assert(ret == PIPE_OK);
+ }
/* add the entry to the invalidated list */
LIST_ADD(&entry->head, &cache->invalidated);
key->cachable);
if (cachable) {
+ /* Try to re-cycle a previously freed, cached surface */
if (key->format == SVGA3D_BUFFER) {
SVGA3dSurfaceFlags hint_flag;
}
if (!handle) {
+ /* Unable to recycle surface, allocate a new one */
unsigned usage = 0;
if (!key->cachable)