Popov72 5 лет назад
Родитель
Сommit
273f0333be

+ 16 - 20
src/Engines/WebGPU/webgpuCacheRenderPipeline.ts

@@ -814,30 +814,26 @@ export abstract class WebGPUCacheRenderPipeline {
                     visibility = visibility | WebGPUConstants.ShaderStage.Fragment;
                 }
 
+                const entry: GPUBindGroupLayoutEntry = {
+                    binding: j,
+                    visibility,
+                };
+                entries.push(entry);
+
                 if (bindingDefinition.isSampler) {
-                    entries.push({
-                        binding: j,
-                        visibility,
-                        type: bindingDefinition.isComparisonSampler ? WebGPUConstants.BindingType.ComparisonSampler : WebGPUConstants.BindingType.Sampler
-                    });
+                    entry.sampler = {
+                        type: bindingDefinition.isComparisonSampler ? WebGPUConstants.SamplerBindingType.Comparison : WebGPUConstants.SamplerBindingType.Filtering
+                    };
                 } else if (bindingDefinition.isTexture) {
-                    entries.push({
-                        binding: j,
-                        visibility,
-                        type: WebGPUConstants.BindingType.SampledTexture,
+                    entry.texture = {
+                        sampleType: bindingDefinition.sampleType,
                         viewDimension: bindingDefinition.textureDimension,
-                        textureComponentType: bindingDefinition.componentType,
-                        // TODO WEBGPU.
-                        // hasDynamicOffset?: boolean;
-                        // storageTextureFormat?: GPUTextureFormat;
-                        // minBufferBindingSize?: number;
-                    });
+                        multisampled: false,
+                    };
                 } else {
-                    entries.push({
-                        binding: j,
-                        visibility,
-                        type: WebGPUConstants.BindingType.UniformBuffer,
-                    });
+                    entry.buffer = {
+                        type: WebGPUConstants.BufferBindingType.Uniform,
+                    };
                 }
             }
 

+ 0 - 21
src/Engines/WebGPU/webgpuConstants.ts

@@ -202,33 +202,12 @@ export enum TextureSampleType {
     Uint = "uint"
 }
 
-// TODO WEBGPU to be removed
-export enum TextureComponentType {
-    Float = "float",
-    Sint = "sint",
-    Uint = "uint",
-    // Texture is used with comparison sampling only.
-    DepthComparison = "depth-comparison"
-}
-
 /** @hidden */
 export enum StorageTextureAccess {
     ReadOnly = "read-only",
     WriteOnly = "write-only"
 }
 
-// TODO WEBGPU to be removed
-export enum BindingType {
-    UniformBuffer = "uniform-buffer",
-    StorageBuffer = "storage-buffer",
-    ReadonlyStorageBuffer = "readonly-storage-buffer",
-    Sampler = "sampler",
-    ComparisonSampler = "comparison-sampler",
-    SampledTexture = "sampled-texture",
-    ReadonlyStorageTexture = "readonly-storage-texture",
-    WriteonlyStorageTexture = "writeonly-storage-texture"
-}
-
 /** @hidden */
 export enum CompilationMessageType {
     Error = "error",

+ 1 - 1
src/Engines/WebGPU/webgpuShaderProcessingContext.ts

@@ -35,7 +35,7 @@ export interface WebGPUBindingDescription {
     isComparisonSampler?: boolean;
 
     isTexture: boolean;
-    componentType?: GPUTextureComponentType;
+    sampleType?: GPUTextureSampleType;
     textureDimension?: GPUTextureViewDimension;
 }
 

+ 3 - 3
src/Engines/WebGPU/webgpuShaderProcessors.ts

@@ -243,9 +243,9 @@ export class WebGPUShaderProcessor implements IShaderProcessor {
                         webgpuProcessingContext.orderedUBOsAndSamplers[textureSetIndex][textureBindingIndex] = {
                             isSampler: false,
                             isTexture: true,
-                            componentType: isComparisonSampler ? WebGPUConstants.TextureComponentType.DepthComparison :
-                                        componentType === 'u' ? WebGPUConstants.TextureComponentType.Uint :
-                                        componentType === 'i' ? WebGPUConstants.TextureComponentType.Sint : WebGPUConstants.TextureComponentType.Float,
+                            sampleType: isComparisonSampler ? WebGPUConstants.TextureSampleType.Depth :
+                                        componentType === 'u' ? WebGPUConstants.TextureSampleType.Uint :
+                                        componentType === 'i' ? WebGPUConstants.TextureSampleType.Sint : WebGPUConstants.TextureSampleType.Float,
                             textureDimension,
                             usedInVertex: false,
                             usedInFragment: false,

+ 3 - 33
src/LibDeclarations/webgpu.d.ts

@@ -321,7 +321,7 @@ interface GPUBindGroupLayoutDescriptor extends GPUObjectDescriptorBase {
 
 type GPUShaderStageFlags = number;
 
-interface GPUBindGroupLayoutEntry2 {
+interface GPUBindGroupLayoutEntry {
     binding: GPUIndex32;
     visibility: GPUShaderStageFlags;
 
@@ -336,7 +336,7 @@ type GPUBufferBindingType = "uniform" | "storage" | "read-only-storage";
 interface GPUBufferBindingLayout {
     type?: GPUBufferBindingType; /* default="uniform" */
     hasDynamicOffset?: boolean; /* default=false */
-    minBindingSize?:GPUSize64; /* default=0 */
+    minBindingSize?: GPUSize64; /* default=0 */
 };
 
 type GPUSamplerBindingType = "filtering" | "non-filtering" | "comparison";
@@ -1080,39 +1080,9 @@ interface GPUExtent3DDict {
 }
 type GPUExtent3D = [GPUIntegerCoordinate, GPUIntegerCoordinate, GPUIntegerCoordinate] | GPUExtent3DDict;
 
+// TODO WEBGPU: below to be removed when GPURenderPipelineDescriptor2 implemented by Chrome
 
 
-
-
-
-
-
-
-
-
-
-interface GPUBindGroupLayoutEntry {
-    binding: GPUIndex32;
-    visibility: GPUShaderStageFlags;
-    type: GPUBindingType;
-    hasDynamicOffset?: boolean;
-    minBufferBindingSize?: number;
-    viewDimension?: GPUTextureViewDimension;
-    textureComponentType?: GPUTextureComponentType;
-    storageTextureFormat?: GPUTextureFormat;
-}
-
-type GPUBindingType =
-    | "uniform-buffer"
-    | "storage-buffer"
-    | "readonly-storage-buffer"
-    | "sampler"
-    | "comparison-sampler"
-    | "sampled-texture"
-    | "readonly-storage-texture"
-    | "writeonly-storage-texture";
-type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
-
 interface GPURenderPipelineDescriptor extends GPUPipelineDescriptorBase {
     vertexStage: GPUProgrammableStage;
     fragmentStage?: GPUProgrammableStage;