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

sokol-shdc TODO #8

Open
3 tasks
floooh opened this issue May 28, 2019 · 6 comments
Open
3 tasks

sokol-shdc TODO #8

floooh opened this issue May 28, 2019 · 6 comments
Assignees

Comments

@floooh
Copy link
Owner

floooh commented May 28, 2019

  • investigate how the new SPIRV-Cross #line information can be improved with SPIRV-Tools optimizer passes enabled (e.g. which passes mangle the location the worst)
  • alternatively have a "dev-mode" where the optimizer passes don't run (because then the line infos appear perfect)
  • implement the #line mapping for D3D... check if the D3D compiler actually uses the #line info for errors and warnings, otherwise parse the #line statements myself
@mattiasljungstrom
Copy link
Contributor

What if on error you compile the shader again with all optimizations turned off to get the line nrs?

@floooh
Copy link
Owner Author

floooh commented May 30, 2019

Good idea!

@floooh floooh self-assigned this May 30, 2019
@eugeneko
Copy link

eugeneko commented Aug 8, 2019

Is it possible to publish sokol-shdc as library?
It's useful tool, but I don't want to have process interop unless necessary.
So I'd like to statically link against sokol-shdc and have some basic interface that will let me use it without unnecessary I/O (e.g. if I don't want to save compiled shader).

@floooh
Copy link
Owner Author

floooh commented Aug 8, 2019

It's possible (main.c would need to be replaced with a sokol_shdc.h/.c, which implements a small API to pass options but otherwise looks much like main.c).

But I think the required dependencies would make this tricky / pretty big (the stuff in here would need to be linked in basically: https://github.com/floooh/sokol-tools/tree/master/ext).

Also the bytecode-compilation for D3D11 and especially Metal should be removed, this is better done via sokol_gfx.h then (especially because compiling Metal bytecode involves running the metal-compiler command line tool as external process).

@eugeneko
Copy link

eugeneko commented Aug 8, 2019

I'm mostly interested in pure GLSL->HLSL, GLSL, Metal conversion and maybe shader optimization.
This is the most re-usable and generic part of this tool.
May you give me a hint what files in shdc are responsible for this logic?

@floooh
Copy link
Owner Author

floooh commented Aug 17, 2019

Here's a quick explanation what each source file is responsible for:

  • args.cc: parse command line arguments into an args_t object
  • input.cc: load and parse the GLSL source file into an input_t object
  • spirv.cc: wrapper around https://github.com/KhronosGroup/glslang to compile vertex- and fragment-shader snippets into SPIRV, results in a number of populated spirv_t objects
  • spirvcross.cc: wrapper around https://github.com/KhronosGroup/SPIRV-Cross to translate the generated SPIRV bytecode to the target shader languages, results in a number of populated spirvcross_t objects
  • bytecode.cc: optionally compile HLSL and/or Metal shader source code to bytecode via d3dcompiler.dll and/or invoking the macOS/iOS Metal shader compiler as command line tool, results in a number of bytecode_t objects
  • sokol.cc, bare.cc: these are the output file writers, sokol.cc generates a sokol_gfx.h compatible header, bare.cc generates binary files which can be loaded at runtime (more file writers may be added in the future)

You can read the main() function in main.cc from top to bottom to see the sequence of actions.

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

No branches or pull requests

3 participants