Created a pass-through post processing compute pass. The other post-processing passes will be changed over to this kind of thing.

makePassFBO has now been split into makeRenderTarget and makeComputeTarget.
This commit is contained in:
Rezmason
2021-11-11 09:18:32 -08:00
parent 9c861fd50b
commit 9ad655ca2e
11 changed files with 158 additions and 32 deletions

View File

@@ -27,13 +27,20 @@ const loadTexture = async (device, url) => {
return texture;
};
const makePassFBO = (device, width, height, format = "bgra8unorm") =>
const makeRenderTarget = (device, width, height, format) =>
device.createTexture({
size: [width, height, 1],
format,
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_SRC | GPUTextureUsage.COPY_DST | GPUTextureUsage.RENDER_ATTACHMENT,
});
const makeComputeTarget = (device, width, height) =>
device.createTexture({
size: [width, height, 1],
format: "rgba8unorm",
usage: GPUTextureUsage.TEXTURE_BINDING | GPUTextureUsage.COPY_SRC | GPUTextureUsage.COPY_DST | GPUTextureUsage.STORAGE_BINDING,
});
const loadShader = async (device, url) => {
const response = await fetch(url);
const code = await response.text();
@@ -90,4 +97,4 @@ const makePass = (getOutputs, ready, setSize, execute) => ({
const makePipeline = (context, steps) =>
steps.filter((f) => f != null).reduce((pipeline, f, i) => [...pipeline, f(context, i == 0 ? null : pipeline[i - 1].getOutputs)], []);
export { getCanvasSize, makePassFBO, make1DTexture, loadTexture, loadShader, makeUniformBuffer, makePass, makePipeline, makeBindGroup };
export { getCanvasSize, makeRenderTarget, makeComputeTarget, make1DTexture, loadTexture, loadShader, makeUniformBuffer, makePass, makePipeline, makeBindGroup };