Skip to content

Commit

Permalink
Neon White: Update for GfxRenderInst changes
Browse files Browse the repository at this point in the history
  • Loading branch information
magcius committed Nov 12, 2024
1 parent 4c92c5e commit 8542e08
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/NeonWhite/Scenes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { GfxrAttachmentSlot } from '../gfx/render/GfxRenderGraph.js';
import { GfxRenderHelper } from '../gfx/render/GfxRenderHelper.js';
import { UnityRuntime, MeshRenderer as UnityMeshRenderer, UnityMaterialFactory, UnityMaterialInstance, createUnityRuntime, UnityShaderProgramBase } from '../Common/Unity/GameObject.js';
import { UnityMaterialData } from '../Common/Unity/AssetManager.js';
import { GfxRenderInst } from '../gfx/render/GfxRenderInstManager.js';
import { GfxRenderInst, GfxRenderInstList } from '../gfx/render/GfxRenderInstManager.js';
import { nArray } from '../util.js';
import { TextureMapping } from '../TextureHolder.js';
import { CameraController } from '../Camera.js';
Expand Down Expand Up @@ -109,6 +109,7 @@ const bindingLayouts = [

class UnityRenderer implements Viewer.SceneGfx {
private renderHelper: GfxRenderHelper;
private renderInstListMain = new GfxRenderInstList();

constructor(private runtime: UnityRuntime) {
this.renderHelper = new GfxRenderHelper(this.runtime.context.device, this.runtime.context);
Expand All @@ -124,6 +125,8 @@ class UnityRenderer implements Viewer.SceneGfx {
const mapped = template.mapUniformBufferF32(0);
offs += fillMatrix4x4(mapped, offs, viewerInput.camera.clipFromWorldMatrix);

this.renderHelper.renderInstManager.setCurrentList(this.renderInstListMain);

const meshRenderers = this.runtime.getComponents(UnityMeshRenderer);
for (let i = 0; i < meshRenderers.length; i++)
meshRenderers[i].prepareToRender(this.renderHelper.renderInstManager, viewerInput);
Expand All @@ -137,8 +140,6 @@ class UnityRenderer implements Viewer.SceneGfx {
}

public render(device: GfxDevice, viewerInput: Viewer.ViewerRenderInput) {
const renderInstList = this.renderHelper.renderInstManager.currentList;

const mainColorDesc = makeBackbufferDescSimple(GfxrAttachmentSlot.Color0, viewerInput, standardFullClearRenderPassDescriptor);
const mainDepthDesc = makeBackbufferDescSimple(GfxrAttachmentSlot.DepthStencil, viewerInput, standardFullClearRenderPassDescriptor);

Expand All @@ -151,14 +152,14 @@ class UnityRenderer implements Viewer.SceneGfx {
pass.attachRenderTargetID(GfxrAttachmentSlot.Color0, mainColorTargetID);
pass.attachRenderTargetID(GfxrAttachmentSlot.DepthStencil, mainDepthTargetID);
pass.exec((passRenderer) => {
renderInstList.drawOnPassRenderer(this.renderHelper.renderCache, passRenderer);
this.renderInstListMain.drawOnPassRenderer(this.renderHelper.renderCache, passRenderer);
});
});
builder.resolveRenderTargetToExternalTexture(mainColorTargetID, viewerInput.onscreenTexture);

this.prepareToRender(device, viewerInput);
this.renderHelper.renderGraph.execute(builder);
renderInstList.reset();
this.renderInstListMain.reset();
}

public destroy(device: GfxDevice) {
Expand Down

0 comments on commit 8542e08

Please sign in to comment.