Closed jherico closed 9 months ago
Just a quick note that we are in the process of completely reworking shader handling in our samples. Please don't invest too much time in this PR
Well that's just awesome. Maybe someone should say something to that effect on the bunch of related open issues. Any of the other open issues I should avoid trying to contribute on, or am I supposed to guess?
We regularly meet inside Khronos to discuss issues and PRs. We're glad for contributions, but it's always a good idea to ask first before putting too much work into it. As for the shader stuff, see #655, #733 and #846. We also have projects with e.g. a roadmap for samples and the framework, which to our shame we should update so people can see what we're actively working on.
Ah I see, there is a reference to the offline shader compiler branch on the issue referenced by this PR. However, I failed to update this to the most recent branch (on my phone now but will be able to drop a link later. It's in the PRs though)
It is essentially to the same point as this PR. It has variant processing but the mechanism could likely be cleaned up.
One of the goals was to have the compile process in python scripts separate to CMake... Variants does make this a little messy.
Feel free to take a look and make any suggestions. There are a few caveats that are discussed in a working group which we are trying to address at the same time
Ah great, thanks @SaschaWillems for finding the links!
The WIP branch has grown in complexity as the difficulty isn't particularly in the compiling of shaders. But making sure they are available to the framework.
Granted the framework could be in a better condition to make this easier. Thats something the working group is attempting to address as well
@SaschaWillems sorry if I was snarky. I saw the existing WIP branch was closed and didn't realize it had been replaced with another WIP. I'm trying to participate more in the official samples, and thought I saw an opportunity and this kind of took the wind out of my sails.
@tomadamatkinson
The WIP branch has grown in complexity as the difficulty isn't particularly in the compiling of shaders. But making sure they are available to the framework.
I'm not certain I understand your meaning. You mean making the result of the offline compilation visible to the framework, so that pieces of framework code could reference the compiled versions as easily as the samples?
My approach creates the output artifacts in the build directory in the same relative path as the shader itself, so shaders/foo/bar.vert
becomes:
<BUILD_DIR>/shaders/foo/bar.vert.debug.spv
<BUILD_DIR>/shaders/foo/bar.vert.spv
<BUILD_DIR>/shaders/foo/bar.vert.inl
There's no reason that multiple samples or parts of the framework itself can't target the same shaders and share the generated files.
At any rate, is there anything I can contribute to the WIP or anywhere else help is desired (ideally something that uses the C++ bindings, but, you know, whatever).
@SaschaWillems sorry if I was snarky. I saw the existing WIP branch was closed and didn't realize it had been replaced with another WIP. I'm trying to participate more in the official samples, and thought I saw an opportunity and this kind of took the wind out of my sails.
I didn't percieve it as snarky ;) We should do a better job at communicating what we're working on. We have two projects in this repo (https://github.com/KhronosGroup/Vulkan-Samples/projects?type=classic), but we haven't really updated those, and we should do that to avoid people wasting their time.
Most external contributions usually come in the form of samples. As Tom noted, we're heavily reworking the framework and that includes how we handle shaders. We also have companies that do on these samples, making it kinda hard to coordinate with external contributions.
I'm not certain I understand your meaning. You mean making the result of the offline compilation visible to the framework, so that pieces of framework code could reference the compiled versions as easily as the samples?
Vulkan Samples effectively has 3 frameworks. Api Samples, Performance Samples (C) and Performance Samples (C++). The Api Samples framework is lightweight and easy to work with - but is glued on top of Performance (C). The Performance Samples framework is a little more robust but also opinionated on how it is used. Components like the Resource Cache and Shader Modules come into play.
The last issue I ran into with the WIP branch was trying to integrate the same loader into all three frameworks effectively. (Granted I got a little sidetracked staring at the resource cache for too long 😄). It's been a few weeks now since I last got a chance to take a look at it and so would appreciate some help getting it over the line if you are interested.
Thanks. I'll check out the branch, look at the PR and try to wrap my head around the changes and what's remaining. It's been a while since I worked directly with the framework code, so I want to make sure I understand both the current state and where you're trying to take it.
Description
Initial work to prototype a solution for #802
The idea here is to take the shader source files that are used by given sample and compile them to SPIRV, and then make them available to the application at build-time rather than requiring any runtime compilation step.
DONE:
SHADER_FILES_GLSL
declared in the sample to be targeted for compilation, and will generate the following artifactsSHADER.debug.spv
file that is the result ofglslangValidator
compilationSHADER.spv
which is the result of runningspirv-opt
on the above fileSHADER.inl
header file which contains the compile SPIRV as astd::vector<uint32_t>
(should be changed tostd::array<uint32_t, N>
so that the structure can beconstexpr
). The header structure also contains the stage bit and the original source code (which was required because I unwisely pickeddebug_utils
as my test sample, without realizing that it depended on having the source code to attach to the shader object as a tag.TODO:
CompiledShader
structureconstexpr
friendly.General Checklist:
Please ensure the following points are checked:
[ ] This PR describes the scope and expected impact of the changes I am making
Note: The Samples CI runs a number of checks including:
Sample Checklist
If your PR contains a new or modified sample, these further checks must be carried out in addition to the General Checklist: