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

WGSL: Nested structures are not allowed for entry point IO #5226

Open
aleino-nv opened this issue Oct 4, 2024 · 3 comments
Open

WGSL: Nested structures are not allowed for entry point IO #5226

aleino-nv opened this issue Oct 4, 2024 · 3 comments
Assignees
Labels
goal:forward looking Feature needed at a later date, not connected to a specific use case. kind:enhancement a desirable new feature, option, or behavior

Comments

@aleino-nv
Copy link
Collaborator

This issue was split from #5173.

Affected tests under tests/compute (currently excluded):

  1. compile-time-loop

Output from slang-test, for compile-time-loop:

...
WGPU error: Error while parsing WGSL: :38:6 error: nested structures cannot be used for entry point IO
     assembledVertex_0 : AssembledVertex_0,
     ^^^^^^^^^^^^^^^^^

:42:1 note: while analyzing entry point 'vertexMain'
fn vertexMain( input_0 : VertexStageInput_0) -> VertexStageOutput_0
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
{
^
    var output_0 : VertexStageOutput_0;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    output_0.coarseVertex_0.color_0 = input_0.assembledVertex_0.color_1;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
var _S2 : vec4<f32> = (((vec4<f32>(input_0.assembledVertex_0.position_0, 1.0f)) * (unpackStorage_0(Uniforms_0.modelViewProjection_0))));
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    output_0.sv_position_0 = _S2;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    output_0.coarseVertex_0.uv_0 = input_0.assembledVertex_0.uv_1;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    return output_0;
^^^^^^^^^^^^^^^^^^^^
}
^


 - While validating [ShaderModuleDescriptor]
 - While calling [Device].CreateShaderModule([ShaderModuleDescriptor]).
...

Generated WGSL for slangc -o test.wgsl -target wgsl -stage vertex -entry vertexMain %SLANG_SRC%\tests\compute\compile-time-loop.slang:

...
struct AssembledVertex_0
{
     position_0 : vec3<f32>,
     color_1 : vec3<f32>,
     uv_1 : vec2<f32>,
};

struct VertexStageInput_0
{
     assembledVertex_0 : AssembledVertex_0,
};

@vertex
fn vertexMain( input_0 : VertexStageInput_0) -> VertexStageOutput_0
{
    var output_0 : VertexStageOutput_0;
    output_0.coarseVertex_0.color_0 = input_0.assembledVertex_0.color_1;
    output_0.sv_position_0 = (((vec4<f32>(input_0.assembledVertex_0.position_0, 1.0f)) * (unpackStorage_0(Uniforms_0.modelViewProjection_0))));
    output_0.coarseVertex_0.uv_0 = input_0.assembledVertex_0.uv_1;
    return output_0;
}
...
@aleino-nv
Copy link
Collaborator Author

@csyonghe The GLSL output seems to get rid of this kind of nesting. Does a similar restriction apply to GLSL?

@aleino-nv
Copy link
Collaborator Author

I think I found he passage that forbids nesting of input structures
in the section on entry point declarations (https://www.w3.org/TR/WGSL/#entry-point-decl):

"The type of each formal parameter, and the entry point’s return type, must be one of: ... a structure whose member types are any of bool, numeric scalar, or numeric vector. ..."

@aleino-nv
Copy link
Collaborator Author

Maybe we can re-use the same legalization pass that's used for GLSL to fix this WGSL issue.

@aleino-nv aleino-nv self-assigned this Oct 4, 2024
@aleino-nv aleino-nv added kind:enhancement a desirable new feature, option, or behavior goal:forward looking Feature needed at a later date, not connected to a specific use case. labels Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
goal:forward looking Feature needed at a later date, not connected to a specific use case. kind:enhancement a desirable new feature, option, or behavior
Projects
None yet
Development

No branches or pull requests

1 participant