A high-performance rendering system and method for 2D dynamic elements based on Unity DOTS

CN122510071APending Publication Date: 2026-08-04FUJIAN JIANZHI INTERACTIVE ENTERTAINMENT SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
FUJIAN JIANZHI INTERACTIVE ENTERTAINMENT SOFTWARE CO LTD
Filing Date
2026-05-13
Publication Date
2026-08-04

AI Technical Summary

Technical Problem

[0005]为了解决现有Unity2D渲染技术在处理海量动态2D图元时存在的内存离散、CPU单线程瓶颈、GC卡顿及渲染指令过载的问题,提供一种基于Unity DOTS的2D动态元素高性能渲染系统及方法,将海量2D图形的计算、排序与渲染压力分摊至多核CPU与GPU硬件,在不改变Unity底层引擎源码的前提下,突破传统2D渲染方案的性能限制,实现万级以上动态2D图元的高性能流畅渲染

Benefits of technology

(1)显著提升CPU缓存命中率,彻底打破“内存墙”计算瓶颈:本发明通过数据模型模块采用实体组件系统(ECS)架构,将2D图元属性拆解为按十六字节对齐的纯值类型结构体,且将相同组件组合的实体集中分配在非托管内存的同一数据块中,使数据在物理内存中呈极致紧凑的线性排列。现有技术中OOP架构导致的内存碎片化问题被彻底解决,CPU遍历数万个图元进行状态更新时,能完美触发硬件高速缓存预取机制,数据读写速度呈指数级上升,彻底突破传统引擎的内存访问瓶颈。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122510071A_ABST
    Figure CN122510071A_ABST
Patent Text Reader

Abstract

This invention belongs to the field of 2D graphics rendering technology of Unity engine, specifically involving a high-performance rendering system and method for 2D dynamic elements based on Unity DOTS. The method is as follows: allocate unmanaged contiguous memory in memory to construct a data model of 2D primitive core components; perform high-concurrency sequence frame animation calculation and bounding box-based parallel frustum culling; perform parallel packaging of visible entity data, adapt the structured buffer capacity, and asynchronously upload the rendering data to GPU memory; configure indirect drawing parameter buffer on the CPU side and trigger the underlying indirect instantiation drawing instructions, transferring the drawing control to the GPU side, and concurrently executing custom vertex shaders in the GPU rendering pipeline. Dynamic depth sorting on the GPU side is achieved through custom vertex shaders, and the final rendering is completed in combination with fragment shaders. This invention breaks through the performance limitations of traditional 2D rendering schemes and achieves high-performance and smooth rendering of tens of thousands of dynamic 2D primitives.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of 2D graphics rendering technology of Unity engine, specifically relating to a high-performance rendering system and method for 2D dynamic elements based on Unity DOTS. Background Technology

