@@ -120,7 +120,7 @@ impl RenderContext {
120
120
device : Arc < wgpu:: Device > ,
121
121
queue : Arc < wgpu:: Queue > ,
122
122
config : RenderContextConfig ,
123
- ) -> Self {
123
+ ) -> Result < Self , String > {
124
124
re_tracing:: profile_function!( ) ;
125
125
126
126
let frame_index_for_uncaptured_errors = Arc :: new ( AtomicU64 :: new ( STARTUP_FRAME_IDX ) ) ;
@@ -155,38 +155,46 @@ impl RenderContext {
155
155
let global_bindings = GlobalBindings :: new ( & gpu_resources, & device) ;
156
156
157
157
// Validate capabilities of the device.
158
- assert ! (
159
- config. device_caps. limits( ) . check_limits( & device. limits( ) ) ,
160
- "The given device doesn't support the required limits for the given hardware caps {:?}.
161
- Required:
162
- {:?}
163
- Actual:
164
- {:?}" ,
165
- config. device_caps,
166
- config. device_caps. limits( ) ,
167
- device. limits( ) ,
168
- ) ;
169
- assert ! (
170
- device. features( ) . contains( config. device_caps. features( ) ) ,
171
- "The given device doesn't support the required features for the given hardware caps {:?}.
172
- Required:
173
- {:?}
174
- Actual:
175
- {:?}" ,
176
- config. device_caps,
177
- config. device_caps. features( ) ,
178
- device. features( ) ,
179
- ) ;
180
- assert ! ( adapter. get_downlevel_capabilities( ) . flags. contains( config. device_caps. required_downlevel_capabilities( ) . flags) ,
181
- "The given device doesn't support the required downlevel capabilities for the given hardware caps {:?}.
182
- Required:
183
- {:?}
184
- Actual:
185
- {:?}" ,
186
- config. device_caps,
187
- config. device_caps. required_downlevel_capabilities( ) ,
188
- adapter. get_downlevel_capabilities( ) ,
189
- ) ;
158
+ if !config. device_caps . limits ( ) . check_limits ( & device. limits ( ) ) {
159
+ return Err ( format ! (
160
+ "The given device doesn't support the required limits for the given hardware caps {:?}.
161
+ Required:
162
+ {:?}
163
+ Actual:
164
+ {:?}" ,
165
+ config. device_caps,
166
+ config. device_caps. limits( ) ,
167
+ device. limits( ) ,
168
+ ) ) ;
169
+ }
170
+ if !device. features ( ) . contains ( config. device_caps . features ( ) ) {
171
+ return Err ( format ! (
172
+ "The given device doesn't support the required features for the given hardware caps {:?}.
173
+ Required:
174
+ {:?}
175
+ Actual:
176
+ {:?}" ,
177
+ config. device_caps,
178
+ config. device_caps. features( ) ,
179
+ device. features( ) ,
180
+ ) ) ;
181
+ }
182
+ if !adapter
183
+ . get_downlevel_capabilities ( )
184
+ . flags
185
+ . contains ( config. device_caps . required_downlevel_capabilities ( ) . flags )
186
+ {
187
+ return Err ( format ! (
188
+ "The given device doesn't support the required downlevel capabilities for the given hardware caps {:?}.
189
+ Required:
190
+ {:?}
191
+ Actual:
192
+ {:?}" ,
193
+ config. device_caps,
194
+ config. device_caps. required_downlevel_capabilities( ) ,
195
+ adapter. get_downlevel_capabilities( ) ,
196
+ ) ) ;
197
+ }
190
198
191
199
let resolver = crate :: new_recommended_file_resolver ( ) ;
192
200
let mesh_manager = RwLock :: new ( MeshManager :: new ( ) ) ;
@@ -222,7 +230,7 @@ impl RenderContext {
222
230
Self :: GPU_READBACK_BELT_DEFAULT_CHUNK_SIZE . unwrap ( ) ,
223
231
) ) ;
224
232
225
- RenderContext {
233
+ Ok ( RenderContext {
226
234
device,
227
235
queue,
228
236
config,
@@ -240,7 +248,7 @@ impl RenderContext {
240
248
active_frame,
241
249
frame_index_for_uncaptured_errors,
242
250
gpu_resources,
243
- }
251
+ } )
244
252
}
245
253
246
254
fn poll_device ( & mut self ) {
0 commit comments