Skip to content

Commit 3b57d71

Browse files
FlannyHkvark
authored andcommitted
Implement missing features for Intersection Function Table
1 parent ff2e8f4 commit 3b57d71

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

src/accelerator_structure.rs

+33
Original file line numberDiff line numberDiff line change
@@ -538,4 +538,37 @@ impl IntersectionFunctionTableRef {
538538
pub fn set_function(&self, function: &FunctionHandleRef, index: NSUInteger) {
539539
unsafe { msg_send![self, setFunction: function atIndex: index] }
540540
}
541+
542+
pub fn set_functions(&self, functions: &[&FunctionHandleRef], start_index: NSUInteger) {
543+
unsafe {
544+
msg_send![self, setFunctions: functions.as_ptr() withRange: NSRange { location: start_index, length: functions.len() as _ }]
545+
}
546+
}
547+
548+
pub fn set_buffer(&self, index: NSUInteger, buffer: Option<&BufferRef>, offset: NSUInteger) {
549+
unsafe { msg_send![self, setBuffer:buffer offset:offset atIndex:index] }
550+
}
551+
552+
pub fn set_buffers(
553+
&self,
554+
start_index: NSUInteger,
555+
data: &[Option<&BufferRef>],
556+
offsets: &[NSUInteger],
557+
) {
558+
debug_assert_eq!(offsets.len(), data.len());
559+
unsafe {
560+
msg_send![self,
561+
setBuffers: data.as_ptr()
562+
offsets: offsets.as_ptr()
563+
withRange: NSRange {
564+
location: start_index,
565+
length: data.len() as _,
566+
}
567+
]
568+
}
569+
}
570+
571+
pub fn gpu_resource_id(&self) -> MTLResourceID {
572+
unsafe { msg_send![self, gpuResourceID] }
573+
}
541574
}

src/pipeline/render.rs

+34
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,16 @@ impl RenderPipelineDescriptorRef {
664664
unsafe { msg_send![self, setBinaryArchives: ns_array] }
665665
}
666666

667+
/// API_AVAILABLE(macos(11.0), ios(14.0));
668+
pub fn fragment_linked_functions(&self) -> &LinkedFunctionsRef {
669+
unsafe { msg_send![self, fragmentLinkedFunctions] }
670+
}
671+
672+
/// API_AVAILABLE(macos(11.0), ios(14.0));
673+
pub fn set_fragment_linked_functions(&self, functions: &LinkedFunctionsRef) {
674+
unsafe { msg_send![self, setFragmentLinkedFunctions: functions] }
675+
}
676+
667677
pub fn reset(&self) {
668678
unsafe { msg_send![self, reset] }
669679
}
@@ -688,6 +698,30 @@ impl RenderPipelineStateRef {
688698
crate::nsstring_as_str(label)
689699
}
690700
}
701+
702+
/// Only available on (macos(11.0), ios(14.0))
703+
pub fn new_intersection_function_table_with_descriptor(
704+
&self,
705+
descriptor: &IntersectionFunctionTableDescriptorRef,
706+
stage: MTLRenderStages,
707+
) -> IntersectionFunctionTable {
708+
unsafe {
709+
msg_send![self, newIntersectionFunctionTableWithDescriptor: descriptor
710+
stage:stage]
711+
}
712+
}
713+
714+
/// Only available on (macos(11.0), ios(14.0))
715+
pub fn function_handle_with_function(
716+
&self,
717+
function: &FunctionRef,
718+
stage: MTLRenderStages,
719+
) -> Option<&FunctionHandleRef> {
720+
unsafe {
721+
msg_send![self, functionHandleWithFunction: function
722+
stage:stage]
723+
}
724+
}
691725
}
692726

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

0 commit comments

Comments
 (0)