Revert "feat(render): Campaign V slice V4d-2 - move terrain onto the RHI"
This reverts commit b064668b63.
This commit is contained in:
parent
b064668b63
commit
ad61f250fb
7 changed files with 553 additions and 496 deletions
|
|
@ -32,6 +32,7 @@ internal sealed record WorldRenderFoundation(
|
|||
string ShadersDirectory,
|
||||
BindlessSupport Bindless,
|
||||
TerrainAtlas TerrainAtlas,
|
||||
Shader TerrainShader,
|
||||
SceneLightingUboBinding SceneLighting,
|
||||
DebugLineRenderer DebugLines,
|
||||
BitmapFont? DebugFont,
|
||||
|
|
@ -61,6 +62,7 @@ internal sealed record WorldRenderDependencies(
|
|||
internal interface IGameWindowWorldRenderPublication
|
||||
{
|
||||
void PublishBindlessSupport(BindlessSupport value);
|
||||
void PublishTerrainShader(Shader value);
|
||||
void PublishSceneLighting(SceneLightingUboBinding value);
|
||||
void PublishDebugLines(DebugLineRenderer value);
|
||||
void PublishHudResources(BitmapFont font, TextRenderer text);
|
||||
|
|
@ -87,6 +89,7 @@ internal interface IWorldRenderCompositionFactory
|
|||
IDatReaderWriter dats,
|
||||
BindlessSupport bindless);
|
||||
void SetTerrainAnisotropic(TerrainAtlas atlas, int level);
|
||||
Shader CreateTerrainShader(GL gl, string shadersDirectory);
|
||||
SceneLightingUboBinding CreateSceneLighting(GL gl);
|
||||
DebugLineRenderer CreateDebugLines(
|
||||
AcDream.App.Rendering.Gpu.IGpuDevice device,
|
||||
|
|
@ -100,8 +103,8 @@ internal interface IWorldRenderCompositionFactory
|
|||
string shadersDirectory);
|
||||
TerrainModernRenderer CreateTerrain(
|
||||
GL gl,
|
||||
AcDream.App.Rendering.Gpu.IGpuDevice device,
|
||||
ICurrentGpuFrameSource frameSource,
|
||||
BindlessSupport bindless,
|
||||
Shader shader,
|
||||
TerrainAtlas atlas,
|
||||
IGpuResourceRetirementQueue retirement);
|
||||
WorldTerrainBuildContext CreateTerrainBuildContext(
|
||||
|
|
@ -212,6 +215,13 @@ internal sealed class RetailWorldRenderCompositionFactory
|
|||
public void SetTerrainAnisotropic(TerrainAtlas atlas, int level) =>
|
||||
atlas.SetAnisotropic(level);
|
||||
|
||||
public Shader CreateTerrainShader(GL gl, string shadersDirectory) =>
|
||||
new(
|
||||
gl,
|
||||
Path.Combine(shadersDirectory, "terrain_modern.vert"),
|
||||
Path.Combine(shadersDirectory, "terrain_modern.frag"),
|
||||
includeCommonPreamble: true);
|
||||
|
||||
public SceneLightingUboBinding CreateSceneLighting(GL gl) => new(gl);
|
||||
|
||||
public DebugLineRenderer CreateDebugLines(
|
||||
|
|
@ -234,11 +244,11 @@ internal sealed class RetailWorldRenderCompositionFactory
|
|||
|
||||
public TerrainModernRenderer CreateTerrain(
|
||||
GL gl,
|
||||
AcDream.App.Rendering.Gpu.IGpuDevice device,
|
||||
ICurrentGpuFrameSource frameSource,
|
||||
BindlessSupport bindless,
|
||||
Shader shader,
|
||||
TerrainAtlas atlas,
|
||||
IGpuResourceRetirementQueue retirement) =>
|
||||
new(gl, device, frameSource, atlas, retirement);
|
||||
new(gl, bindless, shader, atlas, retirement);
|
||||
|
||||
public WorldTerrainBuildContext CreateTerrainBuildContext(
|
||||
uint initialCenterLandblockId,
|
||||
|
|
@ -386,6 +396,7 @@ internal enum WorldRenderCompositionPoint
|
|||
EnvironmentInitialized,
|
||||
BindlessPublished,
|
||||
TerrainAtlasAcquired,
|
||||
TerrainShaderPublished,
|
||||
SceneLightingPublished,
|
||||
DebugLinesPublished,
|
||||
DebugFontCreated,
|
||||
|
|
@ -472,9 +483,12 @@ internal sealed class WorldRenderCompositionPhase
|
|||
AppContext.BaseDirectory,
|
||||
"Rendering",
|
||||
"Shaders");
|
||||
// Campaign V slice V4d: terrain no longer needs a Shader composed
|
||||
// for it — its IGpuPipeline compiles terrain_modern itself, from
|
||||
// the same sources with the same shared preamble.
|
||||
Shader terrainShader = AcquireAndPublish(
|
||||
scope,
|
||||
"terrain shader",
|
||||
() => _factory.CreateTerrainShader(gl, shadersDirectory),
|
||||
_publication.PublishTerrainShader,
|
||||
WorldRenderCompositionPoint.TerrainShaderPublished);
|
||||
SceneLightingUboBinding sceneLighting = AcquireAndPublish(
|
||||
scope,
|
||||
"scene lighting",
|
||||
|
|
@ -499,8 +513,8 @@ internal sealed class WorldRenderCompositionPhase
|
|||
"terrain renderer",
|
||||
() => _factory.CreateTerrain(
|
||||
gl,
|
||||
_dependencies.GpuDevice,
|
||||
_dependencies.GpuFrameSource,
|
||||
bindless,
|
||||
terrainShader,
|
||||
terrainAtlas,
|
||||
_dependencies.ResourceRetirement),
|
||||
_publication.PublishTerrain,
|
||||
|
|
@ -573,6 +587,7 @@ internal sealed class WorldRenderCompositionPhase
|
|||
shadersDirectory,
|
||||
bindless,
|
||||
terrainAtlas,
|
||||
terrainShader,
|
||||
sceneLighting,
|
||||
debugLines,
|
||||
debugFont,
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@ public sealed class GameWindow :
|
|||
private GL? _gl;
|
||||
private IInputContext? _input;
|
||||
private TerrainModernRenderer? _terrain;
|
||||
/// <summary>Phase N.5b: terrain_modern.vert/.frag program. Owned by
|
||||
/// <see cref="_terrain"/> at draw time but allocated + disposed here.</summary>
|
||||
private Shader? _terrainModernShader;
|
||||
private CameraController? _cameraController;
|
||||
private IDatReaderWriter? _dats;
|
||||
private IPreparedAssetSource? _preparedAssets;
|
||||
|
|
@ -894,6 +897,12 @@ public sealed class GameWindow :
|
|||
value,
|
||||
"bindless support");
|
||||
|
||||
void IGameWindowWorldRenderPublication.PublishTerrainShader(Shader value) =>
|
||||
PublishCompositionOwner(
|
||||
ref _terrainModernShader,
|
||||
value,
|
||||
"terrain shader");
|
||||
|
||||
void IGameWindowWorldRenderPublication.PublishSceneLighting(
|
||||
SceneLightingUboBinding value) =>
|
||||
PublishCompositionOwner(
|
||||
|
|
@ -1672,6 +1681,7 @@ public sealed class GameWindow :
|
|||
_wbMeshAdapter,
|
||||
_meshShader,
|
||||
_terrain,
|
||||
_terrainModernShader,
|
||||
_sceneLightingUbo,
|
||||
_debugLines,
|
||||
_textRenderer,
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ internal sealed record RenderShutdownRoots(
|
|||
WbMeshAdapter? MeshAdapter,
|
||||
Shader? MeshShader,
|
||||
TerrainModernRenderer? Terrain,
|
||||
Shader? TerrainShader,
|
||||
SceneLightingUboBinding? SceneLighting,
|
||||
DebugLineRenderer? DebugLines,
|
||||
TextRenderer? TextRenderer,
|
||||
|
|
@ -454,6 +455,7 @@ internal static class GameWindowShutdownManifest
|
|||
[
|
||||
Hard("mesh shader", () => render.MeshShader?.Dispose()),
|
||||
Hard("terrain", () => render.Terrain?.Dispose()),
|
||||
Hard("terrain shader", () => render.TerrainShader?.Dispose()),
|
||||
Hard("scene lighting", () => render.SceneLighting?.Dispose()),
|
||||
Hard("debug lines", () => render.DebugLines?.Dispose()),
|
||||
Hard("text renderer", () => render.TextRenderer?.Dispose()),
|
||||
|
|
|
|||
|
|
@ -30,26 +30,15 @@ out vec4 fragColor;
|
|||
// Campaign V slice V2b (2026-07-27): uTerrainHandle/uAlphaHandle (uvec2, raw
|
||||
// ARB_bindless_texture handles) became uTextureIndexA/uTextureIndexB (slots
|
||||
// into the binding=9 handle table, ACDREAM_TEXTURE_HANDLE in common.glsl).
|
||||
// Named to match the pinned GpuPushConstants.TextureIndexA/B fields, so slice
|
||||
// V4d's move onto push constants was a rename rather than a redesign. The GL
|
||||
// backend maps each push-constant field to the correspondingly named uniform,
|
||||
// which is why these stay declared exactly as they are.
|
||||
// Named to match the pinned GpuPushConstants.TextureIndexA/B fields so V4d's
|
||||
// move to push constants is a rename, not a redesign — there is no
|
||||
// push-constant plumbing yet, so these stay plain uniforms for now.
|
||||
uniform uint uTextureIndexA;
|
||||
uniform uint uTextureIndexB;
|
||||
uniform float uTexTiling[36];
|
||||
#define uTerrain sampler2DArray(ACDREAM_TEXTURE_HANDLE(uTextureIndexA))
|
||||
#define uAlpha sampler2DArray(ACDREAM_TEXTURE_HANDLE(uTextureIndexB))
|
||||
|
||||
// Campaign V slice V4d: the per-layer tiling table moved out of a loose
|
||||
// `uniform float uTexTiling[36]` and into a uniform block at
|
||||
// GpuBindingModel.UniformTerrainTiling. At 144 bytes of payload it cannot ride
|
||||
// in the 96-byte GpuPushConstants block (nor Vulkan's guaranteed 128-byte
|
||||
// ceiling), and there is no RHI verb for setting a uniform array. std140 pads
|
||||
// each array element to 16 bytes, so the block is 576 bytes; the element type
|
||||
// is unchanged so uTexTiling[i] reads exactly as it did before.
|
||||
layout(std140, ACDREAM_UBO_SET binding = 3) uniform TerrainTiling {
|
||||
float uTexTiling[36];
|
||||
};
|
||||
|
||||
struct Light {
|
||||
vec4 posAndKind;
|
||||
vec4 dirAndRange;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -90,11 +90,7 @@ public sealed class WorldRenderCompositionTests
|
|||
}
|
||||
|
||||
[Theory]
|
||||
// The "terrain shader" row went with Campaign V slice V4d: terrain's
|
||||
// IGpuPipeline compiles terrain_modern itself, so there is no longer a
|
||||
// terrain-shader publication step for a failure to be injected into. The
|
||||
// invariant this theory pins is unchanged and still covered by every row
|
||||
// below.
|
||||
[InlineData("terrain shader", "terrain shader")]
|
||||
[InlineData("scene lighting", "scene lighting")]
|
||||
[InlineData("debug lines", "debug lines")]
|
||||
[InlineData("HUD", "text renderer|debug font")]
|
||||
|
|
@ -251,6 +247,9 @@ public sealed class WorldRenderCompositionTests
|
|||
public void SetTerrainAnisotropic(TerrainAtlas atlas, int level) =>
|
||||
AnisotropicLevel = level;
|
||||
|
||||
public Shader CreateTerrainShader(GL gl, string shadersDirectory) =>
|
||||
Resource<Shader>("terrain shader");
|
||||
|
||||
public SceneLightingUboBinding CreateSceneLighting(GL gl) =>
|
||||
Resource<SceneLightingUboBinding>("scene lighting");
|
||||
|
||||
|
|
@ -269,8 +268,8 @@ public sealed class WorldRenderCompositionTests
|
|||
|
||||
public TerrainModernRenderer CreateTerrain(
|
||||
GL gl,
|
||||
IGpuDevice device,
|
||||
ICurrentGpuFrameSource frameSource,
|
||||
BindlessSupport bindless,
|
||||
Shader shader,
|
||||
TerrainAtlas atlas,
|
||||
IGpuResourceRetirementQueue retirement) =>
|
||||
Resource<TerrainModernRenderer>("terrain");
|
||||
|
|
@ -351,6 +350,8 @@ public sealed class WorldRenderCompositionTests
|
|||
|
||||
public void PublishBindlessSupport(BindlessSupport value) =>
|
||||
Fail("bindless");
|
||||
public void PublishTerrainShader(Shader value) =>
|
||||
Fail("terrain shader");
|
||||
public void PublishSceneLighting(SceneLightingUboBinding value) =>
|
||||
Fail("scene lighting");
|
||||
public void PublishDebugLines(DebugLineRenderer value) =>
|
||||
|
|
|
|||
|
|
@ -55,14 +55,7 @@ public sealed class TerrainTextureTilingTableTests
|
|||
"terrain_modern.frag");
|
||||
string shader = File.ReadAllText(shaderPath);
|
||||
|
||||
// Campaign V slice V4d moved the table out of a loose
|
||||
// `uniform float uTexTiling[36]` and into a std140 block at
|
||||
// GpuBindingModel.UniformTerrainTiling. The element type and count are
|
||||
// what every sample site below depends on, so both are still pinned —
|
||||
// and the binding number is now pinned too, because the shader and
|
||||
// GpuBindingModel have to agree.
|
||||
Assert.Contains("binding = 3) uniform TerrainTiling {", shader);
|
||||
Assert.Contains("float uTexTiling[36];", shader);
|
||||
Assert.Contains("uniform float uTexTiling[36];", shader);
|
||||
Assert.Contains("baseUV * terrainTiling(pOverlay0.z)", shader);
|
||||
Assert.Contains("baseUV * terrainTiling(pOverlay1.z)", shader);
|
||||
Assert.Contains("baseUV * terrainTiling(pOverlay2.z)", shader);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue