Skip to content
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

Consider wrapping raw pointers #32

Open
natevm opened this issue Nov 18, 2022 · 2 comments
Open

Consider wrapping raw pointers #32

natevm opened this issue Nov 18, 2022 · 2 comments

Comments

@natevm
Copy link
Contributor

natevm commented Nov 18, 2022

Raw pointers can make many nervous about memory leaks, because these pointers can be lost track of.

For example, with gprtTriangleAccelCreate, we could internally create a std::unique_pointer<TriangleAccel> and then add it to a vector on the context passed into that create call. Then, we'd return a raw pointer pointing to that unique pointer object.

@natevm
Copy link
Contributor Author

natevm commented Nov 18, 2022

The main concern we want to keep in mind is that users need to maintain control over when objects are created and destroyed. Any GPU allocations and frees cause large stalls on GPUs, so it's important that the user be aware of when these occur.

We also want to maintain a C API I think, hence the final raw pointer returned to the user.

@natevm
Copy link
Contributor Author

natevm commented Dec 8, 2022

In the computer graphics community, I've heard that reference counting is a pain point. Case and point: https://twitter.com/amohr/status/1597680648642101248?s=20&t=BstnavjVWUOJvhr57pNlPA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant