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,
|
string ShadersDirectory,
|
||||||
BindlessSupport Bindless,
|
BindlessSupport Bindless,
|
||||||
TerrainAtlas TerrainAtlas,
|
TerrainAtlas TerrainAtlas,
|
||||||
|
Shader TerrainShader,
|
||||||
SceneLightingUboBinding SceneLighting,
|
SceneLightingUboBinding SceneLighting,
|
||||||
DebugLineRenderer DebugLines,
|
DebugLineRenderer DebugLines,
|
||||||
BitmapFont? DebugFont,
|
BitmapFont? DebugFont,
|
||||||
|
|
@ -61,6 +62,7 @@ internal sealed record WorldRenderDependencies(
|
||||||
internal interface IGameWindowWorldRenderPublication
|
internal interface IGameWindowWorldRenderPublication
|
||||||
{
|
{
|
||||||
void PublishBindlessSupport(BindlessSupport value);
|
void PublishBindlessSupport(BindlessSupport value);
|
||||||
|
void PublishTerrainShader(Shader value);
|
||||||
void PublishSceneLighting(SceneLightingUboBinding value);
|
void PublishSceneLighting(SceneLightingUboBinding value);
|
||||||
void PublishDebugLines(DebugLineRenderer value);
|
void PublishDebugLines(DebugLineRenderer value);
|
||||||
void PublishHudResources(BitmapFont font, TextRenderer text);
|
void PublishHudResources(BitmapFont font, TextRenderer text);
|
||||||
|
|
@ -87,6 +89,7 @@ internal interface IWorldRenderCompositionFactory
|
||||||
IDatReaderWriter dats,
|
IDatReaderWriter dats,
|
||||||
BindlessSupport bindless);
|
BindlessSupport bindless);
|
||||||
void SetTerrainAnisotropic(TerrainAtlas atlas, int level);
|
void SetTerrainAnisotropic(TerrainAtlas atlas, int level);
|
||||||
|
Shader CreateTerrainShader(GL gl, string shadersDirectory);
|
||||||
SceneLightingUboBinding CreateSceneLighting(GL gl);
|
SceneLightingUboBinding CreateSceneLighting(GL gl);
|
||||||
DebugLineRenderer CreateDebugLines(
|
DebugLineRenderer CreateDebugLines(
|
||||||
AcDream.App.Rendering.Gpu.IGpuDevice device,
|
AcDream.App.Rendering.Gpu.IGpuDevice device,
|
||||||
|
|
@ -100,8 +103,8 @@ internal interface IWorldRenderCompositionFactory
|
||||||
string shadersDirectory);
|
string shadersDirectory);
|
||||||
TerrainModernRenderer CreateTerrain(
|
TerrainModernRenderer CreateTerrain(
|
||||||
GL gl,
|
GL gl,
|
||||||
AcDream.App.Rendering.Gpu.IGpuDevice device,
|
BindlessSupport bindless,
|
||||||
ICurrentGpuFrameSource frameSource,
|
Shader shader,
|
||||||
TerrainAtlas atlas,
|
TerrainAtlas atlas,
|
||||||
IGpuResourceRetirementQueue retirement);
|
IGpuResourceRetirementQueue retirement);
|
||||||
WorldTerrainBuildContext CreateTerrainBuildContext(
|
WorldTerrainBuildContext CreateTerrainBuildContext(
|
||||||
|
|
@ -212,6 +215,13 @@ internal sealed class RetailWorldRenderCompositionFactory
|
||||||
public void SetTerrainAnisotropic(TerrainAtlas atlas, int level) =>
|
public void SetTerrainAnisotropic(TerrainAtlas atlas, int level) =>
|
||||||
atlas.SetAnisotropic(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 SceneLightingUboBinding CreateSceneLighting(GL gl) => new(gl);
|
||||||
|
|
||||||
public DebugLineRenderer CreateDebugLines(
|
public DebugLineRenderer CreateDebugLines(
|
||||||
|
|
@ -234,11 +244,11 @@ internal sealed class RetailWorldRenderCompositionFactory
|
||||||
|
|
||||||
public TerrainModernRenderer CreateTerrain(
|
public TerrainModernRenderer CreateTerrain(
|
||||||
GL gl,
|
GL gl,
|
||||||
AcDream.App.Rendering.Gpu.IGpuDevice device,
|
BindlessSupport bindless,
|
||||||
ICurrentGpuFrameSource frameSource,
|
Shader shader,
|
||||||
TerrainAtlas atlas,
|
TerrainAtlas atlas,
|
||||||
IGpuResourceRetirementQueue retirement) =>
|
IGpuResourceRetirementQueue retirement) =>
|
||||||
new(gl, device, frameSource, atlas, retirement);
|
new(gl, bindless, shader, atlas, retirement);
|
||||||
|
|
||||||
public WorldTerrainBuildContext CreateTerrainBuildContext(
|
public WorldTerrainBuildContext CreateTerrainBuildContext(
|
||||||
uint initialCenterLandblockId,
|
uint initialCenterLandblockId,
|
||||||
|
|
@ -386,6 +396,7 @@ internal enum WorldRenderCompositionPoint
|
||||||
EnvironmentInitialized,
|
EnvironmentInitialized,
|
||||||
BindlessPublished,
|
BindlessPublished,
|
||||||
TerrainAtlasAcquired,
|
TerrainAtlasAcquired,
|
||||||
|
TerrainShaderPublished,
|
||||||
SceneLightingPublished,
|
SceneLightingPublished,
|
||||||
DebugLinesPublished,
|
DebugLinesPublished,
|
||||||
DebugFontCreated,
|
DebugFontCreated,
|
||||||
|
|
@ -472,9 +483,12 @@ internal sealed class WorldRenderCompositionPhase
|
||||||
AppContext.BaseDirectory,
|
AppContext.BaseDirectory,
|
||||||
"Rendering",
|
"Rendering",
|
||||||
"Shaders");
|
"Shaders");
|
||||||
// Campaign V slice V4d: terrain no longer needs a Shader composed
|
Shader terrainShader = AcquireAndPublish(
|
||||||
// for it — its IGpuPipeline compiles terrain_modern itself, from
|
scope,
|
||||||
// the same sources with the same shared preamble.
|
"terrain shader",
|
||||||
|
() => _factory.CreateTerrainShader(gl, shadersDirectory),
|
||||||
|
_publication.PublishTerrainShader,
|
||||||
|
WorldRenderCompositionPoint.TerrainShaderPublished);
|
||||||
SceneLightingUboBinding sceneLighting = AcquireAndPublish(
|
SceneLightingUboBinding sceneLighting = AcquireAndPublish(
|
||||||
scope,
|
scope,
|
||||||
"scene lighting",
|
"scene lighting",
|
||||||
|
|
@ -499,8 +513,8 @@ internal sealed class WorldRenderCompositionPhase
|
||||||
"terrain renderer",
|
"terrain renderer",
|
||||||
() => _factory.CreateTerrain(
|
() => _factory.CreateTerrain(
|
||||||
gl,
|
gl,
|
||||||
_dependencies.GpuDevice,
|
bindless,
|
||||||
_dependencies.GpuFrameSource,
|
terrainShader,
|
||||||
terrainAtlas,
|
terrainAtlas,
|
||||||
_dependencies.ResourceRetirement),
|
_dependencies.ResourceRetirement),
|
||||||
_publication.PublishTerrain,
|
_publication.PublishTerrain,
|
||||||
|
|
@ -573,6 +587,7 @@ internal sealed class WorldRenderCompositionPhase
|
||||||
shadersDirectory,
|
shadersDirectory,
|
||||||
bindless,
|
bindless,
|
||||||
terrainAtlas,
|
terrainAtlas,
|
||||||
|
terrainShader,
|
||||||
sceneLighting,
|
sceneLighting,
|
||||||
debugLines,
|
debugLines,
|
||||||
debugFont,
|
debugFont,
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,9 @@ public sealed class GameWindow :
|
||||||
private GL? _gl;
|
private GL? _gl;
|
||||||
private IInputContext? _input;
|
private IInputContext? _input;
|
||||||
private TerrainModernRenderer? _terrain;
|
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 CameraController? _cameraController;
|
||||||
private IDatReaderWriter? _dats;
|
private IDatReaderWriter? _dats;
|
||||||
private IPreparedAssetSource? _preparedAssets;
|
private IPreparedAssetSource? _preparedAssets;
|
||||||
|
|
@ -894,6 +897,12 @@ public sealed class GameWindow :
|
||||||
value,
|
value,
|
||||||
"bindless support");
|
"bindless support");
|
||||||
|
|
||||||
|
void IGameWindowWorldRenderPublication.PublishTerrainShader(Shader value) =>
|
||||||
|
PublishCompositionOwner(
|
||||||
|
ref _terrainModernShader,
|
||||||
|
value,
|
||||||
|
"terrain shader");
|
||||||
|
|
||||||
void IGameWindowWorldRenderPublication.PublishSceneLighting(
|
void IGameWindowWorldRenderPublication.PublishSceneLighting(
|
||||||
SceneLightingUboBinding value) =>
|
SceneLightingUboBinding value) =>
|
||||||
PublishCompositionOwner(
|
PublishCompositionOwner(
|
||||||
|
|
@ -1672,6 +1681,7 @@ public sealed class GameWindow :
|
||||||
_wbMeshAdapter,
|
_wbMeshAdapter,
|
||||||
_meshShader,
|
_meshShader,
|
||||||
_terrain,
|
_terrain,
|
||||||
|
_terrainModernShader,
|
||||||
_sceneLightingUbo,
|
_sceneLightingUbo,
|
||||||
_debugLines,
|
_debugLines,
|
||||||
_textRenderer,
|
_textRenderer,
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,7 @@ internal sealed record RenderShutdownRoots(
|
||||||
WbMeshAdapter? MeshAdapter,
|
WbMeshAdapter? MeshAdapter,
|
||||||
Shader? MeshShader,
|
Shader? MeshShader,
|
||||||
TerrainModernRenderer? Terrain,
|
TerrainModernRenderer? Terrain,
|
||||||
|
Shader? TerrainShader,
|
||||||
SceneLightingUboBinding? SceneLighting,
|
SceneLightingUboBinding? SceneLighting,
|
||||||
DebugLineRenderer? DebugLines,
|
DebugLineRenderer? DebugLines,
|
||||||
TextRenderer? TextRenderer,
|
TextRenderer? TextRenderer,
|
||||||
|
|
@ -454,6 +455,7 @@ internal static class GameWindowShutdownManifest
|
||||||
[
|
[
|
||||||
Hard("mesh shader", () => render.MeshShader?.Dispose()),
|
Hard("mesh shader", () => render.MeshShader?.Dispose()),
|
||||||
Hard("terrain", () => render.Terrain?.Dispose()),
|
Hard("terrain", () => render.Terrain?.Dispose()),
|
||||||
|
Hard("terrain shader", () => render.TerrainShader?.Dispose()),
|
||||||
Hard("scene lighting", () => render.SceneLighting?.Dispose()),
|
Hard("scene lighting", () => render.SceneLighting?.Dispose()),
|
||||||
Hard("debug lines", () => render.DebugLines?.Dispose()),
|
Hard("debug lines", () => render.DebugLines?.Dispose()),
|
||||||
Hard("text renderer", () => render.TextRenderer?.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
|
// Campaign V slice V2b (2026-07-27): uTerrainHandle/uAlphaHandle (uvec2, raw
|
||||||
// ARB_bindless_texture handles) became uTextureIndexA/uTextureIndexB (slots
|
// ARB_bindless_texture handles) became uTextureIndexA/uTextureIndexB (slots
|
||||||
// into the binding=9 handle table, ACDREAM_TEXTURE_HANDLE in common.glsl).
|
// into the binding=9 handle table, ACDREAM_TEXTURE_HANDLE in common.glsl).
|
||||||
// Named to match the pinned GpuPushConstants.TextureIndexA/B fields, so slice
|
// Named to match the pinned GpuPushConstants.TextureIndexA/B fields so V4d's
|
||||||
// V4d's move onto push constants was a rename rather than a redesign. The GL
|
// move to push constants is a rename, not a redesign — there is no
|
||||||
// backend maps each push-constant field to the correspondingly named uniform,
|
// push-constant plumbing yet, so these stay plain uniforms for now.
|
||||||
// which is why these stay declared exactly as they are.
|
|
||||||
uniform uint uTextureIndexA;
|
uniform uint uTextureIndexA;
|
||||||
uniform uint uTextureIndexB;
|
uniform uint uTextureIndexB;
|
||||||
|
uniform float uTexTiling[36];
|
||||||
#define uTerrain sampler2DArray(ACDREAM_TEXTURE_HANDLE(uTextureIndexA))
|
#define uTerrain sampler2DArray(ACDREAM_TEXTURE_HANDLE(uTextureIndexA))
|
||||||
#define uAlpha sampler2DArray(ACDREAM_TEXTURE_HANDLE(uTextureIndexB))
|
#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 {
|
struct Light {
|
||||||
vec4 posAndKind;
|
vec4 posAndKind;
|
||||||
vec4 dirAndRange;
|
vec4 dirAndRange;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -90,11 +90,7 @@ public sealed class WorldRenderCompositionTests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
// The "terrain shader" row went with Campaign V slice V4d: terrain's
|
[InlineData("terrain shader", "terrain shader")]
|
||||||
// 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("scene lighting", "scene lighting")]
|
[InlineData("scene lighting", "scene lighting")]
|
||||||
[InlineData("debug lines", "debug lines")]
|
[InlineData("debug lines", "debug lines")]
|
||||||
[InlineData("HUD", "text renderer|debug font")]
|
[InlineData("HUD", "text renderer|debug font")]
|
||||||
|
|
@ -251,6 +247,9 @@ public sealed class WorldRenderCompositionTests
|
||||||
public void SetTerrainAnisotropic(TerrainAtlas atlas, int level) =>
|
public void SetTerrainAnisotropic(TerrainAtlas atlas, int level) =>
|
||||||
AnisotropicLevel = level;
|
AnisotropicLevel = level;
|
||||||
|
|
||||||
|
public Shader CreateTerrainShader(GL gl, string shadersDirectory) =>
|
||||||
|
Resource<Shader>("terrain shader");
|
||||||
|
|
||||||
public SceneLightingUboBinding CreateSceneLighting(GL gl) =>
|
public SceneLightingUboBinding CreateSceneLighting(GL gl) =>
|
||||||
Resource<SceneLightingUboBinding>("scene lighting");
|
Resource<SceneLightingUboBinding>("scene lighting");
|
||||||
|
|
||||||
|
|
@ -269,8 +268,8 @@ public sealed class WorldRenderCompositionTests
|
||||||
|
|
||||||
public TerrainModernRenderer CreateTerrain(
|
public TerrainModernRenderer CreateTerrain(
|
||||||
GL gl,
|
GL gl,
|
||||||
IGpuDevice device,
|
BindlessSupport bindless,
|
||||||
ICurrentGpuFrameSource frameSource,
|
Shader shader,
|
||||||
TerrainAtlas atlas,
|
TerrainAtlas atlas,
|
||||||
IGpuResourceRetirementQueue retirement) =>
|
IGpuResourceRetirementQueue retirement) =>
|
||||||
Resource<TerrainModernRenderer>("terrain");
|
Resource<TerrainModernRenderer>("terrain");
|
||||||
|
|
@ -351,6 +350,8 @@ public sealed class WorldRenderCompositionTests
|
||||||
|
|
||||||
public void PublishBindlessSupport(BindlessSupport value) =>
|
public void PublishBindlessSupport(BindlessSupport value) =>
|
||||||
Fail("bindless");
|
Fail("bindless");
|
||||||
|
public void PublishTerrainShader(Shader value) =>
|
||||||
|
Fail("terrain shader");
|
||||||
public void PublishSceneLighting(SceneLightingUboBinding value) =>
|
public void PublishSceneLighting(SceneLightingUboBinding value) =>
|
||||||
Fail("scene lighting");
|
Fail("scene lighting");
|
||||||
public void PublishDebugLines(DebugLineRenderer value) =>
|
public void PublishDebugLines(DebugLineRenderer value) =>
|
||||||
|
|
|
||||||
|
|
@ -55,14 +55,7 @@ public sealed class TerrainTextureTilingTableTests
|
||||||
"terrain_modern.frag");
|
"terrain_modern.frag");
|
||||||
string shader = File.ReadAllText(shaderPath);
|
string shader = File.ReadAllText(shaderPath);
|
||||||
|
|
||||||
// Campaign V slice V4d moved the table out of a loose
|
Assert.Contains("uniform float uTexTiling[36];", shader);
|
||||||
// `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("baseUV * terrainTiling(pOverlay0.z)", shader);
|
Assert.Contains("baseUV * terrainTiling(pOverlay0.z)", shader);
|
||||||
Assert.Contains("baseUV * terrainTiling(pOverlay1.z)", shader);
|
Assert.Contains("baseUV * terrainTiling(pOverlay1.z)", shader);
|
||||||
Assert.Contains("baseUV * terrainTiling(pOverlay2.z)", shader);
|
Assert.Contains("baseUV * terrainTiling(pOverlay2.z)", shader);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue