@@ -293,74 +293,14 @@ pub fn check_fragment_insts(sess: &Session, module: &Module) -> super::Result<()
293
293
}
294
294
}
295
295
296
- /// Check that types requiring specific capabilities have those capabilities declared.
297
- ///
298
- /// This function validates that if a module uses types like u8/i8 (requiring Int8),
299
- /// u16/i16 (requiring Int16), etc., the corresponding capabilities are declared.
300
- pub fn check_type_capabilities ( sess : & Session , module : & Module ) -> super :: Result < ( ) > {
301
- use rspirv:: spirv:: Capability ;
302
-
303
- // Collect declared capabilities
304
- let declared_capabilities: FxHashSet < Capability > = module
305
- . capabilities
306
- . iter ( )
307
- . map ( |inst| inst. operands [ 0 ] . unwrap_capability ( ) )
308
- . collect ( ) ;
309
-
310
- let mut missing_caps = vec ! [ ] ;
311
-
312
- for inst in & module. types_global_values {
313
- let ( prefix, width, maybe_required_cap) = match inst. class . opcode {
314
- Op :: TypeInt => {
315
- let width = inst. operands [ 0 ] . unwrap_literal_bit32 ( ) ;
316
- let signed = inst. operands [ 1 ] . unwrap_literal_bit32 ( ) != 0 ;
317
-
318
- (
319
- if signed { "i" } else { "u" } ,
320
- width,
321
- capability_for_int_width ( width) ,
322
- )
323
- }
324
- Op :: TypeFloat => {
325
- let width = inst. operands [ 0 ] . unwrap_literal_bit32 ( ) ;
326
-
327
- ( "f" , width, capability_for_float_width ( width) )
328
- }
329
- _ => continue ,
330
- } ;
331
-
332
- match maybe_required_cap {
333
- Err ( UnsupportedType ) => {
334
- sess. dcx ( )
335
- . err ( format ! ( "`{prefix}{width}` unsupported in SPIR-V" ) ) ;
336
- }
337
- Ok ( Some ( required_cap) ) if !declared_capabilities. contains ( & required_cap) => {
338
- missing_caps. push ( format ! (
339
- "`{prefix}{width}` type used without `OpCapability {required_cap:?}`"
340
- ) ) ;
341
- }
342
- Ok ( _) => { }
343
- }
344
- }
345
-
346
- if !missing_caps. is_empty ( ) {
347
- let mut err = sess
348
- . dcx ( )
349
- . struct_err ( "missing required capabilities for types" ) ;
350
- for msg in missing_caps {
351
- err. note ( msg) ;
352
- }
353
- Err ( err. emit ( ) )
354
- } else {
355
- Ok ( ( ) )
356
- }
357
- }
358
-
359
296
/// Remove type-related capabilities that are not required by any types in the module.
360
297
///
361
298
/// This function specifically targets Int8, Int16, Int64, Float16, and Float64 capabilities,
362
299
/// removing them if no types in the module require them. All other capabilities are preserved.
363
300
/// This is part of the fix for issue #300 where constant casts were creating unnecessary types.
301
+ //
302
+ // FIXME(eddyb) move this to a SPIR-T pass (potentially even using sets of used
303
+ // exts/caps that validation itself can collect while traversing the module).
364
304
pub fn remove_unused_type_capabilities ( module : & mut Module ) {
365
305
use rspirv:: spirv:: Capability ;
366
306
0 commit comments