Files
il/resources/public/js/cljs-runtime/module$node_modules$pixi_DOT_js$lib$rendering$renderers$gpu$shader$utils$extractAttributesFromGpuProgram.js
2026-07-01 22:38:29 -06:00

33 lines
2.3 KiB
JavaScript

shadow$provide.module$node_modules$pixi_DOT_js$lib$rendering$renderers$gpu$shader$utils$extractAttributesFromGpuProgram = function(global, require, module, exports) {
function parseLocations(str, results) {
let match;
for (; null !== (match = LOCATION_REGEX.exec(str));) {
const format = WGSL_TO_VERTEX_TYPES[match[3]] ?? "float32";
results[match[2]] = {location:parseInt(match[1], 10), format, stride:getAttributeInfoFromFormat.getAttributeInfoFromFormat(format).stride, offset:0, instance:!1, start:0};
}
LOCATION_REGEX.lastIndex = 0;
}
var getAttributeInfoFromFormat = require("module$node_modules$pixi_DOT_js$lib$rendering$renderers$shared$geometry$utils$getAttributeInfoFromFormat");
"use strict";
const WGSL_TO_VERTEX_TYPES = {f32:"float32", "vec2\x3cf32\x3e":"float32x2", "vec3\x3cf32\x3e":"float32x3", "vec4\x3cf32\x3e":"float32x4", vec2f:"float32x2", vec3f:"float32x3", vec4f:"float32x4", i32:"sint32", "vec2\x3ci32\x3e":"sint32x2", "vec3\x3ci32\x3e":"sint32x3", "vec4\x3ci32\x3e":"sint32x4", vec2i:"sint32x2", vec3i:"sint32x3", vec4i:"sint32x4", u32:"uint32", "vec2\x3cu32\x3e":"uint32x2", "vec3\x3cu32\x3e":"uint32x3", "vec4\x3cu32\x3e":"uint32x4", vec2u:"uint32x2", vec3u:"uint32x3", vec4u:"uint32x4",
bool:"uint32", "vec2\x3cbool\x3e":"uint32x2", "vec3\x3cbool\x3e":"uint32x3", "vec4\x3cbool\x3e":"uint32x4"}, LOCATION_REGEX = /@location\((\d+)\)\s+([a-zA-Z0-9_]+)\s*:\s*([a-zA-Z0-9_<>]+)(?:,|\s|\)|$)/g;
exports.extractAttributesFromGpuProgram = function({source, entryPoint}) {
const results = {};
source = source.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
entryPoint = source.indexOf(`fn ${entryPoint}(`);
if (-1 === entryPoint) {
return results;
}
const arrowFunctionStart = source.indexOf("-\x3e", entryPoint);
if (-1 === arrowFunctionStart) {
return results;
}
entryPoint = source.substring(entryPoint, arrowFunctionStart);
parseLocations(entryPoint, results);
0 === Object.keys(results).length && (entryPoint = entryPoint.match(/\(\s*\w+\s*:\s*(\w+)/)) && (source = source.match(new RegExp(`struct\\s+${entryPoint[1]}\\s*\\{([^}]+)\\}`, "s"))) && parseLocations(source[1], results);
return results;
};
};
//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$rendering$renderers$gpu$shader$utils$extractAttributesFromGpuProgram.js.map