Skip to content
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

V3.8.1 pipeline #15906

Merged
merged 21 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion cocos/rendering/custom/pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ import { GlobalDSManager } from '../global-descriptor-set-manager';
import { Mat4, Quat, Vec2, Vec4 } from '../../core/math';
import { MacroRecord } from '../../render-scene/core/pass-utils';
import { PipelineSceneData } from '../pipeline-scene-data';
import { PointLight } from '../../render-scene/scene/point-light';
import { RangedDirectionalLight } from '../../render-scene/scene/ranged-directional-light';
import { AccessType, CopyPair, LightInfo, MovePair, QueueHint, ResolvePair, ResourceDimension, ResourceFlags, ResourceResidency, SceneFlags, UpdateFrequency, UploadPair } from './types';
import { RenderWindow } from '../../render-scene/core/render-window';
import { Light, Model } from '../../render-scene/scene';
import { SphereLight } from '../../render-scene/scene/sphere-light';
import { SpotLight } from '../../render-scene/scene/spot-light';

/**
Expand Down Expand Up @@ -377,6 +380,11 @@ export interface Setter extends RenderNode {
setSampler (name: string, sampler: Sampler): void;
setBuiltinCameraConstants (camera: Camera): void;
setBuiltinShadowMapConstants (light: DirectionalLight): void;
setBuiltinDirectionalLightConstants (light: DirectionalLight, camera: Camera): void;
setBuiltinSphereLightConstants (light: SphereLight, camera: Camera): void;
setBuiltinSpotLightConstants (light: SpotLight, camera: Camera): void;
setBuiltinPointLightConstants (light: PointLight, camera: Camera): void;
setBuiltinRangedDirectionalLightConstants (light: RangedDirectionalLight, camera: Camera): void;
setBuiltinDirectionalLightViewConstants (light: DirectionalLight, level?: number): void;
setBuiltinSpotLightViewConstants (light: SpotLight): void;
}
Expand All @@ -402,7 +410,10 @@ export interface RenderQueueBuilder extends Setter {
camera: Camera,
light: LightInfo,
sceneFlags?: SceneFlags): void;
addScene (camera: Camera, sceneFlags: SceneFlags): void;
addScene (
camera: Camera,
sceneFlags: SceneFlags,
light?: Light | null): void;
addSceneCulledByDirectionalLight (
camera: Camera,
sceneFlags: SceneFlags,
Expand Down
6 changes: 5 additions & 1 deletion cocos/rendering/custom/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,12 +288,14 @@ export function getClearValueTypeName (e: ClearValueType): string {
}

export class LightInfo {
constructor (light: Light | null = null, level = 0) {
constructor (light: Light | null = null, level = 0, culledByLight = false) {
this.light = light;
this.level = level;
this.culledByLight = culledByLight;
}
/*refcount*/ light: Light | null;
level: number;
culledByLight: boolean;
}

