#include "util/u_math.h"
#include "util/u_memory.h"
-#include "util/u_hash.h"
+#include "util/crc32.h"
#include "svga_debug.h"
#include "svga_format.h"
pipe_mutex_lock(cache->mutex);
- /* Loop over entries in the validated list */
- curr = cache->validated.next;
+ /* Loop over entries in the invalidated list */
+ curr = cache->invalidated.next;
next = curr->next;
- while (curr != &cache->validated) {
+ while (curr != &cache->invalidated) {
entry = LIST_ENTRY(struct svga_host_surface_cache_entry, curr, head);
assert(entry->handle);
if (sws->surface_is_flushed(sws, entry->handle)) {
- /* remove entry from LRU list */
+ /* remove entry from the invalidated list */
LIST_DEL(&entry->head);
- svgascreen->sws->fence_reference(svgascreen->sws, &entry->fence, fence);
+ sws->fence_reference(sws, &entry->fence, fence);
/* Add entry to the unused list */
LIST_ADD(&entry->head, &cache->unused);
next = curr->next;
}
+ curr = cache->validated.next;
+ next = curr->next;
+ while (curr != &cache->validated) {
+ entry = LIST_ENTRY(struct svga_host_surface_cache_entry, curr, head);
+
+ assert(entry->handle);
+
+ if (sws->surface_is_flushed(sws, entry->handle)) {
+ /* remove entry from the validated list */
+ LIST_DEL(&entry->head);
+
+ /* it is now safe to invalidate the surface content. */
+ sws->surface_invalidate(sws, entry->handle);
+
+ /* add the entry to the invalidated list */
+ LIST_ADD(&entry->head, &cache->invalidated);
+ }
+
+ curr = next;
+ next = curr->next;
+ }
+
pipe_mutex_unlock(cache->mutex);
}
}
if (cache->entries[i].fence)
- svgascreen->sws->fence_reference(svgascreen->sws,
- &cache->entries[i].fence, NULL);
+ sws->fence_reference(sws, &cache->entries[i].fence, NULL);
}
pipe_mutex_destroy(cache->mutex);
LIST_INITHEAD(&cache->validated);
+ LIST_INITHEAD(&cache->invalidated);
+
LIST_INITHEAD(&cache->empty);
for (i = 0; i < SVGA_HOST_SURFACE_CACHE_SIZE; ++i)
LIST_ADDTAIL(&cache->entries[i].head, &cache->empty);
* allocate a new surface.
* \param bind_flags bitmask of PIPE_BIND_x flags
* \param usage one of PIPE_USAGE_x values
+ * \param validated return True if the surface is a reused surface
*/
struct svga_winsys_surface *
svga_screen_surface_create(struct svga_screen *svgascreen,
- unsigned bind_flags, unsigned usage,
+ unsigned bind_flags, enum pipe_resource_usage usage,
+ boolean *validated,
struct svga_host_surface_cache_key *key)
{
struct svga_winsys_screen *sws = svgascreen->sws;
key->numMipLevels,
key->numFaces,
key->arraySize);
+ *validated = TRUE;
}
}
key->size.width,
key->size.height,
key->size.depth);
+
+ *validated = FALSE;
}
return handle;
struct svga_host_surface_cache_entry *entry =
LIST_ENTRY(struct svga_host_surface_cache_entry,
curr, bucket_head);
- if (entry->key.format != 37) {
- debug_printf(" %u x %u x %u format %u\n",
+ if (entry->key.format == SVGA3D_BUFFER) {
+ debug_printf(" %p: buffer %u bytes\n",
+ entry->handle,
+ entry->key.size.width);
+ }
+ else {
+ debug_printf(" %p: %u x %u x %u format %u\n",
+ entry->handle,
entry->key.size.width,
entry->key.size.height,
entry->key.size.depth,