-
Notifications
You must be signed in to change notification settings - Fork 37
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
ShaderGen crash #66
Comments
This sample compiles fine for me, it doesn't look like you're running it from the right directory. The default setup is for use with a debugger so it might not be very intuitive. In my case, I have ShaderGlass folder as d:\Work\ShaderGlass and created test.slang as d:\Work\slang-shaders\test.slang . Then this should work: |
Ok, I assumed the tool would keep files under the tree, saw that ======= "test.slang"
"..\ShaderGlass\Tools\glslangValidator.exe" -V -S vert -o test.vert.spv test.vert.glsl
"..\ShaderGlass\Tools\spirv-cross.exe" --hlsl --shader-model 50 test.vert.spv
"..\ShaderGlass\Tools\spirv-cross.exe" test.vert.spv --reflect
"..\ShaderGlass\Tools\glslangValidator.exe" -V -S frag -o test.frag.spv test.frag.glsl
"..\ShaderGlass\Tools\spirv-cross.exe" --hlsl --shader-model 50 test.frag.spv
"..\ShaderGlass\Tools\spirv-cross.exe" test.frag.spv --reflect
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.20348.0\x64\fxc.exe" /O3 /E main /T vs_5_0 /Fh test.vs_5_0.h test.vs_5_0.hlsl
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
"C:\Program Files (x86)\Windows Kits\10\bin\10.0.20348.0\x64\fxc.exe" /O3 /E main /T ps_5_0 /Fh test.ps_5_0.h test.ps_5_0.hlsl
'C:\Program' is not recognized as an internal or external command,
operable program or batch file.
Very curious, as I see the code does stringstream cmd;
cmd << "\"" << _fxcPath << "\" "
<< " /O3 /E main /T " << profile << " /Fh " << output.string() << " " << input.string();
exec(cmd.str().c_str()); I'll investigate 🤔 |
Interesting, check if you have fxc.exe at that path, if not you'll need to install Windows SDK. |
Yes, that was also an issue, but I had already replaced the hardcoded version with "10.0.22000.0", which is stated as a dependency of the project anyway. The real issue was indeed the shell, I band-aided it with stringstream cmd;
cmd << "cmd /c \"\"" << _fxcPath << "\" "
<< " /O3 /E main /T " << profile << " /Fh " << output.string() << " " << input.string() << "\"";
exec(cmd.str().c_str()); I can make a pull request if you want, but that should be a valid pws command too, not sure of what's happening. I'll piggyback this custom shader-related issue to ask some questions, if you don't mind. |
I've put some hours trying to figure out the code and I've managed to write a sample shader header. I've made an attempt to remove the vertex shader part because I won't need it, I need to add a small pixel shader. Shaders/Custom/TestShaderDef.h #pragma once
namespace TestShaderDefs{
static const BYTE sFragmentByteCode[] = {
68, 88, 66, 67, 135, 176,
...
0, 0, 0, 0
};
}
class TestShaderDef : public ShaderDef{
public:
TestShaderDef() : ShaderDef{}{
Name = "test";
VertexByteCode = NULL;
VertexLength = 0;
FragmentByteCode = TestShaderDefs::sFragmentByteCode;
FragmentLength = sizeof(TestShaderDefs::sFragmentByteCode);
Params.push_back(ShaderParam("MVP", 0, 0, 64, 0.000000f, 0.000000f, 0.000000f));
Params.push_back(ShaderParam("SourceSize", -1, 0, 16, 0.000000f, 0.000000f, 0.000000f));
Params.push_back(ShaderParam("OriginalSize", -1, 16, 16, 0.000000f, 0.000000f, 0.000000f));
Params.push_back(ShaderParam("OutputSize", -1, 32, 16, 0.000000f, 0.000000f, 0.000000f));
Params.push_back(ShaderParam("FrameCount", -1, 48, 4, 0.000000f, 0.000000f, 0.000000f));
Samplers.push_back(ShaderSampler("Source", 2));
VertexSource = "";
FragmentSource = "";
}
}; I'm not sure what I've also added <ClInclude Include="Shaders\Custom\TestShaderDef.h" /> and <ClInclude Include="Shaders\Custom\TestShaderDef.h">
<Filter>Shaders</Filter> Respectively in ShaderGlass.vcxproj and ShaderGlass.vcxproj.filters. I'm really guessing here. |
To include a new shader you need to create a Slang profile file (.slangp) and run that through ShaderGen as well. It will automatically add the the profile and shader to the lists/menus, you don't need to modify code in ShaderGlass manually. The source fields will stay blank, it's a remainder of old functionality where I was compiling shaders on-the-fly, not used anymore. Feel free to raise a PR for the shell call, I will test it in the next release 👍 |
After a bit of poking around, I discovered how
ShaderGen.exe
expects it's input.I created a
slang-shaders
folder, put a test shader in it and ranShaderGen.exe filename.slang
in a debugger, with the pwd correctly set to the build folder.I'm new to slang, I'm trying an example found in the slang guide:
The output I get is:
The program crashes at line 336:
Perhaps
MVP
is something which is unsupported? Results are the same if I remove the vertex shader section, andMVP
references.I've seen that the tool acts as a full-blown lexer-parser-.. at once, so the code is quite beyond my capabilities.
Can you reproduce?
The text was updated successfully, but these errors were encountered: