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

A Struct only ParameterBlock's usage in stage is not reported correctly #5940

Closed
jjiangweilan opened this issue Dec 26, 2024 · 0 comments · Fixed by #5956
Closed

A Struct only ParameterBlock's usage in stage is not reported correctly #5940

jjiangweilan opened this issue Dec 26, 2024 · 0 comments · Fixed by #5956
Assignees
Labels
goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang

Comments

@jjiangweilan
Copy link

jjiangweilan commented Dec 26, 2024

Tested using the following code. material in set 0 binding 0 is not reported in use in any stage

// raster-simple.slang

struct AssembledVertex
{
    float3 position : POSITION;
    float3 normal   : NORMAL;
    float2 uv       : TEXCOORD;
};

struct RasterVertex
{
    float3 worldPosition;
    float3 worldNormal;
    float2 uv;
};

struct Model
{
    float3x4 modelToWorld;
    float3x4 modelToWorld_inverseTranspose;
}

struct Material
{
    float2 uvScale;
    float2 uvBias;
}

struct Camera
{
    float3x4 worldToView;
    float3x4 worldToView_inverseTranspose;

    float4x4 viewToProj;
}

struct DirectionalLight
{
    float3 intensity;
    float3 direction;
}

struct Environment
{
    TextureCube environmentMap;
    DirectionalLight light;
}

uniform ParameterBlock<Material>    material;
uniform ParameterBlock<Camera>    camera;

[shader("vertex")]
[require(sm_6_0)]
void vertexMain(
    in AssembledVertex assembledVertex : A,
    out RasterVertex rasterVertex : R,
    in uint vertexID : SV_VertexID,
    out float4 projPosition :  SV_Position)
{
    float3 worldPosition = float3(1,1,1);

    rasterVertex.worldPosition = worldPosition;
    rasterVertex.worldNormal = float3(1,1,1);
    rasterVertex.uv = assembledVertex.uv;

    float3 viewPosition = mul(camera.worldToView, float4(worldPosition,1));
    projPosition = mul(camera.viewToProj, float4(viewPosition,1));
}

[shader("fragment")]
[require(sm_6_0)]
float4 fragmentMain(
    in RasterVertex vertex : R)
    : SV_Target0
{
    float3 normal = vertex.worldNormal;

    float3 albedo = float3(vertex.uv * material.uvScale, 1);

    float3 color = albedo * max(0, dot(normal, float3(1,1,1))) * camera.worldToView[0][0];
    return float4(color, 1);
}

@csyonghe csyonghe added the goal:quality & productivity Quality issues and issues that impact our productivity coding day to day inside slang label Dec 29, 2024
@csyonghe csyonghe added this to the Q4 2024 (Fall) milestone Dec 29, 2024
@csyonghe csyonghe self-assigned this Dec 29, 2024
csyonghe added a commit to csyonghe/slang that referenced this issue Jan 3, 2025
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

Successfully merging a pull request may close this issue.

2 participants