Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/typegpu-docs/src/components/translator/lib/rolldown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { InputOptions, OutputOptions } from '@rolldown/browser';
import { join } from 'pathe';

export interface BundleResult {
output: Record<string, string | Uint8Array>;
output: Record<string, string | Uint8Array<ArrayBuffer>>;
warnings?: string[] | undefined;
}

Expand Down Expand Up @@ -88,7 +88,7 @@ export async function bundle(
result.output.map((chunk) =>
chunk.type === 'chunk'
? [chunk.fileName, chunk.code]
: [chunk.fileName, chunk.source]
: [chunk.fileName, chunk.source.slice()]
),
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ export const controls = {
initial: Object.keys(testCases)[0],
options: Object.keys(testCases),
onSelectChange: async (selected: keyof typeof testCases) => {
// biome-ignore lint/performance/noDynamicNamespaceImportAccess: no other way
testCase = testCases[selected];
pipelines = createPipelines();
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ async function updateLUT(file: string) {

device.queue.writeTexture(
{ texture: root.unwrap(currentLUTTexture) },
parsed.data,
parsed.data.buffer,
{
bytesPerRow: parsed.size * 4 * 2,
rowsPerImage: parsed.size,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ const fragmentFunction = tgpu['~unstable'].fragmentFn({

let density = d.f32(0);
let invColor = d.vec3f(0, 0, 0);
let tMin = d.f32(0);
let intersectionFound = false;

for (let i = 0; i < X; i++) {
Expand Down Expand Up @@ -240,7 +239,6 @@ const fragmentFunction = tgpu['~unstable'].fragmentFn({
div(d.vec3f(1), boxMatrix.$[i][j][k].albedo),
),
);
tMin = intersection.tMin;
intersectionFound = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export async function loadCubemap(
chosenCubemap: CubemapNames,
) {
const images = await Promise.all(
getCubemapUrls(chosenCubemap).map(async (url, i) => {
getCubemapUrls(chosenCubemap).map(async (url) => {
const response = await fetch(url);
const blob = await response.blob();
return await createImageBitmap(blob);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ const renderBackground = (
);
};

const rayMarch = (rayOrigin: d.v3f, rayDirection: d.v3f, uv: d.v2f) => {
const rayMarch = (rayOrigin: d.v3f, rayDirection: d.v3f, _uv: d.v2f) => {
'use gpu';
let totalSteps = d.u32();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,6 @@ export class Slider {
}

#computeControlPoints() {
const eps = 1e-6;
for (let i = 0; i < this.n - 1; i++) {
const A = this.#pos[i];
const B = this.#pos[i + 1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ const renderBackground = (
return d.vec4f(backgroundColor.xyz, 1);
};

const rayMarch = (rayOrigin: d.v3f, rayDirection: d.v3f, uv: d.v2f) => {
const rayMarch = (rayOrigin: d.v3f, rayDirection: d.v3f, _uv: d.v2f) => {
'use gpu';
let totalSteps = d.u32();

Expand Down Expand Up @@ -652,7 +652,7 @@ canvas.addEventListener('touchstart', (event) => {
event.preventDefault();
});

canvas.addEventListener('touchend', (event) => {
canvas.addEventListener('touchend', () => {
switchBehavior.pressed = false;
switchBehavior.toggled = !switchBehavior.toggled;
});
Expand All @@ -668,7 +668,7 @@ canvas.addEventListener('mouseup', (event) => {
event.stopPropagation();
});

window.addEventListener('mouseup', (event) => {
window.addEventListener('mouseup', () => {
switchBehavior.pressed = false;
});

Expand Down
2 changes: 0 additions & 2 deletions apps/typegpu-docs/src/examples/rendering/jelly-switch/taa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ export const taaResolveFn = tgpu['~unstable'].computeFn({

const historyColorClamped = std.clamp(historyColor.xyz, minColor, maxColor);

const uv = d.vec2f(gid.xy).div(d.vec2f(dimensions.xy));

const blendFactor = d.f32(0.9);

const resolvedColor = d.vec4f(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ root['~unstable'].createGuardedComputePipeline((x) => {
const params = root.createUniform(Params, defaultParams);
const deltaTime = root.createUniform(d.f32, 0.016);

const textures = [0, 1].map((i) =>
const textures = [0, 1].map(() =>
root['~unstable']
.createTexture({
size: [resolution.x, resolution.y],
Expand Down
4 changes: 0 additions & 4 deletions apps/typegpu-docs/src/examples/tests/copy-error/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
// irrelevant import so the file becomes a module
import tgpu from 'typegpu';
const t = tgpu;

// setup
const adapter = await navigator.gpu?.requestAdapter();
const device = await adapter?.requestDevice();
Expand Down
2 changes: 1 addition & 1 deletion apps/typegpu-docs/src/examples/tests/dispatch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async function test3d(): Promise<boolean> {

async function testWorkgroupSize(): Promise<boolean> {
const mutable = root.createMutable(d.atomic(d.u32));
root['~unstable'].createGuardedComputePipeline((x, y, z) => {
root['~unstable'].createGuardedComputePipeline((_x, _y, _z) => {
'use gpu';
std.atomicAdd(mutable.$, 1);
}).dispatchThreads(4, 3, 2);
Expand Down
2 changes: 1 addition & 1 deletion packages/typegpu/src/core/texture/texture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ class TgpuTextureImpl<TProps extends TextureProps>
texture: this[$internal].unwrap(),
mipLevel,
},
source,
'buffer' in source ? source.buffer : source,
{
bytesPerRow: this.#formatInfo.texelSize * mipWidth,
rowsPerImage: mipHeight,
Expand Down
7 changes: 5 additions & 2 deletions packages/typegpu/src/data/ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ export interface ref<T> {
$: T;
}

export const ref: DualFn<<T>(value: T) => ref<T>> = (() => {
// biome has issues with this type being inline
type RefFn = <T>(value: T) => ref<T>;

export const ref = (() => {
const gpuImpl = (value: Snippet) => {
if (value.origin === 'argument') {
throw new WgslTypeError(
Expand Down Expand Up @@ -98,7 +101,7 @@ export const ref: DualFn<<T>(value: T) => ref<T>> = (() => {
},
});

return impl as unknown as DualFn<<T>(value: T) => ref<T>>;
return impl as unknown as DualFn<RefFn>;
})();

export function isRef<T>(value: unknown | ref<T>): value is ref<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ describe('box raytracing example', () => {
}
var density = 0f;
var invColor = vec3f();
var tMin = 0f;
var intersectionFound = false;
for (var i = 0; (i < 7i); i++) {
for (var j = 0; (j < 7i); j++) {
Expand All @@ -160,7 +159,6 @@ describe('box raytracing example', () => {
let boxDensity = (max(0f, (intersection.tMax - intersection.tMin)) * pow(uniforms_1.materialDensity, 2f));
density += boxDensity;
invColor = (invColor + (boxDensity * (vec3f(1) / boxMatrix_10[i][j][k].albedo)));
tMin = intersection.tMin;
intersectionFound = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe('tgsl parsing test example', () => {

@group(0) @binding(1) var<storage, read_write> mutable_3: atomic<u32>;

fn wrappedCallback_2(x: u32, y: u32, z: u32) {
fn wrappedCallback_2(_x: u32, _y: u32, _z: u32) {
atomicAdd(&mutable_3, 1u);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ describe('jelly-slider example', () => {
return exp((sigma * -(dist)));
}

fn rayMarch_12(rayOrigin: vec3f, rayDirection: vec3f, uv: vec2f) -> vec4f {
fn rayMarch_12(rayOrigin: vec3f, rayDirection: vec3f, _uv: vec2f) -> vec4f {
var totalSteps = 0u;
var backgroundDist = 0f;
for (var i = 0; (i < 64i); i++) {
Expand Down
4 changes: 2 additions & 2 deletions packages/typegpu/tests/texture.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ Overload 2 of 2, '(schema: "(Error) Storage texture format 'rgba8snorm' incompat
texture: expect.anything(),
mipLevel: 0,
}),
data,
data.buffer,
expect.objectContaining({
bytesPerRow: 16, // 4 pixels * 4 bytes per pixel
rowsPerImage: 4,
Expand All @@ -494,7 +494,7 @@ Overload 2 of 2, '(schema: "(Error) Storage texture format 'rgba8snorm' incompat

expect(device.mock.queue.writeTexture).toHaveBeenCalledWith(
{ texture: expect.anything(), mipLevel: 2 },
data,
data.buffer,
{ bytesPerRow: 8, rowsPerImage: 2 }, // 2 pixels * 4 bytes per pixel
[2, 2, 1], // Mip level 2 dimensions
);
Expand Down
Loading