Skip to main content

wgpu_hal/gles/
command.rs

1use alloc::boxed::Box;
2use alloc::string::String;
3use alloc::sync::Arc;
4use core::{mem, ops::Range};
5
6use arrayvec::ArrayVec;
7
8use super::{conv, Command as C};
9
10#[derive(Clone, Copy, Debug, Default)]
11struct TextureSlotDesc {
12    tex_target: super::BindTarget,
13    sampler_index: Option<u8>,
14}
15
16pub(super) struct State {
17    topology: u32,
18    primitive: super::PrimitiveState,
19    index_format: wgt::IndexFormat,
20    index_offset: wgt::BufferAddress,
21    vertex_buffers: [(
22        Option<super::VertexBufferDesc>,
23        Option<super::BufferBinding>,
24    ); crate::MAX_VERTEX_BUFFERS],
25    vertex_attributes: ArrayVec<super::AttributeDesc, { super::MAX_VERTEX_ATTRIBUTES }>,
26    color_targets: ArrayVec<super::ColorTargetDesc, { crate::MAX_COLOR_ATTACHMENTS }>,
27    stencil: super::StencilState,
28    depth_bias: wgt::DepthBiasState,
29    alpha_to_coverage_enabled: bool,
30    samplers: [Option<glow::Sampler>; super::MAX_SAMPLERS],
31    texture_slots: [TextureSlotDesc; super::MAX_TEXTURE_SLOTS],
32    render_size: wgt::Extent3d,
33    resolve_attachments: ArrayVec<(u32, super::TextureView), { crate::MAX_COLOR_ATTACHMENTS }>,
34    invalidate_attachments: ArrayVec<u32, { crate::MAX_COLOR_ATTACHMENTS + 2 }>,
35    has_pass_label: bool,
36    instance_vbuf_mask: usize,
37    dirty_vbuf_mask: usize,
38    active_first_instance: u32,
39    // The current state of the immediate data block.
40    current_immediates_data: [u32; super::MAX_IMMEDIATES],
41    end_of_pass_timestamp: Option<glow::Query>,
42    clip_distance_count: u32,
43    /// The buffer of the last attribute this encoder pointed.
44    last_attribute_buffer: Option<glow::Buffer>,
45}
46
47impl Default for State {
48    fn default() -> Self {
49        Self {
50            topology: Default::default(),
51            primitive: Default::default(),
52            index_format: Default::default(),
53            index_offset: Default::default(),
54            vertex_buffers: Default::default(),
55            vertex_attributes: Default::default(),
56            color_targets: Default::default(),
57            stencil: Default::default(),
58            depth_bias: Default::default(),
59            alpha_to_coverage_enabled: Default::default(),
60            samplers: Default::default(),
61            texture_slots: Default::default(),
62            render_size: Default::default(),
63            resolve_attachments: Default::default(),
64            invalidate_attachments: Default::default(),
65            has_pass_label: Default::default(),
66            instance_vbuf_mask: Default::default(),
67            dirty_vbuf_mask: Default::default(),
68            active_first_instance: Default::default(),
69            current_immediates_data: [0; super::MAX_IMMEDIATES],
70            end_of_pass_timestamp: Default::default(),
71            clip_distance_count: Default::default(),
72            last_attribute_buffer: Default::default(),
73        }
74    }
75}
76
77impl super::CommandBuffer {
78    fn clear(&mut self) {
79        self.label = None;
80        self.commands.clear();
81        self.data_bytes.clear();
82        self.queries.clear();
83    }
84
85    fn add_marker(&mut self, marker: &str) -> Range<u32> {
86        let start = self.data_bytes.len() as u32;
87        self.data_bytes.extend(marker.as_bytes());
88        start..self.data_bytes.len() as u32
89    }
90
91    fn add_immediates_data(&mut self, data: &[u32]) -> Range<u32> {
92        let data_raw = bytemuck::cast_slice(data);
93        let start = self.data_bytes.len();
94        assert!(start < u32::MAX as usize);
95        self.data_bytes.extend_from_slice(data_raw);
96        let end = self.data_bytes.len();
97        assert!(end < u32::MAX as usize);
98        (start as u32)..(end as u32)
99    }
100}
101
102impl Drop for super::CommandEncoder {
103    fn drop(&mut self) {
104        use crate::CommandEncoder;
105        unsafe { self.discard_encoding() }
106        self.counters.command_encoders.sub(1);
107    }
108}
109
110impl super::CommandEncoder {
111    fn rebind_stencil_func(&mut self) {
112        fn make(s: &super::StencilSide, face: u32) -> C {
113            C::SetStencilFunc {
114                face,
115                function: s.function,
116                reference: s.reference,
117                read_mask: s.mask_read,
118            }
119        }
120
121        let s = &self.state.stencil;
122        if s.front.function == s.back.function
123            && s.front.mask_read == s.back.mask_read
124            && s.front.reference == s.back.reference
125        {
126            self.cmd_buffer
127                .commands
128                .push(make(&s.front, glow::FRONT_AND_BACK));
129        } else {
130            self.cmd_buffer.commands.push(make(&s.front, glow::FRONT));
131            self.cmd_buffer.commands.push(make(&s.back, glow::BACK));
132        }
133    }
134
135    fn rebind_vertex_data(&mut self, first_instance: u32) {
136        if self
137            .private_caps
138            .contains(super::PrivateCapabilities::VERTEX_BUFFER_LAYOUT)
139        {
140            for (index, pair) in self.state.vertex_buffers.iter().enumerate() {
141                if self.state.dirty_vbuf_mask & (1 << index) == 0 {
142                    continue;
143                }
144                let (buffer_desc, vb) = match *pair {
145                    (Some(ref vb_desc), Some(ref vb)) => (vb_desc.clone(), vb),
146                    // Not all dirty bindings are necessarily filled. Some may be unused.
147                    (_, _) => continue,
148                };
149                let instance_offset = match buffer_desc.step {
150                    wgt::VertexStepMode::Vertex => 0,
151                    wgt::VertexStepMode::Instance => first_instance * buffer_desc.stride,
152                };
153
154                self.cmd_buffer.commands.push(C::SetVertexBuffer {
155                    index: index as u32,
156                    buffer: super::BufferBinding {
157                        raw: vb.raw,
158                        offset: vb.offset + instance_offset as wgt::BufferAddress,
159                    },
160                    buffer_desc,
161                });
162                self.state.dirty_vbuf_mask ^= 1 << index;
163            }
164        } else {
165            let mut vbuf_mask = 0;
166            // The buffer the last attribute was pointed into is likely still
167            // bound to `ARRAY_BUFFER`, so its attributes go first: the queue
168            // then binds each other buffer once.
169            let last_buffer = self.state.last_attribute_buffer;
170            for first in [true, false] {
171                for attribute in self.state.vertex_attributes.iter() {
172                    if self.state.dirty_vbuf_mask & (1 << attribute.buffer_index) == 0 {
173                        continue;
174                    }
175                    let (buffer_desc, vb) =
176                        match self.state.vertex_buffers[attribute.buffer_index as usize] {
177                            (Some(ref vb_desc), Some(ref vb)) => (vb_desc.clone(), vb),
178                            // Not all dirty bindings are necessarily filled. Some may be unused.
179                            (_, _) => continue,
180                        };
181                    if (last_buffer == Some(vb.raw)) != first {
182                        continue;
183                    }
184
185                    let mut attribute_desc = attribute.clone();
186                    attribute_desc.offset += vb.offset as u32;
187                    if buffer_desc.step == wgt::VertexStepMode::Instance {
188                        attribute_desc.offset += buffer_desc.stride * first_instance;
189                    }
190
191                    self.cmd_buffer.commands.push(C::SetVertexAttribute {
192                        buffer: Some(vb.raw),
193                        buffer_desc,
194                        attribute_desc,
195                    });
196                    self.state.last_attribute_buffer = Some(vb.raw);
197                    vbuf_mask |= 1 << attribute.buffer_index;
198                }
199            }
200            self.state.dirty_vbuf_mask ^= vbuf_mask;
201        }
202    }
203
204    fn rebind_sampler_states(&mut self, dirty_textures: u32, dirty_samplers: u32) {
205        for (texture_index, slot) in self.state.texture_slots.iter().enumerate() {
206            if dirty_textures & (1 << texture_index) != 0
207                || slot
208                    .sampler_index
209                    .is_some_and(|si| dirty_samplers & (1 << si) != 0)
210            {
211                let sampler = slot
212                    .sampler_index
213                    .and_then(|si| self.state.samplers[si as usize]);
214                self.cmd_buffer
215                    .commands
216                    .push(C::BindSampler(texture_index as u32, sampler));
217            }
218        }
219    }
220
221    fn prepare_draw(&mut self, first_instance: u32) {
222        // If we support fully featured instancing, we want to bind everything as normal
223        // and let the draw call sort it out.
224        let emulated_first_instance_value = if self
225            .private_caps
226            .contains(super::PrivateCapabilities::FULLY_FEATURED_INSTANCING)
227        {
228            0
229        } else {
230            first_instance
231        };
232
233        if emulated_first_instance_value != self.state.active_first_instance {
234            // rebind all per-instance buffers on first-instance change
235            self.state.dirty_vbuf_mask |= self.state.instance_vbuf_mask;
236            self.state.active_first_instance = emulated_first_instance_value;
237        }
238        if self.state.dirty_vbuf_mask != 0 {
239            self.rebind_vertex_data(emulated_first_instance_value);
240        }
241    }
242
243    fn set_pipeline_inner(&mut self, inner: &Arc<super::PipelineInner>) {
244        self.cmd_buffer.commands.push(C::SetProgram(Arc::clone(inner)));
245
246        // rebind textures, if needed
247        let mut dirty_textures = 0u32;
248        for (texture_index, (slot, &sampler_index)) in self
249            .state
250            .texture_slots
251            .iter_mut()
252            .zip(inner.sampler_map.iter())
253            .enumerate()
254        {
255            if slot.sampler_index != sampler_index {
256                slot.sampler_index = sampler_index;
257                dirty_textures |= 1 << texture_index;
258            }
259        }
260        if dirty_textures != 0 {
261            self.rebind_sampler_states(dirty_textures, 0);
262        }
263    }
264}
265
266impl crate::CommandEncoder for super::CommandEncoder {
267    type A = super::Api;
268
269    unsafe fn begin_encoding(&mut self, label: crate::Label) -> Result<(), crate::DeviceError> {
270        self.state = State::default();
271        self.cmd_buffer.label = label.map(String::from);
272        Ok(())
273    }
274    unsafe fn discard_encoding(&mut self) {
275        self.cmd_buffer.clear();
276    }
277    unsafe fn end_encoding(&mut self) -> Result<super::CommandBuffer, crate::DeviceError> {
278        Ok(mem::take(&mut self.cmd_buffer))
279    }
280    unsafe fn reset_all<I>(&mut self, _command_buffers: I) {
281        //TODO: could re-use the allocations in all these command buffers
282    }
283
284    unsafe fn transition_buffers<'a, T>(&mut self, barriers: T)
285    where
286        T: Iterator<Item = crate::BufferBarrier<'a, super::Buffer>>,
287    {
288        if !self
289            .private_caps
290            .contains(super::PrivateCapabilities::MEMORY_BARRIERS)
291        {
292            return;
293        }
294        for bar in barriers {
295            // GLES only synchronizes storage -> anything explicitly
296            if !bar.usage.from.contains(wgt::BufferUses::STORAGE_READ_WRITE) {
297                continue;
298            }
299            self.cmd_buffer
300                .commands
301                .push(C::BufferBarrier(bar.buffer.raw.unwrap(), bar.usage.to));
302        }
303    }
304
305    unsafe fn transition_textures<'a, T>(&mut self, barriers: T)
306    where
307        T: Iterator<Item = crate::TextureBarrier<'a, super::Texture>>,
308    {
309        if !self
310            .private_caps
311            .contains(super::PrivateCapabilities::MEMORY_BARRIERS)
312        {
313            return;
314        }
315
316        let mut combined_usage = wgt::TextureUses::empty();
317        for bar in barriers {
318            // GLES only synchronizes storage -> anything explicitly
319            // if shader writes to a texture then barriers should be placed
320            if !bar.usage.from.intersects(
321                wgt::TextureUses::STORAGE_READ_WRITE | wgt::TextureUses::STORAGE_WRITE_ONLY,
322            ) {
323                continue;
324            }
325            // unlike buffers, there is no need for a concrete texture
326            // object to be bound anywhere for a barrier
327            combined_usage |= bar.usage.to;
328        }
329
330        if !combined_usage.is_empty() {
331            self.cmd_buffer
332                .commands
333                .push(C::TextureBarrier(combined_usage));
334        }
335    }
336
337    unsafe fn clear_buffer(&mut self, buffer: &super::Buffer, range: crate::MemoryRange) {
338        self.cmd_buffer
339            .commands
340            .push(C::ClearBuffer(Box::new(super::ClearBufferOp {
341                dst: buffer.clone(),
342                dst_target: buffer.target,
343                range,
344            })));
345    }
346
347    unsafe fn copy_buffer_to_buffer<T>(
348        &mut self,
349        src: &super::Buffer,
350        dst: &super::Buffer,
351        regions: T,
352    ) where
353        T: Iterator<Item = crate::BufferCopy>,
354    {
355        let (src_target, dst_target) = if src.target == dst.target {
356            (glow::COPY_READ_BUFFER, glow::COPY_WRITE_BUFFER)
357        } else {
358            (src.target, dst.target)
359        };
360        for copy in regions {
361            self.cmd_buffer
362                .commands
363                .push(C::CopyBufferToBuffer(Box::new(super::BufferToBufferCopy {
364                    src: src.clone(),
365                    src_target,
366                    dst: dst.clone(),
367                    dst_target,
368                    copy,
369                })))
370        }
371    }
372
373    #[cfg(webgl)]
374    unsafe fn copy_external_image_to_texture<T>(
375        &mut self,
376        src: &wgt::CopyExternalImageSourceInfo,
377        dst: &super::Texture,
378        dst_premultiplication: bool,
379        regions: T,
380    ) where
381        T: Iterator<Item = crate::TextureCopy>,
382    {
383        let (dst_raw, dst_target) = dst.inner.as_native();
384        for copy in regions {
385            self.cmd_buffer
386                .commands
387                .push(C::CopyExternalImageToTexture(Box::new(
388                    super::ExternalImageToTextureCopy {
389                        src: src.clone(),
390                        dst: dst_raw,
391                        dst_target,
392                        dst_format: dst.format,
393                        dst_premultiplication,
394                        copy,
395                    },
396                )))
397        }
398    }
399
400    unsafe fn copy_texture_to_texture<T>(
401        &mut self,
402        src: &super::Texture,
403        _src_usage: wgt::TextureUses,
404        dst: &super::Texture,
405        regions: T,
406    ) where
407        T: Iterator<Item = crate::TextureCopy>,
408    {
409        for mut copy in regions {
410            copy.clamp_size_to_virtual(&src.copy_size, &dst.copy_size);
411            let command = match (&src.inner, &dst.inner) {
412                (super::TextureInner::DefaultRenderbuffer, _) => {
413                    let (texture, target) = dst.inner.as_native();
414                    C::CopyCanvasToTexture(Box::new(super::CanvasCopy {
415                        texture,
416                        target,
417                        copy,
418                    }))
419                }
420                (_, super::TextureInner::DefaultRenderbuffer) => {
421                    let (texture, target) = src.inner.as_native();
422                    C::CopyTextureToCanvas(Box::new(super::CanvasCopy {
423                        texture,
424                        target,
425                        copy,
426                    }))
427                }
428                _ => {
429                    let (src_raw, src_target) = src.inner.as_native();
430                    let (dst_raw, dst_target) = dst.inner.as_native();
431                    C::CopyTextureToTexture(Box::new(super::TextureToTextureCopy {
432                        src: src_raw,
433                        src_target,
434                        dst: dst_raw,
435                        dst_target,
436                        copy,
437                    }))
438                }
439            };
440            self.cmd_buffer.commands.push(command);
441        }
442    }
443
444    unsafe fn copy_buffer_to_texture<T>(
445        &mut self,
446        src: &super::Buffer,
447        dst: &super::Texture,
448        regions: T,
449    ) where
450        T: Iterator<Item = crate::BufferTextureCopy>,
451    {
452        let (dst_raw, dst_target) = dst.inner.as_native();
453
454        for mut copy in regions {
455            copy.clamp_size_to_virtual(&dst.copy_size);
456            self.cmd_buffer
457                .commands
458                .push(C::CopyBufferToTexture(Box::new(
459                    super::BufferToTextureCopy {
460                        src: src.clone(),
461                        src_target: src.target,
462                        dst: dst_raw,
463                        dst_target,
464                        dst_format: dst.format,
465                        copy,
466                    },
467                )))
468        }
469    }
470
471    unsafe fn copy_texture_to_buffer<T>(
472        &mut self,
473        src: &super::Texture,
474        _src_usage: wgt::TextureUses,
475        dst: &super::Buffer,
476        regions: T,
477    ) where
478        T: Iterator<Item = crate::BufferTextureCopy>,
479    {
480        let (src_raw, src_target) = src.inner.as_native();
481        for mut copy in regions {
482            copy.clamp_size_to_virtual(&src.copy_size);
483            self.cmd_buffer
484                .commands
485                .push(C::CopyTextureToBuffer(Box::new(
486                    super::TextureToBufferCopy {
487                        src: src_raw,
488                        src_target,
489                        src_format: src.format,
490                        dst: dst.clone(),
491                        dst_target: dst.target,
492                        copy,
493                    },
494                )))
495        }
496    }
497
498    unsafe fn begin_query(&mut self, set: &super::QuerySet, index: u32) {
499        let query = set.queries[index as usize];
500        self.cmd_buffer
501            .commands
502            .push(C::BeginQuery(query, set.target));
503    }
504    unsafe fn end_query(&mut self, set: &super::QuerySet, _index: u32) {
505        self.cmd_buffer.commands.push(C::EndQuery(set.target));
506    }
507    unsafe fn write_timestamp(&mut self, set: &super::QuerySet, index: u32) {
508        let query = set.queries[index as usize];
509        self.cmd_buffer.commands.push(C::TimestampQuery(query));
510    }
511    unsafe fn reset_queries(&mut self, _set: &super::QuerySet, _range: Range<u32>) {
512        //TODO: what do we do here?
513    }
514    unsafe fn copy_query_results(
515        &mut self,
516        set: &super::QuerySet,
517        range: Range<u32>,
518        buffer: &super::Buffer,
519        offset: wgt::BufferAddress,
520        _stride: wgt::BufferSize,
521    ) {
522        let start = self.cmd_buffer.queries.len();
523        self.cmd_buffer
524            .queries
525            .extend_from_slice(&set.queries[range.start as usize..range.end as usize]);
526        let query_range = start as u32..self.cmd_buffer.queries.len() as u32;
527        self.cmd_buffer
528            .commands
529            .push(C::CopyQueryResults(Box::new(super::QueryResultsCopy {
530                query_range,
531                dst: buffer.clone(),
532                dst_target: buffer.target,
533                dst_offset: offset,
534            })));
535    }
536
537    // render
538
539    unsafe fn begin_render_pass(
540        &mut self,
541        desc: &crate::RenderPassDescriptor<super::QuerySet, super::TextureView>,
542    ) -> Result<(), crate::DeviceError> {
543        debug_assert!(self.state.end_of_pass_timestamp.is_none());
544        if let Some(ref t) = desc.timestamp_writes {
545            if let Some(index) = t.beginning_of_pass_write_index {
546                unsafe { self.write_timestamp(t.query_set, index) }
547            }
548            self.state.end_of_pass_timestamp = t
549                .end_of_pass_write_index
550                .map(|index| t.query_set.queries[index as usize]);
551        }
552
553        self.state.render_size = desc.extent;
554        self.state.resolve_attachments.clear();
555        self.state.invalidate_attachments.clear();
556        if let Some(label) = desc.label {
557            let range = self.cmd_buffer.add_marker(label);
558            self.cmd_buffer.commands.push(C::PushDebugGroup(range));
559            self.state.has_pass_label = true;
560        }
561
562        let rendering_to_external_framebuffer = desc
563            .color_attachments
564            .iter()
565            .filter_map(|at| at.as_ref())
566            .any(|at| match at.target.view.inner {
567                #[cfg(webgl)]
568                super::TextureInner::ExternalFramebuffer { .. } => true,
569                #[cfg(native)]
570                super::TextureInner::ExternalNativeFramebuffer { .. } => true,
571                _ => false,
572            });
573
574        if rendering_to_external_framebuffer && desc.color_attachments.len() != 1 {
575            panic!("Multiple render attachments with external framebuffers are not supported.");
576        }
577
578        // `COLOR_ATTACHMENT0` to `COLOR_ATTACHMENT31` gives 32 possible color attachments.
579        assert!(desc.color_attachments.len() <= 32);
580
581        match desc
582            .color_attachments
583            .first()
584            .filter(|at| at.is_some())
585            .and_then(|at| at.as_ref().map(|at| &at.target.view.inner))
586        {
587            // default framebuffer (provided externally, or a web canvas a
588            // surface draws into, whose own depth and stencil the pass uses)
589            Some(&super::TextureInner::DefaultRenderbuffer) => {
590                self.cmd_buffer
591                    .commands
592                    .push(C::ResetFramebuffer { is_default: true });
593                if let Some(ref dsat) = desc.depth_stencil_attachment {
594                    if dsat.depth_ops.contains(crate::AttachmentOps::STORE_DISCARD) {
595                        self.state.invalidate_attachments.push(glow::DEPTH);
596                    }
597                    if dsat.stencil_ops.contains(crate::AttachmentOps::STORE_DISCARD) {
598                        self.state.invalidate_attachments.push(glow::STENCIL);
599                    }
600                }
601            }
602            _ => {
603                // set the framebuffer
604                self.cmd_buffer
605                    .commands
606                    .push(C::ResetFramebuffer { is_default: false });
607
608                for (i, cat) in desc.color_attachments.iter().enumerate() {
609                    if let Some(cat) = cat.as_ref() {
610                        let attachment = glow::COLOR_ATTACHMENT0 + i as u32;
611                        // Try to use the multisampled render-to-texture extension to avoid resolving
612                        if let Some(ref rat) = cat.resolve_target {
613                            if matches!(rat.view.inner, super::TextureInner::Texture { .. })
614                                && self.private_caps.contains(
615                                    super::PrivateCapabilities::MULTISAMPLED_RENDER_TO_TEXTURE,
616                                )
617                                && !cat.ops.contains(crate::AttachmentOps::STORE)
618                                // Extension specifies that only COLOR_ATTACHMENT0 is valid
619                                && i == 0
620                            {
621                                self.cmd_buffer.commands.push(C::BindAttachment(Box::new(
622                                    super::AttachmentBinding {
623                                        attachment,
624                                        view: rat.view.clone(),
625                                        depth_slice: None,
626                                        sample_count: desc.sample_count,
627                                    },
628                                )));
629                                continue;
630                            }
631                        }
632                        self.cmd_buffer.commands.push(C::BindAttachment(Box::new(
633                            super::AttachmentBinding {
634                                attachment,
635                                view: cat.target.view.clone(),
636                                depth_slice: cat.depth_slice,
637                                sample_count: 1,
638                            },
639                        )));
640                        if let Some(ref rat) = cat.resolve_target {
641                            self.state
642                                .resolve_attachments
643                                .push((attachment, rat.view.clone()));
644                        }
645                        if cat.ops.contains(crate::AttachmentOps::STORE_DISCARD) {
646                            self.state.invalidate_attachments.push(attachment);
647                        }
648                    }
649                }
650                if let Some(ref dsat) = desc.depth_stencil_attachment {
651                    let aspects = dsat.target.view.aspects;
652                    let attachment = match aspects {
653                        crate::FormatAspects::DEPTH => glow::DEPTH_ATTACHMENT,
654                        crate::FormatAspects::STENCIL => glow::STENCIL_ATTACHMENT,
655                        _ => glow::DEPTH_STENCIL_ATTACHMENT,
656                    };
657                    self.cmd_buffer.commands.push(C::BindAttachment(Box::new(
658                        super::AttachmentBinding {
659                            attachment,
660                            view: dsat.target.view.clone(),
661                            depth_slice: None,
662                            sample_count: 1,
663                        },
664                    )));
665                    if aspects.contains(crate::FormatAspects::DEPTH)
666                        && dsat.depth_ops.contains(crate::AttachmentOps::STORE_DISCARD)
667                    {
668                        self.state
669                            .invalidate_attachments
670                            .push(glow::DEPTH_ATTACHMENT);
671                    }
672                    if aspects.contains(crate::FormatAspects::STENCIL)
673                        && dsat
674                            .stencil_ops
675                            .contains(crate::AttachmentOps::STORE_DISCARD)
676                    {
677                        self.state
678                            .invalidate_attachments
679                            .push(glow::STENCIL_ATTACHMENT);
680                    }
681                }
682            }
683        }
684
685        let rect = crate::Rect {
686            x: 0,
687            y: 0,
688            w: desc.extent.width as i32,
689            h: desc.extent.height as i32,
690        };
691        self.cmd_buffer.commands.push(C::SetScissor(rect.clone()));
692        self.cmd_buffer.commands.push(C::SetViewport {
693            rect,
694            depth: 0.0..1.0,
695        });
696
697        // The default framebuffer draws into its back buffer, which
698        // `drawBuffers` cannot name as a color attachment.
699        let rendering_to_default_framebuffer = matches!(
700            desc.color_attachments
701                .first()
702                .and_then(|at| at.as_ref())
703                .map(|at| &at.target.view.inner),
704            Some(super::TextureInner::DefaultRenderbuffer)
705        );
706        if !rendering_to_external_framebuffer && !rendering_to_default_framebuffer {
707            // set the draw buffers and states
708            self.cmd_buffer
709                .commands
710                .push(C::SetDrawColorBuffers(desc.color_attachments.len() as u8));
711        }
712
713        // issue the clears
714        for (i, cat) in desc
715            .color_attachments
716            .iter()
717            .filter_map(|at| at.as_ref())
718            .enumerate()
719        {
720            if cat.ops.contains(crate::AttachmentOps::LOAD_CLEAR) {
721                let c = &cat.clear_value;
722                self.cmd_buffer.commands.push(
723                    match cat.target.view.format.sample_type(None, None).unwrap() {
724                        wgt::TextureSampleType::Float { .. } => C::ClearColorF {
725                            draw_buffer: i as u32,
726                            color: [c.r as f32, c.g as f32, c.b as f32, c.a as f32],
727                            is_srgb: cat.target.view.format.is_srgb(),
728                        },
729                        wgt::TextureSampleType::Uint => C::ClearColorU(
730                            i as u32,
731                            [c.r as u32, c.g as u32, c.b as u32, c.a as u32],
732                        ),
733                        wgt::TextureSampleType::Sint => C::ClearColorI(
734                            i as u32,
735                            [c.r as i32, c.g as i32, c.b as i32, c.a as i32],
736                        ),
737                        wgt::TextureSampleType::Depth => unreachable!(),
738                    },
739                );
740            }
741        }
742
743        if let Some(ref dsat) = desc.depth_stencil_attachment {
744            let clear_depth = dsat.depth_ops.contains(crate::AttachmentOps::LOAD_CLEAR);
745            let clear_stencil = dsat.stencil_ops.contains(crate::AttachmentOps::LOAD_CLEAR);
746
747            if clear_depth && clear_stencil {
748                self.cmd_buffer.commands.push(C::ClearDepthAndStencil(
749                    dsat.clear_value.0,
750                    dsat.clear_value.1,
751                ));
752            } else if clear_depth {
753                self.cmd_buffer
754                    .commands
755                    .push(C::ClearDepth(dsat.clear_value.0));
756            } else if clear_stencil {
757                self.cmd_buffer
758                    .commands
759                    .push(C::ClearStencil(dsat.clear_value.1));
760            }
761        }
762        Ok(())
763    }
764    unsafe fn end_render_pass(&mut self) {
765        for (attachment, dst) in self.state.resolve_attachments.drain(..) {
766            self.cmd_buffer.commands.push(C::ResolveAttachment(Box::new(
767                super::AttachmentResolve {
768                    attachment,
769                    dst,
770                    size: self.state.render_size,
771                },
772            )));
773        }
774        if !self.state.invalidate_attachments.is_empty() {
775            self.cmd_buffer.commands.push(C::InvalidateAttachments(
776                self.state.invalidate_attachments.clone(),
777            ));
778            self.state.invalidate_attachments.clear();
779        }
780        if self.state.has_pass_label {
781            self.cmd_buffer.commands.push(C::PopDebugGroup);
782            self.state.has_pass_label = false;
783        }
784        self.state.instance_vbuf_mask = 0;
785        self.state.dirty_vbuf_mask = 0;
786        self.state.active_first_instance = 0;
787        self.state.color_targets.clear();
788        for vat in &self.state.vertex_attributes {
789            self.cmd_buffer
790                .commands
791                .push(C::UnsetVertexAttribute(vat.location));
792        }
793        self.state.vertex_attributes.clear();
794        self.state.primitive = super::PrimitiveState::default();
795
796        if let Some(query) = self.state.end_of_pass_timestamp.take() {
797            self.cmd_buffer.commands.push(C::TimestampQuery(query));
798        }
799    }
800
801    unsafe fn set_bind_group(
802        &mut self,
803        layout: &super::PipelineLayout,
804        index: u32,
805        group: &super::BindGroup,
806        dynamic_offsets: &[wgt::DynamicOffset],
807    ) {
808        let mut do_index = 0;
809        let mut dirty_textures = 0u32;
810        let mut dirty_samplers = 0u32;
811        let group_info = layout.group_infos[index as usize].as_ref().unwrap();
812
813        for (binding_layout, raw_binding) in group_info.entries.iter().zip(group.contents.iter()) {
814            let slot = group_info.binding_to_slot[binding_layout.binding as usize] as u32;
815            match *raw_binding {
816                super::RawBinding::Buffer {
817                    raw,
818                    offset: base_offset,
819                    size,
820                } => {
821                    let mut offset = base_offset;
822                    let target = match binding_layout.ty {
823                        wgt::BindingType::Buffer {
824                            ty,
825                            has_dynamic_offset,
826                            min_binding_size: _,
827                        } => {
828                            if has_dynamic_offset {
829                                offset += dynamic_offsets[do_index] as i32;
830                                do_index += 1;
831                            }
832                            match ty {
833                                wgt::BufferBindingType::Uniform => glow::UNIFORM_BUFFER,
834                                wgt::BufferBindingType::Storage { .. } => {
835                                    glow::SHADER_STORAGE_BUFFER
836                                }
837                            }
838                        }
839                        _ => unreachable!(),
840                    };
841                    self.cmd_buffer.commands.push(C::BindBuffer {
842                        target,
843                        slot,
844                        buffer: raw,
845                        offset,
846                        size,
847                    });
848                }
849                super::RawBinding::Sampler(sampler) => {
850                    dirty_samplers |= 1 << slot;
851                    self.state.samplers[slot as usize] = Some(sampler);
852                }
853                super::RawBinding::Texture {
854                    raw,
855                    target,
856                    aspects,
857                    ref mip_levels,
858                } => {
859                    dirty_textures |= 1 << slot;
860                    self.state.texture_slots[slot as usize].tex_target = target;
861                    self.cmd_buffer.commands.push(C::BindTexture {
862                        slot,
863                        texture: raw,
864                        target,
865                        aspects,
866                        mip_levels: mip_levels.clone(),
867                    });
868                }
869                super::RawBinding::Image(ref binding) => {
870                    self.cmd_buffer.commands.push(C::BindImage {
871                        slot,
872                        binding: binding.clone(),
873                    });
874                }
875            }
876        }
877
878        self.rebind_sampler_states(dirty_textures, dirty_samplers);
879    }
880
881    unsafe fn set_immediates(
882        &mut self,
883        _layout: &super::PipelineLayout,
884        offset_bytes: u32,
885        data: &[u32],
886    ) {
887        // There is nothing preventing the user from trying to update a single value within
888        // a vector or matrix in the set_immediates call, as to the user, all of this is
889        // just memory. However OpenGL does not allow partial uniform updates.
890        //
891        // As such, we locally keep a copy of the current state of the immediate data memory
892        // block. If the user tries to update a single value, we have the data to update the entirety
893        // of the uniform.
894        let start_words = offset_bytes / 4;
895        let end_words = start_words + data.len() as u32;
896        self.state.current_immediates_data[start_words as usize..end_words as usize]
897            .copy_from_slice(data);
898
899        // The program's uniforms are known once it links, when the queue
900        // runs this: it sets each of them from the whole block.
901        let data = self
902            .cmd_buffer
903            .add_immediates_data(&self.state.current_immediates_data);
904        self.cmd_buffer.commands.push(C::SetImmediates { data });
905    }
906
907    unsafe fn insert_debug_marker(&mut self, label: &str) {
908        let range = self.cmd_buffer.add_marker(label);
909        self.cmd_buffer.commands.push(C::InsertDebugMarker(range));
910    }
911    unsafe fn begin_debug_marker(&mut self, group_label: &str) {
912        let range = self.cmd_buffer.add_marker(group_label);
913        self.cmd_buffer.commands.push(C::PushDebugGroup(range));
914    }
915    unsafe fn end_debug_marker(&mut self) {
916        self.cmd_buffer.commands.push(C::PopDebugGroup);
917    }
918
919    unsafe fn set_render_pipeline(&mut self, pipeline: &super::RenderPipeline) {
920        self.state.topology = conv::map_primitive_topology(pipeline.primitive.topology);
921
922        if self
923            .private_caps
924            .contains(super::PrivateCapabilities::VERTEX_BUFFER_LAYOUT)
925        {
926            for vat in pipeline.vertex_attributes.iter() {
927                let vb = pipeline.vertex_buffers[vat.buffer_index as usize]
928                    .as_ref()
929                    .unwrap();
930                // set the layout
931                self.cmd_buffer.commands.push(C::SetVertexAttribute {
932                    buffer: None,
933                    buffer_desc: vb.clone(),
934                    attribute_desc: vat.clone(),
935                });
936            }
937        } else {
938            for vat in &self.state.vertex_attributes {
939                self.cmd_buffer
940                    .commands
941                    .push(C::UnsetVertexAttribute(vat.location));
942            }
943            self.state.vertex_attributes.clear();
944
945            self.state.dirty_vbuf_mask = 0;
946            // copy vertex attributes
947            for vat in pipeline.vertex_attributes.iter() {
948                //Note: we can invalidate more carefully here.
949                self.state.dirty_vbuf_mask |= 1 << vat.buffer_index;
950                self.state.vertex_attributes.push(vat.clone());
951            }
952        }
953
954        self.state.instance_vbuf_mask = 0;
955        // copy vertex state
956        for (index, (&mut (ref mut state_desc, _), pipe_desc)) in self
957            .state
958            .vertex_buffers
959            .iter_mut()
960            .zip(pipeline.vertex_buffers.iter())
961            .enumerate()
962        {
963            let Some(pipe_desc) = pipe_desc else {
964                continue;
965            };
966            if pipe_desc.step == wgt::VertexStepMode::Instance {
967                self.state.instance_vbuf_mask |= 1 << index;
968            }
969            if state_desc.as_ref() != Some(pipe_desc) {
970                self.state.dirty_vbuf_mask |= 1 << index;
971                *state_desc = Some(pipe_desc.clone());
972            }
973        }
974
975        self.set_pipeline_inner(&pipeline.inner);
976
977        // set primitive state
978        let prim_state = conv::map_primitive_state(&pipeline.primitive);
979        if prim_state != self.state.primitive {
980            self.cmd_buffer
981                .commands
982                .push(C::SetPrimitive(prim_state.clone()));
983            self.state.primitive = prim_state;
984        }
985
986        // set depth/stencil states
987        let mut aspects = crate::FormatAspects::empty();
988        if pipeline.depth_bias != self.state.depth_bias {
989            self.state.depth_bias = pipeline.depth_bias;
990            self.cmd_buffer
991                .commands
992                .push(C::SetDepthBias(pipeline.depth_bias));
993        }
994        if let Some(ref depth) = pipeline.depth {
995            aspects |= crate::FormatAspects::DEPTH;
996            self.cmd_buffer.commands.push(C::SetDepth(depth.clone()));
997        }
998        if let Some(ref stencil) = pipeline.stencil {
999            aspects |= crate::FormatAspects::STENCIL;
1000            self.state.stencil = stencil.clone();
1001            self.rebind_stencil_func();
1002            if stencil.front.ops == stencil.back.ops
1003                && stencil.front.mask_write == stencil.back.mask_write
1004            {
1005                self.cmd_buffer.commands.push(C::SetStencilOps {
1006                    face: glow::FRONT_AND_BACK,
1007                    write_mask: stencil.front.mask_write,
1008                    ops: stencil.front.ops.clone(),
1009                });
1010            } else {
1011                self.cmd_buffer.commands.push(C::SetStencilOps {
1012                    face: glow::FRONT,
1013                    write_mask: stencil.front.mask_write,
1014                    ops: stencil.front.ops.clone(),
1015                });
1016                self.cmd_buffer.commands.push(C::SetStencilOps {
1017                    face: glow::BACK,
1018                    write_mask: stencil.back.mask_write,
1019                    ops: stencil.back.ops.clone(),
1020                });
1021            }
1022        }
1023        self.cmd_buffer
1024            .commands
1025            .push(C::ConfigureDepthStencil(aspects));
1026
1027        // set multisampling state
1028        if pipeline.alpha_to_coverage_enabled != self.state.alpha_to_coverage_enabled {
1029            self.state.alpha_to_coverage_enabled = pipeline.alpha_to_coverage_enabled;
1030            self.cmd_buffer
1031                .commands
1032                .push(C::SetAlphaToCoverage(pipeline.alpha_to_coverage_enabled));
1033        }
1034
1035        // set blend states
1036        if self.state.color_targets[..] != pipeline.color_targets[..] {
1037            if pipeline
1038                .color_targets
1039                .iter()
1040                .skip(1)
1041                .any(|ct| *ct != pipeline.color_targets[0])
1042            {
1043                for (index, ct) in pipeline.color_targets.iter().enumerate() {
1044                    self.cmd_buffer.commands.push(C::SetColorTarget {
1045                        draw_buffer_index: Some(index as u32),
1046                        desc: ct.clone(),
1047                    });
1048                }
1049            } else {
1050                self.cmd_buffer.commands.push(C::SetColorTarget {
1051                    draw_buffer_index: None,
1052                    desc: pipeline.color_targets.first().cloned().unwrap_or_default(),
1053                });
1054            }
1055        }
1056        self.state.color_targets.clear();
1057        for ct in pipeline.color_targets.iter() {
1058            self.state.color_targets.push(ct.clone());
1059        }
1060
1061        // set clip plane count
1062        if pipeline.inner.clip_distance_count != self.state.clip_distance_count {
1063            self.cmd_buffer.commands.push(C::SetClipDistances {
1064                old_count: self.state.clip_distance_count,
1065                new_count: pipeline.inner.clip_distance_count,
1066            });
1067            self.state.clip_distance_count = pipeline.inner.clip_distance_count;
1068        }
1069    }
1070
1071    unsafe fn set_index_buffer<'a>(
1072        &mut self,
1073        binding: crate::BufferBinding<'a, super::Buffer>,
1074        format: wgt::IndexFormat,
1075    ) {
1076        self.state.index_offset = binding.offset;
1077        self.state.index_format = format;
1078        self.cmd_buffer
1079            .commands
1080            .push(C::SetIndexBuffer(binding.buffer.raw.unwrap()));
1081    }
1082    unsafe fn set_vertex_buffer<'a>(
1083        &mut self,
1084        index: u32,
1085        binding: crate::BufferBinding<'a, super::Buffer>,
1086    ) {
1087        self.state.dirty_vbuf_mask |= 1 << index;
1088        let (_, ref mut vb) = self.state.vertex_buffers[index as usize];
1089        *vb = Some(super::BufferBinding {
1090            raw: binding.buffer.raw.unwrap(),
1091            offset: binding.offset,
1092        });
1093    }
1094    unsafe fn set_viewport(&mut self, rect: &crate::Rect<f32>, depth: Range<f32>) {
1095        self.cmd_buffer.commands.push(C::SetViewport {
1096            rect: crate::Rect {
1097                x: rect.x as i32,
1098                y: rect.y as i32,
1099                w: rect.w as i32,
1100                h: rect.h as i32,
1101            },
1102            depth,
1103        });
1104    }
1105    unsafe fn set_scissor_rect(&mut self, rect: &crate::Rect<u32>) {
1106        self.cmd_buffer.commands.push(C::SetScissor(crate::Rect {
1107            x: rect.x as i32,
1108            y: rect.y as i32,
1109            w: rect.w as i32,
1110            h: rect.h as i32,
1111        }));
1112    }
1113    unsafe fn set_stencil_reference(&mut self, value: u32) {
1114        self.state.stencil.front.reference = value;
1115        self.state.stencil.back.reference = value;
1116        self.rebind_stencil_func();
1117    }
1118    unsafe fn set_blend_constants(&mut self, color: &[f32; 4]) {
1119        self.cmd_buffer.commands.push(C::SetBlendConstant(*color));
1120    }
1121
1122    unsafe fn draw(
1123        &mut self,
1124        first_vertex: u32,
1125        vertex_count: u32,
1126        first_instance: u32,
1127        instance_count: u32,
1128    ) {
1129        self.prepare_draw(first_instance);
1130        self.cmd_buffer.commands.push(C::Draw {
1131            topology: self.state.topology,
1132            first_vertex,
1133            vertex_count,
1134            first_instance,
1135            instance_count,
1136        });
1137    }
1138    unsafe fn draw_indexed(
1139        &mut self,
1140        first_index: u32,
1141        index_count: u32,
1142        base_vertex: i32,
1143        first_instance: u32,
1144        instance_count: u32,
1145    ) {
1146        self.prepare_draw(first_instance);
1147        let (index_size, index_type) = match self.state.index_format {
1148            wgt::IndexFormat::Uint16 => (2, glow::UNSIGNED_SHORT),
1149            wgt::IndexFormat::Uint32 => (4, glow::UNSIGNED_INT),
1150        };
1151        let index_offset = self.state.index_offset + index_size * first_index as wgt::BufferAddress;
1152        self.cmd_buffer.commands.push(C::DrawIndexed {
1153            topology: self.state.topology,
1154            index_type,
1155            index_offset,
1156            index_count,
1157            base_vertex,
1158            first_instance,
1159            instance_count,
1160        });
1161    }
1162    unsafe fn draw_mesh_tasks(
1163        &mut self,
1164        _group_count_x: u32,
1165        _group_count_y: u32,
1166        _group_count_z: u32,
1167    ) {
1168        unreachable!()
1169    }
1170    unsafe fn draw_indirect(
1171        &mut self,
1172        buffer: &super::Buffer,
1173        offset: wgt::BufferAddress,
1174        draw_count: u32,
1175    ) {
1176        self.prepare_draw(0);
1177        for draw in 0..draw_count as wgt::BufferAddress {
1178            let indirect_offset =
1179                offset + draw * size_of::<wgt::DrawIndirectArgs>() as wgt::BufferAddress;
1180            self.cmd_buffer.commands.push(C::DrawIndirect {
1181                topology: self.state.topology,
1182                indirect_buf: buffer.raw.unwrap(),
1183                indirect_offset,
1184            });
1185        }
1186    }
1187    unsafe fn draw_indexed_indirect(
1188        &mut self,
1189        buffer: &super::Buffer,
1190        offset: wgt::BufferAddress,
1191        draw_count: u32,
1192    ) {
1193        self.prepare_draw(0);
1194        let index_type = match self.state.index_format {
1195            wgt::IndexFormat::Uint16 => glow::UNSIGNED_SHORT,
1196            wgt::IndexFormat::Uint32 => glow::UNSIGNED_INT,
1197        };
1198        for draw in 0..draw_count as wgt::BufferAddress {
1199            let indirect_offset =
1200                offset + draw * size_of::<wgt::DrawIndexedIndirectArgs>() as wgt::BufferAddress;
1201            self.cmd_buffer.commands.push(C::DrawIndexedIndirect {
1202                topology: self.state.topology,
1203                index_type,
1204                indirect_buf: buffer.raw.unwrap(),
1205                indirect_offset,
1206            });
1207        }
1208    }
1209    unsafe fn draw_mesh_tasks_indirect(
1210        &mut self,
1211        _buffer: &<Self::A as crate::Api>::Buffer,
1212        _offset: wgt::BufferAddress,
1213        _draw_count: u32,
1214    ) {
1215        unreachable!()
1216    }
1217    unsafe fn draw_indirect_count(
1218        &mut self,
1219        _buffer: &super::Buffer,
1220        _offset: wgt::BufferAddress,
1221        _count_buffer: &super::Buffer,
1222        _count_offset: wgt::BufferAddress,
1223        _max_count: u32,
1224    ) {
1225        unreachable!()
1226    }
1227    unsafe fn draw_indexed_indirect_count(
1228        &mut self,
1229        _buffer: &super::Buffer,
1230        _offset: wgt::BufferAddress,
1231        _count_buffer: &super::Buffer,
1232        _count_offset: wgt::BufferAddress,
1233        _max_count: u32,
1234    ) {
1235        unreachable!()
1236    }
1237    unsafe fn draw_mesh_tasks_indirect_count(
1238        &mut self,
1239        _buffer: &<Self::A as crate::Api>::Buffer,
1240        _offset: wgt::BufferAddress,
1241        _count_buffer: &<Self::A as crate::Api>::Buffer,
1242        _count_offset: wgt::BufferAddress,
1243        _max_count: u32,
1244    ) {
1245        unreachable!()
1246    }
1247
1248    // compute
1249
1250    unsafe fn begin_compute_pass(&mut self, desc: &crate::ComputePassDescriptor<super::QuerySet>) {
1251        debug_assert!(self.state.end_of_pass_timestamp.is_none());
1252        if let Some(ref t) = desc.timestamp_writes {
1253            if let Some(index) = t.beginning_of_pass_write_index {
1254                unsafe { self.write_timestamp(t.query_set, index) }
1255            }
1256            self.state.end_of_pass_timestamp = t
1257                .end_of_pass_write_index
1258                .map(|index| t.query_set.queries[index as usize]);
1259        }
1260
1261        if let Some(label) = desc.label {
1262            let range = self.cmd_buffer.add_marker(label);
1263            self.cmd_buffer.commands.push(C::PushDebugGroup(range));
1264            self.state.has_pass_label = true;
1265        }
1266    }
1267    unsafe fn end_compute_pass(&mut self) {
1268        if self.state.has_pass_label {
1269            self.cmd_buffer.commands.push(C::PopDebugGroup);
1270            self.state.has_pass_label = false;
1271        }
1272
1273        if let Some(query) = self.state.end_of_pass_timestamp.take() {
1274            self.cmd_buffer.commands.push(C::TimestampQuery(query));
1275        }
1276    }
1277
1278    unsafe fn set_compute_pipeline(&mut self, pipeline: &super::ComputePipeline) {
1279        self.set_pipeline_inner(&pipeline.inner);
1280    }
1281
1282    unsafe fn dispatch_workgroups(&mut self, count: [u32; 3]) {
1283        // Empty dispatches are invalid in OpenGL, but valid in WebGPU.
1284        if count.contains(&0) {
1285            return;
1286        }
1287        self.cmd_buffer.commands.push(C::Dispatch(count));
1288    }
1289    unsafe fn dispatch_workgroups_indirect(
1290        &mut self,
1291        buffer: &super::Buffer,
1292        offset: wgt::BufferAddress,
1293    ) {
1294        self.cmd_buffer.commands.push(C::DispatchIndirect {
1295            indirect_buf: buffer.raw.unwrap(),
1296            indirect_offset: offset,
1297        });
1298    }
1299
1300    unsafe fn build_acceleration_structures<'a, T>(
1301        &mut self,
1302        _descriptor_count: u32,
1303        _descriptors: T,
1304    ) where
1305        super::Api: 'a,
1306        T: IntoIterator<
1307            Item = crate::BuildAccelerationStructureDescriptor<
1308                'a,
1309                super::Buffer,
1310                super::AccelerationStructure,
1311            >,
1312        >,
1313    {
1314        unimplemented!()
1315    }
1316
1317    unsafe fn place_acceleration_structure_barrier(
1318        &mut self,
1319        _barriers: crate::AccelerationStructureBarrier,
1320    ) {
1321        unimplemented!()
1322    }
1323
1324    unsafe fn copy_acceleration_structure_to_acceleration_structure(
1325        &mut self,
1326        _src: &super::AccelerationStructure,
1327        _dst: &super::AccelerationStructure,
1328        _copy: wgt::AccelerationStructureCopy,
1329    ) {
1330        unimplemented!()
1331    }
1332
1333    unsafe fn read_acceleration_structure_compact_size(
1334        &mut self,
1335        _acceleration_structure: &super::AccelerationStructure,
1336        _buf: &super::Buffer,
1337    ) {
1338        unimplemented!()
1339    }
1340
1341    unsafe fn set_acceleration_structure_dependencies(
1342        _command_buffers: &[&super::CommandBuffer],
1343        _dependencies: &[&super::AccelerationStructure],
1344    ) {
1345        unimplemented!()
1346    }
1347
1348    unsafe fn begin_ray_tracing_pass(&mut self, _desc: &crate::RayTracingPassDescriptor) {
1349        unimplemented!()
1350    }
1351
1352    unsafe fn end_ray_tracing_pass(&mut self) {
1353        unimplemented!()
1354    }
1355
1356    unsafe fn set_ray_tracing_pipeline(
1357        &mut self,
1358        _pipeline: &<Self::A as crate::Api>::RayTracingPipeline,
1359    ) {
1360        unimplemented!()
1361    }
1362
1363    unsafe fn trace_rays(
1364        &mut self,
1365        _count: [u32; 3],
1366        _ray_generation_group_data: crate::PipelineGroupData<super::Buffer>,
1367        _miss_group_data: crate::PipelineGroupData<super::Buffer>,
1368        _intersection_group_data: crate::PipelineGroupData<super::Buffer>,
1369    ) {
1370        unimplemented!()
1371    }
1372}