Переглянути джерело

Set the textureComponentType when texture is used for a comparison sampling: disabled as it does not work in Chrome

Popov72 4 роки тому
батько
коміт
8bbd513d77

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

@@ -59,7 +59,7 @@ export class WebGPUPipelineContext implements IPipelineContext {
     public availableSamplers: { [key: string]: WebGPUTextureSamplerBindingDescription };
 
     public orderedAttributes: string[];
-    public orderedUBOsAndSamplers: { name: string, isSampler: boolean, isComparisonSampler?: boolean, isTexture: boolean, textureDimension?: GPUTextureViewDimension }[][];
+    public orderedUBOsAndSamplers: { name: string, isSampler: boolean, isComparisonSampler?: boolean, isTexture: boolean, textureNeedsDepthComparison?: boolean, textureDimension?: GPUTextureViewDimension }[][];
 
     public leftOverUniforms: { name: string, type: string, length: number }[];
     public leftOverUniformsByName: { [name: string]: string };

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

@@ -39,7 +39,7 @@ export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
     public leftOverUniforms: { name: string, type: string, length: number }[];
 
     public orderedAttributes: string[];
-    public orderedUBOsAndSamplers: { name: string, isSampler: boolean, isComparisonSampler?: boolean, isTexture: boolean, textureIndex?: number, textureDimension?: GPUTextureViewDimension }[][];
+    public orderedUBOsAndSamplers: { name: string, isSampler: boolean, isComparisonSampler?: boolean, isTexture: boolean, textureNeedsDepthComparison?: boolean, textureDimension?: GPUTextureViewDimension }[][];
 
     private _attributeNextLocation: number;
     private _varyingNextLocation: number;

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

@@ -172,6 +172,7 @@ export class WebGPUShaderProcessor implements IShaderProcessor {
                 const samplerType = _samplerTypeByWebGLSamplerType[uniformType] ?? "sampler";
                 const textureType = _textureTypeByWebGLSamplerType[uniformType];
                 const textureDimension = _gpuTextureViewDimensionByWebGPUTextureType[textureType];
+                const isComparisonSampler = !!_isComparisonSamplerByWebGPUSamplerType[samplerType];
 
                 // Manage textures and samplers.
                 if (!isTextureArray) {
@@ -203,7 +204,7 @@ export class WebGPUShaderProcessor implements IShaderProcessor {
                 webgpuProcessingContext.orderedUBOsAndSamplers[samplerSetIndex][samplerBindingIndex] = {
                     isSampler: true,
                     isTexture: false,
-                    isComparisonSampler: _isComparisonSamplerByWebGPUSamplerType[samplerType] ?? false,
+                    isComparisonSampler,
                     name,
                 };
 
@@ -217,9 +218,9 @@ export class WebGPUShaderProcessor implements IShaderProcessor {
                     webgpuProcessingContext.orderedUBOsAndSamplers[textureSetIndex][textureBindingIndex] = {
                         isSampler: false,
                         isTexture: true,
+                        textureNeedsDepthComparison: isComparisonSampler,
                         textureDimension,
                         name: isTextureArray ? name + i.toString() : name,
-                        textureIndex: i,
                     };
                 }
             }

+ 1 - 2
src/Engines/webgpuEngine.ts

@@ -3228,9 +3228,8 @@ export class WebGPUEngine extends Engine {
                         visibility: WebGPUConstants.ShaderStage.Vertex | WebGPUConstants.ShaderStage.Fragment,
                         type: WebGPUConstants.BindingType.SampledTexture,
                         viewDimension: bindingDefinition.textureDimension,
+                        //textureComponentType: bindingDefinition.textureNeedsDepthComparison ? WebGPUConstants.TextureComponentType.DepthComparison : undefined,
                         // TODO WEBGPU. Handle texture component type properly.
-                        // textureComponentType?: GPUTextureComponentType,
-                        // multisampled?: boolean;
                         // hasDynamicOffset?: boolean;
                         // storageTextureFormat?: GPUTextureFormat;
                         // minBufferBindingSize?: number;