Welcome, Guest.
Username: Password: Remember me

TOPIC: condition with float constant return always false

condition with float constant return always false 5 months 4 days ago #1

Input code
void test()
{
	float R;
	const float V = 10.0;
	if (V > 1.0)
		R = 1.0;
}
Result (from [Show HLSL/GLSL])
#line 63
void F__test()
{
	const float _74 = 0.00000000;
#line 65
	float R;
#line 65
	R = _74;
	const bool _79 = false;
#line 67
	if (_79)
	{
		const float _80 = 1.00000000;
#line 68
		R = _80;
	}
	return;
}
The administrator has disabled public write access.
The following user(s) said Thank You: Wicked Sick

condition with float constant return always false 5 months 4 days ago #2

Cheers, crosire =)
The administrator has disabled public write access.
The following user(s) said Thank You: Wicked Sick, seri14

condition with float constant return always false 5 months 4 days ago #3

After this commit, compile of some effects will fail.

github.com/Mortalitas/GShade-Shaders/blo...haders/MagicBloom.fx
github.com/Mortalitas/GShade-Shaders/blo...aders/qUINT_bloom.fx
github.com/Mortalitas/GShade-Shaders/blo...ers/qUINT_common.fxh
2019-03-21T13:14:33:124 [12608] | ERROR | Failed to compile "C:\...\reshade-shaders\Shaders\MagicBloom.fx":
C:\...\reshade-shaders\Shaders\MagicBloom.fx(91, 34): error X3082: int or unsigned int type required
C:\...\reshade-shaders\Shaders\MagicBloom.fx(91, 122): error X3000: syntax error: unexpected '|', expected expression
C:\...\reshade-shaders\Shaders\MagicBloom.fx(193, 10): error X3011: value must be a literal expression
C:\...\reshade-shaders\Shaders\MagicBloom.fx(216, 109): error X3538: value must be a literal scalar expression

2019-03-21T13:14:33:243 [15272] | ERROR | Failed to compile "C:\...\reshade-shaders\Shaders\qUINT_bloom.fx":
C:\...\reshade-shaders\Shaders\qUINT_bloom.fx(136, 43): error X3082: int or unsigned int type required
C:\...\reshade-shaders\Shaders\qUINT_bloom.fx(136, 113): error X3000: syntax error: unexpected '|', expected expression
C:\...\reshade-shaders\Shaders\qUINT_bloom.fx(145, 100): error X3538: value must be a literal scalar expression
Last Edit: 5 months 3 days ago by seri14.
The administrator has disabled public write access.
The following user(s) said Thank You: Wicked Sick

condition with float constant return always false 5 months 3 days ago #4

Cheers, crosire =)
The administrator has disabled public write access.
The following user(s) said Thank You: Wicked Sick, seri14, Marot

condition with float constant return always false 4 months 4 weeks ago #5

Great catch!

But I'm a bit stumped, and I do hate doing the why would
you do this, but I really would like to know under which
condition you would set up code this way?

const float V = 10.0;
if (V > 1.0)

V is always going to be larger then 1.0.... :blink:
The administrator has disabled public write access.

condition with float constant return always false 4 months 4 weeks ago #6

thrive4 wrote:
Great catch!

But I'm a bit stumped, and I do hate doing the why would
you do this, but I really would like to know under which
condition you would set up code this way?

const float V = 10.0;
if (V > 1.0)

V is always going to be larger then 1.0.... :blink:

Why yes ofc. But that's just to easily provide that something doesn't work.
In real-life scenarios it would be dynamic variables.
The administrator has disabled public write access.

condition with float constant return always false 4 months 4 weeks ago #7

Nah. Dynamic variables worked fine. This was a very specific case. But can happen when you are debugging with constants to check if a certain code path is working for example.
Cheers, crosire =)
The administrator has disabled public write access.

condition with float constant return always false 4 months 4 weeks ago #8

crosire wrote:
Nah. Dynamic variables worked fine. This was a very specific case. But can happen when you are debugging with constants to check if a certain code path is working for example.

Alright, Glad that it was solved!
The administrator has disabled public write access.

condition with float constant return always false 4 months 3 weeks ago #9

Ok, a debugging method thanks for the explanation.
The administrator has disabled public write access.