Re-works how LDS regions are defined and how their total size is computed#70
Merged
pm4rtx merged 1 commit intomicrosoft:developmentfrom Feb 18, 2026
Merged
Conversation
…uted to use for HLSL groupshared definition.
Collaborator
|
Nice!. This looks good to me. |
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.
This PR tries to improve how LDS regions are defined in the code shared between HLSL and C/C++. Previously the size of LDS region was computed twice: in
.hlslshader file when declaring singlegroupsharedvariable and in.hfile within the body of the corresponding function. The latter was necessary to represent LDS by a local array in C/C++ side. Things would have been easier if HLSL had supported declaringgroupsharedvariable within a function, but it doesn't support that. So the first approach existed for some time to somehow address what HLSL can't do, but this approach was prone to errors when sizes ofgroupsharedmemory became out of sync. To address this, this PR starts defining partition (groups) of LDS variables by respective macro lists (usually, right in front of functions that use them) that are expanded twice: outside of the function to compute the total size of required LDS region, and the second time within function body to compute offsets relative to the start of LDS (on HLSL side), and to define local variables replacing global LDS memory (on C/C++ side). This approach requires to define all macro/constants that affect LDS size before includingzstdgpu_shaders.hwhere LDS partition macro are defined.