@@ -124,6 +124,29 @@ impl BuiltInResources {
124
124
}
125
125
}
126
126
127
+ pub type CompileOptions = ShCompileOptions ;
128
+
129
+ impl CompileOptions {
130
+ fn mozangle ( ) -> Self {
131
+ let mut options = unsafe { CompileOptions :: new ( ) } ;
132
+ options. set_validateLoopIndexing ( 1 ) ; // SH_VALIDATE
133
+ options. set_objectCode ( 1 ) ;
134
+ options. set_variables ( 1 ) ; // For uniform_name_map()
135
+ options. set_emulateAbsIntFunction ( 1 ) ; // To workaround drivers
136
+ options. set_emulateIsnanFloatFunction ( 1 ) ; // To workaround drivers
137
+ options. set_emulateAtan2FloatFunction ( 1 ) ; // To workaround drivers
138
+ options. set_clampIndirectArrayBounds ( 1 ) ;
139
+ options. set_initGLPosition ( 1 ) ;
140
+ options. set_enforcePackingRestrictions ( 1 ) ;
141
+ options. set_limitExpressionComplexity ( 1 ) ;
142
+ options. set_limitCallStackDepth ( 1 ) ;
143
+ // Todo(Mortimer): Add SH_TIMING_RESTRICTIONS to options when the implementations gets better
144
+ // Right now SH_TIMING_RESTRICTIONS is experimental
145
+ // and doesn't support user callable functions in shaders
146
+ options
147
+ }
148
+ }
149
+
127
150
pub struct ShaderValidator {
128
151
handle : ShHandle ,
129
152
}
@@ -213,26 +236,7 @@ impl ShaderValidator {
213
236
}
214
237
215
238
pub fn compile_and_translate ( & self , strings : & [ & str ] ) -> Result < String , & ' static str > {
216
- // TODO: make this selection smarter
217
- let options = unsafe {
218
- let mut options = ShCompileOptions :: new ( ) ;
219
- options. set_validateLoopIndexing ( 1 ) ; // SH_VALIDATE
220
- options. set_objectCode ( 1 ) ;
221
- options. set_variables ( 1 ) ; // For uniform_name_map()
222
- options. set_emulateAbsIntFunction ( 1 ) ; // To workaround drivers
223
- options. set_emulateIsnanFloatFunction ( 1 ) ; // To workaround drivers
224
- options. set_emulateAtan2FloatFunction ( 1 ) ; // To workaround drivers
225
- options. set_clampIndirectArrayBounds ( 1 ) ;
226
- options. set_initGLPosition ( 1 ) ;
227
- options. set_enforcePackingRestrictions ( 1 ) ;
228
- options. set_limitExpressionComplexity ( 1 ) ;
229
- options. set_limitCallStackDepth ( 1 ) ;
230
- options
231
- } ;
232
- // Todo(Mortimer): Add SH_TIMING_RESTRICTIONS to options when the implementations gets better
233
- // Right now SH_TIMING_RESTRICTIONS is experimental
234
- // and doesn't support user callable functions in shaders
235
-
239
+ let options = CompileOptions :: mozangle ( ) ;
236
240
self . compile ( strings, options) ?;
237
241
Ok ( self . object_code ( ) )
238
242
}
0 commit comments