diff --git a/src/scene/graphics/gl/GlGraphicsAdaptor.ts b/src/scene/graphics/gl/GlGraphicsAdaptor.ts index f26efca0cf..acbe9a2897 100644 --- a/src/scene/graphics/gl/GlGraphicsAdaptor.ts +++ b/src/scene/graphics/gl/GlGraphicsAdaptor.ts @@ -94,7 +94,7 @@ export class GlGraphicsAdaptor implements GraphicsAdaptor renderer.texture.bind(batch.textures.textures[j], j); } - renderer.geometry.draw('triangle-list', batch.size, batch.start); + renderer.geometry.draw(batch.topology, batch.size, batch.start); } } } diff --git a/src/scene/graphics/gpu/GpuGraphicsAdaptor.ts b/src/scene/graphics/gpu/GpuGraphicsAdaptor.ts index 13089ae683..dd48b6fa08 100644 --- a/src/scene/graphics/gpu/GpuGraphicsAdaptor.ts +++ b/src/scene/graphics/gpu/GpuGraphicsAdaptor.ts @@ -13,6 +13,7 @@ import { UniformGroup } from '../../../rendering/renderers/shared/shader/Uniform import type { Batch } from '../../../rendering/batcher/shared/Batcher'; import type { GpuEncoderSystem } from '../../../rendering/renderers/gpu/GpuEncoderSystem'; import type { WebGPURenderer } from '../../../rendering/renderers/gpu/WebGPURenderer'; +import type { Topology } from '../../../rendering/renderers/shared/geometry/const'; import type { Graphics } from '../shared/Graphics'; import type { GraphicsAdaptor, GraphicsPipe } from '../shared/GraphicsPipe'; @@ -77,12 +78,6 @@ export class GpuGraphicsAdaptor implements GraphicsAdaptor // TODO perf test this a bit... const encoder = renderer.encoder as GpuEncoderSystem; - encoder.setPipelineFromGeometryProgramAndState( - batcher.geometry, - shader.gpuProgram, - graphicsPipe.state - ); - encoder.setGeometry(batcher.geometry, shader.gpuProgram); const globalUniformsBindGroup = renderer.globalUniforms.bindGroup; @@ -96,10 +91,24 @@ export class GpuGraphicsAdaptor implements GraphicsAdaptor const batches = instructions.instructions as Batch[]; + let topology: Topology = null; + for (let i = 0; i < instructions.instructionSize; i++) { const batch = batches[i]; + if (batch.topology !== topology) + { + topology = batch.topology; + + encoder.setPipelineFromGeometryProgramAndState( + batcher.geometry, + shader.gpuProgram, + graphicsPipe.state, + batch.topology + ); + } + shader.groups[1] = batch.bindGroup; if (!batch.gpuBindGroup) diff --git a/tests/visual/scenes/graphics/graphics-pixel-line.scene.ts b/tests/visual/scenes/graphics/graphics-pixel-line.scene.ts index 0f58225a44..bdd50db292 100644 --- a/tests/visual/scenes/graphics/graphics-pixel-line.scene.ts +++ b/tests/visual/scenes/graphics/graphics-pixel-line.scene.ts @@ -20,5 +20,15 @@ export const scene: TestScene = { .stroke({ color: 0x0, pixelLine: true, alpha: 0.5 }); scene.addChild(graphics); + + const graphics2 = new Graphics(); + + graphics2.context.batchMode = 'no-batch'; + + graphics2 + .circle(128 / 2, 128 / 2, 128 / 3) + .stroke({ color: 0x00FF00, pixelLine: true, alpha: 1 }); + + scene.addChild(graphics, graphics2); }, }; diff --git a/tests/visual/snapshots/graphics-pixel-line-scene-ts-webgl1.png b/tests/visual/snapshots/graphics-pixel-line-scene-ts-webgl1.png index 01ac1c0184..44af65fbeb 100644 Binary files a/tests/visual/snapshots/graphics-pixel-line-scene-ts-webgl1.png and b/tests/visual/snapshots/graphics-pixel-line-scene-ts-webgl1.png differ diff --git a/tests/visual/snapshots/graphics-pixel-line-scene-ts-webgl2.png b/tests/visual/snapshots/graphics-pixel-line-scene-ts-webgl2.png index 01ac1c0184..44af65fbeb 100644 Binary files a/tests/visual/snapshots/graphics-pixel-line-scene-ts-webgl2.png and b/tests/visual/snapshots/graphics-pixel-line-scene-ts-webgl2.png differ diff --git a/tests/visual/snapshots/graphics-pixel-line-scene-ts-webgpu.png b/tests/visual/snapshots/graphics-pixel-line-scene-ts-webgpu.png index 01ac1c0184..44af65fbeb 100644 Binary files a/tests/visual/snapshots/graphics-pixel-line-scene-ts-webgpu.png and b/tests/visual/snapshots/graphics-pixel-line-scene-ts-webgpu.png differ