From: Michal Krol Date: Mon, 18 Jan 2010 11:11:05 +0000 (+0100) Subject: tgsi: Add ureg_DECL_immediate_block_uint(). X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4698a865e076998107c188b39db039bdcbaac3a9;p=mesa.git tgsi: Add ureg_DECL_immediate_block_uint(). Allows declaring a contiguous block of immediates. Useful for relative indexing. --- diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.c b/src/gallium/auxiliary/tgsi/tgsi_ureg.c index 8bd6f68dcc0..a67d9c37f87 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.c +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.c @@ -655,6 +655,35 @@ ureg_DECL_immediate_uint( struct ureg_program *ureg, } +struct ureg_src +ureg_DECL_immediate_block_uint( struct ureg_program *ureg, + const unsigned *v, + unsigned nr ) +{ + uint index; + uint i; + + if (ureg->nr_immediates + (nr + 3) / 4 > UREG_MAX_IMMEDIATE) { + set_bad(ureg); + return ureg_src_register(TGSI_FILE_IMMEDIATE, 0); + } + + index = ureg->nr_immediates; + ureg->nr_immediates += (nr + 3) / 4; + + for (i = index; i < ureg->nr_immediates; i++) { + ureg->immediate[i].type = TGSI_IMM_UINT32; + ureg->immediate[i].nr = nr > 4 ? 4 : nr; + memcpy(ureg->immediate[i].value.u, + &v[(i - index) * 4], + ureg->immediate[i].nr * sizeof(uint)); + nr -= 4; + } + + return ureg_src_register(TGSI_FILE_IMMEDIATE, index); +} + + struct ureg_src ureg_DECL_immediate_int( struct ureg_program *ureg, const int *v, diff --git a/src/gallium/auxiliary/tgsi/tgsi_ureg.h b/src/gallium/auxiliary/tgsi/tgsi_ureg.h index 03eaf24854c..a743be702b4 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_ureg.h +++ b/src/gallium/auxiliary/tgsi/tgsi_ureg.h @@ -167,6 +167,11 @@ ureg_DECL_immediate_uint( struct ureg_program *, const unsigned *v, unsigned nr ); +struct ureg_src +ureg_DECL_immediate_block_uint( struct ureg_program *, + const unsigned *v, + unsigned nr ); + struct ureg_src ureg_DECL_immediate_int( struct ureg_program *, const int *v,