[Mesa-dev] [PATCH] softpipe: Do round-to-even, not round-up.

Jose Fonseca jfonseca at vmware.com
Mon Jun 25 05:16:19 PDT 2012



----- Original Message -----
> On Fri, May 18, 2012 at 08:55:39AM -0600, Brian Paul wrote:
> > In any case, I think this function could be moved into u_math.c so
> > it
> > could be used elsewhere.
> [...]
> > I was looking at the GLSL round() and roundEven() functions.  The
> > GLSL
> > spec says round() can use whatever method is fastest.  But in
> > builtin_functions.cpp the round() function is implemented in terms
> > of
> > the round_even builtin.  It seems to me that we should have a
> > generic
> > 'round' builtin function and separate TGSI_ROUND and
> > TGSI_ROUND_EVEN
> > opcodes so that drivers can really have the option of using a
> > faster/looser round function.
> 
> I've tried doing that.  I've moved the function to u_math.c, then
> made
> src/glsl/ir_constant_expression.cpp use it.  That blew up.
> 
> If I compile with scons, I get:
>   Linking build/linux-x86_64-debug/glsl/builtin_compiler ...
> build/linux-x86_64-debug/glsl/ir_constant_expression.o: In function
> `dot':
> /home/galibert/X/work/mesa-play/src/glsl/ir_constant_expression.cpp:47:
> undefined reference to `_debug_assert_fail'
> [...]
> /home/galibert/X/work/mesa-play/src/glsl/ir_constant_expression.cpp:265:
> undefined reference to `ieee754_fp32_round_half_to_even'
> [etc]
> 
> If I compile with autoconf/make I get:
> ir_constant_expression.cpp:42:25: fatal error: util/u_math.h: No such
> file or directory
> 
> So at that point src/glsl and src/gallium are not supposed to meet
> each other.  And changing that is not a responsability I feel like
> taking.  Any advice?

This is a long standing janitorial task that everybody agrees but nobody taken due to lack of time: we need to create a shared top level module (e,g., src/cgrt, for Common Graphics Runtime), with the math/os/portability inlines/defines/helpers, so that all other modules (Mesa, glsl, gallium) can depend on, without introducing cyclic dependencies between them.

Fixing this, is a big task, likely too big for you to take. But you can take a first step in that direction with this work, by creating the src/cgrt/cgrt_math.[ch] with this function, and include/link it everywhere it's used. Others can start moving stuff into there as time/opportunity allows.


Jose


More information about the mesa-dev mailing list