11import {
22 TypedArray ,
3- TypedArrayConstructor ,
43 isTypedArray ,
54} from './typed-arrays.js' ;
65import {
@@ -122,7 +121,7 @@ function uploadDataToTexture(
122121 const blocksDown = Math . ceil ( size [ 1 ] / blockHeight ) ;
123122 const bytesPerRow = blocksAcross * bytesPerBlock ! ;
124123 const bytesPerLayer = bytesPerRow * blocksDown ;
125- const numLayers = texture . dimension == '3d'
124+ const numLayers = texture . dimension === '3d'
126125 ? data . byteLength / bytesPerLayer
127126 : 1 ;
128127 size [ 0 ] = blocksAcross * blockWidth ;
@@ -157,15 +156,15 @@ function uploadDataToTexture(
157156 * set mip level 0 layer 0 (4x4). If you pass in 24 bytes it will set mip level 0 layer 0(4x4)
158157 * and mip level 1 layer 0 (2x2). If you pass in 25 bytes it will set mip level 0, 1, 2, layer 0
159158 * If you pass in 75 bytes it would do all layers, all mip levels.
160- *
159+ *
161160 * Note that for 3d textures there are no "layers" from the POV of this function. There is mip level 0 (which is a cube)
162161 * and mip level 1 (which is a cube). So a '3d' 4x4x3 r8unorm texture, you're expected to provide 48 bytes for mip level 0
163162 * where as for '2d' 4x4x3 you're expected to provide 16 bytes for mip level 0 layer 0. If you want to provide data
164163 * to each layer separately then pass them in as an array
165- *
164+ *
166165 * ```js
167166 * // fill layer 0, mips 0
168- * copySourcesToTexture(device, tex_4x4x3_r8_2d, [data16Bytes]);
167+ * copySourcesToTexture(device, tex_4x4x3_r8_2d, [data16Bytes]);
169168 *
170169 * // fill layer 0, mips 0, 1, 2
171170 * copySourcesToTexture(device, tex_4x4x3_r8_2d, [data25Bytes]);
@@ -179,12 +178,12 @@ function uploadDataToTexture(
179178 * // fills layer 0, mips 0, layer 1, mips 0, layer 2, mips 0
180179 * copySourcesToTexture(device, tex_4x4x3_r8_2d, [data16Bytes, data16bytes, data16Bytes]);
181180 * ```
182- *
181+ *
183182 * This also works for compressed textures, so you can load an entire compressed texture, all mips, all layers in one call.
184183 * See texture-utils-tests.js for examples.
185- *
184+ *
186185 * If the source is an `Array` is it converted to a typed array that matches the format.
187- *
186+ *
188187 * * ????8snorm ????8sint -> `Int8Array`
189188 * * ????8unorm ????8uint -> `Uint8Array`
190189 * * ????16snorm ???16sint -> `Int16Array`
@@ -273,7 +272,6 @@ export function copySourceToTexture(
273272 * @property mipLevelCount Defaults to 1 or the number of mips needed for a full mipmap if `mips` is true
274273 */
275274export type CreateTextureOptions = CopyTextureOptions & {
276- mips ?: boolean ,
277275 usage ?: GPUTextureUsageFlags ,
278276 format ?: GPUTextureFormat ,
279277 mipLevelCount ?: number ,
0 commit comments