-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Reuse webgpu resources #18208
Open
GengineJS
wants to merge
18
commits into
cocos:v3.8.6
Choose a base branch
from
GengineJS:v3.8.6-0114
base: v3.8.6
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Reuse webgpu resources #18208
+289
−334
Conversation
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
👍 Package size ⤵ -2544 bytes, old: 5230226, new: 5227682Interface Check Report! WARNING this pull request has changed these public interfaces:
@@ -67272,13 +67272,125 @@
gpuBlocks: _cocos_gfx_webgpu_webgpu_gpu_objects__IWebGPUGPUUniformBlock[];
gpuSamplers: _cocos_gfx_webgpu_webgpu_gpu_objects__IWebGPUGPUUniformSampler[];
bindings: Map<number, number[]>;
}
+ export type __types_webGPU__GPUIndex32 = number;
+ export type __types_webGPU__GPUShaderStageFlags = number;
+ export type __types_webGPU__GPUBufferBindingType = "uniform" | "storage" | "read-only-storage";
+ export interface __types_webGPU__GPUBufferBindingLayout {
+ /**
+ * Indicates the type required for buffers bound to this bindings.
+ */
+ type?: __types_webGPU__GPUBufferBindingType;
+ /**
+ * Indicates whether this binding requires a dynamic offset.
+ */
+ hasDynamicOffset?: boolean;
+ /**
+ * Indicates the minimum {@link GPUBufferBinding#size} of a buffer binding used with this bind point.
+ * Bindings are always validated against this size in {@link GPUDevice#createBindGroup}.
+ * If this *is not* `0`, pipeline creation additionally [$validating shader binding|validates$]
+ * that this value ≥ the minimum buffer binding size of the variable.
+ * If this *is* `0`, it is ignored by pipeline creation, and instead draw/dispatch commands
+ * [$Validate encoder bind groups|validate$] that each binding in the {@link GPUBindGroup}
+ * satisfies the minimum buffer binding size of the variable.
+ * Note:
+ * Similar execution-time validation is theoretically possible for other
+ * binding-related fields specified for early validation, like
+ * {@link GPUTextureBindingLayout#sampleType} and {@link GPUStorageTextureBindingLayout#format},
+ * which currently can only be validated in pipeline creation.
+ * However, such execution-time validation could be costly or unnecessarily complex, so it is
+ * available only for {@link GPUBufferBindingLayout#minBindingSize} which is expected to have the
+ * most ergonomic impact.
+ */
+ minBindingSize?: __types_webGPU__GPUSize64;
+ }
+ export type __types_webGPU__GPUSamplerBindingType = "filtering" | "non-filtering" | "comparison";
+ export interface __types_webGPU__GPUSamplerBindingLayout {
+ /**
+ * Indicates the required type of a sampler bound to this bindings.
+ */
+ type?: __types_webGPU__GPUSamplerBindingType;
+ }
+ export type __types_webGPU__GPUTextureSampleType = "float" | "unfilterable-float" | "depth" | "sint" | "uint";
+ export interface __types_webGPU__GPUTextureBindingLayout {
+ /**
+ * Indicates the type required for texture views bound to this binding.
+ */
+ sampleType?: __types_webGPU__GPUTextureSampleType;
+ /**
+ * Indicates the required {@link GPUTextureViewDescriptor#dimension} for texture views bound to
+ * this binding.
+ */
+ viewDimension?: __types_webGPU__GPUTextureViewDimension;
+ /**
+ * Indicates whether or not texture views bound to this binding must be multisampled.
+ */
+ multisampled?: boolean;
+ }
+ export type __types_webGPU__GPUStorageTextureAccess = "write-only" | "read-only" | "read-write";
+ export interface __types_webGPU__GPUStorageTextureBindingLayout {
+ /**
+ * The access mode for this binding, indicating readability and writability.
+ */
+ access?: __types_webGPU__GPUStorageTextureAccess;
+ /**
+ * The required {@link GPUTextureViewDescriptor#format} of texture views bound to this binding.
+ */
+ format: __types_webGPU__GPUTextureFormat;
+ /**
+ * Indicates the required {@link GPUTextureViewDescriptor#dimension} for texture views bound to
+ * this binding.
+ */
+ viewDimension?: __types_webGPU__GPUTextureViewDimension;
+ }
+ export interface __types_webGPU__GPUExternalTextureBindingLayout {
+ }
+ export interface __types_webGPU__GPUBindGroupLayoutEntry {
+ /**
+ * A unique identifier for a resource binding within the {@link GPUBindGroupLayout}, corresponding
+ * to a {@link GPUBindGroupEntry#binding|GPUBindGroupEntry.binding} and a @binding
+ * attribute in the {@link GPUShaderModule}.
+ */
+ binding: __types_webGPU__GPUIndex32;
+ /**
+ * A bitset of the members of {@link GPUShaderStage}.
+ * Each set bit indicates that a {@link GPUBindGroupLayoutEntry}'s resource
+ * will be accessible from the associated shader stage.
+ */
+ visibility: __types_webGPU__GPUShaderStageFlags;
+ /**
+ * When map/exist|provided, indicates the binding resource type for this {@link GPUBindGroupLayoutEntry}
+ * is {@link GPUBufferBinding}.
+ */
+ buffer?: __types_webGPU__GPUBufferBindingLayout;
+ /**
+ * When map/exist|provided, indicates the binding resource type for this {@link GPUBindGroupLayoutEntry}
+ * is {@link GPUSampler}.
+ */
+ sampler?: __types_webGPU__GPUSamplerBindingLayout;
+ /**
+ * When map/exist|provided, indicates the binding resource type for this {@link GPUBindGroupLayoutEntry}
+ * is {@link GPUTextureView}.
+ */
+ texture?: __types_webGPU__GPUTextureBindingLayout;
+ /**
+ * When map/exist|provided, indicates the binding resource type for this {@link GPUBindGroupLayoutEntry}
+ * is {@link GPUTextureView}.
+ */
+ storageTexture?: __types_webGPU__GPUStorageTextureBindingLayout;
+ /**
+ * When map/exist|provided, indicates the binding resource type for this {@link GPUBindGroupLayoutEntry}
+ * is {@link GPUExternalTexture}.
+ */
+ externalTexture?: __types_webGPU__GPUExternalTextureBindingLayout;
+ }
export interface _cocos_gfx_webgpu_webgpu_gpu_objects__IWebGPUGPUDescriptorSetLayout {
bindings: gfx.DescriptorSetLayoutBinding[];
dynamicBindings: number[];
descriptorIndices: number[];
descriptorCount: number;
+ entries: __types_webGPU__GPUBindGroupLayoutEntry[];
bindGroupLayout: GPUBindGroupLayout | null;
}
export interface _cocos_gfx_webgpu_webgpu_gpu_objects__IWebGPUGPUPipelineLayout {
setLayouts: gfx.DescriptorSetLayout[];
@@ -67299,9 +67411,8 @@
layout: GPUPipelineLayout | __types_webGPU__GPUAutoLayoutMode;
}
export type __types_webGPU__GPUVertexStepMode = "vertex" | "instance";
export type __types_webGPU__GPUVertexFormat = "uint8" | "uint8x2" | "uint8x4" | "sint8" | "sint8x2" | "sint8x4" | "unorm8" | "unorm8x2" | "unorm8x4" | "snorm8" | "snorm8x2" | "snorm8x4" | "uint16" | "uint16x2" | "uint16x4" | "sint16" | "sint16x2" | "sint16x4" | "unorm16" | "unorm16x2" | "unorm16x4" | "snorm16" | "snorm16x2" | "snorm16x4" | "float16" | "float16x2" | "float16x4" | "float32" | "float32x2" | "float32x3" | "float32x4" | "uint32" | "uint32x2" | "uint32x3" | "uint32x4" | "sint32" | "sint32x2" | "sint32x3" | "sint32x4" | "unorm10-10-10-2" | "unorm8x4-bgra";
- export type __types_webGPU__GPUIndex32 = number;
export interface __types_webGPU__GPUVertexAttribute {
/**
* The {@link GPUVertexFormat} of the attribute.
*/
@@ -67652,8 +67763,9 @@
texturesDescLayout: Map<number, _cocos_gfx_webgpu_webgpu_texture__WebGPUTexture>;
samplersDescLayout: Map<number, _cocos_gfx_webgpu_webgpu_sampler__WebGPUSampler>;
buffer: _cocos_gfx_webgpu_webgpu_buffer__WebGPUBuffer;
texture: _cocos_gfx_webgpu_webgpu_texture__WebGPUTexture;
+ cubeTexture: _cocos_gfx_webgpu_webgpu_texture__WebGPUTexture;
sampler: _cocos_gfx_webgpu_webgpu_sampler__WebGPUSampler;
setLayout: gfx.DescriptorSetLayout;
descSet: gfx.DescriptorSet;
}
@@ -67702,118 +67814,8 @@
*/
alphaMode?: __types_webGPU__GPUCanvasAlphaMode;
}
export type __types_webGPU__GPUSupportedFeatures = ReadonlySet<string>;
- export type __types_webGPU__GPUShaderStageFlags = number;
- export type __types_webGPU__GPUBufferBindingType = "uniform" | "storage" | "read-only-storage";
- export interface __types_webGPU__GPUBufferBindingLayout {
- /**
- * Indicates the type required for buffers bound to this bindings.
- */
- type?: __types_webGPU__GPUBufferBindingType;
- /**
- * Indicates whether this binding requires a dynamic offset.
- */
- hasDynamicOffset?: boolean;
- /**
- * Indicates the minimum {@link GPUBufferBinding#size} of a buffer binding used with this bind point.
- * Bindings are always validated against this size in {@link GPUDevice#createBindGroup}.
- * If this *is not* `0`, pipeline creation additionally [$validating shader binding|validates$]
- * that this value ≥ the minimum buffer binding size of the variable.
- * If this *is* `0`, it is ignored by pipeline creation, and instead draw/dispatch commands
- * [$Validate encoder bind groups|validate$] that each binding in the {@link GPUBindGroup}
- * satisfies the minimum buffer binding size of the variable.
- * Note:
- * Similar execution-time validation is theoretically possible for other
- * binding-related fields specified for early validation, like
- * {@link GPUTextureBindingLayout#sampleType} and {@link GPUStorageTextureBindingLayout#format},
- * which currently can only be validated in pipeline creation.
- * However, such execution-time validation could be costly or unnecessarily complex, so it is
- * available only for {@link GPUBufferBindingLayout#minBindingSize} which is expected to have the
- * most ergonomic impact.
- */
- minBindingSize?: __types_webGPU__GPUSize64;
- }
- export type __types_webGPU__GPUSamplerBindingType = "filtering" | "non-filtering" | "comparison";
- export interface __types_webGPU__GPUSamplerBindingLayout {
- /**
- * Indicates the required type of a sampler bound to this bindings.
- */
- type?: __types_webGPU__GPUSamplerBindingType;
- }
- export type __types_webGPU__GPUTextureSampleType = "float" | "unfilterable-float" | "depth" | "sint" | "uint";
- export interface __types_webGPU__GPUTextureBindingLayout {
- /**
- * Indicates the type required for texture views bound to this binding.
- */
- sampleType?: __types_webGPU__GPUTextureSampleType;
- /**
- * Indicates the required {@link GPUTextureViewDescriptor#dimension} for texture views bound to
- * this binding.
- */
- viewDimension?: __types_webGPU__GPUTextureViewDimension;
- /**
- * Indicates whether or not texture views bound to this binding must be multisampled.
- */
- multisampled?: boolean;
- }
- export type __types_webGPU__GPUStorageTextureAccess = "write-only" | "read-only" | "read-write";
- export interface __types_webGPU__GPUStorageTextureBindingLayout {
- /**
- * The access mode for this binding, indicating readability and writability.
- */
- access?: __types_webGPU__GPUStorageTextureAccess;
- /**
- * The required {@link GPUTextureViewDescriptor#format} of texture views bound to this binding.
- */
- format: __types_webGPU__GPUTextureFormat;
- /**
- * Indicates the required {@link GPUTextureViewDescriptor#dimension} for texture views bound to
- * this binding.
- */
- viewDimension?: __types_webGPU__GPUTextureViewDimension;
- }
- export interface __types_webGPU__GPUExternalTextureBindingLayout {
- }
- export interface __types_webGPU__GPUBindGroupLayoutEntry {
- /**
- * A unique identifier for a resource binding within the {@link GPUBindGroupLayout}, corresponding
- * to a {@link GPUBindGroupEntry#binding|GPUBindGroupEntry.binding} and a @binding
- * attribute in the {@link GPUShaderModule}.
- */
- binding: __types_webGPU__GPUIndex32;
- /**
- * A bitset of the members of {@link GPUShaderStage}.
- * Each set bit indicates that a {@link GPUBindGroupLayoutEntry}'s resource
- * will be accessible from the associated shader stage.
- */
- visibility: __types_webGPU__GPUShaderStageFlags;
- /**
- * When map/exist|provided, indicates the binding resource type for this {@link GPUBindGroupLayoutEntry}
- * is {@link GPUBufferBinding}.
- */
- buffer?: __types_webGPU__GPUBufferBindingLayout;
- /**
- * When map/exist|provided, indicates the binding resource type for this {@link GPUBindGroupLayoutEntry}
- * is {@link GPUSampler}.
- */
- sampler?: __types_webGPU__GPUSamplerBindingLayout;
- /**
- * When map/exist|provided, indicates the binding resource type for this {@link GPUBindGroupLayoutEntry}
- * is {@link GPUTextureView}.
- */
- texture?: __types_webGPU__GPUTextureBindingLayout;
- /**
- * When map/exist|provided, indicates the binding resource type for this {@link GPUBindGroupLayoutEntry}
- * is {@link GPUTextureView}.
- */
- storageTexture?: __types_webGPU__GPUStorageTextureBindingLayout;
- /**
- * When map/exist|provided, indicates the binding resource type for this {@link GPUBindGroupLayoutEntry}
- * is {@link GPUExternalTexture}.
- */
- externalTexture?: __types_webGPU__GPUExternalTextureBindingLayout;
- }
/**
* @en Test line and line
* @zh 测试线段与线段是否相交
*/
|
dumganhar
reviewed
Jan 17, 2025
cocos/gfx/webgpu/webgpu-commands.ts
Outdated
'read-write', | ||
]; | ||
|
||
export function CreateBindGroupLayoutEntry (currBind: DescriptorSetLayoutBinding): GPUBindGroupLayoutEntry[] { |
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.
Keep the same coding style, the first letter of functions must use lowercase .
add missing info
change storage image to sampler texture
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.
No description provided.