refactor(pipeline): MP1a - lift TextureKey out of the GL atlas class
This commit is contained in:
parent
651d041e5a
commit
d778930853
3 changed files with 39 additions and 29 deletions
|
|
@ -15,6 +15,7 @@ using System.Numerics;
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AcDream.Content;
|
||||
using AcDream.Core.Rendering.Wb;
|
||||
using PixelFormat = Silk.NET.OpenGL.PixelFormat;
|
||||
using BoundingBox = Chorizite.Core.Lib.BoundingBox;
|
||||
|
|
@ -114,7 +115,7 @@ namespace AcDream.App.Rendering.Wb {
|
|||
public class MeshBatchData {
|
||||
public ushort[] Indices { get; set; } = Array.Empty<ushort>();
|
||||
public (int Width, int Height, TextureFormat Format) TextureFormat { get; set; }
|
||||
public TextureAtlasManager.TextureKey TextureKey { get; set; }
|
||||
public TextureKey TextureKey { get; set; }
|
||||
public int TextureIndex { get; set; }
|
||||
public byte[] TextureData { get; set; } = Array.Empty<byte>();
|
||||
public PixelFormat? UploadPixelFormat { get; set; }
|
||||
|
|
@ -126,7 +127,7 @@ namespace AcDream.App.Rendering.Wb {
|
|||
/// CPU-side texture info for deduplication during background preparation.
|
||||
/// </summary>
|
||||
public class TextureBatchData {
|
||||
public TextureAtlasManager.TextureKey Key { get; set; }
|
||||
public TextureKey Key { get; set; }
|
||||
public byte[] TextureData { get; set; } = Array.Empty<byte>();
|
||||
public PixelFormat? UploadPixelFormat { get; set; }
|
||||
public PixelType? UploadPixelType { get; set; }
|
||||
|
|
@ -187,7 +188,7 @@ namespace AcDream.App.Rendering.Wb {
|
|||
public (int Width, int Height) TextureSize { get; set; }
|
||||
public TextureFormat TextureFormat { get; set; }
|
||||
public uint SurfaceId { get; set; }
|
||||
public TextureAtlasManager.TextureKey Key { get; set; }
|
||||
public TextureKey Key { get; set; }
|
||||
public DatReaderWriter.Enums.CullMode CullMode { get; set; }
|
||||
public bool IsTransparent { get; set; }
|
||||
public bool IsAdditive { get; set; }
|
||||
|
|
@ -1283,7 +1284,7 @@ namespace AcDream.App.Rendering.Wb {
|
|||
}
|
||||
|
||||
var format = (texWidth, texHeight, textureFormat);
|
||||
var key = new TextureAtlasManager.TextureKey {
|
||||
var key = new TextureKey {
|
||||
SurfaceId = surfaceId,
|
||||
PaletteId = paletteId,
|
||||
Stippling = poly.Stippling,
|
||||
|
|
@ -1628,7 +1629,7 @@ namespace AcDream.App.Rendering.Wb {
|
|||
sourceFormat == DatReaderWriter.Enums.PixelFormat.PFID_DXT5)));
|
||||
|
||||
var format = (texWidth, texHeight, textureFormat);
|
||||
var key = new TextureAtlasManager.TextureKey {
|
||||
var key = new TextureKey {
|
||||
SurfaceId = surfaceId,
|
||||
PaletteId = paletteId,
|
||||
Stippling = poly.Stippling,
|
||||
|
|
@ -2233,7 +2234,7 @@ namespace AcDream.App.Rendering.Wb {
|
|||
new MeshBatchData {
|
||||
Indices = indices.ToArray(),
|
||||
TextureFormat = (1, 1, TextureFormat.RGBA8),
|
||||
TextureKey = new TextureAtlasManager.TextureKey {
|
||||
TextureKey = new TextureKey {
|
||||
SurfaceId = 0xFFFFFFFF, // Dummy surface ID
|
||||
PaletteId = 0,
|
||||
Stippling = StipplingType.NoPos,
|
||||
|
|
@ -2251,7 +2252,7 @@ namespace AcDream.App.Rendering.Wb {
|
|||
[(1, 1, TextureFormat.RGBA8)] = new List<TextureBatchData> {
|
||||
new TextureBatchData {
|
||||
Indices = indices.ToList(),
|
||||
Key = new TextureAtlasManager.TextureKey {
|
||||
Key = new TextureKey {
|
||||
SurfaceId = 0xFFFFFFFF, // Dummy surface ID
|
||||
PaletteId = 0,
|
||||
Stippling = StipplingType.NoPos,
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using AcDream.Content;
|
||||
using Chorizite.Core.Render;
|
||||
using Chorizite.Core.Render.Enums;
|
||||
using DatReaderWriter.Enums;
|
||||
|
|
@ -94,27 +95,5 @@ namespace AcDream.App.Rendering.Wb {
|
|||
_refCounts.Clear();
|
||||
_freeSlots.Clear();
|
||||
}
|
||||
|
||||
public struct TextureKey : IEquatable<TextureKey> {
|
||||
public uint SurfaceId;
|
||||
public uint PaletteId;
|
||||
public StipplingType Stippling;
|
||||
public bool IsSolid;
|
||||
|
||||
public bool Equals(TextureKey other) {
|
||||
return SurfaceId == other.SurfaceId &&
|
||||
PaletteId == other.PaletteId &&
|
||||
Stippling == other.Stippling &&
|
||||
IsSolid == other.IsSolid;
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj) {
|
||||
return obj is TextureKey other && Equals(other);
|
||||
}
|
||||
|
||||
public override int GetHashCode() {
|
||||
return HashCode.Combine(SurfaceId, PaletteId, Stippling, IsSolid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
30
src/AcDream.Content/TextureKey.cs
Normal file
30
src/AcDream.Content/TextureKey.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
using DatReaderWriter.Enums;
|
||||
using System;
|
||||
|
||||
namespace AcDream.Content;
|
||||
|
||||
// MP1a (2026-07-05): lifted verbatim out of TextureAtlasManager (GL class)
|
||||
// so the GL-free mesh-extraction path (MeshExtractor / ObjectMeshData) can
|
||||
// reference the atlas dedup key without a Silk.NET dependency. Field set,
|
||||
// equality semantics, and hash behavior are UNCHANGED.
|
||||
public struct TextureKey : IEquatable<TextureKey> {
|
||||
public uint SurfaceId;
|
||||
public uint PaletteId;
|
||||
public StipplingType Stippling;
|
||||
public bool IsSolid;
|
||||
|
||||
public bool Equals(TextureKey other) {
|
||||
return SurfaceId == other.SurfaceId &&
|
||||
PaletteId == other.PaletteId &&
|
||||
Stippling == other.Stippling &&
|
||||
IsSolid == other.IsSolid;
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj) {
|
||||
return obj is TextureKey other && Equals(other);
|
||||
}
|
||||
|
||||
public override int GetHashCode() {
|
||||
return HashCode.Combine(SurfaceId, PaletteId, Stippling, IsSolid);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue