-
-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor 2d render pipeline #1708
base: dev/1.3
Are you sure you want to change the base?
Refactor 2d render pipeline #1708
Conversation
for (let i = 0; i < charCount; ++i) { | ||
const charRenderData = charRenderDatas[i]; | ||
const spriteRenderData = spriteRenderDataPool.getFromPool(); | ||
spriteRenderData.set(this, material, charRenderData.renderData, charRenderData.texture, i); | ||
charsData[i] = spriteRenderData; | ||
spriteRenderData.set(this, material, charRenderData.renderData, charRenderData.texture); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
charRenderData.usage = RenderDataUsage.Sprite;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
packages/core/src/Camera.ts
Outdated
@@ -70,6 +71,9 @@ export class Camera extends Component { | |||
_renderPipeline: BasicRenderPipeline; | |||
/** @internal */ | |||
@ignoreClone | |||
_batcherManager: BatcherManager; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not in BasicRenderPipeline
.
} | ||
|
||
commitRenderData(context: RenderContext, data: RenderData | Array<RenderData>): void { | ||
if (!data) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line can be deleted.
/** @internal */ | ||
_meshCount: number = 1; | ||
/** @internal */ | ||
_subMeshPool: ClassPool<SubMesh> = new ClassPool(SubMesh); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be a static variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be a static variable.
has deleted
|
||
commitRenderData(context: RenderContext, data: SpriteRenderData): void { | ||
if (this._preSpriteRenderData) { | ||
if (this._vertexCount + data.verticesData.vertexCount > Batcher2D.MAX_VERTEX_COUNT) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to judge index
this._cascadedShadowCaster = new CascadedShadowCasterPass(camera); | ||
this._depthOnlyPass = new DepthOnlyPass(engine); | ||
this._spriteMaskManager = new SpriteMaskManager(camera.engine); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it better to put SpriteMaskManager
in Scene
? Because :
- Mask does not depend on rendering timing.
- More memory efficient.
/** @internal */ | ||
_componentInstanceId: number; | ||
/** @internal */ | ||
_distanceForSort: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a internal class, why use internal property?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will change
|
||
/** | ||
* Render queue. | ||
*/ | ||
export class RenderQueue { | ||
private static _textureProperty: ShaderProperty = ShaderProperty.getByName("renderer_SpriteTexture"); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you define a render property in Renderqueue
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for text that with multi-texture, i do not have any good idea now
} else { | ||
return distanceDiff; | ||
} | ||
return dataA._distanceForSort - dataB._distanceForSort || instanceIdDiff; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not OK?
return (
dataA._priority - dataB._priority ||
dataA._distanceForSort - dataB._distanceForSort ||
dataA._componentInstanceId - dataB._componentInstanceId ||
dataA._materialPriority - dataB._materialPriority
);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, in some case, the same renderer wo want control the sort just for material priority, link lottie or spine
// TextRenderer may be has multi-texture. | ||
const isText = usage === RenderDataUsage.Text; | ||
// @ts-ignore | ||
isText && rendererData.setTexture(RenderQueue._textureProperty, data.texture); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No!!!!! This configuration should be done at the upper level
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't has a good idea how to handle a text renderer with multi-texture right now
const { usage } = data; | ||
const needMask = usage === RenderDataUsage.Sprite || usage === RenderDataUsage.Text; | ||
const renderer = data.component; | ||
needMask && spriteMaskManager.preRender(camera, <SpriteRenderer>renderer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Type is not write
compileMacros | ||
); | ||
const { usage } = data; | ||
const needMask = usage === RenderDataUsage.Sprite || usage === RenderDataUsage.Text; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SpriteMask is still very specialized!
import { SpriteMaskBatcher } from "./SpriteMaskBatcher"; | ||
import { SpriteMaskRenderData } from "./SpriteMaskRenderData"; | ||
import { StencilOperation } from "../shader"; | ||
import { SpriteMaskBatcher } from "./batcher/SpriteMaskBatcher"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to discuss!!!
} | ||
|
||
set( | ||
override set( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Further abstraction is needed. In addition, this is a common class between text and elves. The current definition is unreasonable.
import { RenderDataUsage } from "../enums/RenderDataUsage"; | ||
import { Batcher2D } from "./Batcher2D"; | ||
|
||
export class BatcherManager { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the value of this class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
future, i want handle all batch logic in batch function
/** | ||
* @internal | ||
*/ | ||
export class MeshBuffer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vague definition, and needs to be redesigned!!!!!!!!!
import { SpriteRenderData } from "../SpriteRenderData"; | ||
import { Batcher2D } from "./Batcher2D"; | ||
|
||
export class SpriteMaskBatcher extends Batcher2D { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically no design, may need to be rewritten
*/ | ||
export class MeshBuffer { | ||
/** @internal */ | ||
_mesh: BufferMesh; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Primitive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
Primitive
done
* @internal | ||
*/ | ||
protected _canBatch(elementA: RenderElement, elementB: RenderElement): boolean { | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to use RenderData
, RenderElement
is specific to RenderQueue
* @internal | ||
*/ | ||
protected _batchRenderElement(elementA: RenderElement, elementB?: RenderElement): void {} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to use RenderData
, RenderElement
is specific to RenderQueue
galacean-refactor-2d-render-pipeline.zip