28 lines
2.5 KiB
JavaScript
28 lines
2.5 KiB
JavaScript
shadow$provide.module$node_modules$pixi_DOT_js$lib$rendering$renderers$gpu$shader$utils$createUboElementsWGSL = function(global, require, module, exports) {
|
|
const WGSL_ALIGN_SIZE_DATA = {i32:{align:4, size:4}, u32:{align:4, size:4}, f32:{align:4, size:4}, f16:{align:2, size:2}, "vec2\x3ci32\x3e":{align:8, size:8}, "vec2\x3cu32\x3e":{align:8, size:8}, "vec2\x3cf32\x3e":{align:8, size:8}, "vec2\x3cf16\x3e":{align:4, size:4}, "vec3\x3ci32\x3e":{align:16, size:12}, "vec3\x3cu32\x3e":{align:16, size:12}, "vec3\x3cf32\x3e":{align:16, size:12}, "vec3\x3cf16\x3e":{align:8, size:6}, "vec4\x3ci32\x3e":{align:16, size:16}, "vec4\x3cu32\x3e":{align:16, size:16},
|
|
"vec4\x3cf32\x3e":{align:16, size:16}, "vec4\x3cf16\x3e":{align:8, size:8}, "mat2x2\x3cf32\x3e":{align:8, size:16}, "mat2x2\x3cf16\x3e":{align:4, size:8}, "mat3x2\x3cf32\x3e":{align:8, size:24}, "mat3x2\x3cf16\x3e":{align:4, size:12}, "mat4x2\x3cf32\x3e":{align:8, size:32}, "mat4x2\x3cf16\x3e":{align:4, size:16}, "mat2x3\x3cf32\x3e":{align:16, size:32}, "mat2x3\x3cf16\x3e":{align:8, size:16}, "mat3x3\x3cf32\x3e":{align:16, size:48}, "mat3x3\x3cf16\x3e":{align:8, size:24}, "mat4x3\x3cf32\x3e":{align:16,
|
|
size:64}, "mat4x3\x3cf16\x3e":{align:8, size:32}, "mat2x4\x3cf32\x3e":{align:16, size:32}, "mat2x4\x3cf16\x3e":{align:8, size:16}, "mat3x4\x3cf32\x3e":{align:16, size:48}, "mat3x4\x3cf16\x3e":{align:8, size:24}, "mat4x4\x3cf32\x3e":{align:16, size:64}, "mat4x4\x3cf16\x3e":{align:8, size:32}};
|
|
exports.WGSL_ALIGN_SIZE_DATA = WGSL_ALIGN_SIZE_DATA;
|
|
exports.createUboElementsWGSL = function(uniformData) {
|
|
uniformData = uniformData.map(data => ({data, offset:0, size:0}));
|
|
let offset = 0;
|
|
for (let i = 0; i < uniformData.length; i++) {
|
|
const uboElement = uniformData[i];
|
|
let size = WGSL_ALIGN_SIZE_DATA[uboElement.data.type].size;
|
|
const align = WGSL_ALIGN_SIZE_DATA[uboElement.data.type].align;
|
|
if (!WGSL_ALIGN_SIZE_DATA[uboElement.data.type]) {
|
|
throw Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${uboElement.data.type}`);
|
|
}
|
|
1 < uboElement.data.size && (size = Math.max(size, align) * uboElement.data.size);
|
|
offset = Math.ceil(offset / align) * align;
|
|
uboElement.size = size;
|
|
uboElement.offset = offset;
|
|
offset += size;
|
|
}
|
|
offset = 16 * Math.ceil(offset / 16);
|
|
return {uboElements:uniformData, size:offset};
|
|
};
|
|
};
|
|
|
|
//# sourceMappingURL=module$node_modules$pixi_DOT_js$lib$rendering$renderers$gpu$shader$utils$createUboElementsWGSL.js.map
|