@@ -14,7 +14,7 @@ use crate::auxil::dxgi::result::HResult;
14
14
pub ( super ) fn compile_fxc (
15
15
device : & super :: Device ,
16
16
source : & str ,
17
- source_name : & str ,
17
+ source_name : Option < & CStr > ,
18
18
raw_ep : & std:: ffi:: CString ,
19
19
stage_bit : wgt:: ShaderStages ,
20
20
full_stage : String ,
@@ -34,11 +34,7 @@ pub(super) fn compile_fxc(
34
34
}
35
35
36
36
// If no name has been set, D3DCompile wants the null pointer.
37
- let source_name = if source_name. is_empty ( ) {
38
- ptr:: null ( )
39
- } else {
40
- source_name. as_ptr ( )
41
- } ;
37
+ let source_name = source_name. map ( |cstr| cstr. as_ptr ( ) ) . unwrap_or ( ptr:: null ( ) ) ;
42
38
43
39
let mut error = d3d12:: Blob :: null ( ) ;
44
40
let hr = unsafe {
@@ -140,7 +136,7 @@ mod dxc {
140
136
pub ( crate ) fn compile_dxc (
141
137
device : & crate :: dx12:: Device ,
142
138
source : & str ,
143
- source_name : & str ,
139
+ source_name : Option < & CStr > ,
144
140
raw_ep : & str ,
145
141
stage_bit : wgt:: ShaderStages ,
146
142
full_stage : String ,
@@ -174,6 +170,8 @@ mod dxc {
174
170
Err ( e) => return ( Err ( e) , log:: Level :: Error ) ,
175
171
} ;
176
172
173
+ let source_name = source_name. map ( |cstr| cstr. to_str ( ) ) . unwrap_or ( & "" ) ;
174
+
177
175
let compiled = dxc_container. compiler . compile (
178
176
& blob,
179
177
source_name,
0 commit comments