Skip to content
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
wants to merge 18 commits into
base: v3.8.6
Choose a base branch
from
Open

Reuse webgpu resources #18208

wants to merge 18 commits into from

Conversation

GengineJS
Copy link
Contributor

No description provided.

@GengineJS GengineJS requested a review from star-e January 17, 2025 02:32
Copy link

github-actions bot commented Jan 17, 2025

👍 Package size ⤵ -2544 bytes, old: 5230226, new: 5227682

Interface 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 &ge; 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 &ge; 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 测试线段与线段是否相交
          */

'read-write',
];

export function CreateBindGroupLayoutEntry (currBind: DescriptorSetLayoutBinding): GPUBindGroupLayoutEntry[] {
Copy link
Contributor

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 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants