Skip to content
This repository has been archived by the owner on Jun 5, 2022. It is now read-only.

Visitor comparison operation bug #1

Open
Agrael1 opened this issue Apr 17, 2022 · 1 comment
Open

Visitor comparison operation bug #1

Agrael1 opened this issue Apr 17, 2022 · 1 comment

Comments

@Agrael1
Copy link

Agrael1 commented Apr 17, 2022

Describe the bug
Any comparison operation on single value type results in pre- placing of operator (like ==(a,b)), also bvec1 does not exist.

To Reproduce
Steps to reproduce the behavior:

#version 330
layout(location = 0)out vec4 Output_0;

float Circle_2_circle(in vec2 _st){
 vec2 dist = _st-vec2(0.5);       
 return 1 - smoothstep(1-(1*0.01),  
   1+(1*0.01),      
   dot(dist,dist)*4.0);       
}              
 vec4 Circle_2_main(vec2 sv_texc) {
	vec4 Shape;           
 vec3 xcolor = vec3(Circle_2_circle(sv_texc));    
 Shape = vec4(xcolor, 1.0);       
	return Shape;
}

//-------------------------------------------------------//

float Circle_1_circle(in vec2 _st){
 vec2 dist = _st-vec2(0.5);       
 return 1 - smoothstep(0.708-(0.708*0.01),  
   0.708+(0.708*0.01),      
   dot(dist,dist)*4.0);       
}              
 vec4 Circle_1_main(vec2 sv_texc) {
	vec4 Shape;           
 vec3 xcolor = vec3(Circle_1_circle(sv_texc));    
 Shape = vec4(xcolor, 1.0);       
	return Shape;
}

//-------------------------------------------------------//

 vec4 Subtract_1_main(vec2 sv_texc) {
	vec4 Out;
	vec4 t1 = Circle_2_main( sv_texc);
	vec4 t2 = Circle_1_main( sv_texc);
	vec3 s = (t1-t2).xyz;
	Out = vec4(max(s, vec3(0.0)),1.0);
	return Out;
}

//-------------------------------------------------------//

#define Polygon_1_PI 3.14159265359
#define Polygon_1_TWO_PI 6.28318530718
 vec4 Polygon_1_main(vec2 sv_texc){
	vec4 Shape;
	vec2 st = sv_texc;
	st = st *2.-1.;
	float a = atan(st.x,st.y);
	float r = Polygon_1_TWO_PI/float(3);
	float d = cos(floor(.5+a/r)*r-a)*length(st);
	Shape = vec4(vec3(1-smoothstep(.4,.41,d)), 1.0);
	return Shape;
}

//-------------------------------------------------------//

#define Rotate_1_PI 3.14159265359
mat2 Rotate_1_rotate(float r){
	float a = sin(r);
	float b = cos(r);
    	return mat2(b,-a,
			a,b);
}

 vec4 Rotate_1_main(vec2 sv_texc)
{
	vec4 _out;
	vec2 st = sv_texc;
	st -= vec2(0.5);
	st = Rotate_1_rotate(-1*Rotate_1_PI) * st;
	st += vec2(0.5);
	_out = Polygon_1_main( st);
	return _out;
}

//-------------------------------------------------------//

 vec4 Add_2_main(vec2 sv_texc) {
	vec4 Out;
	vec4 t1 = Polygon_1_main( sv_texc);
	vec4 t2 = Rotate_1_main( sv_texc);
	Out = min(t2+t1, vec4(1.0));
	return Out;
}

//-------------------------------------------------------//

 vec4 Add_1_main(vec2 sv_texc) {
	vec4 Out;
	vec4 t1 = Subtract_1_main( sv_texc);
	vec4 t2 = Add_2_main( sv_texc);
	Out = min(t2+t1, vec4(1.0));
	return Out;
}

//-------------------------------------------------------//

void main(){
	vec4 tmpvar_Add_1 = Add_1_main(gl_FragCoord.xy);
	Output_0 = tmpvar_Add_1;
}

Work shader from my shader generator to be optimized, if all optimizations in opt. struct are disabled, then in polygon there are some instances of both bugs at tmpvar_67. For enabled tmpvar_17 it is;

Expected behavior
bool(a==b) instead of bvec1(==(a,b))

Desktop (please complete the following information):

  • OS: Windows 10

Additional context
Problem is in Optimizer Code, also it's not possible to compile lib outside of the project, and no way to tell if operation is successful or not. I have my own take at https://github.com/Agrael1/tiny-glsl-optimizer, I think the best way is to separate library from gui

@aiekick
Copy link
Owner

aiekick commented Apr 17, 2022

the opimization code from from the mesa3D project.
do you read the readme.md ? the lib is here in the directory GlslOptimizerV2)
bu tbh it was a pain to get it working the last time.
i have no more use of this porject, so i will not spend mush time on it.
for me this porject is dead and may be archived, you can improve it if you want, but i will not work on it

the futur for me is with spirv and glslang

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants