summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/radeon/r600_cs.h
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2016-07-29 21:53:23 +0200
committerMarek Olšák <marek.olsak@amd.com>2016-08-06 13:56:14 +0200
commitc5ff0d3e65d499dcb466c151ed48cdf67e43cdbb (patch)
treebd999e295394f4a002d5d539907288b19e0afa44 /src/gallium/drivers/radeon/r600_cs.h
parent076db67217741aa820feadccc66067516d4cf4ca (diff)
downloadexternal_mesa3d-c5ff0d3e65d499dcb466c151ed48cdf67e43cdbb.zip
external_mesa3d-c5ff0d3e65d499dcb466c151ed48cdf67e43cdbb.tar.gz
external_mesa3d-c5ff0d3e65d499dcb466c151ed48cdf67e43cdbb.tar.bz2
gallium/radeon: move radeon_winsys::cs_memory_below_limit to drivers
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Diffstat (limited to 'src/gallium/drivers/radeon/r600_cs.h')
-rw-r--r--src/gallium/drivers/radeon/r600_cs.h29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/gallium/drivers/radeon/r600_cs.h b/src/gallium/drivers/radeon/r600_cs.h
index 988774a..e97769b 100644
--- a/src/gallium/drivers/radeon/r600_cs.h
+++ b/src/gallium/drivers/radeon/r600_cs.h
@@ -34,6 +34,29 @@
#include "r600d_common.h"
/**
+ * Return true if there is enough memory in VRAM and GTT for the buffers
+ * added so far.
+ *
+ * \param vram VRAM memory size not added to the buffer list yet
+ * \param gtt GTT memory size not added to the buffer list yet
+ */
+static inline bool
+radeon_cs_memory_below_limit(struct r600_common_screen *screen,
+ struct radeon_winsys_cs *cs,
+ uint64_t vram, uint64_t gtt)
+{
+ vram += cs->used_vram;
+ gtt += cs->used_gart;
+
+ /* Anything that goes above the VRAM size should go to GTT. */
+ if (vram > screen->info.vram_size)
+ gtt += vram - screen->info.vram_size;
+
+ /* Now we just need to check if we have enough GTT. */
+ return gtt < screen->info.gart_size * 0.7;
+}
+
+/**
* Add a buffer to the buffer list for the given command stream (CS).
*
* All buffers used by a CS must be added to the list. This tells the kernel
@@ -80,9 +103,9 @@ radeon_add_to_buffer_list_check_mem(struct r600_common_context *rctx,
bool check_mem)
{
if (check_mem &&
- !rctx->ws->cs_memory_below_limit(ring->cs,
- rctx->vram + rbo->vram_usage,
- rctx->gtt + rbo->gart_usage))
+ !radeon_cs_memory_below_limit(rctx->screen, ring->cs,
+ rctx->vram + rbo->vram_usage,
+ rctx->gtt + rbo->gart_usage))
ring->flush(rctx, RADEON_FLUSH_ASYNC, NULL);
return radeon_add_to_buffer_list(rctx, ring, rbo, usage, priority);