diff options
Diffstat (limited to 'src/gallium/auxiliary/util')
-rw-r--r-- | src/gallium/auxiliary/util/u_blit.c | 6 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_blitter.c | 67 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_debug.c | 14 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_debug.h | 6 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_dl.h | 3 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_gen_mipmap.c | 6 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_math.h | 12 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_pointer.h | 12 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_simple_shaders.c | 19 | ||||
-rw-r--r-- | src/gallium/auxiliary/util/u_simple_shaders.h | 7 |
10 files changed, 97 insertions, 55 deletions
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c index d4fbd658f4..97fa99ec65 100644 --- a/src/gallium/auxiliary/util/u_blit.c +++ b/src/gallium/auxiliary/util/u_blit.c @@ -42,12 +42,10 @@ #include "util/u_blit.h" #include "util/u_draw_quad.h" -#include "util/u_format.h" #include "util/u_math.h" #include "util/u_memory.h" #include "util/u_sampler.h" #include "util/u_simple_shaders.h" -#include "util/u_surface.h" #include "cso_cache/cso_context.h" @@ -136,7 +134,8 @@ util_create_blit(struct pipe_context *pipe, struct cso_context *cso) /* fragment shader */ ctx->fs[TGSI_WRITEMASK_XYZW] = - util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D); + util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D, + TGSI_INTERPOLATE_LINEAR); ctx->vbuf = NULL; /* init vertex data that doesn't change */ @@ -476,6 +475,7 @@ util_blit_pixels_writemask(struct blit_state *ctx, if (ctx->fs[writemask] == NULL) ctx->fs[writemask] = util_make_fragment_tex_shader_writemask(pipe, TGSI_TEXTURE_2D, + TGSI_INTERPOLATE_LINEAR, writemask); /* shaders */ diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index 9ae7b38e6e..183ffe5670 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -522,6 +522,26 @@ void *blitter_get_fs_col(struct blitter_context_priv *ctx, unsigned num_cbufs) return ctx->fs_col[num_cbufs]; } +/** Convert PIPE_TEXTURE_x to TGSI_TEXTURE_x */ +static unsigned +pipe_tex_to_tgsi_tex(unsigned pipe_tex_target) +{ + switch (pipe_tex_target) { + case PIPE_TEXTURE_1D: + return TGSI_TEXTURE_1D; + case PIPE_TEXTURE_2D: + return TGSI_TEXTURE_2D; + case PIPE_TEXTURE_3D: + return TGSI_TEXTURE_3D; + case PIPE_TEXTURE_CUBE: + return TGSI_TEXTURE_CUBE; + default: + assert(0 && "unexpected texture target"); + return TGSI_TEXTURE_UNKNOWN; + } +} + + static INLINE void *blitter_get_fs_texfetch_col(struct blitter_context_priv *ctx, unsigned tex_target) @@ -532,25 +552,10 @@ void *blitter_get_fs_texfetch_col(struct blitter_context_priv *ctx, /* Create the fragment shader on-demand. */ if (!ctx->fs_texfetch_col[tex_target]) { - switch (tex_target) { - case PIPE_TEXTURE_2D: - ctx->fs_texfetch_col[PIPE_TEXTURE_2D] = - util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D); - break; - case PIPE_TEXTURE_3D: - ctx->fs_texfetch_col[PIPE_TEXTURE_3D] = - util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_3D); - break; - case PIPE_TEXTURE_CUBE: - ctx->fs_texfetch_col[PIPE_TEXTURE_CUBE] = - util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_CUBE); - break; - case PIPE_TEXTURE_1D: - default: - ctx->fs_texfetch_col[PIPE_TEXTURE_1D] = - util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_1D); - tex_target = PIPE_TEXTURE_1D; /* for the default case */ - } + unsigned tgsi_tex = pipe_tex_to_tgsi_tex(tex_target); + + ctx->fs_texfetch_col[tex_target] = + util_make_fragment_tex_shader(pipe, tgsi_tex, TGSI_INTERPOLATE_LINEAR); } return ctx->fs_texfetch_col[tex_target]; @@ -566,25 +571,11 @@ void *blitter_get_fs_texfetch_depth(struct blitter_context_priv *ctx, /* Create the fragment shader on-demand. */ if (!ctx->fs_texfetch_depth[tex_target]) { - switch (tex_target) { - case PIPE_TEXTURE_2D: - ctx->fs_texfetch_depth[PIPE_TEXTURE_2D] = - util_make_fragment_tex_shader_writedepth(pipe, TGSI_TEXTURE_2D); - break; - case PIPE_TEXTURE_3D: - ctx->fs_texfetch_depth[PIPE_TEXTURE_3D] = - util_make_fragment_tex_shader_writedepth(pipe, TGSI_TEXTURE_3D); - break; - case PIPE_TEXTURE_CUBE: - ctx->fs_texfetch_depth[PIPE_TEXTURE_CUBE] = - util_make_fragment_tex_shader_writedepth(pipe,TGSI_TEXTURE_CUBE); - break; - case PIPE_TEXTURE_1D: - default: - ctx->fs_texfetch_depth[PIPE_TEXTURE_1D] = - util_make_fragment_tex_shader_writedepth(pipe, TGSI_TEXTURE_1D); - tex_target = PIPE_TEXTURE_1D; /* for the default case */ - } + unsigned tgsi_tex = pipe_tex_to_tgsi_tex(tex_target); + + ctx->fs_texfetch_depth[tex_target] = + util_make_fragment_tex_shader_writedepth(pipe, tgsi_tex, + TGSI_INTERPOLATE_LINEAR); } return ctx->fs_texfetch_depth[tex_target]; diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c index 86db2c2e4b..954f5706ef 100644 --- a/src/gallium/auxiliary/util/u_debug.c +++ b/src/gallium/auxiliary/util/u_debug.c @@ -42,6 +42,7 @@ #include "util/u_tile.h" #include "util/u_prim.h" +#include <limits.h> /* CHAR_BIT */ void _debug_vprintf(const char *format, va_list ap) { @@ -181,16 +182,21 @@ debug_get_flags_option(const char *name, { unsigned long result; const char *str; + const struct debug_named_value *orig = flags; + int namealign = 0; str = os_get_option(name); if(!str) result = dfault; else if (!util_strcmp(str, "help")) { result = dfault; - while (flags->name) { - debug_printf("%s: help for %s: %s [0x%lx]\n", __FUNCTION__, name, flags->name, flags->value); - flags++; - } + debug_printf("%s: help for %s:\n", __FUNCTION__, name); + for (; flags->name; ++flags) + namealign = MAX2(namealign, strlen(flags->name)); + for (flags = orig; flags->name; ++flags) + debug_printf("| %*s [0x%0*lx]%s%s\n", namealign, flags->name, + sizeof(unsigned long)*CHAR_BIT/4, flags->value, + flags->desc ? " " : "", flags->desc ? flags->desc : ""); } else { result = 0; diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h index e8ff2773e6..1c9624ea3e 100644 --- a/src/gallium/auxiliary/util/u_debug.h +++ b/src/gallium/auxiliary/util/u_debug.h @@ -230,6 +230,7 @@ struct debug_named_value { const char *name; unsigned long value; + const char *desc; }; @@ -252,8 +253,9 @@ struct debug_named_value * ... * @endcode */ -#define DEBUG_NAMED_VALUE(__symbol) {#__symbol, (unsigned long)__symbol} -#define DEBUG_NAMED_VALUE_END {NULL, 0} +#define DEBUG_NAMED_VALUE(__symbol) DEBUG_NAMED_VALUE_WITH_DESCRIPTION(__symbol, NULL) +#define DEBUG_NAMED_VALUE_WITH_DESCRIPTION(__symbol, __desc) {#__symbol, (unsigned long)__symbol, __desc} +#define DEBUG_NAMED_VALUE_END {NULL, 0, NULL} /** diff --git a/src/gallium/auxiliary/util/u_dl.h b/src/gallium/auxiliary/util/u_dl.h index 2853b447c6..80a00ed679 100644 --- a/src/gallium/auxiliary/util/u_dl.h +++ b/src/gallium/auxiliary/util/u_dl.h @@ -35,10 +35,13 @@ #if defined(PIPE_OS_WINDOWS) # define UTIL_DL_EXT ".dll" +# define UTIL_DL_PREFIX "" #elif defined(PIPE_OS_APPLE) # define UTIL_DL_EXT ".dylib" +# define UTIL_DL_PREFIX "lib" #else # define UTIL_DL_EXT ".so" +# define UTIL_DL_PREFIX "lib" #endif diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c index d19267be72..b7fe2d3003 100644 --- a/src/gallium/auxiliary/util/u_gen_mipmap.c +++ b/src/gallium/auxiliary/util/u_gen_mipmap.c @@ -1327,8 +1327,10 @@ util_create_gen_mipmap(struct pipe_context *pipe, } /* fragment shader */ - ctx->fs2d = util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D); - ctx->fsCube = util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_CUBE); + ctx->fs2d = util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_2D, + TGSI_INTERPOLATE_LINEAR); + ctx->fsCube = util_make_fragment_tex_shader(pipe, TGSI_TEXTURE_CUBE, + TGSI_INTERPOLATE_LINEAR); /* vertex data that doesn't change */ for (i = 0; i < 4; i++) { diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index d1ec13def3..6370e77986 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -168,6 +168,9 @@ static INLINE float logf( float f ) #undef logf #define logf(x) ((float)log((double)(x))) #endif /* logf */ + +#define isfinite(x) _finite((double)(x)) +#define isnan(x) _isnan((double)(x)) #endif static INLINE double log2( double x ) @@ -335,6 +338,15 @@ util_iround(float f) } +/** + * Approximate floating point comparison + */ +static INLINE boolean +util_is_approx(float a, float b, float tol) +{ + return fabs(b - a) <= tol; +} + /** * Test if x is NaN or +/- infinity. diff --git a/src/gallium/auxiliary/util/u_pointer.h b/src/gallium/auxiliary/util/u_pointer.h index e1af9f11cb..ae6f43bff8 100644 --- a/src/gallium/auxiliary/util/u_pointer.h +++ b/src/gallium/auxiliary/util/u_pointer.h @@ -98,6 +98,18 @@ align16( void *unaligned ) return align_pointer( unaligned, 16 ); } +typedef void (*func_pointer)(void); + +static INLINE func_pointer +pointer_to_func( void *p ) +{ + union { + void *p; + func_pointer f; + } pf; + pf.p = p; + return pf.f; +} #ifdef __cplusplus diff --git a/src/gallium/auxiliary/util/u_simple_shaders.c b/src/gallium/auxiliary/util/u_simple_shaders.c index 019dda767d..5b682f496c 100644 --- a/src/gallium/auxiliary/util/u_simple_shaders.c +++ b/src/gallium/auxiliary/util/u_simple_shaders.c @@ -87,10 +87,15 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe, * MOV OUT[0], IMM[0] // (if writemask != 0xf) * TEX OUT[0].writemask, IN[0], SAMP[0], 2D; * END; + * + * \param tex_target one of PIPE_TEXTURE_x + * \parma interp_mode either TGSI_INTERPOLATE_LINEAR or PERSPECTIVE + * \param writemask mask of TGSI_WRITEMASK_x */ void * util_make_fragment_tex_shader_writemask(struct pipe_context *pipe, unsigned tex_target, + unsigned interp_mode, unsigned writemask ) { struct ureg_program *ureg; @@ -98,6 +103,9 @@ util_make_fragment_tex_shader_writemask(struct pipe_context *pipe, struct ureg_src tex; struct ureg_dst out; + assert(interp_mode == TGSI_INTERPOLATE_LINEAR || + interp_mode == TGSI_INTERPOLATE_PERSPECTIVE); + ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT ); if (ureg == NULL) return NULL; @@ -106,7 +114,7 @@ util_make_fragment_tex_shader_writemask(struct pipe_context *pipe, tex = ureg_DECL_fs_input( ureg, TGSI_SEMANTIC_GENERIC, 0, - TGSI_INTERPOLATE_PERSPECTIVE ); + interp_mode ); out = ureg_DECL_output( ureg, TGSI_SEMANTIC_COLOR, @@ -133,10 +141,12 @@ util_make_fragment_tex_shader_writemask(struct pipe_context *pipe, * \param tex_target one of PIPE_TEXTURE_x */ void * -util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target ) +util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target, + unsigned interp_mode) { return util_make_fragment_tex_shader_writemask( pipe, tex_target, + interp_mode, TGSI_WRITEMASK_XYZW ); } @@ -147,7 +157,8 @@ util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target ) */ void * util_make_fragment_tex_shader_writedepth(struct pipe_context *pipe, - unsigned tex_target) + unsigned tex_target, + unsigned interp_mode) { struct ureg_program *ureg; struct ureg_src sampler; @@ -163,7 +174,7 @@ util_make_fragment_tex_shader_writedepth(struct pipe_context *pipe, tex = ureg_DECL_fs_input( ureg, TGSI_SEMANTIC_GENERIC, 0, - TGSI_INTERPOLATE_PERSPECTIVE ); + interp_mode ); out = ureg_DECL_output( ureg, TGSI_SEMANTIC_COLOR, diff --git a/src/gallium/auxiliary/util/u_simple_shaders.h b/src/gallium/auxiliary/util/u_simple_shaders.h index 6e760942e2..4aa34bc475 100644 --- a/src/gallium/auxiliary/util/u_simple_shaders.h +++ b/src/gallium/auxiliary/util/u_simple_shaders.h @@ -52,15 +52,18 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe, extern void * util_make_fragment_tex_shader_writemask(struct pipe_context *pipe, unsigned tex_target, + unsigned interp_mode, unsigned writemask); extern void * -util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target); +util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target, + unsigned interp_mode); extern void * util_make_fragment_tex_shader_writedepth(struct pipe_context *pipe, - unsigned tex_target); + unsigned tex_target, + unsigned interp_mode); extern void * |