Module: Mesa
Branch: master
Commit: 1d6384318eb100e3c4c50ad43e2a3e1942ccbd21
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=1d6384318eb100e3c4c50ad43e2a3e1942ccbd21

Author: Bruno JimĂ©nez <[email protected]>
Date:   Mon May 19 18:14:54 2014 +0200

r600g/compute: Tidy a bit compute_memory_finalize_pending

Explanation of the changes, as requested by Tom Stellard:

Let's take need after is calculated as
item->size_in_dw+2048 - (pool->size_in_dw - allocated)

BEFORE:
If need is positive or 0:
    we calculate need += 1024 - (need % 1024), which is like
        cealing to the nearest multiple of 1024, for example
        0 goes to 1024, 512 goes to 1024 as well, 1025 goes
        to 2048 and so on. So now need is always possitive,
        we do compute_memory_grow_pool, check its output
        and continue.

If need is negative:
    we calculate need += 1024 - (need % 1024), in this case
        we will have negative numbers, and if need is
        [-1024:-1] 0, so now we take the else, recalculate
        need as need = pool->size_in_dw / 10 and
        need += 1024 - (need % 1024), we do
        compute_memory_grow_pool, check its output and continue.

AFTER:
If need is positive or 0:
    we jump the if, calculate need += 1024 - (need % 1024)
        compute_memory_grow_pool, check its output and continue.

If need is negative:
    we enter the if, and need is now pool->size_in_dw / 10.
        Now we calculate need += 1024 - (need % 1024)
        compute_memory_grow_pool, check its output and continue.

Reviewed-by: Tom Stellard <[email protected]>

---

 src/gallium/drivers/r600/compute_memory_pool.c |   19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/r600/compute_memory_pool.c 
b/src/gallium/drivers/r600/compute_memory_pool.c
index e959a6d..01851ad 100644
--- a/src/gallium/drivers/r600/compute_memory_pool.c
+++ b/src/gallium/drivers/r600/compute_memory_pool.c
@@ -319,21 +319,16 @@ int compute_memory_finalize_pending(struct 
compute_memory_pool* pool,
                        int64_t need = item->size_in_dw+2048 -
                                                (pool->size_in_dw - allocated);
 
-                       need += 1024 - (need % 1024);
-
-                       if (need > 0) {
-                               err = compute_memory_grow_pool(pool,
-                                               pipe,
-                                               pool->size_in_dw + need);
-                       }
-                       else {
+                       if (need < 0) {
                                need = pool->size_in_dw / 10;
-                               need += 1024 - (need % 1024);
-                               err = compute_memory_grow_pool(pool,
-                                               pipe,
-                                               pool->size_in_dw + need);
                        }
 
+                       need += 1024 - (need % 1024);
+
+                       err = compute_memory_grow_pool(pool,
+                                       pipe,
+                                       pool->size_in_dw + need);
+
                        if (err == -1)
                                return -1;
                }

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to