feat(render): implement Campaign AR and terrain fidelity
This commit is contained in:
parent
99cf26e00c
commit
7a5f96ede5
368 changed files with 50611 additions and 950 deletions
|
|
@ -18,7 +18,8 @@ namespace AcDream.Tools.ShaderCompiler;
|
|||
/// <c>BatchBuffer</c> (SSBO binding 1) and <c>SceneLighting</c> (UBO binding 1)
|
||||
/// can share a number. Vulkan has one namespace per set, so moving uniform
|
||||
/// buffers to set 1 preserves both numbers. <c>common.glsl</c> has carried this
|
||||
/// macro since V2 for exactly this moment.</item>
|
||||
/// macro since V2 for exactly this moment. <c>ACDREAM_PACK_UBO_SET</c> separately
|
||||
/// names opt-in set 3, which retail pipeline layouts do not contain.</item>
|
||||
/// <item>The texture table becomes a real descriptor array at set 2 binding 0,
|
||||
/// and <c>ACDREAM_TEXTURE_HANDLE</c> becomes an index rather than a packed
|
||||
/// bindless handle. <c>nonuniformEXT</c> is required, not optional: within one
|
||||
|
|
@ -59,6 +60,10 @@ internal static class VulkanGlslPreamble
|
|||
"uTextureIndexB",
|
||||
"uParamA",
|
||||
"uParamB",
|
||||
// Render-pack logical inputs C/D are packed into the existing spare
|
||||
// scalar words; no bytes are appended to retail's push block.
|
||||
"uTextureIndexC",
|
||||
"uTextureIndexD",
|
||||
];
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -66,7 +71,13 @@ internal static class VulkanGlslPreamble
|
|||
/// <paramref name="stage"/> only affects which stage-specific rewrites are
|
||||
/// emitted.
|
||||
/// </summary>
|
||||
internal static string Build(string stage)
|
||||
internal static string Build(string stage) =>
|
||||
Build(stage, includePackUniformSet: false, includePackTextureIndices: false);
|
||||
|
||||
private static string Build(
|
||||
string stage,
|
||||
bool includePackUniformSet,
|
||||
bool includePackTextureIndices)
|
||||
{
|
||||
var text = new StringBuilder();
|
||||
text.AppendLine("// ---- injected by tools/compile-shaders.ps1 (Campaign V slice V6c) ----");
|
||||
|
|
@ -86,6 +97,11 @@ internal static class VulkanGlslPreamble
|
|||
text.AppendLine("// §3.4 set 1: every uniform buffer. Under GL this macro expands to nothing.");
|
||||
text.AppendLine("#undef ACDREAM_UBO_SET");
|
||||
text.AppendLine("#define ACDREAM_UBO_SET set = 1,");
|
||||
if (includePackUniformSet)
|
||||
{
|
||||
text.AppendLine("#undef ACDREAM_PACK_UBO_SET");
|
||||
text.AppendLine("#define ACDREAM_PACK_UBO_SET set = 3,");
|
||||
}
|
||||
text.AppendLine();
|
||||
text.AppendLine("// §4.4 set 2: the global sampled-texture table that replaces");
|
||||
text.AppendLine("// GL_ARB_bindless_texture. Variable count, partially bound,");
|
||||
|
|
@ -136,6 +152,11 @@ internal static class VulkanGlslPreamble
|
|||
text.AppendLine("#define uTextureIndexB acdreamPush.textureIndexB");
|
||||
text.AppendLine("#define uParamA acdreamPush.paramA");
|
||||
text.AppendLine("#define uParamB acdreamPush.paramB");
|
||||
if (includePackTextureIndices)
|
||||
{
|
||||
text.AppendLine("#define uTextureIndexC floatBitsToUint(acdreamPush.paramA)");
|
||||
text.AppendLine("#define uTextureIndexD floatBitsToUint(acdreamPush.paramB)");
|
||||
}
|
||||
text.AppendLine();
|
||||
text.AppendLine("// §4.6: gl_DrawIDARB stays as written — glslang exposes it for Vulkan");
|
||||
text.AppendLine("// under the same ARB extension name. gl_InstanceIndex already includes");
|
||||
|
|
@ -158,6 +179,10 @@ internal static class VulkanGlslPreamble
|
|||
internal static string Apply(string source, string stage)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(source);
|
||||
bool includePackUniformSet = source.Contains("ACDREAM_PACK_UBO_SET", StringComparison.Ordinal);
|
||||
bool includePackTextureIndices =
|
||||
source.Contains("uTextureIndexC", StringComparison.Ordinal)
|
||||
|| source.Contains("uTextureIndexD", StringComparison.Ordinal);
|
||||
string[] lines = source.Replace("\r\n", "\n").Split('\n');
|
||||
var output = new StringBuilder();
|
||||
bool injected = false;
|
||||
|
|
@ -171,7 +196,7 @@ internal static class VulkanGlslPreamble
|
|||
// more keeps it, because a shader that opted into 460 did so for
|
||||
// a feature and quietly downgrading it would be a silent change.
|
||||
output.AppendLine(HighestVersion(trimmed) >= 460 ? "#version 460 core" : "#version 450 core");
|
||||
output.Append(Build(stage));
|
||||
output.Append(Build(stage, includePackUniformSet, includePackTextureIndices));
|
||||
injected = true;
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue