Mesa (main): mesa: don't add attenuation constants if ffvp doesn't use them
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Nov 24 10:27:19 UTC 2021
Module: Mesa
Branch: main
Commit: 09342dcfc0e45fbbe4a019a7e8086780aebd8336
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=09342dcfc0e45fbbe4a019a7e8086780aebd8336
Author: Marek Olšák <marek.olsak at amd.com>
Date: Mon Nov 1 12:00:06 2021 -0400
mesa: don't add attenuation constants if ffvp doesn't use them
This slightly decreases the size of constant buffers.
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13872>
---
src/mesa/main/ffvertex_prog.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index f38c6a3d36e..2f8b721a2f8 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -939,8 +939,7 @@ static struct ureg calculate_light_attenuation( struct tnl_program *p,
struct ureg VPpli,
struct ureg dist )
{
- struct ureg attenuation = register_param3(p, STATE_LIGHT, i,
- STATE_ATTENUATION);
+ struct ureg attenuation = undef;
struct ureg att = undef;
/* Calculate spot attenuation:
@@ -950,6 +949,7 @@ static struct ureg calculate_light_attenuation( struct tnl_program *p,
struct ureg spot = get_temp(p);
struct ureg slt = get_temp(p);
+ attenuation = register_param3(p, STATE_LIGHT, i, STATE_ATTENUATION);
att = get_temp(p);
emit_op2(p, OPCODE_DP3, spot, 0, negate(VPpli), spot_dir_norm);
@@ -969,6 +969,10 @@ static struct ureg calculate_light_attenuation( struct tnl_program *p,
if (p->state->unit[i].light_attenuated && !is_undef(dist)) {
if (is_undef(att))
att = get_temp(p);
+
+ if (is_undef(attenuation))
+ attenuation = register_param3(p, STATE_LIGHT, i, STATE_ATTENUATION);
+
/* 1/d,d,d,1/d */
emit_op1(p, OPCODE_RCP, dist, WRITEMASK_YZ, dist);
/* 1,d,d*d,1/d */
@@ -1141,7 +1145,10 @@ static void build_lighting( struct tnl_program *p )
}
}
for (i = 0; i < MAX_LIGHTS; i++) {
- if (p->state->unit[i].light_enabled)
+ if (p->state->unit[i].light_enabled &&
+ (!p->state->unit[i].light_spotcutoff_is_180 ||
+ (p->state->unit[i].light_attenuated &&
+ !p->state->unit[i].light_eyepos3_is_zero)))
register_param3(p, STATE_LIGHT, i, STATE_ATTENUATION);
}
More information about the mesa-commit
mailing list