Sebastien Vandenberghe преди 6 години
родител
ревизия
b10515df07
променени са 2 файла, в които са добавени 34 реда и са изтрити 0 реда
  1. 33 0
      src/Engines/WebGPU/webgpuShaderProcessors.ts
  2. 1 0
      src/LibDeclarations/webgpu.d.ts

+ 33 - 0
src/Engines/WebGPU/webgpuShaderProcessors.ts

@@ -17,10 +17,36 @@ export class WebGPUShaderProcessor implements IShaderProcessor {
 
     public attributeProcessor(attribute: string) {
         return attribute.replace("attribute", "in");
+        // const inOut = isFragment ? "in" : "out";
+        // const attribRegex = new RegExp(/\s+attribute\s+(\w+)\s+/gm);
+
+        // let location = 0;
+        // let match = attribRegex.exec(code);
+        // while (match != null) {
+        //     if (match[1]) {
+        //         code = code.replace(match[0], ` layout(location = ${location}) ${inOut} ${match[1]} `);
+        //         location++;
+        //     }
+        //     match = attribRegex.exec(code);
+        // }
+        // return code;
     }
 
     public varyingProcessor(varying: string, isFragment: boolean) {
         return varying.replace("varying", isFragment ? "in" : "out");
+        // const inOut = isFragment ? "in" : "out";
+        // const attribRegex = new RegExp(/\s+varying\s+(\w+)\s+/gm);
+
+        // let location = 0;
+        // let match = attribRegex.exec(code);
+        // while (match != null) {
+        //     if (match[1]) {
+        //         code = code.replace(match[0], ` layout(location = ${location}) ${inOut} ${match[1]} `);
+        //         location++;
+        //     }
+        //     match = attribRegex.exec(code);
+        // }
+        // return code;
     }
 
     public postProcessor(code: string, defines: string[], isFragment: boolean) {
@@ -47,6 +73,13 @@ export class WebGPUShaderProcessor implements IShaderProcessor {
             }
         }
 
+        // Flip Y.
+        if (!isFragment) {
+            const lastClosingCurly = code.lastIndexOf("}");
+            code = code.substring(0, lastClosingCurly);
+            code += "gl_Position.y *= -1.; }";
+        }
+
         return code;
     }
 }

+ 1 - 0
src/LibDeclarations/webgpu.d.ts

@@ -435,6 +435,7 @@ interface GPURenderPipelineDescriptor extends GPUPipelineDescriptorBase, GPURend
   primitiveTopology?: GPUPrimitiveTopology;
   rasterizationState?: GPURasterizationStateDescriptor;
   sampleCount?: number;
+  sampleMask?:number;
 }
 
 interface GPUSamplerDescriptor {