@@ -212,7 +212,7 @@ function withRenderLock(setupFn: { (): Promise<void>; }, renderFn: { (timeMS: nu
212212 }
213213}
214214
215- function startRendering ( ) {
215+ function handleResize ( ) {
216216 // This is a lighter-weight setup function that doesn't need to re-compile the shader code.
217217 const setupRenderer = async ( ) => {
218218 if ( ! computePipeline || ! passThroughPipeline )
@@ -221,8 +221,7 @@ function startRendering() {
221221 if ( ! currentWindowSize || currentWindowSize [ 0 ] < 2 || currentWindowSize [ 1 ] < 2 )
222222 throw new NotReadyError ( "window not ready" ) ;
223223
224- allocatedResources = await processResourceCommands ( computePipeline , resourceBindings , resourceCommands ) ;
225-
224+ safeSet ( allocatedResources , "outputTexture" , createOutputTexture ( device , currentWindowSize [ 0 ] , currentWindowSize [ 1 ] , 'rgba8unorm' ) ) ;
226225 computePipeline . createBindGroup ( allocatedResources ) ;
227226
228227 passThroughPipeline . inputTexture = ( allocatedResources . get ( "outputTexture" ) as GPUTexture ) ;
@@ -240,7 +239,7 @@ function startRendering() {
240239function resizeCanvasHandler ( entries : ResizeObserverEntry [ ] ) {
241240 let needResize = resizeCanvas ( entries ) ;
242241 if ( needResize ) {
243- startRendering ( ) ;
242+ handleResize ( ) ;
244243 }
245244}
246245
@@ -617,7 +616,7 @@ async function processResourceCommands(pipeline: ComputePipeline | GraphicsPipel
617616 throw new Error ( `Failed to create texture from image: ${ error } ` ) ;
618617 }
619618 } else if ( parsedCommand . type === "RAND" ) {
620- const elementSize = 4 ; // Assuming 4 bytes per element (e.g., float) TODO: infer from type.
619+ const elementSize = 4 ; // RAND is only valid for floats
621620 const bindingInfo = resourceBindings . get ( resourceName ) ;
622621 if ( ! bindingInfo ) {
623622 throw new Error ( `Resource ${ resourceName } is not defined in the bindings.` ) ;
0 commit comments