Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shaders using GLSL not Cg/HLSL #26

Merged
merged 105 commits into from
Sep 8, 2018
Merged

Shaders using GLSL not Cg/HLSL #26

merged 105 commits into from
Sep 8, 2018

Conversation

revmischa
Copy link
Collaborator

@revmischa revmischa commented Feb 2, 2018

Trying to get rid of super ancient unsupported nVidia Cg framework and use standard GL shaders.
The shaders in preset files are written in HLSL for DirectX. projectM used a toolkit from nVidia called Cg to handle them, but Cg is long deprecated and obsolete.
I'm attempting to use https://github.com/Thekla/hlslparser to transpile from HLSL to GLSL on the fly, and it's close to working but has some syntax issues.

The main conversion is done in:
https://github.com/projectM-visualizer/projectm/pull/26/files#diff-6df95f02d59c83baf42ed81c8668722a
https://github.com/projectM-visualizer/projectm/pull/26/files#diff-f4b5c1904e3d8fa6c1248fe1ac843d79

This may be close to working but it has issues right now. Needs work.

@revmischa revmischa self-assigned this Feb 2, 2018
@axe312ger
Copy link
Contributor

Awesome! Will this boost the visual quality, too? Or is it just refactoring to get rid of legacy code?

@revmischa
Copy link
Collaborator Author

If we can get the shaders to work it will greatly increase the quality. However the shaders are written in DirectX/Cg style and may need some converting to GLSL style. I dunno anything about doing that so someone else needs to help.

@axe312ger
Copy link
Contributor

Maybe twitter can help? I tweeted about it here: https://twitter.com/axe312ger/status/968429518095634432

@revmischa
Copy link
Collaborator Author

I'll put up a status update on where things are at in the next few weeks.. stay tuned

@revmischa
Copy link
Collaborator Author

I'm not working on anything right now for projectM (busy with $dayjob), but I'm happy to provide guidance to anyone who wants to contribute

@axe312ger
Copy link
Contributor

Any chance this can help?
https://www.opengl.org/discussion_boards/showthread.php/174728-Compiling-CG-to-GLSL

cgc -profile glslv vert.cg

@revmischa
Copy link
Collaborator Author

Very cool! Feel free to give it a try. The shader code is shoved inside the preset files in a funky format though so you'd have to parse it out, convert it, and reinsert it

@revmischa revmischa mentioned this pull request Apr 8, 2018
Merge master + work on HLSL->GLSL transpilation
@revmischa
Copy link
Collaborator Author

I'm giving https://github.com/Thekla/hlslparser a try - it should transpile from HLSL to GLSL. I've got it hooked up, now work needs to be done on passing in the variables and texture samplers from projectM into the shaders. Then maybe shaders will work!

@revmischa
Copy link
Collaborator Author

Some syntax issues and GL versioning issues but it's close! I think!

@revmischa revmischa changed the title Shaders using GLSL not Cg Shaders using GLSL not Cg/HLSL May 28, 2018
@deltaoscarmike
Copy link
Collaborator

Status:

  • All presets with a warp and/or composite shader are successfully compiled in GLSL
  • Nativepresets are working again
  • screens "borders" are fixed

To do: fix rendering differences against winamp/milkdrop. Some presets are correctly rendered but other have visual issues.

loadTextureDir();

loadTextureDir(std::string(DATADIR_PATH) + "/presets");
loadTextureDir(std::string(DATADIR_PATH) + "/textures");
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this exist?

@revmischa
Copy link
Collaborator Author

Bravo! Good stuff 👍
You think you're gonna submit the hlslparser fixes back?

@revmischa
Copy link
Collaborator Author

Got a crash:

libc++abi.dylib: Pure virtual function called!
Process 76589 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
    frame #0: 0x00007fff5ba5bb66 libsystem_kernel.dylib`__pthread_kill + 10
libsystem_kernel.dylib`__pthread_kill:
->  0x7fff5ba5bb66 <+10>: jae    0x7fff5ba5bb70            ; <+20>
    0x7fff5ba5bb68 <+12>: movq   %rax, %rdi
    0x7fff5ba5bb6b <+15>: jmp    0x7fff5ba52ae9            ; cerror_nocancel
    0x7fff5ba5bb70 <+20>: retq   
Target 0: (projectMSDL) stopped.

@revmischa
Copy link
Collaborator Author

doesn't crash if i disable threading

@deltaoscarmike
Copy link
Collaborator

You think you're gonna submit the hlslparser fixes back?

No, my modifications have many impacts on Metal and HLSL generators and it's a lot of work to make sure these will still generate valid code.

Got a crash:

Could you provide a more explicit backtrace callstack (with files and line number) ?

@revmischa
Copy link
Collaborator Author

Anything left to do @deltaoscarmike? Is it good to go? Can I help with anything?

@revmischa
Copy link
Collaborator Author

@deltaoscarmike merge y/n?

@deltaoscarmike
Copy link
Collaborator

Yes

@revmischa revmischa merged commit 6240b9d into master Sep 8, 2018
revmischa added a commit that referenced this pull request Nov 16, 2019
Re-enable shaders on modern platforms by transpiling HLSL to GLSL on the fly.
Better GLES support.
Running successfully on embedded systems with GLES and shaders. Compiles and almost runs with emscripten now (#92).
Mega props 👏 => @deltaoscarmike <= 👏
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants