Optimize prepared asset package v2
This commit is contained in:
parent
d123c4b67c
commit
0dd966f3a0
28 changed files with 1277 additions and 106 deletions
|
|
@ -433,7 +433,18 @@ public sealed class MeshExtractor {
|
|||
isClipMap,
|
||||
surface.Type.HasFlag(SurfaceType.Additive));
|
||||
|
||||
if (TextureHelpers.IsCompressedFormat(renderSurface.Format)) {
|
||||
if (CanPreserveCompressedTexture(
|
||||
renderSurface.Format,
|
||||
isClipMap,
|
||||
surface.Translucency)) {
|
||||
// Vulkan requires textureCompressionBC, so an unedited
|
||||
// DAT DXT surface can stay byte-exact all the way to the
|
||||
// GPU. Decoding it here inflated pak, CPU, and GPU
|
||||
// residency by up to eight times.
|
||||
textureFormat = ToTextureFormat(renderSurface.Format);
|
||||
textureData = renderSurface.SourceData;
|
||||
}
|
||||
else if (TextureHelpers.IsCompressedFormat(renderSurface.Format)) {
|
||||
isDxt3or5 = renderSurface.Format == DatReaderWriter.Enums.PixelFormat.PFID_DXT3 || renderSurface.Format == DatReaderWriter.Enums.PixelFormat.PFID_DXT5;
|
||||
textureFormat = TextureFormat.RGBA8;
|
||||
uploadPixelFormat = UploadPixelFormat.Rgba;
|
||||
|
|
@ -822,7 +833,14 @@ public sealed class MeshExtractor {
|
|||
isClipMap,
|
||||
surface.Type.HasFlag(SurfaceType.Additive));
|
||||
|
||||
if (_decodedTextureCache.TryGet(decodedTextureKey, out var cachedData)) {
|
||||
if (CanPreserveCompressedTexture(
|
||||
renderSurface.Format,
|
||||
isClipMap,
|
||||
surface.Translucency)) {
|
||||
textureData = renderSurface.SourceData;
|
||||
textureFormat = ToTextureFormat(renderSurface.Format);
|
||||
}
|
||||
else if (_decodedTextureCache.TryGet(decodedTextureKey, out var cachedData)) {
|
||||
textureData = cachedData;
|
||||
textureFormat = TextureFormat.RGBA8;
|
||||
uploadPixelFormat = UploadPixelFormat.Rgba;
|
||||
|
|
@ -1126,6 +1144,26 @@ public sealed class MeshExtractor {
|
|||
return textureData;
|
||||
}
|
||||
|
||||
private static bool CanPreserveCompressedTexture(
|
||||
DatReaderWriter.Enums.PixelFormat format,
|
||||
bool isClipMap,
|
||||
float translucency) =>
|
||||
TextureHelpers.IsCompressedFormat(format)
|
||||
&& !isClipMap
|
||||
&& translucency <= 0.0f;
|
||||
|
||||
private static TextureFormat ToTextureFormat(
|
||||
DatReaderWriter.Enums.PixelFormat format) => format switch
|
||||
{
|
||||
DatReaderWriter.Enums.PixelFormat.PFID_DXT1 => TextureFormat.DXT1,
|
||||
DatReaderWriter.Enums.PixelFormat.PFID_DXT3 => TextureFormat.DXT3,
|
||||
DatReaderWriter.Enums.PixelFormat.PFID_DXT5 => TextureFormat.DXT5,
|
||||
_ => throw new ArgumentOutOfRangeException(
|
||||
nameof(format),
|
||||
format,
|
||||
"The source is not a supported block-compressed texture."),
|
||||
};
|
||||
|
||||
private void BuildPolygonIndices(Polygon poly, GfxObj gfxObj, Vector3 scale,
|
||||
Dictionary<(ushort vertId, ushort uvIdx, bool isNeg), ushort> UVLookup,
|
||||
List<VertexPositionNormalTexture> vertices, List<ushort> indices, bool useNegSurface, ref bool hasWrappingUVs) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue