Skip to content
This repository has been archived by the owner on Oct 22, 2020. It is now read-only.

Allow functions to return references #43

Closed
MaikKlein opened this issue Jun 10, 2018 · 2 comments
Closed

Allow functions to return references #43

MaikKlein opened this issue Jun 10, 2018 · 2 comments

Comments

@MaikKlein
Copy link
Owner

SPIR-V only allowes to return values by copy. #[inline(always)] in Rust doesn't seem to force inlining.

This is a needed feature because a lot of things in Rust like ops::Index and ops::Deref return a reference.

A temporary workaround would be to implement an intrinsic for accessing elements in a storage buffer.

A possible implementation could be to transform functions from

fn index(&self, idx: usize) -> &Foo{..}

to

fn index(&self, idx: usize, output: &mut Foo){..}

Possibly those functions would need to be annotated with something like

#[spirv(transform_ref)]
fn index(&self, idx: usize) -> &Foo{..}

Another possibility would be to force inlining, by inserting those functions directly into the mir where they are used.

@MaikKlein MaikKlein added this to To do in rlsl via automation Jun 10, 2018
@MaikKlein
Copy link
Owner Author

Might be easier than expected if we can use the mir::transoform::Inline to always inline functions that return a reference.

@MaikKlein
Copy link
Owner Author

Almost fully implemented. Currently requires #[inline(always)] on top of functions that return a reference. Those functions are then inlined manually and removed.

#45

rlsl automation moved this from To do to Done Jun 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
rlsl
  
Done
Development

No branches or pull requests

1 participant