Skip to content

Commit

Permalink
refactor: opt code
Browse files Browse the repository at this point in the history
  • Loading branch information
GuoLei1990 committed Nov 18, 2024
1 parent 77fefc3 commit 0225664
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
7 changes: 4 additions & 3 deletions packages/core/src/RenderPipeline/BasicRenderPipeline.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Vector2 } from "@galacean/engine-math";
import { Background } from "../Background";
import { Camera } from "../Camera";
import { Engine } from "../Engine";
import { BackgroundMode } from "../enums/BackgroundMode";
import { BackgroundTextureFillMode } from "../enums/BackgroundTextureFillMode";
import { CameraClearFlags } from "../enums/CameraClearFlags";
Expand Down Expand Up @@ -270,8 +269,10 @@ export class BasicRenderPipeline {
const shaderPass = shaderPasses[i];
const renderState = shaderPass._renderState;
if (renderState) {
renderState._applyRenderQueueByShaderData(shaderPass._renderStateDataMap, subRenderElement.material.shaderData);
renderQueueType = renderState.renderQueueType;
renderQueueType = renderState._getRenderQueueByShaderData(
shaderPass._renderStateDataMap,
subRenderElement.material.shaderData
);
} else {
renderQueueType = renderStates[i].renderQueueType;
}
Expand Down
12 changes: 8 additions & 4 deletions packages/core/src/RenderPipeline/RenderQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,17 @@ export class RenderQueue {
if (shaderPass.getTagValue(pipelineStageKey) !== pipelineStageTagValue) {
continue;
}
const renderState = shaderPass._renderState ?? renderStates[j];

if (shaderPass._renderState) {
renderState._applyRenderQueueByShaderData(shaderPass._renderStateDataMap, materialData);
let renderState = shaderPass._renderState;
let passQueueType: RenderQueueType;
if (renderState) {
passQueueType = renderState._getRenderQueueByShaderData(shaderPass._renderStateDataMap, materialData);
} else {
renderState = renderStates[j];
passQueueType = renderState.renderQueueType;
}

if (renderState.renderQueueType !== renderQueueType) {
if (passQueueType !== renderQueueType) {
continue;
}

Expand Down
11 changes: 8 additions & 3 deletions packages/core/src/shader/state/RenderState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,15 @@ export class RenderState {
* @internal
* @todo Should merge when we can delete material render state
*/
_applyRenderQueueByShaderData(renderStateDataMap: Record<number, ShaderProperty>, shaderData: ShaderData): void {
_getRenderQueueByShaderData(
renderStateDataMap: Record<number, ShaderProperty>,
shaderData: ShaderData
): RenderQueueType {
const renderQueueType = renderStateDataMap[RenderStateElementKey.RenderQueueType];
if (renderQueueType !== undefined) {
this.renderQueueType = shaderData.getFloat(renderQueueType) ?? RenderQueueType.Opaque;
if (renderQueueType === undefined) {
return this.renderQueueType;
} else {
return shaderData.getFloat(renderQueueType) ?? RenderQueueType.Opaque;
}
}

Expand Down

0 comments on commit 0225664

Please sign in to comment.