Skip to content

Javascript and WGSL #113

Closed Answered by greggman
Atticus-X asked this question in Q&A
Discussion options

You must be logged in to vote

WebGPU-'s function createShaderModule takes a template literal and not a string.

This might be one of those semantic things but WebGPU only takes strings. From the spec

dictionary GPUShaderModuleDescriptor : GPUObjectDescriptorBase {
  required USVString code;       <========---------- string
  ....
};

A template literal generates a string

const a = 'foo';
const b = `foo`;
const c = 'f' + 'oo';
const d = `f${'oo'}`;
const x = 'oo';
const e = `f${x}`;

a, b, c, d, and e are exact the same. They are all a string with the contents 'foo'

As for doing things like includes, preprocessing is explicitly out of scope. The topic is complex and the solution is to provide your own preprocessor w…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Atticus-X
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants