[Mesa-dev] [PATCH 03/43] st/nine: Declare constants only up to the maximum needed.
Ilia Mirkin
imirkin at alum.mit.edu
Sat Jan 31 12:30:31 PST 2015
On Fri, Jan 30, 2015 at 3:34 PM, Axel Davy <axel.davy at ens.fr> wrote:
> Previously 276 constants were declared everytime.
>
> This patch makes shaders declare constants up to the maximum
> constant needed and moves the moment we print the TGSI
> shader after the moment we declare the constants.
>
> This is needed for r500, since when indirect addressing is used,
> it cannot reduce the amount of constants needed, and that it is
> restricted to 256 constant slots.
>
> Signed-off-by: Axel Davy <axel.davy at ens.fr>
> ---
> src/gallium/state_trackers/nine/nine_shader.c | 38 ++++++++-------------------
> 1 file changed, 11 insertions(+), 27 deletions(-)
>
> diff --git a/src/gallium/state_trackers/nine/nine_shader.c b/src/gallium/state_trackers/nine/nine_shader.c
> index 1984087..8a8695a 100644
> --- a/src/gallium/state_trackers/nine/nine_shader.c
> +++ b/src/gallium/state_trackers/nine/nine_shader.c
> @@ -620,24 +620,6 @@ tx_src_scalar(struct ureg_dst dst)
> return src;
> }
>
> -/* Need to declare all constants if indirect addressing is used,
> - * otherwise we could scan the shader to determine the maximum.
> - * TODO: It doesn't really matter for nv50 so I won't do the scan,
> - * but radeon drivers might care, if they don't infer it from TGSI.
> - */
> -static void
> -tx_decl_constants(struct shader_translator *tx)
> -{
> - unsigned i, n = 0;
> -
> - for (i = 0; i < NINE_MAX_CONST_F; ++i)
> - ureg_DECL_constant(tx->ureg, n++);
> - for (i = 0; i < NINE_MAX_CONST_I; ++i)
> - ureg_DECL_constant(tx->ureg, n++);
> - for (i = 0; i < (NINE_MAX_CONST_B / 4); ++i)
> - ureg_DECL_constant(tx->ureg, n++);
> -}
> -
> static INLINE void
> tx_temp_alloc(struct shader_translator *tx, INT idx)
> {
> @@ -3067,7 +3049,7 @@ nine_translate_shader(struct NineDevice9 *device, struct nine_shader_info *info)
> struct shader_translator *tx;
> HRESULT hr = D3D_OK;
> const unsigned processor = tgsi_processor_from_type(info->type);
> - unsigned slot_max;
> + unsigned s, slot_max;
>
> user_assert(processor != ~0, D3DERR_INVALIDCALL);
>
> @@ -3095,7 +3077,6 @@ nine_translate_shader(struct NineDevice9 *device, struct nine_shader_info *info)
> hr = E_OUTOFMEMORY;
> goto out;
> }
> - tx_decl_constants(tx);
>
> tx->native_integers = GET_SHADER_CAP(INTEGERS);
> tx->inline_subroutines = !GET_SHADER_CAP(SUBROUTINES);
> @@ -3134,13 +3115,6 @@ nine_translate_shader(struct NineDevice9 *device, struct nine_shader_info *info)
> if (IS_VS && !ureg_dst_is_undef(tx->regs.oPts))
> info->point_size = TRUE;
>
> - if (debug_get_bool_option("NINE_TGSI_DUMP", FALSE)) {
> - unsigned count;
> - const struct tgsi_token *toks = ureg_get_tokens(tx->ureg, &count);
> - tgsi_dump(toks, 0);
> - ureg_free_tokens(toks);
> - }
> -
> /* record local constants */
> if (tx->num_lconstf && tx->indirect_const_access) {
> struct nine_range *ranges;
> @@ -3210,6 +3184,16 @@ nine_translate_shader(struct NineDevice9 *device, struct nine_shader_info *info)
> info->num_float_consts_slots;
> info->const_used_size = sizeof(float[4]) * slot_max; /* slots start from 1 */
>
> + for(s = 0; s < slot_max; s++)
for (
With that fixed, Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
> + ureg_DECL_constant(tx->ureg, s);
> +
> + if (debug_get_bool_option("NINE_TGSI_DUMP", FALSE)) {
> + unsigned count;
> + const struct tgsi_token *toks = ureg_get_tokens(tx->ureg, &count);
> + tgsi_dump(toks, 0);
> + ureg_free_tokens(toks);
> + }
> +
> info->cso = ureg_create_shader_and_destroy(tx->ureg, device->pipe);
> if (!info->cso) {
> hr = D3DERR_DRIVERINTERNALERROR;
> --
> 2.1.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list