Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AccelerationStructurePassDescriptor #337

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
108 changes: 108 additions & 0 deletions src/acceleration_structure_pass.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
use super::{CounterSampleBufferRef, NSUInteger};

/// See <https://developer.apple.com/documentation/metal/mtlaccelerationstructurepassdescriptor>
pub enum MTLAccelerationStructurePassDescriptor {}

foreign_obj_type! {
type CType = MTLAccelerationStructurePassDescriptor;
pub struct AccelerationStructurePassDescriptor;
}

impl AccelerationStructurePassDescriptor {
/// Creates a default compute pass descriptor with no attachments.
pub fn new<'a>() -> &'a AccelerationStructurePassDescriptorRef {
unsafe {
msg_send![
class!(MTLAccelerationStructurePassDescriptor),
accelerationStructurePassDescriptor
]
}
}
}

impl AccelerationStructurePassDescriptorRef {
pub fn sample_buffer_attachments(
&self,
) -> &AccelerationStructurePassSampleBufferAttachmentDescriptorArrayRef {
unsafe { msg_send![self, sampleBufferAttachments] }
}
}

/// See <https://developer.apple.com/documentation/metal/mtlaccelerationstructurepasssamplebufferattachmentdescriptorarray>
pub enum MTLAccelerationStructurePassSampleBufferAttachmentDescriptorArray {}

foreign_obj_type! {
type CType = MTLAccelerationStructurePassSampleBufferAttachmentDescriptorArray;
pub struct AccelerationStructurePassSampleBufferAttachmentDescriptorArray;
}

impl AccelerationStructurePassSampleBufferAttachmentDescriptorArrayRef {
pub fn object_at(
&self,
index: NSUInteger,
) -> Option<&AccelerationStructurePassSampleBufferAttachmentDescriptorRef> {
unsafe { msg_send![self, objectAtIndexedSubscript: index] }
}

pub fn set_object_at(
&self,
index: NSUInteger,
attachment: Option<&AccelerationStructurePassSampleBufferAttachmentDescriptorRef>,
) {
unsafe {
msg_send![self, setObject:attachment
atIndexedSubscript:index]
}
}
}

/// See <https://developer.apple.com/documentation/metal/mtlaccelerationstructurepasssamplebufferattachmentdescriptor>
pub enum MTLAccelerationStructurePassSampleBufferAttachmentDescriptor {}

foreign_obj_type! {
type CType = MTLAccelerationStructurePassSampleBufferAttachmentDescriptor;
pub struct AccelerationStructurePassSampleBufferAttachmentDescriptor;
}

impl AccelerationStructurePassSampleBufferAttachmentDescriptor {
pub fn new() -> Self {
let class = class!(MTLAccelerationStructurePassSampleBufferAttachmentDescriptor);
unsafe { msg_send![class, new] }
}
}

impl AccelerationStructurePassSampleBufferAttachmentDescriptorRef {
pub fn sample_buffer(&self) -> &CounterSampleBufferRef {
unsafe { msg_send![self, sampleBuffer] }
}

pub fn set_sample_buffer(&self, sample_buffer: &CounterSampleBufferRef) {
unsafe { msg_send![self, setSampleBuffer: sample_buffer] }
}

pub fn start_of_encoder_sample_index(&self) -> NSUInteger {
unsafe { msg_send![self, startOfEncoderSampleIndex] }
}

pub fn set_start_of_encoder_sample_index(&self, start_of_encoder_sample_index: NSUInteger) {
unsafe {
msg_send![
self,
setStartOfEncoderSampleIndex: start_of_encoder_sample_index
]
}
}

pub fn end_of_encoder_sample_index(&self) -> NSUInteger {
unsafe { msg_send![self, endOfEncoderSampleIndex] }
}

pub fn set_end_of_encoder_sample_index(&self, end_of_encoder_sample_index: NSUInteger) {
unsafe {
msg_send![
self,
setEndOfEncoderSampleIndex: end_of_encoder_sample_index
]
}
}
}
7 changes: 7 additions & 0 deletions src/commandbuffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ impl CommandBufferRef {
unsafe { msg_send![self, accelerationStructureCommandEncoder] }
}

pub fn acceleration_structure_command_encoder_with_descriptor(
&self,
descriptor: &AccelerationStructurePassDescriptorRef,
) -> &AccelerationStructureCommandEncoderRef {
unsafe { msg_send![self, accelerationStructureCommandEncoderWithDescriptor: descriptor] }
}

pub fn encode_signal_event(&self, event: &EventRef, new_value: u64) {
unsafe {
msg_send![self,
Expand Down
5 changes: 1 addition & 4 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2109,10 +2109,7 @@ impl DeviceRef {
unsafe { msg_send![self, accelerationStructureSizesWithDescriptor: desc] }
}

pub fn new_acceleration_structure_with_size(
&self,
size: NSUInteger,
) -> accelerator_structure::AccelerationStructure {
pub fn new_acceleration_structure_with_size(&self, size: NSUInteger) -> AccelerationStructure {
unsafe { msg_send![self, newAccelerationStructureWithSize: size] }
}

Expand Down
6 changes: 3 additions & 3 deletions src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ impl RenderCommandEncoderRef {
pub fn set_vertex_acceleration_structure(
&self,
index: NSUInteger,
accel: Option<&accelerator_structure::AccelerationStructureRef>,
accel: Option<&AccelerationStructureRef>,
) {
unsafe {
msg_send![
Expand Down Expand Up @@ -868,7 +868,7 @@ impl RenderCommandEncoderRef {
pub fn set_fragment_acceleration_structure(
&self,
index: NSUInteger,
accel: Option<&accelerator_structure::AccelerationStructureRef>,
accel: Option<&AccelerationStructureRef>,
) {
unsafe {
msg_send![
Expand Down Expand Up @@ -1815,7 +1815,7 @@ impl ComputeCommandEncoderRef {
pub fn set_acceleration_structure(
&self,
index: NSUInteger,
accel: Option<&accelerator_structure::AccelerationStructureRef>,
accel: Option<&AccelerationStructureRef>,
) {
unsafe {
msg_send![
Expand Down
6 changes: 4 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,8 @@ impl MetalLayerRef {
}
}

mod accelerator_structure;
mod acceleration_structure;
mod acceleration_structure_pass;
mod argument;
mod blitpass;
mod buffer;
Expand Down Expand Up @@ -567,7 +568,8 @@ mod vertexdescriptor;

#[rustfmt::skip]
pub use {
accelerator_structure::*,
acceleration_structure::*,
acceleration_structure_pass::*,
argument::*,
blitpass::*,
buffer::*,
Expand Down