File tree Expand file tree Collapse file tree 7 files changed +13
-30
lines changed
rustc_codegen_spirv-target-specs/src
tests/difftests/lib/src/scaffold/compute Expand file tree Collapse file tree 7 files changed +13
-30
lines changed Original file line number Diff line number Diff line change @@ -109,22 +109,6 @@ impl SpirvTargetEnv {
109
109
}
110
110
}
111
111
112
- pub trait IntoSpirvTarget : Sized {
113
- fn to_spirv_target_env ( & self ) -> Result < SpirvTargetEnv , SpirvTargetParseError > ;
114
- }
115
-
116
- impl IntoSpirvTarget for SpirvTargetEnv {
117
- fn to_spirv_target_env ( & self ) -> Result < SpirvTargetEnv , SpirvTargetParseError > {
118
- Ok ( * self )
119
- }
120
- }
121
-
122
- impl IntoSpirvTarget for & str {
123
- fn to_spirv_target_env ( & self ) -> Result < SpirvTargetEnv , SpirvTargetParseError > {
124
- SpirvTargetEnv :: parse_triple ( self )
125
- }
126
- }
127
-
128
112
#[ cfg( test) ]
129
113
mod tests {
130
114
use super :: * ;
Original file line number Diff line number Diff line change @@ -90,9 +90,7 @@ use std::path::{Path, PathBuf};
90
90
use std:: process:: { Command , Stdio } ;
91
91
use thiserror:: Error ;
92
92
93
- pub use rustc_codegen_spirv_target_specs:: {
94
- IntoSpirvTarget , SpirvTargetEnv , SpirvTargetParseError ,
95
- } ;
93
+ pub use rustc_codegen_spirv_target_specs:: { SpirvTargetEnv , SpirvTargetParseError } ;
96
94
pub use rustc_codegen_spirv_types:: * ;
97
95
98
96
#[ cfg( feature = "include-target-specs" ) ]
@@ -492,10 +490,10 @@ impl Default for SpirvBuilder {
492
490
}
493
491
494
492
impl SpirvBuilder {
495
- pub fn new ( path_to_crate : impl AsRef < Path > , target : impl IntoSpirvTarget ) -> Self {
493
+ pub fn new ( path_to_crate : impl AsRef < Path > , target : SpirvTargetEnv ) -> Self {
496
494
Self {
497
495
path_to_crate : Some ( path_to_crate. as_ref ( ) . to_owned ( ) ) ,
498
- target : target . to_spirv_target_env ( ) . ok ( ) ,
496
+ target : Some ( target ) ,
499
497
..SpirvBuilder :: default ( )
500
498
}
501
499
}
Original file line number Diff line number Diff line change 1
- use spirv_builder:: { MetadataPrintout , SpirvBuilder } ;
1
+ use spirv_builder:: { MetadataPrintout , SpirvBuilder , SpirvTargetEnv } ;
2
2
3
3
fn main ( ) {
4
4
let result = SpirvBuilder :: new (
5
5
concat ! ( env!( "CARGO_MANIFEST_DIR" ) , "/../shaders/sky-shader" ) ,
6
- "spirv-unknown-spv1.3" ,
6
+ SpirvTargetEnv :: Vulkan_1_3 ,
7
7
)
8
8
. print_metadata ( MetadataPrintout :: DependencyOnly )
9
9
. multimodule ( true )
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ use std::{
91
91
92
92
use clap:: Parser ;
93
93
94
- use spirv_builder:: { MetadataPrintout , SpirvBuilder } ;
94
+ use spirv_builder:: { MetadataPrintout , SpirvBuilder , SpirvTargetEnv } ;
95
95
96
96
use shared:: ShaderConstants ;
97
97
@@ -247,7 +247,7 @@ pub fn compile_shaders() -> Vec<SpvFile> {
247
247
248
248
SpirvBuilder :: new (
249
249
concat ! ( env!( "CARGO_MANIFEST_DIR" ) , "/../../shaders/sky-shader" ) ,
250
- "spirv-unknown-vulkan1.1" ,
250
+ SpirvTargetEnv :: Vulkan_1_1 ,
251
251
)
252
252
. print_metadata ( MetadataPrintout :: None )
253
253
. shader_panic_strategy ( spirv_builder:: ShaderPanicStrategy :: DebugPrintfThenExit {
Original file line number Diff line number Diff line change 1
- use spirv_builder:: { MetadataPrintout , SpirvBuilder } ;
1
+ use spirv_builder:: { MetadataPrintout , SpirvBuilder , SpirvTargetEnv } ;
2
2
use std:: env;
3
3
use std:: error:: Error ;
4
4
use std:: fs;
@@ -7,7 +7,7 @@ use std::path::Path;
7
7
fn build_shader ( path_to_crate : & str , codegen_names : bool ) -> Result < ( ) , Box < dyn Error > > {
8
8
let builder_dir = & Path :: new ( env ! ( "CARGO_MANIFEST_DIR" ) ) ;
9
9
let path_to_crate = builder_dir. join ( path_to_crate) ;
10
- let result = SpirvBuilder :: new ( path_to_crate, "spirv-unknown-vulkan1.1" )
10
+ let result = SpirvBuilder :: new ( path_to_crate, SpirvTargetEnv :: Vulkan_1_1 )
11
11
. print_metadata ( MetadataPrintout :: Full )
12
12
. build ( ) ?;
13
13
if codegen_names {
Original file line number Diff line number Diff line change 73
73
74
74
use clap:: Parser ;
75
75
use clap:: ValueEnum ;
76
+ use spirv_builder:: SpirvTargetEnv ;
76
77
use std:: borrow:: Cow ;
77
78
use strum:: { Display , EnumString } ;
78
79
@@ -152,7 +153,7 @@ fn maybe_watch(
152
153
153
154
let has_debug_printf = options. force_spirv_passthru ;
154
155
155
- let builder = SpirvBuilder :: new ( crate_path, "spirv-unknown-vulkan1.1" )
156
+ let builder = SpirvBuilder :: new ( crate_path, SpirvTargetEnv :: Vulkan_1_1 )
156
157
. print_metadata ( MetadataPrintout :: None )
157
158
. shader_panic_strategy ( if has_debug_printf {
158
159
spirv_builder:: ShaderPanicStrategy :: DebugPrintfThenExit {
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ use crate::config::Config;
2
2
use anyhow:: Context ;
3
3
use bytemuck:: Pod ;
4
4
use futures:: executor:: block_on;
5
- use spirv_builder:: { ModuleResult , SpirvBuilder } ;
5
+ use spirv_builder:: { ModuleResult , SpirvBuilder , SpirvTargetEnv } ;
6
6
use std:: {
7
7
borrow:: Cow ,
8
8
env,
@@ -36,7 +36,7 @@ impl ComputeShader for RustComputeShader {
36
36
& self ,
37
37
device : & wgpu:: Device ,
38
38
) -> anyhow:: Result < ( wgpu:: ShaderModule , Option < String > ) > {
39
- let builder = SpirvBuilder :: new ( & self . path , "spirv-unknown-vulkan1.1" )
39
+ let builder = SpirvBuilder :: new ( & self . path , SpirvTargetEnv :: Vulkan_1_2 )
40
40
. print_metadata ( spirv_builder:: MetadataPrintout :: None )
41
41
. release ( true )
42
42
. multimodule ( false )
You can’t perform that action at this time.
0 commit comments