SWDEV-559353 - HIP GL Interop: Support GL Context Switches and Code Cleanup #2561
+1,901
−87
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.
Motivation
HIP GL interop fails when applications switch GL contexts (e.g., multi-window or context recreation). The existing std::call_once approach only sets up interop once and cannot handle context changes.
Technical Details
Commit 1: Code style fixes - typos, [[fallthrough]], nullptr, constexpr, base class cast in hipGraphicsUnregisterResource
Commit 2: Improve flag handling
Add convertHipGraphicsFlagsToCL() to properly map HIP flags to CL memory flags
Use bitmask validation to reject invalid flag combinations
Commit 3: Thread-safe GL context tracking
Track associated GL context, detect changes, and re-associate automatically
GLInteropGuard RAII class with shared_mutex (read-write lock pattern)
Cache GL function pointers to avoid library handle mismatches
Apply guard to all GL interop APIs
JIRA ID
Resolves SWDEV-559353
Test Plan
Verified GL interop works with context switches
Tested multi-threaded GL interop operations
Existing GL interop tests pass
Test Result
All tests passed
Submission Checklist