|
@@ -418,13 +418,13 @@ class WebGPUNodeBuilder extends NodeBuilder {
|
|
|
|
|
|
const snippets = [];
|
|
const snippets = [];
|
|
|
|
|
|
- if ( shaderStage === 'vertex' || shaderStage === 'compute' ) {
|
|
|
|
|
|
+ if ( shaderStage === 'compute' ) {
|
|
|
|
|
|
- if ( shaderStage === 'compute' ) {
|
|
|
|
|
|
+ this.getBuiltin( 'global_invocation_id', 'id', 'vec3<u32>', 'attribute' );
|
|
|
|
|
|
- this.getBuiltin( 'global_invocation_id', 'id', 'vec3<u32>', 'attribute' );
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ if ( shaderStage === 'vertex' || shaderStage === 'compute' ) {
|
|
|
|
|
|
for ( const { name, property, type } of this.builtins.attribute.values() ) {
|
|
for ( const { name, property, type } of this.builtins.attribute.values() ) {
|
|
|
|
|
|
@@ -477,26 +477,9 @@ class WebGPUNodeBuilder extends NodeBuilder {
|
|
|
|
|
|
this.getBuiltin( 'position', 'Vertex', 'vec4<f32>', 'vertex' );
|
|
this.getBuiltin( 'position', 'Vertex', 'vec4<f32>', 'vertex' );
|
|
|
|
|
|
- const varyings = this.varyings;
|
|
|
|
- const vars = this.vars[ shaderStage ];
|
|
|
|
-
|
|
|
|
- for ( let index = 0; index < varyings.length; index ++ ) {
|
|
|
|
-
|
|
|
|
- const varying = varyings[ index ];
|
|
|
|
-
|
|
|
|
- if ( varying.needsInterpolation ) {
|
|
|
|
-
|
|
|
|
- snippets.push( `@location( ${index} ) ${ varying.name } : ${ this.getType( varying.type ) }` );
|
|
|
|
-
|
|
|
|
- } else if ( vars.includes( varying ) === false ) {
|
|
|
|
-
|
|
|
|
- vars.push( varying );
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- } else if ( shaderStage === 'fragment' ) {
|
|
|
|
|
|
+ if ( shaderStage === 'vertex' || shaderStage === 'fragment' ) {
|
|
|
|
|
|
const varyings = this.varyings;
|
|
const varyings = this.varyings;
|
|
const vars = this.vars[ shaderStage ];
|
|
const vars = this.vars[ shaderStage ];
|
|
@@ -543,7 +526,7 @@ class WebGPUNodeBuilder extends NodeBuilder {
|
|
|
|
|
|
for ( const uniform of uniforms ) {
|
|
for ( const uniform of uniforms ) {
|
|
|
|
|
|
- if ( uniform.type === 'texture' ) {
|
|
|
|
|
|
+ if ( uniform.type === 'texture' || uniform.type === 'cubeTexture' ) {
|
|
|
|
|
|
if ( shaderStage === 'fragment' ) {
|
|
if ( shaderStage === 'fragment' ) {
|
|
|
|
|
|
@@ -553,25 +536,23 @@ class WebGPUNodeBuilder extends NodeBuilder {
|
|
|
|
|
|
const texture = uniform.node.value;
|
|
const texture = uniform.node.value;
|
|
|
|
|
|
- if ( texture.isVideoTexture === true ) {
|
|
|
|
-
|
|
|
|
- bindingSnippets.push( `@group( 0 ) @binding( ${index ++} ) var ${uniform.name} : texture_external;` );
|
|
|
|
|
|
+ let textureType;
|
|
|
|
|
|
- } else {
|
|
|
|
|
|
+ if ( texture.isCubeTexture === true ) {
|
|
|
|
|
|
- bindingSnippets.push( `@group( 0 ) @binding( ${index ++} ) var ${uniform.name} : texture_2d<f32>;` );
|
|
|
|
|
|
+ textureType = 'texture_cube<f32>';
|
|
|
|
|
|
- }
|
|
|
|
|
|
+ } else if ( texture.isVideoTexture === true ) {
|
|
|
|
|
|
- } else if ( uniform.type === 'cubeTexture' ) {
|
|
|
|
|
|
+ textureType = 'texture_external';
|
|
|
|
|
|
- if ( shaderStage === 'fragment' ) {
|
|
|
|
|
|
+ } else {
|
|
|
|
|
|
- bindingSnippets.push( `@group( 0 ) @binding( ${index ++} ) var ${uniform.name}_sampler : sampler;` );
|
|
|
|
|
|
+ textureType = 'texture_2d<f32>';
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- bindingSnippets.push( `@group( 0 ) @binding( ${index ++} ) var ${uniform.name} : texture_cube<f32>;` );
|
|
|
|
|
|
+ bindingSnippets.push( `@group( 0 ) @binding( ${index ++} ) var ${uniform.name} : ${textureType};` );
|
|
|
|
|
|
} else if ( uniform.type === 'buffer' || uniform.type === 'storageBuffer' ) {
|
|
} else if ( uniform.type === 'buffer' || uniform.type === 'storageBuffer' ) {
|
|
|
|
|