Skip to content

Commit

Permalink
Ported clearQuad to avoid using twgsl by default (#14933)
Browse files Browse the repository at this point in the history
  • Loading branch information
deltakosh authored Mar 30, 2024
1 parent 9cc9591 commit 040fb05
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 28 deletions.
7 changes: 4 additions & 3 deletions packages/dev/core/src/Engines/WebGPU/webgpuClearQuad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import { WebGPUShaderProcessingContext } from "./webgpuShaderProcessingContext";
import { WebGPUTextureHelper } from "./webgpuTextureHelper";
import { renderableTextureFormatToIndex } from "./webgpuTextureManager";

import "../../Shaders/clearQuad.vertex";
import "../../Shaders/clearQuad.fragment";
import "../../ShadersWGSL/clearQuad.vertex";
import "../../ShadersWGSL/clearQuad.fragment";
import { ShaderLanguage } from "../../Materials/shaderLanguage";

/** @internal */
export class WebGPUClearQuad {
Expand Down Expand Up @@ -49,7 +50,7 @@ export class WebGPUClearQuad {
this._cacheRenderPipeline.setDepthTestEnabled(false);
this._cacheRenderPipeline.setStencilReadMask(0xff);

this._effect = engine.createEffect("clearQuad", [], ["color", "depthValue"]);
this._effect = engine.createEffect("clearQuad", [], ["color", "depthValue"], undefined, undefined, undefined, undefined, undefined, undefined, ShaderLanguage.WGSL);
}

public clear(
Expand Down
5 changes: 0 additions & 5 deletions packages/dev/core/src/Shaders/clearQuad.fragment.fx

This file was deleted.

20 changes: 0 additions & 20 deletions packages/dev/core/src/Shaders/clearQuad.vertex.fx

This file was deleted.

6 changes: 6 additions & 0 deletions packages/dev/core/src/ShadersWGSL/clearQuad.fragment.fx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
uniform color: vec4f;

@fragment
fn main(input: FragmentInputs) -> FragmentOutputs {
fragmentOutputs.color = uniforms.color;
}
20 changes: 20 additions & 0 deletions packages/dev/core/src/ShadersWGSL/clearQuad.vertex.fx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
uniform depthValue: f32;

const pos = array(
vec2f(-1.0, 1.0),
vec2f(1.0, 1.0),
vec2f(-1.0, -1.0),
vec2f(1.0, -1.0)
);


#define CUSTOM_VERTEX_DEFINITIONS

@vertex
fn main(input : VertexInputs) -> FragmentInputs {

#define CUSTOM_VERTEX_MAIN_BEGIN
vertexOutputs.position = vec4f(pos[input.vertexIndex], uniforms.depthValue, 1.0);

#define CUSTOM_VERTEX_MAIN_END
}

0 comments on commit 040fb05

Please sign in to comment.