Skip to content

Validation of inter-stage variable counts does not match the spec #5577

@Imberflur

Description

@Imberflur

https://gpuweb.github.io/gpuweb/#abstract-opdef-validating-inter-stage-interfaces

I noticed a few inconsistencies with the spec when reading through the interface validation code in wgpu-core.

  • User-defined variables all count as 4 components towards the limit (not what ty.dim.num_components() returns).

    Each user-defined output of descriptor.vertex consumes 4 scalar components.

    For each user-defined input of descriptor.fragment there must be a user-defined output of descriptor.vertex that location, type, and interpolation of the input.

  • If the topology is "point-list" the component limit for vertex outputs needs to be reduced by 1.

    If descriptor.primitive.topology is "point-list":

    Decrement maxVertexShaderOutputComponents by 1.

  • For fragment inputs, the front_facing, sample_index, and sample_mask builtins all count as 1 component towards the limit.

  • There is now a maxInterStageShaderVariables (also mentioned in Further spec compliance #2170):

    The location of each user-defined output of descriptor.vertex must be < device.limits.maxInterStageShaderVariables.


I also had a couple questions on things aren't necessarily issues but weren't obvious to me when reading the code:

  • At the point where validation is done:
    Varying::Local { ref iv, .. } => iv.ty.dim.num_components(),
    are all Varying::Local variables "user-defined"? (in terms of how the spec uses "user-defined")
  • (Now tracked by Validation of inter-stage variable types does not match the spec #9143): Matching types between stages is checked via frag_input_ty.is_subtype_of(vert_output_ty) (here). E.g. for a particular location this would allow vec4<f32> on the vertex side and f32 on the fragment side. Whether this is allowed isn't clear to me when looking at the line in the spec:

    For each user-defined input of descriptor.fragment there must be a user-defined output of descriptor.vertex that location, type, and interpolation of the input.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: validationIssues related to validation, diagnostics, and error handling

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions