-
Notifications
You must be signed in to change notification settings - Fork 111
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
indexing (not working currently) #116
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,20 +34,26 @@ fn prepare_pipeline_state<'a>(device: &DeviceRef, library: &LibraryRef) -> Rende | |
pipeline_state_descriptor.set_vertex_function(Some(&vert)); | ||
pipeline_state_descriptor.set_fragment_function(Some(&frag)); | ||
pipeline_state_descriptor | ||
.color_attachments() | ||
.object_at(0) | ||
.unwrap() | ||
.color_attachments()[0] | ||
// .object_at(0) | ||
// .unwrap() | ||
.set_pixel_format(MTLPixelFormat::BGRA8Unorm); | ||
|
||
device | ||
.new_render_pipeline_state(&pipeline_state_descriptor) | ||
.unwrap() | ||
} | ||
|
||
fn ppd(desc: &mut RenderPassDescriptorRef) { | ||
// let color_attachment = &desc.color_attachments()[0]; | ||
desc.color_attachments()[0] = desc.color_attachments()[0].to_owned(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can live with the fact this doesn't work. It doesn't have to be provided - users can still do |
||
} | ||
|
||
fn prepare_render_pass_descriptor(descriptor: &RenderPassDescriptorRef, texture: &TextureRef) { | ||
//descriptor.color_attachments().set_object_at(0, MTLRenderPassColorAttachmentDescriptor::alloc()); | ||
//let color_attachment: MTLRenderPassColorAttachmentDescriptor = unsafe { msg_send![descriptor.color_attachments().0, _descriptorAtIndex:0] };//descriptor.color_attachments().object_at(0); | ||
let color_attachment = descriptor.color_attachments().object_at(0).unwrap(); | ||
let color_attachment = &descriptor.color_attachments()[0]; | ||
|
||
|
||
color_attachment.set_texture(Some(texture)); | ||
color_attachment.set_load_action(MTLLoadAction::Clear); | ||
|
@@ -133,9 +139,9 @@ fn main() { | |
encoder.end_encoding(); | ||
|
||
render_pass_descriptor | ||
.color_attachments() | ||
.object_at(0) | ||
.unwrap() | ||
.color_attachments()[0] | ||
// .object_at(0) | ||
// .unwrap() | ||
.set_load_action(MTLLoadAction::DontCare); | ||
|
||
let encoder = command_buffer.new_render_command_encoder(&render_pass_descriptor); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -261,13 +261,28 @@ foreign_obj_type! { | |
pub struct AttributeDescriptorArrayRef; | ||
} | ||
|
||
impl AttributeDescriptorArrayRef { | ||
pub fn object_at(&self, index: usize) -> Option<&AttributeDescriptorRef> { | ||
// impl AttributeDescriptorArrayRef { | ||
// pub fn object_at(&self, index: NSUInteger) -> Option<&AttributeDescriptorRef> { | ||
// unsafe { msg_send![self, objectAtIndexedSubscript: index] } | ||
// } | ||
|
||
// pub fn set_object_at(&self, index: NSUInteger, buffer_desc: Option<&AttributeDescriptorRef>) { | ||
// unsafe { msg_send![self, setObject:buffer_desc atIndexedSubscript:index] } | ||
// } | ||
// } | ||
|
||
|
||
impl std::ops::Index<NSUInteger> for AttributeDescriptorArrayRef { | ||
type Output = AttributeDescriptor; | ||
|
||
fn index(&self, index: NSUInteger) -> &Self::Output { | ||
unsafe { msg_send![self, objectAtIndexedSubscript: index] } | ||
} | ||
} | ||
|
||
pub fn set_object_at(&self, index: usize, buffer_desc: Option<&AttributeDescriptorRef>) { | ||
unsafe { msg_send![self, setObject:buffer_desc atIndexedSubscript:index] } | ||
impl std::ops::IndexMut<NSUInteger> for AttributeDescriptorArrayRef { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems to me that this isn't actually needed. Today, metal-rs doesn't enforce thread guarantees (unfortunately!) so all the methods are In the future, it will definitely be desired to make us properly Send/Sync/Clone/&mut, but this is out of scope of this PR. |
||
fn index_mut(&mut self, index: NSUInteger) -> &mut Self::Output { | ||
unsafe { msg_send![self, objectAtIndexedSubscript: index] } | ||
} | ||
} | ||
|
||
|
@@ -313,13 +328,17 @@ foreign_obj_type! { | |
pub struct BufferLayoutDescriptorArrayRef; | ||
} | ||
|
||
impl BufferLayoutDescriptorArrayRef { | ||
pub fn object_at(&self, index: usize) -> Option<&BufferLayoutDescriptorRef> { | ||
impl std::ops::Index<NSUInteger> for BufferLayoutDescriptorArrayRef { | ||
type Output = BufferLayoutDescriptor; | ||
|
||
fn index(&self, index: NSUInteger) -> &Self::Output { | ||
unsafe { msg_send![self, objectAtIndexedSubscript: index] } | ||
} | ||
} | ||
|
||
pub fn set_object_at(&self, index: usize, buffer_desc: Option<&BufferLayoutDescriptorRef>) { | ||
unsafe { msg_send![self, setObject:buffer_desc atIndexedSubscript:index] } | ||
impl std::ops::IndexMut<NSUInteger> for BufferLayoutDescriptorArrayRef { | ||
fn index_mut(&mut self, index: NSUInteger) -> &mut Self::Output { | ||
unsafe { msg_send![self, objectAtIndexedSubscript: index] } | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's clean up all these comments