MCPcopy Index your code
hub / github.com/ColmapView/Colmapview.github.io / uploadTexture

Function uploadTexture

e2e/webgpu-render.spec.ts:349–367  ·  view source on GitHub ↗
(
        texture: BrowserGpuTexture,
        pixels: Uint8Array
      )

Source from the content-addressed store, hash-verified

347 };
348
349 const uploadTexture = (
350 texture: BrowserGpuTexture,
351 pixels: Uint8Array
352 ) => {
353 const bytesPerRow = Math.ceil((width * 4) / 256) * 256;
354 const upload = new Uint8Array(bytesPerRow * height);
355 for (let y = 0; y < height; y++) {
356 upload.set(
357 pixels.subarray(y * width * 4, (y + 1) * width * 4),
358 y * bytesPerRow
359 );
360 }
361 device!.queue.writeTexture(
362 { texture },
363 upload,
364 { bytesPerRow, rowsPerImage: height },
365 { width, height }
366 );
367 };
368
369 const createAndWriteUniformBuffer = (data: Uint32Array): BrowserGpuBuffer => {
370 const buffer = device!.createBuffer({

Callers 2

createUploadedTextureFunction · 0.70

Calls 1

writeTextureMethod · 0.65

Tested by

no test coverage detected