11import { convertRgbToY } from '@typegpu/color' ;
22import { accessViewportSize } from '@typegpu/common' ;
3- import tgpu , { unstable_asUniform , type TgpuRoot } from 'typegpu' ;
3+ import tgpu , { type TgpuRoot } from 'typegpu' ;
44import * as d from 'typegpu/data' ;
55
66import {
@@ -55,8 +55,11 @@ const BLOCK_SIZE = 8;
5555// }`;
5656
5757const ioLayout = tgpu . bindGroupLayout ( {
58- output_buffer : { storage : ( n ) => d . arrayOf ( d . f32 , n ) , access : 'mutable' } ,
59- input_buffer : { storage : ( n ) => d . arrayOf ( d . vec4f , n ) } ,
58+ output_buffer : {
59+ storage : ( n : number ) => d . arrayOf ( d . f32 , n ) ,
60+ access : 'mutable' ,
61+ } ,
62+ input_buffer : { storage : ( n : number ) => d . arrayOf ( d . vec4f , n ) } ,
6063 blurred_tex : { texture : 'unfilterable-float' } ,
6164 aux_tex : { texture : 'unfilterable-float' } ,
6265} ) ;
@@ -147,14 +150,19 @@ const menderConvolveFn = convolveFn({
147150} ) ;
148151
149152const entryComputeFn = tgpu [ '~unstable' ]
150- . computeFn ( [ ] , { workgroupSize : [ BLOCK_SIZE , BLOCK_SIZE ] } )
151- . does ( /* wgsl */ `(@builtin(global_invocation_id) gid: vec3u) {
153+ . computeFn ( {
154+ workgroupSize : [ BLOCK_SIZE , BLOCK_SIZE ] ,
155+ in : {
156+ gid : d . builtin . globalInvocationId ,
157+ } ,
158+ } )
159+ . does ( /* wgsl */ `(input: Input) {
152160 var result: array<f32, OUT_CHANNELS>;
153161 for (var i = 0; i < OUT_CHANNELS; i += 1) {
154162 result[i] = biases[i];
155163 }
156164
157- menderConvolveFn(gid.xy, &result);
165+ menderConvolveFn(input. gid.xy, &result);
158166
159167 if (reluSlot) {
160168 applyReLU(&result);
@@ -163,8 +171,8 @@ const entryComputeFn = tgpu['~unstable']
163171 let canvasSize = accessViewportSize;
164172
165173 let output_buffer_begin =
166- (gid.y * u32(canvasSize.x) +
167- gid.x) * OUT_CHANNELS;
174+ (input. gid.y * u32(canvasSize.x) +
175+ input. gid.x) * OUT_CHANNELS;
168176
169177 for (var i: u32 = 0; i < OUT_CHANNELS; i++) {
170178 output_buffer[output_buffer_begin + i] = result[i];
@@ -232,7 +240,7 @@ export const MenderStep = ({ root, gBuffer, targetTexture }: Options) => {
232240 . with ( outChannelsSlot , options . outChannels )
233241 . with ( reluSlot , options . relu )
234242 . with ( inputFromGBufferSlot , options . inputFromGBuffer )
235- . with ( accessViewportSize , unstable_asUniform ( viewportSizeBuffer ) )
243+ . with ( accessViewportSize , viewportSizeBuffer . as ( 'uniform' ) )
236244 // ---
237245 . withCompute ( entryComputeFn )
238246 . createPipeline ( )
@@ -296,7 +304,7 @@ export const MenderStep = ({ root, gBuffer, targetTexture }: Options) => {
296304 // ---
297305
298306 const combinationPipeline = root [ '~unstable' ]
299- . with ( accessViewportSize , unstable_asUniform ( viewportSizeBuffer ) )
307+ . with ( accessViewportSize , viewportSizeBuffer . as ( 'uniform' ) )
300308 . withVertex ( fullScreenQuadVertexFn , { } )
301309 . withFragment ( combinationEntryFn , { format : 'rgba8unorm' } )
302310 . createPipeline ( ) ;
0 commit comments