diff --git a/src/accelerator_structure.rs b/src/acceleration_structure.rs similarity index 100% rename from src/accelerator_structure.rs rename to src/acceleration_structure.rs diff --git a/src/acceleration_structure_pass.rs b/src/acceleration_structure_pass.rs new file mode 100644 index 0000000..a9862f2 --- /dev/null +++ b/src/acceleration_structure_pass.rs @@ -0,0 +1,108 @@ +use super::{CounterSampleBufferRef, NSUInteger}; + +/// See +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 +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 +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) -> Option<&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 + ] + } + } +} diff --git a/src/blitpass.rs b/src/blitpass.rs index 290cadf..cb56186 100644 --- a/src/blitpass.rs +++ b/src/blitpass.rs @@ -66,7 +66,7 @@ impl BlitPassSampleBufferAttachmentDescriptor { } impl BlitPassSampleBufferAttachmentDescriptorRef { - pub fn sample_buffer(&self) -> &CounterSampleBufferRef { + pub fn sample_buffer(&self) -> Option<&CounterSampleBufferRef> { unsafe { msg_send![self, sampleBuffer] } } diff --git a/src/commandbuffer.rs b/src/commandbuffer.rs index 26fea2e..a7c829c 100644 --- a/src/commandbuffer.rs +++ b/src/commandbuffer.rs @@ -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, diff --git a/src/computepass.rs b/src/computepass.rs index bb21a72..d3173e3 100644 --- a/src/computepass.rs +++ b/src/computepass.rs @@ -71,7 +71,7 @@ impl ComputePassSampleBufferAttachmentDescriptor { } impl ComputePassSampleBufferAttachmentDescriptorRef { - pub fn sample_buffer(&self) -> &CounterSampleBufferRef { + pub fn sample_buffer(&self) -> Option<&CounterSampleBufferRef> { unsafe { msg_send![self, sampleBuffer] } } diff --git a/src/device.rs b/src/device.rs index 12e43ae..330a013 100644 --- a/src/device.rs +++ b/src/device.rs @@ -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] } } diff --git a/src/encoder.rs b/src/encoder.rs index 9156172..e737a2f 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -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![ @@ -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![ @@ -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![ diff --git a/src/lib.rs b/src/lib.rs index 0d400d6..0b5c6d7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -536,7 +536,8 @@ impl MetalLayerRef { } } -mod accelerator_structure; +mod acceleration_structure; +mod acceleration_structure_pass; mod argument; mod blitpass; mod buffer; @@ -567,7 +568,8 @@ mod vertexdescriptor; #[rustfmt::skip] pub use { - accelerator_structure::*, + acceleration_structure::*, + acceleration_structure_pass::*, argument::*, blitpass::*, buffer::*, diff --git a/src/renderpass.rs b/src/renderpass.rs index f9aa50b..f23d934 100644 --- a/src/renderpass.rs +++ b/src/renderpass.rs @@ -266,7 +266,7 @@ impl RenderPassSampleBufferAttachmentDescriptor { } impl RenderPassSampleBufferAttachmentDescriptorRef { - pub fn sample_buffer(&self) -> &CounterSampleBufferRef { + pub fn sample_buffer(&self) -> Option<&CounterSampleBufferRef> { unsafe { msg_send![self, sampleBuffer] } }