diff options
author | Michal Krol <michal@vmware.com> | 2010-03-10 15:49:30 +0100 |
---|---|---|
committer | Michal Krol <michal@vmware.com> | 2010-03-10 15:49:30 +0100 |
commit | 3ce4375912c8ea488460e593e07c5bb15b92dca9 (patch) | |
tree | 1011fa439bd829fd46a44fd99478135848800e73 /progs/gallium | |
parent | f59f28093ea827bd234d8e1a36bdd56a9fce5f09 (diff) | |
parent | 9b348d0ed125a22be3f318ac60cef6f201edfdab (diff) |
Merge branch 'master' into gallium-sampler-view
Conflicts:
src/gallium/auxiliary/Makefile
src/gallium/auxiliary/SConscript
src/gallium/auxiliary/tgsi/tgsi_exec.c
src/gallium/auxiliary/util/u_blitter.c
src/gallium/drivers/i915/i915_context.h
src/gallium/drivers/i965/brw_context.h
src/gallium/drivers/llvmpipe/lp_context.h
src/gallium/drivers/nv50/nv50_context.h
src/gallium/drivers/nv50/nv50_state_validate.c
src/gallium/drivers/nv50/nv50_tex.c
src/gallium/drivers/r300/r300_blit.c
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/softpipe/sp_context.h
src/gallium/drivers/svga/svga_context.h
src/gallium/drivers/svga/svga_pipe_sampler.c
Diffstat (limited to 'progs/gallium')
-rwxr-xr-x | progs/gallium/python/retrace/interpreter.py | 5 | ||||
-rw-r--r-- | progs/gallium/python/samples/gs.py | 2 | ||||
-rw-r--r-- | progs/gallium/python/samples/tri.py | 2 | ||||
-rwxr-xr-x | progs/gallium/python/tests/base.py | 4 | ||||
-rw-r--r-- | progs/gallium/python/tests/regress/fragment-shader/fragment-shader.py | 2 | ||||
-rw-r--r-- | progs/gallium/python/tests/regress/vertex-shader/vertex-shader.py | 2 | ||||
-rwxr-xr-x | progs/gallium/python/tests/surface_copy.py | 16 | ||||
-rwxr-xr-x | progs/gallium/python/tests/texture_render.py | 20 | ||||
-rwxr-xr-x | progs/gallium/python/tests/texture_sample.py | 24 | ||||
-rwxr-xr-x | progs/gallium/python/tests/texture_transfer.py | 16 | ||||
-rw-r--r-- | progs/gallium/unit/SConscript | 20 | ||||
-rw-r--r-- | progs/gallium/unit/u_format_test.c | 242 |
12 files changed, 308 insertions, 47 deletions
diff --git a/progs/gallium/python/retrace/interpreter.py b/progs/gallium/python/retrace/interpreter.py index 2db71a212f..1a96181255 100755 --- a/progs/gallium/python/retrace/interpreter.py +++ b/progs/gallium/python/retrace/interpreter.py @@ -543,7 +543,7 @@ class Context(Object): gallium.PIPE_FORMAT_R32G32_FLOAT: '2f', gallium.PIPE_FORMAT_R32G32B32_FLOAT: '3f', gallium.PIPE_FORMAT_R32G32B32A32_FLOAT: '4f', - gallium.PIPE_FORMAT_B8G8R8A8_UNORM: '4B', + gallium.PIPE_FORMAT_A8R8G8B8_UNORM: '4B', gallium.PIPE_FORMAT_R8G8B8A8_UNORM: '4B', gallium.PIPE_FORMAT_R16G16B16_SNORM: '3h', }[velem.src_format] @@ -551,7 +551,6 @@ class Context(Object): data = vbuf.buffer.read() values = unpack_from(format, data, offset) sys.stdout.write('\t\t{' + ', '.join(map(str, values)) + '},\n') - assert len(values) == velem.nr_components sys.stdout.write('\t},\n') sys.stdout.flush() @@ -572,7 +571,7 @@ class Context(Object): sys.stdout.write('\t{\n') for i in range(start, start + count): - if i >= start + 16: + if i >= start + 16 and not self.interpreter.verbosity(3): sys.stdout.write('\t...\n') break offset = i*isize diff --git a/progs/gallium/python/samples/gs.py b/progs/gallium/python/samples/gs.py index cd68abac9a..5c22269b18 100644 --- a/progs/gallium/python/samples/gs.py +++ b/progs/gallium/python/samples/gs.py @@ -134,7 +134,7 @@ def test(dev): # framebuffer cbuf = dev.texture_create( - PIPE_FORMAT_X8R8G8B8_UNORM, + PIPE_FORMAT_B8G8R8X8_UNORM, width, height, tex_usage=PIPE_TEXTURE_USAGE_RENDER_TARGET, ).get_surface() diff --git a/progs/gallium/python/samples/tri.py b/progs/gallium/python/samples/tri.py index f0b5e3dc98..d7fbdb10ac 100644 --- a/progs/gallium/python/samples/tri.py +++ b/progs/gallium/python/samples/tri.py @@ -134,7 +134,7 @@ def test(dev): # framebuffer cbuf = dev.texture_create( - PIPE_FORMAT_X8R8G8B8_UNORM, + PIPE_FORMAT_B8G8R8X8_UNORM, width, height, tex_usage=PIPE_TEXTURE_USAGE_RENDER_TARGET, ).get_surface() diff --git a/progs/gallium/python/tests/base.py b/progs/gallium/python/tests/base.py index b022d073fd..bd82f50811 100755 --- a/progs/gallium/python/tests/base.py +++ b/progs/gallium/python/tests/base.py @@ -50,8 +50,8 @@ def is_depth_stencil_format(format): # FIXME: make and use binding to util_format_is_depth_or_stencil return format in ( PIPE_FORMAT_Z32_UNORM, - PIPE_FORMAT_Z24S8_UNORM, - PIPE_FORMAT_Z24X8_UNORM, + PIPE_FORMAT_S8Z24_UNORM, + PIPE_FORMAT_X8Z24_UNORM, PIPE_FORMAT_Z16_UNORM, ) diff --git a/progs/gallium/python/tests/regress/fragment-shader/fragment-shader.py b/progs/gallium/python/tests/regress/fragment-shader/fragment-shader.py index 41dd69d254..b758b4c622 100644 --- a/progs/gallium/python/tests/regress/fragment-shader/fragment-shader.py +++ b/progs/gallium/python/tests/regress/fragment-shader/fragment-shader.py @@ -113,7 +113,7 @@ def test(dev, name): # framebuffer cbuf = dev.texture_create( - PIPE_FORMAT_X8R8G8B8_UNORM, + PIPE_FORMAT_B8G8R8X8_UNORM, width, height, tex_usage=PIPE_TEXTURE_USAGE_RENDER_TARGET, ).get_surface() diff --git a/progs/gallium/python/tests/regress/vertex-shader/vertex-shader.py b/progs/gallium/python/tests/regress/vertex-shader/vertex-shader.py index 2c44f872e1..bd838cc282 100644 --- a/progs/gallium/python/tests/regress/vertex-shader/vertex-shader.py +++ b/progs/gallium/python/tests/regress/vertex-shader/vertex-shader.py @@ -114,7 +114,7 @@ def test(dev, name): # framebuffer cbuf = dev.texture_create( - PIPE_FORMAT_X8R8G8B8_UNORM, + PIPE_FORMAT_B8G8R8X8_UNORM, width, height, tex_usage=PIPE_TEXTURE_USAGE_RENDER_TARGET, ).get_surface() diff --git a/progs/gallium/python/tests/surface_copy.py b/progs/gallium/python/tests/surface_copy.py index df5babb78a..a3f1b3e130 100755 --- a/progs/gallium/python/tests/surface_copy.py +++ b/progs/gallium/python/tests/surface_copy.py @@ -131,15 +131,15 @@ def main(): ] formats = [ - PIPE_FORMAT_A8R8G8B8_UNORM, - PIPE_FORMAT_X8R8G8B8_UNORM, - PIPE_FORMAT_A8R8G8B8_SRGB, - PIPE_FORMAT_R5G6B5_UNORM, - PIPE_FORMAT_A1R5G5B5_UNORM, - PIPE_FORMAT_A4R4G4B4_UNORM, + PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_B8G8R8X8_UNORM, + PIPE_FORMAT_B8G8R8A8_SRGB, + PIPE_FORMAT_B5G6R5_UNORM, + PIPE_FORMAT_B5G5R5A1_UNORM, + PIPE_FORMAT_B4G4R4A4_UNORM, PIPE_FORMAT_Z32_UNORM, - PIPE_FORMAT_Z24S8_UNORM, - PIPE_FORMAT_Z24X8_UNORM, + PIPE_FORMAT_S8Z24_UNORM, + PIPE_FORMAT_X8Z24_UNORM, PIPE_FORMAT_Z16_UNORM, PIPE_FORMAT_S8_UNORM, PIPE_FORMAT_A8_UNORM, diff --git a/progs/gallium/python/tests/texture_render.py b/progs/gallium/python/tests/texture_render.py index 0fac1ea5ef..1e26639db6 100755 --- a/progs/gallium/python/tests/texture_render.py +++ b/progs/gallium/python/tests/texture_render.py @@ -96,7 +96,7 @@ class TextureTest(TestCase): src_texture = dev.texture_create( target = target, - format = PIPE_FORMAT_A8R8G8B8_UNORM, + format = PIPE_FORMAT_B8G8R8A8_UNORM, width = dst_surface.width, height = dst_surface.height, depth = 1, @@ -149,7 +149,7 @@ class TextureTest(TestCase): # framebuffer cbuf_tex = dev.texture_create( - PIPE_FORMAT_A8R8G8B8_UNORM, + PIPE_FORMAT_B8G8R8A8_UNORM, width, height, tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET, @@ -251,15 +251,15 @@ def main(): ] formats = [ - PIPE_FORMAT_A8R8G8B8_UNORM, - PIPE_FORMAT_X8R8G8B8_UNORM, - #PIPE_FORMAT_A8R8G8B8_SRGB, - PIPE_FORMAT_R5G6B5_UNORM, - PIPE_FORMAT_A1R5G5B5_UNORM, - PIPE_FORMAT_A4R4G4B4_UNORM, + PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_B8G8R8X8_UNORM, + #PIPE_FORMAT_B8G8R8A8_SRGB, + PIPE_FORMAT_B5G6R5_UNORM, + PIPE_FORMAT_B5G5R5A1_UNORM, + PIPE_FORMAT_B4G4R4A4_UNORM, #PIPE_FORMAT_Z32_UNORM, - #PIPE_FORMAT_Z24S8_UNORM, - #PIPE_FORMAT_Z24X8_UNORM, + #PIPE_FORMAT_S8Z24_UNORM, + #PIPE_FORMAT_X8Z24_UNORM, #PIPE_FORMAT_Z16_UNORM, #PIPE_FORMAT_S8_UNORM, PIPE_FORMAT_A8_UNORM, diff --git a/progs/gallium/python/tests/texture_sample.py b/progs/gallium/python/tests/texture_sample.py index db32b537a1..49545c2e07 100755 --- a/progs/gallium/python/tests/texture_sample.py +++ b/progs/gallium/python/tests/texture_sample.py @@ -193,7 +193,7 @@ class TextureColorSampleTest(TestCase): # framebuffer cbuf_tex = dev.texture_create( - PIPE_FORMAT_A8R8G8B8_UNORM, + PIPE_FORMAT_B8G8R8A8_UNORM, width, height, tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET, @@ -383,14 +383,14 @@ class TextureDepthSampleTest(TestCase): # framebuffer cbuf_tex = dev.texture_create( - PIPE_FORMAT_A8R8G8B8_UNORM, + PIPE_FORMAT_B8G8R8A8_UNORM, width, height, tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET, ) zsbuf_tex = dev.texture_create( - PIPE_FORMAT_Z24X8_UNORM, + PIPE_FORMAT_X8Z24_UNORM, width, height, tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET, @@ -498,15 +498,15 @@ def main(): ] color_formats = [ - PIPE_FORMAT_A8R8G8B8_UNORM, - PIPE_FORMAT_X8R8G8B8_UNORM, - #PIPE_FORMAT_A8R8G8B8_SRGB, - PIPE_FORMAT_R5G6B5_UNORM, - PIPE_FORMAT_A1R5G5B5_UNORM, - PIPE_FORMAT_A4R4G4B4_UNORM, + PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_B8G8R8X8_UNORM, + #PIPE_FORMAT_B8G8R8A8_SRGB, + PIPE_FORMAT_B5G6R5_UNORM, + PIPE_FORMAT_B5G5R5A1_UNORM, + PIPE_FORMAT_B4G4R4A4_UNORM, PIPE_FORMAT_A8_UNORM, PIPE_FORMAT_L8_UNORM, - PIPE_FORMAT_YCBCR, + PIPE_FORMAT_UYVY, PIPE_FORMAT_DXT1_RGB, #PIPE_FORMAT_DXT1_RGBA, #PIPE_FORMAT_DXT3_RGBA, @@ -515,8 +515,8 @@ def main(): depth_formats = [ PIPE_FORMAT_Z32_UNORM, - PIPE_FORMAT_Z24S8_UNORM, - PIPE_FORMAT_Z24X8_UNORM, + PIPE_FORMAT_S8Z24_UNORM, + PIPE_FORMAT_X8Z24_UNORM, PIPE_FORMAT_Z16_UNORM, ] diff --git a/progs/gallium/python/tests/texture_transfer.py b/progs/gallium/python/tests/texture_transfer.py index 35daca9e49..7da00e4255 100755 --- a/progs/gallium/python/tests/texture_transfer.py +++ b/progs/gallium/python/tests/texture_transfer.py @@ -111,15 +111,15 @@ def main(): ] formats = [ - PIPE_FORMAT_A8R8G8B8_UNORM, - PIPE_FORMAT_X8R8G8B8_UNORM, - PIPE_FORMAT_A8R8G8B8_SRGB, - PIPE_FORMAT_R5G6B5_UNORM, - PIPE_FORMAT_A1R5G5B5_UNORM, - PIPE_FORMAT_A4R4G4B4_UNORM, + PIPE_FORMAT_B8G8R8A8_UNORM, + PIPE_FORMAT_B8G8R8X8_UNORM, + PIPE_FORMAT_B8G8R8A8_SRGB, + PIPE_FORMAT_B5G6R5_UNORM, + PIPE_FORMAT_B5G5R5A1_UNORM, + PIPE_FORMAT_B4G4R4A4_UNORM, PIPE_FORMAT_Z32_UNORM, - PIPE_FORMAT_Z24S8_UNORM, - PIPE_FORMAT_Z24X8_UNORM, + PIPE_FORMAT_S8Z24_UNORM, + PIPE_FORMAT_X8Z24_UNORM, PIPE_FORMAT_Z16_UNORM, PIPE_FORMAT_S8_UNORM, PIPE_FORMAT_A8_UNORM, diff --git a/progs/gallium/unit/SConscript b/progs/gallium/unit/SConscript new file mode 100644 index 0000000000..9891440df6 --- /dev/null +++ b/progs/gallium/unit/SConscript @@ -0,0 +1,20 @@ +Import('*') + +env = env.Clone() + +env.Prepend(LIBS = [gallium]) + +progs = [ + 'u_format_test' +] + +for prog in progs: + prog = env.Program( + target = prog, + source = prog + '.c', + ) + + # http://www.scons.org/wiki/UnitTests + test_alias = env.Alias('unit', [prog], prog[0].abspath) + AlwaysBuild(test_alias) + diff --git a/progs/gallium/unit/u_format_test.c b/progs/gallium/unit/u_format_test.c new file mode 100644 index 0000000000..5274311e03 --- /dev/null +++ b/progs/gallium/unit/u_format_test.c @@ -0,0 +1,242 @@ +/************************************************************************** + * + * Copyright 2009-2010 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#include <stdlib.h> +#include <stdio.h> + +#include "util/u_format.h" +#include "util/u_format_tests.h" +#include "util/u_format_pack.h" + + +static boolean +test_format_unpack_4f(const struct util_format_test_case *test) +{ + float unpacked[4]; + unsigned i; + boolean success; + + util_format_unpack_4f(test->format, unpacked, test->packed); + + success = TRUE; + for (i = 0; i < 4; ++i) + if (test->unpacked[i] != unpacked[i]) + success = FALSE; + + if (!success) { + printf("FAILED: (%f %f %f %f) obtained\n", unpacked[0], unpacked[1], unpacked[2], unpacked[3]); + printf(" (%f %f %f %f) expected\n", test->unpacked[0], test->unpacked[1], test->unpacked[2], test->unpacked[3]); + } + + return success; +} + + +static boolean +test_format_pack_4f(const struct util_format_test_case *test) +{ + uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES]; + unsigned i; + boolean success; + + memset(packed, 0, sizeof packed); + + util_format_pack_4f(test->format, packed, test->unpacked[0], test->unpacked[1], test->unpacked[2], test->unpacked[3]); + + success = TRUE; + for (i = 0; i < UTIL_FORMAT_MAX_PACKED_BYTES; ++i) + if ((test->packed[i] & test->mask[i]) != (packed[i] & test->mask[i])) + success = FALSE; + + if (!success) { + /* TODO: print more than 4 bytes */ + printf("FAILED: (%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x) obtained\n", + packed[0], packed[1], packed[2], packed[3], + packed[4], packed[5], packed[6], packed[7], + packed[8], packed[9], packed[10], packed[11], + packed[12], packed[13], packed[14], packed[15]); + printf(" (%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x) expected\n", + test->packed[0], test->packed[1], test->packed[2], test->packed[3], + test->packed[4], test->packed[5], test->packed[6], test->packed[7], + test->packed[8], test->packed[9], test->packed[10], test->packed[11], + test->packed[12], test->packed[13], test->packed[14], test->packed[15]); + } + + return success; +} + + +static boolean +convert_4f_to_4ub(uint8_t *dst, const double *src) +{ + unsigned i; + boolean accurate = TRUE; + + for (i = 0; i < 4; ++i) { + if (src[i] < 0.0) { + accurate = FALSE; + dst[i] = 0; + } + else if (src[i] > 1.0) { + accurate = FALSE; + dst[i] = 255; + } + else { + dst[i] = src[i] * 255.0; + } + } + + return accurate; +} + + +static boolean +test_format_unpack_4ub(const struct util_format_test_case *test) +{ + uint8_t unpacked[4]; + uint8_t expected[4]; + unsigned i; + boolean success; + + util_format_unpack_4ub(test->format, unpacked, test->packed); + + convert_4f_to_4ub(expected, test->unpacked); + + success = TRUE; + for (i = 0; i < 4; ++i) + if (expected[i] != unpacked[i]) + success = FALSE; + + if (!success) { + printf("FAILED: (0x%02x 0x%02x 0x%02x 0x%02x) obtained\n", unpacked[0], unpacked[1], unpacked[2], unpacked[3]); + printf(" (0x%02x 0x%02x 0x%02x 0x%02x) expected\n", expected[0], expected[1], expected[2], expected[3]); + } + + return success; +} + + +static boolean +test_format_pack_4ub(const struct util_format_test_case *test) +{ + uint8_t unpacked[4]; + uint8_t packed[UTIL_FORMAT_MAX_PACKED_BYTES]; + unsigned i; + boolean success; + + if (!convert_4f_to_4ub(unpacked, test->unpacked)) { + /* + * Skip test cases which cannot be represented by four unorm bytes. + */ + return TRUE; + } + + memset(packed, 0, sizeof packed); + + util_format_pack_4ub(test->format, packed, unpacked[0], unpacked[1], unpacked[2], unpacked[3]); + + success = TRUE; + for (i = 0; i < UTIL_FORMAT_MAX_PACKED_BYTES; ++i) + if ((test->packed[i] & test->mask[i]) != (packed[i] & test->mask[i])) + success = FALSE; + + if (!success) { + /* TODO: print more than 4 bytes */ + printf("FAILED: (%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x) obtained\n", + packed[0], packed[1], packed[2], packed[3], + packed[4], packed[5], packed[6], packed[7], + packed[8], packed[9], packed[10], packed[11], + packed[12], packed[13], packed[14], packed[15]); + printf(" (%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x) expected\n", + test->packed[0], test->packed[1], test->packed[2], test->packed[3], + test->packed[4], test->packed[5], test->packed[6], test->packed[7], + test->packed[8], test->packed[9], test->packed[10], test->packed[11], + test->packed[12], test->packed[13], test->packed[14], test->packed[15]); + } + + return success; +} + + +typedef boolean +(*test_func_t)(const struct util_format_test_case *test); + + +static boolean +test_one(test_func_t func, const char *suffix) +{ + enum pipe_format last_format = PIPE_FORMAT_NONE; + unsigned i; + bool success = TRUE; + + for (i = 0; i < util_format_nr_test_cases; ++i) { + const struct util_format_test_case *test = &util_format_test_cases[i]; + if (test->format != last_format) { + const struct util_format_description *format_desc; + format_desc = util_format_description(test->format); + printf("Testing util_format_%s_%s ...\n", format_desc->short_name, suffix); + last_format = test->format; + } + + if (!func(&util_format_test_cases[i])) + success = FALSE; + } + + return success; +} + + +static boolean +test_all(void) +{ + bool success = TRUE; + + if (!test_one(&test_format_pack_4f, "pack_4f")) + success = FALSE; + + if (!test_one(&test_format_unpack_4f, "unpack_4f")) + success = FALSE; + + if (!test_one(&test_format_pack_4ub, "pack_4ub")) + success = FALSE; + + if (!test_one(&test_format_unpack_4ub, "unpack_4ub")) + success = FALSE; + + return success; +} + + +int main(int argc, char **argv) +{ + boolean success; + + success = test_all(); + + return success ? 0 : 1; +} |