[0002] Currently, when the Unity engine processes 2D graphics rendering, it generally adopts a component-based architecture based on object-oriented programming (OOP). The typical processing mechanism of this architecture is as follows: 2D primitives are instantiated into independent game objects, logic and rendering components are attached to the objects, and the system serially executes the lifecycle updates of the objects on the CPU main thread; at the same time, the engine needs to perform a full depth sort (painter's algorithm) on all visible objects on the CPU, and then merge vertices through dynamic batching technology. Finally, the CPU submits Draw Call rendering instructions to the GPU one by one to complete the rendering of 2D primitives.

[0003] When modern games (such as bullet hell games and large-scale RTS games) need to process tens of thousands of dynamic 2D elements on the same screen, the aforementioned traditional 2D rendering solutions expose underlying technical deficiencies, specifically in three aspects: Extremely fragmented memory and low cache hit rate: The OOP architecture causes object data to be scattered in the managed heap as reference types, resulting in physical memory fragmentation. When the CPU traverses and updates data, it cannot utilize the high-speed cache prefetch mechanism, causing serious cache misses and forming a performance "memory wall". Single-threaded computing bottleneck and GC stuttering: The massive component updates and Transform matrix calculations rely heavily on the CPU main thread to execute serially, making it impossible to take advantage of the computing power of multi-core processors. At the same time, the frequent creation and destruction of massive 2D elements will generate a large amount of managed memory allocation, which will cause global main thread blocking when garbage collection (GC) is triggered, resulting in screen stuttering. The overhead of full sorting and draw call submission on the CPU side is too high: When faced with tens of thousands of 2D objects, the time complexity of the full depth sorting algorithm executed by the CPU per frame is O(N log N), which greatly squeezes the computation time of the core logic of the game. In addition, the traditional dynamic batching technology is limited by the upper limit of hardware vertices and buffers, which still generates a large number of draw calls, causing the CPU to spend a lot of time preparing the rendering state, while the GPU is in a state of starvation and waiting.

[0004] The inherent defects of traditional OOP architecture, such as "discrete memory", "serial computation of the main thread" and "over-reliance on CPU sorting and DrawCall submission", have reached the hardware performance ceiling. The industry urgently needs to transform to a new paradigm of data-oriented architecture (DOTS) and GPU-driven rendering in order to completely break the performance barrier of rendering massive 2D dynamic elements. Summary of the Invention

[0005] To address the issues of memory dispersion, CPU single-threaded bottleneck, GC stuttering, and rendering instruction overload in existing Unity2D rendering technologies when handling massive amounts of dynamic 2D primitives, this paper provides a high-performance rendering system and method for 2D dynamic elements based on Unity DOTS. This system distributes the computation, sorting, and rendering pressure of massive 2D graphics to multi-core CPU and GPU hardware. Without changing the underlying Unity engine source code, it breaks through the performance limitations of traditional 2D rendering solutions and achieves high-performance and smooth rendering of tens of thousands of dynamic 2D primitives.

[0006] The technical solution of the present invention is as follows: A high-performance rendering system for 2D dynamic elements based on Unity DOTS, running on the Unity engine, is built on a data-oriented architecture and includes a data model module, a parallel computing module, a data processing module, and a GPU rendering module. The data model module is used to allocate unmanaged contiguous memory in memory and construct a 2D primitive core component data model composed of pure value type data structures aligned to sixteen bytes. The parallel computing module schedules the parallel job system and the Burst compiler to perform high-concurrency sequence frame animation solving and parallel view frustum culling of entity bounding boxes; The data processing module performs parallel packaging of visible entity data, adapts the structured buffer capacity, and asynchronously uploads the rendering data to the GPU's structured cache. The GPU rendering module configures an indirect drawing parameter buffer on the CPU side and triggers the underlying indirect instantiation drawing instructions. The drawing control is transferred to the GPU side, and the GPU rendering pipeline executes a custom vertex shader concurrently. The custom vertex shader realizes dynamic depth sorting on the GPU side, and the final rendering is completed in combination with the fragment shader.

[0007] Furthermore, the 2D primitive core component data model includes local space components, visual data components, animation state components, and sorting key components, and entity objects with the same component combination are uniformly allocated to the same memory data block to achieve continuous storage; The local space component is used to record world coordinates, scaling ratio, and rotation angle; The visual data component is used to record the basic color and atlas texture sampling area; The animation status component is used to record the current playback time and playback speed multiplier. The sorting key component is used to record the numerical value of the layer sorting priority.

[0008] Furthermore, the sequence frame animation solution of the parallel computing module specifically involves: scheduling a parallel job system to simultaneously traverse all entities containing animation state components on multiple central processing unit cores, and calculating the texture coordinate region of the entity in the current frame; the calculation logic is as follows: The system simultaneously traverses entities containing animation state components across multiple CPU cores, calculates the cumulative playback time of the entities and obtains the theoretical frame number, calculates the actual frame number based on the animation playback mode and the theoretical frame number, and then extracts the corresponding texture coordinate region in the binary large object of the animation configuration based on the actual frame number, overwriting the visual data component of the entity. The method for calculating the cumulative playback time of an entity is as follows: obtain the time increment between the current frame and the previous frame of the current entity, multiply it by the playback speed multiplier of the current entity, and then add the multiplier to the original playback time of the current entity; then divide the cumulative playback time by the duration set for a single image in the animation, and take the integer part of the calculation result to obtain the theoretical frame number. The method of calculating the actual frame number based on the animation playback mode and theoretical frame number, and then extracting the corresponding texture coordinate region in the animation configuration binary large object based on the actual frame number to overwrite the visual data component written to the entity is as follows: The computer program extracts the animation configuration mode of the current entity, and the animation playback mode includes a single playback mode and a loop playback mode; When the animation playback mode is configured as loop playback mode, the theoretical frame number is used to perform a remainder operation on the total number of frames contained in the animation of the current entity, and the remainder is used as the actual frame number. When the animation playback mode is configured as single playback mode, the theoretical frame number is compared with the number of the last image of the current entity's animation, and the smaller value between the two is selected as the actual frame number to prevent reading out of bounds. Finally, based on the actual frame number obtained by the parallel computing module, the animation configuration binary large object in memory is accessed, the texture coordinate region corresponding to the animation configuration binary large object is extracted, and overwritten into the visual data component of the current entity.

[0009] Furthermore, the parallel frustum culling of the parallel computing module specifically involves the following steps: In Unity's orthographic camera mode, frustum culling is performed by conducting an intersection test of two 2D axis-aligned bounding boxes. The specific calculation logic can be broken down into the following three sub-steps: Step 1: Calculation of the 2D viewport boundary of the main camera; Step 1.1: First, the 3D camera view frustum is reduced to a 2D rectangular boundary, and then the world center coordinates of the main camera are read. ), orthogonal field of view size and screen aspect ratio ; Step 1.2: Calculate the total viewport height using the following formula: * ; in, Indicates the total height of the viewport. Indicates the total width of the viewport; Step 1.3: Calculate the viewport boundary points: Combining the center coordinates of the main camera, obtain the coordinates of the minimum and maximum points of the main camera's 2D viewport. The calculation formula is as follows: ; ; in, This represents the smallest point in the camera's two-dimensional viewport. This represents the maximum point of the camera's two-dimensional viewport; Step 2: Calculation of the bounding box of the physical world space; Step 2.1: Obtain local data of the bounding box of the physical world space, and read the world center coordinates within the bounding box of the physical world space ( ), original primitive width Original primitive height Scaling factor ( ) and the current two-dimensional rotation angle ; Step 2.2: Calculate the actual width of the bounding box in the real world after scaling. and actual height The formula is as follows: ; ; Step 2.3: Calculate the projected radius of the bounding box of the physical world space after rotation, calculate the half-length of the projected bounding box of the physical world space on both axes, including the half-length of the projected bounding box along the X-axis. and Y-axis projection half length The formula is as follows: ; ; in This represents taking the absolute value; Step 2.4: Calculate the entity boundary points of the entity world bounding box: Combine the world center coordinates of the entity world bounding box ( (This sentence appears to be incomplete and requires more context to translate accurately. It likely refers to finding the minimum point of the bounding rectangle of the entity's world space and the maximum point of the bounding rectangle.) The formula is as follows: ; ; Step 3: Determine the intersection of bounding boxes in the physical world; To determine whether two 2D axis-aligned bounding boxes intersect, the following four Boolean conditions must be met simultaneously: Condition 1, X-axis left boundary determination: the maximum X-coordinate of the bounding rectangle of the entity world's spatial bounding box. The minimum X coordinate of the camera's two-dimensional viewport, i.e. ; Condition 2, Right boundary determination on the X-axis: The minimum X-coordinate of the entity whose bounding rectangle is the outermost rectangle of the entity's world bounding box. The maximum X coordinate of the camera's two-dimensional viewport, i.e. ; Condition 3, Y-axis lower boundary determination: The maximum Y-coordinate of the entity whose bounding rectangle is the outermost rectangle of the entity's world bounding box. The minimum Y-coordinate of the camera's two-dimensional viewport, i.e.

[0010] Condition 4, Y-axis upper boundary determination: The minimum Y-coordinate of the entity whose bounding rectangle is the outermost rectangle of the entity's world space bounding box. The maximum Y-coordinate of the camera's 2D viewport, i.e. ; If all four conditions above are true, the current entity world bounding box is determined to intersect with or be completely contained within the main camera's 2D viewport, i.e., it is considered visible, and its corresponding memory index is recorded in the rendering queue; if any one of the four conditions above is false, the current entity world bounding box is determined to be completely outside the main camera's 2D viewport, i.e., it is considered invisible, and the data is directly discarded to complete the view frustum culling.

[0011] Furthermore, the data processing module specifically compares the length of the visible index list with the current capacity limit of the structured buffer in the video memory. The length of the visible index list is the total number of visible entities. If the total number of visible entities is less than or equal to the current capacity limit of the structured buffer, then the current capacity limit of the structured buffer is directly reused. If the total number of visible entities is greater than the current maximum capacity of the structured buffer, an expansion operation is performed. The current maximum capacity of the structured buffer is compared with the total number of visible entities, and the larger of the two values ​​is taken as the new buffer capacity. Then, the old buffer is released, and a contiguous space corresponding to the new buffer capacity is re-allocated in the video memory. Based on the visible index list, several threads are scheduled to read the coordinates, rotation, scaling, color, texture region and sorting priority values ​​of the corresponding entity from memory in parallel, and write these data into the pre-allocated local instance data array in sequence; The underlying graphics interface is invoked to copy the data in the local instance data array to the structured buffer of the graphics processor in one go.

[0012] Furthermore, the GPU rendering module specifically works as follows: the vertex shader reads the corresponding instance data from the structured buffer using the built-in instance identifier, extracts the layer sorting key value of the corresponding instance, and calculates the Z-axis depth offset of the corresponding instance in the 3D clipping space; the Z-axis depth offset is specifically calculated as follows: The vertex shader multiplies the read sort key value by a preset minimum precision coefficient to obtain the Z-axis depth offset; The vertex shader subtracts the calculated Z-axis depth offset from the original Z-axis spatial coordinates of the corresponding instance to obtain the final Z-axis coordinates, thereby achieving the display effect of foreground occlusion of background. Finally, the fragment shader performs pixel rendering, extracting the corresponding pixel color from the atlas file based on the texture coordinate region passed from the vertex shader, and completing the rendering output of a massive number of two-dimensional primitives in the current frame.

[0013] Furthermore, a high-performance rendering method for 2D dynamic elements based on Unity DOTS, running on the Unity engine and based on a data-oriented architecture, includes the following steps: Step 1: Allocate unmanaged contiguous memory in memory and construct a 2D primitive core component data model consisting of pure value type data structures aligned to 16 bytes. Step 2: Schedule the parallel job system and Burst compiler to perform high-concurrency sequence frame animation solving and bounding box-based parallel view frustum culling; Step 3: Perform parallel packaging of visible entity data, adapt the structured buffer capacity, and asynchronously upload the rendering data to the GPU memory; Step 4: Configure the indirect drawing parameter buffer on the CPU side and trigger the underlying indirect instantiation drawing instructions. The drawing control is transferred to the GPU side. The GPU rendering pipeline executes the custom vertex shader concurrently. The custom vertex shader realizes the dynamic depth sorting on the GPU side and completes the final rendering in combination with the fragment shader.

[0014] Furthermore, the 2D primitive core component data model includes local space components, visual data components, animation state components, and sorting key components, and entity objects with the same component combination are uniformly allocated to the same memory data block to achieve continuous storage; The local space component is used to record world coordinates, scaling ratio, and rotation angle; The visual data component is used to record the basic color and atlas texture sampling area; The animation status component is used to record the current playback time and playback speed multiplier. The sorting key component is used to record the numerical value of the layer sorting priority.

[0015] Furthermore, in step 2, the sequence frame animation calculation specifically involves: scheduling a parallel processing system to simultaneously traverse all entities containing animation state components on multiple central processing unit cores, and calculating the texture coordinate region of the entity in the current frame; the calculation logic is as follows: The system simultaneously traverses entities containing animation state components across multiple CPU cores, calculates the cumulative playback time of the entities and obtains the theoretical frame number, calculates the actual frame number based on the animation playback mode and the theoretical frame number, and then extracts the corresponding texture coordinate region in the binary large object of the animation configuration based on the actual frame number, overwriting the visual data component of the entity. The method for calculating the cumulative playback time of an entity is as follows: obtain the time increment between the current frame and the previous frame of the current entity, multiply it by the playback speed multiplier of the current entity, and then add the multiplier to the original playback time of the current entity; then divide the cumulative playback time by the duration set for a single image in the animation, and take the integer part of the calculation result to obtain the theoretical frame number. The method of calculating the actual frame number based on the animation playback mode and theoretical frame number, and then extracting the corresponding texture coordinate region in the animation configuration binary large object based on the actual frame number to overwrite the visual data component written to the entity is as follows: The computer program extracts the animation configuration mode of the current entity, and the animation playback mode includes a single playback mode and a loop playback mode; When the animation playback mode is configured as loop playback mode, the theoretical frame number is used to perform a remainder operation on the total number of frames contained in the animation of the current entity, and the remainder is used as the actual frame number. When the animation playback mode is configured as single playback mode, the theoretical frame number is compared with the number of the last image of the current entity's animation, and the smaller value between the two is selected as the actual frame number to prevent reading out of bounds. Finally, based on the actual frame number obtained by the parallel computing module, the animation configuration binary large object in memory is accessed, the texture coordinate region corresponding to the animation configuration binary large object is extracted, and overwritten into the visual data component of the current entity.

[0016] Furthermore, in step 2, the parallel view frustum culling specifically involves: in Unity's orthographic camera mode, view frustum culling is the intersection test of two 2D axis-aligned bounding boxes. The specific calculation logic can be broken down into the following three sub-steps: Step 1: Calculation of the 2D viewport boundary of the main camera; Step 1.1: First, the 3D camera view frustum is reduced to a 2D rectangular boundary, and then the world center coordinates of the main camera are read. ), orthogonal field of view size and screen aspect ratio ; Step 1.2: Calculate the total viewport height using the following formula: * ; in, Indicates the total height of the viewport. Indicates the total width of the viewport; Step 1.3: Calculate the viewport boundary points: Combining the center coordinates of the main camera, obtain the coordinates of the minimum and maximum points of the main camera's 2D viewport. The calculation formula is as follows: ; ; in, This represents the smallest point in the camera's two-dimensional viewport. This represents the maximum point of the camera's two-dimensional viewport; Step 2: Calculation of the bounding box of the physical world space; Step 2.1: Obtain local data of the bounding box of the physical world space, and read the world center coordinates within the bounding box of the physical world space ( ), original primitive width Original primitive height Scaling factor ( ) and the current two-dimensional rotation angle ; Step 2.2: Calculate the actual width of the bounding box in the real world after scaling. and actual height The formula is as follows: ; ; Step 2.3: Calculate the projected radius of the bounding box of the physical world space after rotation, calculate the half-length of the projected bounding box of the physical world space on both axes, including the half-length of the projected bounding box along the X-axis. and Y-axis projection half length The formula is as follows: ; ; in This represents taking the absolute value; Step 2.4: Calculate the entity boundary points of the entity world bounding box: Combine the world center coordinates of the entity world bounding box ( (This sentence appears to be incomplete and requires more context to translate accurately. It likely refers to finding the minimum point of the bounding rectangle of the entity's world space and the maximum point of the bounding rectangle.) The formula is as follows: ; ; Step 3: Determine the intersection of bounding boxes in the physical world; To determine whether two 2D axis-aligned bounding boxes intersect, the following four Boolean conditions must be met simultaneously: Condition 1, X-axis left boundary determination: the maximum X-coordinate of the bounding rectangle of the entity world's spatial bounding box. The minimum X coordinate of the camera's two-dimensional viewport, i.e. ; Condition 2, Right boundary determination on the X-axis: The minimum X-coordinate of the entity whose bounding rectangle is the outermost rectangle of the entity's world bounding box. The maximum X coordinate of the camera's two-dimensional viewport, i.e. ; Condition 3, Y-axis lower boundary determination: The maximum Y-coordinate of the entity whose bounding rectangle is the outermost rectangle of the entity's world bounding box. The minimum Y-coordinate of the camera's two-dimensional viewport, i.e. ; Condition 4, Y-axis upper boundary determination: The minimum Y-coordinate of the entity whose bounding rectangle is the outermost rectangle of the entity's world space bounding box. The maximum Y-coordinate of the camera's 2D viewport, i.e. ; If all four conditions above are true, the current entity world bounding box is determined to intersect with or be completely contained within the main camera's 2D viewport, i.e., it is considered visible, and its corresponding memory index is recorded in the rendering queue; if any one of the four conditions above is false, the current entity world bounding box is determined to be completely outside the main camera's 2D viewport, i.e., it is considered invisible, and the data is directly discarded to complete the view frustum culling.

[0017] Furthermore, step 3 specifically involves comparing the length of the visible index list with the current maximum capacity of the structured buffer in the video memory. The length of the visible index list represents the total number of visible entities. If the total number of visible entities is less than or equal to the current maximum capacity of the structured buffer, then the current maximum capacity of the structured buffer is directly reused. If the total number of visible entities is greater than the current maximum capacity of the structured buffer, an expansion operation is performed. The current maximum capacity of the structured buffer is compared with the total number of visible entities, and the larger of the two values ​​is taken as the new buffer capacity. Then, the old buffer is released, and a contiguous space corresponding to the new buffer capacity is re-allocated in the video memory. Based on the visible index list, several threads are scheduled to read the coordinates, rotation, scaling, color, texture region and sorting priority values ​​of the corresponding entity from memory in parallel, and write these data into the pre-allocated local instance data array in sequence; The underlying graphics interface is invoked to copy the data in the local instance data array to the structured buffer of the graphics processor in one go.

[0018] Further, step 4 specifically involves: the vertex shader reading the corresponding instance data from the structured buffer using the built-in instance identifier, extracting the layer sorting key value of the corresponding instance, and calculating the Z-axis depth offset of the corresponding instance in the 3D clipping space; the Z-axis depth offset is specifically calculated as follows: The vertex shader multiplies the read sort key value by a preset minimum precision coefficient to obtain the Z-axis depth offset; The vertex shader subtracts the calculated Z-axis depth offset from the original Z-axis spatial coordinates of the corresponding instance to obtain the final Z-axis coordinates, thereby achieving a two-dimensional hierarchical display effect where the foreground occludes the background. Finally, the fragment shader performs pixel rendering, extracting the corresponding pixel color from the atlas file based on the texture coordinate region passed from the vertex shader, and completing the rendering output of a massive number of two-dimensional primitives in the current frame.

[0019] Compared with the prior art, the present invention has the following beneficial effects: (1) Significantly improves CPU cache hit rate and completely breaks through the "memory wall" computational bottleneck: This invention adopts the Entity Component System (ECS) architecture through the data model module, decomposes 2D primitive attributes into pure value type structures aligned to 16 bytes, and centrally allocates entities with the same component combination in the same data block of unmanaged memory, so that the data is arranged in an extremely compact linear manner in physical memory. The memory fragmentation problem caused by the OOP architecture in the prior art is completely solved. When the CPU traverses tens of thousands of primitives to update the state, it can perfectly trigger the hardware high-speed cache prefetch mechanism, and the data read and write speed increases exponentially, completely breaking through the memory access bottleneck of the traditional engine.

[0020] (2) Completely eliminate garbage collection (GC) overhead to ensure extremely smooth game frame rate: In the entire process of rendering data packaging, view frustum culling, and animation data reading, the modules of this invention abandon the traditional instantiation of class objects and use unmanaged contiguous memory, unmanaged memory containers based on low-level pointer operations, and binary shared large objects (animation configuration binary large objects) to handle high-frequency data interaction, thus realizing "zero memory allocation (Zero-GC)" in the high-frequency main loop of the game. The GC stuttering problem caused by the creation / destruction of massive dynamic elements in the prior art is fundamentally eliminated, ensuring the smoothness and stability of the rendered screen.

[0021] (3) Breaking through the single-threaded computing power limit and achieving efficient parallelism of animation and culling logic: The parallel computing module of this invention decomposes the massive amount of computation, such as sequence frame animation time calculation and viewport bounding box intersection test, into independent jobs, which are scheduled to be executed simultaneously on multi-core CPUs by a parallel job system, and compiled into highly optimized SIMD native machine code by the Burst compiler. The computing power bottleneck of single-core serial computing in the main thread in the prior art has been broken through, awakening the computing power potential of multi-core processors, compressing the original single-threaded logic operation time of tens of milliseconds to sub-millisecond level (<1ms), and greatly improving the computing throughput of the system.

[0022] (4) Innovative elimination of CPU sorting computational power consumption, freeing up core game performance: The GPU rendering module of this invention innovatively adopts a GPU dynamic sorting mechanism based on vertex shaders. The CPU only needs to pass the layer sorting key value to the GPU, which converts the key value into a Z-axis depth offset and uses the hardware-level depth buffer (Z-Buffer) to test and complete the two-dimensional occlusion. The O(N log N) full sorting performed by the CPU per frame in the prior art is replaced, and the sorting time of the CPU is directly reduced to 0, freeing up valuable computing cycles for core game gameplay (such as massive AI pathfinding and complex physical collisions).

[0023] (5) Minimize rendering instruction submission overhead and achieve a leap in rendering volume of tens of thousands of elements on the same screen: The data processing module of this invention packages visible graphic data in parallel and uploads it to the GPU structured buffer at once. The GPU rendering module only issues a single-digit number of indirect drawing instructions to drive the rendering. The problem of massive DrawCalls caused by dynamic batching in the prior art is solved. The CPU is completely freed from the lengthy rendering instruction preparation process. In actual tests, only a single-digit number of Draw Calls are needed to smoothly render more than 5,000 to 10,000 dynamic 2D primitives. On mobile devices, full-frame rendering of 60FPS+ can be achieved. The rendering throughput is more than 5 times that of traditional technology, and a leapfrog improvement in the rendering volume on the same screen is achieved. Attached Figure Description

[0024] Figure 1 This is a system logic block diagram of the present invention; Figure 2 This is a flowchart of the method. Detailed Implementation

[0025] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments.

[0026] See Figure 1 A high-performance rendering system for 2D dynamic elements based on Unity DOTS The system is built on a data-oriented architecture and includes a data model module, a parallel computing module, a data processing module, and a GPU rendering module. These modules work together to achieve high-performance rendering of massive amounts of dynamic 2D elements. The specific functions and features of each module are as follows: Data Model Module: Used to allocate unmanaged contiguous memory in memory and construct a 2D primitive core component data model consisting of pure value type data structures aligned to sixteen bytes; The 2D primitive core component data model includes local space components, visual data components, animation state components, and sorting key components. The data model module uniformly allocates entity objects with the same component combination to the same memory data block to achieve physical continuous storage of entity data. Among them, the local space component is used to record world coordinates, scaling ratio and rotation angle; the visual data component is used to record basic color and atlas texture sampling area; the animation status component is used to record the current playback time and playback speed multiplier; and the sorting key component is used to record the value of layer sorting priority.

[0027] Parallel computing module: Schedules the parallel job system and Burst compiler to perform high-concurrency sequence frame animation solving and bounding box-based parallel view frustum culling, specifically including: High-concurrency sequence frame animation resolution: The parallel job system is scheduled to simultaneously traverse all entities containing animation state components on multiple central processing unit cores and calculate the texture coordinate region of the entity in the current frame. The calculation logic is as follows: First, the cumulative playback time of the entity is calculated to obtain the theoretical frame number. Then, the actual frame number is calculated according to the animation playback mode and the theoretical frame number. Finally, the corresponding texture coordinate region in the binary large object of animation configuration is extracted according to the actual frame number and overwritten into the visual data component of the entity. The method for calculating the cumulative playback time of an entity is as follows: obtain the time increment between the current frame and the previous frame of the current entity, multiply it by the playback speed multiplier of the current entity, and then add the multiplier to the original playback time of the current entity. The theoretical frame number is obtained by dividing the accumulated playback time by the duration of a single animation image, and then taking the integer part. The animation playback modes include loop playback mode and single playback mode. When the animation playback mode is configured as loop playback mode, the theoretical frame number is used to perform a remainder operation on the total number of frames contained in the animation of the current entity, and the remainder is used as the actual frame number. When the animation playback mode is configured as single playback mode, the theoretical frame number is compared with the number of the last image of the current entity's animation, and the smaller value between the two is selected as the actual frame number to prevent reading out of bounds. Finally, based on the actual frame number obtained by the parallel computing module, the animation configuration binary large object in memory is accessed, the texture coordinate region corresponding to the animation configuration binary large object is extracted, and overwritten into the visual data component of the current entity.

[0028] Parallel frustum culling based on bounding boxes: Extract the frustum parameters of the main camera and map the main camera frustum parameters to the two-dimensional viewport boundary, read the local spatial components of the current entity and calculate the entity bounding box in world space in combination with the scaling value, and determine whether the boundary point of the entity bounding box is located within the two-dimensional viewport boundary of the main camera. If the current entity's bounding box intersects with or is completely contained within the 2D viewport boundary, the entity's unique memory index will be extracted and appended to a contiguous list of visible indices; if the entity's bounding box is completely outside the 2D viewport boundary, the entity's index will be discarded.

[0029] Specifically, the parallel frustum culling of the parallel computing module is as follows: In Unity's orthographic camera mode, frustum culling involves performing an intersection test on two 2D axis-aligned bounding boxes. The specific calculation logic can be broken down into the following three sub-steps: Step 1: Calculation of the 2D viewport boundary of the main camera; Step 1.1: First, the 3D camera view frustum is reduced to a 2D rectangular boundary, and then the world center coordinates of the main camera are read. ), orthogonal field of view size and screen aspect ratio ; Step 1.2: Calculate the total viewport height using the following formula: * ; in, Indicates the total height of the viewport. Indicates the total width of the viewport; Step 1.3: Calculate the viewport boundary points: Combining the center coordinates of the main camera, obtain the coordinates of the minimum and maximum points of the main camera's 2D viewport. The calculation formula is as follows: ; ; in, This represents the smallest point in the camera's two-dimensional viewport. This represents the maximum point of the camera's two-dimensional viewport; Step 2: Calculation of the bounding box of the physical world space; Step 2.1: Obtain local data of the bounding box of the physical world space, and read the world center coordinates within the bounding box of the physical world space ( ), original primitive width Original primitive height Scaling factor ( ) and the current two-dimensional rotation angle ; Step 2.2: Calculate the actual width of the bounding box in the real world after scaling. and actual height The formula is as follows: ; ;

[0030] Step 2.3: Calculate the projected radius of the bounding box of the physical world space after rotation, calculate the half-length of the projected bounding box of the physical world space on both axes, including the half-length of the projected bounding box along the X-axis. and Y-axis projection half length The formula is as follows: ; ; in This represents taking the absolute value; Step 2.4: Calculate the entity boundary points of the entity world bounding box: Combine the world center coordinates of the entity world bounding box ( (This sentence appears to be incomplete and requires more context to translate accurately. It likely refers to finding the minimum point of the bounding rectangle of the entity's world space and the maximum point of the bounding rectangle.) The formula is as follows: ; ; Step 3: Determine the intersection of bounding boxes in the physical world; To determine whether two 2D axis-aligned bounding boxes intersect, the following four Boolean conditions must be met simultaneously: Condition 1, X-axis left boundary determination: the maximum X-coordinate of the bounding rectangle of the entity world's spatial bounding box. The minimum X coordinate of the camera's two-dimensional viewport, i.e. ; Condition 2, Right boundary determination on the X-axis: The minimum X-coordinate of the entity whose bounding rectangle is the outermost rectangle of the entity's world bounding box. The maximum X coordinate of the camera's two-dimensional viewport, i.e. ; Condition 3, Y-axis lower boundary determination: The maximum Y-coordinate of the entity whose bounding rectangle is the outermost rectangle of the entity's world bounding box. The minimum Y-coordinate of the camera's two-dimensional viewport, i.e. ; Condition 4, Y-axis upper boundary determination: The minimum Y-coordinate of the entity whose bounding rectangle is the outermost rectangle of the entity's world space bounding box. The maximum Y-coordinate of the camera's 2D viewport, i.e. ;

[0031] If all four conditions above are true, the current entity world bounding box is determined to intersect with or be completely contained within the main camera's 2D viewport, i.e., it is considered visible, and its corresponding memory index is recorded in the rendering queue; if any one of the four conditions above is false, the current entity world bounding box is determined to be completely outside the main camera's 2D viewport, i.e., it is considered invisible, and the data is directly discarded to complete the view frustum culling.

[0032] Parallel operation system, in the existing technology, Unity operation system supports the construction of multi-threaded code logic, which allows the application to fully call all available CPU cores to perform calculations. By efficiently utilizing the hardware resources of each CPU core, it avoids all code being concentrated on a single CPU core to run, thereby improving program performance; therefore, this invention is named parallel operation system.

[0033] The present invention defines the Burst compiler as follows: Although the task system can be used independently, existing technologies typically work in conjunction with the Burst compiler to further optimize execution efficiency; the compiler performs specific compilation optimizations for the Unity task system, which can improve code generation efficiency, thereby enhancing program performance and reducing power consumption of mobile terminal devices.

[0034] Data processing module: Performs parallel packaging of visible entity data, adapts structured buffer capacity, and asynchronously uploads rendering data to GPU memory. Specific operations include: By comparing the length of the visible index list with the upper limit of the current structured buffer capacity in the video memory, the length of the visible index list can be used to determine the total number of visible entities; if the total number of visible entities is less than or equal to the upper limit of the current structured buffer capacity, the upper limit of the current structured buffer capacity is directly reused. If the total number of visible entities is greater than the current maximum capacity of the structured buffer, an expansion operation is performed. The current maximum capacity of the structured buffer is compared with the total number of visible entities, and the larger of the two values ​​is taken as the new buffer capacity. Then, the old buffer is released, and a contiguous space corresponding to the new buffer capacity is re-allocated in the video memory. Based on the visible index list, several threads are scheduled to read the coordinates, rotation, scaling, color, texture region and sorting priority values ​​of the corresponding entity from memory in parallel, and write these data into the pre-allocated local instance data array in sequence; The underlying graphics interface is invoked to copy the data in the local instance data array to the structured buffer of the graphics processor in one go.

[0035] GPU rendering module: Configures indirect drawing parameter buffer on the CPU side and triggers the underlying indirect instantiation drawing instructions. Drawing control is transferred to the GPU side. The GPU rendering pipeline executes custom vertex shaders concurrently. Dynamic depth sorting on the GPU side is achieved through custom vertex shaders. The final rendering is completed in combination with fragment shaders. Indirect instantiation drawing instructions submit all drawing data to the GPU at once. This causes the GPU to be unaware of the drawing order and occlusion relationship between the data. The GPU executes the data in parallel, but the actual game screen requires the correct occlusion relationship between 2D elements. Applying the sorting algorithm of this invention, the GPU calculates the occlusion relationship, which is a dynamic sorting performed on the GPU side. Specifically: The vertex shader reads the corresponding instance data from the structured buffer using the built-in instance identifier, extracts the layer sort key value of the corresponding instance, and calculates the Z-axis depth offset of the corresponding instance in 3D clipping space; the Z-axis depth offset is specifically calculated as follows: The vertex shader reads the sort key value and multiplies it by a preset minimal precision coefficient to obtain the Z-axis depth offset. This precision coefficient is set small enough to ensure that the final calculated offset does not cause the primitive to exceed the camera's visible depth range.

[0036] The vertex shader subtracts the calculated Z-axis depth offset from the original Z-axis spatial coordinates of the corresponding instance to obtain the final Z-axis coordinates, thereby achieving a two-dimensional hierarchical display effect where the foreground occludes the background. The final Z-axis coordinate is the sole basis for the GPU hardware to perform the "Depth Test (Z-Test)". The result of the depth test directly determines whether the fragment shader needs to be executed.

[0037] The responsibilities of the vertex shader: One of the main tasks of the vertex shader is to calculate the final coordinates (a float4 vector) of each vertex in clip space. The x and y components of this coordinate determine the vertex's two-dimensional position on the screen, while the z component, after subsequent perspective division, becomes the depth value of that pixel in normalized device coordinates. This depth value is written to the GPU's hardware cache—the depth buffer (Z-Buffer).

[0038] When to execute depth tests: Before the vertex shader finishes execution and enters the fragment shader, the GPU's rasterizer performs a depth test for each pixel that is about to be drawn.

[0039] Test logic: The GPU reads the depth value of the current pixel in the depth buffer (usually the depth of the previously drawn object closest to the camera) and compares it with the depth value of the pixel being drawn.

[0040] Judgment rule: If the depth value of the current pixel is "better" (e.g., smaller, indicating closer to the camera, using a comparison function such as Less Equal) than the value in the depth buffer, the test passes. Otherwise, the test fails.

[0041] Causal relationship with fragment shaders: If the depth test passes, it means that the current pixel occludes all previously drawn pixels and is visible. The GPU updates the depth buffer to the new, closer value and continues executing the fragment shader, calculating the final color of the pixel and writing it to the color buffer.

[0042] If the depth test fails, it means that the current pixel is occluded by a closer object and is not visible. The GPU will discard this pixel directly and will not execute the expensive fragment shader.

[0043] The GPU's graphics rendering pipeline generates the depth value of the corresponding pixel based on the final Z-axis coordinate, and uses a hardware depth testing unit to compare the depth value with the depth value already stored in the depth buffer.

[0044] If the depth test passes, it means the current pixel is not occluded, and the GPU continues to execute subsequent fragment shader rendering; if the depth test fails, it means the current pixel is occluded, and the GPU discards the pixel directly and does not execute the fragment shader. Through this hardware-automated occlusion detection mechanism, a two-dimensional hierarchical display effect of foreground occlusion of background is achieved.

[0045] Finally, the fragment shader performs pixel rendering, extracting the corresponding pixel color from the atlas file based on the texture coordinate region passed from the vertex shader, and completing the rendering output of a massive number of two-dimensional primitives in the current frame.

[0046] The texture coordinate region, as the output of the vertex shader, is "interpolated" by the rasterization unit and then passed as input to the fragment shader.

[0047] Output of the vertex shader: The vertex shader not only calculates the final clipping space coordinates of the vertices, but also outputs other properties that need to be used in the fragment shader; these properties are called variables.

[0048] The UVRegion (a float4 representing the position and size in the atlas) read from the GraphicsBuffer is computed in the vertex shader with the vertex’s original local UV (usually a quadrilateral in the range of 0-1) to obtain the final sampled UV coordinates of the vertex in the larger atlas.

[0049] The final UV coordinates, along with the colors, will be packaged into an output structure and returned as the vertex shader's return value.

[0050] Interpolation work of rasterization units: The task of the rasterization unit is to calculate all the pixels that the triangle covers on the screen based on the three vertices of the triangle.

[0051] For each pixel it generates, it automatically performs perspective correction interpolation on the variables output by the vertex shader.

[0052] In simple terms, it calculates the UV coordinates that a pixel "should" have by taking a weighted average of the UV coordinates of the three vertices of the triangle based on the distance of the pixel from the triangle.

[0053] Inputs to the fragment shader: The UV coordinates, colors, etc., calculated by rasterization unit interpolation become the input parameters of the fragment shader.

[0054] Once the fragment shader has the pre-interpolated, pixel-accurate UV coordinates, it can use them to sample the texture atlas and extract the correct colors.

[0055] The vertex shader reads atlas sampling information from the structured buffer, calculates the vertex's local UV coordinates, generates the final sampled coordinates of the vertex in the atlas file, and passes these final sampled coordinates as output variables to the rasterization unit of the graphics rendering pipeline.

[0056] When generating each pixel, the rasterization unit performs linear interpolation on the final sampled coordinates of the triangle vertex to calculate the precise sampled coordinates of the pixel, and passes them as input parameters to the fragment shader.

[0057] See Figure 2 A high-performance rendering method for 2D dynamic elements based on Unity DOTS: Step 1: Allocate unmanaged contiguous memory in memory and construct a 2D primitive core component data model consisting of pure value type data structures aligned to 16 bytes. Step 2: Schedule the parallel job system and Burst compiler to perform high-concurrency sequence frame animation solving and bounding box-based parallel view frustum culling; Step 3: Perform parallel packaging of visible entity data, adapt the structured buffer capacity, and asynchronously upload the rendering data to the GPU memory; Step 4: Configure the indirect drawing parameter buffer on the CPU side and trigger the underlying indirect instantiation drawing instructions. The drawing control is transferred to the GPU side. The GPU rendering pipeline executes the custom vertex shader concurrently. The custom vertex shader realizes the dynamic depth sorting on the GPU side and completes the final rendering in combination with the fragment shader.

[0058] In one embodiment of the present invention, the 2D primitive core component data model includes a local space component, a visual data component, an animation state component, and a sorting key component, and entity objects with the same component combination are uniformly allocated to the same memory data block to achieve continuous storage; The local space component is used to record world coordinates, scaling ratio, and rotation angle; The visual data component is used to record the basic color and atlas texture sampling area; The animation status component is used to record the current playback time and playback speed multiplier. The sorting key component is used to record the numerical value of the layer sorting priority.

[0059] In one embodiment of the present invention, step 2, specifically the sequence frame animation calculation, involves: scheduling a parallel processing system to simultaneously traverse all entities containing animation state components on multiple central processing unit cores, and calculating the texture coordinate region of the entity in the current frame; the calculation logic is as follows: The system simultaneously traverses entities containing animation state components across multiple CPU cores, calculates the cumulative playback time of the entities and obtains the theoretical frame number, calculates the actual frame number based on the animation playback mode and the theoretical frame number, and then extracts the corresponding texture coordinate region in the binary large object of the animation configuration based on the actual frame number, overwriting the visual data component of the entity. The method for calculating the cumulative playback time of an entity is as follows: obtain the time increment between the current frame and the previous frame of the current entity, multiply it by the playback speed multiplier of the current entity, and then add the multiplier to the original playback time of the current entity; then divide the cumulative playback time by the duration set for a single image in the animation, and take the integer part of the calculation result to obtain the theoretical frame number. The method of calculating the actual frame number based on the animation playback mode and theoretical frame number, and then extracting the corresponding texture coordinate region in the animation configuration binary large object based on the actual frame number to overwrite the visual data component written to the entity is as follows: The computer program extracts the animation configuration mode of the current entity, and the animation playback mode includes a single playback mode and a loop playback mode; When the animation playback mode is configured as loop playback mode, the theoretical frame number is used to perform a remainder operation on the total number of frames contained in the animation of the current entity, and the remainder is used as the actual frame number. When the animation playback mode is configured as single playback mode, the theoretical frame number is compared with the number of the last image of the current entity's animation, and the smaller value between the two is selected as the actual frame number to prevent reading out of bounds. Finally, based on the actual frame number obtained by the parallel computing module, the animation configuration binary large object in memory is accessed, the texture coordinate region corresponding to the animation configuration binary large object is extracted, and overwritten into the visual data component of the current entity.

[0060] In one embodiment of the present invention, step 2, specifically, involves the parallel frustum culling as follows: In Unity's orthographic camera mode, frustum culling involves performing an intersection test of two 2D axis-aligned bounding boxes. The specific calculation logic can be broken down into the following three sub-steps: Step 1: Calculation of the 2D viewport boundary of the main camera; Step 1.1: First, the 3D camera view frustum is reduced to a 2D rectangular boundary, and then the world center coordinates of the main camera are read. ), orthogonal field of view size and screen aspect ratio ; Step 1.2: Calculate the total viewport height using the following formula: * ; in, Indicates the total height of the viewport. Indicates the total width of the viewport; Step 1.3: Calculate the viewport boundary points: Combining the center coordinates of the main camera, obtain the coordinates of the minimum and maximum points of the main camera's 2D viewport. The calculation formula is as follows: ; ; in, This represents the smallest point in the camera's two-dimensional viewport. This represents the maximum point of the camera's two-dimensional viewport; Step 2: Calculation of the bounding box of the physical world space; Step 2.1: Obtain local data of the bounding box of the physical world space, and read the world center coordinates within the bounding box of the physical world space ( ), original primitive width Original primitive height Scaling factor ( ) and the current two-dimensional rotation angle ; Step 2.2: Calculate the actual width of the bounding box in the real world after scaling. and actual height The formula is as follows: ; ; Step 2.3: Calculate the projected radius of the bounding box of the physical world space after rotation, calculate the half-length of the projected bounding box of the physical world space on both axes, including the half-length of the projected bounding box along the X-axis. and Y-axis projection half length The formula is as follows: ; ; in This represents taking the absolute value; Step 2.4: Calculate the entity boundary points of the entity world bounding box: Combine the world center coordinates of the entity world bounding box ( (This sentence appears to be incomplete and requires more context to translate accurately. It likely refers to finding the minimum point of the bounding rectangle of the entity's world space and the maximum point of the bounding rectangle.) The formula is as follows: ; ; Step 3: Determine the intersection of bounding boxes in the physical world; To determine whether two 2D axis-aligned bounding boxes intersect, the following four Boolean conditions must be met simultaneously: Condition 1, X-axis left boundary determination: the maximum X-coordinate of the bounding rectangle of the entity world's spatial bounding box. The minimum X coordinate of the camera's two-dimensional viewport, i.e. ; Condition 2, Right boundary determination on the X-axis: The minimum X-coordinate of the entity whose bounding rectangle is the outermost rectangle of the entity's world bounding box. The maximum X coordinate of the camera's two-dimensional viewport, i.e. ; Condition 3, Y-axis lower boundary determination: The maximum Y-coordinate of the entity whose bounding rectangle is the outermost rectangle of the entity's world bounding box. The minimum Y-coordinate of the camera's two-dimensional viewport, i.e. ; Condition 4, Y-axis upper boundary determination: The minimum Y-coordinate of the entity whose bounding rectangle is the outermost rectangle of the entity's world space bounding box. The maximum Y-coordinate of the camera's 2D viewport, i.e. ; If all four conditions above are true, the current entity world bounding box is determined to intersect with or be completely contained within the main camera's 2D viewport, i.e., it is considered visible, and its corresponding memory index is recorded in the rendering queue; if any one of the four conditions above is false, the current entity world bounding box is determined to be completely outside the main camera's 2D viewport, i.e., it is considered invisible, and the data is directly discarded to complete the view frustum culling.

[0061] In one embodiment of the present invention, step 3 specifically involves: comparing the length of the visible index list with the upper limit of the current structured buffer capacity in the video memory, wherein the length of the visible index list is the total number of visible entities; if the total number of visible entities is less than or equal to the upper limit of the current structured buffer capacity, then the upper limit of the current structured buffer capacity is directly reused. If the total number of visible entities is greater than the current maximum capacity of the structured buffer, an expansion operation is performed. The current maximum capacity of the structured buffer is compared with the total number of visible entities, and the larger of the two values ​​is taken as the new buffer capacity. Then, the old buffer is released, and a contiguous space corresponding to the new buffer capacity is re-allocated in the video memory. Based on the visible index list, several threads are scheduled to read the coordinates, rotation, scaling, color, texture region and sorting priority values ​​of the corresponding entity from memory in parallel, and write these data into the pre-allocated local instance data array in sequence; Assuming the visible index list is 8000 long, Unity's underlying parallel job system will automatically split these 8000 tasks into several batches (e.g., 64 data points per batch) based on the current hardware capabilities (e.g., a mobile phone with 8 CPU cores). These batches will then be automatically assigned to 8 background worker threads for simultaneous processing.

[0062] The underlying graphics interface is invoked to copy the data in the local instance data array to the structured buffer of the graphics processor in one go.

[0063] In the C# development layer of the Unity engine, the specific interface called is GraphicsBuffer.SetData(). In the code implementation, the array type used to store local instance data is usually the unmanaged container NativeArray. <gpuinstancedata>The buffer in video memory is GraphicsBuffer.

[0064] The specific interface call code for copying data from memory to video memory is as follows: Code C# / / graphicsBuffer is the video memory buffer, and instanceDataArray is a locally allocated memory array. graphicsBuffer.SetData(instanceDataArray); Lower-level graphics API mapping: When Unity calls `SetData()`, the engine's underlying C++ code automatically maps and calls the actual system-level graphics APIs based on the graphics system supported by the phone or computer. For example: In a Vulkan environment, copying is achieved by mapping to something like vkCmdCopyBuffer or by using memory mapping vkMapMemory.

[0065] In the Metal (Apple iOS) environment, it will map MTLBuffer.contents() to write or blitCommandEncoder.

[0066] In the OpenGL ES 3.1+ (old Android) environment, it will map glBufferSubData or glMapBufferRange.

[0067] In a DirectX 11 / 12 (Windows PC) environment, it will map instructions such as ID3D11DeviceContext::UpdateSubresource.

[0068] In one embodiment of the present invention, step 4 specifically involves: the vertex shader reading the corresponding instance data in the structured buffer through the built-in instance identifier, extracting the layer sorting key value of the corresponding instance, and the vertex shader calculating the Z-axis depth offset of the corresponding instance in the 3D clipping space; the Z-axis depth offset is specifically calculated as follows: The vertex shader multiplies the read sort key value by a preset minimum precision coefficient to obtain the Z-axis depth offset; The vertex shader subtracts the calculated Z-axis depth offset from the original Z-axis spatial coordinates of the corresponding instance to obtain the final Z-axis coordinates, thereby achieving a two-dimensional hierarchical display effect where the foreground occludes the background. Finally, the fragment shader performs pixel rendering, extracting the corresponding pixel color from the atlas file based on the texture coordinate region passed from the vertex shader, and completing the rendering output of a massive number of two-dimensional primitives in the current frame.

[0069] The following specific embodiment is provided to further illustrate the present invention: The system and method of this invention run on the Unity engine and are automatically executed by a computer program (entity component system instructions and vertex shaders on the Unity engine). The four modules of the system correspond one-to-one with the four steps of the method, working together to complete the rendering of massive amounts of 2D dynamic elements. The specific implementation process is as follows: Step 1: Build and initialize a 2D rendering data model based on a data-oriented architecture (executed by the data model module). The computer program allocates unmanaged contiguous memory in memory, defines a pure value type data structure aligned to 16 bytes, and constructs a 2D primitive core component data model containing a local space component, a visual data component, an animation state component, and a sorting key component. Among them, the local space component records the world coordinates, scaling ratio, and rotation angle of the primitive; the visual data component records the basic color and atlas texture sampling area; the animation state component records the current playback time and playback speed multiplier; and the sorting key component records the layer sorting priority value.

[0070] The program allocates entity objects with the same component combination to the same memory data block, realizing continuous data storage at the physical level and improving CPU cache read hit rate.

[0071] Step 2: Perform high-concurrency sequence frame animation solving and bounding box-based parallel view frustum culling (executed by the parallel computing module). 2.1 High-concurrency sequence frame animation calculation The program schedules a parallel job system that simultaneously traverses all entities containing animation state components across multiple CPU cores, calculating the texture coordinates of each entity in the current frame. The specific calculation and judgment process is illustrated with numerical examples. Calculate the cumulative playback time and theoretical frame number: Simultaneously traverse entities containing animation state components on multiple CPU cores, calculate the cumulative playback time of the entities and obtain the theoretical frame number, determine the actual frame number according to the animation playback mode, and then extract the corresponding texture coordinate area in the animation configuration binary large object based on the actual frame number, and overwrite the visual data component of the entity. The method for calculating the cumulative playback time of an entity and obtaining the theoretical frame number is as follows: obtain the time increment between the current frame and the previous frame of the current entity, multiply it by the playback speed multiplier of the current entity, and then add the multiplier to the original playback time of the current entity; then divide the cumulative playback time by the duration set for a single image in the animation, and take the integer part of the calculation result to obtain the theoretical frame number. The actual frame number is calculated based on the animation playback mode and the theoretical frame number as follows: The computer program extracts the animation configuration mode of the current entity, and the animation playback mode includes a single playback mode and a loop playback mode; Loop Playback Mode: For example, if an explosion effect lasts approximately 0.016 seconds per frame and the normal playback speed is 1, then the time increment between the current frame and the previous frame is 0.016 seconds, resulting in a cumulative playback time of 0.55 seconds. Assuming the duration of a single image in this explosion animation is set to 0.1 seconds, and the entire animation consists of 5 images (5 frames in total), the system divides 0.55 by 0.1 to obtain the theoretical frame number 5. Then, it divides 5 by the total number of frames (5) and calculates the remainder, resulting in 0. This means the actual frame number is reset to zero, and the animation restarts looping from the first image.

[0072] Single Playback Mode: Assume a character's death animation also accumulates to 0.55 seconds, with the same single-frame duration and total frame count as the previous example. The theoretical frame number is calculated to be 5. The last image in this animation has a frame number of 4 (i.e., 5 frames minus 1). The system compares 5 and 4, selecting the smaller value of 4. Therefore, the animation will remain at the last image (frame number 4) and will not loop.

[0073] Texture coordinate update: Access the animation configuration binary large object in memory according to the actual frame number, extract the corresponding texture coordinate area (such as the coordinate range of the upper right quarter of the atlas), and overwrite the visual data component written to this entity.

[0074] 2.2 Bounding Box-Based Parallel Frustum Canceling The program extracts the main camera's view frustum parameters and maps them to a two-dimensional viewport boundary. It reads the local spatial components of the current entity and calculates the entity bounding box in world space by combining the scaling value. It then determines whether the boundary points of the entity bounding box are located within the two-dimensional viewport boundary of the main camera. If the current entity's bounding box intersects with or is completely contained within the 2D viewport boundary, the entity's unique memory index will be extracted and appended to a contiguous list of visible indices; if the entity's bounding box is completely outside the 2D viewport boundary, the entity's index will be discarded.

[0075] This step allows the computer to dynamically filter out objects off-screen, significantly reducing the burden on subsequent data packaging and rendering.

[0076] Step 3: Parallel packaging and structured buffering of rendered data for uploading (executed by the data processing module) By comparing the length of the visible index list with the upper limit of the current structured buffer capacity in the video memory, the length of the visible index list can be used to determine the total number of visible entities; if the total number of visible entities is less than or equal to the upper limit of the current structured buffer capacity, the upper limit of the current structured buffer capacity is directly reused. If the total number of visible entities is greater than the current maximum capacity of the structured buffer, an expansion operation is performed. The current maximum capacity of the structured buffer is compared with the total number of visible entities, and the larger of the two values ​​is taken as the new buffer capacity. Then, the old buffer is released, and a contiguous space corresponding to the new buffer capacity is re-allocated in the video memory. Based on the visible index list, several threads are scheduled to read the coordinates, rotation, scaling, color, texture region and sorting priority values ​​of the corresponding entity from memory in parallel, and write these data into the pre-allocated local instance data array in sequence; The underlying graphics interface is invoked to copy the data in the local instance data array to the structured buffer of the graphics processor in one go.

[0077] For example, Example 1: Structured buffer capacity determination and dynamic expansion logic Assume that during system initialization, the maximum capacity of the current structured buffer allocated in video memory is 10,000 (i.e., it can hold a maximum of 10,000 entity data). In different frames of the game, based on the visible index list generated after frustum culling, the system executes the following different decision branches: Scenario A (Reusing the Current Buffer): At frame 100, after frustum culling, the length of the visible index list (total number of visible entities) is 8500. The program compares 8500 with the current buffer capacity of 10000. Since 8500 is less than 10000, the system does not perform expansion and directly reuses the current structured buffer with a capacity of 10000 to avoid unnecessary memory allocation overhead.

[0078] Scenario B (Expanding by 1.5 times): At frame 150, the player unleashes a large-scale full-screen skill, causing the total number of visible entities to surge to 12,000. The program determines that 12,000 is greater than the current buffer capacity of 10,000, triggering an expansion operation. The program calculates 1.5 times the current capacity (10,000 × 1.5 = 15,000) and compares this value of 15,000 with the total number of visible entities of 12,000. The program extracts the larger value, 15,000, as the new buffer capacity. Subsequently, the program releases the original buffer and allocates a contiguous space in video memory to accommodate 15,000 entity data. This mechanism reserves buffer margin to prevent frequent expansion triggers when the number of entities fluctuates slightly in subsequent frames.

[0079] Scenario C (Expansion based on actual surge): At frame 200, a large number of monsters suddenly spawn in the scene, causing the total number of visible entities to surge to 20,000. At this point, the current buffer capacity remains at 15,000 (after the previous expansion). The program determines that 20,000 is greater than 15,000 and triggers expansion again. The program calculates 1.5 times the current capacity (15,000 × 1.5 = 22,500) and compares 22,500 with the total number of visible entities of 20,000. The larger value, 22,500, is extracted as the new buffer capacity, and new space is allocated in video memory.

[0080] Example 2: Multi-threaded parallel reading and structured buffered upload logic Assuming that after the capacity determination described above, the length of the currently visible index list is 8000, the list records the unique memory address indices of 8000 entities scattered across different data blocks in main memory.

[0081] 1. Parallel Task Splitting and Data Writing: The underlying multi-threaded job system of the system scheduling divides these 8000 read tasks into multiple batches. For example, four physical cores of the central processing unit (i.e., four worker threads) are allocated, with each thread responsible for processing 2000 index data.

[0082] Thread 1 is responsible for reading the entity data corresponding to indices 0 to 1999 in the visible list.

[0083] Thread 2 is responsible for reading the entity data corresponding to indices 2000 to 3999 in the visible list.

[0084] During the read operation, each thread precisely extracts the entity's coordinates, rotation, scale, color, texture region, and sort priority values ​​from main memory based on the obtained entity index. To avoid multi-threaded write conflicts, each thread directly uses the entity's rank in the visible index list as the index for writing to the pre-allocated local instance data array. For example, after thread 2 reads the entity data at rank 2005 in the visible list, it directly packages the extracted values ​​into an instance data structure and writes it to the 2005th storage slot of the local instance data array.

[0085] 2. One-time Low-Level Interface Upload: After all background threads have completed the extraction and array packaging of the aforementioned 8000 entity data points, the main thread takes over the operation. The main thread calls the low-level graphics interface of the graphics processor (e.g., calling the GraphicsBuffer.SetData interface in the Unity engine) to asynchronously copy the local instance data array containing the complete data of these 8000 entities as a contiguous block of binary data across the bus to the structured buffer in video memory in one go. This "batch packaging, one-time transmission" method completely eliminates the high communication latency caused by submitting each object to the graphics card one by one in traditional rendering.

[0086] Step 4: Custom vertex sorting and indirect batch rendering on the graphics processor side (executed by the GPU rendering module) The program configures an indirect drawing parameter buffer on the CPU (writing the total number of entities that actually need to be drawn into it), triggers the underlying indirect instantiation drawing instructions, and transfers drawing control to the GPU. The GPU rendering pipeline concurrently executes the custom vertex shader and fragment shader to complete the final rendering. The GPU-side dynamic depth sorting is illustrated with numerical examples: The vertex shader reads the corresponding instance data in the structured buffer through the built-in instance identifier, extracts the layer sorting key value of the corresponding instance, and calculates the Z-axis depth offset of the corresponding instance in the 3D clipping space. For example: Suppose there are two semi-transparent primitives overlapping on the same screen. The sort key value of the background primitive A is 10, and the sort key value of the foreground primitive B is 500. The original Z-axis coordinates of both are 0.0.

[0087] Calculate the Z-axis depth offset: The system presets the minimum precision coefficient to be 0.0001. The offset of element A = 10 × 0.0001 = 0.001, and the offset of element B = 500 × 0.0001 = 0.050.

[0088] Calculate the final Z-axis coordinates: The final Z-axis coordinate of primitive A = 0.0 - 0.001 = -0.001, and the final Z-axis coordinate of primitive B = 0.0 - 0.050 = -0.050. Primitive B's Z-axis coordinate is closer to the camera, and the GPU hardware depth testing unit automatically retains the pixels of primitive B to achieve a two-dimensional layered display effect where the foreground occludes the background.

[0089] Pixel rendering: The fragment shader extracts the corresponding pixel color from the atlas file based on the texture coordinate region transmitted by the visual data component, and completes the rendering output of 10,000 dynamic 2D primitives in the current frame.

[0090] In this embodiment, through the execution of the above four steps, the system and method of the present invention achieve smooth rendering of 10,000 dynamic 2D primitives at 60FPS+ on a mobile device. Compared with traditional Unity2D rendering technology, the CPU computing power usage is reduced by more than 80%, and the number of Draw Calls is reduced from thousands to thousands, completely solving the performance bottleneck of rendering massive 2D dynamic elements.

[0091] The above description is merely an embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.< / gpuinstancedata>

Claims

1. A high-performance rendering system for 2D dynamic elements based on Unity DOTS, running on the Unity engine, characterized in that, The system is built on a data-oriented architecture and includes a data model module, a parallel computing module, a data processing module, and a GPU rendering module. The data model module is used to allocate unmanaged contiguous memory in memory and construct a 2D primitive core component data model composed of pure value type data structures aligned to sixteen bytes. The parallel computing module schedules the parallel job system and the Burst compiler to perform high-concurrency sequence frame animation solving and parallel view frustum culling of entity bounding boxes; The data processing module performs parallel packaging of visible entity data, adapts the structured buffer capacity, and asynchronously uploads the rendering data to the GPU's structured cache. The GPU rendering module configures an indirect drawing parameter buffer on the CPU side and triggers the underlying indirect instantiation drawing instructions. The drawing control is transferred to the GPU side, and the GPU rendering pipeline executes a custom vertex shader concurrently. The custom vertex shader realizes dynamic depth sorting on the GPU side, and the final rendering is completed in combination with the fragment shader.

2. The high-performance rendering system for 2D dynamic elements based on Unity DOTS according to claim 1, characterized in that, The 2D primitive core component data model includes local space components, visual data components, animation state components, and sorting key components, and entity objects with the same component combination are uniformly allocated to the same memory data block to achieve continuous storage; The local space component is used to record world coordinates, scaling ratio, and rotation angle; The visual data component is used to record the basic color and atlas texture sampling area; The animation status component is used to record the current playback time and playback speed multiplier. The sorting key component is used to record the numerical value of the layer sorting priority.

3. The high-performance rendering system for 2D dynamic elements based on Unity DOTS according to claim 2, characterized in that, The sequence frame animation solving of the parallel computing module specifically involves: scheduling a parallel job system to simultaneously traverse all entities containing animation state components on multiple central processing unit cores, and calculating the texture coordinate region of the entity in the current frame; the calculation logic is as follows: The system simultaneously traverses entities containing animation state components across multiple CPU cores, calculates the cumulative playback time of the entities and obtains the theoretical frame number, calculates the actual frame number based on the animation playback mode and the theoretical frame number, and then extracts the corresponding texture coordinate region in the binary large object of the animation configuration based on the actual frame number, overwriting the visual data component of the entity. The method for calculating the cumulative playback time of an entity is as follows: obtain the time increment between the current frame and the previous frame of the current entity, multiply it by the playback speed multiplier of the current entity, and then add the multiplier to the original playback time of the current entity; then divide the cumulative playback time by the duration set for a single image in the animation, and take the integer part of the calculation result to obtain the theoretical frame number. The method of calculating the actual frame number based on the animation playback mode and theoretical frame number, and then extracting the corresponding texture coordinate region in the animation configuration binary large object based on the actual frame number to overwrite the visual data component written to the entity is as follows: The computer program extracts the animation configuration mode of the current entity, and the animation playback mode includes a single playback mode and a loop playback mode; When the animation playback mode is configured as loop playback mode, the theoretical frame number is used to perform a remainder operation on the total number of frames contained in the animation of the current entity, and the remainder is used as the actual frame number. When the animation playback mode is configured as single playback mode, the theoretical frame number is compared with the number of the last image of the current entity's animation, and the smaller value between the two is selected as the actual frame number to prevent reading out of bounds. Finally, based on the actual frame number obtained by the parallel computing module, the animation configuration binary large object in memory is accessed, the texture coordinate region corresponding to the animation configuration binary large object is extracted, and overwritten into the visual data component of the current entity.

4. A high-performance rendering system for 2D dynamic elements based on Unity DOTS according to claim 1, characterized in that, The parallel frustum culling of the parallel computing module specifically involves the following steps: In Unity's orthographic camera mode, frustum culling is essentially performing an intersection test on two 2D axis-aligned bounding boxes. The specific calculation logic can be broken down into the following three sub-steps: Step 1: Calculation of the 2D viewport boundary of the main camera; Step 1.1: First, the 3D camera view frustum is reduced to a 2D rectangular boundary, and then the world center coordinates of the main camera are read. ), orthogonal field of view size and screen aspect ratio ; Step 1.2: Calculate the total viewport height using the following formula: * ; in, Indicates the total height of the viewport. Indicates the total width of the viewport; Step 1.3: Calculate the viewport boundary points: Combining the center coordinates of the main camera, obtain the coordinates of the minimum and maximum points of the main camera's 2D viewport. The calculation formula is as follows: ; ; in, This represents the smallest point in the camera's two-dimensional viewport. This represents the maximum point of the camera's two-dimensional viewport; Step 2: Calculation of the bounding box of the physical world space; Step 2.1: Obtain local data of the bounding box of the physical world space, and read the world center coordinates within the bounding box of the physical world space ( ), original primitive width Original primitive height Scaling factor ( ) and the current two-dimensional rotation angle ; Step 2.2: Calculate the actual width of the bounding box in the real world after scaling. and actual height The formula is as follows: ; ; Step 2.3: Calculate the projected radius of the bounding box of the physical world space after rotation, calculate the half-length of the projected bounding box of the physical world space on both axes, including the half-length of the projected bounding box along the X-axis. and Y-axis projection half length The formula is as follows: ; ; in This represents taking the absolute value; Step 2.4: Calculate the entity boundary points of the entity world bounding box: Combine the world center coordinates of the entity world bounding box ( (This sentence appears to be incomplete and requires more context to translate accurately. It likely refers to finding the minimum point of the bounding rectangle of the entity's world space and the maximum point of the bounding rectangle.) The formula is as follows: ; ; Step 3: Determine the intersection of bounding boxes in the physical world; To determine whether two 2D axis-aligned bounding boxes intersect, the following four Boolean conditions must be met simultaneously: Condition 1, X-axis left boundary determination: the maximum X-coordinate of the bounding rectangle of the entity world's spatial bounding box. The minimum X coordinate of the camera's two-dimensional viewport, i.e. ; Condition 2, Right boundary determination on the X-axis: The minimum X-coordinate of the entity whose bounding rectangle is the outermost rectangle of the entity's world bounding box. The maximum X coordinate of the camera's two-dimensional viewport, i.e. ; Condition 3, Y-axis lower boundary determination: The maximum Y-coordinate of the entity whose bounding rectangle is the outermost rectangle of the entity's world bounding box. The minimum Y-coordinate of the camera's two-dimensional viewport, i.e. ; Condition 4, Y-axis upper boundary determination: The minimum Y-coordinate of the entity whose bounding rectangle is the outermost rectangle of the entity's world space bounding box. The maximum Y-coordinate of the camera's 2D viewport, i.e. ; If all four conditions above are true, the current entity world bounding box is determined to intersect with or be completely contained within the main camera's 2D viewport, i.e., it is considered visible, and its corresponding memory index is recorded in the rendering queue; if any one of the four conditions above is false, the current entity world bounding box is determined to be completely outside the main camera's 2D viewport, i.e., it is considered invisible, and the data is directly discarded to complete the view frustum culling.

5. A high-performance rendering system for 2D dynamic elements based on Unity DOTS according to claim 4, characterized in that, The data processing module specifically compares the length of the visible index list with the current capacity limit of the structured buffer in the video memory. The length of the visible index list is the total number of visible entities. If the total number of visible entities is less than or equal to the current capacity limit of the structured buffer, the current capacity limit of the structured buffer is directly reused. If the total number of visible entities is greater than the current structured buffer capacity limit, then an expansion operation is performed. The current structured buffer capacity limit is compared with the total number of visible entities, and the larger of the two values ​​is taken as the new buffer capacity. Then, the old buffer is released, and a contiguous space corresponding to the new buffer size is allocated in the video memory. Based on the visible index list, several threads are scheduled to read the coordinates, rotation, scaling, color, texture region and sorting priority values ​​of the corresponding entity from memory in parallel, and write these data into the pre-allocated local instance data array in sequence; The underlying graphics interface is invoked to copy the data in the local instance data array to the structured buffer of the graphics processor in one go.

6. A high-performance rendering system for 2D dynamic elements based on Unity DOTS according to claim 1, characterized in that, The GPU rendering module works as follows: The vertex shader reads the corresponding instance data from the structured buffer using the built-in instance identifier, extracts the layer sort key value of the corresponding instance, and calculates the Z-axis depth offset of the corresponding instance in the 3D clipping space; the Z-axis depth offset is specifically calculated as follows: The vertex shader multiplies the read sort key value by a preset minimum precision coefficient to obtain the Z-axis depth offset; The vertex shader subtracts the calculated Z-axis depth offset from the original Z-axis spatial coordinates of the corresponding instance to obtain the final Z-axis coordinates, thereby achieving the display effect of foreground occlusion of background. Finally, the fragment shader performs pixel rendering, extracting the corresponding pixel color from the atlas file based on the texture coordinate region passed from the vertex shader, and completing the rendering output of a massive number of two-dimensional primitives in the current frame.

7. A high-performance rendering method for 2D dynamic elements based on Unity DOTS, running on the Unity engine and based on a data-oriented architecture, characterized in that... Includes the following steps: Step 1: Allocate unmanaged contiguous memory in memory and construct a 2D primitive core component data model consisting of pure value type data structures aligned to 16 bytes. Step 2: Schedule the parallel job system and Burst compiler to perform high-concurrency sequence frame animation solving and bounding box-based parallel view frustum culling; Step 3: Perform parallel packaging of visible entity data, adapt the structured buffer capacity, and asynchronously upload the rendering data to the GPU memory; Step 4: Configure the indirect drawing parameter buffer on the CPU side and trigger the underlying indirect instantiation drawing instructions. The drawing control is transferred to the GPU side. The GPU rendering pipeline executes the custom vertex shader concurrently. The custom vertex shader realizes the dynamic depth sorting on the GPU side and completes the final rendering in combination with the fragment shader.

8. A high-performance rendering method for 2D dynamic elements based on Unity DOTS according to claim 7, characterized in that, The 2D primitive core component data model includes local space components, visual data components, animation state components, and sorting key components, and entity objects with the same component combination are uniformly allocated to the same memory data block to achieve continuous storage; The local space component is used to record world coordinates, scaling ratio, and rotation angle; The visual data component is used to record the basic color and atlas texture sampling area; The animation status component is used to record the current playback time and playback speed multiplier. The sorting key component is used to record the numerical value of the layer sorting priority.

9. A high-performance rendering method for 2D dynamic elements based on Unity DOTS according to claim 8, characterized in that, In step 2, the sequence frame animation calculation specifically involves: scheduling a parallel processing system to simultaneously traverse all entities containing animation state components across multiple central processing unit cores, and calculating the texture coordinate region of the entity in the current frame; the calculation logic is as follows: The system simultaneously traverses entities containing animation state components across multiple CPU cores, calculates the cumulative playback time of the entities and obtains the theoretical frame number, calculates the actual frame number based on the animation playback mode and the theoretical frame number, and then extracts the corresponding texture coordinate region in the binary large object of the animation configuration based on the actual frame number, overwriting the visual data component of the entity. The method for calculating the cumulative playback time of an entity is as follows: obtain the time increment between the current frame and the previous frame of the current entity, multiply it by the playback speed multiplier of the current entity, and then add the multiplier to the original playback time of the current entity; then divide the cumulative playback time by the duration set for a single image in the animation, and take the integer part of the calculation result to obtain the theoretical frame number. The method of calculating the actual frame number based on the animation playback mode and theoretical frame number, and then extracting the corresponding texture coordinate region in the animation configuration binary large object based on the actual frame number to overwrite the visual data component written to the entity is as follows: The computer program extracts the animation configuration mode of the current entity, and the animation playback mode includes a single playback mode and a loop playback mode; When the animation playback mode is configured as loop playback mode, the theoretical frame number is used to perform a remainder operation on the total number of frames contained in the animation of the current entity, and the remainder is used as the actual frame number. When the animation playback mode is configured as single playback mode, the theoretical frame number is compared with the number of the last image of the current entity's animation, and the smaller value between the two is selected as the actual frame number to prevent reading out of bounds. Finally, based on the actual frame number obtained by the parallel computing module, the animation configuration binary large object in memory is accessed, the texture coordinate region corresponding to the animation configuration binary large object is extracted, and overwritten into the visual data component of the current entity.

10. A high-performance rendering method for 2D dynamic elements based on Unity DOTS according to claim 7, characterized in that, In step 2, the parallel view frustum culling specifically involves: In Unity's orthographic camera mode, view frustum culling is the intersection test of two 2D axis-aligned bounding boxes. The specific calculation logic can be broken down into the following three sub-steps: Step 1: Calculation of the 2D viewport boundary of the main camera; Step 1.1: First, the 3D camera view frustum is reduced to a 2D rectangular boundary, and then the world center coordinates of the main camera are read. ), orthogonal field of view size and screen aspect ratio ; Step 1.2: Calculate the total viewport height using the following formula: * ; in, Indicates the total height of the viewport. Indicates the total width of the viewport; Step 1.3: Calculate the viewport boundary points: Combining the center coordinates of the main camera, obtain the coordinates of the minimum and maximum points of the main camera's 2D viewport. The calculation formula is as follows: ; ; in, This represents the smallest point in the camera's two-dimensional viewport. This represents the maximum point of the camera's two-dimensional viewport; Step 2: Calculation of the bounding box of the physical world space; Step 2.1: Obtain local data of the bounding box of the physical world space, and read the world center coordinates within the bounding box of the physical world space ( ), original primitive width Original primitive height Scaling factor ( ) and the current two-dimensional rotation angle Original primitive height Step 2.2: Calculate the actual width of the bounding box in the real world after scaling. and actual height The formula is as follows: ; ; Step 2.3: Calculate the projected radius of the bounding box of the physical world space after rotation, calculate the half-length of the projected bounding box of the physical world space on both axes, including the half-length of the projected bounding box along the X-axis. and Y-axis projection half length The formula is as follows: ; ; in This represents taking the absolute value; Step 2.4: Calculate the entity boundary points of the entity world bounding box: Combine the world center coordinates of the entity world bounding box ( (This sentence appears to be incomplete and requires more context to translate accurately. It likely refers to finding the minimum point of the bounding rectangle of the entity's world space and the maximum point of the bounding rectangle.) The formula is as follows: ; ; Step 3: Determine the intersection of bounding boxes in the physical world; To determine whether two 2D axis-aligned bounding boxes intersect, the following four Boolean conditions must be met simultaneously: Condition 1, X-axis left boundary determination: the maximum X-coordinate of the bounding rectangle of the entity world's spatial bounding box. The minimum X coordinate of the camera's two-dimensional viewport, i.e. ; Condition 2, Right boundary determination on the X-axis: The minimum X-coordinate of the entity whose bounding rectangle is the outermost rectangle of the entity's world bounding box. The maximum X coordinate of the camera's two-dimensional viewport, i.e. ; Condition 3, Y-axis lower boundary determination: The maximum Y-coordinate of the entity whose bounding rectangle is the outermost rectangle of the entity's world bounding box. The minimum Y-coordinate of the camera's two-dimensional viewport, i.e. ; Condition 4, Y-axis upper boundary determination: The minimum Y-coordinate of the entity whose bounding rectangle is the outermost rectangle of the entity's world space bounding box. The maximum Y-coordinate of the camera's 2D viewport, i.e. ; If all four conditions above are true, the current entity world bounding box is determined to intersect with or be completely contained within the main camera's 2D viewport, i.e., it is considered visible, and its corresponding memory index is recorded in the rendering queue; if any one of the four conditions above is false, the current entity world bounding box is determined to be completely outside the main camera's 2D viewport, i.e., it is considered invisible, and the data is directly discarded to complete the view frustum culling.

11. A high-performance rendering method for 2D dynamic elements based on Unity DOTS according to claim 10, characterized in that, Step 3 specifically involves comparing the length of the visible index list with the current maximum capacity of the structured buffer in the video memory. The length of the visible index list represents the total number of visible entities. If the total number of visible entities is less than or equal to the current maximum capacity of the structured buffer, then the current maximum capacity of the structured buffer is directly reused. If the total number of visible entities is greater than the current structured buffer capacity limit, then an expansion operation is performed. The current structured buffer capacity limit is compared with the total number of visible entities, and the larger of the two values ​​is taken as the new buffer capacity. Then, the old buffer is released, and a contiguous space corresponding to the new buffer size is allocated in the video memory. Based on the visible index list, several threads are scheduled to read the coordinates, rotation, scaling, color, texture region and sorting priority values ​​of the corresponding entity from memory in parallel, and write these data into the pre-allocated local instance data array in sequence; The underlying graphics interface is invoked to copy the data in the local instance data array to the structured buffer of the graphics processor in one go.

12. A high-performance rendering method for 2D dynamic elements based on Unity DOTS according to claim 7, characterized in that, Step 4 specifically involves: the vertex shader reading the corresponding instance data from the structured buffer using the built-in instance identifier, extracting the layer sort key value of the corresponding instance, and calculating the Z-axis depth offset of the corresponding instance in 3D clipping space; the Z-axis depth offset is specifically calculated as follows: The vertex shader multiplies the read sort key value by a preset minimum precision coefficient to obtain the Z-axis depth offset; The vertex shader subtracts the calculated Z-axis depth offset from the original Z-axis spatial coordinates of the corresponding instance to obtain the final Z-axis coordinates, thereby achieving a two-dimensional hierarchical display effect where the foreground occludes the background. Finally, the fragment shader performs pixel rendering, extracting the corresponding pixel color from the atlas file based on the texture coordinate region passed from the vertex shader, and completing the rendering output of a massive number of two-dimensional primitives in the current frame.