[Mesa-dev] Mesa (shader-work): glsl: add pass to lower variable array indexing to conditional assignments

Ian Romanick idr at freedesktop.org
Mon Sep 13 13:14:39 PDT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Luca Barbieri wrote:
> Module: Mesa
> Branch: shader-work
> Commit: 831691d0bdcae4b1efbab3a62f7ead59e30ae5d7
> URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=831691d0bdcae4b1efbab3a62f7ead59e30ae5d7
> 
> Author: Luca Barbieri <luca at luca-barbieri.com>
> Date:   Wed Sep  8 01:35:44 2010 +0200
> 
> glsl: add pass to lower variable array indexing to conditional assignments
> 
> Currenly GLSL happily generates indirect addressing of any kind of
> arrays.
> 
> Unfortunately DirectX 9 GPUs are not guaranteed to support any of them in
> general.
> 
> This pass fixes that by lowering such constructs to a binary search on the
> values, followed at the end by vectorized generation of equality masks, and
> 4 conditional assignments for each mask generation.
> 
> Note that this requires the ir_binop_equal change so that we can emit SEQ
> to generate the boolean masks.
> 
> Unfortunately, ir_structure_splitting is too dumb to turn the resulting
> constant array references to individual variables, so this will need to
> be added too before this pass can actually be effective for temps.
> 
> ---
> 
>  src/glsl/Makefile          |    1 +
>  src/glsl/SConscript        |    1 +
>  src/glsl/ir_optimization.h |    1 +
>  3 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/src/glsl/Makefile b/src/glsl/Makefile
> index efa274b..b12878c 100644
> --- a/src/glsl/Makefile
> +++ b/src/glsl/Makefile
> @@ -31,6 +31,7 @@ CXX_SOURCES = \
>  	glsl_symbol_table.cpp \
>  	hir_field_selection.cpp \
>  	ir_algebraic.cpp \
> +	ir_array_index_to_cond_assign.cpp \

I think you forgot to include this file in this commit.

This is one that I was going to give some review comments on.  I really
want to have this change in 7.9, but the patch is going to need some
changes.  When we first discussed using C++ in the GLSL compiler in
Mesa, we got some feedback about C++ features not to use.  The main ones
on the list are:

	- RTTI
	- Operator overloading
	- Multiple / virtual inheritance
	- Templates

Based on my memory of the code, it should be pretty easy to eliminate
the use of templates.

>  	ir_basic_block.cpp \
>  	ir_clone.cpp \
>  	ir_constant_expression.cpp \

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkyOhisACgkQX1gOwKyEAw/M9gCggz7cOBqyXhyHXrOyywAU9H4y
jWkAnRn6LQhRAr/cEduKE0j0nOLT2nlw
=2OzQ
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list