Adaug proiectul Unity

This commit is contained in:
2026-11-01 23:39:55 +02:00
parent cb14d9d37d
commit 863eac8f2c
23463 changed files with 5412601 additions and 0 deletions
@@ -0,0 +1,87 @@
#if ENABLE_PROFILER && PROFILER_INSTALLED
using System;
using System.Collections.Generic;
using Unity.Profiling;
namespace UnityEngine.Rendering.Universal.U2D.Profiler
{
[Serializable]
struct MeshFrameData
{
public EntityId gameObjectEntityId;
public int triangleCount;
public int vertexCount;
}
class MeshFrameDataProfilerEmitter
{
List<MeshFrameData> m_FrameDataList = new List<MeshFrameData>();
int m_TriangleCount = 0;
int m_Tag;
ProfilerCounterValue<int> m_MeshCounter;
public MeshFrameDataProfilerEmitter(int tag, ProfilerCounterValue<int> meshCounter)
{
m_Tag = tag;
m_MeshCounter = meshCounter;
}
public void Capture(GameObject go, Mesh mesh)
{
if (!UnityEngine.Profiling.Profiler.enabled)
return;
// Don't add duplicates
for (int i = 0; i < m_FrameDataList.Count; ++i)
{
if (m_FrameDataList[i].gameObjectEntityId == go.GetEntityId())
return;
}
if (mesh != null)
{
var meshData = Mesh.AcquireReadOnlyMeshData(mesh);
var triangleCount = 0;
var vertexCount = 0;
for (int i = 0; i < meshData.Length; i++)
{
var m = meshData[i];
int indexCount = 0;
if (m.indexFormat == UnityEngine.Rendering.IndexFormat.UInt16)
{
var indexData = m.GetIndexData<ushort>();
indexCount = indexData.Length;
}
else
{
var indexData = m.GetIndexData<uint>();
indexCount = indexData.Length;
}
triangleCount += indexCount / 3;
vertexCount += m.vertexCount;
}
m_TriangleCount += triangleCount;
var frameData = new MeshFrameData()
{
gameObjectEntityId = go.GetEntityId(),
triangleCount = triangleCount,
vertexCount = vertexCount,
};
m_FrameDataList.Add(frameData);
meshData.Dispose();
}
}
public void Emit()
{
if (!UnityEngine.Profiling.Profiler.enabled)
return;
UnityEngine.Profiling.Profiler.EmitFrameMetaData(ProfilerMarkers.k_2DGraphicProfilerProjectId, m_Tag, m_FrameDataList.ToArray());
m_MeshCounter.Value = m_TriangleCount;
m_TriangleCount = 0;
m_FrameDataList.Clear();
}
}
}
#endif
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e1ff83c8166949f6b18db235eff60cf8
timeCreated: 1773121961
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
namespace UnityEngine.Rendering.Universal.U2D.Profiler
{
class MeshRenderFrameDataProfilerEmitter
{
List<EntityId> m_FrameDataList = new List<EntityId>();
int m_Tag;
public MeshRenderFrameDataProfilerEmitter(int tag)
{
m_Tag = tag;
}
public void Capture(EntityId entityId)
{
if (!UnityEngine.Profiling.Profiler.enabled)
return;
m_FrameDataList.Add(entityId);
}
public void Emit()
{
if (!UnityEngine.Profiling.Profiler.enabled)
return;
UnityEngine.Profiling.Profiler.EmitFrameMetaData(ProfilerMarkers.k_2DGraphicProfilerProjectId, m_Tag, m_FrameDataList.ToArray());
m_FrameDataList.Clear();
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5e9904b465dd472cb54afffbd556cb57
timeCreated: 1774614307
@@ -0,0 +1,99 @@
using System;
using Unity.Profiling;
namespace UnityEngine.Rendering.Universal.U2D.Profiler
{
static class ProfilerMarkers
{
public static readonly Guid k_2DGraphicProfilerProjectId = new Guid("a7f8c3d4-9e2b-4a1c-8f6d-3b9e7a5c2d1f");
// Light Pass Markers
public static readonly string s_LightPass = "Light2D Pass";
public static readonly string s_LightSRTPass = "Light2D SRT Pass";
public static readonly string s_LightVolumetricPass = "Light2D Volumetric Pass";
public static readonly string s_Light2DBatcher = "Light2D Batcher";
public static readonly ProfilingSampler s_ProfilingSampler = new ProfilingSampler(s_LightPass);
public static readonly ProfilingSampler s_ProfilingSampleSRT = new ProfilingSampler(s_LightSRTPass);
public static readonly ProfilingSampler s_ProfilingSamplerVolume = new ProfilingSampler(s_LightVolumetricPass);
public static readonly ProfilingSampler s_ProfilingDrawBatched = new ProfilingSampler(s_Light2DBatcher);
// Shadow Pass Markers
public static readonly string s_ShadowTexture = "Draw 2D Shadow Texture";
public static readonly ProfilingSampler s_ProfilingSamplerShadows = new ProfilingSampler(s_ShadowTexture);
// Render Pass Markers
public static readonly string s_SetGlobalProperties = "SetGlobalProperties";
public static readonly string s_RenderPass = "Renderer2D Pass";
public static readonly string s_SetLightBlendTexture = "SetLightBlendTextures";
public static readonly string s_UpscalePass = "Upscale2D Pass";
public static readonly string s_DrawUpscale = "Draw Upscale";
public static readonly string s_MormalPass = "Normal2D Pass";
public static readonly string s_ShadowPass = "Shadow2D UnsafePass";
public static readonly string s_ShadowVolumetricPass = "Shadow2D Volumetric UnsafePass";
public static readonly string s_CopyCameraSortingLayerPass = "CopyCameraSortingLayer Pass";
public static readonly string s_Copy = "Copy";
public static readonly ProfilingSampler s_ProfilingSamplerSetGlobalProperties = new ProfilingSampler(s_SetGlobalProperties);
public static readonly ProfilingSampler s_ProfilingSamplerRenderPass = new ProfilingSampler(s_RenderPass);
public static readonly ProfilingSampler s_ProfilingSamplerSetLightBlendTexture = new ProfilingSampler(s_SetLightBlendTexture);
public static readonly ProfilingSampler s_ProfilingSamplerUpscalePass = new ProfilingSampler(s_UpscalePass);
public static readonly ProfilingSampler s_ProfilingSamplerDrawUpscale = new ProfilingSampler(s_DrawUpscale);
public static readonly ProfilingSampler s_ProfilingSamplerNormalPass = new ProfilingSampler(s_MormalPass);
public static readonly ProfilingSampler s_ProfilingSamplerShadowPass = new ProfilingSampler(s_ShadowPass);
public static readonly ProfilingSampler s_ProfilingSamplerShadowVolumetricPass = new ProfilingSampler(s_ShadowVolumetricPass);
public static readonly ProfilingSampler s_ProfilingSamplerCopyCameraSortingLayerPass = new ProfilingSampler(s_CopyCameraSortingLayerPass);
public static readonly ProfilingSampler s_ProfilingSamplerCopy = new ProfilingSampler(s_Copy);
public const string k_U2DNormalMapProfilerCounterName = "Normal Textures";
public const string k_U2DLightProfilerCounterName = "Light Textures";
public const string k_U2DShadowProfilerCounterName = "Shadow Textures";
public const string k_U2DShadowCasterCounterName = "Shadow Casters Draw Calls";
public const string k_U2DShadowVerticesCounterName = "Shadow Triangles";
public const string k_U2DLightBatchCounterName = "Light Batches";
public const string k_U2DLightTriangleCounterName = "Light Triangles";
#if ENABLE_PROFILER && PROFILER_INSTALLED
public enum ProfilerFrameDataTag
{
ShadowFrameData = 0,
LightFrameData = 1,
LightRenderFrameData = 2,
ShadowRenderFrameData = 3
}
public static readonly ProfilerCounterValue<int> s_U2DNormalMapProfilerCounterValue =
new ProfilerCounterValue<int>(ProfilerCategory.U2D, k_U2DNormalMapProfilerCounterName, ProfilerMarkerDataUnit.Count,
ProfilerCounterOptions.FlushOnEndOfFrame | ProfilerCounterOptions.ResetToZeroOnFlush);
public static readonly ProfilerCounterValue<int> s_U2DLightProfilerCounterValue =
new ProfilerCounterValue<int>(ProfilerCategory.U2D, k_U2DLightProfilerCounterName, ProfilerMarkerDataUnit.Count,
ProfilerCounterOptions.FlushOnEndOfFrame | ProfilerCounterOptions.ResetToZeroOnFlush);
public static readonly ProfilerCounterValue<int> s_U2DShadowProfilerCounterValue =
new ProfilerCounterValue<int>(ProfilerCategory.U2D, k_U2DShadowProfilerCounterName, ProfilerMarkerDataUnit.Count,
ProfilerCounterOptions.FlushOnEndOfFrame | ProfilerCounterOptions.ResetToZeroOnFlush);
public static readonly ProfilerCounterValue<int> s_U2DShadowCasterCounterValue =
new ProfilerCounterValue<int>(ProfilerCategory.U2D, k_U2DShadowCasterCounterName, ProfilerMarkerDataUnit.Count,
ProfilerCounterOptions.FlushOnEndOfFrame | ProfilerCounterOptions.ResetToZeroOnFlush);
public static readonly ProfilerCounterValue<int> s_U2DShadowVerticesCounterValue =
new ProfilerCounterValue<int>(ProfilerCategory.U2D, k_U2DShadowVerticesCounterName, ProfilerMarkerDataUnit.Count,
ProfilerCounterOptions.FlushOnEndOfFrame | ProfilerCounterOptions.ResetToZeroOnFlush);
public static readonly ProfilerCounterValue<int> s_U2DLightBatchCounterValue =
new ProfilerCounterValue<int>(ProfilerCategory.U2D, k_U2DLightBatchCounterName, ProfilerMarkerDataUnit.Count,
ProfilerCounterOptions.FlushOnEndOfFrame | ProfilerCounterOptions.ResetToZeroOnFlush);
public static readonly ProfilerCounterValue<int> s_U2DLightTriangleCounterValue =
new ProfilerCounterValue<int>(ProfilerCategory.U2D, k_U2DLightTriangleCounterName, ProfilerMarkerDataUnit.Count,
ProfilerCounterOptions.FlushOnEndOfFrame | ProfilerCounterOptions.ResetToZeroOnFlush);
public static MeshFrameDataProfilerEmitter s_LightMeshFrameData = new ((int)ProfilerFrameDataTag.LightFrameData, s_U2DLightTriangleCounterValue);
public static MeshRenderFrameDataProfilerEmitter s_LightRenderFrameData = new ((int)ProfilerFrameDataTag.LightRenderFrameData);
public static MeshFrameDataProfilerEmitter s_ShadowMeshFrameData = new ((int)ProfilerFrameDataTag.ShadowFrameData, s_U2DShadowVerticesCounterValue);
public static MeshRenderFrameDataProfilerEmitter s_ShadowRenderFrameData = new ((int)ProfilerFrameDataTag.ShadowRenderFrameData);
#endif
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 19dc6d7acb114482bdbc10c16b44cdc4
timeCreated: 1773110223