summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Fonseca <jrfonseca@tungstengraphics.com>2008-07-17 10:27:10 +0900
committerJosé Fonseca <jrfonseca@tungstengraphics.com>2008-07-18 01:20:44 +0900
commitd398e1360d5c1c0f44a4ba9cd167c39a29ce8254 (patch)
tree9f3a2c163d6b8479cb3217741b6cc56b819bee57
parent457bb10cee6a2f6f7b7e320f066a26e24e13c550 (diff)
python: Reimplement tile comparison in C to speed up tests.
-rw-r--r--src/gallium/state_trackers/python/gallium.i48
-rw-r--r--src/gallium/state_trackers/python/tests/texture.py20
2 files changed, 53 insertions, 15 deletions
diff --git a/src/gallium/state_trackers/python/gallium.i b/src/gallium/state_trackers/python/gallium.i
index fe0afb18a9..1c207a41b9 100644
--- a/src/gallium/state_trackers/python/gallium.i
+++ b/src/gallium/state_trackers/python/gallium.i
@@ -425,23 +425,23 @@ error1:
void unmap( void );
void
- get_tile_raw(unsigned x, unsigned y, unsigned w, unsigned h, unsigned char *p, unsigned stride) {
- pipe_get_tile_raw($self, x, y, w, h, p, stride);
+ get_tile_raw(unsigned x, unsigned y, unsigned w, unsigned h, unsigned char *raw, unsigned stride) {
+ pipe_get_tile_raw($self, x, y, w, h, raw, stride);
}
void
- put_tile_raw(unsigned x, unsigned y, unsigned w, unsigned h, const unsigned char *p, unsigned stride) {
- pipe_put_tile_raw($self, x, y, w, h, p, stride);
+ put_tile_raw(unsigned x, unsigned y, unsigned w, unsigned h, const unsigned char *raw, unsigned stride) {
+ pipe_put_tile_raw($self, x, y, w, h, raw, stride);
}
void
- get_tile_rgba(unsigned x, unsigned y, unsigned w, unsigned h, float *p) {
- pipe_get_tile_rgba($self, x, y, w, h, p);
+ get_tile_rgba(unsigned x, unsigned y, unsigned w, unsigned h, float *rgba) {
+ pipe_get_tile_rgba($self, x, y, w, h, rgba);
}
void
- put_tile_rgba(unsigned x, unsigned y, unsigned w, unsigned h, const float *p) {
- pipe_put_tile_rgba($self, x, y, w, h, p);
+ put_tile_rgba(unsigned x, unsigned y, unsigned w, unsigned h, const float *rgba) {
+ pipe_put_tile_rgba($self, x, y, w, h, rgba);
}
void
@@ -454,6 +454,38 @@ error1:
pipe_put_tile_z($self, x, y, w, h, z);
}
+ unsigned
+ compare_tile_rgba(unsigned x, unsigned y, unsigned w, unsigned h, const float *rgba, float tol = 0.0)
+ {
+ float *rgba2;
+ const float *p1;
+ const float *p2;
+ unsigned i, j, n;
+
+ rgba2 = MALLOC(h*w*4*sizeof(float));
+ if(!rgba2)
+ return ~0;
+
+ pipe_get_tile_rgba($self, x, y, w, h, rgba2);
+
+ p1 = rgba;
+ p2 = rgba2;
+ n = 0;
+ for(i = h*w; i; --i) {
+ unsigned differs = 0;
+ for(j = 4; j; --j) {
+ float delta = *p2++ - *p1++;
+ if (delta < -tol || delta > tol)
+ differs = 1;
+ }
+ n += differs;
+ }
+
+ FREE(rgba2);
+
+ return n;
+ }
+
};
diff --git a/src/gallium/state_trackers/python/tests/texture.py b/src/gallium/state_trackers/python/tests/texture.py
index edaa2b8b26..3d76953126 100644
--- a/src/gallium/state_trackers/python/tests/texture.py
+++ b/src/gallium/state_trackers/python/tests/texture.py
@@ -304,15 +304,21 @@ class TextureTest(TestCase):
ctx.flush()
- rgba = FloatArray(h*w*4)
-
- cbuf_tex.get_surface(usage = PIPE_BUFFER_USAGE_CPU_READ).get_tile_rgba(x, y, w, h, rgba)
+ cbuf = cbuf_tex.get_surface(usage = PIPE_BUFFER_USAGE_CPU_READ)
+
+ total = h*w
+ different = cbuf.compare_tile_rgba(x, y, w, h, expected_rgba, tol=4.0/256)
+ if different:
+ sys.stderr.write("%u out of %u pixels differ\n" % (different, total))
- if not compare_rgba(w, h, rgba, expected_rgba):
+ if float(total - different)/float(total) < 0.85:
- #show_image(w, h, Result=rgba, Expected=expected_rgba)
- #save_image(w, h, rgba, "result.png")
- #save_image(w, h, expected_rgba, "expected.png")
+ if 0:
+ rgba = FloatArray(h*w*4)
+ cbuf.get_tile_rgba(x, y, w, h, rgba)
+ show_image(w, h, Result=rgba, Expected=expected_rgba)
+ save_image(w, h, rgba, "result.png")
+ save_image(w, h, expected_rgba, "expected.png")
#sys.exit(0)
raise TestFailure