summaryrefslogtreecommitdiffstats
path: root/third_party/rust/metal/src/commandbuffer.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /third_party/rust/metal/src/commandbuffer.rs
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/metal/src/commandbuffer.rs')
-rw-r--r--third_party/rust/metal/src/commandbuffer.rs158
1 files changed, 158 insertions, 0 deletions
diff --git a/third_party/rust/metal/src/commandbuffer.rs b/third_party/rust/metal/src/commandbuffer.rs
new file mode 100644
index 0000000000..32a1d8fb94
--- /dev/null
+++ b/third_party/rust/metal/src/commandbuffer.rs
@@ -0,0 +1,158 @@
+// Copyright 2016 GFX developers
+//
+// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
+// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
+// http://opensource.org/licenses/MIT>, at your option. This file may not be
+// copied, modified, or distributed except according to those terms.
+
+use super::*;
+
+use block::Block;
+
+#[repr(u32)]
+#[allow(non_camel_case_types)]
+#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
+pub enum MTLCommandBufferStatus {
+ NotEnqueued = 0,
+ Enqueued = 1,
+ Committed = 2,
+ Scheduled = 3,
+ Completed = 4,
+ Error = 5,
+}
+
+#[repr(u32)]
+#[allow(non_camel_case_types)]
+#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
+pub enum MTLCommandBufferError {
+ None = 0,
+ Internal = 1,
+ Timeout = 2,
+ PageFault = 3,
+ Blacklisted = 4,
+ NotPermitted = 7,
+ OutOfMemory = 8,
+ InvalidResource = 9,
+ Memoryless = 10,
+ DeviceRemoved = 11,
+}
+
+#[repr(u32)]
+#[allow(non_camel_case_types)]
+#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
+pub enum MTLDispatchType {
+ Serial = 0,
+ Concurrent = 1,
+}
+
+type CommandBufferHandler<'a> = Block<(&'a CommandBufferRef,), ()>;
+
+pub enum MTLCommandBuffer {}
+
+foreign_obj_type! {
+ type CType = MTLCommandBuffer;
+ pub struct CommandBuffer;
+ pub struct CommandBufferRef;
+}
+
+impl CommandBufferRef {
+ pub fn label(&self) -> &str {
+ unsafe {
+ let label = msg_send![self, label];
+ crate::nsstring_as_str(label)
+ }
+ }
+
+ pub fn set_label(&self, label: &str) {
+ unsafe {
+ let nslabel = crate::nsstring_from_str(label);
+ let () = msg_send![self, setLabel: nslabel];
+ }
+ }
+
+ pub fn enqueue(&self) {
+ unsafe { msg_send![self, enqueue] }
+ }
+
+ pub fn commit(&self) {
+ unsafe { msg_send![self, commit] }
+ }
+
+ pub fn status(&self) -> MTLCommandBufferStatus {
+ unsafe { msg_send![self, status] }
+ }
+
+ pub fn present_drawable(&self, drawable: &DrawableRef) {
+ unsafe { msg_send![self, presentDrawable: drawable] }
+ }
+
+ pub fn wait_until_completed(&self) {
+ unsafe { msg_send![self, waitUntilCompleted] }
+ }
+
+ pub fn wait_until_scheduled(&self) {
+ unsafe { msg_send![self, waitUntilScheduled] }
+ }
+
+ pub fn add_completed_handler(&self, block: &CommandBufferHandler) {
+ unsafe { msg_send![self, addCompletedHandler: block] }
+ }
+
+ pub fn new_blit_command_encoder(&self) -> &BlitCommandEncoderRef {
+ unsafe { msg_send![self, blitCommandEncoder] }
+ }
+
+ pub fn new_compute_command_encoder(&self) -> &ComputeCommandEncoderRef {
+ unsafe { msg_send![self, computeCommandEncoder] }
+ }
+
+ pub fn new_render_command_encoder(
+ &self,
+ descriptor: &RenderPassDescriptorRef,
+ ) -> &RenderCommandEncoderRef {
+ unsafe { msg_send![self, renderCommandEncoderWithDescriptor: descriptor] }
+ }
+
+ pub fn new_parallel_render_command_encoder(
+ &self,
+ descriptor: &RenderPassDescriptorRef,
+ ) -> &ParallelRenderCommandEncoderRef {
+ unsafe { msg_send![self, parallelRenderCommandEncoderWithDescriptor: descriptor] }
+ }
+
+ pub fn compute_command_encoder_with_dispatch_type(
+ &self,
+ ty: MTLDispatchType,
+ ) -> &ComputeCommandEncoderRef {
+ unsafe { msg_send![self, computeCommandEncoderWithDispatchType: ty] }
+ }
+
+ pub fn encode_signal_event(&self, event: &EventRef, new_value: u64) {
+ unsafe {
+ msg_send![self,
+ encodeSignalEvent: event
+ value: new_value
+ ]
+ }
+ }
+
+ pub fn encode_wait_for_event(&self, event: &EventRef, value: u64) {
+ unsafe {
+ msg_send![self,
+ encodeWaitForEvent: event
+ value: value
+ ]
+ }
+ }
+
+ pub fn push_debug_group(&self, name: &str) {
+ unsafe {
+ let nslabel = crate::nsstring_from_str(name);
+ msg_send![self, pushDebugGroup: nslabel]
+ }
+ }
+
+ pub fn pop_debug_group(&self) {
+ unsafe { msg_send![self, popDebugGroup] }
+ }
+}