Make GraphicsResource inherit from Buffer#1701
Open
rparolin wants to merge 3 commits intoNVIDIA:mainfrom
Open
Conversation
Contributor
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
Contributor
|
Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
Collaborator
Author
|
/ok to test |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
GraphicsResourceto inherit fromBufferinstead of wrapping a separateBufferobject, eliminating the_MappedBufferContextintermediary classmap()now populates theGraphicsResourceitself with device pointer/size (since it IS-ABuffer) and returnsselfstreama required parameter formap()andunmap()(removes implicit default stream usage)streamparameter tofrom_gl_buffer()for a convenient register-and-map-in-one-step patternhandleproperty toresource_handleto avoid conflicting withBuffer.handle(which now exposes the mapped device pointer)Motivation
Review feedback requested that
GraphicsResourcebe aBufferdirectly rather than producing a separateBufferviamap(). This simplifies the API surface: a mappedGraphicsResourcecan be passed directly anywhere aBufferis accepted (e.g.,StridedMemoryView.from_buffer()), without needing a wrapper context manager.Key changes
GraphicsResource(Buffer)— inherits fromBuffer;handleandsizeare valid while mapped_MappedBufferContext— no longer needed sinceGraphicsResourceitself is the buffer__enter__/__exit__— moved ontoGraphicsResourcedirectly;__exit__auto-unmaps using the stream frommap()streamrequired —map(stream=)andunmap(stream=)no longer default to stream 0from_gl_buffer(stream=)— optional stream param to register + map in one call, enablingwith GraphicsResource.from_gl_buffer(vbo, stream=s) as buf:patternclose(stream=None)— acceptsstreamkwarg for compatibility withBuffer.close()resource_handle— renamed fromhandleto avoid shadowingBuffer.handle🤖 Generated with Claude Code