MCPcopy
hub / github.com/pixijs/pixijs / GpuMeshAdapter

Class GpuMeshAdapter

src/scene/mesh/gpu/GpuMeshAdapter.ts:20–104  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18 * @ignore
19 */
20export class GpuMeshAdapter implements MeshAdaptor
21{
22 /** @ignore */
23 public static extension = {
24 type: [
25 ExtensionType.WebGPUPipesAdaptor,
26 ],
27 name: 'mesh',
28 } as const;
29
30 private _shader: Shader;
31
32 public init(): void
33 {
34 const gpuProgram = compileHighShaderGpuProgram({
35 name: 'mesh',
36 bits: [
37 localUniformBit,
38 textureBit,
39 roundPixelsBit,
40 ]
41 });
42
43 this._shader = new Shader({
44 gpuProgram,
45 resources: {
46 uTexture: Texture.EMPTY._source,
47 uSampler: Texture.EMPTY._source.style,
48 textureUniforms: {
49 uTextureMatrix: { type: 'mat3x3<f32>', value: new Matrix() },
50 }
51 }
52 });
53 }
54
55 public execute(meshPipe: MeshPipe, mesh: Mesh)
56 {
57 const renderer = meshPipe.renderer as WebGPURenderer;
58
59 let shader: Shader = mesh._shader;
60
61 if (!shader)
62 {
63 shader = this._shader;
64
65 shader.groups[2] = renderer.texture.getTextureBindGroup(mesh.texture);
66 }
67 else if (!shader.gpuProgram)
68 {
69 // #if _DEBUG
70 warn('Mesh shader has no gpuProgram', mesh.shader);
71 // #endif
72
73 return;
74 }
75
76 const gpuProgram = shader.gpuProgram;
77 // GPU..

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected