@@ -131,7 +131,7 @@ export const createReduceSharedProgramInfo =
131
131
const workgroupSize = 32 ;
132
132
133
133
const sharedMemorySnippet = `
134
- var<workgroup> aBestValues : array<${ output . type . storage } , ${ workgroupSize } >;
134
+ var<workgroup> aBestValues : array<f32 , ${ workgroupSize } >;
135
135
` ;
136
136
137
137
const getShaderSource = ( shaderHelper : ShaderHelper ) => `
@@ -145,10 +145,10 @@ export const createReduceSharedProgramInfo =
145
145
let outputIndex = global_idx / ${ workgroupSize } ;
146
146
let offset = outputIndex * uniforms.reduceSize;
147
147
148
- var bestValue = ${ output . type . storage } (${ reduceInitValues [ reduceType ] } );
148
+ var bestValue = f32 (${ reduceInitValues [ reduceType ] } );
149
149
let Length = uniforms.reduceSize;
150
150
for (var k = local_idx; k < Length; k = k + ${ workgroupSize } ) {
151
- let candidate = ${ output . type . storage } (${ input . getByOffset ( 'offset + k' ) } );
151
+ let candidate = f32 (${ input . getByOffset ( 'offset + k' ) } );
152
152
bestValue = ${ reduceOps [ reduceType ] } ;
153
153
}
154
154
aBestValues[local_idx] = bestValue;
@@ -172,8 +172,8 @@ export const createReduceSharedProgramInfo =
172
172
output . setByOffset (
173
173
'outputIndex' ,
174
174
`${
175
- reduceType === 'mean' ? `bestValue / ${ output . type . storage } (uniforms.reduceSize)` :
176
- `${ reduceOutputValues [ reduceType ] } ` } `) } ;
175
+ reduceType === 'mean' ? `${ output . type . storage } (bestValue / f32( uniforms.reduceSize) )` :
176
+ `${ output . type . storage } ( ${ reduceOutputValues [ reduceType ] } ) ` } `) } ;
177
177
}
178
178
}` ;
179
179
0 commit comments