diff options
author | marha <marha@users.sourceforge.net> | 2015-02-22 14:31:16 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2015-02-22 14:31:16 +0100 |
commit | f1c2db43dcf35d2cf4715390bd2391c28e42a8c2 (patch) | |
tree | 46b537271afe0f6534231b1bd4cc4f91ae1fb446 /mesalib/src/gallium/auxiliary/util | |
parent | 5e5a48ff8cd08f123601cd0625ca62a86675aac9 (diff) | |
download | vcxsrv-f1c2db43dcf35d2cf4715390bd2391c28e42a8c2.tar.gz vcxsrv-f1c2db43dcf35d2cf4715390bd2391c28e42a8c2.tar.bz2 vcxsrv-f1c2db43dcf35d2cf4715390bd2391c28e42a8c2.zip |
xwininfo fontconfig libX11 libXdmcp libfontenc libxcb libxcb/xcb-proto mesalib xserver xkeyboard-config mkfontscale git update 22 Feb 2015
xserver commit 3a06faf3fcdb7451125a46181f9152e8e59e9770
libxcb commit e3ec1f74637237ce500dfd0ca59f2e422da4e019
libxcb/xcb-proto commit 4c550465934164aab2449a125f75f4ca07816233
xkeyboard-config commit 26f344c93f8c6141e9233eb68088ba4fd56bc9ef
libX11 commit c8e19b393defd53f046ddc2da3a16881221b3c34
libXdmcp commit 9f4cac7656b221ce2a8f97e7bd31e5e23126d001
libfontenc commit de1843aaf76015c9d99416f3122d169fe331b849
mkfontscale commit 87d628f8eec170ec13bb9feefb1ce05aed07d1d6
xwininfo commit 0c49f8f2bd56b1e77721e81030ea948386dcdf4e
fontconfig commit d6d5adeb7940c0d0beb86489c2a1c2ce59e5c044
mesa commit 4359954d842caa2a9f8d4b50d70ecc789884b68b
Diffstat (limited to 'mesalib/src/gallium/auxiliary/util')
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_cache.c | 2 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_cpu_detect.c | 8 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_format.csv | 11 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_format_bptc.h | 109 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_format_fake.c (renamed from mesalib/src/gallium/auxiliary/util/u_format_bptc.c) | 13 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_format_fake.h | 66 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_format_table.py | 2 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_math.h | 21 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_pstipple.c | 25 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_pstipple.h | 3 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_simple_list.h | 199 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_simple_shaders.c | 12 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_slab.c | 2 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_tests.c | 301 | ||||
-rw-r--r-- | mesalib/src/gallium/auxiliary/util/u_tests.h | 4 |
15 files changed, 394 insertions, 384 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_cache.c b/mesalib/src/gallium/auxiliary/util/u_cache.c index 26aab2bf1..9395c66f2 100644 --- a/mesalib/src/gallium/auxiliary/util/u_cache.c +++ b/mesalib/src/gallium/auxiliary/util/u_cache.c @@ -42,7 +42,7 @@ #include "util/u_math.h" #include "util/u_memory.h" #include "util/u_cache.h" -#include "util/u_simple_list.h" +#include "util/simple_list.h" struct util_cache_entry diff --git a/mesalib/src/gallium/auxiliary/util/u_cpu_detect.c b/mesalib/src/gallium/auxiliary/util/u_cpu_detect.c index 5d9db59d1..23ab46c54 100644 --- a/mesalib/src/gallium/auxiliary/util/u_cpu_detect.c +++ b/mesalib/src/gallium/auxiliary/util/u_cpu_detect.c @@ -272,7 +272,7 @@ static INLINE uint64_t xgetbv(void) #if defined(PIPE_ARCH_X86) -static INLINE boolean sse2_has_daz(void) +PIPE_ALIGN_STACK static INLINE boolean sse2_has_daz(void) { struct { uint32_t pad1[7]; @@ -409,8 +409,12 @@ util_cpu_detect(void) } if (regs[0] >= 0x80000006) { + /* should we really do this if the clflush size above worked? */ + unsigned int cacheline; cpuid(0x80000006, regs2); - util_cpu_caps.cacheline = regs2[2] & 0xFF; + cacheline = regs2[2] & 0xFF; + if (cacheline > 0) + util_cpu_caps.cacheline = cacheline; } if (!util_cpu_caps.has_sse) { diff --git a/mesalib/src/gallium/auxiliary/util/u_format.csv b/mesalib/src/gallium/auxiliary/util/u_format.csv index a71aaf15d..d3b77e6b9 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format.csv +++ b/mesalib/src/gallium/auxiliary/util/u_format.csv @@ -186,6 +186,17 @@ PIPE_FORMAT_LATC2_SNORM , rgtc, 4, 4, x128, , , , xxxy, rg PIPE_FORMAT_ETC1_RGB8 , etc, 4, 4, x64, , , , xyz1, rgb +PIPE_FORMAT_ETC2_RGB8 , etc, 4, 4, x64, , , , xyz1, rgb +PIPE_FORMAT_ETC2_SRGB8 , etc, 4, 4, x64, , , , xyz1, srgb +PIPE_FORMAT_ETC2_RGB8A1 , etc, 4, 4, x64, , , , xyzw, rgb +PIPE_FORMAT_ETC2_SRGB8A1 , etc, 4, 4, x64, , , , xyzw, srgb +PIPE_FORMAT_ETC2_RGBA8 , etc, 4, 4, x128, , , , xyzw, rgb +PIPE_FORMAT_ETC2_SRGBA8 , etc, 4, 4, x128, , , , xyzw, srgb +PIPE_FORMAT_ETC2_R11_UNORM , etc, 4, 4, x64, , , , x001, rgb +PIPE_FORMAT_ETC2_R11_SNORM , etc, 4, 4, x64, , , , x001, rgb +PIPE_FORMAT_ETC2_RG11_UNORM , etc, 4, 4, x128, , , , xy01, rgb +PIPE_FORMAT_ETC2_RG11_SNORM , etc, 4, 4, x128, , , , xy01, rgb + PIPE_FORMAT_BPTC_RGBA_UNORM , bptc, 4, 4, x128, , , , xyzw, rgb PIPE_FORMAT_BPTC_SRGBA , bptc, 4, 4, x128, , , , xyzw, srgb PIPE_FORMAT_BPTC_RGB_FLOAT , bptc, 4, 4, x128, , , , xyz1, rgb diff --git a/mesalib/src/gallium/auxiliary/util/u_format_bptc.h b/mesalib/src/gallium/auxiliary/util/u_format_bptc.h deleted file mode 100644 index f67d071ee..000000000 --- a/mesalib/src/gallium/auxiliary/util/u_format_bptc.h +++ /dev/null @@ -1,109 +0,0 @@ -/************************************************************************** - * - * Copyright 2011 Red Hat 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 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 - * THE COPYRIGHT HOLDERS, AUTHORS 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. - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - **************************************************************************/ - -#ifndef U_FORMAT_BPTC_H_ -#define U_FORMAT_BPTC_H_ - -void -util_format_bptc_rgba_unorm_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j); - -void -util_format_bptc_rgba_unorm_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_bptc_rgba_unorm_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_bptc_rgba_unorm_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_bptc_rgba_unorm_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_bptc_rgba_unorm_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); - - - -void -util_format_bptc_srgba_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j); - -void -util_format_bptc_srgba_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_bptc_srgba_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_bptc_srgba_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_bptc_srgba_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_bptc_srgba_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); - - - -void -util_format_bptc_rgb_float_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j); - -void -util_format_bptc_rgb_float_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_bptc_rgb_float_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_bptc_rgb_float_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_bptc_rgb_float_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_bptc_rgb_float_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); - - -void -util_format_bptc_rgb_ufloat_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j); - -void -util_format_bptc_rgb_ufloat_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_bptc_rgb_ufloat_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_bptc_rgb_ufloat_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_bptc_rgb_ufloat_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); - -void -util_format_bptc_rgb_ufloat_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); - - -#endif diff --git a/mesalib/src/gallium/auxiliary/util/u_format_bptc.c b/mesalib/src/gallium/auxiliary/util/u_format_fake.c index 196220ee0..77e896d27 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_bptc.c +++ b/mesalib/src/gallium/auxiliary/util/u_format_fake.c @@ -1,5 +1,5 @@ #include "u_format.h" -#include "u_format_bptc.h" +#include "u_format_fake.h" #define fake(format) \ void \ @@ -24,3 +24,14 @@ fake(bptc_rgba_unorm) fake(bptc_srgba) fake(bptc_rgb_float) fake(bptc_rgb_ufloat) + +fake(etc2_rgb8) +fake(etc2_srgb8) +fake(etc2_rgb8a1) +fake(etc2_srgb8a1) +fake(etc2_rgba8) +fake(etc2_srgba8) +fake(etc2_r11_unorm) +fake(etc2_r11_snorm) +fake(etc2_rg11_unorm) +fake(etc2_rg11_snorm) diff --git a/mesalib/src/gallium/auxiliary/util/u_format_fake.h b/mesalib/src/gallium/auxiliary/util/u_format_fake.h new file mode 100644 index 000000000..e6bfd4e15 --- /dev/null +++ b/mesalib/src/gallium/auxiliary/util/u_format_fake.h @@ -0,0 +1,66 @@ +/************************************************************************** + * + * Copyright 2011 Red Hat 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 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 + * THE COPYRIGHT HOLDERS, AUTHORS 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. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + **************************************************************************/ + +#ifndef U_FORMAT_FAKE_H_ +#define U_FORMAT_FAKE_H_ + +#define __format_fake(format) \ +void \ +util_format_##format##_fetch_rgba_8unorm(uint8_t *dst, const uint8_t *src, unsigned i, unsigned j); \ +\ +void \ +util_format_##format##_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); \ +\ +void \ +util_format_##format##_pack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); \ +\ +void \ +util_format_##format##_unpack_rgba_float(float *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); \ +\ +void \ +util_format_##format##_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, const float *src_row, unsigned src_stride, unsigned width, unsigned height); \ +\ +void \ +util_format_##format##_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j); + +__format_fake(bptc_rgba_unorm) +__format_fake(bptc_srgba) +__format_fake(bptc_rgb_float) +__format_fake(bptc_rgb_ufloat) + +__format_fake(etc2_rgb8) +__format_fake(etc2_srgb8) +__format_fake(etc2_rgb8a1) +__format_fake(etc2_srgb8a1) +__format_fake(etc2_rgba8) +__format_fake(etc2_srgba8) +__format_fake(etc2_r11_unorm) +__format_fake(etc2_r11_snorm) +__format_fake(etc2_rg11_unorm) +__format_fake(etc2_rg11_snorm) + +#endif diff --git a/mesalib/src/gallium/auxiliary/util/u_format_table.py b/mesalib/src/gallium/auxiliary/util/u_format_table.py index ad582e4f5..aceb0caf7 100644 --- a/mesalib/src/gallium/auxiliary/util/u_format_table.py +++ b/mesalib/src/gallium/auxiliary/util/u_format_table.py @@ -90,7 +90,7 @@ def write_format_table(formats): print '#include "u_format_rgtc.h"' print '#include "u_format_latc.h"' print '#include "u_format_etc.h"' - print '#include "u_format_bptc.h"' + print '#include "u_format_fake.h"' print u_format_pack.generate(formats) diff --git a/mesalib/src/gallium/auxiliary/util/u_math.h b/mesalib/src/gallium/auxiliary/util/u_math.h index 19c7343b1..d6e83f962 100644 --- a/mesalib/src/gallium/auxiliary/util/u_math.h +++ b/mesalib/src/gallium/auxiliary/util/u_math.h @@ -40,7 +40,6 @@ #include "pipe/p_compiler.h" -#include "util/u_debug.h" #ifdef __cplusplus @@ -530,6 +529,7 @@ unsigned ffs( unsigned u ) } #elif defined(__MINGW32__) || defined(PIPE_OS_ANDROID) #define ffs __builtin_ffs +#define ffsll __builtin_ffsll #endif #endif /* FFS_DEFINED */ @@ -561,14 +561,10 @@ util_last_bit(unsigned u) static INLINE unsigned util_last_bit_signed(int i) { -#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 407) && !defined(__INTEL_COMPILER) - return 31 - __builtin_clrsb(i); -#else if (i >= 0) return util_last_bit(i); else return util_last_bit(~(unsigned)i); -#endif } /* Destructively loop over all of the bits in a mask as in: @@ -587,6 +583,15 @@ u_bit_scan(unsigned *mask) return i; } +#ifndef _MSC_VER +static INLINE int +u_bit_scan64(uint64_t *mask) +{ + int i = ffsll(*mask) - 1; + *mask &= ~(1llu << i); + return i; +} +#endif /** * Return float bits. @@ -602,9 +607,9 @@ fui( float f ) static INLINE float uif(uint32_t ui) { - union fi fi; - fi.ui = ui; - return fi.f; + union fi fi; + fi.ui = ui; + return fi.f; } diff --git a/mesalib/src/gallium/auxiliary/util/u_pstipple.c b/mesalib/src/gallium/auxiliary/util/u_pstipple.c index 1e1ec4a98..0a20bdb47 100644 --- a/mesalib/src/gallium/auxiliary/util/u_pstipple.c +++ b/mesalib/src/gallium/auxiliary/util/u_pstipple.c @@ -182,6 +182,8 @@ struct pstip_transform_context { int freeSampler; /** an available sampler for the pstipple */ int numImmed; uint coordOrigin; + unsigned fixedUnit; + bool hasFixedUnit; }; @@ -279,7 +281,8 @@ pstip_transform_prolog(struct tgsi_transform_context *ctx) } /* declare new sampler */ - tgsi_transform_sampler_decl(ctx, pctx->freeSampler); + tgsi_transform_sampler_decl(ctx, + pctx->hasFixedUnit ? pctx->fixedUnit : pctx->freeSampler); /* Declare temp[0] reg if not already declared. * We can always use temp[0] since this code is before @@ -318,7 +321,8 @@ pstip_transform_prolog(struct tgsi_transform_context *ctx) tgsi_transform_tex_2d_inst(ctx, TGSI_FILE_TEMPORARY, texTemp, TGSI_FILE_TEMPORARY, texTemp, - pctx->freeSampler); + pctx->hasFixedUnit ? pctx->fixedUnit + : pctx->freeSampler); /* KILL_IF -texTemp; # if -texTemp < 0, kill fragment */ tgsi_transform_kill_inst(ctx, @@ -330,12 +334,16 @@ pstip_transform_prolog(struct tgsi_transform_context *ctx) /** * Given a fragment shader, return a new fragment shader which * samples a stipple texture and executes KILL. + * * \param samplerUnitOut returns the index of the sampler unit which - * will be used to sample the stipple texture + * will be used to sample the stipple texture; + * if NULL, the fixed unit is used + * \param fixedUnit fixed texture unit used for the stipple texture */ struct tgsi_token * util_pstipple_create_fragment_shader(const struct tgsi_token *tokens, - unsigned *samplerUnitOut) + unsigned *samplerUnitOut, + unsigned fixedUnit) { struct pstip_transform_context transform; const uint newLen = tgsi_num_tokens(tokens) + NUM_NEW_TOKENS; @@ -352,6 +360,8 @@ util_pstipple_create_fragment_shader(const struct tgsi_token *tokens, transform.wincoordInput = -1; transform.maxInput = -1; transform.coordOrigin = TGSI_FS_COORD_ORIGIN_UPPER_LEFT; + transform.hasFixedUnit = !samplerUnitOut; + transform.fixedUnit = fixedUnit; transform.base.prolog = pstip_transform_prolog; transform.base.transform_declaration = pstip_transform_decl; transform.base.transform_immediate = pstip_transform_immed; @@ -368,9 +378,10 @@ util_pstipple_create_fragment_shader(const struct tgsi_token *tokens, tgsi_dump(new_fs->tokens, 0); #endif - assert(transform.freeSampler < PIPE_MAX_SAMPLERS); - *samplerUnitOut = transform.freeSampler; + if (samplerUnitOut) { + assert(transform.freeSampler < PIPE_MAX_SAMPLERS); + *samplerUnitOut = transform.freeSampler; + } return new_tokens; } - diff --git a/mesalib/src/gallium/auxiliary/util/u_pstipple.h b/mesalib/src/gallium/auxiliary/util/u_pstipple.h index 13155e7f5..249c58be9 100644 --- a/mesalib/src/gallium/auxiliary/util/u_pstipple.h +++ b/mesalib/src/gallium/auxiliary/util/u_pstipple.h @@ -49,7 +49,8 @@ util_pstipple_create_sampler(struct pipe_context *pipe); struct tgsi_token * util_pstipple_create_fragment_shader(const struct tgsi_token *tokens, - unsigned *samplerUnitOut); + unsigned *samplerUnitOut, + unsigned fixed_unit); #endif diff --git a/mesalib/src/gallium/auxiliary/util/u_simple_list.h b/mesalib/src/gallium/auxiliary/util/u_simple_list.h deleted file mode 100644 index 3f7def5fc..000000000 --- a/mesalib/src/gallium/auxiliary/util/u_simple_list.h +++ /dev/null @@ -1,199 +0,0 @@ -/** - * \file simple_list.h - * Simple macros for type-safe, intrusive lists. - * - * Intended to work with a list sentinal which is created as an empty - * list. Insert & delete are O(1). - * - * \author - * (C) 1997, Keith Whitwell - */ - -/* - * Mesa 3-D graphics library - * - * Copyright (C) 1999-2001 Brian Paul 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, sublicense, - * 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 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 NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS 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. - */ - - -#ifndef _U_SIMPLE_LIST_H_ -#define _U_SIMPLE_LIST_H_ - -/** - * Remove an element from list. - * - * \param elem element to remove. - */ -#define remove_from_list(elem) \ -do { \ - (elem)->next->prev = (elem)->prev; \ - (elem)->prev->next = (elem)->next; \ - (elem)->next = elem; \ - (elem)->prev = elem; \ -} while (0) - -/** - * Insert an element to the list head. - * - * \param list list. - * \param elem element to insert. - */ -#define insert_at_head(list, elem) \ -do { \ - (elem)->prev = list; \ - (elem)->next = (list)->next; \ - (list)->next->prev = elem; \ - (list)->next = elem; \ -} while(0) - -/** - * Insert an element to the list tail. - * - * \param list list. - * \param elem element to insert. - */ -#define insert_at_tail(list, elem) \ -do { \ - (elem)->next = list; \ - (elem)->prev = (list)->prev; \ - (list)->prev->next = elem; \ - (list)->prev = elem; \ -} while(0) - -/** - * Move an element to the list head. - * - * \param list list. - * \param elem element to move. - */ -#define move_to_head(list, elem) \ -do { \ - remove_from_list(elem); \ - insert_at_head(list, elem); \ -} while (0) - -/** - * Move an element to the list tail. - * - * \param list list. - * \param elem element to move. - */ -#define move_to_tail(list, elem) \ -do { \ - remove_from_list(elem); \ - insert_at_tail(list, elem); \ -} while (0) - -/** - * Make a empty list empty. - * - * \param sentinal list (sentinal element). - */ -#define make_empty_list(sentinal) \ -do { \ - (sentinal)->next = sentinal; \ - (sentinal)->prev = sentinal; \ -} while (0) - -/** - * Get list first element. - * - * \param list list. - * - * \return pointer to first element. - */ -#define first_elem(list) ((list)->next) - -/** - * Get list last element. - * - * \param list list. - * - * \return pointer to last element. - */ -#define last_elem(list) ((list)->prev) - -/** - * Get next element. - * - * \param elem element. - * - * \return pointer to next element. - */ -#define next_elem(elem) ((elem)->next) - -/** - * Get previous element. - * - * \param elem element. - * - * \return pointer to previous element. - */ -#define prev_elem(elem) ((elem)->prev) - -/** - * Test whether element is at end of the list. - * - * \param list list. - * \param elem element. - * - * \return non-zero if element is at end of list, or zero otherwise. - */ -#define at_end(list, elem) ((elem) == (list)) - -/** - * Test if a list is empty. - * - * \param list list. - * - * \return non-zero if list empty, or zero otherwise. - */ -#define is_empty_list(list) ((list)->next == (list)) - -/** - * Walk through the elements of a list. - * - * \param ptr pointer to the current element. - * \param list list. - * - * \note It should be followed by a { } block or a single statement, as in a \c - * for loop. - */ -#define foreach(ptr, list) \ - for( ptr=(list)->next ; ptr!=list ; ptr=(ptr)->next ) - -/** - * Walk through the elements of a list. - * - * Same as #foreach but lets you unlink the current value during a list - * traversal. Useful for freeing a list, element by element. - * - * \param ptr pointer to the current element. - * \param t temporary pointer. - * \param list list. - * - * \note It should be followed by a { } block or a single statement, as in a \c - * for loop. - */ -#define foreach_s(ptr, t, list) \ - for(ptr=(list)->next,t=(ptr)->next; list != ptr; ptr=t, t=(t)->next) - -#endif /* _U_SIMPLE_LIST_H_ */ diff --git a/mesalib/src/gallium/auxiliary/util/u_simple_shaders.c b/mesalib/src/gallium/auxiliary/util/u_simple_shaders.c index edb30379b..c612b67e2 100644 --- a/mesalib/src/gallium/auxiliary/util/u_simple_shaders.c +++ b/mesalib/src/gallium/auxiliary/util/u_simple_shaders.c @@ -246,9 +246,15 @@ util_make_fragment_tex_shader_writemask(struct pipe_context *pipe, ureg_MOV( ureg, out, imm ); } - ureg_TEX( ureg, - ureg_writemask(out, writemask), - tex_target, tex, sampler ); + if (tex_target == TGSI_TEXTURE_BUFFER) + ureg_TXF(ureg, + ureg_writemask(out, writemask), + tex_target, tex, sampler); + else + ureg_TEX(ureg, + ureg_writemask(out, writemask), + tex_target, tex, sampler); + ureg_END( ureg ); return ureg_create_shader_and_destroy( ureg, pipe ); diff --git a/mesalib/src/gallium/auxiliary/util/u_slab.c b/mesalib/src/gallium/auxiliary/util/u_slab.c index dbdebc6c9..7e7d43bd8 100644 --- a/mesalib/src/gallium/auxiliary/util/u_slab.c +++ b/mesalib/src/gallium/auxiliary/util/u_slab.c @@ -24,7 +24,7 @@ #include "util/u_math.h" #include "util/u_memory.h" -#include "util/u_simple_list.h" +#include "util/simple_list.h" #include <stdio.h> diff --git a/mesalib/src/gallium/auxiliary/util/u_tests.c b/mesalib/src/gallium/auxiliary/util/u_tests.c index b42f5e137..fe549723c 100644 --- a/mesalib/src/gallium/auxiliary/util/u_tests.c +++ b/mesalib/src/gallium/auxiliary/util/u_tests.c @@ -30,9 +30,13 @@ #include "util/u_draw_quad.h" #include "util/u_format.h" #include "util/u_inlines.h" +#include "util/u_memory.h" #include "util/u_simple_shaders.h" #include "util/u_surface.h" +#include "util/u_string.h" #include "util/u_tile.h" +#include "tgsi/tgsi_strings.h" +#include "tgsi/tgsi_text.h" #include "cso_cache/cso_context.h" #include <stdio.h> @@ -138,15 +142,70 @@ util_set_interleaved_vertex_elements(struct cso_context *cso, free(velem); } +static void * +util_set_passthrough_vertex_shader(struct cso_context *cso, + struct pipe_context *ctx, + bool window_space) +{ + static const uint vs_attribs[] = { + TGSI_SEMANTIC_POSITION, + TGSI_SEMANTIC_GENERIC + }; + static const uint vs_indices[] = {0, 0}; + void *vs; + + vs = util_make_vertex_passthrough_shader(ctx, 2, vs_attribs, vs_indices, + window_space); + cso_set_vertex_shader_handle(cso, vs); + return vs; +} + +static void +util_set_common_states_and_clear(struct cso_context *cso, struct pipe_context *ctx, + struct pipe_resource *cb) +{ + static const float clear_color[] = {0.1, 0.1, 0.1, 0.1}; + + util_set_framebuffer_cb0(cso, ctx, cb); + util_set_blend_normal(cso); + util_set_dsa_disable(cso); + util_set_rasterizer_normal(cso); + util_set_max_viewport(cso, cb); + + ctx->clear(ctx, PIPE_CLEAR_COLOR0, (void*)clear_color, 0, 0); +} + +static void +util_draw_fullscreen_quad(struct cso_context *cso) +{ + static float vertices[] = { + -1, -1, 0, 1, 0, 0, 0, 0, + -1, 1, 0, 1, 0, 1, 0, 0, + 1, 1, 0, 1, 1, 1, 0, 0, + 1, -1, 0, 1, 1, 0, 0, 0 + }; + util_set_interleaved_vertex_elements(cso, 2); + util_draw_user_vertex_buffer(cso, vertices, PIPE_PRIM_QUADS, 4, 2); +} + +/** + * Probe and test if the rectangle contains the expected color. + * + * If "num_expected_colors" > 1, at least one expected color must match + * the probed color. "expected" should be an array of 4*num_expected_colors + * floats. + */ static bool -util_probe_rect_rgba(struct pipe_context *ctx, struct pipe_resource *tex, - unsigned offx, unsigned offy, unsigned w, unsigned h, - const float *expected) +util_probe_rect_rgba_multi(struct pipe_context *ctx, struct pipe_resource *tex, + unsigned offx, unsigned offy, unsigned w, + unsigned h, + const float *expected, + unsigned num_expected_colors) { struct pipe_transfer *transfer; void *map; float *pixels = malloc(w * h * 4 * sizeof(float)); - int x,y,c; + int x,y,e,c; bool pass = true; map = pipe_transfer_map(ctx, tex, 0, 0, PIPE_TRANSFER_READ, @@ -154,21 +213,31 @@ util_probe_rect_rgba(struct pipe_context *ctx, struct pipe_resource *tex, pipe_get_tile_rgba(transfer, map, 0, 0, w, h, pixels); pipe_transfer_unmap(ctx, transfer); - for (y = 0; y < h; y++) { - for (x = 0; x < w; x++) { - float *probe = &pixels[(y*w + x)*4]; - - for (c = 0; c < 4; c++) - if (fabs(probe[c] - expected[c]) >= TOLERANCE) { - printf("Probe color at (%i,%i), ", offx+x, offy+y); - printf("Expected: %.3f, %.3f, %.3f, %.3f, ", - expected[0], expected[1], expected[2], expected[3]); - printf("Got: %.3f, %.3f, %.3f, %.3f\n", - probe[0], probe[1], probe[2], probe[2]); - pass = false; - goto done; + for (e = 0; e < num_expected_colors; e++) { + for (y = 0; y < h; y++) { + for (x = 0; x < w; x++) { + float *probe = &pixels[(y*w + x)*4]; + + for (c = 0; c < 4; c++) { + if (fabs(probe[c] - expected[e*4+c]) >= TOLERANCE) { + if (e < num_expected_colors-1) + goto next_color; /* test the next expected color */ + + printf("Probe color at (%i,%i), ", offx+x, offy+y); + printf("Expected: %.3f, %.3f, %.3f, %.3f, ", + expected[e*4], expected[e*4+1], + expected[e*4+2], expected[e*4+3]); + printf("Got: %.3f, %.3f, %.3f, %.3f\n", + probe[0], probe[1], probe[2], probe[2]); + pass = false; + goto done; + } } + } } + break; /* this color was successful */ + + next_color:; } done: @@ -176,6 +245,37 @@ done: return pass; } +static bool +util_probe_rect_rgba(struct pipe_context *ctx, struct pipe_resource *tex, + unsigned offx, unsigned offy, unsigned w, unsigned h, + const float *expected) +{ + return util_probe_rect_rgba_multi(ctx, tex, offx, offy, w, h, expected, 1); +} + +enum { + SKIP = -1, + FAIL = 0, /* also "false" */ + PASS = 1 /* also "true" */ +}; + +static void +util_report_result_helper(int status, const char *name, ...) +{ + char buf[256]; + va_list ap; + + va_start(ap, name); + util_vsnprintf(buf, sizeof(buf), name, ap); + va_end(ap); + + printf("Test(%s) = %s\n", buf, + status == SKIP ? "skip" : + status == PASS ? "pass" : "fail"); +} + +#define util_report_result(status) util_report_result_helper(status, __func__) + /** * Test TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION. * @@ -196,38 +296,18 @@ tgsi_vs_window_space_position(struct pipe_context *ctx) struct pipe_resource *cb; void *fs, *vs; bool pass = true; - - static uint vs_attribs[] = { - TGSI_SEMANTIC_POSITION, - TGSI_SEMANTIC_GENERIC - }; - static uint vs_indices[] = {0, 0}; - static float vertices[] = { - 0, 0, 0, 0, 1, 0, 0, 1, - 0, 256, 0, 0, 1, 0, 0, 1, - 256, 256, 0, 0, 1, 0, 0, 1, - 256, 0, 0, 0, 1, 0, 0, 1, - }; - static float red[] = {1, 0, 0, 1}; - static float clear_color[] = {0.1, 0.1, 0.1, 0.1}; + static const float red[] = {1, 0, 0, 1}; if (!ctx->screen->get_param(ctx->screen, PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION)) { - printf("Test(%s) = skip\n", __func__); + util_report_result(SKIP); return; } cso = cso_create_context(ctx); cb = util_create_texture2d(ctx->screen, 256, 256, PIPE_FORMAT_R8G8B8A8_UNORM); - - /* Set states. */ - util_set_framebuffer_cb0(cso, ctx, cb); - util_set_blend_normal(cso); - util_set_dsa_disable(cso); - util_set_rasterizer_normal(cso); - util_set_max_viewport(cso, cb); - util_set_interleaved_vertex_elements(cso, 2); + util_set_common_states_and_clear(cso, ctx, cb); /* Fragment shader. */ fs = util_make_fragment_passthrough_shader(ctx, TGSI_SEMANTIC_GENERIC, @@ -235,13 +315,19 @@ tgsi_vs_window_space_position(struct pipe_context *ctx) cso_set_fragment_shader_handle(cso, fs); /* Vertex shader. */ - vs = util_make_vertex_passthrough_shader(ctx, 2, vs_attribs, vs_indices, - TRUE); - cso_set_vertex_shader_handle(cso, vs); - - /* Clear and draw. */ - ctx->clear(ctx, PIPE_CLEAR_COLOR0, (void*)clear_color, 0, 0); - util_draw_user_vertex_buffer(cso, vertices, PIPE_PRIM_QUADS, 4, 2); + vs = util_set_passthrough_vertex_shader(cso, ctx, true); + + /* Draw. */ + { + static float vertices[] = { + 0, 0, 0, 0, 1, 0, 0, 1, + 0, 256, 0, 0, 1, 0, 0, 1, + 256, 256, 0, 0, 1, 0, 0, 1, + 256, 0, 0, 0, 1, 0, 0, 1, + }; + util_set_interleaved_vertex_elements(cso, 2); + util_draw_user_vertex_buffer(cso, vertices, PIPE_PRIM_QUADS, 4, 2); + } /* Probe pixels. */ pass = pass && util_probe_rect_rgba(ctx, cb, 0, 0, @@ -253,7 +339,114 @@ tgsi_vs_window_space_position(struct pipe_context *ctx) ctx->delete_fs_state(ctx, fs); pipe_resource_reference(&cb, NULL); - printf("Test(%s) = %s\n", __func__, pass ? "pass" : "fail"); + util_report_result(pass); +} + +static void +null_sampler_view(struct pipe_context *ctx, unsigned tgsi_tex_target) +{ + struct cso_context *cso; + struct pipe_resource *cb; + void *fs, *vs; + bool pass = true; + /* 2 expected colors: */ + static const float expected_tex[] = {0, 0, 0, 1, + 0, 0, 0, 0}; + static const float expected_buf[] = {0, 0, 0, 0}; + const float *expected = tgsi_tex_target == TGSI_TEXTURE_BUFFER ? + expected_buf : expected_tex; + unsigned num_expected = tgsi_tex_target == TGSI_TEXTURE_BUFFER ? 1 : 2; + + if (tgsi_tex_target == TGSI_TEXTURE_BUFFER && + !ctx->screen->get_param(ctx->screen, PIPE_CAP_TEXTURE_BUFFER_OBJECTS)) { + util_report_result_helper(SKIP, "%s: %s", __func__, + tgsi_texture_names[tgsi_tex_target]); + return; + } + + cso = cso_create_context(ctx); + cb = util_create_texture2d(ctx->screen, 256, 256, + PIPE_FORMAT_R8G8B8A8_UNORM); + util_set_common_states_and_clear(cso, ctx, cb); + + ctx->set_sampler_views(ctx, PIPE_SHADER_FRAGMENT, 0, 1, NULL); + + /* Fragment shader. */ + fs = util_make_fragment_tex_shader(ctx, tgsi_tex_target, + TGSI_INTERPOLATE_LINEAR); + cso_set_fragment_shader_handle(cso, fs); + + /* Vertex shader. */ + vs = util_set_passthrough_vertex_shader(cso, ctx, false); + util_draw_fullscreen_quad(cso); + + /* Probe pixels. */ + pass = pass && util_probe_rect_rgba_multi(ctx, cb, 0, 0, + cb->width0, cb->height0, expected, + num_expected); + + /* Cleanup. */ + cso_destroy_context(cso); + ctx->delete_vs_state(ctx, vs); + ctx->delete_fs_state(ctx, fs); + pipe_resource_reference(&cb, NULL); + + util_report_result_helper(pass, "%s: %s", __func__, + tgsi_texture_names[tgsi_tex_target]); +} + +static void +null_constant_buffer(struct pipe_context *ctx) +{ + struct cso_context *cso; + struct pipe_resource *cb; + void *fs, *vs; + bool pass = true; + static const float zero[] = {0, 0, 0, 0}; + + cso = cso_create_context(ctx); + cb = util_create_texture2d(ctx->screen, 256, 256, + PIPE_FORMAT_R8G8B8A8_UNORM); + util_set_common_states_and_clear(cso, ctx, cb); + + ctx->set_constant_buffer(ctx, PIPE_SHADER_FRAGMENT, 0, NULL); + + /* Fragment shader. */ + { + static const char *text = /* I don't like ureg... */ + "FRAG\n" + "DCL CONST[0]\n" + "DCL OUT[0], COLOR\n" + + "MOV OUT[0], CONST[0]\n" + "END\n"; + struct tgsi_token tokens[1000]; + struct pipe_shader_state state = {tokens}; + + if (!tgsi_text_translate(text, tokens, Elements(tokens))) { + puts("Can't compile a fragment shader."); + util_report_result(FAIL); + return; + } + fs = ctx->create_fs_state(ctx, &state); + cso_set_fragment_shader_handle(cso, fs); + } + + /* Vertex shader. */ + vs = util_set_passthrough_vertex_shader(cso, ctx, false); + util_draw_fullscreen_quad(cso); + + /* Probe pixels. */ + pass = pass && util_probe_rect_rgba(ctx, cb, 0, 0, cb->width0, + cb->height0, zero); + + /* Cleanup. */ + cso_destroy_context(cso); + ctx->delete_vs_state(ctx, vs); + ctx->delete_fs_state(ctx, fs); + pipe_resource_reference(&cb, NULL); + + util_report_result(pass); } /** @@ -261,7 +454,17 @@ tgsi_vs_window_space_position(struct pipe_context *ctx) * context_create. */ void -util_run_tests(struct pipe_context *ctx) +util_run_tests(struct pipe_screen *screen) { + struct pipe_context *ctx = screen->context_create(screen, NULL); + tgsi_vs_window_space_position(ctx); + null_sampler_view(ctx, TGSI_TEXTURE_2D); + null_sampler_view(ctx, TGSI_TEXTURE_BUFFER); + null_constant_buffer(ctx); + + ctx->destroy(ctx); + + puts("Done. Exiting.."); + exit(0); } diff --git a/mesalib/src/gallium/auxiliary/util/u_tests.h b/mesalib/src/gallium/auxiliary/util/u_tests.h index a1439347d..49ae54f87 100644 --- a/mesalib/src/gallium/auxiliary/util/u_tests.h +++ b/mesalib/src/gallium/auxiliary/util/u_tests.h @@ -30,8 +30,8 @@ #include "pipe/p_compiler.h" -struct pipe_context; +struct pipe_screen; -void util_run_tests(struct pipe_context *ctx); +void util_run_tests(struct pipe_screen *screen); #endif |