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

DirectX is required to compile to SPIR-V #111

Closed
sutbult opened this issue Mar 1, 2025 · 4 comments
Closed

DirectX is required to compile to SPIR-V #111

sutbult opened this issue Mar 1, 2025 · 4 comments

Comments

@sutbult
Copy link

sutbult commented Mar 1, 2025

I built SDL_shadercross locally using this command:

cmake -B build -DSDLSHADERCROSS_DXC=OFF -DSDLSHADERCROSS_INSTALL=ON -DSDLSHADERCROSS_SHARED=ON

As you can see, I disabled DXC as I in this early stage of development of the project I am working on, I am only interested in compiling my program on Linux and running SDL_GPU with the Vulkan backend.

I have this function:

SDL_GPUShader* compileShader(SDL_GPUDevice* device) {
    SDL_ShaderCross_HLSL_Info info = {0};
    SDL_ShaderCross_GraphicsShaderMetadata metadata = {0};

    SDL_GPUShader *vertexShader = SDL_ShaderCross_CompileGraphicsShaderFromHLSL(
        device,
        &info,
        &metadata);

    if(vertexShader == NULL) {
        fprintf(
            stderr,
            "SDL_ShaderCross_CompileGraphicsShaderFromHLSL failed: %s\n",
            SDL_GetError());
        return NULL;
    }

    return vertexShader;
}

When the function is called, I get this output:

SDL_ShaderCross_CompileGraphicsShaderFromHLSL failed: Shadercross was not built with DXC support, cannot compile using DXC!

I would expect something like "Your source is null" instead.

I also tried this:

shadercross triangle.vert.hlsl -o triangle.vert.spv

Then I got this result:

ERROR: Failed to compile SPIR-V From HLSL: Shadercross was not built with DXC support, cannot compile using DXC!

So it seems like the command line tool has the same problem.

@thatcosmonaut
Copy link
Collaborator

Not really sure how you expect to compile HLSL to SPIR-V without DXC, the compiler that compiles HLSL to SPIR-V.

@thatcosmonaut thatcosmonaut closed this as not planned Won't fix, can't repro, duplicate, stale Mar 1, 2025
@sutbult
Copy link
Author

sutbult commented Mar 1, 2025

Okay, it just seems kind of counter-intuitive to require something related to DirectX to compile shader code for Vulkan.

@thatcosmonaut
Copy link
Collaborator

You could always use GLSL and a compiler like glslc to produce SPIR-V. You aren't required to use HLSL or SDL_shadercross.

@sutbult
Copy link
Author

sutbult commented Mar 1, 2025

You could always use GLSL and a compiler like glslc to produce SPIR-V. You aren't required to use HLSL or SDL_shadercross.

That's a good point. However, I solved it by running the command-line tool through Docker.

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

2 participants