Game.Rendering.ProceduralUploadSystem
Assembly: Assembly-CSharp.dll
Namespace: Game.Rendering
Type: public class
Base: GameSystemBase
Summary:
ProceduralUploadSystem is a game system responsible for preparing and uploading GPU data for procedural animated geometry (bones/skeletons) and emissive lights. It coordinates with ProceduralSkeletonSystem, ProceduralEmissiveSystem, PreCullingSystem and PrefabSystem to:
- scan pre-culling results for entities that require skeleton or emissive uploads,
- accumulate upload sizes using a NativeAccumulator (UploadData),
- schedule parallel jobs that build CPU-side skin/light buffers and submit sparse uploads to threaded uploaders,
- optionally apply an "override" light/emissive animation for previewing or special rendering cases.
Key nested types:
- Prepare (nested GameSystemBase) — runs before the upload job to compute upload size statistics into a NativeAccumulator
Fields
-
private ProceduralSkeletonSystem m_ProceduralSkeletonSystem
Holds a reference to the ProceduralSkeletonSystem used to obtain bone uploaders and motion-blur/history settings. -
private ProceduralEmissiveSystem m_ProceduralEmissiveSystem
Reference to the emissive/light system used to get the light uploader for emissive uploads. -
private PreCullingSystem m_PreCullingSystem
Reference to the pre-culling system; used to obtain culling results (NativeList) that the jobs iterate. -
private PrefabSystem m_PrefabSystem
Reference to the prefab system used for prefab-related lookups when applying overrides. -
private RenderPrefabBase m_OverridePrefab
When an override is active, this stores the prefab whose emissive/light data will be used to synthesize overridden light states. -
private NativeAccumulator<UploadData> m_UploadData
Accumulator used by the Prepare job to aggregate UploadData for skeletons (index 0) and emissives (index 1). Created in the Prepare step and consumed in OnUpdate. -
private JobHandle m_PrepareDeps
JobHandle for the Prepare job chain; completed before launching the actual upload job. -
private Entity m_OverrideEntity
Entity used for override mode. If set, UpdateOverride modifies its emissive/light buffers and contributes to upload sizing. -
private LightState m_OverrideLightState
Stores a cached LightState used when animating/applying the override emissive/light data. -
private int m_OverrideSingleLightIndex
Index used when selecting a single light in override mode. -
private int m_OverrideMultiLightIndex
Index used when selecting a multi-light in override mode. -
private float m_OverrideTime
Internal time accumulator used by override animation playback. -
private TypeHandle __TypeHandle
Cached lookups (ComponentLookup/BufferLookup) used by the system's jobs (assigned in OnCreateForCompiler).
Properties
- (none public on this system)
Constructors
public ProceduralUploadSystem()
Default constructor; attributed with [Preserve]. The real initialization happens in OnCreate where dependent systems are acquired from the World.
Methods
-
protected override void OnCreate()
Initializes references to required systems: ProceduralSkeletonSystem, ProceduralEmissiveSystem, PreCullingSystem and PrefabSystem. -
public void SetOverride(Entity entity, RenderPrefabBase prefab, int singleLightIndex, int multiLightIndex)
Public API to enable or update override mode. Resets cached override light state if the entity or indices change, and stores the override parameters. This causes the system to synthesize emissive/light updates for the override entity on the next update. -
private unsafe void UpdateOverride(ref UploadData emissiveData)
When an override entity is set, this method updates the emissive and LightState buffers of that entity according to the override prefab/light selection. It marks emissives as updated and accumulates upload sizes into emissiveData so the upload job will allocate uploader capacity accordingly. Handles animation curves and multiple-light prefabs. Uses EntityManager buffer/component queries and Prefab lookups. -
protected override void OnUpdate()
Main runtime update. Steps: - Completes the Prepare job (m_PrepareDeps) that produced m_UploadData.
- Extracts UploadData results for skeletons and emissives and disposes the accumulator.
- Optionally calls UpdateOverride to modify override entity buffers and adjust emissive upload sizing.
- Calls ProceduralSkeletonSystem.BeginUpload and ProceduralEmissiveSystem.BeginUpload to obtain ThreadedSparseUploader instances sized from UploadData.
-
Builds a ProceduralUploadJob with lookups, uploaders and culling data, schedules it as a parallel job over pre-culling results, and wires uploader/job dependencies into the respective systems and pre-culling readers.
-
protected override void OnCreateForCompiler()
Assigns query handles and calls __TypeHandle.__AssignHandles to bind lookup handles to the system's TypeHandle. This method is part of ECS/IL2CPP wiring. -
private void __AssignQueries(ref SystemState state)
Internal helper that creates/assigns entity queries used by the system (in this class the query is empty but kept for compiler-generated wiring).
Notes on the nested Prepare class and jobs:
- Prepare.OnCreate registers m_ProceduralUploadSystem reference.
- Prepare.OnUpdate creates the NativeAccumulator
Usage Example
// Typical use from game/mod code — acquire the system and optionally set an override
var world = World.DefaultGameObjectInjectionWorld;
var proceduralUpload = world.GetOrCreateSystemManaged<Game.Rendering.ProceduralUploadSystem>();
// To preview a prefab's emissive/light as an override:
proceduralUpload.SetOverride(overrideEntity, myRenderPrefabBase, singleLightIndex: 0, multiLightIndex: -1);
// The system runs automatically as part of the ECS update loop; no manual Update call is necessary.