feat(render): unify physical residency accounting
This commit is contained in:
parent
1866ea0c6d
commit
3e18fc2730
25 changed files with 642 additions and 48 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using System.Collections.Concurrent;
|
||||
using AcDream.App.Rendering;
|
||||
using AcDream.App.Rendering.Wb;
|
||||
using AcDream.App.Rendering.Residency;
|
||||
using AcDream.App.World;
|
||||
using AcDream.Content;
|
||||
using AcDream.Core.Terrain;
|
||||
|
|
@ -37,7 +38,8 @@ internal sealed record WorldRenderFoundation(
|
|||
Shader MeshShader,
|
||||
WbMeshAdapter MeshAdapter,
|
||||
TextureCache TextureCache,
|
||||
SamplerCache Samplers);
|
||||
SamplerCache Samplers,
|
||||
ResidencyManager Residency);
|
||||
|
||||
internal sealed record WorldRenderResult(
|
||||
WorldTerrainBuildContext TerrainBuild,
|
||||
|
|
@ -47,6 +49,7 @@ internal sealed record WorldRenderDependencies(
|
|||
WorldEnvironmentController Environment,
|
||||
IGameRenderResourceLifetime RenderResources,
|
||||
IGpuResourceRetirementQueue ResourceRetirement,
|
||||
ResidencyBudgetOptions ResidencyBudgets,
|
||||
uint InitialCenterLandblockId,
|
||||
Action<string> Log);
|
||||
|
||||
|
|
@ -101,12 +104,19 @@ internal interface IWorldRenderCompositionFactory
|
|||
GL gl,
|
||||
IDatReaderWriter dats,
|
||||
IPreparedAssetSource preparedAssets,
|
||||
IGpuResourceRetirementQueue retirement);
|
||||
IGpuResourceRetirementQueue retirement,
|
||||
ResidencyBudgetOptions budgets);
|
||||
TextureCache CreateTextureCache(
|
||||
GL gl,
|
||||
IDatReaderWriter dats,
|
||||
BindlessSupport bindless,
|
||||
IGpuResourceRetirementQueue retirement);
|
||||
IGpuResourceRetirementQueue retirement,
|
||||
ResidencyBudgetOptions budgets);
|
||||
void RegisterResidencySources(
|
||||
ResidencyManager manager,
|
||||
WbMeshAdapter meshes,
|
||||
TextureCache textures,
|
||||
IPreparedAssetSource preparedAssets);
|
||||
SamplerCache CreateSamplerCache(GL gl);
|
||||
void Release(IDisposable resource);
|
||||
}
|
||||
|
|
@ -263,20 +273,42 @@ internal sealed class RetailWorldRenderCompositionFactory
|
|||
GL gl,
|
||||
IDatReaderWriter dats,
|
||||
IPreparedAssetSource preparedAssets,
|
||||
IGpuResourceRetirementQueue retirement) =>
|
||||
IGpuResourceRetirementQueue retirement,
|
||||
ResidencyBudgetOptions budgets) =>
|
||||
new(
|
||||
gl,
|
||||
dats,
|
||||
preparedAssets,
|
||||
NullLogger<WbMeshAdapter>.Instance,
|
||||
retirement);
|
||||
retirement,
|
||||
budgets);
|
||||
|
||||
public TextureCache CreateTextureCache(
|
||||
GL gl,
|
||||
IDatReaderWriter dats,
|
||||
BindlessSupport bindless,
|
||||
IGpuResourceRetirementQueue retirement) =>
|
||||
new(gl, dats, bindless, retirement);
|
||||
IGpuResourceRetirementQueue retirement,
|
||||
ResidencyBudgetOptions budgets) =>
|
||||
new(gl, dats, bindless, retirement, budgets);
|
||||
|
||||
public void RegisterResidencySources(
|
||||
ResidencyManager manager,
|
||||
WbMeshAdapter meshes,
|
||||
TextureCache textures,
|
||||
IPreparedAssetSource preparedAssets)
|
||||
{
|
||||
meshes.RegisterResidencySources(manager);
|
||||
textures.RegisterResidencySources(manager);
|
||||
manager.RegisterDomainSource(new DelegateResidencyDomainSource(
|
||||
ResidencyDomain.PreparedPackage,
|
||||
() => new ResidencyDomainSnapshot(
|
||||
ResidencyDomain.PreparedPackage,
|
||||
EntryCount: 1,
|
||||
OwnerCount: 1,
|
||||
Charges: new ResidencyCharges(
|
||||
MappedVirtualBytes:
|
||||
preparedAssets.MappedVirtualBytes))));
|
||||
}
|
||||
|
||||
public SamplerCache CreateSamplerCache(GL gl) => new(gl);
|
||||
|
||||
|
|
@ -349,6 +381,8 @@ internal sealed class WorldRenderCompositionPhase
|
|||
try
|
||||
{
|
||||
GL gl = platform.Graphics;
|
||||
var residency = new ResidencyManager(
|
||||
_dependencies.ResidencyBudgets);
|
||||
_factory.InitializeGlState(gl);
|
||||
Fault(WorldRenderCompositionPoint.GlStateInitialized);
|
||||
|
||||
|
|
@ -434,7 +468,8 @@ internal sealed class WorldRenderCompositionPhase
|
|||
gl,
|
||||
content.Dats,
|
||||
content.PreparedAssets,
|
||||
_dependencies.ResourceRetirement),
|
||||
_dependencies.ResourceRetirement,
|
||||
residency.Budgets),
|
||||
_publication.PublishWbMeshAdapter,
|
||||
WorldRenderCompositionPoint.MeshAdapterPublished);
|
||||
TextureCache textureCache = AcquireAndPublish(
|
||||
|
|
@ -444,7 +479,8 @@ internal sealed class WorldRenderCompositionPhase
|
|||
gl,
|
||||
content.Dats,
|
||||
bindless,
|
||||
_dependencies.ResourceRetirement),
|
||||
_dependencies.ResourceRetirement,
|
||||
residency.Budgets),
|
||||
_publication.PublishTextureCache,
|
||||
WorldRenderCompositionPoint.TextureCachePublished);
|
||||
SamplerCache samplers = AcquireAndPublish(
|
||||
|
|
@ -453,6 +489,11 @@ internal sealed class WorldRenderCompositionPhase
|
|||
() => _factory.CreateSamplerCache(gl),
|
||||
_publication.PublishSamplerCache,
|
||||
WorldRenderCompositionPoint.SamplerCachePublished);
|
||||
_factory.RegisterResidencySources(
|
||||
residency,
|
||||
meshAdapter,
|
||||
textureCache,
|
||||
content.PreparedAssets);
|
||||
|
||||
scope.Complete();
|
||||
_dependencies.Log(
|
||||
|
|
@ -473,7 +514,8 @@ internal sealed class WorldRenderCompositionPhase
|
|||
meshShader,
|
||||
meshAdapter,
|
||||
textureCache,
|
||||
samplers));
|
||||
samplers,
|
||||
residency));
|
||||
}
|
||||
catch (Exception failure)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue