Hi devs,
I’ve made a simple project with :
- one manager GameObject storing an Entity field and an int field
- a cube prefab
- a system responsible for instancing the cube entity
- a system responsible of the rotation of the cube
Buildt in an URP 14.0.8 environment with entities and entities graphics 1.0.14.
The rotation system is a simple ISystem only scheduling one job in parallel.
The job have only an Execute function with a ref LocalTransform parameter.
The rotation use the LocalTransform.RotateY method.
That’s all for the context.
Here is the problematic : when the rotation system is working, the Unity.Rendering.EntitiesGraphicsSystem spent 7ms on the GPU instead of 1ms when disabled. To be more precise, it happen when I use the ref LocalTransform parameter in the execute method from the rotation job.
Has a consequence, the profiler record a 3ms Gfx.WaitForPresentOnGfxThread on the main thread for each frame
With rotation system disabled :
Is it a normal behaviour from the Unity.Rendering.EntitiesGraphicsSystem ?
How many cubes do you have?
It is expected that if you modify the transform (or any other [MaterialProperty] component), Entities Graphics will run a compute shader to update that data on the GPU.
However, that should normally not take anywhere near 7 ms, unless you have an extremely large amount of Entities that you are modifying.
I spawn only one cube (primitive shape, default material), a prefab instantiated with CubeManager settings.
the scene project :
the GPU Usage (constant value) :
Here is the rotation system and job implementation :
```csharp
-
public partial struct CubeRotationSystem : ISystem
{
[BurstCompile]
public void OnCreate(ref SystemState state)
{
state.RequireForUpdate();
state.RequireForUpdate();
}
[BurstCompile]
public void OnUpdate(ref SystemState state)
{
new CubeRotationJob { }.ScheduleParallel();
}
}
[BurstCompile]
public partial struct CubeRotationJob : IJobEntity
{
public void Execute(in Cube cube, ref LocalTransform transform)
{
transform = transform.RotateY(math.radians(cube.RotationSpeed));
}
}*
```
as reminder :
- Unity 2023.1.12f1
- URP 15.0.6
- Entities graphics 1.0.14
I tested the exact same project on another pc (way more performant) and I get the same issue/result.
this issue seems the same as the one describe on this thread : URP loses whopping 3ms of CPU time once a single Hybrid Renderer entity is spawned
thank you for having paying attention to my problem
If there is only a single cube, then 7 ms is definitely way higher than expected. Would it be possible for you to submit a bug report with a repro project?
Something else you could try is to take a GPU capture of a player build of your scene, using a tool which is capable of doing GPU profiling, such as:
- Nvidia Nsight (Nvidia GPUs only)
- AMD Radeon GPU Profiler (AMD GPUs only)
- Microsoft PIX (D3D12 only)
This kind of tool will show you what exactly is taking so much time, and can offer insight into why that is happening.