Skip to content

Commit

Permalink
Implement missing features for Intersection Function Table
Browse files Browse the repository at this point in the history
  • Loading branch information
FlannyH authored and kvark committed May 6, 2024
1 parent ff2e8f4 commit 3b57d71
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/accelerator_structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,4 +538,37 @@ impl IntersectionFunctionTableRef {
pub fn set_function(&self, function: &FunctionHandleRef, index: NSUInteger) {
unsafe { msg_send![self, setFunction: function atIndex: index] }
}

pub fn set_functions(&self, functions: &[&FunctionHandleRef], start_index: NSUInteger) {
unsafe {
msg_send![self, setFunctions: functions.as_ptr() withRange: NSRange { location: start_index, length: functions.len() as _ }]
}
}

pub fn set_buffer(&self, index: NSUInteger, buffer: Option<&BufferRef>, offset: NSUInteger) {
unsafe { msg_send![self, setBuffer:buffer offset:offset atIndex:index] }
}

pub fn set_buffers(
&self,
start_index: NSUInteger,
data: &[Option<&BufferRef>],
offsets: &[NSUInteger],
) {
debug_assert_eq!(offsets.len(), data.len());
unsafe {
msg_send![self,
setBuffers: data.as_ptr()
offsets: offsets.as_ptr()
withRange: NSRange {
location: start_index,
length: data.len() as _,
}
]
}
}

pub fn gpu_resource_id(&self) -> MTLResourceID {
unsafe { msg_send![self, gpuResourceID] }
}
}
34 changes: 34 additions & 0 deletions src/pipeline/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,16 @@ impl RenderPipelineDescriptorRef {
unsafe { msg_send![self, setBinaryArchives: ns_array] }
}

/// API_AVAILABLE(macos(11.0), ios(14.0));
pub fn fragment_linked_functions(&self) -> &LinkedFunctionsRef {
unsafe { msg_send![self, fragmentLinkedFunctions] }
}

/// API_AVAILABLE(macos(11.0), ios(14.0));
pub fn set_fragment_linked_functions(&self, functions: &LinkedFunctionsRef) {
unsafe { msg_send![self, setFragmentLinkedFunctions: functions] }
}

pub fn reset(&self) {
unsafe { msg_send![self, reset] }
}
Expand All @@ -688,6 +698,30 @@ impl RenderPipelineStateRef {
crate::nsstring_as_str(label)
}
}

/// Only available on (macos(11.0), ios(14.0))
pub fn new_intersection_function_table_with_descriptor(
&self,
descriptor: &IntersectionFunctionTableDescriptorRef,
stage: MTLRenderStages,
) -> IntersectionFunctionTable {
unsafe {
msg_send![self, newIntersectionFunctionTableWithDescriptor: descriptor
stage:stage]
}
}

/// Only available on (macos(11.0), ios(14.0))
pub fn function_handle_with_function(
&self,
function: &FunctionRef,
stage: MTLRenderStages,
) -> Option<&FunctionHandleRef> {
unsafe {
msg_send![self, functionHandleWithFunction: function
stage:stage]
}
}
}

/// See <https://developer.apple.com/documentation/metal/mtlrenderpipelinecolorattachmentdescriptorarray>
Expand Down

0 comments on commit 3b57d71

Please sign in to comment.