@@ -212,7 +212,7 @@ function withRenderLock(setupFn: { (): Promise<void>; }, renderFn: { (timeMS: nu
212
212
}
213
213
}
214
214
215
- function startRendering ( ) {
215
+ function handleResize ( ) {
216
216
// This is a lighter-weight setup function that doesn't need to re-compile the shader code.
217
217
const setupRenderer = async ( ) => {
218
218
if ( ! computePipeline || ! passThroughPipeline )
@@ -221,8 +221,7 @@ function startRendering() {
221
221
if ( ! currentWindowSize || currentWindowSize [ 0 ] < 2 || currentWindowSize [ 1 ] < 2 )
222
222
throw new NotReadyError ( "window not ready" ) ;
223
223
224
- allocatedResources = await processResourceCommands ( computePipeline , resourceBindings , resourceCommands ) ;
225
-
224
+ safeSet ( allocatedResources , "outputTexture" , createOutputTexture ( device , currentWindowSize [ 0 ] , currentWindowSize [ 1 ] , 'rgba8unorm' ) ) ;
226
225
computePipeline . createBindGroup ( allocatedResources ) ;
227
226
228
227
passThroughPipeline . inputTexture = ( allocatedResources . get ( "outputTexture" ) as GPUTexture ) ;
@@ -240,7 +239,7 @@ function startRendering() {
240
239
function resizeCanvasHandler ( entries : ResizeObserverEntry [ ] ) {
241
240
let needResize = resizeCanvas ( entries ) ;
242
241
if ( needResize ) {
243
- startRendering ( ) ;
242
+ handleResize ( ) ;
244
243
}
245
244
}
246
245
@@ -617,7 +616,7 @@ async function processResourceCommands(pipeline: ComputePipeline | GraphicsPipel
617
616
throw new Error ( `Failed to create texture from image: ${ error } ` ) ;
618
617
}
619
618
} 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
621
620
const bindingInfo = resourceBindings . get ( resourceName ) ;
622
621
if ( ! bindingInfo ) {
623
622
throw new Error ( `Resource ${ resourceName } is not defined in the bindings.` ) ;
0 commit comments