This commit is contained in:
Akko
2025-08-04 18:57:35 +02:00
parent 8cf6e78a79
commit 9495868c2e
5030 changed files with 518594 additions and 17609 deletions

View File

@@ -0,0 +1,19 @@
import { ExtensionType } from '../../../extensions/Extensions';
import type { Mesh } from '../shared/Mesh';
import type { MeshAdaptor, MeshPipe } from '../shared/MeshPipe';
/**
* The WebGL adaptor for the mesh system. Allows the Mesh System to be used with the WebGl renderer
* @memberof rendering
* @ignore
*/
export declare class GpuMeshAdapter implements MeshAdaptor {
/** @ignore */
static extension: {
readonly type: readonly [ExtensionType.WebGPUPipesAdaptor];
readonly name: "mesh";
};
private _shader;
init(): void;
execute(meshPipe: MeshPipe, mesh: Mesh): void;
destroy(): void;
}

View File

@@ -0,0 +1,73 @@
'use strict';
var Extensions = require('../../../extensions/Extensions.js');
var Matrix = require('../../../maths/matrix/Matrix.js');
var compileHighShaderToProgram = require('../../../rendering/high-shader/compileHighShaderToProgram.js');
var localUniformBit = require('../../../rendering/high-shader/shader-bits/localUniformBit.js');
var roundPixelsBit = require('../../../rendering/high-shader/shader-bits/roundPixelsBit.js');
var textureBit = require('../../../rendering/high-shader/shader-bits/textureBit.js');
var Shader = require('../../../rendering/renderers/shared/shader/Shader.js');
var Texture = require('../../../rendering/renderers/shared/texture/Texture.js');
var warn = require('../../../utils/logging/warn.js');
"use strict";
class GpuMeshAdapter {
init() {
const gpuProgram = compileHighShaderToProgram.compileHighShaderGpuProgram({
name: "mesh",
bits: [
localUniformBit.localUniformBit,
textureBit.textureBit,
roundPixelsBit.roundPixelsBit
]
});
this._shader = new Shader.Shader({
gpuProgram,
resources: {
uTexture: Texture.Texture.EMPTY._source,
uSampler: Texture.Texture.EMPTY._source.style,
textureUniforms: {
uTextureMatrix: { type: "mat3x3<f32>", value: new Matrix.Matrix() }
}
}
});
}
execute(meshPipe, mesh) {
const renderer = meshPipe.renderer;
let shader = mesh._shader;
if (!shader) {
shader = this._shader;
shader.groups[2] = renderer.texture.getTextureBindGroup(mesh.texture);
} else if (!shader.gpuProgram) {
warn.warn("Mesh shader has no gpuProgram", mesh.shader);
return;
}
const gpuProgram = shader.gpuProgram;
if (gpuProgram.autoAssignGlobalUniforms) {
shader.groups[0] = renderer.globalUniforms.bindGroup;
}
if (gpuProgram.autoAssignLocalUniforms) {
const localUniforms = meshPipe.localUniforms;
shader.groups[1] = renderer.renderPipes.uniformBatch.getUniformBindGroup(localUniforms, true);
}
renderer.encoder.draw({
geometry: mesh._geometry,
shader,
state: mesh.state
});
}
destroy() {
this._shader.destroy(true);
this._shader = null;
}
}
/** @ignore */
GpuMeshAdapter.extension = {
type: [
Extensions.ExtensionType.WebGPUPipesAdaptor
],
name: "mesh"
};
exports.GpuMeshAdapter = GpuMeshAdapter;
//# sourceMappingURL=GpuMeshAdapter.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,71 @@
import { ExtensionType } from '../../../extensions/Extensions.mjs';
import { Matrix } from '../../../maths/matrix/Matrix.mjs';
import { compileHighShaderGpuProgram } from '../../../rendering/high-shader/compileHighShaderToProgram.mjs';
import { localUniformBit } from '../../../rendering/high-shader/shader-bits/localUniformBit.mjs';
import { roundPixelsBit } from '../../../rendering/high-shader/shader-bits/roundPixelsBit.mjs';
import { textureBit } from '../../../rendering/high-shader/shader-bits/textureBit.mjs';
import { Shader } from '../../../rendering/renderers/shared/shader/Shader.mjs';
import { Texture } from '../../../rendering/renderers/shared/texture/Texture.mjs';
import { warn } from '../../../utils/logging/warn.mjs';
"use strict";
class GpuMeshAdapter {
init() {
const gpuProgram = compileHighShaderGpuProgram({
name: "mesh",
bits: [
localUniformBit,
textureBit,
roundPixelsBit
]
});
this._shader = new Shader({
gpuProgram,
resources: {
uTexture: Texture.EMPTY._source,
uSampler: Texture.EMPTY._source.style,
textureUniforms: {
uTextureMatrix: { type: "mat3x3<f32>", value: new Matrix() }
}
}
});
}
execute(meshPipe, mesh) {
const renderer = meshPipe.renderer;
let shader = mesh._shader;
if (!shader) {
shader = this._shader;
shader.groups[2] = renderer.texture.getTextureBindGroup(mesh.texture);
} else if (!shader.gpuProgram) {
warn("Mesh shader has no gpuProgram", mesh.shader);
return;
}
const gpuProgram = shader.gpuProgram;
if (gpuProgram.autoAssignGlobalUniforms) {
shader.groups[0] = renderer.globalUniforms.bindGroup;
}
if (gpuProgram.autoAssignLocalUniforms) {
const localUniforms = meshPipe.localUniforms;
shader.groups[1] = renderer.renderPipes.uniformBatch.getUniformBindGroup(localUniforms, true);
}
renderer.encoder.draw({
geometry: mesh._geometry,
shader,
state: mesh.state
});
}
destroy() {
this._shader.destroy(true);
this._shader = null;
}
}
/** @ignore */
GpuMeshAdapter.extension = {
type: [
ExtensionType.WebGPUPipesAdaptor
],
name: "mesh"
};
export { GpuMeshAdapter };
//# sourceMappingURL=GpuMeshAdapter.mjs.map

File diff suppressed because one or more lines are too long