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

Errors with Filenames including file extension #5995

Open
kphillisjr opened this issue Jan 3, 2025 · 1 comment
Open

Errors with Filenames including file extension #5995

kphillisjr opened this issue Jan 3, 2025 · 1 comment
Assignees
Labels
goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang

Comments

@kphillisjr
Copy link

kphillisjr commented Jan 3, 2025

A little bit of clarification is needed in how file resolution works. I have a public Git repository ( see: https://github.com/kphillisjr/Shader_Slang_tests ) ) that has compile errors when i write the following code examples:

Shaders\ExampleShaderModule.slang(38): error 30502: the included source file is expected to implement module 'ExampleShaderModule', but it is implementing 'ExampleShaderModule.slang' instead.
__include "TestEmbeddedDirectory/EmbeddedSubDirectory/InterfaceFoo2.slang";
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Shaders\ExampleShaderModule.slang(41): error 30502: the included source file is expected to implement module 'ExampleShaderModule', but it is implementing 'ExampleShaderModule.slang' instead.
__include "TestEmbeddedDirectory/EmbeddedSubDirectory/MyFooType2.slang";
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Shaders/ExampleShader.slang(1): error 39999: import of module 'ExampleShaderModule' failed because of a compilation error
import ExampleShaderModule;
       ^~~~~~~~~~~~~~~~~~~
(0): fatal error 39999: compilation ceased

D:\Shader_Slang_Test\Source>

Tested Versions of Shader-SlangC:

# This is from Shader-Slang github release.
D:\Shader_Slang_Test\Source>D:\Slang\bin\slangc.exe -v
2024.17
# This is the default included in Vulkan SDK.
D:\Shader_Slang_Test\Source>slangc -v
2024.13

File: dir/subdirectory/a.slang

// dir/subdirectory/a.slang
implementing m;
void f_a() {}

File: dir/subdirectory/b.slang

// dir/subdirectory/b.slang
implementing "m"; // alternate syntax.
__include a; // pulls in `a` to module `m`.
void f_b() { f_a(); }

File: dir/subdirectory/c.slang

// dir/subdirectory/c.slang
implementing "m.slang"; // alternate syntax.

void f_c()
{
    // OK, `dir/subdirectory/c.slang` is part of module `m` because it is `__include`'d by
    // `m.slang`.
    f_a(); f_b();
}


File: m.slang

// m.slang
module m;
__include m; // OK, a file including itself is allowed and has no effect.
__include "dir/subdirectory/b"; // Pulls in file b (alternate syntax), and transitively pulls in file a.
__include "dir/subdirectory/c.slang"; // Pulls in file c, specifying the full file name.
void test() { f_a(); f_b(); f_c(); }

Edit: I made a few changes to the bug report to better describe the bug I am talking about.

  • Fixed the github repository with example module code to be visible. This should show the layout of the files causing a bug.
  • Added some inline shader code showing what the example module I wrote is looking at.
  • This is mostly based on how the Module reference is written, so I believe my example should be considered valid code.
@bmillsNV bmillsNV added this to the Q1 2025 (Winter) milestone Jan 7, 2025
@bmillsNV bmillsNV added the goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang label Jan 7, 2025
@kphillisjr
Copy link
Author

Small update, I Created another repository changing the behavior, but still shows this bug:
https://github.com/kphillisjr/ShaderSlangModuleExample

D:\testshaders\ShaderSlang_Module\ShaderSlangModule\ShaderSource>slangc ExampleShader.slang -target cpp -o ExampleShader.cpp -DREVERSE_MODULE_ORDER
ExampleModule.slang(23): error 30502: the included source file is expected to implement module 'ExampleModule.slang', but it is implementing 'ExampleModule' instead.
__include "ModuleSource/Default/b";       // Pulls in file b (alternate syntax), and transitively pulls in file a.
          ^~~~~~~~~~~~~~~~~~~~~~~~
ExampleModule.slang(24): error 30502: the included source file is expected to implement module 'ExampleModule.slang', but it is implementing 'ExampleModule' instead.
__include "ModuleSource/Default/c.slang"; // Pulls in file b (alternate syntax), and transitively pulls in file a.
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ModuleSource/Default/b.slang(7): error 30502: the included source file is expected to implement module 'ExampleModule.slang', but it is implementing 'ExampleModule' instead.
__include a; // pulls in `a` to module `m`.
          ^
ExampleShader.slang(4): error 39999: import of module 'ExampleModule' failed because of a compilation error
import ExampleModule;
       ^~~~~~~~~~~~~
(0): fatal error 39999: compilation ceased

D:\testshaders\ShaderSlang_Module\ShaderSlangModule\ShaderSource>slangc ExampleShader.slang -target cpp -o ExampleShader.cpp
ExampleModule.slang(28): error 30502: the included source file is expected to implement module 'ExampleModule', but it is implementing 'ExampleModule.slang' instead.
__include "ModuleSource/UseFileExtension/b"; // Pulls in file c, specifying the full file name.
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ExampleModule.slang(29): error 30502: the included source file is expected to implement module 'ExampleModule', but it is implementing 'ExampleModule.slang' instead.
__include "ModuleSource/UseFileExtension/c.slang"; // Pulls in file c, specifying the full file name.
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ModuleSource/UseFileExtension/b.slang(9): error 30502: the included source file is expected to implement module 'ExampleModule', but it is implementing 'ExampleModule.slang' instead.
__include "a.slang";
          ^~~~~~~~~
ExampleShader.slang(4): error 39999: import of module 'ExampleModule' failed because of a compilation error
import ExampleModule;
       ^~~~~~~~~~~~~
(0): fatal error 39999: compilation ceased

D:\testshaders\ShaderSlang_Module\ShaderSlangModule\ShaderSource>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang
Projects
None yet
Development

No branches or pull requests

3 participants