Fixing the names of shaders in the passes. The loadShader utility function now returns the code and the module, since I'm hoping to parse uniform buffer layouts from the code.

This commit is contained in:
Rezmason
2021-11-07 00:40:50 -07:00
parent bade1667ad
commit bd3d0c76d2
8 changed files with 39 additions and 32 deletions

View File

@@ -35,10 +35,13 @@ const makePassFBO = (device, width, height, format = "rgba8unorm") =>
// TODO: whittle these down
});
const loadShaderModule = async (device, url) => {
const loadShader = async (device, url) => {
const response = await fetch(url);
const code = await response.text();
return device.createShaderModule({ code });
return {
code,
module: device.createShaderModule({ code }),
};
};
const makeUniformBuffer = (device, structLayout, values = null) => {
@@ -77,4 +80,4 @@ const makePass = (ready, setSize, getOutputs, 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, loadShaderModule, makeUniformBuffer, makePass, makePipeline };
export { getCanvasSize, makePassFBO, make1DTexture, loadTexture, loadShader, makeUniformBuffer, makePass, makePipeline };