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

Invalid warning when using Sampler2D, generating GLSL code #5429

Closed
Ollhax opened this issue Oct 29, 2024 · 2 comments
Closed

Invalid warning when using Sampler2D, generating GLSL code #5429

Ollhax opened this issue Oct 29, 2024 · 2 comments
Assignees
Labels
goal:client support Feature or fix needed for a current slang user.

Comments

@Ollhax
Copy link

Ollhax commented Oct 29, 2024

I'm trying to compile slang to GLSL via the commandline and I'm getting a warning that I can't make sense of:

1>shaders.slang(40): warning 41012: entry point 'fragmentMain' uses additional capabilities that are not part of the specified profile 'glsl_450'. The profile setting is automatically updated to include these capabilities: 'GL_EXT_texture_query_lod + GL_ARB_sparse_texture_clamp'
1>float4 fragmentMain(CoarseVertex coarseVertex : CoarseVertex) : SV_Target
1>       ^~~~~~~~~~~~

Command line arguments:

SlangC\slangc.exe shaders.slang -profile glsl_450 -target glsl -o $(ProjectDir)shaders.frag -entry fragmentMain

shaders.slang:

Sampler2D sampler;

struct AssembledVertex
{
    float3	position : POSITION;
    float3	color    : COLOR;
    float2	uv       : UV;
};

struct CoarseVertex
{
    float3 color;
    float2 uv;
};

struct VertexStageOutput
{
    CoarseVertex    coarseVertex    : CoarseVertex;
    float4          sv_position     : SV_Position;
};

[shader("vertex")]
VertexStageOutput vertexMain(
    AssembledVertex assembledVertex)
{
    VertexStageOutput output;

    float3 position = assembledVertex.position;
    float3 color    = assembledVertex.color;
    float2 uv       = assembledVertex.uv;

    output.coarseVertex.color = color;
    output.coarseVertex.uv = uv;
    output.sv_position = float4(position, 1.0);

    return output;
}

[shader("fragment")]
float4 fragmentMain(CoarseVertex coarseVertex : CoarseVertex) : SV_Target
{
    return sampler.Sample(coarseVertex.uv);
}

The generated shaders.frag:

#version 450
layout(row_major) uniform;
layout(row_major) buffer;

#line 1 0
layout(binding = 0)
uniform sampler2D sampler_0;


#line 4368 1
layout(location = 0)
out vec4 entryPointParam_fragmentMain_0;


#line 4368
layout(location = 1)
in vec2 coarseVertex_uv_0;


#line 40 0
void main()
{

#line 40
    entryPointParam_fragmentMain_0 = (texture((sampler_0), (coarseVertex_uv_0)));

#line 40
    return;
}

Both my GLSL and slang is a bit rusty, but it looks basic to me. Why would I need the extensions GL_EXT_texture_query_lod and GL_ARB_sparse_texture_clamp here?

@csyonghe
Copy link
Collaborator

To get rid of the warning, remove -profile glsl_450 in your commandline to slangc. If you specified a profile, slang will try to verify you don't use anything not covered by glsl_450 profile. And it seems that the capability definition for texture.Sample method isn't correct.

@bmillsNV bmillsNV added the goal:client support Feature or fix needed for a current slang user. label Oct 31, 2024
@bmillsNV bmillsNV added this to the Q4 2024 (Fall) milestone Oct 31, 2024
@csyonghe
Copy link
Collaborator

csyonghe commented Nov 4, 2024

This is already fixed in tot. No more warnings for the Sample call when specifying glsl_450 profile. Closing.

@csyonghe csyonghe closed this as completed Nov 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
goal:client support Feature or fix needed for a current slang user.
Projects
None yet
Development

No branches or pull requests

3 participants