Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Integrate any one of the various GLSL / shader optimizers #167

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

lf94
Copy link
Contributor

@lf94 lf94 commented Feb 1, 2023

Amazing glsl-optimizer bulids no problem! This should help resolve the massive GLSL code that curv generates before sending it to the glShaderCompiler. I noticed while curv does a small bit of optimization itself, actually not optimizing and using a library like this (which was developed mostly by the MESA people, who are extremely knowledgeable with shader compilers) will have great effects.

I just need to resolve some linking errors in the CMakefile (damn cmake...) and it should be good to go!

@lf94
Copy link
Contributor Author

lf94 commented Feb 1, 2023

@doug-moen would you happen to know a quick fix for this?

error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.40, 1.50, 1.00 ES, and 3.00 ES

I'm guessing it's because the GLSL optimizer is outputting GLSL 3.30?

@lf94
Copy link
Contributor Author

lf94 commented Feb 1, 2023

Nevermind, it's glsl-optimizer that's expecting a certain GLSL variant.

@lf94
Copy link
Contributor Author

lf94 commented Feb 1, 2023

Agh, in the README:

GLSL versions 1.10 and 1.20 are supported. 1.10 is the default, use #version 120 to specify 1.20. Higher GLSL versions might work, but aren't tested now.
GLSL ES versions 1.00 and 3.00 are supported.

Maybe https://github.com/aiekick/GlslOptimizerV2 will work better.

@lf94
Copy link
Contributor Author

lf94 commented Feb 1, 2023

I'm going to throw out the current code and rework it to use Khrono's SPIR-V optimizer stuff: https://stackoverflow.com/a/59770586

@lf94 lf94 requested a review from doug-moen February 3, 2023 03:58
@lf94 lf94 marked this pull request as ready for review February 3, 2023 03:58
@lf94
Copy link
Contributor Author

lf94 commented Feb 3, 2023

Bada-boom bada-bing. Optimizer is working. :) I went with https://github.com/google/shaderc which combines the things mentioned in that StackOverflow post.

@doug-moen please run any heavy examples you may have privately. Everything I throw at it is basically rendering immediately.

@lf94
Copy link
Contributor Author

lf94 commented Feb 3, 2023

My skull and phone controller things seem to run well; the skull is still noticeably a tad staggering but I dont think it was like before.

@lf94
Copy link
Contributor Author

lf94 commented Feb 3, 2023

(I'll fix the CI after a few tests we do)

@lf94
Copy link
Contributor Author

lf94 commented Feb 3, 2023

git://len.falken.directory/code/Scadvent.git clone this and try out Day4. Anything with repetitions like that should be noticeably better than curv without the optimizer. Edit: Day5 seems to be even more tasking

@lf94
Copy link
Contributor Author

lf94 commented Feb 3, 2023

It looks like *into_preprocessed_text function doesn't do any size optimization (well it does but nothing actually noticeable) - I need to figure out how to load SPIR-V binary or assembly...

@lf94 lf94 marked this pull request as draft February 3, 2023 05:13
@lf94
Copy link
Contributor Author

lf94 commented Feb 3, 2023

Nevermind, you can ignore this PR again for now. I need to update glfw glad or whatever to get access to OpenGL 4.6 so functions like glShaderBinary are available.

@lf94 lf94 changed the title Integrate glsl-optimizer Integrate any of the various GLSL / shader optimizers Feb 3, 2023
@lf94 lf94 changed the title Integrate any of the various GLSL / shader optimizers Integrate any one of the various GLSL / shader optimizers Feb 3, 2023
@lf94
Copy link
Contributor Author

lf94 commented Feb 4, 2023

@doug-moen I could use your expertise on this one. For some reason, the shader becomes optimized, and is loaded, but no output. I'm at a complete loss.

@lf94
Copy link
Contributor Author

lf94 commented Feb 4, 2023

We can have a debug session in the matrix channel if you'd like too: https://app.element.io/#/room/!BbbouYwtinZcRySkDA:matrix.org - it'd really help me. From what I'm reading everything should be setup ok, but it could be how the uniforms are connected or related.

@doug-moen
Copy link
Member

I'm signed into matrix. Let me know how you want to talk.

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

Successfully merging this pull request may close these issues.

None yet

2 participants