export enum DescriptorTypeOrder {
Expand Down Expand Up @@ -505,11 +507,13 @@ export class PipelineStatistics {
export function saveLightInfo (ar: OutputArchive, v: LightInfo): void {
// skip, v.light: Light
ar.writeNumber(v.level);
ar.writeBool(v.culledByLight);
}

export function loadLightInfo (ar: InputArchive, v: LightInfo): void {
// skip, v.light: Light
v.level = ar.readNumber();
v.culledByLight = ar.readBool();
}

export function saveDescriptor (ar: OutputArchive, v: Descriptor): void {
Expand Down
41 changes: 31 additions & 10 deletions cocos/rendering/custom/web-pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { AccessType, AttachmentType, CopyPair, LightInfo, LightingMode, MovePair
import { ComputeView, RasterView, Blit, ClearView, ComputePass, CopyPass, Dispatch, ManagedBuffer, ManagedResource, MovePass, RasterPass, RasterSubpass, RenderData, RenderGraph, RenderGraphComponent, RenderGraphValue, RenderQueue, RenderSwapchain, ResourceDesc, ResourceGraph, ResourceGraphValue, ResourceStates, ResourceTraits, SceneData, Subpass } from './render-graph';
import { ComputePassBuilder, ComputeQueueBuilder, ComputeSubpassBuilder, BasicPipeline, PipelineBuilder, RenderPassBuilder, RenderQueueBuilder, RenderSubpassBuilder, PipelineType, BasicRenderPassBuilder, PipelineCapabilities, BasicMultisampleRenderPassBuilder } from './pipeline';
import { PipelineSceneData } from '../pipeline-scene-data';
import { Model, Camera, ShadowType, CSMLevel, DirectionalLight, SpotLight, PCFType, Shadows } from '../../render-scene/scene';
import { Model, Camera, ShadowType, CSMLevel, DirectionalLight, SpotLight, PCFType, Shadows, SphereLight, PointLight, RangedDirectionalLight } from '../../render-scene/scene';
import { Light, LightType } from '../../render-scene/scene/light';
import { DescriptorSetData, DescriptorSetLayoutData, LayoutGraphData } from './layout-graph';
import { Executor } from './executor';
Expand Down Expand Up @@ -237,16 +237,22 @@ export class WebSetter {
public offsetFloat (v: number, offset: number): void {
this._copyToBuffer(v, offset, Type.FLOAT);
}
public setBuffer (name: string, buffer: Buffer): void {}
public setBuffer (name: string, buffer: Buffer): void {
// TODO
}
public setTexture (name: string, texture: Texture): void {
if (this._getCurrDescriptorBlock(name) === -1) {
return;
}
const num = this._lg.attributeIndex.get(name)!;
this._data.textures.set(num, texture);
}
public setReadWriteBuffer (name: string, buffer: Buffer): void {}
public setReadWriteTexture (name: string, texture: Texture): void {}
public setReadWriteBuffer (name: string, buffer: Buffer): void {
// TODO
}
public setReadWriteTexture (name: string, texture: Texture): void {
// TODO
}
public setSampler (name: string, sampler: Sampler): void {
if (this._getCurrDescriptorBlock(name) === -1) {
return;
Expand All @@ -255,16 +261,31 @@ export class WebSetter {
this._data.samplers.set(num, sampler);
}
public setBuiltinCameraConstants (camera: Camera): void {

// TODO
}
public setBuiltinShadowMapConstants (light: Light, numLevels?: number): void {

// TODO
}
public setBuiltinDirectionalLightViewConstants (light: DirectionalLight): void {

// TODO
}
public setBuiltinSpotLightViewConstants (light: SpotLight): void {

// TODO
}
public setBuiltinDirectionalLightConstants (light: DirectionalLight, camera: Camera): void {
// TODO
}
public setBuiltinSphereLightConstants (light: SphereLight, camera: Camera): void {
// TODO
}
public setBuiltinSpotLightConstants (light: SpotLight, camera: Camera): void {
// TODO
}
public setBuiltinPointLightConstants (light: PointLight, camera: Camera): void {
// TODO
}
public setBuiltinRangedDirectionalLightConstants (light: RangedDirectionalLight, camera: Camera): void {
// TODO
}
public hasSampler (name: string): boolean {
const id = this._lg.attributeIndex.get(name);
Expand Down Expand Up @@ -1084,15 +1105,15 @@ export class WebRenderPassBuilder extends WebSetter implements BasicMultisampleR
this._pass.rasterViews.set(name, view);
}
resolveRenderTarget (source: string, target: string): void {

// TODO
}
resolveDepthStencil (
source: string,
target: string,
depthMode?: ResolveMode,
stencilMode?: ResolveMode,
): void {

// TODO
}
private _addComputeResource (name: string, accessType: AccessType, slotName: string): void {
const view = new ComputeView(slotName);
Expand Down
8 changes: 4 additions & 4 deletions native/cocos/renderer/frame-graph/ImmutableState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ std::pair<gfx::GFXObject*, gfx::GFXObject*> getBarrier(const ResourceBarrier& ba
info.type = barrierInfo.barrierType;
info.prevAccesses = getAccessFlags(usage, barrierInfo.beginStatus);
info.nextAccesses = getAccessFlags(usage, barrierInfo.endStatus);
info.baseMipLevel = static_cast<uint32_t>(barrierInfo.mipRange.base);
info.levelCount = static_cast<uint32_t>(barrierInfo.mipRange.len);
info.baseSlice = static_cast<uint32_t>(barrierInfo.layerRange.base);
info.sliceCount = static_cast<uint32_t>(barrierInfo.layerRange.len);
info.range.mipLevel = static_cast<uint32_t>(barrierInfo.mipRange.base);
info.range.levelCount = static_cast<uint32_t>(barrierInfo.mipRange.len);
info.range.firstSlice = static_cast<uint32_t>(barrierInfo.layerRange.base);
info.range.numSlices = static_cast<uint32_t>(barrierInfo.layerRange.len);

res.first = gfx::Device::getInstance()->getTextureBarrier(info);
res.second = gfxTexture;
Expand Down
18 changes: 13 additions & 5 deletions native/cocos/renderer/gfx-base/GFXDef-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,18 @@ struct RenderPassInfo {
EXPOSE_COPY_FN(RenderPassInfo)
};

struct ResourceRange {
uint32_t width{0};
uint32_t height{0};
uint32_t depthOrArraySize{0};
uint32_t firstSlice{0};
uint32_t numSlices{0};
uint32_t mipLevel{0};
uint32_t levelCount{0};
uint32_t basePlane{0};
uint32_t planeCount{0};
};

struct ALIGNAS(8) GeneralBarrierInfo {
AccessFlags prevAccesses{AccessFlagBit::NONE};
AccessFlags nextAccesses{AccessFlagBit::NONE};
Expand All @@ -1360,11 +1372,7 @@ struct ALIGNAS(8) TextureBarrierInfo {

BarrierType type{BarrierType::FULL};

uint32_t baseMipLevel{0};
uint32_t levelCount{1};
uint32_t baseSlice{0};
uint32_t sliceCount{1};

ResourceRange range{};
uint64_t discardContents{0}; // @ts-boolean

Queue *srcQueue{nullptr}; // @ts-nullable
Expand Down
8 changes: 4 additions & 4 deletions native/cocos/renderer/gfx-vulkan/states/VKTextureBarrier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ CCVKTextureBarrier::CCVKTextureBarrier(const TextureBarrierInfo &info) : Texture
_gpuBarrier->barrier.prevLayout = getAccessLayout(info.prevAccesses);
_gpuBarrier->barrier.nextLayout = getAccessLayout(info.nextAccesses);
_gpuBarrier->barrier.discardContents = !!info.discardContents;
_gpuBarrier->barrier.subresourceRange.baseMipLevel = 0U;
_gpuBarrier->barrier.subresourceRange.levelCount = VK_REMAINING_MIP_LEVELS;
_gpuBarrier->barrier.subresourceRange.baseArrayLayer = 0U;
_gpuBarrier->barrier.subresourceRange.layerCount = VK_REMAINING_ARRAY_LAYERS;
_gpuBarrier->barrier.subresourceRange.baseMipLevel = info.range.mipLevel;
_gpuBarrier->barrier.subresourceRange.levelCount = info.range.levelCount;
_gpuBarrier->barrier.subresourceRange.baseArrayLayer = info.range.firstSlice;
_gpuBarrier->barrier.subresourceRange.layerCount = info.range.numSlices;
_gpuBarrier->barrier.srcQueueFamilyIndex = info.srcQueue
? static_cast<CCVKQueue *>(info.srcQueue)->gpuQueue()->queueFamilyIndex
: VK_QUEUE_FAMILY_IGNORED;
Expand Down
3 changes: 2 additions & 1 deletion native/cocos/renderer/pipeline/custom/FGDispatcherTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ ResourceAccessGraph::ResourceAccessGraph(const allocator_type& alloc) noexcept
topologicalOrder(alloc),
resourceAccess(alloc),
movedTarget(alloc),
movedSourceStatus(alloc) {}
movedSourceStatus(alloc),
movedTargetStatus(alloc) {}

// ContinuousContainer
void ResourceAccessGraph::reserve(vertices_size_type sz) {
Expand Down
38 changes: 21 additions & 17 deletions native/cocos/renderer/pipeline/custom/FGDispatcherTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,9 @@ struct LeafStatus {
bool needCulling{false};
};

struct ResourceRange {
uint32_t width{0};
uint32_t height{0};
uint32_t depthOrArraySize{0};
uint32_t firstSlice{0};
uint32_t numSlices{0};
uint32_t mipLevel{0};
uint32_t levelCount{0};
uint32_t basePlane{0};
uint32_t planeCount{0};
};

struct AccessStatus {
gfx::AccessFlagBit accessFlag{gfx::AccessFlagBit::NONE};
ResourceRange range;
gfx::ResourceRange range;
};

struct ResourceAccessNode {
Expand Down Expand Up @@ -135,7 +123,7 @@ struct FGRenderPassInfo {
FGRenderPassInfo& operator=(FGRenderPassInfo&& rhs) = default;
FGRenderPassInfo& operator=(FGRenderPassInfo const& rhs) = default;

std::vector<LayoutAccess> colorAccesses;
ccstd::vector<LayoutAccess> colorAccesses;
LayoutAccess dsAccess;
LayoutAccess dsResolveAccess;
gfx::RenderPassInfo rpInfo;
Expand All @@ -156,8 +144,23 @@ struct Barrier {
};

struct BarrierNode {
std::vector<Barrier> frontBarriers;
std::vector<Barrier> rearBarriers;
ccstd::vector<Barrier> frontBarriers;
ccstd::vector<Barrier> rearBarriers;
};

struct SliceNode {
bool full{false};
ccstd::vector<uint32_t> mips;
};

struct TextureNode {
bool full{false};
ccstd::vector<SliceNode> slices;
};

struct ResourceNode {
bool full{false};
ccstd::vector<TextureNode> planes;
};

struct ResourceAccessGraph {
Expand Down Expand Up @@ -293,8 +296,9 @@ struct ResourceAccessGraph {
PmrFlatMap<ccstd::pmr::string, ResourceLifeRecord> resourceLifeRecord;
ccstd::pmr::vector<vertex_descriptor> topologicalOrder;
PmrTransparentMap<ccstd::pmr::string, PmrFlatMap<uint32_t, AccessStatus>> resourceAccess;
PmrFlatMap<ccstd::pmr::string, ccstd::pmr::vector<ccstd::pmr::string>> movedTarget;
PmrFlatMap<ccstd::pmr::string, PmrFlatMap<ccstd::pmr::string, ccstd::pmr::string>> movedTarget;
PmrFlatMap<ccstd::pmr::string, AccessStatus> movedSourceStatus;
PmrFlatMap<ccstd::pmr::string, ResourceNode> movedTargetStatus;
};

struct RelationGraph {
Expand Down
Loading
Loading