Skip to content

shader,validation,expression,call,builtin,clamp:low_high:* appear invalid for override expression #4588

@mwyrzykowski

Description

@mwyrzykowski

The WGSL specification says 8.1.2:

Otherwise, an override-expression E will be evaluated if and only if:

E forms part of the shader for the entry point specified by the GPUProgrammableStage, and:
Any of the following are true:

However the source for this test

onst wgsl = `
${enable}
override o_low : ${scalar};
override o_high : ${scalar};
fn foo() {
  var v_low : ${t.params.type};
  var v_high : ${t.params.type};
  var v : ${t.params.type};
  let tmp = clamp(v, ${low_arg}, ${high_arg});
}`;
    const error = t.params.low > t.params.high;
    const shader_error =
      error && t.params.lowStage === 'constant' && t.params.highStage === 'constant';
    const pipeline_error =
      t.params.in_shader &&
      error &&
      t.params.lowStage !== 'runtime' &&
      t.params.highStage !== 'runtime';
    t.expectCompileResult(!shader_error, wgsl);
    if (!shader_error) {
      const constants: Record<string, number> = {};
      constants['o_low'] = t.params.low;
      constants['o_high'] = t.params.high;
      t.expectPipelineResult({
        expectedResult: !pipeline_error,
        code: wgsl,
        constants,
        reference: ['o_low', 'o_high'],
        statements: t.params.in_shader ? ['foo();'] : [],
      });
    }

and then checking the definition of expectPipelineResult:

const code =
      args.code +
      (args.addWorkgroupSize !== false
        ? `
@workgroup_size(1)`
        : ``) +
      `
      @compute fn main() {
  ${phonies.join('\n')}
}

I.e., foo is not an entry point as defined in the specification:

To create an entry point, declare a user-defined function with a shader stage attribute.

but rather main is

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions