@@ -313,6 +313,11 @@ pub enum StageError {
313
313
MultipleEntryPointsFound ,
314
314
#[ error( transparent) ]
315
315
InvalidResource ( #[ from] InvalidResourceError ) ,
316
+ #[ error(
317
+ "Location[{location}] {var}'s index exceeds `max_color_attachments` ({})" ,
318
+ hal:: MAX_COLOR_ATTACHMENTS
319
+ ) ]
320
+ ColorAttachmentLocationExceedsLimit { location : u32 , var : InterfaceVar } ,
316
321
}
317
322
318
323
impl WebGpuError for StageError {
@@ -334,7 +339,8 @@ impl WebGpuError for StageError {
334
339
| Self :: TooManyVaryings { .. }
335
340
| Self :: MissingEntryPoint ( ..)
336
341
| Self :: NoEntryPointFound
337
- | Self :: MultipleEntryPointsFound => return ErrorType :: Validation ,
342
+ | Self :: MultipleEntryPointsFound
343
+ | Self :: ColorAttachmentLocationExceedsLimit { .. } => return ErrorType :: Validation ,
338
344
} ;
339
345
e. webgpu_error_type ( )
340
346
}
@@ -1317,7 +1323,6 @@ impl Interface {
1317
1323
}
1318
1324
}
1319
1325
1320
- #[ expect( clippy:: single_match) ]
1321
1326
match shader_stage {
1322
1327
naga:: ShaderStage :: Vertex => {
1323
1328
for output in entry_point. outputs . iter ( ) {
@@ -1352,6 +1357,19 @@ impl Interface {
1352
1357
}
1353
1358
}
1354
1359
}
1360
+ naga:: ShaderStage :: Fragment => {
1361
+ for output in & entry_point. outputs {
1362
+ let & Varying :: Local { location, ref iv } = output else {
1363
+ continue ;
1364
+ } ;
1365
+ if location > self . limits . max_color_attachments {
1366
+ return Err ( StageError :: ColorAttachmentLocationExceedsLimit {
1367
+ location,
1368
+ var : iv. clone ( ) ,
1369
+ } ) ;
1370
+ }
1371
+ }
1372
+ }
1355
1373
_ => ( ) ,
1356
1374
}
1357
1375
@@ -1370,6 +1388,7 @@ impl Interface {
1370
1388
Varying :: BuiltIn ( _) => None ,
1371
1389
} )
1372
1390
. collect ( ) ;
1391
+
1373
1392
Ok ( outputs)
1374
1393
}
1375
1394
0 commit comments