Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/platform/graphics/webgpu/webgpu-shader-processor-wgsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const KEYWORD_RESOURCE = /^[ \t]*var\s*(?:(<storage,[^>]*>)\s*([\w\d_]+)\s*:\s*(

// match varying name from string like: '@interpolate(perspective, centroid) smoothColor : vec3f;'
// eslint-disable-next-line
const VARYING = /(?:@interpolate\([^)]*\)\s*)?([\w]+)\s*:/;
const VARYING = /(?:@interpolate\([^)]*\)\s*)?([\w]+)\s*:\s*([\w<>]+)/;
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex pattern [\w<>]+ for capturing the type is too permissive and will not correctly handle nested generic types or array types with dimensions (e.g., vec3<f32> or array<vec4<f32>, 4>). Consider using a more robust pattern like [\w<>,\s\d]+ to properly capture complex type syntax including spaces, commas, and numbers in type parameters.

Suggested change
const VARYING = /(?:@interpolate\([^)]*\)\s*)?([\w]+)\s*:\s*([\w<>]+)/;
const VARYING = /(?:@interpolate\([^)]*\)\s*)?([\w]+)\s*:\s*([\w<>,\s\d]+)/;

Copilot uses AI. Check for mistakes.

// marker for a place in the source code to be replaced by code
const MARKER = '@@@';
Expand Down Expand Up @@ -711,6 +711,7 @@ class WebgpuShaderProcessorWGSL {

if (match) {
const name = match[1];
const type = match[2];

if (isVertex) {
// store it in the map
Expand All @@ -727,7 +728,7 @@ class WebgpuShaderProcessorWGSL {
if (!isVertex) {

// private global variable for fragment varying
blockPrivates += ` var<private> ${line};\n`;
blockPrivates += ` var<private> ${name}: ${type};\n`;

// copy input variable to the private variable
blockCopy += ` ${name} = input.${name};\n`;
Expand Down