Open
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the GPU initialization to use a singleton pattern, ensuring that the same GPU instance is re-used even during hot reloads. Key changes include moving the GPU constructor to private, introducing a static getInstance() function, and updating consumers (e.g., RNWebGPUManager) to use the singleton instance.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| packages/webgpu/cpp/rnwgpu/api/descriptors/Unions.h | Minor formatting update for readability. |
| packages/webgpu/cpp/rnwgpu/api/GPU.h | Refactored GPU class to implement singleton pattern. |
| packages/webgpu/cpp/rnwgpu/api/GPU.cpp | Added static member definitions for the singleton pattern. |
| packages/webgpu/cpp/rnwgpu/RNWebGPUManager.cpp | Updated usage to fetch the singleton GPU instance. |
| externals/dawn | Updated subproject commit. |
Comments suppressed due to low confidence (1)
packages/webgpu/cpp/rnwgpu/api/GPU.h:76
- The name '_instance' is used both for the static singleton pointer and for the member variable of type wgpu::Instance (line 80), which may lead to confusion. Consider renaming the member variable (e.g., to 'gpuInstance') to improve clarity.
static std::shared_ptr<GPU> _instance;
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.
the idea is to be use that the same instance is always used even in case of hot reload and so on