Skip to content

Commit

Permalink
Comment on some cold functions
Browse files Browse the repository at this point in the history
  • Loading branch information
kainino0x committed Oct 30, 2023
1 parent ef41384 commit fe03729
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ export class BufferSyncTest extends GPUTest {

// Create a 1x1 texture, and initialize it to a specified value for all elements.
async createTextureWithValue(initValue: number): Promise<GPUTexture> {
// This is not hot in profiles; optimize if this gets used more heavily.
const data = new Uint32Array(1).fill(initValue);
const texture = this.trackForCleanup(
this.device.createTexture({
Expand Down Expand Up @@ -446,6 +447,7 @@ export class BufferSyncTest extends GPUTest {

// Write buffer via writeBuffer API on queue
writeByWriteBuffer(buffer: GPUBuffer, value: number) {
// This is not hot in profiles; optimize if this gets used more heavily.
const data = new Uint32Array(1).fill(value);
this.device.queue.writeBuffer(buffer, 0, data);
}
Expand Down Expand Up @@ -919,12 +921,14 @@ export class BufferSyncTest extends GPUTest {
}

verifyData(buffer: GPUBuffer, expectedValue: number) {
// This is not hot in profiles; optimize if this gets used more heavily.
const bufferData = new Uint32Array(1);
bufferData[0] = expectedValue;
this.expectGPUBufferValuesEqual(buffer, bufferData);
}

verifyDataTwoValidValues(buffer: GPUBuffer, expectedValue1: number, expectedValue2: number) {
// This is not hot in profiles; optimize if this gets used more heavily.
const bufferData1 = new Uint32Array(1);
bufferData1[0] = expectedValue1;
const bufferData2 = new Uint32Array(1);
Expand Down
2 changes: 2 additions & 0 deletions src/webgpu/web_platform/reftests/canvas_colorspace.html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { kCanvasAlphaModes, kCanvasColorSpaces } from '../../capability_info.js'
import { runRefTest } from './gpu_ref_test.js';

function bgra8UnormFromRgba8Unorm(rgba8Unorm: Uint8Array) {
// This is used only once. May need to optimize if reused.
const bgra8Unorm = rgba8Unorm.slice();
for (let i = 0; i < bgra8Unorm.length; i += 4) {
[bgra8Unorm[i], bgra8Unorm[i + 2]] = [bgra8Unorm[i + 2], bgra8Unorm[i]];
Expand All @@ -13,6 +14,7 @@ function bgra8UnormFromRgba8Unorm(rgba8Unorm: Uint8Array) {
}

function rgba16floatFromRgba8unorm(rgba8Unorm: Uint8Array) {
// This is used only once. May need to optimize if reused.
const rgba16Float = new Float16Array(rgba8Unorm.length);
for (let i = 0; i < rgba8Unorm.length; ++i) {
rgba16Float[i] = rgba8Unorm[i] / 255;
Expand Down
1 change: 1 addition & 0 deletions src/webgpu/web_platform/reftests/canvas_complex.html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export function run(
size: rows * bytesPerRow,
usage: GPUBufferUsage.COPY_SRC,
});
// These are run only once per test, so there are no wasted reallocations below.
let red: Uint8Array | Uint16Array;
let green: Uint8Array | Uint16Array;
let blue: Uint8Array | Uint16Array;
Expand Down

0 comments on commit fe03729

Please sign in to comment.