1 //! Mock backend implementation to test the code for compile errors
2 //! outside of the graphics development environment.
3 
4 extern crate gfx_hal as hal;
5 
6 use crate::{
7     buffer::Buffer,
8     descriptor::{DescriptorPool, DescriptorSet, DescriptorSetLayout},
9     image::Image,
10     memory::Memory,
11 };
12 
13 use hal::{adapter, command, device, format, pass, pool, pso, query, queue, window};
14 use log::debug;
15 
16 use std::{borrow::Borrow, ops::Range};
17 
18 mod buffer;
19 mod descriptor;
20 mod image;
21 mod memory;
22 
23 const NOT_SUPPORTED_MESSAGE: &str = "This function is not currently mocked by the empty backend";
24 
25 /// Dummy backend.
26 #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
27 pub enum Backend {}
28 impl hal::Backend for Backend {
29     type Instance = Instance;
30     type PhysicalDevice = PhysicalDevice;
31     type Device = Device;
32     type Surface = Surface;
33 
34     type QueueFamily = QueueFamily;
35     type Queue = Queue;
36     type CommandBuffer = CommandBuffer;
37 
38     type Memory = Memory;
39     type CommandPool = CommandPool;
40 
41     type ShaderModule = ();
42     type RenderPass = ();
43     type Framebuffer = ();
44 
45     type Buffer = Buffer;
46     type BufferView = ();
47     type Image = Image;
48     type ImageView = ();
49     type Sampler = ();
50 
51     type ComputePipeline = ();
52     type GraphicsPipeline = ();
53     type PipelineCache = ();
54     type PipelineLayout = ();
55     type DescriptorSetLayout = DescriptorSetLayout;
56     type DescriptorPool = DescriptorPool;
57     type DescriptorSet = DescriptorSet;
58 
59     type Fence = ();
60     type Semaphore = ();
61     type Event = ();
62     type QueryPool = ();
63 }
64 
65 /// Dummy physical device.
66 #[derive(Debug)]
67 pub struct PhysicalDevice;
68 impl adapter::PhysicalDevice<Backend> for PhysicalDevice {
open( &self, families: &[(&QueueFamily, &[queue::QueuePriority])], _requested_features: hal::Features, ) -> Result<adapter::Gpu<Backend>, device::CreationError>69     unsafe fn open(
70         &self,
71         families: &[(&QueueFamily, &[queue::QueuePriority])],
72         _requested_features: hal::Features,
73     ) -> Result<adapter::Gpu<Backend>, device::CreationError> {
74         // Validate the arguments
75         assert_eq!(
76             families.len(),
77             1,
78             "Empty backend doesn't have multiple queue families"
79         );
80         let (_family, priorities) = families[0];
81         assert_eq!(
82             priorities.len(),
83             1,
84             "Empty backend doesn't support multiple queues"
85         );
86         let priority = priorities[0];
87         assert!(
88             0.0 <= priority && priority <= 1.0,
89             "Queue priority is out of range"
90         );
91 
92         // Create the queues
93         let queue_groups = {
94             let mut queue_group = queue::QueueGroup::new(QUEUE_FAMILY_ID);
95             queue_group.add_queue(Queue);
96             vec![queue_group]
97         };
98         let gpu = adapter::Gpu {
99             device: Device,
100             queue_groups,
101         };
102         Ok(gpu)
103     }
104 
format_properties(&self, _: Option<format::Format>) -> format::Properties105     fn format_properties(&self, _: Option<format::Format>) -> format::Properties {
106         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
107     }
108 
image_format_properties( &self, _: format::Format, _dim: u8, _: hal::image::Tiling, _: hal::image::Usage, _: hal::image::ViewCapabilities, ) -> Option<hal::image::FormatProperties>109     fn image_format_properties(
110         &self,
111         _: format::Format,
112         _dim: u8,
113         _: hal::image::Tiling,
114         _: hal::image::Usage,
115         _: hal::image::ViewCapabilities,
116     ) -> Option<hal::image::FormatProperties> {
117         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
118     }
119 
memory_properties(&self) -> adapter::MemoryProperties120     fn memory_properties(&self) -> adapter::MemoryProperties {
121         let memory_types = {
122             use hal::memory::Properties;
123             let properties = Properties::DEVICE_LOCAL
124                 | Properties::CPU_VISIBLE
125                 | Properties::COHERENT
126                 | Properties::CPU_CACHED;
127             let memory_type = adapter::MemoryType {
128                 properties,
129                 heap_index: 0,
130             };
131             vec![memory_type]
132         };
133         // TODO: perhaps get an estimate of free RAM to report here?
134         let memory_heaps = vec![adapter::MemoryHeap {
135             size: 64 * 1024,
136             flags: hal::memory::HeapFlags::empty(),
137         }];
138         adapter::MemoryProperties {
139             memory_types,
140             memory_heaps,
141         }
142     }
143 
features(&self) -> hal::Features144     fn features(&self) -> hal::Features {
145         hal::Features::empty()
146     }
147 
properties(&self) -> hal::PhysicalDeviceProperties148     fn properties(&self) -> hal::PhysicalDeviceProperties {
149         hal::PhysicalDeviceProperties {
150             limits: hal::Limits {
151                 non_coherent_atom_size: 1,
152                 optimal_buffer_copy_pitch_alignment: 1,
153                 ..Default::default()
154             },
155             ..Default::default()
156         }
157     }
158 }
159 
160 /// Dummy command queue doing nothing.
161 #[derive(Debug)]
162 pub struct Queue;
163 impl queue::Queue<Backend> for Queue {
submit<'a, Ic, Iw, Is>(&mut self, _: Ic, _: Iw, _: Is, _: Option<&mut ()>) where Ic: Iterator<Item = &'a CommandBuffer>,164     unsafe fn submit<'a, Ic, Iw, Is>(&mut self, _: Ic, _: Iw, _: Is, _: Option<&mut ()>)
165     where
166         Ic: Iterator<Item = &'a CommandBuffer>,
167     {
168     }
169 
present( &mut self, _surface: &mut Surface, _image: SwapchainImage, _wait_semaphore: Option<&mut ()>, ) -> Result<Option<window::Suboptimal>, window::PresentError>170     unsafe fn present(
171         &mut self,
172         _surface: &mut Surface,
173         _image: SwapchainImage,
174         _wait_semaphore: Option<&mut ()>,
175     ) -> Result<Option<window::Suboptimal>, window::PresentError> {
176         Ok(None)
177     }
178 
wait_idle(&mut self) -> Result<(), device::OutOfMemory>179     fn wait_idle(&mut self) -> Result<(), device::OutOfMemory> {
180         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
181     }
182 
timestamp_period(&self) -> f32183     fn timestamp_period(&self) -> f32 {
184         1.0
185     }
186 }
187 
188 /// Dummy device doing nothing.
189 #[derive(Debug)]
190 pub struct Device;
191 impl device::Device<Backend> for Device {
create_command_pool( &self, _: queue::QueueFamilyId, _: pool::CommandPoolCreateFlags, ) -> Result<CommandPool, device::OutOfMemory>192     unsafe fn create_command_pool(
193         &self,
194         _: queue::QueueFamilyId,
195         _: pool::CommandPoolCreateFlags,
196     ) -> Result<CommandPool, device::OutOfMemory> {
197         Ok(CommandPool)
198     }
199 
destroy_command_pool(&self, _: CommandPool)200     unsafe fn destroy_command_pool(&self, _: CommandPool) {}
201 
allocate_memory( &self, memory_type: hal::MemoryTypeId, size: u64, ) -> Result<Memory, device::AllocationError>202     unsafe fn allocate_memory(
203         &self,
204         memory_type: hal::MemoryTypeId,
205         size: u64,
206     ) -> Result<Memory, device::AllocationError> {
207         Memory::allocate(memory_type, size)
208     }
209 
create_render_pass<'a, Ia, Is, Id>( &self, _: Ia, _: Is, _: Id, ) -> Result<(), device::OutOfMemory> where Is: Iterator<Item = pass::SubpassDesc<'a>>,210     unsafe fn create_render_pass<'a, Ia, Is, Id>(
211         &self,
212         _: Ia,
213         _: Is,
214         _: Id,
215     ) -> Result<(), device::OutOfMemory>
216     where
217         Is: Iterator<Item = pass::SubpassDesc<'a>>,
218     {
219         Ok(())
220     }
221 
create_pipeline_layout<'a, Is, Ic>( &self, _: Is, _: Ic, ) -> Result<(), device::OutOfMemory> where Is: Iterator<Item = &'a DescriptorSetLayout>,222     unsafe fn create_pipeline_layout<'a, Is, Ic>(
223         &self,
224         _: Is,
225         _: Ic,
226     ) -> Result<(), device::OutOfMemory>
227     where
228         Is: Iterator<Item = &'a DescriptorSetLayout>,
229     {
230         Ok(())
231     }
232 
create_pipeline_cache( &self, _data: Option<&[u8]>, ) -> Result<(), device::OutOfMemory>233     unsafe fn create_pipeline_cache(
234         &self,
235         _data: Option<&[u8]>,
236     ) -> Result<(), device::OutOfMemory> {
237         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
238     }
239 
get_pipeline_cache_data(&self, _cache: &()) -> Result<Vec<u8>, device::OutOfMemory>240     unsafe fn get_pipeline_cache_data(&self, _cache: &()) -> Result<Vec<u8>, device::OutOfMemory> {
241         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
242     }
243 
destroy_pipeline_cache(&self, _: ())244     unsafe fn destroy_pipeline_cache(&self, _: ()) {
245         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
246     }
247 
create_graphics_pipeline<'a>( &self, _: &pso::GraphicsPipelineDesc<'a, Backend>, _: Option<&()>, ) -> Result<(), pso::CreationError>248     unsafe fn create_graphics_pipeline<'a>(
249         &self,
250         _: &pso::GraphicsPipelineDesc<'a, Backend>,
251         _: Option<&()>,
252     ) -> Result<(), pso::CreationError> {
253         Ok(())
254     }
255 
create_compute_pipeline<'a>( &self, _: &pso::ComputePipelineDesc<'a, Backend>, _: Option<&()>, ) -> Result<(), pso::CreationError>256     unsafe fn create_compute_pipeline<'a>(
257         &self,
258         _: &pso::ComputePipelineDesc<'a, Backend>,
259         _: Option<&()>,
260     ) -> Result<(), pso::CreationError> {
261         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
262     }
263 
merge_pipeline_caches<'a, I>( &self, _: &mut (), _: I, ) -> Result<(), device::OutOfMemory> where I: Iterator<Item = &'a ()>,264     unsafe fn merge_pipeline_caches<'a, I>(
265         &self,
266         _: &mut (),
267         _: I,
268     ) -> Result<(), device::OutOfMemory>
269     where
270         I: Iterator<Item = &'a ()>,
271     {
272         Ok(())
273     }
274 
create_framebuffer<I>( &self, _: &(), _: I, _: hal::image::Extent, ) -> Result<(), device::OutOfMemory>275     unsafe fn create_framebuffer<I>(
276         &self,
277         _: &(),
278         _: I,
279         _: hal::image::Extent,
280     ) -> Result<(), device::OutOfMemory> {
281         Ok(())
282     }
283 
create_shader_module(&self, _: &[u32]) -> Result<(), device::ShaderError>284     unsafe fn create_shader_module(&self, _: &[u32]) -> Result<(), device::ShaderError> {
285         Ok(())
286     }
287 
create_sampler( &self, _: &hal::image::SamplerDesc, ) -> Result<(), device::AllocationError>288     unsafe fn create_sampler(
289         &self,
290         _: &hal::image::SamplerDesc,
291     ) -> Result<(), device::AllocationError> {
292         Ok(())
293     }
294 
create_buffer( &self, size: u64, _: hal::buffer::Usage, _: hal::memory::SparseFlags, ) -> Result<Buffer, hal::buffer::CreationError>295     unsafe fn create_buffer(
296         &self,
297         size: u64,
298         _: hal::buffer::Usage,
299         _: hal::memory::SparseFlags,
300     ) -> Result<Buffer, hal::buffer::CreationError> {
301         Ok(Buffer::new(size))
302     }
303 
get_buffer_requirements(&self, buffer: &Buffer) -> hal::memory::Requirements304     unsafe fn get_buffer_requirements(&self, buffer: &Buffer) -> hal::memory::Requirements {
305         hal::memory::Requirements {
306             size: buffer.size,
307             // TODO: perhaps require stronger alignments?
308             alignment: 1,
309             type_mask: !0,
310         }
311     }
312 
bind_buffer_memory( &self, _memory: &Memory, _: u64, _: &mut Buffer, ) -> Result<(), device::BindError>313     unsafe fn bind_buffer_memory(
314         &self,
315         _memory: &Memory,
316         _: u64,
317         _: &mut Buffer,
318     ) -> Result<(), device::BindError> {
319         Ok(())
320     }
321 
create_buffer_view( &self, _: &Buffer, _: Option<format::Format>, _: hal::buffer::SubRange, ) -> Result<(), hal::buffer::ViewCreationError>322     unsafe fn create_buffer_view(
323         &self,
324         _: &Buffer,
325         _: Option<format::Format>,
326         _: hal::buffer::SubRange,
327     ) -> Result<(), hal::buffer::ViewCreationError> {
328         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
329     }
330 
create_image( &self, kind: hal::image::Kind, _: hal::image::Level, _: format::Format, _: hal::image::Tiling, _: hal::image::Usage, _: hal::memory::SparseFlags, _: hal::image::ViewCapabilities, ) -> Result<Image, hal::image::CreationError>331     unsafe fn create_image(
332         &self,
333         kind: hal::image::Kind,
334         _: hal::image::Level,
335         _: format::Format,
336         _: hal::image::Tiling,
337         _: hal::image::Usage,
338         _: hal::memory::SparseFlags,
339         _: hal::image::ViewCapabilities,
340     ) -> Result<Image, hal::image::CreationError> {
341         Ok(Image::new(kind))
342     }
343 
get_image_requirements(&self, image: &Image) -> hal::memory::Requirements344     unsafe fn get_image_requirements(&self, image: &Image) -> hal::memory::Requirements {
345         image.get_requirements()
346     }
347 
get_image_subresource_footprint( &self, _: &Image, _: hal::image::Subresource, ) -> hal::image::SubresourceFootprint348     unsafe fn get_image_subresource_footprint(
349         &self,
350         _: &Image,
351         _: hal::image::Subresource,
352     ) -> hal::image::SubresourceFootprint {
353         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
354     }
355 
bind_image_memory( &self, _memory: &Memory, _: u64, _: &mut Image, ) -> Result<(), device::BindError>356     unsafe fn bind_image_memory(
357         &self,
358         _memory: &Memory,
359         _: u64,
360         _: &mut Image,
361     ) -> Result<(), device::BindError> {
362         Ok(())
363     }
364 
create_image_view( &self, _: &Image, _: hal::image::ViewKind, _: format::Format, _: format::Swizzle, _: hal::image::Usage, _: hal::image::SubresourceRange, ) -> Result<(), hal::image::ViewCreationError>365     unsafe fn create_image_view(
366         &self,
367         _: &Image,
368         _: hal::image::ViewKind,
369         _: format::Format,
370         _: format::Swizzle,
371         _: hal::image::Usage,
372         _: hal::image::SubresourceRange,
373     ) -> Result<(), hal::image::ViewCreationError> {
374         Ok(())
375     }
376 
create_descriptor_pool<I>( &self, _: usize, _: I, _: pso::DescriptorPoolCreateFlags, ) -> Result<DescriptorPool, device::OutOfMemory>377     unsafe fn create_descriptor_pool<I>(
378         &self,
379         _: usize,
380         _: I,
381         _: pso::DescriptorPoolCreateFlags,
382     ) -> Result<DescriptorPool, device::OutOfMemory> {
383         Ok(DescriptorPool)
384     }
385 
create_descriptor_set_layout<'a, I, J>( &self, _bindings: I, _samplers: J, ) -> Result<DescriptorSetLayout, device::OutOfMemory> where J: Iterator<Item = &'a ()>,386     unsafe fn create_descriptor_set_layout<'a, I, J>(
387         &self,
388         _bindings: I,
389         _samplers: J,
390     ) -> Result<DescriptorSetLayout, device::OutOfMemory>
391     where
392         J: Iterator<Item = &'a ()>,
393     {
394         let layout = DescriptorSetLayout {
395             name: String::new(),
396         };
397         Ok(layout)
398     }
399 
write_descriptor_set<'a, I>(&self, _: pso::DescriptorSetWrite<'a, Backend, I>) where I: Iterator<Item = pso::Descriptor<'a, Backend>>,400     unsafe fn write_descriptor_set<'a, I>(&self, _: pso::DescriptorSetWrite<'a, Backend, I>)
401     where
402         I: Iterator<Item = pso::Descriptor<'a, Backend>>,
403     {
404     }
405 
copy_descriptor_set<'a>(&self, _: pso::DescriptorSetCopy<'a, Backend>)406     unsafe fn copy_descriptor_set<'a>(&self, _: pso::DescriptorSetCopy<'a, Backend>) {
407         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
408     }
409 
create_semaphore(&self) -> Result<(), device::OutOfMemory>410     fn create_semaphore(&self) -> Result<(), device::OutOfMemory> {
411         Ok(())
412     }
413 
create_fence(&self, _: bool) -> Result<(), device::OutOfMemory>414     fn create_fence(&self, _: bool) -> Result<(), device::OutOfMemory> {
415         Ok(())
416     }
417 
get_fence_status(&self, _: &()) -> Result<bool, device::DeviceLost>418     unsafe fn get_fence_status(&self, _: &()) -> Result<bool, device::DeviceLost> {
419         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
420     }
421 
create_event(&self) -> Result<(), device::OutOfMemory>422     fn create_event(&self) -> Result<(), device::OutOfMemory> {
423         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
424     }
425 
get_event_status(&self, _: &()) -> Result<bool, device::WaitError>426     unsafe fn get_event_status(&self, _: &()) -> Result<bool, device::WaitError> {
427         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
428     }
429 
set_event(&self, _: &mut ()) -> Result<(), device::OutOfMemory>430     unsafe fn set_event(&self, _: &mut ()) -> Result<(), device::OutOfMemory> {
431         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
432     }
433 
reset_event(&self, _: &mut ()) -> Result<(), device::OutOfMemory>434     unsafe fn reset_event(&self, _: &mut ()) -> Result<(), device::OutOfMemory> {
435         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
436     }
437 
create_query_pool(&self, _: query::Type, _: u32) -> Result<(), query::CreationError>438     unsafe fn create_query_pool(&self, _: query::Type, _: u32) -> Result<(), query::CreationError> {
439         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
440     }
441 
destroy_query_pool(&self, _: ())442     unsafe fn destroy_query_pool(&self, _: ()) {
443         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
444     }
445 
get_query_pool_results( &self, _: &(), _: Range<query::Id>, _: &mut [u8], _: hal::buffer::Stride, _: query::ResultFlags, ) -> Result<bool, device::WaitError>446     unsafe fn get_query_pool_results(
447         &self,
448         _: &(),
449         _: Range<query::Id>,
450         _: &mut [u8],
451         _: hal::buffer::Stride,
452         _: query::ResultFlags,
453     ) -> Result<bool, device::WaitError> {
454         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
455     }
456 
map_memory( &self, memory: &mut Memory, segment: hal::memory::Segment, ) -> Result<*mut u8, device::MapError>457     unsafe fn map_memory(
458         &self,
459         memory: &mut Memory,
460         segment: hal::memory::Segment,
461     ) -> Result<*mut u8, device::MapError> {
462         memory.map(segment)
463     }
464 
unmap_memory(&self, _memory: &mut Memory)465     unsafe fn unmap_memory(&self, _memory: &mut Memory) {}
466 
flush_mapped_memory_ranges<'a, I>(&self, _: I) -> Result<(), device::OutOfMemory> where I: Iterator<Item = (&'a Memory, hal::memory::Segment)>,467     unsafe fn flush_mapped_memory_ranges<'a, I>(&self, _: I) -> Result<(), device::OutOfMemory>
468     where
469         I: Iterator<Item = (&'a Memory, hal::memory::Segment)>,
470     {
471         Ok(())
472     }
473 
invalidate_mapped_memory_ranges<'a, I>(&self, _: I) -> Result<(), device::OutOfMemory> where I: Iterator<Item = (&'a Memory, hal::memory::Segment)>,474     unsafe fn invalidate_mapped_memory_ranges<'a, I>(&self, _: I) -> Result<(), device::OutOfMemory>
475     where
476         I: Iterator<Item = (&'a Memory, hal::memory::Segment)>,
477     {
478         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
479     }
480 
free_memory(&self, _memory: Memory)481     unsafe fn free_memory(&self, _memory: Memory) {
482         // Let memory drop
483     }
484 
destroy_shader_module(&self, _: ())485     unsafe fn destroy_shader_module(&self, _: ()) {}
486 
destroy_render_pass(&self, _: ())487     unsafe fn destroy_render_pass(&self, _: ()) {}
488 
destroy_pipeline_layout(&self, _: ())489     unsafe fn destroy_pipeline_layout(&self, _: ()) {}
490 
destroy_graphics_pipeline(&self, _: ())491     unsafe fn destroy_graphics_pipeline(&self, _: ()) {}
492 
destroy_compute_pipeline(&self, _: ())493     unsafe fn destroy_compute_pipeline(&self, _: ()) {
494         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
495     }
destroy_framebuffer(&self, _: ())496     unsafe fn destroy_framebuffer(&self, _: ()) {}
497 
destroy_buffer(&self, _: Buffer)498     unsafe fn destroy_buffer(&self, _: Buffer) {}
499 
destroy_buffer_view(&self, _: ())500     unsafe fn destroy_buffer_view(&self, _: ()) {
501         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
502     }
503 
destroy_image(&self, _: Image)504     unsafe fn destroy_image(&self, _: Image) {}
505 
destroy_image_view(&self, _: ())506     unsafe fn destroy_image_view(&self, _: ()) {}
507 
destroy_sampler(&self, _: ())508     unsafe fn destroy_sampler(&self, _: ()) {}
509 
destroy_descriptor_pool(&self, _: DescriptorPool)510     unsafe fn destroy_descriptor_pool(&self, _: DescriptorPool) {}
511 
destroy_descriptor_set_layout(&self, _: DescriptorSetLayout)512     unsafe fn destroy_descriptor_set_layout(&self, _: DescriptorSetLayout) {}
513 
destroy_fence(&self, _: ())514     unsafe fn destroy_fence(&self, _: ()) {}
515 
destroy_semaphore(&self, _: ())516     unsafe fn destroy_semaphore(&self, _: ()) {}
517 
destroy_event(&self, _: ())518     unsafe fn destroy_event(&self, _: ()) {
519         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
520     }
521 
wait_idle(&self) -> Result<(), device::OutOfMemory>522     fn wait_idle(&self) -> Result<(), device::OutOfMemory> {
523         Ok(())
524     }
525 
set_image_name(&self, _: &mut Image, _: &str)526     unsafe fn set_image_name(&self, _: &mut Image, _: &str) {
527         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
528     }
529 
set_buffer_name(&self, _: &mut Buffer, _: &str)530     unsafe fn set_buffer_name(&self, _: &mut Buffer, _: &str) {
531         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
532     }
533 
set_command_buffer_name(&self, _: &mut CommandBuffer, _: &str)534     unsafe fn set_command_buffer_name(&self, _: &mut CommandBuffer, _: &str) {
535         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
536     }
537 
set_semaphore_name(&self, _: &mut (), _: &str)538     unsafe fn set_semaphore_name(&self, _: &mut (), _: &str) {
539         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
540     }
541 
set_fence_name(&self, _: &mut (), _: &str)542     unsafe fn set_fence_name(&self, _: &mut (), _: &str) {
543         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
544     }
545 
set_framebuffer_name(&self, _: &mut (), _: &str)546     unsafe fn set_framebuffer_name(&self, _: &mut (), _: &str) {
547         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
548     }
549 
set_render_pass_name(&self, _: &mut (), _: &str)550     unsafe fn set_render_pass_name(&self, _: &mut (), _: &str) {
551         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
552     }
553 
set_descriptor_set_name(&self, set: &mut DescriptorSet, name: &str)554     unsafe fn set_descriptor_set_name(&self, set: &mut DescriptorSet, name: &str) {
555         set.name = name.to_string();
556     }
557 
set_descriptor_set_layout_name(&self, layout: &mut DescriptorSetLayout, name: &str)558     unsafe fn set_descriptor_set_layout_name(&self, layout: &mut DescriptorSetLayout, name: &str) {
559         layout.name = name.to_string();
560     }
561 
set_pipeline_layout_name(&self, _pipeline_layout: &mut (), _name: &str)562     unsafe fn set_pipeline_layout_name(&self, _pipeline_layout: &mut (), _name: &str) {
563         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
564     }
565 
reset_fence(&self, _: &mut ()) -> Result<(), device::OutOfMemory>566     unsafe fn reset_fence(&self, _: &mut ()) -> Result<(), device::OutOfMemory> {
567         Ok(())
568     }
569 
wait_for_fence(&self, _: &(), _: u64) -> Result<bool, device::WaitError>570     unsafe fn wait_for_fence(&self, _: &(), _: u64) -> Result<bool, device::WaitError> {
571         Ok(true)
572     }
573 
start_capture(&self)574     fn start_capture(&self) {
575         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
576     }
577 
stop_capture(&self)578     fn stop_capture(&self) {
579         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
580     }
581 }
582 
583 #[derive(Debug)]
584 pub struct QueueFamily;
585 impl queue::QueueFamily for QueueFamily {
queue_type(&self) -> queue::QueueType586     fn queue_type(&self) -> queue::QueueType {
587         queue::QueueType::General
588     }
max_queues(&self) -> usize589     fn max_queues(&self) -> usize {
590         1
591     }
id(&self) -> queue::QueueFamilyId592     fn id(&self) -> queue::QueueFamilyId {
593         QUEUE_FAMILY_ID
594     }
supports_sparse_binding(&self) -> bool595     fn supports_sparse_binding(&self) -> bool {
596         true
597     }
598 }
599 
600 const QUEUE_FAMILY_ID: queue::QueueFamilyId = queue::QueueFamilyId(0);
601 
602 /// Dummy raw command pool.
603 #[derive(Debug)]
604 pub struct CommandPool;
605 impl pool::CommandPool<Backend> for CommandPool {
allocate_one(&mut self, level: command::Level) -> CommandBuffer606     unsafe fn allocate_one(&mut self, level: command::Level) -> CommandBuffer {
607         assert_eq!(
608             level,
609             command::Level::Primary,
610             "Only primary command buffers are supported"
611         );
612         CommandBuffer
613     }
614 
reset(&mut self, _: bool)615     unsafe fn reset(&mut self, _: bool) {}
616 
free<I>(&mut self, _: I)617     unsafe fn free<I>(&mut self, _: I) {
618         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
619     }
620 }
621 
622 /// Dummy command buffer, which ignores all the calls.
623 #[derive(Debug)]
624 pub struct CommandBuffer;
625 impl command::CommandBuffer<Backend> for CommandBuffer {
begin( &mut self, _: command::CommandBufferFlags, _: command::CommandBufferInheritanceInfo<Backend>, )626     unsafe fn begin(
627         &mut self,
628         _: command::CommandBufferFlags,
629         _: command::CommandBufferInheritanceInfo<Backend>,
630     ) {
631     }
632 
finish(&mut self)633     unsafe fn finish(&mut self) {}
634 
reset(&mut self, _: bool)635     unsafe fn reset(&mut self, _: bool) {
636         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
637     }
638 
pipeline_barrier<'a, T>( &mut self, _: Range<pso::PipelineStage>, _: hal::memory::Dependencies, _: T, ) where T: Iterator<Item = hal::memory::Barrier<'a, Backend>>,639     unsafe fn pipeline_barrier<'a, T>(
640         &mut self,
641         _: Range<pso::PipelineStage>,
642         _: hal::memory::Dependencies,
643         _: T,
644     ) where
645         T: Iterator<Item = hal::memory::Barrier<'a, Backend>>,
646     {
647     }
648 
fill_buffer(&mut self, _: &Buffer, _: hal::buffer::SubRange, _: u32)649     unsafe fn fill_buffer(&mut self, _: &Buffer, _: hal::buffer::SubRange, _: u32) {
650         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
651     }
652 
update_buffer(&mut self, _: &Buffer, _: hal::buffer::Offset, _: &[u8])653     unsafe fn update_buffer(&mut self, _: &Buffer, _: hal::buffer::Offset, _: &[u8]) {
654         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
655     }
656 
clear_image<T>( &mut self, _: &Image, _: hal::image::Layout, _: command::ClearValue, _: T, )657     unsafe fn clear_image<T>(
658         &mut self,
659         _: &Image,
660         _: hal::image::Layout,
661         _: command::ClearValue,
662         _: T,
663     ) {
664         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
665     }
666 
clear_attachments<T, U>(&mut self, _: T, _: U)667     unsafe fn clear_attachments<T, U>(&mut self, _: T, _: U) {
668         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
669     }
670 
resolve_image<T>( &mut self, _: &Image, _: hal::image::Layout, _: &Image, _: hal::image::Layout, _: T, )671     unsafe fn resolve_image<T>(
672         &mut self,
673         _: &Image,
674         _: hal::image::Layout,
675         _: &Image,
676         _: hal::image::Layout,
677         _: T,
678     ) {
679         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
680     }
681 
blit_image<T>( &mut self, _: &Image, _: hal::image::Layout, _: &Image, _: hal::image::Layout, _: hal::image::Filter, _: T, )682     unsafe fn blit_image<T>(
683         &mut self,
684         _: &Image,
685         _: hal::image::Layout,
686         _: &Image,
687         _: hal::image::Layout,
688         _: hal::image::Filter,
689         _: T,
690     ) {
691         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
692     }
693 
bind_index_buffer( &mut self, _: &Buffer, _: hal::buffer::SubRange, _: hal::IndexType, )694     unsafe fn bind_index_buffer(
695         &mut self,
696         _: &Buffer,
697         _: hal::buffer::SubRange,
698         _: hal::IndexType,
699     ) {
700         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
701     }
702 
bind_vertex_buffers<'a, T>(&mut self, _: u32, _: T) where T: Iterator<Item = (&'a Buffer, hal::buffer::SubRange)>,703     unsafe fn bind_vertex_buffers<'a, T>(&mut self, _: u32, _: T)
704     where
705         T: Iterator<Item = (&'a Buffer, hal::buffer::SubRange)>,
706     {
707     }
708 
set_viewports<T>(&mut self, _: u32, _: T)709     unsafe fn set_viewports<T>(&mut self, _: u32, _: T) {}
710 
set_scissors<T>(&mut self, _: u32, _: T)711     unsafe fn set_scissors<T>(&mut self, _: u32, _: T) {}
712 
set_stencil_reference(&mut self, _: pso::Face, _: pso::StencilValue)713     unsafe fn set_stencil_reference(&mut self, _: pso::Face, _: pso::StencilValue) {
714         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
715     }
716 
set_stencil_read_mask(&mut self, _: pso::Face, _: pso::StencilValue)717     unsafe fn set_stencil_read_mask(&mut self, _: pso::Face, _: pso::StencilValue) {
718         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
719     }
720 
set_stencil_write_mask(&mut self, _: pso::Face, _: pso::StencilValue)721     unsafe fn set_stencil_write_mask(&mut self, _: pso::Face, _: pso::StencilValue) {
722         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
723     }
724 
set_blend_constants(&mut self, _: pso::ColorValue)725     unsafe fn set_blend_constants(&mut self, _: pso::ColorValue) {
726         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
727     }
728 
set_depth_bounds(&mut self, _: Range<f32>)729     unsafe fn set_depth_bounds(&mut self, _: Range<f32>) {
730         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
731     }
732 
set_line_width(&mut self, _: f32)733     unsafe fn set_line_width(&mut self, _: f32) {
734         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
735     }
736 
set_depth_bias(&mut self, _: pso::DepthBias)737     unsafe fn set_depth_bias(&mut self, _: pso::DepthBias) {
738         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
739     }
740 
begin_render_pass<'a, T>( &mut self, _: &(), _: &(), _: pso::Rect, _: T, _: command::SubpassContents, ) where T: Iterator<Item = command::RenderAttachmentInfo<'a, Backend>>,741     unsafe fn begin_render_pass<'a, T>(
742         &mut self,
743         _: &(),
744         _: &(),
745         _: pso::Rect,
746         _: T,
747         _: command::SubpassContents,
748     ) where
749         T: Iterator<Item = command::RenderAttachmentInfo<'a, Backend>>,
750     {
751     }
752 
next_subpass(&mut self, _: command::SubpassContents)753     unsafe fn next_subpass(&mut self, _: command::SubpassContents) {
754         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
755     }
756 
end_render_pass(&mut self)757     unsafe fn end_render_pass(&mut self) {}
758 
bind_graphics_pipeline(&mut self, _: &())759     unsafe fn bind_graphics_pipeline(&mut self, _: &()) {}
760 
bind_graphics_descriptor_sets<'a, I, J>(&mut self, _: &(), _: usize, _: I, _: J) where I: Iterator<Item = &'a DescriptorSet>,761     unsafe fn bind_graphics_descriptor_sets<'a, I, J>(&mut self, _: &(), _: usize, _: I, _: J)
762     where
763         I: Iterator<Item = &'a DescriptorSet>,
764     {
765         // Do nothing
766     }
767 
bind_compute_pipeline(&mut self, _: &())768     unsafe fn bind_compute_pipeline(&mut self, _: &()) {
769         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
770     }
771 
bind_compute_descriptor_sets<'a, I, J>(&mut self, _: &(), _: usize, _: I, _: J) where I: Iterator<Item = &'a DescriptorSet>,772     unsafe fn bind_compute_descriptor_sets<'a, I, J>(&mut self, _: &(), _: usize, _: I, _: J)
773     where
774         I: Iterator<Item = &'a DescriptorSet>,
775     {
776         // Do nothing
777     }
778 
dispatch(&mut self, _: hal::WorkGroupCount)779     unsafe fn dispatch(&mut self, _: hal::WorkGroupCount) {
780         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
781     }
782 
dispatch_indirect(&mut self, _: &Buffer, _: hal::buffer::Offset)783     unsafe fn dispatch_indirect(&mut self, _: &Buffer, _: hal::buffer::Offset) {
784         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
785     }
786 
copy_buffer<T>(&mut self, _: &Buffer, _: &Buffer, _: T)787     unsafe fn copy_buffer<T>(&mut self, _: &Buffer, _: &Buffer, _: T) {
788         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
789     }
790 
copy_image<T>( &mut self, _: &Image, _: hal::image::Layout, _: &Image, _: hal::image::Layout, _: T, )791     unsafe fn copy_image<T>(
792         &mut self,
793         _: &Image,
794         _: hal::image::Layout,
795         _: &Image,
796         _: hal::image::Layout,
797         _: T,
798     ) {
799         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
800     }
801 
copy_buffer_to_image<T>( &mut self, _: &Buffer, _: &Image, _: hal::image::Layout, _: T, )802     unsafe fn copy_buffer_to_image<T>(
803         &mut self,
804         _: &Buffer,
805         _: &Image,
806         _: hal::image::Layout,
807         _: T,
808     ) {
809     }
810 
copy_image_to_buffer<T>( &mut self, _: &Image, _: hal::image::Layout, _: &Buffer, _: T, )811     unsafe fn copy_image_to_buffer<T>(
812         &mut self,
813         _: &Image,
814         _: hal::image::Layout,
815         _: &Buffer,
816         _: T,
817     ) {
818         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
819     }
820 
draw(&mut self, _: Range<hal::VertexCount>, _: Range<hal::InstanceCount>)821     unsafe fn draw(&mut self, _: Range<hal::VertexCount>, _: Range<hal::InstanceCount>) {}
822 
draw_indexed( &mut self, _: Range<hal::IndexCount>, _: hal::VertexOffset, _: Range<hal::InstanceCount>, )823     unsafe fn draw_indexed(
824         &mut self,
825         _: Range<hal::IndexCount>,
826         _: hal::VertexOffset,
827         _: Range<hal::InstanceCount>,
828     ) {
829     }
830 
draw_indirect( &mut self, _: &Buffer, _: hal::buffer::Offset, _: hal::DrawCount, _: hal::buffer::Stride, )831     unsafe fn draw_indirect(
832         &mut self,
833         _: &Buffer,
834         _: hal::buffer::Offset,
835         _: hal::DrawCount,
836         _: hal::buffer::Stride,
837     ) {
838     }
839 
draw_indexed_indirect( &mut self, _: &Buffer, _: hal::buffer::Offset, _: hal::DrawCount, _: hal::buffer::Stride, )840     unsafe fn draw_indexed_indirect(
841         &mut self,
842         _: &Buffer,
843         _: hal::buffer::Offset,
844         _: hal::DrawCount,
845         _: hal::buffer::Stride,
846     ) {
847     }
848 
draw_indirect_count( &mut self, _: &Buffer, _: hal::buffer::Offset, _: &Buffer, _: hal::buffer::Offset, _: u32, _: hal::buffer::Stride, )849     unsafe fn draw_indirect_count(
850         &mut self,
851         _: &Buffer,
852         _: hal::buffer::Offset,
853         _: &Buffer,
854         _: hal::buffer::Offset,
855         _: u32,
856         _: hal::buffer::Stride,
857     ) {
858     }
859 
draw_indexed_indirect_count( &mut self, _: &Buffer, _: hal::buffer::Offset, _: &Buffer, _: hal::buffer::Offset, _: u32, _: hal::buffer::Stride, )860     unsafe fn draw_indexed_indirect_count(
861         &mut self,
862         _: &Buffer,
863         _: hal::buffer::Offset,
864         _: &Buffer,
865         _: hal::buffer::Offset,
866         _: u32,
867         _: hal::buffer::Stride,
868     ) {
869     }
870 
draw_mesh_tasks(&mut self, _: hal::TaskCount, _: hal::TaskCount)871     unsafe fn draw_mesh_tasks(&mut self, _: hal::TaskCount, _: hal::TaskCount) {
872         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
873     }
874 
draw_mesh_tasks_indirect( &mut self, _: &Buffer, _: hal::buffer::Offset, _: hal::DrawCount, _: hal::buffer::Stride, )875     unsafe fn draw_mesh_tasks_indirect(
876         &mut self,
877         _: &Buffer,
878         _: hal::buffer::Offset,
879         _: hal::DrawCount,
880         _: hal::buffer::Stride,
881     ) {
882         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
883     }
884 
draw_mesh_tasks_indirect_count( &mut self, _: &Buffer, _: hal::buffer::Offset, _: &Buffer, _: hal::buffer::Offset, _: u32, _: hal::buffer::Stride, )885     unsafe fn draw_mesh_tasks_indirect_count(
886         &mut self,
887         _: &Buffer,
888         _: hal::buffer::Offset,
889         _: &Buffer,
890         _: hal::buffer::Offset,
891         _: u32,
892         _: hal::buffer::Stride,
893     ) {
894         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
895     }
896 
set_event(&mut self, _: &(), _: pso::PipelineStage)897     unsafe fn set_event(&mut self, _: &(), _: pso::PipelineStage) {
898         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
899     }
900 
reset_event(&mut self, _: &(), _: pso::PipelineStage)901     unsafe fn reset_event(&mut self, _: &(), _: pso::PipelineStage) {
902         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
903     }
904 
wait_events<'a, I, J>(&mut self, _: I, _: Range<pso::PipelineStage>, _: J) where J: Iterator<Item = hal::memory::Barrier<'a, Backend>>,905     unsafe fn wait_events<'a, I, J>(&mut self, _: I, _: Range<pso::PipelineStage>, _: J)
906     where
907         J: Iterator<Item = hal::memory::Barrier<'a, Backend>>,
908     {
909         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
910     }
911 
begin_query(&mut self, _: query::Query<Backend>, _: query::ControlFlags)912     unsafe fn begin_query(&mut self, _: query::Query<Backend>, _: query::ControlFlags) {
913         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
914     }
915 
end_query(&mut self, _: query::Query<Backend>)916     unsafe fn end_query(&mut self, _: query::Query<Backend>) {
917         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
918     }
919 
reset_query_pool(&mut self, _: &(), _: Range<query::Id>)920     unsafe fn reset_query_pool(&mut self, _: &(), _: Range<query::Id>) {
921         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
922     }
923 
copy_query_pool_results( &mut self, _: &(), _: Range<query::Id>, _: &Buffer, _: hal::buffer::Offset, _: hal::buffer::Stride, _: query::ResultFlags, )924     unsafe fn copy_query_pool_results(
925         &mut self,
926         _: &(),
927         _: Range<query::Id>,
928         _: &Buffer,
929         _: hal::buffer::Offset,
930         _: hal::buffer::Stride,
931         _: query::ResultFlags,
932     ) {
933         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
934     }
935 
write_timestamp(&mut self, _: pso::PipelineStage, _: query::Query<Backend>)936     unsafe fn write_timestamp(&mut self, _: pso::PipelineStage, _: query::Query<Backend>) {
937         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
938     }
939 
push_graphics_constants( &mut self, _: &(), _: pso::ShaderStageFlags, _: u32, _: &[u32], )940     unsafe fn push_graphics_constants(
941         &mut self,
942         _: &(),
943         _: pso::ShaderStageFlags,
944         _: u32,
945         _: &[u32],
946     ) {
947         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
948     }
949 
push_compute_constants(&mut self, _: &(), _: u32, _: &[u32])950     unsafe fn push_compute_constants(&mut self, _: &(), _: u32, _: &[u32]) {
951         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
952     }
953 
execute_commands<'a, T>(&mut self, _: T) where T: Iterator<Item = &'a CommandBuffer>,954     unsafe fn execute_commands<'a, T>(&mut self, _: T)
955     where
956         T: Iterator<Item = &'a CommandBuffer>,
957     {
958         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
959     }
960 
insert_debug_marker(&mut self, _: &str, _: u32)961     unsafe fn insert_debug_marker(&mut self, _: &str, _: u32) {
962         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
963     }
begin_debug_marker(&mut self, _: &str, _: u32)964     unsafe fn begin_debug_marker(&mut self, _: &str, _: u32) {
965         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
966     }
end_debug_marker(&mut self)967     unsafe fn end_debug_marker(&mut self) {
968         unimplemented!("{}", NOT_SUPPORTED_MESSAGE)
969     }
970 }
971 
972 /// Dummy surface.
973 #[derive(Debug)]
974 pub struct Surface;
975 impl window::Surface<Backend> for Surface {
supports_queue_family(&self, _: &QueueFamily) -> bool976     fn supports_queue_family(&self, _: &QueueFamily) -> bool {
977         true
978     }
979 
capabilities(&self, _: &PhysicalDevice) -> window::SurfaceCapabilities980     fn capabilities(&self, _: &PhysicalDevice) -> window::SurfaceCapabilities {
981         let extents = {
982             let min_extent = window::Extent2D {
983                 width: 0,
984                 height: 0,
985             };
986             let max_extent = window::Extent2D {
987                 width: 8192,
988                 height: 4096,
989             };
990             min_extent..=max_extent
991         };
992         let usage = hal::image::Usage::COLOR_ATTACHMENT;
993         let present_modes = window::PresentMode::all();
994         let composite_alpha_modes = window::CompositeAlphaMode::OPAQUE;
995         window::SurfaceCapabilities {
996             image_count: 1..=1,
997             current_extent: None,
998             extents,
999             max_image_layers: 1,
1000             usage,
1001             present_modes,
1002             composite_alpha_modes,
1003         }
1004     }
1005 
supported_formats(&self, _: &PhysicalDevice) -> Option<Vec<format::Format>>1006     fn supported_formats(&self, _: &PhysicalDevice) -> Option<Vec<format::Format>> {
1007         None
1008     }
1009 }
1010 
1011 #[derive(Debug)]
1012 pub struct SwapchainImage;
1013 impl Borrow<Image> for SwapchainImage {
borrow(&self) -> &Image1014     fn borrow(&self) -> &Image {
1015         unimplemented!()
1016     }
1017 }
1018 impl Borrow<()> for SwapchainImage {
borrow(&self) -> &()1019     fn borrow(&self) -> &() {
1020         unimplemented!()
1021     }
1022 }
1023 
1024 impl window::PresentationSurface<Backend> for Surface {
1025     type SwapchainImage = SwapchainImage;
1026 
configure_swapchain( &mut self, _: &Device, _: window::SwapchainConfig, ) -> Result<(), window::SwapchainError>1027     unsafe fn configure_swapchain(
1028         &mut self,
1029         _: &Device,
1030         _: window::SwapchainConfig,
1031     ) -> Result<(), window::SwapchainError> {
1032         Ok(())
1033     }
1034 
unconfigure_swapchain(&mut self, _: &Device)1035     unsafe fn unconfigure_swapchain(&mut self, _: &Device) {}
1036 
acquire_image( &mut self, _: u64, ) -> Result<(SwapchainImage, Option<window::Suboptimal>), window::AcquireError>1037     unsafe fn acquire_image(
1038         &mut self,
1039         _: u64,
1040     ) -> Result<(SwapchainImage, Option<window::Suboptimal>), window::AcquireError> {
1041         Ok((SwapchainImage, None))
1042     }
1043 }
1044 
1045 #[derive(Debug)]
1046 pub struct Instance;
1047 
1048 impl hal::Instance<Backend> for Instance {
create(name: &str, version: u32) -> Result<Self, hal::UnsupportedBackend>1049     fn create(name: &str, version: u32) -> Result<Self, hal::UnsupportedBackend> {
1050         debug!(
1051             "Creating empty backend instance with name '{}' and version {}",
1052             name, version
1053         );
1054         Ok(Instance)
1055     }
1056 
enumerate_adapters(&self) -> Vec<adapter::Adapter<Backend>>1057     fn enumerate_adapters(&self) -> Vec<adapter::Adapter<Backend>> {
1058         // TODO: provide more mock adapters, with various qualities
1059         let info = adapter::AdapterInfo {
1060             name: "Mock Device".to_string(),
1061             vendor: 0,
1062             device: 1234,
1063             device_type: adapter::DeviceType::Other,
1064         };
1065         let adapter = adapter::Adapter {
1066             info,
1067             physical_device: PhysicalDevice,
1068             // TODO: multiple queue families
1069             queue_families: vec![QueueFamily],
1070         };
1071         vec![adapter]
1072     }
1073 
create_surface( &self, raw_window_handle: &impl raw_window_handle::HasRawWindowHandle, ) -> Result<Surface, hal::window::InitError>1074     unsafe fn create_surface(
1075         &self,
1076         raw_window_handle: &impl raw_window_handle::HasRawWindowHandle,
1077     ) -> Result<Surface, hal::window::InitError> {
1078         // TODO: maybe check somehow that the given handle is valid?
1079         let _handle = raw_window_handle.raw_window_handle();
1080         Ok(Surface)
1081     }
1082 
destroy_surface(&self, _surface: Surface)1083     unsafe fn destroy_surface(&self, _surface: Surface) {}
1084 }
1085