if (usage & (PIPE_MAP_DISCARD_RANGE |
PIPE_MAP_DISCARD_WHOLE_RESOURCE) &&
!(usage & PIPE_MAP_PERSISTENT) &&
- /* Try not to decrement the counter if it's not positive. Still racy,
- * but it makes it harder to wrap the counter from INT_MIN to INT_MAX. */
- tres->max_forced_staging_uploads > 0 &&
- tc->use_forced_staging_uploads &&
- p_atomic_dec_return(&tres->max_forced_staging_uploads) >= 0) {
+ tres->b.flags & PIPE_RESOURCE_FLAG_DONT_MAP_DIRECTLY &&
+ tc->use_forced_staging_uploads) {
usage &= ~(PIPE_MAP_DISCARD_WHOLE_RESOURCE |
PIPE_MAP_UNSYNCHRONIZED);
/* Set expected VRAM and GART usage for the buffer. */
res->vram_usage_kb = 0;
res->gart_usage_kb = 0;
- res->max_forced_staging_uploads = 0;
- res->b.max_forced_staging_uploads = 0;
if (res->domains & RADEON_DOMAIN_VRAM) {
res->vram_usage_kb = MAX2(1, size / 1024);
- if (!sscreen->info.smart_access_memory) {
- /* We don't want to evict buffers from VRAM by mapping them for CPU access,
- * because they might never be moved back again. If a buffer is large enough,
- * upload data by copying from a temporary GTT buffer. 8K might not seem much,
- * but there can be 100000 buffers.
- *
- * This tweak improves performance for viewperf.
- */
- const unsigned min_size = 8196; /* tuned to minimize mapped VRAM */
- /* Number of uploads before mapping directly. A very high number helps display lists (snx). */
- const unsigned max_staging_uploads = 1000000;
-
- res->max_forced_staging_uploads = res->b.max_forced_staging_uploads =
- sscreen->info.has_dedicated_vram && size >= min_size ? max_staging_uploads : 0;
- }
+ /* We don't want to evict buffers from VRAM by mapping them for CPU access,
+ * because they might never be moved back again. If a buffer is large enough,
+ * upload data by copying from a temporary GTT buffer. 8K might not seem much,
+ * but there can be 100000 buffers.
+ *
+ * This tweak improves performance for viewperf creo & snx.
+ */
+ if (!sscreen->info.smart_access_memory &&
+ sscreen->info.has_dedicated_vram &&
+ size >= 8196)
+ res->b.b.flags |= PIPE_RESOURCE_FLAG_DONT_MAP_DIRECTLY;
} else if (res->domains & RADEON_DOMAIN_GTT) {
res->gart_usage_kb = MAX2(1, size / 1024);
}
radeon_bo_reference(sctx->screen->ws, &sdst->buf, ssrc->buf);
sdst->gpu_address = ssrc->gpu_address;
sdst->b.b.bind = ssrc->b.b.bind;
- sdst->b.max_forced_staging_uploads = ssrc->b.max_forced_staging_uploads;
- sdst->max_forced_staging_uploads = ssrc->max_forced_staging_uploads;
sdst->flags = ssrc->flags;
assert(sdst->vram_usage_kb == ssrc->vram_usage_kb);
bool force_discard_range = false;
if (usage & (PIPE_MAP_DISCARD_WHOLE_RESOURCE | PIPE_MAP_DISCARD_RANGE) &&
!(usage & PIPE_MAP_PERSISTENT) &&
- /* Try not to decrement the counter if it's not positive. Still racy,
- * but it makes it harder to wrap the counter from INT_MIN to INT_MAX. */
- buf->max_forced_staging_uploads > 0 &&
- p_atomic_dec_return(&buf->max_forced_staging_uploads) >= 0) {
+ buf->b.b.flags & PIPE_RESOURCE_FLAG_DONT_MAP_DIRECTLY) {
usage &= ~(PIPE_MAP_DISCARD_WHOLE_RESOURCE | PIPE_MAP_UNSYNCHRONIZED);
usage |= PIPE_MAP_DISCARD_RANGE;
force_discard_range = true;