Giter VIP home page Giter VIP logo

aiekick / glsloptimizerv2 Goto Github PK

View Code? Open in Web Editor NEW
35.0 8.0 3.0 8.61 MB

Glsl Optimizer based on Mesa3D implementation for Opengl 4.5 (450) (Vertex/Geom/Fragment/Tesselation Support)

License: Apache License 2.0

CMake 0.26% C 37.06% C++ 58.18% GLSL 0.95% Lex 0.25% Yacc 2.54% Python 0.12% LLVM 0.64%
glsl optimization mesa3d tool lib shader vertex-shader tesselation-shader geometry-shader fragment-shader

glsloptimizerv2's Introduction

GlslOptimizerV2

GlslOptimizerV2 is an optimizer for the glsl language with support of last opengl api and Stages Vertex \ Tesselation Control \ Tesselation Evaluation \ Geometry \ Fragment

Based on Mesa3D and glsl-optimizer

Pay Attention, for the moment this app is full of bugs and can crash in any reason.

Why ?

Some time ago i found the original glsl-optimizer, but this project is stopped since a while and without support of Tesselation and Geometry shader stage nor last Opengl Api.

After analysed it a bit, i discovered than most of the Optimization code is coming from Mesa3D Implementation. So after a bit of search, i decided to create an updated version of Gsl-Optimizer who can support last stages and last Opengl api too.

All this work is mostly based on Mesa3D and original Glsl-Optimizer, but all not work porperly for the moment. I not guaranty than generated optimized shader can compile

I have exposed the most of params i have found in Mesa3D for better optimization possibilities, and proposed a GlslOptimizer module and an standalone App for optimize in an easy way your shaders.

I am very interested in graphic programming but as a self-learning guy, im in no way an expert.

So if you feel like it, help me improve this Software that I make available in open source for that.

Get started :

  1. Open the App :)
  2. Open a shader file( you have many samples in dir shader_samples) or create new (in the main menu bar)
  3. Set the type of shader, The version of glsl you want, and Tune the parameters.
  4. Optimize

Get started

To note :

All the settings are saved in a conf file in the same directory of your shader file the conf file name the name and ext of your shader file with an extention conf : If you have a shader like : shader.frag => the conf file will be shader_frag.conf

So for the next time, you just need to open your sahder file again, (dont opn conf file) and your settings will comming back :)

The module GlslOptimizerV2 :

The module GlslOptimizerV2 is inside the directory GlslOptimizerV2

There is a CMakeLists.txt file for link into your porject easily

The Standalone App :

Some screenshots of the current app :

Open You file : Open a  File

Write/open your code and optimzie it : (see in the pane, all the params i exepose) Write your code Optimize a shader

Customize the style ( the default theme is light but you can also customize app theme and editor palette) Customize app Style

Library used :

Based on :

Contributions / issues :

As said im not an expert, so if you want help me, your are welcome.

Contributiond : you can send a pull request or speak about in issue tab

Issues : use issue tab

Feature request : use issue tab

glsloptimizerv2's People

Contributors

aiekick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

glsloptimizerv2's Issues

Visitor comparison operation bug

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.