-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
gfx: refactor binding mappings #10013
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,7 @@ export enum API { | |
GLES3, | ||
METAL, | ||
VULKAN, | ||
NVN, | ||
WEBGL, | ||
WEBGL2, | ||
WEBGPU, | ||
|
@@ -953,19 +954,44 @@ export class Color { | |
} | ||
} | ||
|
||
/** | ||
* For non-vulkan backends, to maintain compatibility and maximize | ||
* descriptor cache-locality, descriptor-set-based binding numbers need | ||
* to be mapped to backend-specific bindings based on maximum limit | ||
* of available descriptor slots in each set. | ||
* | ||
* The GFX layer assumes the binding numbers for each descriptor type inside each set | ||
* are guaranteed to be consecutive, so the mapping procedure is reduced | ||
* to a simple shifting operation. This data structure specifies the | ||
* capacity for each descriptor type in each set. | ||
* | ||
* The `setIndices` field defines the binding ordering between different sets. | ||
* The last set index is treated as the 'flexible set', whose capacity is dynamically | ||
* assigned based on the total available descriptor slots on the runtime device. | ||
*/ | ||
export class BindingMappingInfo { | ||
declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object | ||
|
||
constructor ( | ||
public bufferOffsets: number[] = [], | ||
public samplerOffsets: number[] = [], | ||
public flexibleSet: number = 0, | ||
public maxBlockCounts: number[] = [0], | ||
public maxSamplerTextureCounts: number[] = [0], | ||
public maxSamplerCounts: number[] = [0], | ||
public maxTextureCounts: number[] = [0], | ||
public maxBufferCounts: number[] = [0], | ||
public maxImageCounts: number[] = [0], | ||
public maxSubpassInputCounts: number[] = [0], | ||
public setIndices: number[] = [0], | ||
) {} | ||
|
||
public copy (info: Readonly<BindingMappingInfo>) { | ||
this.bufferOffsets = info.bufferOffsets.slice(); | ||
this.samplerOffsets = info.samplerOffsets.slice(); | ||
this.flexibleSet = info.flexibleSet; | ||
this.maxBlockCounts = info.maxBlockCounts.slice(); | ||
this.maxSamplerTextureCounts = info.maxSamplerTextureCounts.slice(); | ||
this.maxSamplerCounts = info.maxSamplerCounts.slice(); | ||
this.maxTextureCounts = info.maxTextureCounts.slice(); | ||
this.maxBufferCounts = info.maxBufferCounts.slice(); | ||
this.maxImageCounts = info.maxImageCounts.slice(); | ||
this.maxSubpassInputCounts = info.maxSubpassInputCounts.slice(); | ||
this.setIndices = info.setIndices.slice(); | ||
return this; | ||
} | ||
} | ||
|
@@ -1712,7 +1738,7 @@ export class QueryPoolInfo { | |
|
||
constructor ( | ||
public type: QueryType = QueryType.OCCLUSION, | ||
public maxQueryObjects: number = 65536, | ||
public maxQueryObjects: number = 32767, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 16bit count should be 32768 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is synced from native changes @stanleyljl |
||
public forceWait: boolean = true, | ||
) {} | ||
|
||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a lot more data, have memory impact ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I don't understand why maxXXXCounts are arrays...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The limits are given per descriptor set, thus the array structure.
The arrays are very small by nature, 4 elements at most according to vk spec. For our purposes this is fixed as length-3 arrays, corresponding to the 3 descriptor sets (global, material & local).
This interface is transparent to the upper layer most of the time, and the semantics should be pretty straightforward.
The complexities are all encapsulated inside the actual backends.