condition with float constant return always false

More
3 years 8 months ago #1 by seri14 condition with float constant return always false was created by seri14
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 following user(s) said Thank You: Wicked Sick

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #2 by crosire Replied by crosire on topic condition with float constant return always false
The following user(s) said Thank You: Wicked Sick, seri14

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago - 3 years 8 months ago #3 by seri14 Replied by seri14 on topic condition with float constant return always false
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: 3 years 8 months ago by seri14.
The following user(s) said Thank You: Wicked Sick

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #4 by crosire Replied by crosire on topic condition with float constant return always false
The following user(s) said Thank You: Wicked Sick, seri14, Marot

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #5 by thrive4 Replied by thrive4 on topic condition with float constant return always false
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:

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #6 by klotim Replied by klotim on topic condition with float constant return always false

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.

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #7 by crosire Replied by crosire on topic condition with float constant return always false
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.

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #8 by klotim Replied by klotim on topic condition with float constant return always false

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!

Please Log in or Create an account to join the conversation.

More
3 years 8 months ago #9 by thrive4 Replied by thrive4 on topic condition with float constant return always false
Ok, a debugging method thanks for the explanation.

Please Log in or Create an account to join the conversation.

We use cookies

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.