Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ public void Dispose()
{
}

public async UniTask InitializeAsync(CancellationToken ct)
{
}
public UniTask InitializeAsync(CancellationToken ct) => UniTask.CompletedTask;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,12 @@ public async UniTask InitializeAsync(LightSourcePluginSettings settings, Cancell
await CreateLightSourcePoolAsync(lightSourcePrefab, ct);
}

private async UniTask CreateLightSourcePoolAsync(Light lightSourcePrefab, CancellationToken ct)
private UniTask CreateLightSourcePoolAsync(Light lightSourcePrefab, CancellationToken ct)
{
lightPoolRegistry = poolsRegistry.AddGameObjectPool(() => Object.Instantiate(lightSourcePrefab, Vector3.zero, quaternion.identity), onRelease: OnPoolRelease, onGet: OnPoolGet);

cacheCleaner.Register(lightPoolRegistry);
return UniTask.CompletedTask;
}

private void OnPoolRelease(Light light)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ ref PBAudioAnalysis sdkComponent
{
PBAudioAnalysisMode.ModeRaw => AnalysisResultMode.Raw,
PBAudioAnalysisMode.ModeLogarithmic => AnalysisResultMode.Logarithmic,

// proto3 open enum: scene wire data can carry any out-of-range value; fall back
// to the default mode instead of throwing every frame.
_ => AnalysisResultMode.Raw,
};
float amplitudeGain = sdkComponent.HasAmplitudeGain ? sdkComponent.AmplitudeGain : DEFAULT_AMPLITUDE_GAIN;
float bandsGain = sdkComponent.HasBandsGain ? sdkComponent.BandsGain : DEFAULT_BANDS_GAIN;
Expand Down
19 changes: 18 additions & 1 deletion Explorer/Assets/DCL/SDKComponents/MediaStream/AnyTexture.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using REnum;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using Utility;

namespace ECS.StreamableLoading.Textures
Expand All @@ -12,7 +13,23 @@ namespace ECS.StreamableLoading.Textures
[REnumField(typeof(Texture2D))]
public partial struct AnyTexture
{
public long ByteSize => Match(static _ => 0L, tex2d => tex2d.GetRawTextureData<byte>().Length);
public long ByteSize => Match(static _ => 0L, static tex2d => EstimateTextureByteSize(tex2d));

private static long EstimateTextureByteSize(Texture2D tex2d)
{
// Destroyed textures (Unity fake-null) account as zero instead of throwing.
if (tex2d == null) return 0L;
if (tex2d.isReadable) return tex2d.GetRawTextureData<byte>().Length;

// Non-readable textures have no CPU copy to measure (GetRawTextureData throws);
// estimate the GPU footprint across the full mip chain instead.
var size = (long)GraphicsFormatUtility.ComputeMipmapSize(tex2d.width, tex2d.height, tex2d.graphicsFormat);

for (var mip = 1; mip < tex2d.mipmapCount; mip++)
size += (long)GraphicsFormatUtility.ComputeMipmapSize(Mathf.Max(1, tex2d.width >> mip), Mathf.Max(1, tex2d.height >> mip), tex2d.graphicsFormat);

return size;
}

public Texture Texture => Match<Texture>(static video => video.Texture, static tex2d => tex2d);

Expand Down
Loading