Skip to content

Exposing the native OpenGL ID (issue ##1468) #1736

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Spartan-X1
Copy link

@Spartan-X1 Spartan-X1 commented Mar 13, 2025

Issue description

This change exposes the native OpenGL buffer ID via a virtual method in BufferContext. It allows external tools and libraries to interoperate with GPU buffers without copying data between system memory and GPU memory
( Issue #1468 )

Solution description

This PR adds a new method virtual uint64_t get_native_id() const override; to the BufferContext class which returns the contents of the _index member cast to a uint64_t. The method provides direct access to the native OpenGL buffer ID, enabling efficient interoperability with external libraries like CUDA, TensorFlow, and PyTorch. The implementation adheres to Panda3D's existing design patterns and coding style.

Checklist

I have done my best to ensure that…

  • …I have familiarized myself with the CONTRIBUTING.md file
  • …this change follows the coding style and design patterns of the codebase
  • …I own the intellectual property rights to this code
  • …the intent of this change is clearly explained
  • …existing uses of the Panda3D API are not broken
  • …the changed code is adequately covered by the test suite, where possible.

Copy link
Member

@rdb rdb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! Sorry for the delay in responding.

Looks great. I just have two nitpicks. If you fix that and the CI passes this is good to go.

/**
* Returns the native OpenGL buffer ID for this buffer.
*/
uint64_t CLP(BufferContext)::get_native_id() const {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Panda style is to put the part starting with get_native_id on a new line. See the other definitions in this file.

* if this is not a buffer texture.
*/
uint64_t BufferContext::
get_native_buffer_id() const {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to have a separate get_native_buffer_id (which isn't implemented anyway) for buffers since the get_native_id already returns the buffer id. The distinction only makes sense for textures.

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

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy