Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
slimbuck committed Sep 16, 2024
2 parents df8501a + 1ebd443 commit fafcdbc
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 23 deletions.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions src/framework/components/camera/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ class CameraComponent extends Component {
*/
set renderPasses(passes) {
this._camera.renderPasses = passes;
this.dirtyLayerCompositionCameras();
this.system.app.scene.updateShaders = true;
}

/**
Expand All @@ -254,6 +256,8 @@ class CameraComponent extends Component {
* Sets the rendering parameters. If this is not null, the camera will use these rendering
* parameters instead of those specified in the scene's rendering parameters
* {@link Scene#rendering}.
*
* @type {RenderingParams|null}
*/
set rendering(value) {
this._camera.renderingParams = value;
Expand Down
2 changes: 1 addition & 1 deletion src/platform/graphics/render-target.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class RenderTarget {
this.id = id++;

// device, from one of the buffers
const device = options.colorBuffer?.device || options.depthBuffer?.device || options.graphicsDevice;
const device = options.colorBuffer?.device ?? options.colorBuffers?.[0].device ?? options.depthBuffer?.device ?? options.graphicsDevice;
Debug.assert(device, 'Failed to obtain the device, colorBuffer nor depthBuffer store it.');
this._device = device;

Expand Down
6 changes: 3 additions & 3 deletions src/platform/graphics/webgl/webgl-graphics-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -1149,14 +1149,14 @@ class WebglGraphicsDevice extends GraphicsDevice {
*/
startRenderPass(renderPass) {

DebugGraphics.pushGpuMarker(this, `Pass:${renderPass.name}`);
DebugGraphics.pushGpuMarker(this, 'START-PASS');

// set up render target
const rt = renderPass.renderTarget ?? this.backBuffer;
this.renderTarget = rt;
Debug.assert(rt);

DebugGraphics.pushGpuMarker(this, `Pass:${renderPass.name} RT:${rt.name}`);
DebugGraphics.pushGpuMarker(this, 'START-PASS');

this.updateBegin();

// the pass always start using full size of the target
Expand Down
6 changes: 3 additions & 3 deletions src/platform/graphics/webgpu/webgpu-graphics-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ class WebgpuGraphicsDevice extends GraphicsDevice {

// create a new encoder for each pass
this.commandEncoder = this.wgpu.createCommandEncoder();
DebugHelper.setLabel(this.commandEncoder, `${renderPass.name}-Encoder`);
DebugHelper.setLabel(this.commandEncoder, `${renderPass.name}-CmdEncoder RT:${rt.name}`);

// framebuffer is initialized at the start of the frame
if (rt !== this.backBuffer) {
Expand All @@ -676,10 +676,10 @@ class WebgpuGraphicsDevice extends GraphicsDevice {

// start the pass
this.passEncoder = this.commandEncoder.beginRenderPass(renderPassDesc);
DebugHelper.setLabel(this.passEncoder, renderPass.name);
DebugHelper.setLabel(this.passEncoder, `${renderPass.name}-PassEncoder RT:${rt.name}`);

// push marker to the passEncoder
DebugGraphics.pushGpuMarker(this, `Pass:${renderPass.name}`);
DebugGraphics.pushGpuMarker(this, `Pass:${renderPass.name} RT:${rt.name}`);

this.setupPassEncoderDefaults();

Expand Down
19 changes: 10 additions & 9 deletions src/platform/graphics/webgpu/webgpu-render-target.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,6 @@ class WebgpuRenderTarget {
*/
constructor(renderTarget) {
this.renderTarget = renderTarget;

// color formats are based on the textures
if (renderTarget._colorBuffers) {
renderTarget._colorBuffers.forEach((colorBuffer, index) => {
this.setColorAttachment(index, undefined, colorBuffer.impl.format);
});
}

this.updateKey();
}

/**
Expand Down Expand Up @@ -259,6 +250,14 @@ class WebgpuRenderTarget {
this.initDepthStencil(device, wgpu, renderTarget);

// initialize color attachments

// color formats are based on the textures
if (renderTarget._colorBuffers) {
renderTarget._colorBuffers.forEach((colorBuffer, index) => {
this.setColorAttachment(index, undefined, colorBuffer.impl.format);
});
}

this.renderPassDescriptor.colorAttachments = [];
const count = this.isBackbuffer ? 1 : (renderTarget._colorBuffers?.length ?? 0);
for (let i = 0; i < count; ++i) {
Expand All @@ -273,6 +272,8 @@ class WebgpuRenderTarget {
}
}

this.updateKey();

this.initialized = true;

WebgpuDebug.end(device, { renderTarget });
Expand Down
2 changes: 1 addition & 1 deletion src/scene/graphics/render-pass-quad.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class RenderPassQuad extends RenderPass {

execute() {
const { device } = this;
DebugGraphics.pushGpuMarker(device, 'drawQuadWithShader');
DebugGraphics.pushGpuMarker(device, `${this.name}:${this.quad.shader.name}`);

device.setCullMode(CULLFACE_NONE);
device.setDepthState(DepthState.NODEPTH);
Expand Down
10 changes: 4 additions & 6 deletions src/scene/renderer/forward-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,21 +794,19 @@ class ForwardRenderer extends Renderer {

if (renderParams.fog !== FOG_NONE) {

const scene = this.scene;

// color in linear space
tmpColor.linear(scene?.rendering.fogColor);
tmpColor.linear(renderParams.fogColor);
const fogUniform = this.fogColor;
fogUniform[0] = tmpColor.r;
fogUniform[1] = tmpColor.g;
fogUniform[2] = tmpColor.b;
this.fogColorId.setValue(fogUniform);

if (renderParams.fog === FOG_LINEAR) {
this.fogStartId.setValue(scene.rendering.fogStart);
this.fogEndId.setValue(scene.rendering.fogEnd);
this.fogStartId.setValue(renderParams.fogStart);
this.fogEndId.setValue(renderParams.fogEnd);
} else {
this.fogDensityId.setValue(scene.rendering.fogDensity);
this.fogDensityId.setValue(renderParams.fogDensity);
}
}
}
Expand Down

0 comments on commit fafcdbc

Please sign in to comment.