WIP pre-reboot checkpoint: Cut 14b HbGpuCanvas HUD + 4 Cut 14a scars
This commit is contained in:
parent
8310246f89
commit
93df511b60
10 changed files with 2630 additions and 2079 deletions
|
|
@ -14,6 +14,8 @@ public partial class HbGpuCanvas : Control
|
||||||
{
|
{
|
||||||
public const byte DefaultFontId = 0;
|
public const byte DefaultFontId = 0;
|
||||||
private const int PushConstantBytes = 80; // mat4 (64) + vec2 viewport (8) + vec2 logicalSize (8)
|
private const int PushConstantBytes = 80; // mat4 (64) + vec2 viewport (8) + vec2 logicalSize (8)
|
||||||
|
private const int AtlasTexWidth = 1024;
|
||||||
|
private const int AtlasTexHeight = 256; // 1024 * 256 = 262,144 == HbGpuAtlasAllocator.TotalTexels
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||||
private struct PushConstants
|
private struct PushConstants
|
||||||
|
|
@ -34,6 +36,8 @@ public partial class HbGpuCanvas : Control
|
||||||
|
|
||||||
private readonly object _syncLock = new();
|
private readonly object _syncLock = new();
|
||||||
private readonly HbGpuQuadInstance[] _stagedQuads = new HbGpuQuadInstance[HbGpuCommandWriter.MaxQuads];
|
private readonly HbGpuQuadInstance[] _stagedQuads = new HbGpuQuadInstance[HbGpuCommandWriter.MaxQuads];
|
||||||
|
private readonly byte[] _stagedAtlasMirror = new byte[HbGpuAtlasAllocator.TotalBytes];
|
||||||
|
private bool _stagedAtlasDirty;
|
||||||
private int _stagedQuadCount;
|
private int _stagedQuadCount;
|
||||||
private float _stagedLogicalW = 1280f;
|
private float _stagedLogicalW = 1280f;
|
||||||
private float _stagedLogicalH = 720f;
|
private float _stagedLogicalH = 720f;
|
||||||
|
|
@ -89,7 +93,7 @@ public partial class HbGpuCanvas : Control
|
||||||
AddChild(_outputRect);
|
AddChild(_outputRect);
|
||||||
_outputRect.SetAnchorsAndOffsetsPreset(LayoutPreset.FullRect);
|
_outputRect.SetAnchorsAndOffsetsPreset(LayoutPreset.FullRect);
|
||||||
|
|
||||||
_backend = new HbGpuVulkanBackend(_outputTexRd, _atlas);
|
_backend = new HbGpuVulkanBackend(_outputTexRd);
|
||||||
_renderCallable = Callable.From(RenderOnRenderThread);
|
_renderCallable = Callable.From(RenderOnRenderThread);
|
||||||
_disposeCallable = Callable.From(DisposeOnRenderThread);
|
_disposeCallable = Callable.From(DisposeOnRenderThread);
|
||||||
}
|
}
|
||||||
|
|
@ -277,6 +281,72 @@ public partial class HbGpuCanvas : Control
|
||||||
color.R, color.G, color.B, color.A);
|
color.R, color.G, color.B, color.A);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DrawChevron(float cx, float cy, float sizePx, float angleRad, Color color)
|
||||||
|
{
|
||||||
|
CachedBlob blob = HbGpuVectorShapes.GetChevronTriangle(_blobCache);
|
||||||
|
float s = sizePx * 0.001f;
|
||||||
|
float cos = MathF.Cos(angleRad);
|
||||||
|
float sin = MathF.Sin(angleRad);
|
||||||
|
_writer.DrawBlob(
|
||||||
|
blob, cx, cy,
|
||||||
|
-sin * s, cos * s,
|
||||||
|
cos * s, sin * s,
|
||||||
|
0f, 0f,
|
||||||
|
color.R, color.G, color.B, color.A);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DrawDiamond(float cx, float cy, float radiusPx, Color color,
|
||||||
|
uint clipMinPacked = 0, uint clipMaxPacked = HbGpuQuadInstance.Unclipped)
|
||||||
|
{
|
||||||
|
CachedBlob blob = HbGpuVectorShapes.GetDiamondBlip(_blobCache);
|
||||||
|
float s = radiusPx * 0.002f;
|
||||||
|
_writer.DrawBlob(
|
||||||
|
blob, cx, cy,
|
||||||
|
s, 0f, 0f, -s,
|
||||||
|
0f, 0f,
|
||||||
|
color.R, color.G, color.B, color.A,
|
||||||
|
stemDarken: false, clipMinPacked, clipMaxPacked);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DrawRectOutline(float x, float y, float w, float h, float thicknessPx, Color color,
|
||||||
|
uint clipMinPacked = 0, uint clipMaxPacked = HbGpuQuadInstance.Unclipped)
|
||||||
|
{
|
||||||
|
if (w <= 0f || h <= 0f || thicknessPx <= 0f)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
float t = thicknessPx;
|
||||||
|
DrawRectFilled(x, y, w, t, color, clipMinPacked, clipMaxPacked);
|
||||||
|
DrawRectFilled(x, y + h - t, w, t, color, clipMinPacked, clipMaxPacked);
|
||||||
|
DrawRectFilled(x, y + t, t, MathF.Max(0f, h - 2f * t), color, clipMinPacked, clipMaxPacked);
|
||||||
|
DrawRectFilled(x + w - t, y + t, t, MathF.Max(0f, h - 2f * t), color, clipMinPacked, clipMaxPacked);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DrawPanelFrame(Rect2 rect, Color bgCol, Color borderCol, Color accentCol,
|
||||||
|
float cornerLen = 12f, float borderPx = 1.5f, bool drawBg = true)
|
||||||
|
{
|
||||||
|
float x = rect.Position.X;
|
||||||
|
float y = rect.Position.Y;
|
||||||
|
float w = rect.Size.X;
|
||||||
|
float h = rect.Size.Y;
|
||||||
|
if (w < 2f || h < 2f)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (drawBg)
|
||||||
|
{
|
||||||
|
DrawRectFilled(x, y, w, h, bgCol);
|
||||||
|
}
|
||||||
|
DrawRectOutline(x, y, w, h, borderPx, borderCol);
|
||||||
|
|
||||||
|
float arm = MathF.Min(cornerLen, MathF.Min(w, h) * 0.4f);
|
||||||
|
float cThick = MathF.Max(borderPx + 0.5f, 2.0f);
|
||||||
|
DrawTargetBracketCorner(x, y, arm, cThick, 0, accentCol);
|
||||||
|
DrawTargetBracketCorner(x + w, y, arm, cThick, 1, accentCol);
|
||||||
|
DrawTargetBracketCorner(x + w, y + h, arm, cThick, 2, accentCol);
|
||||||
|
DrawTargetBracketCorner(x, y + h, arm, cThick, 3, accentCol);
|
||||||
|
}
|
||||||
|
|
||||||
public void DrawArcStrokeDynamic(float cx, float cy, float radiusPx, float strokePx, float startRadScreen, float endRadScreen, Color color)
|
public void DrawArcStrokeDynamic(float cx, float cy, float radiusPx, float strokePx, float startRadScreen, float endRadScreen, Color color)
|
||||||
{
|
{
|
||||||
if (radiusPx <= 0f || strokePx <= 0f)
|
if (radiusPx <= 0f || strokePx <= 0f)
|
||||||
|
|
@ -314,6 +384,11 @@ public partial class HbGpuCanvas : Control
|
||||||
{
|
{
|
||||||
Array.Copy(_writer.RawBuffer, 0, _stagedQuads, 0, count);
|
Array.Copy(_writer.RawBuffer, 0, _stagedQuads, 0, count);
|
||||||
}
|
}
|
||||||
|
if (_atlas.PendingChunkCount > 0)
|
||||||
|
{
|
||||||
|
_atlas.DrainToMirror(_stagedAtlasMirror);
|
||||||
|
_stagedAtlasDirty = true;
|
||||||
|
}
|
||||||
_stagedQuadCount = count;
|
_stagedQuadCount = count;
|
||||||
_stagedLogicalW = logicalW;
|
_stagedLogicalW = logicalW;
|
||||||
_stagedLogicalH = logicalH;
|
_stagedLogicalH = logicalH;
|
||||||
|
|
@ -367,9 +442,6 @@ public partial class HbGpuCanvas : Control
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int quadCount;
|
|
||||||
float logicalW, logicalH;
|
|
||||||
int physW, physH;
|
|
||||||
lock (_syncLock)
|
lock (_syncLock)
|
||||||
{
|
{
|
||||||
if (!_hasStagedFrame)
|
if (!_hasStagedFrame)
|
||||||
|
|
@ -377,12 +449,17 @@ public partial class HbGpuCanvas : Control
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_hasStagedFrame = false;
|
_hasStagedFrame = false;
|
||||||
quadCount = _stagedQuadCount;
|
bool atlasDirty = _stagedAtlasDirty;
|
||||||
logicalW = _stagedLogicalW;
|
_stagedAtlasDirty = false;
|
||||||
logicalH = _stagedLogicalH;
|
_backend.RenderFrame(
|
||||||
physW = _stagedPhysW;
|
_stagedQuads,
|
||||||
physH = _stagedPhysH;
|
_stagedQuadCount,
|
||||||
_backend.RenderFrame(_stagedQuads, quadCount, logicalW, logicalH, physW, physH);
|
_stagedAtlasMirror,
|
||||||
|
atlasDirty,
|
||||||
|
_stagedLogicalW,
|
||||||
|
_stagedLogicalH,
|
||||||
|
_stagedPhysW,
|
||||||
|
_stagedPhysH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -429,6 +506,17 @@ public partial class HbGpuCanvas : Control
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _ExitTree()
|
public override void _ExitTree()
|
||||||
|
{
|
||||||
|
ReleaseResources(disposing: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
ReleaseResources(disposing);
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ReleaseResources(bool disposing)
|
||||||
{
|
{
|
||||||
if (_disposed)
|
if (_disposed)
|
||||||
{
|
{
|
||||||
|
|
@ -436,15 +524,18 @@ public partial class HbGpuCanvas : Control
|
||||||
}
|
}
|
||||||
_disposed = true;
|
_disposed = true;
|
||||||
|
|
||||||
if (_outputTexRd is not null)
|
if (disposing)
|
||||||
{
|
{
|
||||||
_outputTexRd.TextureRdRid = new Rid();
|
if (_outputTexRd is not null)
|
||||||
}
|
{
|
||||||
|
_outputTexRd.TextureRdRid = new Rid();
|
||||||
|
}
|
||||||
|
|
||||||
if (_backend is not null && RenderingServer.GetRenderingDevice() is not null)
|
if (_backend is not null && RenderingServer.GetRenderingDevice() is not null)
|
||||||
{
|
{
|
||||||
RenderingServer.CallOnRenderThread(_disposeCallable);
|
RenderingServer.CallOnRenderThread(_disposeCallable);
|
||||||
RenderingServer.ForceSync();
|
RenderingServer.ForceSync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_fontCache.Dispose();
|
_fontCache.Dispose();
|
||||||
|
|
@ -453,9 +544,7 @@ public partial class HbGpuCanvas : Control
|
||||||
private sealed class HbGpuVulkanBackend
|
private sealed class HbGpuVulkanBackend
|
||||||
{
|
{
|
||||||
private readonly Texture2Drd _outputTexRd;
|
private readonly Texture2Drd _outputTexRd;
|
||||||
private readonly HbGpuAtlasAllocator _atlas;
|
|
||||||
|
|
||||||
private readonly byte[] _atlasMirrorBytes = new byte[HbGpuAtlasAllocator.TotalBytes];
|
|
||||||
private readonly byte[] _quadUploadBytes = new byte[HbGpuCommandWriter.MaxQuads * 80];
|
private readonly byte[] _quadUploadBytes = new byte[HbGpuCommandWriter.MaxQuads * 80];
|
||||||
private readonly byte[] _pushConstantBytes = new byte[PushConstantBytes];
|
private readonly byte[] _pushConstantBytes = new byte[PushConstantBytes];
|
||||||
private static readonly Color[] ClearColors = { new Color(0f, 0f, 0f, 0f) };
|
private static readonly Color[] ClearColors = { new Color(0f, 0f, 0f, 0f) };
|
||||||
|
|
@ -466,7 +555,8 @@ public partial class HbGpuCanvas : Control
|
||||||
|
|
||||||
private Rid _shaderRid;
|
private Rid _shaderRid;
|
||||||
private Rid _pipelineRid;
|
private Rid _pipelineRid;
|
||||||
private Rid _atlasBufRid;
|
private Rid _nearestSamplerRid;
|
||||||
|
private Rid _atlasTexRid;
|
||||||
private Rid _quadSsboRid;
|
private Rid _quadSsboRid;
|
||||||
private Rid _uniformSetRid;
|
private Rid _uniformSetRid;
|
||||||
private Rid _colorTexRid;
|
private Rid _colorTexRid;
|
||||||
|
|
@ -481,15 +571,16 @@ public partial class HbGpuCanvas : Control
|
||||||
public double LastHbGpuMs { get; private set; }
|
public double LastHbGpuMs { get; private set; }
|
||||||
public int LastDrawCallCount { get; private set; }
|
public int LastDrawCallCount { get; private set; }
|
||||||
|
|
||||||
public HbGpuVulkanBackend(Texture2Drd outputTexRd, HbGpuAtlasAllocator atlas)
|
public HbGpuVulkanBackend(Texture2Drd outputTexRd)
|
||||||
{
|
{
|
||||||
_outputTexRd = outputTexRd;
|
_outputTexRd = outputTexRd;
|
||||||
_atlas = atlas;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RenderFrame(
|
public void RenderFrame(
|
||||||
HbGpuQuadInstance[] quads,
|
HbGpuQuadInstance[] quads,
|
||||||
int quadCount,
|
int quadCount,
|
||||||
|
byte[] atlasMirrorBytes,
|
||||||
|
bool atlasDirty,
|
||||||
float logicalW,
|
float logicalW,
|
||||||
float logicalH,
|
float logicalH,
|
||||||
int physW,
|
int physW,
|
||||||
|
|
@ -506,15 +597,9 @@ public partial class HbGpuCanvas : Control
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool atlasDirty = _atlas.PendingChunkCount > 0;
|
|
||||||
if (atlasDirty)
|
|
||||||
{
|
|
||||||
_atlas.DrainToMirror(_atlasMirrorBytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_initialized)
|
if (!_initialized)
|
||||||
{
|
{
|
||||||
if (!TryInitialize(rd, physW, physH))
|
if (!TryInitialize(rd, atlasMirrorBytes, physW, physH))
|
||||||
{
|
{
|
||||||
_failed = true;
|
_failed = true;
|
||||||
return;
|
return;
|
||||||
|
|
@ -524,7 +609,7 @@ public partial class HbGpuCanvas : Control
|
||||||
{
|
{
|
||||||
if (atlasDirty)
|
if (atlasDirty)
|
||||||
{
|
{
|
||||||
RebuildAtlasBufferAndUniformSet(rd);
|
rd.TextureUpdate(_atlasTexRid, 0, atlasMirrorBytes);
|
||||||
}
|
}
|
||||||
if (physW != _fbWidth || physH != _fbHeight)
|
if (physW != _fbWidth || physH != _fbHeight)
|
||||||
{
|
{
|
||||||
|
|
@ -590,30 +675,43 @@ public partial class HbGpuCanvas : Control
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RebuildAtlasBufferAndUniformSet(RenderingDevice rd)
|
private void CreateAtlasAndUniformSet(RenderingDevice rd, byte[] initialAtlasBytes)
|
||||||
{
|
{
|
||||||
if (_uniformSetRid.IsValid)
|
var nearestState = new RDSamplerState
|
||||||
{
|
{
|
||||||
rd.FreeRid(_uniformSetRid);
|
MinFilter = RenderingDevice.SamplerFilter.Nearest,
|
||||||
_uniformSetRid = new Rid();
|
MagFilter = RenderingDevice.SamplerFilter.Nearest,
|
||||||
}
|
RepeatU = RenderingDevice.SamplerRepeatMode.ClampToEdge,
|
||||||
if (_atlasBufRid.IsValid)
|
RepeatV = RenderingDevice.SamplerRepeatMode.ClampToEdge,
|
||||||
{
|
RepeatW = RenderingDevice.SamplerRepeatMode.ClampToEdge
|
||||||
rd.FreeRid(_atlasBufRid);
|
};
|
||||||
_atlasBufRid = new Rid();
|
_nearestSamplerRid = rd.SamplerCreate(nearestState);
|
||||||
}
|
|
||||||
|
|
||||||
_atlasBufRid = rd.TextureBufferCreate(
|
var atlasFmt = new RDTextureFormat
|
||||||
HbGpuAtlasAllocator.TotalTexels,
|
{
|
||||||
RenderingDevice.DataFormat.R16G16B16A16Sint,
|
TextureType = RenderingDevice.TextureType.Type2D,
|
||||||
_atlasMirrorBytes);
|
Format = RenderingDevice.DataFormat.R16G16B16A16Sint,
|
||||||
|
Width = AtlasTexWidth,
|
||||||
|
Height = AtlasTexHeight,
|
||||||
|
Depth = 1,
|
||||||
|
ArrayLayers = 1,
|
||||||
|
Mipmaps = 1,
|
||||||
|
Samples = RenderingDevice.TextureSamples.Samples1,
|
||||||
|
UsageBits = RenderingDevice.TextureUsageBits.SamplingBit
|
||||||
|
| RenderingDevice.TextureUsageBits.CanUpdateBit
|
||||||
|
};
|
||||||
|
_atlasTexRid = rd.TextureCreate(
|
||||||
|
atlasFmt,
|
||||||
|
new RDTextureView(),
|
||||||
|
new Godot.Collections.Array<byte[]> { initialAtlasBytes });
|
||||||
|
|
||||||
var u0 = new RDUniform
|
var u0 = new RDUniform
|
||||||
{
|
{
|
||||||
UniformType = RenderingDevice.UniformType.TextureBuffer,
|
UniformType = RenderingDevice.UniformType.SamplerWithTexture,
|
||||||
Binding = 0
|
Binding = 0
|
||||||
};
|
};
|
||||||
u0.AddId(_atlasBufRid);
|
u0.AddId(_nearestSamplerRid);
|
||||||
|
u0.AddId(_atlasTexRid);
|
||||||
|
|
||||||
var u1 = new RDUniform
|
var u1 = new RDUniform
|
||||||
{
|
{
|
||||||
|
|
@ -660,7 +758,7 @@ public partial class HbGpuCanvas : Control
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool TryInitialize(RenderingDevice rd, int physW, int physH)
|
private bool TryInitialize(RenderingDevice rd, byte[] initialAtlasBytes, int physW, int physH)
|
||||||
{
|
{
|
||||||
_rd = rd;
|
_rd = rd;
|
||||||
|
|
||||||
|
|
@ -694,7 +792,7 @@ public partial class HbGpuCanvas : Control
|
||||||
}
|
}
|
||||||
|
|
||||||
_quadSsboRid = rd.StorageBufferCreate((uint)(HbGpuCommandWriter.MaxQuads * 80));
|
_quadSsboRid = rd.StorageBufferCreate((uint)(HbGpuCommandWriter.MaxQuads * 80));
|
||||||
RebuildAtlasBufferAndUniformSet(rd);
|
CreateAtlasAndUniformSet(rd, initialAtlasBytes);
|
||||||
|
|
||||||
RecreateRenderTarget(rd, physW, physH);
|
RecreateRenderTarget(rd, physW, physH);
|
||||||
|
|
||||||
|
|
@ -805,7 +903,8 @@ public partial class HbGpuCanvas : Control
|
||||||
if (_colorTexRid.IsValid) { _rd.FreeRid(_colorTexRid); _colorTexRid = new Rid(); }
|
if (_colorTexRid.IsValid) { _rd.FreeRid(_colorTexRid); _colorTexRid = new Rid(); }
|
||||||
if (_uniformSetRid.IsValid) { _rd.FreeRid(_uniformSetRid); _uniformSetRid = new Rid(); }
|
if (_uniformSetRid.IsValid) { _rd.FreeRid(_uniformSetRid); _uniformSetRid = new Rid(); }
|
||||||
if (_quadSsboRid.IsValid) { _rd.FreeRid(_quadSsboRid); _quadSsboRid = new Rid(); }
|
if (_quadSsboRid.IsValid) { _rd.FreeRid(_quadSsboRid); _quadSsboRid = new Rid(); }
|
||||||
if (_atlasBufRid.IsValid) { _rd.FreeRid(_atlasBufRid); _atlasBufRid = new Rid(); }
|
if (_atlasTexRid.IsValid) { _rd.FreeRid(_atlasTexRid); _atlasTexRid = new Rid(); }
|
||||||
|
if (_nearestSamplerRid.IsValid) { _rd.FreeRid(_nearestSamplerRid); _nearestSamplerRid = new Rid(); }
|
||||||
if (_pipelineRid.IsValid) { _rd.FreeRid(_pipelineRid); _pipelineRid = new Rid(); }
|
if (_pipelineRid.IsValid) { _rd.FreeRid(_pipelineRid); _pipelineRid = new Rid(); }
|
||||||
if (_shaderRid.IsValid) { _rd.FreeRid(_shaderRid); _shaderRid = new Rid(); }
|
if (_shaderRid.IsValid) { _rd.FreeRid(_shaderRid); _shaderRid = new Rid(); }
|
||||||
|
|
||||||
|
|
@ -886,10 +985,20 @@ void main() {{
|
||||||
{
|
{
|
||||||
string sharedFrag = HbGpuNative.GetShaderSource(HbGpuShaderStage.Fragment, HbGpuShaderKind.Shared);
|
string sharedFrag = HbGpuNative.GetShaderSource(HbGpuShaderStage.Fragment, HbGpuShaderKind.Shared);
|
||||||
string drawFrag = HbGpuNative.GetShaderSource(HbGpuShaderStage.Fragment, HbGpuShaderKind.Draw);
|
string drawFrag = HbGpuNative.GetShaderSource(HbGpuShaderStage.Fragment, HbGpuShaderKind.Draw);
|
||||||
|
const string oldAtlasDecl = "uniform highp isampler2D hb_gpu_atlas;";
|
||||||
|
const string oldWidthDecl = "uniform int hb_gpu_atlas_width;";
|
||||||
|
if (!sharedFrag.Contains(oldAtlasDecl, StringComparison.Ordinal) ||
|
||||||
|
!sharedFrag.Contains(oldWidthDecl, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Unexpected hb-gpu-fragment.glsl HB_GPU_ATLAS_2D uniform layout.");
|
||||||
|
}
|
||||||
|
sharedFrag = sharedFrag
|
||||||
|
.Replace(oldAtlasDecl, "layout(set = 0, binding = 0) uniform highp isampler2D hb_gpu_atlas;", StringComparison.Ordinal)
|
||||||
|
.Replace(oldWidthDecl, $"const int hb_gpu_atlas_width = {AtlasTexWidth};", StringComparison.Ordinal);
|
||||||
|
|
||||||
return $@"#version 450
|
return $@"#version 450
|
||||||
#define uniform layout(set = 0, binding = 0) uniform
|
#define HB_GPU_ATLAS_2D
|
||||||
{sharedFrag}
|
{sharedFrag}
|
||||||
#undef uniform
|
|
||||||
{drawFrag}
|
{drawFrag}
|
||||||
|
|
||||||
layout(push_constant, std430) uniform Push {{
|
layout(push_constant, std430) uniform Push {{
|
||||||
|
|
|
||||||
4104
client/Hud.cs
4104
client/Hud.cs
File diff suppressed because it is too large
Load diff
|
|
@ -2,6 +2,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Godot;
|
using Godot;
|
||||||
using RustToDust.Core;
|
using RustToDust.Core;
|
||||||
|
using RustToDust.HbGpu;
|
||||||
|
|
||||||
namespace RustToDust.Client;
|
namespace RustToDust.Client;
|
||||||
|
|
||||||
|
|
@ -38,8 +39,14 @@ public partial class InventoryGridControl : Control
|
||||||
private static Shader? _sharedShader;
|
private static Shader? _sharedShader;
|
||||||
|
|
||||||
private readonly TextureRect _gridSurface;
|
private readonly TextureRect _gridSurface;
|
||||||
private readonly LabelsOverlay _labelsOverlay;
|
|
||||||
private readonly ShaderMaterial _material;
|
private readonly ShaderMaterial _material;
|
||||||
|
private HbGpuCanvas? _standaloneCanvas;
|
||||||
|
|
||||||
|
private readonly Dictionary<string, string> _lastEmittedTags = new(StringComparer.Ordinal);
|
||||||
|
private readonly char[] _tagScratch = new char[32];
|
||||||
|
private int _overlayEmitCount;
|
||||||
|
private float _standaloneTime;
|
||||||
|
private bool _standaloneDirty = true;
|
||||||
|
|
||||||
private Image? _dataImage;
|
private Image? _dataImage;
|
||||||
private ImageTexture? _dataTex;
|
private ImageTexture? _dataTex;
|
||||||
|
|
@ -83,17 +90,10 @@ public partial class InventoryGridControl : Control
|
||||||
_gridSurface.SetAnchorsPreset(LayoutPreset.FullRect);
|
_gridSurface.SetAnchorsPreset(LayoutPreset.FullRect);
|
||||||
AddChild(_gridSurface);
|
AddChild(_gridSurface);
|
||||||
|
|
||||||
_labelsOverlay = new LabelsOverlay(this)
|
|
||||||
{
|
|
||||||
Name = "GridLabelsOverlay",
|
|
||||||
MouseFilter = MouseFilterEnum.Ignore
|
|
||||||
};
|
|
||||||
_labelsOverlay.SetAnchorsPreset(LayoutPreset.FullRect);
|
|
||||||
AddChild(_labelsOverlay);
|
|
||||||
|
|
||||||
MouseExited += OnMouseExited;
|
MouseExited += OnMouseExited;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ExternalHbGpuOwner { get; set; }
|
||||||
public ShaderMaterial ShaderMaterial => _material;
|
public ShaderMaterial ShaderMaterial => _material;
|
||||||
public Control ShaderSurface => _gridSurface;
|
public Control ShaderSurface => _gridSurface;
|
||||||
public ChassisGrid? Grid => _grid;
|
public ChassisGrid? Grid => _grid;
|
||||||
|
|
@ -103,9 +103,24 @@ public partial class InventoryGridControl : Control
|
||||||
? _hardpointLookup[c.X, c.Y]
|
? _hardpointLookup[c.X, c.Y]
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
internal int LabelsDrawCount => _labelsOverlay.DrawCount;
|
internal int OverlayEmitCount => _overlayEmitCount;
|
||||||
internal string? GetLastDrawnLabel(string hardpointId) =>
|
internal HbGpuCanvas? StandaloneCanvas => _standaloneCanvas;
|
||||||
_labelsOverlay.LastDrawnTags.TryGetValue(hardpointId, out string? tag) ? tag : null;
|
internal string? GetLastEmittedLabel(string hardpointId) =>
|
||||||
|
_lastEmittedTags.TryGetValue(hardpointId, out string? tag) ? tag : null;
|
||||||
|
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
if (!ExternalHbGpuOwner && _standaloneCanvas is null)
|
||||||
|
{
|
||||||
|
_standaloneCanvas = new HbGpuCanvas
|
||||||
|
{
|
||||||
|
Name = "StandaloneHbGpuCanvas",
|
||||||
|
MouseFilter = MouseFilterEnum.Ignore
|
||||||
|
};
|
||||||
|
_standaloneCanvas.SetAnchorsPreset(LayoutPreset.FullRect);
|
||||||
|
AddChild(_standaloneCanvas);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public event Action<int, int>? CellClicked;
|
public event Action<int, int>? CellClicked;
|
||||||
public event Action<string>? HardpointClicked;
|
public event Action<string>? HardpointClicked;
|
||||||
|
|
@ -116,13 +131,14 @@ public partial class InventoryGridControl : Control
|
||||||
if (what == NotificationResized)
|
if (what == NotificationResized)
|
||||||
{
|
{
|
||||||
SyncRectUniform();
|
SyncRectUniform();
|
||||||
_labelsOverlay.QueueRedraw();
|
_standaloneDirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
float dt = (float)delta;
|
float dt = (float)delta;
|
||||||
|
_standaloneTime += MathF.Max(0f, dt);
|
||||||
|
|
||||||
bool anyPulse = false;
|
bool anyPulse = false;
|
||||||
for (int y = 0; y < _gridHeight; y++)
|
for (int y = 0; y < _gridHeight; y++)
|
||||||
|
|
@ -141,6 +157,19 @@ public partial class InventoryGridControl : Control
|
||||||
{
|
{
|
||||||
PackDataTexture(_grid);
|
PackDataTexture(_grid);
|
||||||
FlushTextures();
|
FlushTextures();
|
||||||
|
_standaloneDirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ExternalHbGpuOwner && _standaloneCanvas is not null && _grid is not null)
|
||||||
|
{
|
||||||
|
bool hasCompatiblePulse = _selectedCargoIndex >= 0 && _selectedCargoIndex < _grid.Cargo.Count;
|
||||||
|
if (_standaloneDirty || hasCompatiblePulse)
|
||||||
|
{
|
||||||
|
_standaloneDirty = false;
|
||||||
|
_standaloneCanvas.BeginFrame();
|
||||||
|
EmitHbGpuOverlay(_standaloneCanvas, Vector2.Zero, _standaloneTime);
|
||||||
|
_standaloneCanvas.EndFrameAndSubmit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -195,7 +224,7 @@ public partial class InventoryGridControl : Control
|
||||||
PackTempTexture(grid);
|
PackTempTexture(grid);
|
||||||
FlushTextures();
|
FlushTextures();
|
||||||
SyncRectUniform();
|
SyncRectUniform();
|
||||||
_labelsOverlay.QueueRedraw();
|
_standaloneDirty = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -224,7 +253,7 @@ public partial class InventoryGridControl : Control
|
||||||
}
|
}
|
||||||
if (dataChanged || tempChanged)
|
if (dataChanged || tempChanged)
|
||||||
{
|
{
|
||||||
_labelsOverlay.QueueRedraw();
|
_standaloneDirty = true;
|
||||||
FlushTextures();
|
FlushTextures();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -236,6 +265,7 @@ public partial class InventoryGridControl : Control
|
||||||
_hitPulse[x, y] = Math.Clamp(intensity, 0f, 1f);
|
_hitPulse[x, y] = Math.Clamp(intensity, 0f, 1f);
|
||||||
PackDataTexture(_grid);
|
PackDataTexture(_grid);
|
||||||
FlushTextures();
|
FlushTextures();
|
||||||
|
_standaloneDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TryGetCellAt(Vector2 localPos, out Vector2I cell)
|
public bool TryGetCellAt(Vector2 localPos, out Vector2I cell)
|
||||||
|
|
@ -282,6 +312,7 @@ public partial class InventoryGridControl : Control
|
||||||
{
|
{
|
||||||
PackDataTexture(_grid);
|
PackDataTexture(_grid);
|
||||||
FlushTextures();
|
FlushTextures();
|
||||||
|
_standaloneDirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -301,6 +332,7 @@ public partial class InventoryGridControl : Control
|
||||||
{
|
{
|
||||||
PackDataTexture(_grid);
|
PackDataTexture(_grid);
|
||||||
FlushTextures();
|
FlushTextures();
|
||||||
|
_standaloneDirty = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -685,62 +717,218 @@ public partial class InventoryGridControl : Control
|
||||||
_ => ColTextLight
|
_ => ColTextLight
|
||||||
};
|
};
|
||||||
|
|
||||||
private sealed partial class LabelsOverlay : Control
|
/// <summary>
|
||||||
|
/// Emits crisp analytic vector cell borders, hardpoint L-brackets, compatibility pulses,
|
||||||
|
/// stripped X-marks, and Monaspace Krypton hardpoint labels into <paramref name="canvas"/>.
|
||||||
|
/// Zero GC allocations on steady-state calls.
|
||||||
|
/// </summary>
|
||||||
|
public void EmitHbGpuOverlay(HbGpuCanvas canvas, Vector2 originOffset, float timeSec)
|
||||||
{
|
{
|
||||||
private readonly InventoryGridControl _owner;
|
_overlayEmitCount++;
|
||||||
public int DrawCount { get; private set; }
|
var grid = _grid;
|
||||||
public readonly Dictionary<string, string> LastDrawnTags = new(StringComparer.Ordinal);
|
if (grid is null)
|
||||||
|
|
||||||
public LabelsOverlay(InventoryGridControl owner) => _owner = owner;
|
|
||||||
|
|
||||||
public override void _Draw()
|
|
||||||
{
|
{
|
||||||
DrawCount++;
|
return;
|
||||||
LastDrawnTags.Clear();
|
}
|
||||||
var grid = _owner._grid;
|
|
||||||
if (grid is null) return;
|
|
||||||
|
|
||||||
_owner.ComputeCellLayout(out float cellSize, out Vector2 origin);
|
ComputeCellLayout(out float cellSize, out Vector2 origin);
|
||||||
if (cellSize < 14f) return;
|
if (cellSize < 8f)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var spec = grid.Spec;
|
Vector2 basePos = originOffset + origin;
|
||||||
int fontSize = cellSize >= 38f ? 10 : 9;
|
var spec = grid.Spec;
|
||||||
float alpha = 0.95f;
|
ModuleSpec? selectedCargo = _selectedCargoIndex >= 0 && _selectedCargoIndex < grid.Cargo.Count
|
||||||
|
? grid.Cargo[_selectedCargoIndex]
|
||||||
|
: null;
|
||||||
|
HardpointSpec? hoveredHp = HoveredHardpoint;
|
||||||
|
Color flashCol = new(1.0f, 0.76f, 0.38f, 1.0f);
|
||||||
|
Color redAccent = new(0.92f, 0.26f, 0.18f, 1.0f);
|
||||||
|
|
||||||
for (int i = 0; i < spec.Hardpoints.Length; i++)
|
// 1. Hull cell outlines, internal subdivisions, and stripped-cell X marks
|
||||||
|
for (int y = 0; y < _gridHeight; y++)
|
||||||
|
{
|
||||||
|
for (int x = 0; x < _gridWidth; x++)
|
||||||
{
|
{
|
||||||
var hp = spec.Hardpoints[i];
|
if (!spec.IsActive(x, y))
|
||||||
var mounted = grid.GetMountedOn(hp.Id);
|
{
|
||||||
var pos = origin + new Vector2(hp.X * cellSize, hp.Y * cellSize);
|
continue;
|
||||||
float maxW = MathF.Max(12f, hp.Width * cellSize - 6f);
|
}
|
||||||
|
|
||||||
string tag = mounted is not null
|
float cx = basePos.X + x * cellSize;
|
||||||
? $"{mounted.Spec.Kind.ToString()[..1]}:{mounted.CurrentTemp:F0}°"
|
float cy = basePos.Y + y * cellSize;
|
||||||
: hp.Kind.ToString()[..3].ToUpperInvariant();
|
bool stripped = grid.Armor[x, y] <= 0.01f;
|
||||||
LastDrawnTags[hp.Id] = tag;
|
var hp = _hardpointLookup[x, y];
|
||||||
|
|
||||||
|
if (hp is null)
|
||||||
|
{
|
||||||
|
Color edgeCol = grid.BorderCells[x, y]
|
||||||
|
? ColBorderHull.Lerp(ColBorderRadiatorCell, 0.30f)
|
||||||
|
: ColBorderHull;
|
||||||
|
float pulse = Math.Clamp(_hitPulse[x, y], 0f, 1f);
|
||||||
|
bool isCellHovered = _hoveredCell is { } hc && hc.X == x && hc.Y == y;
|
||||||
|
if (stripped) edgeCol = edgeCol.Lerp(redAccent, 0.65f);
|
||||||
|
if (isCellHovered) edgeCol = edgeCol.Lerp(Colors.White, 0.35f);
|
||||||
|
if (pulse > 0.01f) edgeCol = edgeCol.Lerp(flashCol, pulse * 0.90f);
|
||||||
|
|
||||||
|
float inset = 1.5f;
|
||||||
|
float x0 = cx + inset;
|
||||||
|
float y0 = cy + inset;
|
||||||
|
float x1 = cx + cellSize - inset;
|
||||||
|
float y1 = cy + cellSize - inset;
|
||||||
|
|
||||||
|
// Outer hull perimeter edges get crisp medium lines; internal matched hull edges get faint hairlines
|
||||||
|
bool nMatch = spec.IsActive(x, y - 1) && _hardpointLookup[x, y - 1] is null;
|
||||||
|
bool sMatch = spec.IsActive(x, y + 1) && _hardpointLookup[x, y + 1] is null;
|
||||||
|
bool wMatch = spec.IsActive(x - 1, y) && _hardpointLookup[x - 1, y] is null;
|
||||||
|
bool eMatch = spec.IsActive(x + 1, y) && _hardpointLookup[x + 1, y] is null;
|
||||||
|
|
||||||
|
Color outerCol = new(edgeCol.R, edgeCol.G, edgeCol.B, isCellHovered ? 0.85f : 0.42f);
|
||||||
|
Color innerCol = new(edgeCol.R, edgeCol.G, edgeCol.B, 0.14f);
|
||||||
|
|
||||||
|
if (!nMatch) canvas.DrawLineSegment(x0, y0, x1, y0, 1.2f, outerCol);
|
||||||
|
if (!sMatch) canvas.DrawLineSegment(x0, y1, x1, y1, 1.2f, outerCol);
|
||||||
|
else canvas.DrawLineSegment(cx + 2f, cy + cellSize, cx + cellSize - 2f, cy + cellSize, 0.9f, innerCol);
|
||||||
|
if (!wMatch) canvas.DrawLineSegment(x0, y0, x0, y1, 1.2f, outerCol);
|
||||||
|
if (!eMatch) canvas.DrawLineSegment(x1, y0, x1, y1, 1.2f, outerCol);
|
||||||
|
else canvas.DrawLineSegment(cx + cellSize, cy + 2f, cx + cellSize, cy + cellSize - 2f, 0.9f, innerCol);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stripped)
|
||||||
|
{
|
||||||
|
float pad = MathF.Max(4.5f, cellSize * 0.18f);
|
||||||
|
Color xCol = new(0.95f, 0.28f, 0.20f, 0.78f);
|
||||||
|
canvas.DrawLineSegment(cx + pad, cy + pad, cx + cellSize - pad, cy + cellSize - pad, 1.5f, xCol);
|
||||||
|
canvas.DrawLineSegment(cx + cellSize - pad, cy + pad, cx + pad, cy + cellSize - pad, 1.5f, xCol);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Contiguous hardpoint borders, L-brackets, and Krypton tags
|
||||||
|
float fontSize = cellSize >= 38f ? 10.5f : 9.2f;
|
||||||
|
float compatPulse = 0.72f + 0.28f * MathF.Sin(timeSec * 6.5f);
|
||||||
|
|
||||||
|
for (int i = 0; i < spec.Hardpoints.Length; i++)
|
||||||
|
{
|
||||||
|
var hp = spec.Hardpoints[i];
|
||||||
|
var mounted = grid.GetMountedOn(hp.Id);
|
||||||
|
float hx = basePos.X + hp.X * cellSize;
|
||||||
|
float hy = basePos.Y + hp.Y * cellSize;
|
||||||
|
float hw = hp.Width * cellSize;
|
||||||
|
float hh = hp.Height * cellSize;
|
||||||
|
|
||||||
|
bool strippedHp = !grid.IsHardpointOperational(hp);
|
||||||
|
bool isCompatible = selectedCargo is not null && ChassisGrid.CanFit(hp, selectedCargo);
|
||||||
|
bool isHovered = hoveredHp is not null && ReferenceEquals(hp, hoveredHp);
|
||||||
|
|
||||||
|
float maxPulse = 0f;
|
||||||
|
for (int dy = 0; dy < hp.Height; dy++)
|
||||||
|
{
|
||||||
|
for (int dx = 0; dx < hp.Width; dx++)
|
||||||
|
{
|
||||||
|
int cx = hp.X + dx;
|
||||||
|
int cy = hp.Y + dy;
|
||||||
|
if (cx >= 0 && cy >= 0 && cx < _gridWidth && cy < _gridHeight)
|
||||||
|
{
|
||||||
|
maxPulse = MathF.Max(maxPulse, _hitPulse[cx, cy]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Color accent;
|
||||||
|
if (isCompatible)
|
||||||
|
{
|
||||||
|
accent = ColGold;
|
||||||
|
}
|
||||||
|
else if (mounted is { Spec.IsImperial: true })
|
||||||
|
{
|
||||||
|
accent = ColGold;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
accent = KindColor(hp.Kind);
|
||||||
|
if (mounted is null)
|
||||||
|
{
|
||||||
|
accent = accent.Lerp(ColBorderHull, 0.45f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strippedHp) accent = accent.Lerp(redAccent, 0.70f);
|
||||||
|
if (isCompatible) accent = accent.Lerp(new Color(0.96f, 0.82f, 0.30f, 1f), compatPulse);
|
||||||
|
if (isHovered) accent = accent.Lerp(Colors.White, 0.35f);
|
||||||
|
if (maxPulse > 0.01f) accent = accent.Lerp(flashCol, maxPulse * 0.90f);
|
||||||
|
|
||||||
|
const float inset = 1.8f;
|
||||||
|
float rx = hx + inset;
|
||||||
|
float ry = hy + inset;
|
||||||
|
float rw = MathF.Max(2f, hw - inset * 2f);
|
||||||
|
float rh = MathF.Max(2f, hh - inset * 2f);
|
||||||
|
|
||||||
|
float ruleAlpha = isCompatible ? 0.68f : (isHovered ? 0.60f : 0.34f);
|
||||||
|
canvas.DrawRectOutline(rx, ry, rw, rh, isCompatible ? 1.5f : 1.0f, new Color(accent.R, accent.G, accent.B, ruleAlpha));
|
||||||
|
|
||||||
|
float arm = Math.Clamp(MathF.Min(rw, rh) * 0.28f, 4.5f, 12f);
|
||||||
|
float bracketThick = (isCompatible || isHovered) ? 2.4f : 1.8f;
|
||||||
|
Color bracketCol = new(accent.R, accent.G, accent.B, 0.96f);
|
||||||
|
canvas.DrawTargetBracketCorner(rx, ry, arm, bracketThick, 0, bracketCol);
|
||||||
|
canvas.DrawTargetBracketCorner(rx + rw, ry, arm, bracketThick, 1, bracketCol);
|
||||||
|
canvas.DrawTargetBracketCorner(rx + rw, ry + rh, arm, bracketThick, 2, bracketCol);
|
||||||
|
canvas.DrawTargetBracketCorner(rx, ry + rh, arm, bracketThick, 3, bracketCol);
|
||||||
|
|
||||||
|
if (cellSize >= 14f)
|
||||||
|
{
|
||||||
|
ReadOnlySpan<char> tagSpan = FormatHardpointTag(hp, mounted, _tagScratch);
|
||||||
|
if (!_lastEmittedTags.TryGetValue(hp.Id, out string? existingTag) || !tagSpan.SequenceEqual(existingTag))
|
||||||
|
{
|
||||||
|
_lastEmittedTags[hp.Id] = new string(tagSpan);
|
||||||
|
}
|
||||||
|
|
||||||
Color col = mounted is { Spec.IsImperial: true } ? ColGold : ColTextLight;
|
Color col = mounted is { Spec.IsImperial: true } ? ColGold : ColTextLight;
|
||||||
col.A = alpha;
|
col.A = 0.95f;
|
||||||
|
HbGpuCommandWriter.PackClipRect(hx + 2f, hy + 2f, hw - 4f, hh - 4f, out uint clipMin, out uint clipMax);
|
||||||
|
|
||||||
// Dark shadow for crisp legibility over bright thermal glow
|
float tx = hx + 5f;
|
||||||
DrawString(
|
float ty = hy + fontSize + 4.5f;
|
||||||
UiFonts.Regular,
|
canvas.DrawText(tagSpan, tx + 1f, ty + 1f, fontSize, new Color(0.04f, 0.05f, 0.04f, 0.90f),
|
||||||
pos + new Vector2(7f, fontSize + 6f),
|
wght: 550f, stemDarken: true, clipMinPacked: clipMin, clipMaxPacked: clipMax);
|
||||||
tag,
|
canvas.DrawText(tagSpan, tx, ty, fontSize, col,
|
||||||
HorizontalAlignment.Left,
|
wght: 550f, stemDarken: true, clipMinPacked: clipMin, clipMaxPacked: clipMax);
|
||||||
maxW - 2f,
|
|
||||||
fontSize,
|
|
||||||
new Color(0.04f, 0.05f, 0.04f, alpha * 0.9f));
|
|
||||||
|
|
||||||
DrawString(
|
|
||||||
UiFonts.Regular,
|
|
||||||
pos + new Vector2(6f, fontSize + 5f),
|
|
||||||
tag,
|
|
||||||
HorizontalAlignment.Left,
|
|
||||||
maxW - 2f,
|
|
||||||
fontSize,
|
|
||||||
col);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ReadOnlySpan<char> FormatHardpointTag(HardpointSpec hp, MountedModule? mounted, char[] buf)
|
||||||
|
{
|
||||||
|
if (mounted is null)
|
||||||
|
{
|
||||||
|
return hp.Kind switch
|
||||||
|
{
|
||||||
|
HardpointKind.Weapon => "WPN",
|
||||||
|
HardpointKind.Engine => "ENG",
|
||||||
|
HardpointKind.Radiator => "RAD",
|
||||||
|
HardpointKind.Armor => "ARM",
|
||||||
|
HardpointKind.Utility => "UTL",
|
||||||
|
_ => "MOD"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
buf[0] = mounted.Spec.Kind switch
|
||||||
|
{
|
||||||
|
HardpointKind.Weapon => 'W',
|
||||||
|
HardpointKind.Engine => 'E',
|
||||||
|
HardpointKind.Radiator => 'R',
|
||||||
|
HardpointKind.Armor => 'A',
|
||||||
|
HardpointKind.Utility => 'U',
|
||||||
|
_ => 'M'
|
||||||
|
};
|
||||||
|
buf[1] = ':';
|
||||||
|
int pos = 2;
|
||||||
|
if (mounted.CurrentTemp.TryFormat(buf.AsSpan(pos), out int written, "F0", System.Globalization.CultureInfo.InvariantCulture))
|
||||||
|
{
|
||||||
|
pos += written;
|
||||||
|
}
|
||||||
|
buf[pos++] = '°';
|
||||||
|
return buf.AsSpan(0, pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -311,6 +311,10 @@ public partial class Main : Node3D
|
||||||
{
|
{
|
||||||
_atmosphere.VolumetricEffect.ProfilingEnabled = true;
|
_atmosphere.VolumetricEffect.ProfilingEnabled = true;
|
||||||
}
|
}
|
||||||
|
if (_hud?.HbCanvas is not null)
|
||||||
|
{
|
||||||
|
_hud.HbCanvas.ProfilingEnabled = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (int.TryParse(System.Environment.GetEnvironmentVariable("RTD_AUTO_EXIT_FRAMES"), out int autoExitFrames) && autoExitFrames > 0)
|
else if (int.TryParse(System.Environment.GetEnvironmentVariable("RTD_AUTO_EXIT_FRAMES"), out int autoExitFrames) && autoExitFrames > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -1600,6 +1604,10 @@ public partial class Main : Node3D
|
||||||
double vpCpuMs = RenderingServer.ViewportGetMeasuredRenderTimeCpu(vpRid);
|
double vpCpuMs = RenderingServer.ViewportGetMeasuredRenderTimeCpu(vpRid);
|
||||||
GD.Print($"Cut10bGpuMs: total={volFx.LastTotalGpuMs:F3} flow={volFx.LastFlowGpuMs:F3} cull={volFx.LastCullGpuMs:F3} march={volFx.LastMarchGpuMs:F3} comp={volFx.LastCompGpuMs:F3} viewportGpuMs={vpGpuMs:F2} viewportCpuMs={vpCpuMs:F2}");
|
GD.Print($"Cut10bGpuMs: total={volFx.LastTotalGpuMs:F3} flow={volFx.LastFlowGpuMs:F3} cull={volFx.LastCullGpuMs:F3} march={volFx.LastMarchGpuMs:F3} comp={volFx.LastCompGpuMs:F3} viewportGpuMs={vpGpuMs:F2} viewportCpuMs={vpCpuMs:F2}");
|
||||||
}
|
}
|
||||||
|
if (_hud?.HbCanvas is { } hb)
|
||||||
|
{
|
||||||
|
GD.Print($"HbGpuHud: drawCalls={hb.LastDrawCallCount} quads={hb.LastQuadCount} gpuMs={hb.LastHbGpuMs:F4}");
|
||||||
|
}
|
||||||
if (_session is not null)
|
if (_session is not null)
|
||||||
{
|
{
|
||||||
var net = _session.ConnectionStatus;
|
var net = _session.ConnectionStatus;
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,13 @@ shader_type canvas_item;
|
||||||
render_mode blend_premul_alpha;
|
render_mode blend_premul_alpha;
|
||||||
|
|
||||||
// Port of Aetheria's UI/Inventory Grid shader to Godot 4 Forward+ Vulkan.
|
// Port of Aetheria's UI/Inventory Grid shader to Godot 4 Forward+ Vulkan.
|
||||||
// Evaluates analytical corner-folded texel boxes for hull/hardpoint silhouettes, L-brackets,
|
// Evaluates stateless interior cell fill: corner-folded texel masks, bilinear heat glow,
|
||||||
// hairline rules, direct bilinear heat glow, hit-pulse flash, and 45-degree fracture hatching.
|
// hit-pulse flash, and 45-degree fracture hatching. Crisp vector frames, L-brackets,
|
||||||
|
// stripped X-marks, and Krypton labels are rendered by HbGpuCanvas on top.
|
||||||
//
|
//
|
||||||
// data_tex (3W x H, filter_nearest):
|
// data_tex (3W x H, filter_nearest):
|
||||||
// 3x + 0 : cell/item fill & armor tint (RGBA)
|
// 3x + 0 : cell/item fill & armor tint (RGBA)
|
||||||
// 3x + 1 : border/bracket accent color (RGBA)
|
// 3x + 1 : reserved / accent tint
|
||||||
// 3x + 2 : R = 8-bit neighbor mismatch mask (N,E,S,W,NE,SE,SW,NW)
|
// 3x + 2 : R = 8-bit neighbor mismatch mask (N,E,S,W,NE,SE,SW,NW)
|
||||||
// G = flags (bit0=present, bit1=item, bit2=hover, bit3=damaged/stripped, bit4=compatible, bit5=border_radiator)
|
// G = flags (bit0=present, bit1=item, bit2=hover, bit3=damaged/stripped, bit4=compatible, bit5=border_radiator)
|
||||||
// B = reserved (0)
|
// B = reserved (0)
|
||||||
|
|
@ -23,17 +24,9 @@ uniform sampler2D temp_tex : filter_linear, repeat_disable;
|
||||||
uniform vec2 grid_size = vec2(4.0, 5.0);
|
uniform vec2 grid_size = vec2(4.0, 5.0);
|
||||||
uniform vec2 rect_size = vec2(180.0, 225.0);
|
uniform vec2 rect_size = vec2(180.0, 225.0);
|
||||||
|
|
||||||
// Look parameters in Aetheria texel units
|
|
||||||
uniform float icon_texel = 1.51515;
|
|
||||||
uniform float bg_texel = 1.0;
|
uniform float bg_texel = 1.0;
|
||||||
uniform float rule_inset = 1.5;
|
|
||||||
uniform float rule_width = 1.0;
|
|
||||||
uniform float arm_texels = 1.25;
|
|
||||||
uniform float fill_inset = 2.6;
|
uniform float fill_inset = 2.6;
|
||||||
uniform float softness = 1.0;
|
uniform float softness = 1.0;
|
||||||
uniform float rule_alpha = 0.34;
|
|
||||||
uniform float bracket_alpha = 1.0;
|
|
||||||
uniform float fill_alpha = 0.14;
|
|
||||||
|
|
||||||
const float FAR = 1000.0;
|
const float FAR = 1000.0;
|
||||||
|
|
||||||
|
|
@ -45,7 +38,7 @@ float box_profile(float x, float lo, float hi, float soft) {
|
||||||
return clamp(1.0 - outside / soft, 0.0, 1.0);
|
return clamp(1.0 - outside / soft, 0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
float eval_layer(vec2 p, float cell_px, float texel, uint mask, bool is_item, bool is_icon, float aa_px) {
|
float eval_bg_mask(vec2 p, float cell_px, float texel, uint mask, float aa_px) {
|
||||||
float t = min(texel, cell_px / 8.0);
|
float t = min(texel, cell_px / 8.0);
|
||||||
bool left = p.x < cell_px * 0.5;
|
bool left = p.x < cell_px * 0.5;
|
||||||
bool top = p.y >= cell_px * 0.5;
|
bool top = p.y >= cell_px * 0.5;
|
||||||
|
|
@ -69,36 +62,7 @@ float eval_layer(vec2 p, float cell_px, float texel, uint mask, bool is_item, bo
|
||||||
if (concave) {
|
if (concave) {
|
||||||
f -= box_profile(x, -FAR, fill_inset - 0.5, soft) * box_profile(y, -FAR, fill_inset - 0.5, soft);
|
f -= box_profile(x, -FAR, fill_inset - 0.5, soft) * box_profile(y, -FAR, fill_inset - 0.5, soft);
|
||||||
}
|
}
|
||||||
f = clamp(f, 0.0, 1.0);
|
return clamp(f, 0.0, 1.0);
|
||||||
if (!is_icon) {
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
|
|
||||||
float a = is_item ? fill_alpha * f : 0.0;
|
|
||||||
float ri = rule_inset;
|
|
||||||
float rlo = ri - (rule_width - 1.0) * 0.5;
|
|
||||||
float rhi = ri + (rule_width - 1.0) * 0.5;
|
|
||||||
float rx = box_profile(x, rlo, rhi, soft);
|
|
||||||
float ry = box_profile(y, rlo, rhi, soft);
|
|
||||||
float arms = arm_texels >= 1.0 ? 1.0 : 0.0;
|
|
||||||
|
|
||||||
if (v) {
|
|
||||||
a += rule_alpha * ry * (h ? box_profile(x, ri, FAR, soft) : 1.0);
|
|
||||||
}
|
|
||||||
if (h) {
|
|
||||||
a += rule_alpha * rx * (v ? box_profile(y, ri + 1.0, FAR, soft) : 1.0);
|
|
||||||
}
|
|
||||||
if (v && h) {
|
|
||||||
a += (bracket_alpha - rule_alpha) * (ry * box_profile(x, ri, ri + arm_texels, soft) + arms * rx * box_profile(y, ri + 1.0, ri + arm_texels, soft));
|
|
||||||
} else if (concave) {
|
|
||||||
a += bracket_alpha * (ry * box_profile(x, ri - arm_texels, ri, soft) + arms * rx * box_profile(y, ri - arm_texels, ri - 1.0, soft));
|
|
||||||
} else if (!v && !h) {
|
|
||||||
// Faint cell subdivision hairline across matched internal cell boundaries
|
|
||||||
float sub_x = box_profile(x, 0.0, 0.65, soft);
|
|
||||||
float sub_y = box_profile(y, 0.0, 0.65, soft);
|
|
||||||
a += 0.14 * max(sub_x, sub_y);
|
|
||||||
}
|
|
||||||
return clamp(a, 0.0, 1.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 thermal_ramp(float t) {
|
vec3 thermal_ramp(float t) {
|
||||||
|
|
@ -136,7 +100,6 @@ void fragment() {
|
||||||
float tex_w = safe_grid.x * 3.0;
|
float tex_w = safe_grid.x * 3.0;
|
||||||
float ty = (cellf.y + 0.5) / safe_grid.y;
|
float ty = (cellf.y + 0.5) / safe_grid.y;
|
||||||
vec4 cell_fill = textureLod(data_tex, vec2((cellf.x * 3.0 + 0.5) / tex_w, ty), 0.0);
|
vec4 cell_fill = textureLod(data_tex, vec2((cellf.x * 3.0 + 0.5) / tex_w, ty), 0.0);
|
||||||
vec4 border_accent = textureLod(data_tex, vec2((cellf.x * 3.0 + 1.5) / tex_w, ty), 0.0);
|
|
||||||
vec4 meta = textureLod(data_tex, vec2((cellf.x * 3.0 + 2.5) / tex_w, ty), 0.0);
|
vec4 meta = textureLod(data_tex, vec2((cellf.x * 3.0 + 2.5) / tex_w, ty), 0.0);
|
||||||
|
|
||||||
uint mask = uint(round(meta.r * 255.0));
|
uint mask = uint(round(meta.r * 255.0));
|
||||||
|
|
@ -146,7 +109,6 @@ void fragment() {
|
||||||
if ((flags & 1u) == 0u) {
|
if ((flags & 1u) == 0u) {
|
||||||
COLOR = vec4(0.0);
|
COLOR = vec4(0.0);
|
||||||
} else {
|
} else {
|
||||||
bool is_item = (flags & 2u) != 0u;
|
|
||||||
bool is_hover = (flags & 4u) != 0u;
|
bool is_hover = (flags & 4u) != 0u;
|
||||||
bool is_damaged = (flags & 8u) != 0u;
|
bool is_damaged = (flags & 8u) != 0u;
|
||||||
bool is_compatible = (flags & 16u) != 0u;
|
bool is_compatible = (flags & 16u) != 0u;
|
||||||
|
|
@ -155,8 +117,7 @@ void fragment() {
|
||||||
float plateau_stress = temp_sample.g;
|
float plateau_stress = temp_sample.g;
|
||||||
vec3 heat_col = thermal_ramp(norm_temp);
|
vec3 heat_col = thermal_ramp(norm_temp);
|
||||||
|
|
||||||
float a_bg = eval_layer(p, S, bg_texel, mask, false, false, aa_px) * cell_fill.a;
|
float a_bg = eval_bg_mask(p, S, bg_texel, mask, aa_px) * cell_fill.a;
|
||||||
float a_rules = eval_layer(p, S, icon_texel, mask, is_item, true, aa_px);
|
|
||||||
|
|
||||||
// Intact vs stripped (Armor == 0) interior fill with always-active subtle bilinear heat glow on hot cells
|
// Intact vs stripped (Armor == 0) interior fill with always-active subtle bilinear heat glow on hot cells
|
||||||
float hot_blend = smoothstep(0.05, 0.65, norm_temp) * 0.56;
|
float hot_blend = smoothstep(0.05, 0.65, norm_temp) * 0.56;
|
||||||
|
|
@ -174,6 +135,10 @@ void fragment() {
|
||||||
base_rgb += heat_col * (0.20 * norm_temp + 0.30 * overheat_glow);
|
base_rgb += heat_col * (0.20 * norm_temp + 0.30 * overheat_glow);
|
||||||
base_rgb = clamp(base_rgb, vec3(0.0), vec3(1.0));
|
base_rgb = clamp(base_rgb, vec3(0.0), vec3(1.0));
|
||||||
|
|
||||||
|
if (is_compatible) {
|
||||||
|
float pulse = 0.72 + 0.28 * sin(TIME * 6.5);
|
||||||
|
base_rgb = mix(base_rgb, vec3(0.96, 0.82, 0.30), 0.16 * pulse);
|
||||||
|
}
|
||||||
if (is_hover) {
|
if (is_hover) {
|
||||||
base_rgb = mix(base_rgb, vec3(0.95, 0.94, 0.88), 0.16);
|
base_rgb = mix(base_rgb, vec3(0.95, 0.94, 0.88), 0.16);
|
||||||
}
|
}
|
||||||
|
|
@ -182,27 +147,8 @@ void fragment() {
|
||||||
vec3 flash_col = vec3(1.0, 0.76, 0.38);
|
vec3 flash_col = vec3(1.0, 0.76, 0.38);
|
||||||
base_rgb = clamp(mix(base_rgb, flash_col, hit_pulse * 0.85), vec3(0.0), vec3(1.0));
|
base_rgb = clamp(mix(base_rgb, flash_col, hit_pulse * 0.85), vec3(0.0), vec3(1.0));
|
||||||
|
|
||||||
vec3 accent_rgb = border_accent.rgb;
|
float out_a = clamp(a_bg, 0.0, 1.0);
|
||||||
if (is_damaged) {
|
vec3 out_rgb = clamp(base_rgb, vec3(0.0), vec3(1.0)) * out_a;
|
||||||
accent_rgb = mix(accent_rgb, vec3(0.92, 0.26, 0.18), 0.70);
|
|
||||||
}
|
|
||||||
if (is_compatible) {
|
|
||||||
float pulse = 0.72 + 0.28 * sin(TIME * 6.5);
|
|
||||||
accent_rgb = mix(accent_rgb, vec3(0.96, 0.82, 0.30), pulse);
|
|
||||||
a_rules = clamp(a_rules * 1.35, 0.0, 1.0);
|
|
||||||
}
|
|
||||||
if (is_hover) {
|
|
||||||
accent_rgb = mix(accent_rgb, vec3(1.0), 0.35);
|
|
||||||
a_rules = clamp(a_rules * 1.25, 0.0, 1.0);
|
|
||||||
}
|
|
||||||
accent_rgb = clamp(mix(accent_rgb, flash_col, hit_pulse * 0.90), vec3(0.0), vec3(1.0));
|
|
||||||
|
|
||||||
float icon_alpha = clamp(a_rules * border_accent.a, 0.0, 1.0);
|
|
||||||
vec3 icon_rgb = clamp(accent_rgb, vec3(0.0), vec3(1.0));
|
|
||||||
|
|
||||||
float out_a = clamp(icon_alpha + a_bg * (1.0 - icon_alpha), 0.0, 1.0);
|
|
||||||
vec3 out_rgb = min(icon_rgb * icon_alpha + base_rgb * a_bg * (1.0 - icon_alpha), vec3(out_a));
|
|
||||||
out_rgb = max(out_rgb, vec3(0.0));
|
|
||||||
COLOR = vec4(out_rgb, out_a);
|
COLOR = vec4(out_rgb, out_a);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -287,15 +287,23 @@ public partial class Smoke : Node
|
||||||
var invShader = _main.Hud.Schematic.ShaderMaterial.Shader;
|
var invShader = _main.Hud.Schematic.ShaderMaterial.Shader;
|
||||||
Check(invShader is not null && !string.IsNullOrWhiteSpace(invShader.Code),
|
Check(invShader is not null && !string.IsNullOrWhiteSpace(invShader.Code),
|
||||||
"inventory_grid.gdshader failed to load");
|
"inventory_grid.gdshader failed to load");
|
||||||
|
Check(_main.Hud.HbCanvas is not null, "Expected Hud.HbCanvas to be initialized");
|
||||||
|
|
||||||
int chromeCount = 0;
|
// Warm up HUD HbGpuCanvas and verify steady-state Sync allocates zero managed bytes
|
||||||
foreach (var mat in _main.Hud.GetChromeMaterials())
|
_main.Hud.Sync(_main.Session);
|
||||||
|
_main.Hud.Sync(_main.Session);
|
||||||
|
_main.Hud.Sync(_main.Session);
|
||||||
|
Check(_main.Hud.HbCanvas!.LastQuadCount > 50,
|
||||||
|
$"Expected Hud.HbCanvas.LastQuadCount > 50 after Sync, got {_main.Hud.HbCanvas.LastQuadCount}");
|
||||||
|
long gcBefore = GC.GetAllocatedBytesForCurrentThread();
|
||||||
|
for (int i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
chromeCount++;
|
_main.Hud.Sync(_main.Session);
|
||||||
Check(mat.Shader is not null && !string.IsNullOrWhiteSpace(mat.Shader.Code),
|
|
||||||
$"panel_chrome.gdshader failed to load on HUD panel #{chromeCount}");
|
|
||||||
}
|
}
|
||||||
Check(chromeCount == 6, $"Expected 6 ChromePanel materials on HUD, got {chromeCount}");
|
long gcAfter = GC.GetAllocatedBytesForCurrentThread();
|
||||||
|
long gcDelta = gcAfter - gcBefore;
|
||||||
|
GD.Print($"SMOKE INFO: Steady-state Hud.Sync x16 managed allocs={gcDelta} B");
|
||||||
|
Check(gcDelta == 0, $"Expected 0 B managed allocations across steady-state Hud.Sync x16, got {gcDelta} B");
|
||||||
|
|
||||||
// Pack a real Ironclad chassis with mounted modules, thermal gradient, stripped cell, and active hit-pulse
|
// Pack a real Ironclad chassis with mounted modules, thermal gradient, stripped cell, and active hit-pulse
|
||||||
var testGrid = new ChassisGrid(Catalog.Ironclad);
|
var testGrid = new ChassisGrid(Catalog.Ironclad);
|
||||||
|
|
@ -488,7 +496,7 @@ public partial class Smoke : Node
|
||||||
Check(raptorHoleScanned > 1000, $"Expected > 1000 inactive hole pixels scanned on Raptor, got {raptorHoleScanned}");
|
Check(raptorHoleScanned > 1000, $"Expected > 1000 inactive hole pixels scanned on Raptor, got {raptorHoleScanned}");
|
||||||
Check(raptorHoleLit == 0, $"Expected 0 lit/opaque pixels in inactive Raptor cell holes, got {raptorHoleLit}");
|
Check(raptorHoleLit == 0, $"Expected 0 lit/opaque pixels in inactive Raptor cell holes, got {raptorHoleLit}");
|
||||||
|
|
||||||
// Finding 5 GPU check: LabelsOverlay redraws on temp-only change & compatibility highlights update when Cargo[0] swaps at unchanged index 0
|
// Cut 14b GPU check: HbGpuCanvas overlay re-emits on temp-only change & compatibility highlights update when Cargo[0] swaps at unchanged index 0
|
||||||
{
|
{
|
||||||
raptorGrid.Cargo.Clear();
|
raptorGrid.Cargo.Clear();
|
||||||
Check(raptorGrid.TryAddCargo(Catalog.Autocannon), "Expected Autocannon in Raptor Cargo[0]");
|
Check(raptorGrid.TryAddCargo(Catalog.Autocannon), "Expected Autocannon in Raptor Cargo[0]");
|
||||||
|
|
@ -496,8 +504,8 @@ public partial class Smoke : Node
|
||||||
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
||||||
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
||||||
|
|
||||||
int drawCountBeforeTemp = vpGrid.LabelsDrawCount;
|
int emitCountBeforeTemp = vpGrid.OverlayEmitCount;
|
||||||
string? tagBeforeTemp = vpGrid.GetLastDrawnLabel("hp.engine.chest");
|
string? tagBeforeTemp = vpGrid.GetLastEmittedLabel("hp.engine.chest");
|
||||||
var cargoImgWeapon = gridVp.GetTexture().GetImage();
|
var cargoImgWeapon = gridVp.GetTexture().GetImage();
|
||||||
|
|
||||||
// Temp-only change (no armor hit, no mount change)
|
// Temp-only change (no armor hit, no mount change)
|
||||||
|
|
@ -507,10 +515,10 @@ public partial class Smoke : Node
|
||||||
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
||||||
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
||||||
|
|
||||||
int drawCountAfterTemp = vpGrid.LabelsDrawCount;
|
int emitCountAfterTemp = vpGrid.OverlayEmitCount;
|
||||||
string? tagAfterTemp = vpGrid.GetLastDrawnLabel("hp.engine.chest");
|
string? tagAfterTemp = vpGrid.GetLastEmittedLabel("hp.engine.chest");
|
||||||
Check(drawCountAfterTemp > drawCountBeforeTemp,
|
Check(emitCountAfterTemp > emitCountBeforeTemp,
|
||||||
$"Expected LabelsOverlay to redraw on temp-only change ({drawCountBeforeTemp} -> {drawCountAfterTemp})");
|
$"Expected InventoryGridControl HbGpu overlay to re-emit on temp-only change ({emitCountBeforeTemp} -> {emitCountAfterTemp})");
|
||||||
Check(!string.Equals(tagBeforeTemp, tagAfterTemp, StringComparison.Ordinal),
|
Check(!string.Equals(tagBeforeTemp, tagAfterTemp, StringComparison.Ordinal),
|
||||||
$"Expected engine temp label text to update on temp-only change ('{tagBeforeTemp}' -> '{tagAfterTemp}')");
|
$"Expected engine temp label text to update on temp-only change ('{tagBeforeTemp}' -> '{tagAfterTemp}')");
|
||||||
|
|
||||||
|
|
@ -525,47 +533,31 @@ public partial class Smoke : Node
|
||||||
GD.Print($"SMOKE INFO: InventoryGrid Cargo[0] swap diff pixels={cargoDiff}, label '{tagBeforeTemp}'->'{tagAfterTemp}'");
|
GD.Print($"SMOKE INFO: InventoryGrid Cargo[0] swap diff pixels={cargoDiff}, label '{tagBeforeTemp}'->'{tagAfterTemp}'");
|
||||||
Check(cargoDiff > 50,
|
Check(cargoDiff > 50,
|
||||||
$"Expected Cargo[0] replacement at unchanged index 0 to update compatibility highlight pixels (>50), got {cargoDiff}");
|
$"Expected Cargo[0] replacement at unchanged index 0 to update compatibility highlight pixels (>50), got {cargoDiff}");
|
||||||
|
Check(vpGrid.StandaloneCanvas is { LastDrawCallCount: 1 },
|
||||||
|
$"Expected standalone InventoryGridControl HbGpuCanvas to render in 1 draw call, got {vpGrid.StandaloneCanvas?.LastDrawCallCount ?? -1}");
|
||||||
}
|
}
|
||||||
|
|
||||||
gridVp.QueueFree();
|
gridVp.QueueFree();
|
||||||
|
|
||||||
// GPU verification for panel_chrome.gdshader
|
// Cut 14b Vulkan single-draw-call verification on live Hud.HbCanvas
|
||||||
var chromeVp = new SubViewport
|
_main.Hud.Sync(_main.Session);
|
||||||
{
|
|
||||||
Size = new Vector2I(240, 120),
|
|
||||||
TransparentBg = true,
|
|
||||||
RenderTargetUpdateMode = SubViewport.UpdateMode.Always
|
|
||||||
};
|
|
||||||
var chromeShader = GD.Load<Shader>("res://panel_chrome.gdshader");
|
|
||||||
var chromeMat = new ShaderMaterial { Shader = chromeShader };
|
|
||||||
chromeMat.SetShaderParameter("rect_size", new Vector2(240f, 120f));
|
|
||||||
chromeMat.SetShaderParameter("accent_color", Color.FromHtml("#e08a4a"));
|
|
||||||
var chromeImgTex = Image.CreateEmpty(1, 1, false, Image.Format.Rgba8);
|
|
||||||
chromeImgTex.SetPixel(0, 0, Colors.White);
|
|
||||||
var chromeRect = new TextureRect
|
|
||||||
{
|
|
||||||
Texture = ImageTexture.CreateFromImage(chromeImgTex),
|
|
||||||
Size = new Vector2(240f, 120f),
|
|
||||||
ExpandMode = TextureRect.ExpandModeEnum.IgnoreSize,
|
|
||||||
StretchMode = TextureRect.StretchModeEnum.Scale,
|
|
||||||
Material = chromeMat
|
|
||||||
};
|
|
||||||
chromeVp.AddChild(chromeRect);
|
|
||||||
AddChild(chromeVp);
|
|
||||||
|
|
||||||
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
||||||
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
||||||
|
var hudHb = _main.Hud.HbCanvas;
|
||||||
var chromeImg = chromeVp.GetTexture().GetImage();
|
Check(hudHb.LastDrawCallCount == 1, $"Expected Hud.HbCanvas LastDrawCallCount == 1, got {hudHb.LastDrawCallCount}");
|
||||||
int chromeOpaque = CountNonZeroAlphaPixels(chromeImg, 0.08f);
|
Check(hudHb.TryReadbackRgba8(out byte[] hudRgba, out int hudW, out int hudH),
|
||||||
Color cornerPx = chromeImg.GetPixel(2, 2);
|
"Expected Hud.HbCanvas.TryReadbackRgba8 to succeed on Vulkan");
|
||||||
Color centerPx = chromeImg.GetPixel(120, 60);
|
int hudNonZero = 0;
|
||||||
GD.Print($"SMOKE INFO: panel_chrome GPU opaque={chromeOpaque}, corner={cornerPx}, center={centerPx}");
|
int hudPremulViol = 0;
|
||||||
Check(chromeOpaque > 10000, $"Expected > 10000 rendered pixels from panel_chrome.gdshader, got {chromeOpaque}");
|
for (int i = 0; i + 3 < hudRgba.Length; i += 4)
|
||||||
Check(cornerPx.R > centerPx.R + 0.25f,
|
{
|
||||||
$"Expected L-bracket corner pixel ({cornerPx}) to be accented brighter than panel center ({centerPx})");
|
byte r = hudRgba[i], g = hudRgba[i + 1], b = hudRgba[i + 2], a = hudRgba[i + 3];
|
||||||
|
if (a > 0) hudNonZero++;
|
||||||
chromeVp.QueueFree();
|
if (r > a || g > a || b > a) hudPremulViol++;
|
||||||
|
}
|
||||||
|
GD.Print($"SMOKE INFO: Hud.HbCanvas Vulkan {hudW}x{hudH} quads={hudHb.LastQuadCount}, drawCalls={hudHb.LastDrawCallCount}, nonZeroPx={hudNonZero}, premulViol={hudPremulViol}");
|
||||||
|
Check(hudNonZero > 4000, $"Expected > 4000 rendered pixels in Hud.HbCanvas, got {hudNonZero}");
|
||||||
|
Check(hudPremulViol == 0, $"Expected 0 premul violations in Hud.HbCanvas, got {hudPremulViol}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task MaybeCapturePreviewAsync(bool isHeadless)
|
private async Task MaybeCapturePreviewAsync(bool isHeadless)
|
||||||
|
|
@ -2216,9 +2208,8 @@ public partial class Smoke : Node
|
||||||
_main.Hud.SimulateCellHover(new Vector2I(pWeaponHpSpec.X, pWeaponHpSpec.Y), pWeaponHpSpec);
|
_main.Hud.SimulateCellHover(new Vector2I(pWeaponHpSpec.X, pWeaponHpSpec.Y), pWeaponHpSpec);
|
||||||
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
|
||||||
|
|
||||||
int chromeCount = 0;
|
Check(_main.Hud.HbCanvas.LastQuadCount > 50,
|
||||||
foreach (var _ in _main.Hud.GetChromeMaterials()) chromeCount++;
|
$"Expected Hud.HbCanvas.LastQuadCount > 50 in Garage mode, got {_main.Hud.HbCanvas.LastQuadCount}");
|
||||||
Check(chromeCount == 6, $"Expected 6 HUD chrome panels, got {chromeCount}");
|
|
||||||
Check(_main.Hud.HoverLabelText.Contains(sabotDream.ManufacturerLabel) && _main.Hud.HoverLabelText.Contains('\n'),
|
Check(_main.Hud.HoverLabelText.Contains(sabotDream.ManufacturerLabel) && _main.Hud.HoverLabelText.Contains('\n'),
|
||||||
$"Expected 2-line Borderlands hover tooltip with manufacturer badge, got: {_main.Hud.HoverLabelText}");
|
$"Expected 2-line Borderlands hover tooltip with manufacturer badge, got: {_main.Hud.HoverLabelText}");
|
||||||
Check(_main.Hud.GarageDetailsText.Contains(sabotDream.SummaryLine1) && _main.Hud.GarageDetailsText.Contains(sabotDream.SummaryLine2),
|
Check(_main.Hud.GarageDetailsText.Contains(sabotDream.SummaryLine1) && _main.Hud.GarageDetailsText.Contains(sabotDream.SummaryLine2),
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ public sealed unsafe class HbGpuBlobCache
|
||||||
private readonly Dictionary<GlyphBlobKey, CachedBlob> _glyphBlobs = new(512);
|
private readonly Dictionary<GlyphBlobKey, CachedBlob> _glyphBlobs = new(512);
|
||||||
private readonly Dictionary<VectorBlobKey, CachedBlob> _vectorBlobs = new(64);
|
private readonly Dictionary<VectorBlobKey, CachedBlob> _vectorBlobs = new(64);
|
||||||
private readonly short[] _scratchShorts = new short[ScratchShortsCapacity];
|
private readonly short[] _scratchShorts = new short[ScratchShortsCapacity];
|
||||||
|
private bool _persistentOverflowPending;
|
||||||
|
|
||||||
public HbGpuBlobCache(HbGpuAtlasAllocator atlas)
|
public HbGpuBlobCache(HbGpuAtlasAllocator atlas)
|
||||||
{
|
{
|
||||||
|
|
@ -28,9 +29,11 @@ public sealed unsafe class HbGpuBlobCache
|
||||||
|
|
||||||
public int CachedVectorCount => _vectorBlobs.Count;
|
public int CachedVectorCount => _vectorBlobs.Count;
|
||||||
|
|
||||||
|
public bool IsPersistentOverflowPending => _persistentOverflowPending;
|
||||||
|
|
||||||
public bool EnsureBudgetOrReset()
|
public bool EnsureBudgetOrReset()
|
||||||
{
|
{
|
||||||
if (!_atlas.NeedsPersistentReset)
|
if (!_atlas.NeedsPersistentReset && !_persistentOverflowPending)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -38,6 +41,7 @@ public sealed unsafe class HbGpuBlobCache
|
||||||
_atlas.ResetPersistent();
|
_atlas.ResetPersistent();
|
||||||
_glyphBlobs.Clear();
|
_glyphBlobs.Clear();
|
||||||
_vectorBlobs.Clear();
|
_vectorBlobs.Clear();
|
||||||
|
_persistentOverflowPending = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,9 +81,10 @@ public sealed unsafe class HbGpuBlobCache
|
||||||
{
|
{
|
||||||
if (_atlas.PersistentCursor + (uint)texelCount > HbGpuAtlasAllocator.PersistentCapacity)
|
if (_atlas.PersistentCursor + (uint)texelCount > HbGpuAtlasAllocator.PersistentCapacity)
|
||||||
{
|
{
|
||||||
_atlas.ResetPersistent();
|
// Never wipe persistent atlas mid-frame while earlier quads reference pre-reset offsets.
|
||||||
_glyphBlobs.Clear();
|
// Flag for reset at next BeginFrame() and skip overflow glyphs cleanly for this frame.
|
||||||
_vectorBlobs.Clear();
|
_persistentOverflowPending = true;
|
||||||
|
return new CachedBlob(0, 0, 0, 0, 0, 0, IsEmpty: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint offset = _atlas.AllocatePersistent(_scratchShorts.AsSpan(0, texelCount * 4));
|
uint offset = _atlas.AllocatePersistent(_scratchShorts.AsSpan(0, texelCount * 4));
|
||||||
|
|
@ -97,6 +102,9 @@ public sealed unsafe class HbGpuBlobCache
|
||||||
return blob;
|
return blob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool TryGetStaticPath(VectorBlobKey key, out CachedBlob cached) =>
|
||||||
|
_vectorBlobs.TryGetValue(key, out cached);
|
||||||
|
|
||||||
public CachedBlob GetOrEncodeStaticPath(
|
public CachedBlob GetOrEncodeStaticPath(
|
||||||
VectorBlobKey key,
|
VectorBlobKey key,
|
||||||
uint designUpem,
|
uint designUpem,
|
||||||
|
|
@ -118,9 +126,9 @@ public sealed unsafe class HbGpuBlobCache
|
||||||
{
|
{
|
||||||
if (_atlas.PersistentCursor + (uint)texelCount > HbGpuAtlasAllocator.PersistentCapacity)
|
if (_atlas.PersistentCursor + (uint)texelCount > HbGpuAtlasAllocator.PersistentCapacity)
|
||||||
{
|
{
|
||||||
_atlas.ResetPersistent();
|
// Never wipe persistent atlas mid-frame while earlier quads reference pre-reset offsets.
|
||||||
_glyphBlobs.Clear();
|
_persistentOverflowPending = true;
|
||||||
_vectorBlobs.Clear();
|
return new CachedBlob(0, 0, 0, 0, 0, 0, IsEmpty: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint offset = _atlas.AllocatePersistent(_scratchShorts.AsSpan(0, texelCount * 4));
|
uint offset = _atlas.AllocatePersistent(_scratchShorts.AsSpan(0, texelCount * 4));
|
||||||
|
|
|
||||||
|
|
@ -80,31 +80,37 @@ public static class HbGpuVectorShapes
|
||||||
|
|
||||||
public static CachedBlob GetUnitRingStroke(HbGpuBlobCache cache, ushort strokeUnits = 24)
|
public static CachedBlob GetUnitRingStroke(HbGpuBlobCache cache, ushort strokeUnits = 24)
|
||||||
{
|
{
|
||||||
Span<float> args = stackalloc float[] { 0f, 0f, 500f, strokeUnits };
|
var key = new VectorBlobKey(VectorShapeKind.UnitRingStroke, strokeUnits, 0);
|
||||||
return cache.GetOrEncodeStaticPath(
|
if (cache.TryGetStaticPath(key, out CachedBlob cached))
|
||||||
new VectorBlobKey(VectorShapeKind.UnitRingStroke, strokeUnits, 0),
|
{
|
||||||
DesignUpem,
|
return cached;
|
||||||
CircleVerbs,
|
}
|
||||||
args);
|
|
||||||
|
Span<float> args = stackalloc float[4];
|
||||||
|
args[0] = 0f;
|
||||||
|
args[1] = 0f;
|
||||||
|
args[2] = 500f;
|
||||||
|
args[3] = strokeUnits;
|
||||||
|
return cache.GetOrEncodeStaticPath(key, DesignUpem, CircleVerbs, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CachedBlob GetTargetBracketCorner(HbGpuBlobCache cache, ushort thicknessUnits = 120)
|
public static CachedBlob GetTargetBracketCorner(HbGpuBlobCache cache, ushort thicknessUnits = 120)
|
||||||
{
|
{
|
||||||
float t = Math.Clamp((float)thicknessUnits, 10f, 450f);
|
var key = new VectorBlobKey(VectorShapeKind.TargetBracketCorner, thicknessUnits, 0);
|
||||||
Span<float> args = stackalloc float[]
|
if (cache.TryGetStaticPath(key, out CachedBlob cached))
|
||||||
{
|
{
|
||||||
0f, 0f,
|
return cached;
|
||||||
1000f, 0f,
|
}
|
||||||
1000f, -t,
|
|
||||||
t, -t,
|
float t = Math.Clamp((float)thicknessUnits, 10f, 450f);
|
||||||
t, -1000f,
|
Span<float> args = stackalloc float[12];
|
||||||
0f, -1000f
|
args[0] = 0f; args[1] = 0f;
|
||||||
};
|
args[2] = 1000f; args[3] = 0f;
|
||||||
return cache.GetOrEncodeStaticPath(
|
args[4] = 1000f; args[5] = -t;
|
||||||
new VectorBlobKey(VectorShapeKind.TargetBracketCorner, thicknessUnits, 0),
|
args[6] = t; args[7] = -t;
|
||||||
DesignUpem,
|
args[8] = t; args[9] = -1000f;
|
||||||
CornerBracketVerbs,
|
args[10] = 0f; args[11] = -1000f;
|
||||||
args);
|
return cache.GetOrEncodeStaticPath(key, DesignUpem, CornerBracketVerbs, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CachedBlob GetChevronTriangle(HbGpuBlobCache cache) =>
|
public static CachedBlob GetChevronTriangle(HbGpuBlobCache cache) =>
|
||||||
|
|
|
||||||
|
|
@ -175,4 +175,73 @@ public sealed class HbGpuNativeTests
|
||||||
atlas.ClearPending();
|
atlas.ClearPending();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void PersistentAtlasOverflowDoesNotResetMidFrame()
|
||||||
|
{
|
||||||
|
var atlas = new HbGpuAtlasAllocator();
|
||||||
|
var blobs = new HbGpuBlobCache(atlas);
|
||||||
|
|
||||||
|
// Fill persistent zone right up near PersistentCapacity without crossing it
|
||||||
|
short[] chunk = new short[4096 * 4]; // 4096 texels
|
||||||
|
chunk[0] = 1;
|
||||||
|
while (atlas.PersistentCursor + 4096 <= HbGpuAtlasAllocator.PersistentCapacity)
|
||||||
|
{
|
||||||
|
atlas.AllocatePersistent(chunk);
|
||||||
|
atlas.ClearPending();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint epochBefore = atlas.Epoch;
|
||||||
|
uint cursorBefore = atlas.PersistentCursor;
|
||||||
|
Assert.True(cursorBefore > HbGpuAtlasAllocator.PersistentResetWatermark);
|
||||||
|
|
||||||
|
// Encode a static vector that exceeds remaining PersistentCapacity: must NOT reset mid-frame!
|
||||||
|
Span<byte> bigVerbs = stackalloc byte[64];
|
||||||
|
Span<float> bigArgs = stackalloc float[128];
|
||||||
|
int v = 0, a = 0;
|
||||||
|
bigVerbs[v++] = (byte)HbGpuPathVerb.Move;
|
||||||
|
bigArgs[a++] = 0f;
|
||||||
|
bigArgs[a++] = 0f;
|
||||||
|
for (int i = 1; i <= 30; i++)
|
||||||
|
{
|
||||||
|
float ang = i * 0.2f;
|
||||||
|
bigVerbs[v++] = (byte)HbGpuPathVerb.LineTo;
|
||||||
|
bigArgs[a++] = MathF.Cos(ang) * 400f;
|
||||||
|
bigArgs[a++] = MathF.Sin(ang) * 400f;
|
||||||
|
}
|
||||||
|
bigVerbs[v++] = (byte)HbGpuPathVerb.Close;
|
||||||
|
|
||||||
|
// First force a large remaining fill so the encoded vector overflows remaining space
|
||||||
|
uint rem = HbGpuAtlasAllocator.PersistentCapacity - atlas.PersistentCursor;
|
||||||
|
if (rem > 2)
|
||||||
|
{
|
||||||
|
atlas.AllocatePersistent(new short[(rem - 1) * 4]);
|
||||||
|
atlas.ClearPending();
|
||||||
|
}
|
||||||
|
cursorBefore = atlas.PersistentCursor;
|
||||||
|
|
||||||
|
CachedBlob overflowed = blobs.GetOrEncodeStaticPath(
|
||||||
|
new VectorBlobKey(VectorShapeKind.Custom, 999, 1),
|
||||||
|
1000u,
|
||||||
|
bigVerbs[..v],
|
||||||
|
bigArgs[..a]);
|
||||||
|
|
||||||
|
Assert.False(overflowed.IsValid);
|
||||||
|
Assert.Equal(epochBefore, atlas.Epoch);
|
||||||
|
Assert.Equal(cursorBefore, atlas.PersistentCursor);
|
||||||
|
Assert.True(blobs.IsPersistentOverflowPending);
|
||||||
|
|
||||||
|
// Next BeginFrame resets cleanly and allows encoding
|
||||||
|
Assert.True(blobs.EnsureBudgetOrReset());
|
||||||
|
Assert.Equal(epochBefore + 1, atlas.Epoch);
|
||||||
|
Assert.Equal(0u, atlas.PersistentCursor);
|
||||||
|
Assert.False(blobs.IsPersistentOverflowPending);
|
||||||
|
|
||||||
|
CachedBlob recovered = blobs.GetOrEncodeStaticPath(
|
||||||
|
new VectorBlobKey(VectorShapeKind.Custom, 999, 1),
|
||||||
|
1000u,
|
||||||
|
bigVerbs[..v],
|
||||||
|
bigArgs[..a]);
|
||||||
|
Assert.True(recovered.IsValid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,8 @@ catch {
|
||||||
|
|
||||||
$MinReleaseYmirDllBytes = 400000L
|
$MinReleaseYmirDllBytes = 400000L
|
||||||
$MaxReleaseYmirDllBytes = 2000000L # Release is ~750-900 KB; Debug (with BOX3D_VALIDATE) is > 4 MB
|
$MaxReleaseYmirDllBytes = 2000000L # Release is ~750-900 KB; Debug (with BOX3D_VALIDATE) is > 4 MB
|
||||||
|
$MinReleaseHbGpuDllBytes = 100000L
|
||||||
|
$MaxReleaseHbGpuDllBytes = 2621440L # < 2.5 MiB HarfBuzz 15.2.0 hb-gpu DLL budget
|
||||||
|
|
||||||
function Resolve-RepoPath {
|
function Resolve-RepoPath {
|
||||||
param([string]$PathValue, [string]$BaseDir)
|
param([string]$PathValue, [string]$BaseDir)
|
||||||
|
|
@ -259,6 +261,23 @@ if ($ymirDllLen -lt $MinReleaseYmirDllBytes -or $ymirDllLen -gt $MaxReleaseYmirD
|
||||||
}
|
}
|
||||||
Write-Host "Verified Release ymir_box3d.dll ($ymirDllLen B)."
|
Write-Host "Verified Release ymir_box3d.dll ($ymirDllLen B)."
|
||||||
|
|
||||||
|
Write-Host "`n[1b/5] Building Release rtd_hbgpu.dll..."
|
||||||
|
$hbGpuProj = Join-Path $RepoRoot "src\RustToDust.HbGpu\RustToDust.HbGpu.csproj"
|
||||||
|
& dotnet build $hbGpuProj -c Release -p:HbGpuNativeConfiguration=Release --disable-build-servers -p:UseSharedCompilation=false -nr:false
|
||||||
|
if ($LASTEXITCODE -ne 0) {
|
||||||
|
throw "dotnet build RustToDust.HbGpu failed with exit code $LASTEXITCODE."
|
||||||
|
}
|
||||||
|
|
||||||
|
$hbGpuDllPath = Join-Path $RepoRoot "artifacts\hbgpu-native\Release\bin\Release\rtd_hbgpu.dll"
|
||||||
|
if (-not (Test-Path $hbGpuDllPath)) {
|
||||||
|
throw "Release rtd_hbgpu.dll not found at '$hbGpuDllPath'."
|
||||||
|
}
|
||||||
|
$hbGpuDllLen = (Get-Item $hbGpuDllPath).Length
|
||||||
|
if ($hbGpuDllLen -lt $MinReleaseHbGpuDllBytes -or $hbGpuDllLen -gt $MaxReleaseHbGpuDllBytes) {
|
||||||
|
throw "rtd_hbgpu.dll size outside Release range ($MinReleaseHbGpuDllBytes..$MaxReleaseHbGpuDllBytes B): got $hbGpuDllLen bytes at '$hbGpuDllPath'."
|
||||||
|
}
|
||||||
|
Write-Host "Verified Release rtd_hbgpu.dll ($hbGpuDllLen B)."
|
||||||
|
|
||||||
# Step 2: Export Windows Desktop Release via Godot
|
# Step 2: Export Windows Desktop Release via Godot
|
||||||
Write-Host "`n[2/5] Exporting Windows Desktop Release..."
|
Write-Host "`n[2/5] Exporting Windows Desktop Release..."
|
||||||
if (Test-Path $StageDir) {
|
if (Test-Path $StageDir) {
|
||||||
|
|
@ -318,10 +337,12 @@ if (-not $stagedDataDir) {
|
||||||
# Remove PDBs if any slipped through
|
# Remove PDBs if any slipped through
|
||||||
Get-ChildItem -Path $StageDir -Recurse -Filter "*.pdb" -File | Remove-Item -Force
|
Get-ChildItem -Path $StageDir -Recurse -Filter "*.pdb" -File | Remove-Item -Force
|
||||||
|
|
||||||
# Step 3: Stage Release ymir_box3d.dll & runtime assets/
|
# Step 3: Stage Release ymir_box3d.dll, rtd_hbgpu.dll, licenses & runtime assets/
|
||||||
Write-Host "`n[3/5] Staging Release ymir_box3d.dll and runtime assets/..."
|
Write-Host "`n[3/5] Staging Release native DLLs, licenses, and runtime assets/..."
|
||||||
Copy-Item -Path $ymirDllPath -Destination (Join-Path $StageDir "ymir_box3d.dll") -Force
|
Copy-Item -Path $ymirDllPath -Destination (Join-Path $StageDir "ymir_box3d.dll") -Force
|
||||||
Copy-Item -Path $ymirDllPath -Destination (Join-Path $stagedDataDir "ymir_box3d.dll") -Force
|
Copy-Item -Path $ymirDllPath -Destination (Join-Path $stagedDataDir "ymir_box3d.dll") -Force
|
||||||
|
Copy-Item -Path $hbGpuDllPath -Destination (Join-Path $StageDir "rtd_hbgpu.dll") -Force
|
||||||
|
Copy-Item -Path $hbGpuDllPath -Destination (Join-Path $stagedDataDir "rtd_hbgpu.dll") -Force
|
||||||
|
|
||||||
$fontLicenseSrc = Join-Path $ClientDir "fonts\MONASPACE_LICENSE.txt"
|
$fontLicenseSrc = Join-Path $ClientDir "fonts\MONASPACE_LICENSE.txt"
|
||||||
if (-not (Test-Path $fontLicenseSrc)) {
|
if (-not (Test-Path $fontLicenseSrc)) {
|
||||||
|
|
@ -329,13 +350,26 @@ if (-not (Test-Path $fontLicenseSrc)) {
|
||||||
}
|
}
|
||||||
Copy-Item -Path $fontLicenseSrc -Destination (Join-Path $StageDir "MONASPACE_LICENSE.txt") -Force
|
Copy-Item -Path $fontLicenseSrc -Destination (Join-Path $StageDir "MONASPACE_LICENSE.txt") -Force
|
||||||
|
|
||||||
|
$thirdPartySrc = Join-Path $RepoRoot "THIRD_PARTY_NOTICES.txt"
|
||||||
|
if (-not (Test-Path $thirdPartySrc)) {
|
||||||
|
throw "Required third-party notices missing: '$thirdPartySrc'."
|
||||||
|
}
|
||||||
|
Copy-Item -Path $thirdPartySrc -Destination (Join-Path $StageDir "THIRD_PARTY_NOTICES.txt") -Force
|
||||||
|
|
||||||
$stagedAssetsDir = Join-Path $StageDir "assets"
|
$stagedAssetsDir = Join-Path $StageDir "assets"
|
||||||
$vCount = Copy-FilteredTree -SourceDir (Join-Path $AssetsSrcDir "vehicles") -DestDir (Join-Path $stagedAssetsDir "vehicles") -IncludeExtensions @(".glb", ".cc", ".json")
|
$vCount = Copy-FilteredTree -SourceDir (Join-Path $AssetsSrcDir "vehicles") -DestDir (Join-Path $stagedAssetsDir "vehicles") -IncludeExtensions @(".glb", ".cc", ".json")
|
||||||
$gCount = Copy-FilteredTree -SourceDir (Join-Path $AssetsSrcDir "gear") -DestDir (Join-Path $stagedAssetsDir "gear") -IncludeExtensions @(".glb")
|
$gCount = Copy-FilteredTree -SourceDir (Join-Path $AssetsSrcDir "gear") -DestDir (Join-Path $stagedAssetsDir "gear") -IncludeExtensions @(".glb")
|
||||||
$dCount = Copy-FilteredTree -SourceDir (Join-Path $AssetsSrcDir "decals") -DestDir (Join-Path $stagedAssetsDir "decals") -IncludeExtensions @(".png")
|
$dCount = Copy-FilteredTree -SourceDir (Join-Path $AssetsSrcDir "decals") -DestDir (Join-Path $stagedAssetsDir "decals") -IncludeExtensions @(".png")
|
||||||
$aCount = Copy-FilteredTree -SourceDir (Join-Path $AssetsSrcDir "audio") -DestDir (Join-Path $stagedAssetsDir "audio") -IncludeExtensions @(".wav", ".md")
|
$aCount = Copy-FilteredTree -SourceDir (Join-Path $AssetsSrcDir "audio") -DestDir (Join-Path $stagedAssetsDir "audio") -IncludeExtensions @(".wav", ".md")
|
||||||
|
$fCount = Copy-FilteredTree -SourceDir (Join-Path $AssetsSrcDir "fonts") -DestDir (Join-Path $stagedAssetsDir "fonts") -IncludeExtensions @(".ttf", ".txt", ".md")
|
||||||
$mCount = Copy-FilteredTree -SourceDir (Join-Path $AssetsSrcDir "maps\sion") -DestDir (Join-Path $stagedAssetsDir "maps\sion") -IncludeExtensions @(".json", ".f32", ".png", ".bin", ".glb")
|
$mCount = Copy-FilteredTree -SourceDir (Join-Path $AssetsSrcDir "maps\sion") -DestDir (Join-Path $stagedAssetsDir "maps\sion") -IncludeExtensions @(".json", ".f32", ".png", ".bin", ".glb")
|
||||||
Write-Host "Staged runtime assets: vehicles=$vCount gear=$gCount decals=$dCount audio=$aCount sion=$mCount"
|
foreach ($reqFontFile in @("Krypton.ttf", "OFL-1.1.txt", "HARFBUZZ-COPYING.txt")) {
|
||||||
|
$reqPath = Join-Path (Join-Path $stagedAssetsDir "fonts") $reqFontFile
|
||||||
|
if (-not (Test-Path $reqPath)) {
|
||||||
|
throw "Required staged font/license file missing: '$reqPath'."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Write-Host "Staged runtime assets: vehicles=$vCount gear=$gCount decals=$dCount audio=$aCount fonts=$fCount sion=$mCount"
|
||||||
|
|
||||||
# Step 4: Create ZIP and SHA256SUMS.txt
|
# Step 4: Create ZIP and SHA256SUMS.txt
|
||||||
Write-Host "`n[4/5] Packaging $ZipName..."
|
Write-Host "`n[4/5] Packaging $ZipName..."
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue