Skip to content

Commit 42aa1fc

Browse files
committed
Updated to newest unstable typegpu
1 parent a3d00dd commit 42aa1fc

File tree

4 files changed

+99
-104
lines changed

4 files changed

+99
-104
lines changed

apps/phoure-www/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"@radix-ui/react-tooltip": "^1.1.6",
2929
"@typegpu/color": "workspace:*",
3030
"@typegpu/common": "workspace:*",
31-
"@typegpu/noise": "^0.0.5",
31+
"@typegpu/noise": "^0.0.6",
3232
"@typegpu/sdf": "workspace:*",
3333
"@types/react": "^18.0.2",
3434
"@types/react-dom": "^18.0.2",

apps/phoure-www/src/lib-phoure/menderStep.ts

Lines changed: 34 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { convertRgbToY } from '@typegpu/color';
22
import { accessViewportSize } from '@typegpu/common';
33
import tgpu, { type TgpuRoot } from 'typegpu';
44
import * as d from 'typegpu/data';
5+
import * as std from 'typegpu/std';
56

67
import {
78
convolveFn,
@@ -68,63 +69,43 @@ const { weights, biases } = layerLayout.bound;
6869

6970
const sampleGlobal = tgpu['~unstable'].derived(() => {
7071
return tgpu['~unstable']
71-
.fn([
72-
d.i32,
73-
d.i32,
74-
d.ptrFn(d.arrayOf(d.vec4f, inChannelsQuarter.value)),
75-
])(`(x: i32, y: i32, result: ptr<function, array<vec4f, inChannelsQuarter>>) {
76-
let canvasSize = accessViewportSize;
77-
let coord = vec2u(
78-
u32(max(0, min(x, i32(canvasSize.x) - 1))),
79-
u32(max(0, min(y, i32(canvasSize.y) - 1))),
80-
);
81-
82-
if (inputFromGBufferSlot) {
83-
let blurred = textureLoad(
84-
blurred_tex,
85-
coord,
86-
0
72+
.fn([d.i32, d.i32, d.ptrFn(d.arrayOf(d.vec4f, inChannelsQuarter.value))])(
73+
(x, y, result) => {
74+
const canvasSize = accessViewportSize.value;
75+
const coord = d.vec2u(
76+
d.u32(std.max(0, std.min(x, d.i32(canvasSize.x) - 1))),
77+
d.u32(std.max(0, std.min(y, d.i32(canvasSize.y) - 1))),
8778
);
8879

89-
var aux = textureLoad(
90-
aux_tex,
91-
coord,
92-
0
93-
);
80+
if (inputFromGBufferSlot) {
81+
const blurred = std.textureLoad(ioLayout.$.blurred_tex, coord, 0);
9482

95-
(*result)[0] = vec4f(
96-
convertRgbToY(blurred.rgb),
97-
aux.z, // albedo luminance
98-
aux.x, // normal.x
99-
aux.y, // normal.y
100-
);
101-
(*result)[1] = vec4f(
102-
aux.w, // emission luminance
103-
0, // zero padding
104-
0, // zero padding
105-
0, // zero padding
106-
);
107-
}
108-
else {
109-
for (var i: u32 = 0; i < inChannelsQuarter; i++) {
110-
let index =
111-
(coord.y * u32(canvasSize.x) +
112-
coord.x) * inChannelsQuarter +
113-
i;
114-
115-
(*result)[i] = input_buffer[index];
83+
const aux = std.textureLoad(ioLayout.$.aux_tex, coord, 0);
84+
85+
result[0] = d.vec4f(
86+
convertRgbToY(blurred.xyz),
87+
aux.z, // albedo luminance
88+
aux.x, // normal.x
89+
aux.y, // normal.y
90+
);
91+
result[1] = d.vec4f(
92+
aux.w, // emission luminance
93+
0, // zero padding
94+
0, // zero padding
95+
0, // zero padding
96+
);
97+
} else {
98+
for (let i = d.u32(0); i < inChannelsQuarter.value; i++) {
99+
const index =
100+
(coord.y * d.u32(canvasSize.x) + coord.x) *
101+
inChannelsQuarter.value +
102+
i;
103+
104+
result[i] = ioLayout.$.input_buffer[index];
105+
}
116106
}
117-
}
118-
}`)
119-
.$uses({
120-
inChannelsQuarter,
121-
accessViewportSize,
122-
inputFromGBufferSlot,
123-
blurred_tex: ioLayout.bound.blurred_tex,
124-
aux_tex: ioLayout.bound.aux_tex,
125-
input_buffer: ioLayout.bound.input_buffer,
126-
convertRgbToY,
127-
})
107+
},
108+
)
128109
.$name('sample_global');
129110
});
130111

pnpm-lock.yaml

Lines changed: 62 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ packages:
44

55
# Define a catalog of version ranges.
66
catalog:
7-
typegpu: ^0.5.5
8-
unplugin-typegpu: ^0.1.0-alpha.9
7+
typegpu: https://pkg.pr.new/software-mansion/TypeGPU/typegpu@4cc7f09503fd2b81d63c48be4a48b48670b5aa95
8+
unplugin-typegpu: ^0.1.0

0 commit comments

Comments
 (0)