diff --git a/sample/a-buffer/composite.wgsl b/sample/a-buffer/composite.wgsl index 09ff0af6..72604372 100644 --- a/sample/a-buffer/composite.wgsl +++ b/sample/a-buffer/composite.wgsl @@ -1,5 +1,5 @@ struct Uniforms { - modelViewProjectionMatrix: mat4x4, + modelViewProjectionMatrix: mat4x4f, maxStorableFragments: u32, targetWidth: u32, }; @@ -14,7 +14,7 @@ struct Heads { }; struct LinkedListElement { - color: vec4, + color: vec4f, depth: f32, next: u32 }; @@ -30,8 +30,8 @@ struct LinkedList { // Output a full screen quad @vertex -fn main_vs(@builtin(vertex_index) vertIndex: u32) -> @builtin(position) vec4 { - const position = array, 6>( +fn main_vs(@builtin(vertex_index) vertIndex: u32) -> @builtin(position) vec4f { + const position = array( vec2(-1.0, -1.0), vec2(1.0, -1.0), vec2(1.0, 1.0), @@ -44,8 +44,8 @@ fn main_vs(@builtin(vertex_index) vertIndex: u32) -> @builtin(position) vec4) -> @location(0) vec4 { - let fragCoords = vec2(position.xy); +fn main_fs(@builtin(position) position: vec4f) -> @location(0) vec4f { + let fragCoords = vec2i(position.xy); let headsIndex = u32(fragCoords.y - sliceInfo.sliceStartY) * uniforms.targetWidth + u32(fragCoords.x); // The maximum layers we can process for any pixel diff --git a/sample/a-buffer/main.ts b/sample/a-buffer/main.ts index 39f8b2b3..ede56880 100644 --- a/sample/a-buffer/main.ts +++ b/sample/a-buffer/main.ts @@ -62,7 +62,7 @@ const indexBuffer = device.createBuffer({ } // Uniforms contains: -// * modelViewProjectionMatrix: mat4x4 +// * modelViewProjectionMatrix: mat4x4f // * maxStorableFragments: u32 // * targetWidth: u32 const uniformsSize = roundUp( @@ -365,7 +365,7 @@ const configure = () => { const averageLayersPerFragment = 4; // Each element stores - // * color : vec4 + // * color : vec4f // * depth : f32 // * index of next element in the list : u32 const linkedListElementSize = diff --git a/sample/a-buffer/opaque.wgsl b/sample/a-buffer/opaque.wgsl index 2f9ab25b..ec943f64 100644 --- a/sample/a-buffer/opaque.wgsl +++ b/sample/a-buffer/opaque.wgsl @@ -1,16 +1,16 @@ struct Uniforms { - modelViewProjectionMatrix: mat4x4, + modelViewProjectionMatrix: mat4x4f, }; @binding(0) @group(0) var uniforms: Uniforms; struct VertexOutput { - @builtin(position) position: vec4, + @builtin(position) position: vec4f, @location(0) @interpolate(flat) instance: u32 }; @vertex -fn main_vs(@location(0) position: vec4, @builtin(instance_index) instance: u32) -> VertexOutput { +fn main_vs(@location(0) position: vec4f, @builtin(instance_index) instance: u32) -> VertexOutput { var output: VertexOutput; // distribute instances into a staggered 4x4 grid @@ -30,8 +30,8 @@ fn main_vs(@location(0) position: vec4, @builtin(instance_index) instance: } @fragment -fn main_fs(@location(0) @interpolate(flat) instance: u32) -> @location(0) vec4 { - const colors = array,6>( +fn main_fs(@location(0) @interpolate(flat) instance: u32) -> @location(0) vec4f { + const colors = array( vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, 0.0, 1.0), diff --git a/sample/a-buffer/translucent.wgsl b/sample/a-buffer/translucent.wgsl index 22399d5a..b74bc096 100644 --- a/sample/a-buffer/translucent.wgsl +++ b/sample/a-buffer/translucent.wgsl @@ -1,5 +1,5 @@ struct Uniforms { - modelViewProjectionMatrix: mat4x4, + modelViewProjectionMatrix: mat4x4f, maxStorableFragments: u32, targetWidth: u32, }; @@ -14,7 +14,7 @@ struct Heads { }; struct LinkedListElement { - color: vec4, + color: vec4f, depth: f32, next: u32 }; @@ -30,12 +30,12 @@ struct LinkedList { @binding(4) @group(0) var sliceInfo: SliceInfo; struct VertexOutput { - @builtin(position) position: vec4, + @builtin(position) position: vec4f, @location(0) @interpolate(flat) instance: u32 }; @vertex -fn main_vs(@location(0) position: vec4, @builtin(instance_index) instance: u32) -> VertexOutput { +fn main_vs(@location(0) position: vec4f, @builtin(instance_index) instance: u32) -> VertexOutput { var output: VertexOutput; // distribute instances into a staggered 4x4 grid @@ -56,8 +56,8 @@ fn main_vs(@location(0) position: vec4, @builtin(instance_index) instance: } @fragment -fn main_fs(@builtin(position) position: vec4, @location(0) @interpolate(flat) instance: u32) { - const colors = array,6>( +fn main_fs(@builtin(position) position: vec4f, @location(0) @interpolate(flat) instance: u32) { + const colors = array( vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, 0.0, 1.0), @@ -66,7 +66,7 @@ fn main_fs(@builtin(position) position: vec4, @location(0) @interpolate(fla vec3(0.0, 1.0, 1.0), ); - let fragCoords = vec2(position.xy); + let fragCoords = vec2i(position.xy); let opaqueDepth = textureLoad(opaqueDepthTexture, fragCoords, 0); // reject fragments behind opaque objects diff --git a/sample/animometer/animometer.wgsl b/sample/animometer/animometer.wgsl index b38d4660..3b1bed18 100644 --- a/sample/animometer/animometer.wgsl +++ b/sample/animometer/animometer.wgsl @@ -14,14 +14,14 @@ struct Uniforms { @binding(0) @group(1) var uniforms : Uniforms; struct VertexOutput { - @builtin(position) Position : vec4, - @location(0) v_color : vec4, + @builtin(position) Position : vec4f, + @location(0) v_color : vec4f, } @vertex fn vert_main( - @location(0) position : vec4, - @location(1) color : vec4 + @location(0) position : vec4f, + @location(1) color : vec4f ) -> VertexOutput { var fade = (uniforms.scalarOffset + time.value * uniforms.scalar / 10.0) % 1.0; if (fade < 0.5) { @@ -44,6 +44,6 @@ fn vert_main( } @fragment -fn frag_main(@location(0) v_color : vec4) -> @location(0) vec4 { +fn frag_main(@location(0) v_color : vec4f) -> @location(0) vec4f { return v_color; } diff --git a/sample/bitonicSort/bitonicCompute.ts b/sample/bitonicSort/bitonicCompute.ts index 0b11f8f2..8e05334f 100644 --- a/sample/bitonicSort/bitonicCompute.ts +++ b/sample/bitonicSort/bitonicCompute.ts @@ -36,12 +36,12 @@ fn local_compare_and_swap(idx_before: u32, idx_after: u32) { } // invoke_id goes from 0 to workgroupSize -fn get_flip_indices(invoke_id: u32, block_height: u32) -> vec2 { +fn get_flip_indices(invoke_id: u32, block_height: u32) -> vec2u { // Caculate index offset (i.e move indices into correct block) let block_offset: u32 = ((2 * invoke_id) / block_height) * block_height; let half_height = block_height / 2; // Calculate index spacing - var idx: vec2 = vec2( + var idx: vec2u = vec2u( invoke_id % half_height, block_height - (invoke_id % half_height) - 1, ); idx.x += block_offset; @@ -49,10 +49,10 @@ fn get_flip_indices(invoke_id: u32, block_height: u32) -> vec2 { return idx; } -fn get_disperse_indices(invoke_id: u32, block_height: u32) -> vec2 { +fn get_disperse_indices(invoke_id: u32, block_height: u32) -> vec2u { var block_offset: u32 = ((2 * invoke_id) / block_height) * block_height; let half_height = block_height / 2; - var idx: vec2 = vec2( + var idx: vec2u = vec2u( invoke_id % half_height, (invoke_id % half_height) + half_height ); idx.x += block_offset; @@ -76,9 +76,9 @@ const ALGO_GLOBAL_FLIP = 3; // Our compute shader will execute specified # of invocations or elements / 2 invocations @compute @workgroup_size(${workgroupSize}, 1, 1) fn computeMain( - @builtin(global_invocation_id) global_id: vec3, - @builtin(local_invocation_id) local_id: vec3, - @builtin(workgroup_id) workgroup_id: vec3, + @builtin(global_invocation_id) global_id: vec3u, + @builtin(local_invocation_id) local_id: vec3u, + @builtin(workgroup_id) workgroup_id: vec3u, ) { let offset = ${workgroupSize} * 2 * workgroup_id.x; diff --git a/sample/bitonicSort/bitonicDisplay.frag.wgsl b/sample/bitonicSort/bitonicDisplay.frag.wgsl index 17842eab..33bbf49c 100644 --- a/sample/bitonicSort/bitonicDisplay.frag.wgsl +++ b/sample/bitonicSort/bitonicDisplay.frag.wgsl @@ -11,8 +11,8 @@ struct FragmentUniforms { } struct VertexOutput { - @builtin(position) Position: vec4, - @location(0) fragUV: vec2 + @builtin(position) Position: vec4f, + @location(0) fragUV: vec2f } // Uniforms from compute shader @@ -22,13 +22,13 @@ struct VertexOutput { @group(1) @binding(0) var fragment_uniforms: FragmentUniforms; @fragment -fn frag_main(input: VertexOutput) -> @location(0) vec4 { - var uv: vec2 = vec2( +fn frag_main(input: VertexOutput) -> @location(0) vec4f { + var uv: vec2f = vec2f( input.fragUV.x * uniforms.width, input.fragUV.y * uniforms.height ); - var pixel: vec2 = vec2( + var pixel: vec2u = vec2u( u32(floor(uv.x)), u32(floor(uv.y)), ); @@ -41,16 +41,16 @@ fn frag_main(input: VertexOutput) -> @location(0) vec4 { if (fragment_uniforms.highlight == 1) { return select( //If element is above halfHeight, highlight green - vec4(vec3(0.0, 1.0 - subtracter, 0.0).rgb, 1.0), + vec4f(vec3f(0.0, 1.0 - subtracter, 0.0).rgb, 1.0), //If element is below halfheight, highlight red - vec4(vec3(1.0 - subtracter, 0.0, 0.0).rgb, 1.0), + vec4f(vec3f(1.0 - subtracter, 0.0, 0.0).rgb, 1.0), elementIndex % uniforms.blockHeight < uniforms.blockHeight / 2 ); } - var color: vec3 = vec3f( + var color: vec3f = vec3f( 1.0 - subtracter ); - return vec4(color.rgb, 1.0); + return vec4f(color.rgb, 1.0); } diff --git a/sample/cameras/cube.wgsl b/sample/cameras/cube.wgsl index 9ca444c5..0513561f 100644 --- a/sample/cameras/cube.wgsl +++ b/sample/cameras/cube.wgsl @@ -1,5 +1,5 @@ struct Uniforms { - modelViewProjectionMatrix : mat4x4, + modelViewProjectionMatrix : mat4x4f, } @group(0) @binding(0) var uniforms : Uniforms; diff --git a/sample/computeBoids/sprite.wgsl b/sample/computeBoids/sprite.wgsl index ecc2978e..ec58780a 100644 --- a/sample/computeBoids/sprite.wgsl +++ b/sample/computeBoids/sprite.wgsl @@ -1,13 +1,13 @@ struct VertexOutput { - @builtin(position) position : vec4, - @location(4) color : vec4, + @builtin(position) position : vec4f, + @location(4) color : vec4f, } @vertex fn vert_main( - @location(0) a_particlePos : vec2, - @location(1) a_particleVel : vec2, - @location(2) a_pos : vec2 + @location(0) a_particlePos : vec2f, + @location(1) a_particleVel : vec2f, + @location(2) a_pos : vec2f ) -> VertexOutput { let angle = -atan2(a_particleVel.x, a_particleVel.y); let pos = vec2( @@ -26,6 +26,6 @@ fn vert_main( } @fragment -fn frag_main(@location(4) color : vec4) -> @location(0) vec4 { +fn frag_main(@location(4) color : vec4f) -> @location(0) vec4f { return color; } diff --git a/sample/computeBoids/updateSprites.wgsl b/sample/computeBoids/updateSprites.wgsl index 4aa4eaa2..afc68956 100644 --- a/sample/computeBoids/updateSprites.wgsl +++ b/sample/computeBoids/updateSprites.wgsl @@ -1,6 +1,6 @@ struct Particle { - pos : vec2, - vel : vec2, + pos : vec2f, + vel : vec2f, } struct SimParams { deltaT : f32, @@ -20,7 +20,7 @@ struct Particles { // https://github.com/austinEng/Project6-Vulkan-Flocking/blob/master/data/shaders/computeparticles/particle.comp @compute @workgroup_size(64) -fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3) { +fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3u) { var index = GlobalInvocationID.x; var vPos = particlesA.particles[index].pos; @@ -30,8 +30,8 @@ fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3) { var colVel = vec2(0.0); var cMassCount = 0u; var cVelCount = 0u; - var pos : vec2; - var vel : vec2; + var pos : vec2f; + var vel : vec2f; for (var i = 0u; i < arrayLength(&particlesA.particles); i++) { if (i == index) { diff --git a/sample/cubemap/sampleCubemap.frag.wgsl b/sample/cubemap/sampleCubemap.frag.wgsl index 70d979f8..757b42d0 100644 --- a/sample/cubemap/sampleCubemap.frag.wgsl +++ b/sample/cubemap/sampleCubemap.frag.wgsl @@ -3,9 +3,9 @@ @fragment fn main( - @location(0) fragUV: vec2, - @location(1) fragPosition: vec4 -) -> @location(0) vec4 { + @location(0) fragUV: vec2f, + @location(1) fragPosition: vec4f +) -> @location(0) vec4f { // Our camera and the skybox cube are both centered at (0, 0, 0) // so we can use the cube geomtry position to get viewing vector to sample the cube texture. // The magnitude of the vector doesn't matter. diff --git a/sample/deferredRendering/fragmentDeferredRendering.wgsl b/sample/deferredRendering/fragmentDeferredRendering.wgsl index 2f90bddd..27031753 100644 --- a/sample/deferredRendering/fragmentDeferredRendering.wgsl +++ b/sample/deferredRendering/fragmentDeferredRendering.wgsl @@ -3,8 +3,8 @@ @group(0) @binding(2) var gBufferDepth: texture_depth_2d; struct LightData { - position : vec4, - color : vec3, + position : vec4f, + color : vec3f, radius : f32, } struct LightsBuffer { @@ -16,13 +16,13 @@ struct Config { numLights : u32, } struct Camera { - viewProjectionMatrix : mat4x4, - invViewProjectionMatrix : mat4x4, + viewProjectionMatrix : mat4x4f, + invViewProjectionMatrix : mat4x4f, } @group(1) @binding(1) var config: Config; @group(1) @binding(2) var camera: Camera; -fn world_from_screen_coord(coord : vec2, depth_sample: f32) -> vec3 { +fn world_from_screen_coord(coord : vec2f, depth_sample: f32) -> vec3f { // reconstruct world-space position from the screen coordinate. let posClip = vec4(coord.x * 2.0 - 1.0, (1.0 - coord.y) * 2.0 - 1.0, depth_sample, 1.0); let posWorldW = camera.invViewProjectionMatrix * posClip; @@ -32,13 +32,13 @@ fn world_from_screen_coord(coord : vec2, depth_sample: f32) -> vec3 { @fragment fn main( - @builtin(position) coord : vec4 -) -> @location(0) vec4 { - var result : vec3; + @builtin(position) coord : vec4f +) -> @location(0) vec4f { + var result : vec3f; let depth = textureLoad( gBufferDepth, - vec2(floor(coord.xy)), + vec2i(floor(coord.xy)), 0 ); @@ -48,18 +48,18 @@ fn main( } let bufferSize = textureDimensions(gBufferDepth); - let coordUV = coord.xy / vec2(bufferSize); + let coordUV = coord.xy / vec2f(bufferSize); let position = world_from_screen_coord(coordUV, depth); let normal = textureLoad( gBufferNormal, - vec2(floor(coord.xy)), + vec2i(floor(coord.xy)), 0 ).xyz; let albedo = textureLoad( gBufferAlbedo, - vec2(floor(coord.xy)), + vec2i(floor(coord.xy)), 0 ).rgb; @@ -70,7 +70,7 @@ fn main( continue; } let lambert = max(dot(normal, normalize(L)), 0.0); - result += vec3( + result += vec3f( lambert * pow(1.0 - distance / lightsBuffer.lights[i].radius, 2.0) * lightsBuffer.lights[i].color * albedo ); } diff --git a/sample/deferredRendering/fragmentGBuffersDebugView.wgsl b/sample/deferredRendering/fragmentGBuffersDebugView.wgsl index 28ef03b3..6e40e2e7 100644 --- a/sample/deferredRendering/fragmentGBuffersDebugView.wgsl +++ b/sample/deferredRendering/fragmentGBuffersDebugView.wgsl @@ -7,14 +7,14 @@ override canvasSizeHeight: f32; @fragment fn main( - @builtin(position) coord : vec4 -) -> @location(0) vec4 { - var result : vec4; - let c = coord.xy / vec2(canvasSizeWidth, canvasSizeHeight); + @builtin(position) coord : vec4f +) -> @location(0) vec4f { + var result : vec4f; + let c = coord.xy / vec2f(canvasSizeWidth, canvasSizeHeight); if (c.x < 0.33333) { let rawDepth = textureLoad( gBufferDepth, - vec2(floor(coord.xy)), + vec2i(floor(coord.xy)), 0 ); // remap depth into something a bit more visible @@ -23,7 +23,7 @@ fn main( } else if (c.x < 0.66667) { result = textureLoad( gBufferNormal, - vec2(floor(coord.xy)), + vec2i(floor(coord.xy)), 0 ); result.x = (result.x + 1.0) * 0.5; @@ -32,7 +32,7 @@ fn main( } else { result = textureLoad( gBufferAlbedo, - vec2(floor(coord.xy)), + vec2i(floor(coord.xy)), 0 ); } diff --git a/sample/deferredRendering/fragmentWriteGBuffers.wgsl b/sample/deferredRendering/fragmentWriteGBuffers.wgsl index f90d0554..3658313f 100644 --- a/sample/deferredRendering/fragmentWriteGBuffers.wgsl +++ b/sample/deferredRendering/fragmentWriteGBuffers.wgsl @@ -1,14 +1,14 @@ struct GBufferOutput { - @location(0) normal : vec4, + @location(0) normal : vec4f, // Textures: diffuse color, specular color, smoothness, emissive etc. could go here - @location(1) albedo : vec4, + @location(1) albedo : vec4f, } @fragment fn main( - @location(0) fragNormal: vec3, - @location(1) fragUV : vec2 + @location(0) fragNormal: vec3f, + @location(1) fragUV : vec2f ) -> GBufferOutput { // faking some kind of checkerboard texture let uv = floor(30.0 * fragUV); diff --git a/sample/deferredRendering/lightUpdate.wgsl b/sample/deferredRendering/lightUpdate.wgsl index 2c7672dd..a2ca49e4 100644 --- a/sample/deferredRendering/lightUpdate.wgsl +++ b/sample/deferredRendering/lightUpdate.wgsl @@ -1,6 +1,6 @@ struct LightData { - position : vec4, - color : vec3, + position : vec4f, + color : vec3f, radius : f32, } struct LightsBuffer { @@ -14,13 +14,13 @@ struct Config { @group(0) @binding(1) var config: Config; struct LightExtent { - min : vec4, - max : vec4, + min : vec4f, + max : vec4f, } @group(0) @binding(2) var lightExtent: LightExtent; @compute @workgroup_size(64, 1, 1) -fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3) { +fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3u) { var index = GlobalInvocationID.x; if (index >= config.numLights) { return; diff --git a/sample/deferredRendering/vertexTextureQuad.wgsl b/sample/deferredRendering/vertexTextureQuad.wgsl index c2cfb18b..c1802e7d 100644 --- a/sample/deferredRendering/vertexTextureQuad.wgsl +++ b/sample/deferredRendering/vertexTextureQuad.wgsl @@ -1,11 +1,11 @@ @vertex fn main( @builtin(vertex_index) VertexIndex : u32 -) -> @builtin(position) vec4 { +) -> @builtin(position) vec4f { const pos = array( vec2(-1.0, -1.0), vec2(1.0, -1.0), vec2(-1.0, 1.0), vec2(-1.0, 1.0), vec2(1.0, -1.0), vec2(1.0, 1.0), ); - return vec4(pos[VertexIndex], 0.0, 1.0); + return vec4f(pos[VertexIndex], 0.0, 1.0); } diff --git a/sample/deferredRendering/vertexWriteGBuffers.wgsl b/sample/deferredRendering/vertexWriteGBuffers.wgsl index eb3b930e..6ffe79ef 100644 --- a/sample/deferredRendering/vertexWriteGBuffers.wgsl +++ b/sample/deferredRendering/vertexWriteGBuffers.wgsl @@ -1,25 +1,25 @@ struct Uniforms { - modelMatrix : mat4x4, - normalModelMatrix : mat4x4, + modelMatrix : mat4x4f, + normalModelMatrix : mat4x4f, } struct Camera { - viewProjectionMatrix : mat4x4, - invViewProjectionMatrix : mat4x4, + viewProjectionMatrix : mat4x4f, + invViewProjectionMatrix : mat4x4f, } @group(0) @binding(0) var uniforms : Uniforms; @group(0) @binding(1) var camera : Camera; struct VertexOutput { - @builtin(position) Position : vec4, - @location(0) fragNormal: vec3, // normal in world space - @location(1) fragUV: vec2, + @builtin(position) Position : vec4f, + @location(0) fragNormal: vec3f, // normal in world space + @location(1) fragUV: vec2f, } @vertex fn main( - @location(0) position : vec3, - @location(1) normal : vec3, - @location(2) uv : vec2 + @location(0) position : vec3f, + @location(1) normal : vec3f, + @location(2) uv : vec2f ) -> VertexOutput { var output : VertexOutput; let worldPosition = (uniforms.modelMatrix * vec4(position, 1.0)).xyz; diff --git a/sample/fractalCube/sampleSelf.frag.wgsl b/sample/fractalCube/sampleSelf.frag.wgsl index 54192e37..f2c4c14b 100644 --- a/sample/fractalCube/sampleSelf.frag.wgsl +++ b/sample/fractalCube/sampleSelf.frag.wgsl @@ -3,9 +3,9 @@ @fragment fn main( - @location(0) fragUV: vec2, - @location(1) fragPosition: vec4 -) -> @location(0) vec4 { + @location(0) fragUV: vec2f, + @location(1) fragPosition: vec4f +) -> @location(0) vec4f { let texColor = textureSample(myTexture, mySampler, fragUV * 0.8 + vec2(0.1)); let f = select(1.0, 0.0, length(texColor.rgb - vec3(0.5)) < 0.01); return f * texColor + (1.0 - f) * fragPosition; diff --git a/sample/gameOfLife/compute.wgsl b/sample/gameOfLife/compute.wgsl index a9b92f29..286ae7f6 100644 --- a/sample/gameOfLife/compute.wgsl +++ b/sample/gameOfLife/compute.wgsl @@ -1,4 +1,4 @@ -@binding(0) @group(0) var size: vec2; +@binding(0) @group(0) var size: vec2u; @binding(1) @group(0) var current: array; @binding(2) @group(0) var next: array; @@ -22,7 +22,7 @@ fn countNeighbors(x: u32, y: u32) -> u32 { } @compute @workgroup_size(blockSize, blockSize) -fn main(@builtin(global_invocation_id) grid: vec3) { +fn main(@builtin(global_invocation_id) grid: vec3u) { let x = grid.x; let y = grid.y; let n = countNeighbors(x, y); diff --git a/sample/gameOfLife/frag.wgsl b/sample/gameOfLife/frag.wgsl index f70d1f95..d17c5889 100644 --- a/sample/gameOfLife/frag.wgsl +++ b/sample/gameOfLife/frag.wgsl @@ -1,4 +1,4 @@ @fragment -fn main(@location(0) cell: f32) -> @location(0) vec4 { - return vec4(cell, cell, cell, 1.); +fn main(@location(0) cell: f32) -> @location(0) vec4f { + return vec4f(cell, cell, cell, 1.); } diff --git a/sample/gameOfLife/vert.wgsl b/sample/gameOfLife/vert.wgsl index 443cf6ba..07649a14 100644 --- a/sample/gameOfLife/vert.wgsl +++ b/sample/gameOfLife/vert.wgsl @@ -1,16 +1,16 @@ struct Out { - @builtin(position) pos: vec4, + @builtin(position) pos: vec4f, @location(0) cell: f32, } -@binding(0) @group(0) var size: vec2; +@binding(0) @group(0) var size: vec2u; @vertex -fn main(@builtin(instance_index) i: u32, @location(0) cell: u32, @location(1) pos: vec2) -> Out { +fn main(@builtin(instance_index) i: u32, @location(0) cell: u32, @location(1) pos: vec2u) -> Out { let w = size.x; let h = size.y; let x = (f32(i % w + pos.x) / f32(w) - 0.5) * 2. * f32(w) / f32(max(w, h)); let y = (f32((i - (i % w)) / w + pos.y) / f32(h) - 0.5) * 2. * f32(h) / f32(max(w, h)); - return Out(vec4(x, y, 0., 1.), f32(cell)); + return Out(vec4f(x, y, 0., 1.), f32(cell)); } diff --git a/sample/imageBlur/blur.wgsl b/sample/imageBlur/blur.wgsl index e8c5d1be..ef4184f0 100644 --- a/sample/imageBlur/blur.wgsl +++ b/sample/imageBlur/blur.wgsl @@ -27,16 +27,16 @@ struct Flip { // square blocks of size 128 - (filterSize - 1). We compute the number of blocks // needed in Javascript and dispatch that amount. -var tile : array, 128>, 4>; +var tile : array, 4>; @compute @workgroup_size(32, 1, 1) fn main( - @builtin(workgroup_id) WorkGroupID : vec3, - @builtin(local_invocation_id) LocalInvocationID : vec3 + @builtin(workgroup_id) WorkGroupID : vec3u, + @builtin(local_invocation_id) LocalInvocationID : vec3u ) { let filterOffset = (params.filterDim - 1) / 2; - let dims = vec2(textureDimensions(inputTex, 0)); - let baseIndex = vec2(WorkGroupID.xy * vec2(params.blockDim, 4) + + let dims = vec2i(textureDimensions(inputTex, 0)); + let baseIndex = vec2i(WorkGroupID.xy * vec2(params.blockDim, 4) + LocalInvocationID.xy * vec2(4, 1)) - vec2(filterOffset, 0); @@ -50,7 +50,7 @@ fn main( tile[r][4 * LocalInvocationID.x + u32(c)] = textureSampleLevel( inputTex, samp, - (vec2(loadIndex) + vec2(0.25, 0.25)) / vec2(dims), + (vec2f(loadIndex) + vec2f(0.25, 0.25)) / vec2f(dims), 0.0 ).rgb; } diff --git a/sample/instancedCube/instanced.vert.wgsl b/sample/instancedCube/instanced.vert.wgsl index 933dafda..c1ccb98b 100644 --- a/sample/instancedCube/instanced.vert.wgsl +++ b/sample/instancedCube/instanced.vert.wgsl @@ -1,20 +1,20 @@ struct Uniforms { - modelViewProjectionMatrix : array, 16>, + modelViewProjectionMatrix : array, } @binding(0) @group(0) var uniforms : Uniforms; struct VertexOutput { - @builtin(position) Position : vec4, - @location(0) fragUV : vec2, - @location(1) fragPosition: vec4, + @builtin(position) Position : vec4f, + @location(0) fragUV : vec2f, + @location(1) fragPosition: vec4f, } @vertex fn main( @builtin(instance_index) instanceIdx : u32, - @location(0) position : vec4, - @location(1) uv : vec2 + @location(0) position : vec4f, + @location(1) uv : vec2f ) -> VertexOutput { var output : VertexOutput; output.Position = uniforms.modelViewProjectionMatrix[instanceIdx] * position; diff --git a/sample/particles/main.ts b/sample/particles/main.ts index 66e3da7f..c4353b2a 100644 --- a/sample/particles/main.ts +++ b/sample/particles/main.ts @@ -65,7 +65,7 @@ const renderPipeline = device.createRenderPipeline({ }, { // quad vertex buffer - arrayStride: 2 * 4, // vec2 + arrayStride: 2 * 4, // vec2f stepMode: 'vertex', attributes: [ { @@ -118,10 +118,10 @@ const depthTexture = device.createTexture({ }); const uniformBufferSize = - 4 * 4 * 4 + // modelViewProjectionMatrix : mat4x4 - 3 * 4 + // right : vec3 + 4 * 4 * 4 + // modelViewProjectionMatrix : mat4x4f + 3 * 4 + // right : vec3f 4 + // padding - 3 * 4 + // up : vec3 + 3 * 4 + // up : vec3f 4 + // padding 0; const uniformBuffer = device.createBuffer({ @@ -163,7 +163,7 @@ const renderPassDescriptor: GPURenderPassDescriptor = { // Quad vertex buffer ////////////////////////////////////////////////////////////////////////////// const quadVertexBuffer = device.createBuffer({ - size: 6 * 2 * 4, // 6x vec2 + size: 6 * 2 * 4, // 6x vec2f usage: GPUBufferUsage.VERTEX, mappedAtCreation: true, }); diff --git a/sample/particles/particle.wgsl b/sample/particles/particle.wgsl index 40987a4d..15c3f604 100644 --- a/sample/particles/particle.wgsl +++ b/sample/particles/particle.wgsl @@ -1,17 +1,17 @@ //////////////////////////////////////////////////////////////////////////////// // Utilities //////////////////////////////////////////////////////////////////////////////// -var rand_seed : vec2; +var rand_seed : vec2f; -fn init_rand(invocation_id : u32, seed : vec4) { +fn init_rand(invocation_id : u32, seed : vec4f) { rand_seed = seed.xz; rand_seed = fract(rand_seed * cos(35.456+f32(invocation_id) * seed.yw)); rand_seed = fract(rand_seed * cos(41.235+f32(invocation_id) * seed.xw)); } fn rand() -> f32 { - rand_seed.x = fract(cos(dot(rand_seed, vec2(23.14077926, 232.61690225))) * 136.8168); - rand_seed.y = fract(cos(dot(rand_seed, vec2(54.47856553, 345.84153136))) * 534.7645); + rand_seed.x = fract(cos(dot(rand_seed, vec2f(23.14077926, 232.61690225))) * 136.8168); + rand_seed.y = fract(cos(dot(rand_seed, vec2f(54.47856553, 345.84153136))) * 534.7645); return rand_seed.y; } @@ -19,30 +19,30 @@ fn rand() -> f32 { // Vertex shader //////////////////////////////////////////////////////////////////////////////// struct RenderParams { - modelViewProjectionMatrix : mat4x4, - right : vec3, - up : vec3 + modelViewProjectionMatrix : mat4x4f, + right : vec3f, + up : vec3f } @binding(0) @group(0) var render_params : RenderParams; struct VertexInput { - @location(0) position : vec3, - @location(1) color : vec4, - @location(2) quad_pos : vec2, // -1..+1 + @location(0) position : vec3f, + @location(1) color : vec4f, + @location(2) quad_pos : vec2f, // -1..+1 } struct VertexOutput { - @builtin(position) position : vec4, - @location(0) color : vec4, - @location(1) quad_pos : vec2, // -1..+1 + @builtin(position) position : vec4f, + @location(0) color : vec4f, + @location(1) quad_pos : vec2f, // -1..+1 } @vertex fn vs_main(in : VertexInput) -> VertexOutput { - var quad_pos = mat2x3(render_params.right, render_params.up) * in.quad_pos; + var quad_pos = mat2x3f(render_params.right, render_params.up) * in.quad_pos; var position = in.position + quad_pos * 0.01; var out : VertexOutput; - out.position = render_params.modelViewProjectionMatrix * vec4(position, 1.0); + out.position = render_params.modelViewProjectionMatrix * vec4f(position, 1.0); out.color = in.color; out.quad_pos = in.quad_pos; return out; @@ -52,7 +52,7 @@ fn vs_main(in : VertexInput) -> VertexOutput { // Fragment shader //////////////////////////////////////////////////////////////////////////////// @fragment -fn fs_main(in : VertexOutput) -> @location(0) vec4 { +fn fs_main(in : VertexOutput) -> @location(0) vec4f { var color = in.color; // Apply a circular particle alpha mask color.a = color.a * max(1.0 - length(in.quad_pos), 0.0); @@ -64,14 +64,14 @@ fn fs_main(in : VertexOutput) -> @location(0) vec4 { //////////////////////////////////////////////////////////////////////////////// struct SimulationParams { deltaTime : f32, - seed : vec4, + seed : vec4f, } struct Particle { - position : vec3, + position : vec3f, lifetime : f32, - color : vec4, - velocity : vec3, + color : vec4f, + velocity : vec3f, } struct Particles { @@ -83,7 +83,7 @@ struct Particles { @binding(2) @group(0) var texture : texture_2d; @compute @workgroup_size(64) -fn simulate(@builtin(global_invocation_id) global_invocation_id : vec3) { +fn simulate(@builtin(global_invocation_id) global_invocation_id : vec3u) { let idx = global_invocation_id.x; init_rand(idx, sim_params.seed); @@ -105,7 +105,7 @@ fn simulate(@builtin(global_invocation_id) global_invocation_id : vec3) { if (particle.lifetime < 0.0) { // Use the probability map to find where the particle should be spawned. // Starting with the 1x1 mip level. - var coord : vec2; + var coord : vec2i; for (var level = u32(textureNumLevels(texture) - 1); level > 0; level--) { // Load the probability value from the mip-level // Generate a random number and using the probabilty values, pick the @@ -116,14 +116,14 @@ fn simulate(@builtin(global_invocation_id) global_invocation_id : vec3) { // | TOP-LEFT | TOP-RIGHT | BOTTOM-LEFT | BOTTOM_RIGHT | // let probabilites = textureLoad(texture, coord, level); - let value = vec4(rand()); - let mask = (value >= vec4(0.0, probabilites.xyz)) & (value < probabilites); + let value = vec4f(rand()); + let mask = (value >= vec4f(0.0, probabilites.xyz)) & (value < probabilites); coord = coord * 2; coord.x = coord.x + select(0, 1, any(mask.yw)); // x y coord.y = coord.y + select(0, 1, any(mask.zw)); // z w } - let uv = vec2(coord) / vec2(textureDimensions(texture)); - particle.position = vec3((uv - 0.5) * 3.0 * vec2(1.0, -1.0), 0.0); + let uv = vec2f(coord) / vec2f(textureDimensions(texture)); + particle.position = vec3f((uv - 0.5) * 3.0 * vec2f(1.0, -1.0), 0.0); particle.color = textureLoad(texture, coord, 0); particle.velocity.x = (rand() - 0.5) * 0.1; particle.velocity.y = (rand() - 0.5) * 0.1; diff --git a/sample/particles/probabilityMap.wgsl b/sample/particles/probabilityMap.wgsl index aa51c0e8..62d8b7d5 100644 --- a/sample/particles/probabilityMap.wgsl +++ b/sample/particles/probabilityMap.wgsl @@ -20,10 +20,10 @@ struct Buffer { // the buf_out.weights. //////////////////////////////////////////////////////////////////////////////// @compute @workgroup_size(64) -fn import_level(@builtin(global_invocation_id) coord : vec3) { +fn import_level(@builtin(global_invocation_id) coord : vec3u) { _ = &buf_in; let offset = coord.x + coord.y * ubo.width; - buf_out.weights[offset] = textureLoad(tex_in, vec2(coord.xy), 0).w; + buf_out.weights[offset] = textureLoad(tex_in, vec2i(coord.xy), 0).w; } //////////////////////////////////////////////////////////////////////////////// @@ -35,8 +35,8 @@ fn import_level(@builtin(global_invocation_id) coord : vec3) { // probability logic. //////////////////////////////////////////////////////////////////////////////// @compute @workgroup_size(64) -fn export_level(@builtin(global_invocation_id) coord : vec3) { - if (all(coord.xy < vec2(textureDimensions(tex_out)))) { +fn export_level(@builtin(global_invocation_id) coord : vec3u) { + if (all(coord.xy < vec2u(textureDimensions(tex_out)))) { let dst_offset = coord.x + coord.y * ubo.width; let src_offset = coord.x*2u + coord.y*2u * ubo.width; @@ -44,11 +44,11 @@ fn export_level(@builtin(global_invocation_id) coord : vec3) { let b = buf_in.weights[src_offset + 1u]; let c = buf_in.weights[src_offset + 0u + ubo.width]; let d = buf_in.weights[src_offset + 1u + ubo.width]; - let sum = dot(vec4(a, b, c, d), vec4(1.0)); + let sum = dot(vec4f(a, b, c, d), vec4f(1.0)); buf_out.weights[dst_offset] = sum / 4.0; - let probabilities = vec4(a, a+b, a+b+c, sum) / max(sum, 0.0001); - textureStore(tex_out, vec2(coord.xy), probabilities); + let probabilities = vec4f(a, a+b, a+b+c, sum) / max(sum, 0.0001); + textureStore(tex_out, vec2i(coord.xy), probabilities); } } diff --git a/sample/reversedZ/fragment.wgsl b/sample/reversedZ/fragment.wgsl index daf3803f..2746f0c2 100644 --- a/sample/reversedZ/fragment.wgsl +++ b/sample/reversedZ/fragment.wgsl @@ -1,6 +1,6 @@ @fragment fn main( - @location(0) fragColor: vec4 -) -> @location(0) vec4 { + @location(0) fragColor: vec4f +) -> @location(0) vec4f { return fragColor; } diff --git a/sample/reversedZ/fragmentPrecisionErrorPass.wgsl b/sample/reversedZ/fragmentPrecisionErrorPass.wgsl index 98a039f1..158130da 100644 --- a/sample/reversedZ/fragmentPrecisionErrorPass.wgsl +++ b/sample/reversedZ/fragmentPrecisionErrorPass.wgsl @@ -2,10 +2,10 @@ @fragment fn main( - @builtin(position) coord: vec4, - @location(0) clipPos: vec4 -) -> @location(0) vec4 { - let depthValue = textureLoad(depthTexture, vec2(floor(coord.xy)), 0); + @builtin(position) coord: vec4f, + @location(0) clipPos: vec4f +) -> @location(0) vec4f { + let depthValue = textureLoad(depthTexture, vec2i(floor(coord.xy)), 0); let v : f32 = abs(clipPos.z / clipPos.w - depthValue) * 2000000.0; - return vec4(v, v, v, 1.0); + return vec4f(v, v, v, 1.0); } diff --git a/sample/reversedZ/fragmentTextureQuad.wgsl b/sample/reversedZ/fragmentTextureQuad.wgsl index e3eb20bd..37f5f4dc 100644 --- a/sample/reversedZ/fragmentTextureQuad.wgsl +++ b/sample/reversedZ/fragmentTextureQuad.wgsl @@ -2,8 +2,8 @@ @fragment fn main( - @builtin(position) coord : vec4 -) -> @location(0) vec4 { - let depthValue = textureLoad(depthTexture, vec2(floor(coord.xy)), 0); - return vec4(depthValue, depthValue, depthValue, 1.0); + @builtin(position) coord : vec4f +) -> @location(0) vec4f { + let depthValue = textureLoad(depthTexture, vec2i(floor(coord.xy)), 0); + return vec4f(depthValue, depthValue, depthValue, 1.0); } diff --git a/sample/reversedZ/vertex.wgsl b/sample/reversedZ/vertex.wgsl index aac8afc4..9613a5a5 100644 --- a/sample/reversedZ/vertex.wgsl +++ b/sample/reversedZ/vertex.wgsl @@ -1,23 +1,23 @@ struct Uniforms { - modelMatrix : array, 5>, + modelMatrix : array, } struct Camera { - viewProjectionMatrix : mat4x4, + viewProjectionMatrix : mat4x4f, } @binding(0) @group(0) var uniforms : Uniforms; @binding(1) @group(0) var camera : Camera; struct VertexOutput { - @builtin(position) Position : vec4, - @location(0) fragColor : vec4, + @builtin(position) Position : vec4f, + @location(0) fragColor : vec4f, } @vertex fn main( @builtin(instance_index) instanceIdx : u32, - @location(0) position : vec4, - @location(1) color : vec4 + @location(0) position : vec4f, + @location(1) color : vec4f ) -> VertexOutput { var output : VertexOutput; output.Position = camera.viewProjectionMatrix * uniforms.modelMatrix[instanceIdx] * position; diff --git a/sample/reversedZ/vertexDepthPrePass.wgsl b/sample/reversedZ/vertexDepthPrePass.wgsl index 3ee7913b..dc40cbc2 100644 --- a/sample/reversedZ/vertexDepthPrePass.wgsl +++ b/sample/reversedZ/vertexDepthPrePass.wgsl @@ -1,8 +1,8 @@ struct Uniforms { - modelMatrix : array, 5>, + modelMatrix : array, } struct Camera { - viewProjectionMatrix : mat4x4, + viewProjectionMatrix : mat4x4f, } @binding(0) @group(0) var uniforms : Uniforms; @@ -11,7 +11,7 @@ struct Camera { @vertex fn main( @builtin(instance_index) instanceIdx : u32, - @location(0) position : vec4 -) -> @builtin(position) vec4 { + @location(0) position : vec4f +) -> @builtin(position) vec4f { return camera.viewProjectionMatrix * uniforms.modelMatrix[instanceIdx] * position; } diff --git a/sample/reversedZ/vertexPrecisionErrorPass.wgsl b/sample/reversedZ/vertexPrecisionErrorPass.wgsl index 30921b2d..19cad8bd 100644 --- a/sample/reversedZ/vertexPrecisionErrorPass.wgsl +++ b/sample/reversedZ/vertexPrecisionErrorPass.wgsl @@ -1,22 +1,22 @@ struct Uniforms { - modelMatrix : array, 5>, + modelMatrix : array, } struct Camera { - viewProjectionMatrix : mat4x4, + viewProjectionMatrix : mat4x4f, } @binding(0) @group(0) var uniforms : Uniforms; @binding(1) @group(0) var camera : Camera; struct VertexOutput { - @builtin(position) Position : vec4, - @location(0) clipPos : vec4, + @builtin(position) Position : vec4f, + @location(0) clipPos : vec4f, } @vertex fn main( @builtin(instance_index) instanceIdx : u32, - @location(0) position : vec4 + @location(0) position : vec4f ) -> VertexOutput { var output : VertexOutput; output.Position = camera.viewProjectionMatrix * uniforms.modelMatrix[instanceIdx] * position; diff --git a/sample/reversedZ/vertexTextureQuad.wgsl b/sample/reversedZ/vertexTextureQuad.wgsl index 8e601ef9..a8f03007 100644 --- a/sample/reversedZ/vertexTextureQuad.wgsl +++ b/sample/reversedZ/vertexTextureQuad.wgsl @@ -1,7 +1,7 @@ @vertex fn main( @builtin(vertex_index) VertexIndex : u32 -) -> @builtin(position) vec4 { +) -> @builtin(position) vec4f { const pos = array( vec2(-1.0, -1.0), vec2(1.0, -1.0), vec2(-1.0, 1.0), vec2(-1.0, 1.0), vec2(1.0, -1.0), vec2(1.0, 1.0), diff --git a/sample/shadowMapping/fragment.wgsl b/sample/shadowMapping/fragment.wgsl index 6a45e347..11e46a0d 100644 --- a/sample/shadowMapping/fragment.wgsl +++ b/sample/shadowMapping/fragment.wgsl @@ -1,9 +1,9 @@ override shadowDepthTextureSize: f32 = 1024.0; struct Scene { - lightViewProjMatrix : mat4x4, - cameraViewProjMatrix : mat4x4, - lightPos : vec3, + lightViewProjMatrix : mat4x4f, + cameraViewProjMatrix : mat4x4f, + lightPos : vec3f, } @group(0) @binding(0) var scene : Scene; @@ -11,23 +11,23 @@ struct Scene { @group(0) @binding(2) var shadowSampler: sampler_comparison; struct FragmentInput { - @location(0) shadowPos : vec3, - @location(1) fragPos : vec3, - @location(2) fragNorm : vec3, + @location(0) shadowPos : vec3f, + @location(1) fragPos : vec3f, + @location(2) fragNorm : vec3f, } -const albedo = vec3(0.9); +const albedo = vec3f(0.9); const ambientFactor = 0.2; @fragment -fn main(input : FragmentInput) -> @location(0) vec4 { +fn main(input : FragmentInput) -> @location(0) vec4f { // Percentage-closer filtering. Sample texels in the region // to smooth the result. var visibility = 0.0; let oneOverShadowDepthTextureSize = 1.0 / shadowDepthTextureSize; for (var y = -1; y <= 1; y++) { for (var x = -1; x <= 1; x++) { - let offset = vec2(vec2(x, y)) * oneOverShadowDepthTextureSize; + let offset = vec2f(vec2(x, y)) * oneOverShadowDepthTextureSize; visibility += textureSampleCompare( shadowMap, shadowSampler, diff --git a/sample/shadowMapping/vertex.wgsl b/sample/shadowMapping/vertex.wgsl index b344d786..797daf89 100644 --- a/sample/shadowMapping/vertex.wgsl +++ b/sample/shadowMapping/vertex.wgsl @@ -1,28 +1,28 @@ struct Scene { - lightViewProjMatrix: mat4x4, - cameraViewProjMatrix: mat4x4, - lightPos: vec3, + lightViewProjMatrix: mat4x4f, + cameraViewProjMatrix: mat4x4f, + lightPos: vec3f, } struct Model { - modelMatrix: mat4x4, + modelMatrix: mat4x4f, } @group(0) @binding(0) var scene : Scene; @group(1) @binding(0) var model : Model; struct VertexOutput { - @location(0) shadowPos: vec3, - @location(1) fragPos: vec3, - @location(2) fragNorm: vec3, + @location(0) shadowPos: vec3f, + @location(1) fragPos: vec3f, + @location(2) fragNorm: vec3f, - @builtin(position) Position: vec4, + @builtin(position) Position: vec4f, } @vertex fn main( - @location(0) position: vec3, - @location(1) normal: vec3 + @location(0) position: vec3f, + @location(1) normal: vec3f ) -> VertexOutput { var output : VertexOutput; diff --git a/sample/shadowMapping/vertexShadow.wgsl b/sample/shadowMapping/vertexShadow.wgsl index 30722dda..97295ec9 100644 --- a/sample/shadowMapping/vertexShadow.wgsl +++ b/sample/shadowMapping/vertexShadow.wgsl @@ -1,11 +1,11 @@ struct Scene { - lightViewProjMatrix: mat4x4, - cameraViewProjMatrix: mat4x4, - lightPos: vec3, + lightViewProjMatrix: mat4x4f, + cameraViewProjMatrix: mat4x4f, + lightPos: vec3f, } struct Model { - modelMatrix: mat4x4, + modelMatrix: mat4x4f, } @group(0) @binding(0) var scene : Scene; @@ -13,7 +13,7 @@ struct Model { @vertex fn main( - @location(0) position: vec3 -) -> @builtin(position) vec4 { + @location(0) position: vec3f +) -> @builtin(position) vec4f { return scene.lightViewProjMatrix * model.modelMatrix * vec4(position, 1.0); } diff --git a/sample/skinnedMesh/glbUtils.ts b/sample/skinnedMesh/glbUtils.ts index 0bd69931..63198a2b 100644 --- a/sample/skinnedMesh/glbUtils.ts +++ b/sample/skinnedMesh/glbUtils.ts @@ -176,37 +176,37 @@ const convertGPUVertexFormatToWGSLFormat = (vertexFormat: GPUVertexFormat) => { return 'f32'; } case 'float32x2': { - return 'vec2'; + return 'vec2f'; } case 'float32x3': { - return 'vec3'; + return 'vec3f'; } case 'float32x4': { - return 'vec4'; + return 'vec4f'; } case 'uint32': { return 'u32'; } case 'uint32x2': { - return 'vec2'; + return 'vec2u'; } case 'uint32x3': { - return 'vec3'; + return 'vec3u'; } case 'uint32x4': { - return 'vec4'; + return 'vec4u'; } case 'uint8x2': { - return 'vec2'; + return 'vec2u'; } case 'uint8x4': { - return 'vec4'; + return 'vec4u'; } case 'uint16x4': { - return 'vec4'; + return 'vec4u'; } case 'uint16x2': { - return 'vec2'; + return 'vec2u'; } default: { return 'f32'; @@ -739,7 +739,7 @@ export class GLTFSkin { inverseBindMatricesAccessor.byteStride !== 64 ) { throw Error( - `This skin's provided accessor does not access a mat4x4 matrix, or does not access the provided mat4x4 data correctly` + `This skin's provided accessor does not access a mat4x4f matrix, or does not access the provided mat4x4f data correctly` ); } // NOTE: Come back to this uint8array to float32array conversion in case it is incorrect diff --git a/sample/skinnedMesh/gltf.wgsl b/sample/skinnedMesh/gltf.wgsl index 0310a2a3..7b107721 100644 --- a/sample/skinnedMesh/gltf.wgsl +++ b/sample/skinnedMesh/gltf.wgsl @@ -2,10 +2,10 @@ // Read in VertexInput from attributes // f32x3 f32x3 f32x2 u8x4 f32x4 struct VertexOutput { - @builtin(position) Position: vec4, - @location(0) normal: vec3, - @location(1) joints: vec4, - @location(2) weights: vec4, + @builtin(position) Position: vec4f, + @location(0) normal: vec3f, + @location(1) joints: vec4f, + @location(2) weights: vec4f, } struct CameraUniforms { @@ -26,8 +26,8 @@ struct NodeUniforms { @group(0) @binding(0) var camera_uniforms: CameraUniforms; @group(1) @binding(0) var general_uniforms: GeneralUniforms; @group(2) @binding(0) var node_uniforms: NodeUniforms; -@group(3) @binding(0) var joint_matrices: array>; -@group(3) @binding(1) var inverse_bind_matrices: array>; +@group(3) @binding(0) var joint_matrices: array; +@group(3) @binding(1) var inverse_bind_matrices: array; @vertex fn vertexMain(input: VertexInput) -> VertexOutput { @@ -44,7 +44,7 @@ fn vertexMain(input: VertexInput) -> VertexOutput { joint2 * input.weights[2] + joint3 * input.weights[3]; // Position of the vertex relative to our world - let world_position = vec4(input.position.x, input.position.y, input.position.z, 1.0); + let world_position = vec4f(input.position.x, input.position.y, input.position.z, 1.0); // Vertex position with model rotation, skinning, and the mesh's node transformation applied. let skinned_position = camera_uniforms.model_matrix * skin_matrix * node_uniforms.world_matrix * world_position; // Vertex position with only the model rotation applied. @@ -59,13 +59,13 @@ fn vertexMain(input: VertexInput) -> VertexOutput { output.Position = camera_uniforms.proj_matrix * camera_uniforms.view_matrix * transformed_position; output.normal = input.normal; // Convert u32 joint data to f32s to prevent flat interpolation error. - output.joints = vec4(f32(input.joints[0]), f32(input.joints[1]), f32(input.joints[2]), f32(input.joints[3])); + output.joints = vec4f(f32(input.joints[0]), f32(input.joints[1]), f32(input.joints[2]), f32(input.joints[3])); output.weights = input.weights; return output; } @fragment -fn fragmentMain(input: VertexOutput) -> @location(0) vec4 { +fn fragmentMain(input: VertexOutput) -> @location(0) vec4f { switch general_uniforms.render_mode { case 1: { return input.joints; @@ -74,7 +74,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4 { return input.weights; } default: { - return vec4(input.normal, 1.0); + return vec4f(input.normal, 1.0); } } } \ No newline at end of file diff --git a/sample/skinnedMesh/grid.wgsl b/sample/skinnedMesh/grid.wgsl index cdfc9cac..ee484117 100644 --- a/sample/skinnedMesh/grid.wgsl +++ b/sample/skinnedMesh/grid.wgsl @@ -1,14 +1,14 @@ struct VertexInput { - @location(0) vert_pos: vec2, - @location(1) joints: vec4, - @location(2) weights: vec4 + @location(0) vert_pos: vec2f, + @location(1) joints: vec4u, + @location(2) weights: vec4f } struct VertexOutput { - @builtin(position) Position: vec4, - @location(0) world_pos: vec3, - @location(1) joints: vec4, - @location(2) weights: vec4, + @builtin(position) Position: vec4f, + @location(0) world_pos: vec3f, + @location(1) joints: vec4f, + @location(2) weights: vec4f, } struct CameraUniforms { @@ -24,14 +24,14 @@ struct GeneralUniforms { @group(0) @binding(0) var camera_uniforms: CameraUniforms; @group(1) @binding(0) var general_uniforms: GeneralUniforms; -@group(2) @binding(0) var joint_matrices: array>; -@group(2) @binding(1) var inverse_bind_matrices: array>; +@group(2) @binding(0) var joint_matrices: array; +@group(2) @binding(1) var inverse_bind_matrices: array; @vertex fn vertexMain(input: VertexInput) -> VertexOutput { var output: VertexOutput; - var bones = vec4(0.0, 0.0, 0.0, 0.0); - let position = vec4(input.vert_pos.x, input.vert_pos.y, 0.0, 1.0); + var bones = vec4f(0.0, 0.0, 0.0, 0.0); + let position = vec4f(input.vert_pos.x, input.vert_pos.y, 0.0, 1.0); // Get relevant 4 bone matrices let joint0 = joint_matrices[input.joints[0]] * inverse_bind_matrices[input.joints[0]]; let joint1 = joint_matrices[input.joints[1]] * inverse_bind_matrices[input.joints[1]]; @@ -52,14 +52,14 @@ fn vertexMain(input: VertexInput) -> VertexOutput { //Get unadjusted world coordinates output.world_pos = position.xyz; - output.joints = vec4(f32(input.joints.x), f32(input.joints.y), f32(input.joints.z), f32(input.joints.w)); + output.joints = vec4f(f32(input.joints.x), f32(input.joints.y), f32(input.joints.z), f32(input.joints.w)); output.weights = input.weights; return output; } @fragment -fn fragmentMain(input: VertexOutput) -> @location(0) vec4 { +fn fragmentMain(input: VertexOutput) -> @location(0) vec4f { switch general_uniforms.render_mode { case 1: { return input.joints; @@ -68,7 +68,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4 { return input.weights; } default: { - return vec4(255.0, 0.0, 1.0, 1.0); + return vec4f(255.0, 0.0, 1.0, 1.0); } } } \ No newline at end of file diff --git a/sample/texturedCube/sampleTextureMixColor.frag.wgsl b/sample/texturedCube/sampleTextureMixColor.frag.wgsl index 04e64a65..8f0165c3 100644 --- a/sample/texturedCube/sampleTextureMixColor.frag.wgsl +++ b/sample/texturedCube/sampleTextureMixColor.frag.wgsl @@ -3,8 +3,8 @@ @fragment fn main( - @location(0) fragUV: vec2, - @location(1) fragPosition: vec4 -) -> @location(0) vec4 { + @location(0) fragUV: vec2f, + @location(1) fragPosition: vec4f +) -> @location(0) vec4f { return textureSample(myTexture, mySampler, fragUV) * fragPosition; } diff --git a/shaders/basic.vert.wgsl b/shaders/basic.vert.wgsl index 257c9276..64052407 100644 --- a/shaders/basic.vert.wgsl +++ b/shaders/basic.vert.wgsl @@ -1,18 +1,18 @@ struct Uniforms { - modelViewProjectionMatrix : mat4x4, + modelViewProjectionMatrix : mat4x4f, } @binding(0) @group(0) var uniforms : Uniforms; struct VertexOutput { - @builtin(position) Position : vec4, - @location(0) fragUV : vec2, - @location(1) fragPosition: vec4, + @builtin(position) Position : vec4f, + @location(0) fragUV : vec2f, + @location(1) fragPosition: vec4f, } @vertex fn main( - @location(0) position : vec4, - @location(1) uv : vec2 + @location(0) position : vec4f, + @location(1) uv : vec2f ) -> VertexOutput { var output : VertexOutput; output.Position = uniforms.modelViewProjectionMatrix * position; diff --git a/shaders/fullscreenTexturedQuad.wgsl b/shaders/fullscreenTexturedQuad.wgsl index 415dcfd7..b3656e23 100644 --- a/shaders/fullscreenTexturedQuad.wgsl +++ b/shaders/fullscreenTexturedQuad.wgsl @@ -2,8 +2,8 @@ @group(0) @binding(1) var myTexture : texture_2d; struct VertexOutput { - @builtin(position) Position : vec4, - @location(0) fragUV : vec2, + @builtin(position) Position : vec4f, + @location(0) fragUV : vec2f, } @vertex @@ -33,6 +33,6 @@ fn vert_main(@builtin(vertex_index) VertexIndex : u32) -> VertexOutput { } @fragment -fn frag_main(@location(0) fragUV : vec2) -> @location(0) vec4 { +fn frag_main(@location(0) fragUV : vec2f) -> @location(0) vec4f { return textureSample(myTexture, mySampler, fragUV); } diff --git a/shaders/red.frag.wgsl b/shaders/red.frag.wgsl index 69fb65b1..de720e85 100644 --- a/shaders/red.frag.wgsl +++ b/shaders/red.frag.wgsl @@ -1,4 +1,4 @@ @fragment -fn main() -> @location(0) vec4 { +fn main() -> @location(0) vec4f { return vec4(1.0, 0.0, 0.0, 1.0); } \ No newline at end of file diff --git a/shaders/sampleExternalTexture.frag.wgsl b/shaders/sampleExternalTexture.frag.wgsl index ac665293..e5ff5693 100644 --- a/shaders/sampleExternalTexture.frag.wgsl +++ b/shaders/sampleExternalTexture.frag.wgsl @@ -2,6 +2,6 @@ @group(0) @binding(2) var myTexture: texture_external; @fragment -fn main(@location(0) fragUV : vec2) -> @location(0) vec4 { +fn main(@location(0) fragUV : vec2f) -> @location(0) vec4f { return textureSampleBaseClampToEdge(myTexture, mySampler, fragUV); } diff --git a/shaders/triangle.vert.wgsl b/shaders/triangle.vert.wgsl index 9bac6bb7..0df4e5fc 100644 --- a/shaders/triangle.vert.wgsl +++ b/shaders/triangle.vert.wgsl @@ -1,12 +1,12 @@ @vertex fn main( @builtin(vertex_index) VertexIndex : u32 -) -> @builtin(position) vec4 { - var pos = array, 3>( +) -> @builtin(position) vec4f { + var pos = array( vec2(0.0, 0.5), vec2(-0.5, -0.5), vec2(0.5, -0.5) ); - return vec4(pos[VertexIndex], 0.0, 1.0); + return vec4f(pos[VertexIndex], 0.0, 1.0); } diff --git a/shaders/vertexPositionColor.frag.wgsl b/shaders/vertexPositionColor.frag.wgsl index 6f986128..a6032398 100644 --- a/shaders/vertexPositionColor.frag.wgsl +++ b/shaders/vertexPositionColor.frag.wgsl @@ -1,7 +1,7 @@ @fragment fn main( - @location(0) fragUV: vec2, - @location(1) fragPosition: vec4 -) -> @location(0) vec4 { + @location(0) fragUV: vec2f, + @location(1) fragPosition: vec4f +) -> @location(0) vec4f { return fragPosition; }