xf86-video-intel: src/sna/sna_threads.c src/sna/sna_trapezoids.c src/sna/sna_trapezoids_imprecise.c src/sna/sna_trapezoids_mono.c src/sna/sna_trapezoids_precise.c

Chris Wilson ickle at kemper.freedesktop.org
Tue Oct 8 02:09:04 PDT 2013


 src/sna/sna_threads.c              |    2 +-
 src/sna/sna_trapezoids.c           |    2 +-
 src/sna/sna_trapezoids_imprecise.c |    6 +++---
 src/sna/sna_trapezoids_mono.c      |    2 +-
 src/sna/sna_trapezoids_precise.c   |   10 +++++-----
 5 files changed, 11 insertions(+), 11 deletions(-)

New commits:
commit 082c08789cf9a8c0cc2bf44d0fee579b96c0798f
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Oct 8 09:40:34 2013 +0100

    sna: Rework the num_threads refinement to avoid the division
    
    We can replace the division by a multiplication.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_threads.c b/src/sna/sna_threads.c
index 3e10e5a..333b7eb 100644
--- a/src/sna/sna_threads.c
+++ b/src/sna/sna_threads.c
@@ -274,7 +274,7 @@ void sna_image_composite(pixman_op_t        op,
 
 		y = dst_y;
 		dy = (height + num_threads - 1) / num_threads;
-		num_threads = (height + dy - 1) / dy;
+		num_threads -= (num_threads-1) * dy >= height;
 
 		data[0].op = op;
 		data[0].src = src;
diff --git a/src/sna/sna_trapezoids.c b/src/sna/sna_trapezoids.c
index 8827b9c..f14a67c 100644
--- a/src/sna/sna_trapezoids.c
+++ b/src/sna/sna_trapezoids.c
@@ -390,7 +390,7 @@ trapezoids_fallback(struct sna *sna,
 
 				y = bounds.y1;
 				dy = (height + num_threads - 1) / num_threads;
-				num_threads = (bounds.y2 - bounds.y1 + dy - 1) / dy;
+				num_threads -= (num_threads-1) * dy >= bounds.y2 - bounds.y1;
 
 				for (n = 1; n < num_threads; n++) {
 					threads[n] = threads[0];
diff --git a/src/sna/sna_trapezoids_imprecise.c b/src/sna/sna_trapezoids_imprecise.c
index 4809e9c..3624dd6 100644
--- a/src/sna/sna_trapezoids_imprecise.c
+++ b/src/sna/sna_trapezoids_imprecise.c
@@ -1982,7 +1982,7 @@ imprecise_trapezoid_span_converter(struct sna *sna,
 		y = clip.extents.y1;
 		h = clip.extents.y2 - clip.extents.y1;
 		h = (h + num_threads - 1) / num_threads;
-		num_threads = (clip.extents.y2 - clip.extents.y1 + h - 1) / h;
+		num_threads -= (num_threads-1) * h >= clip.extents.y2 - clip.extents.y1;
 
 		for (n = 1; n < num_threads; n++) {
 			threads[n] = threads[0];
@@ -2841,7 +2841,7 @@ trapezoid_span_inplace__x8r8g8b8(CARD8 op,
 		y = region.extents.y1;
 		h = region.extents.y2 - region.extents.y1;
 		h = (h + num_threads - 1) / num_threads;
-		num_threads = (region.extents.y2 - region.extents.y1 + h - 1) / h;
+		num_threads -= (num_threads-1) * h >= region.extents.y2 - region.extents.y1;
 
 		for (n = 1; n < num_threads; n++) {
 			threads[n] = threads[0];
@@ -3112,7 +3112,7 @@ imprecise_trapezoid_span_inplace(struct sna *sna,
 		y = region.extents.y1;
 		h = region.extents.y2 - region.extents.y1;
 		h = (h + num_threads - 1) / num_threads;
-		num_threads = (region.extents.y2 - region.extents.y1 + h - 1) / h;
+		num_threads -= (num_threads-1) * h >= region.extents.y2 - region.extents.y1;
 
 		for (n = 1; n < num_threads; n++) {
 			threads[n] = threads[0];
diff --git a/src/sna/sna_trapezoids_mono.c b/src/sna/sna_trapezoids_mono.c
index 790863e..2f7a2bb 100644
--- a/src/sna/sna_trapezoids_mono.c
+++ b/src/sna/sna_trapezoids_mono.c
@@ -843,7 +843,7 @@ mono_trapezoids_span_converter(struct sna *sna,
 		y = extents.y1;
 		h = extents.y2 - extents.y1;
 		h = (h + num_threads - 1) / num_threads;
-		num_threads = (extents.y2 - extents.y1 + h - 1) / h;
+		num_threads -= (num_threads-1) * h >= extents.y2 - extents.y1;
 
 		for (n = 1; n < num_threads; n++) {
 			threads[n] = threads[0];
diff --git a/src/sna/sna_trapezoids_precise.c b/src/sna/sna_trapezoids_precise.c
index 3720d8b..7e68547 100644
--- a/src/sna/sna_trapezoids_precise.c
+++ b/src/sna/sna_trapezoids_precise.c
@@ -1907,7 +1907,7 @@ precise_trapezoid_span_converter(struct sna *sna,
 		y = clip.extents.y1;
 		h = clip.extents.y2 - clip.extents.y1;
 		h = (h + num_threads - 1) / num_threads;
-		num_threads = (clip.extents.y2 - clip.extents.y1 + h - 1) / h;
+		num_threads -= (num_threads-1) * h >= clip.extents.y2 - clip.extents.y1;
 
 		for (n = 1; n < num_threads; n++) {
 			threads[n] = threads[0];
@@ -2133,7 +2133,7 @@ precise_trapezoid_mask_converter(CARD8 op, PicturePtr src, PicturePtr dst,
 		y = extents.y1;
 		h = extents.y2 - extents.y1;
 		h = (h + num_threads - 1) / num_threads;
-		num_threads = (extents.y2 - extents.y1 + h - 1) / h;
+		num_threads -= (num_threads-1) * h >= extents.y2 - extents.y1;
 
 		for (n = 1; n < num_threads; n++) {
 			threads[n] = threads[0];
@@ -2839,7 +2839,7 @@ trapezoid_span_inplace__x8r8g8b8(CARD8 op,
 		y = region.extents.y1;
 		h = region.extents.y2 - region.extents.y1;
 		h = (h + num_threads - 1) / num_threads;
-		num_threads = (region.extents.y2 - region.extents.y1 + h - 1) / h;
+		num_threads -= (num_threads-1) * h >= region.extents.y2 - region.extents.y1;
 
 		for (n = 1; n < num_threads; n++) {
 			threads[n] = threads[0];
@@ -3111,7 +3111,7 @@ precise_trapezoid_span_inplace(struct sna *sna,
 		y = region.extents.y1;
 		h = region.extents.y2 - region.extents.y1;
 		h = (h + num_threads - 1) / num_threads;
-		num_threads = (region.extents.y2 - region.extents.y1 + h - 1) / h;
+		num_threads -= (num_threads-1) * h >= region.extents.y2 - region.extents.y1;
 
 		for (n = 1; n < num_threads; n++) {
 			threads[n] = threads[0];
@@ -3255,7 +3255,7 @@ precise_trapezoid_span_fallback(CARD8 op, PicturePtr src, PicturePtr dst,
 		y = extents.y1;
 		h = extents.y2 - extents.y1;
 		h = (h + num_threads - 1) / num_threads;
-		num_threads = (extents.y2 - extents.y1 + h - 1) / h;
+		num_threads -= (num_threads-1) * h >= extents.y2 - extents.y1;
 
 		for (n = 1; n < num_threads; n++) {
 			threads[n] = threads[0];


More information about the xorg-commit mailing list