gfx-rs / metal-rs

Rust bindings for Metal
Apache License 2.0
567 stars 112 forks source link

`new_render_command_encoder` assumes the return value can never be NULL #282

Open madsmtm opened 1 year ago

madsmtm commented 1 year ago

Found while working on https://github.com/gfx-rs/metal-rs/pull/241.

The argument-buffer and the bindless examples currently pass an empty RenderPassDescriptor to CommandBuffer::new_render_command_encoder, which causes the function to return NULL (instead of an actual render command encoder object).

This in turn means that all the code following it basically does nothing (as it sends messages to a NULL value, which Objective-C just ignores).

To very clearly see how this is unsound and confusing, try putting the following statement after new_render_command_encoder:

let encoder = Some(encoder).unwrap();