Skip to content

Conversation

@mvaligursky
Copy link
Contributor

@mvaligursky mvaligursky commented May 9, 2025

This PR is breaking on in the rare case you were using pc.createShader.

Changes:

  1. REMOVED pc.createShader function, which was very rarely if ever used. The newly provided function can be used instead.
  2. DEPRECATED 'pc.createShaderFromCode' function. It can still be used, but logs a deprecated warning in debug build.
  3. NEW REPLACEMENT functionality: 'ShaderUtils.createShader'

NEW API

// create a shader, supports both GLSL and WGSL
static ShaderUtils.createShader(device, options);

// parameters
- device – The graphics device.
- options – Object for optional arguments.
- options.uniqueName – Unique shader name; reused if already existing.
- options.attributes – Maps vertex shader attributes to semantics.
- options.useTransformFeedback – Enables transform feedback (WebGL only, default false).
- options.vertexGLSL – Vertex shader code in GLSL.
- options.vertexWGSL – Vertex shader code in WGSL.
- options.vertexIncludes – Includes for resolving #include in vertex shader.
- options.vertexDefines – Defines for resolving #ifdef in vertex shader.
- options.fragmentGLSL – Fragment shader code in GLSL.
- options.fragmentWGSL – Fragment shader code in WGSL.
- options.fragmentIncludes – Includes for resolving #include in fragment shader.
- options.fragmentDefines – Defines for resolving #ifdef in fragment shader.
- options.fragmentOutputTypes – Fragment output types, defaults to vec4.

- returns: Shader

@mvaligursky mvaligursky self-assigned this May 9, 2025
@mvaligursky mvaligursky added enhancement Request for a new feature area: graphics Graphics related issue labels May 9, 2025
@mvaligursky mvaligursky requested a review from a team May 9, 2025 09:48
@slimbuck
Copy link
Member

slimbuck commented May 9, 2025

How can it be rare when so many examples do it?!

@slimbuck
Copy link
Member

slimbuck commented May 9, 2025

How can it be rare when so many examples do it?!

Oh I see they were using createShaderFromCode! :D

@mvaligursky mvaligursky requested a review from slimbuck May 9, 2025 14:03
@mvaligursky mvaligursky merged commit 16bd562 into main May 9, 2025
1 check passed
@mvaligursky mvaligursky deleted the mv-createshader branch May 9, 2025 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: graphics Graphics related issue enhancement Request for a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants