A clipmap-based virtual texture parallel page management method and system
By employing native compilation and parallel task management for page state in the Clipmap solution, and utilizing the GPU pipeline for physical texture rendering and batch updating of indirect textures, the performance bottleneck and consistency issues of existing Clipmap solutions in large-scale 3D terrain scene rendering are resolved, achieving efficient texture management and improved rendering quality.
Patent Information
- Application Number
- CN202611234262.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-14
- Publication Date
- 2026-11-03
AI Technical Summary
Existing Clipmap solutions suffer from several issues in rendering large-scale 3D terrain scenes, including low page update computation efficiency, high GC overhead, high CPU-GPU synchronization overhead, lack of GPU-side optimization for physical texture rendering pipelines, lack of batch rendering optimization, insufficient flexibility in Mip hierarchy management, and lack of consistency repair mechanisms when switching indirect texture update modes.
It adopts a Clipmap-based virtual texture parallel page management method, manages page state through native compilation parallel tasks, utilizes GPU pipeline for physical texture rendering and batch update of indirect textures, supports Atlas batch rendering and Mip level skipping, and sets the NeedsITRefresh flag to ensure consistency of mode switching.
It significantly improves page update performance, reduces memory usage, reduces GC overhead, optimizes the physical texture rendering pipeline, improves GPU utilization, ensures consistency in texture update mode switching, and improves rendering quality and user experience.
Smart Images

Figure CN123030820A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer image processing technology, and in particular to large-scale continuous texture parallel management rendering of large-scale three-dimensional terrain scenes. Background Technology
[0002] In the field of computer graphics, clipping is a core texture processing scheme used for rendering large-scale terrain or scenes. This technique achieves efficient rendering of large-scale continuous textures by maintaining a series of texture rings (Mip levels) centered on the observer and with progressively decreasing resolution. The basic idea is to dynamically update the texture pages in the ring buffers of each Mip level as the viewpoint moves, ensuring that areas near the observer display high-precision texture details while distant areas display low-precision textures, thus achieving visual coverage of a large scene with limited texture memory.
[0003] The development of Clipmap technology has evolved from early fixed-function pipeline implementations to adaptations to modern programmable rendering pipelines. Early Clipmap solutions primarily handled page management and texture uploading operations on the CPU. With the improvement of GPU computing power and the development of graphics APIs, more and more researchers are attempting to offload texture updates and rendering tasks to the GPU. However, existing Clipmap solutions still have the following six limitations in their implementation: First, page update computation is inefficient and incurs significant garbage collection (GC) overhead. Existing Clipmap solutions typically use managed code (such as C# or Java) to traverse page slots frame by frame for page update computation. This fails to leverage the SIMD instruction set and parallel computing capabilities of modern CPUs, resulting in computational bottlenecks in large-scale page scenarios. Furthermore, the core page management algorithm runs on managed code, leading to frequent garbage collection (GC) allocations. This causes frame rate fluctuations in high-frequency hot paths, severely impacting rendering smoothness.
[0004] Second, indirect texture updates are inefficient and have high CPU-GPU synchronization overhead. Existing Clipmap solutions typically use a method of writing to each pixel on the CPU and then calling a texture upload operation for indirect texture updates. This operation requires reading the entire texture back from the GPU to the CPU and then uploading it, which cannot be combined with other operations in the GPU rendering pipeline and has high CPU-GPU synchronization overhead, becoming one of the bottlenecks in system performance.
[0005] Third, the physical texture rendering pipeline lacks GPU-side optimization. Existing Clipmap solutions lack an efficient physical texture rendering pipeline, typically employing per-page CPU rendering or simple single-pass rendering methods. They cannot utilize Multiple Render Targets (MRT) technology to simultaneously output multiple texture layers, and lack GPU-side compression, resulting in low storage efficiency and rendering throughput for physical textures.
[0006] Fourth, the lack of batch rendering optimization results in a large number of DrawCalls. The existing Clipmap solution lacks Atlas batch rendering optimization. The rendering operations for each page are executed independently, including independent rendering target settings, clearing, and drawing scheduling. When there are many pages, the number of rendering state switches is high, resulting in a large number of DrawCalls and low GPU utilization.
[0007] Fifth, the Mip layer management is not flexible enough, resulting in a large memory footprint. The existing Clipmap solution's Mip layer management is not flexible enough. All Mip levels require the allocation of page data and physical tiles, and it cannot skip unnecessary Mip levels based on texture features. This leads to a large total number of pages and texture memory usage, which is particularly prominent in memory-constrained mobile scenarios.
[0008] Sixth, the lack of a consistency repair mechanism when switching indirect texture update modes. The existing Clipmap solution lacks a cross-mode consistency repair mechanism when switching indirect texture update modes. Indirect texture mappings cleared in indirect texture reconstruction mode cannot be automatically restored after switching back to incremental mode, causing loaded pages to display abnormally after camera movement, severely impacting rendering quality and user experience.
[0009] To address the aforementioned issues, a more efficient Clipmap virtual texture management solution is needed to improve page update performance, enable batch updates of indirect textures on the GPU, optimize the physical texture rendering pipeline, reduce memory usage and GC overhead, and ensure consistency in switching between different indirect texture update modes. Summary of the Invention
[0010] To address the above problems, this invention provides a virtual texture parallel page management method based on Clipmap, comprising the following steps: S1: Create page data container, tile data container, indirect texture resource, physical texture resource and finalizer resource and perform system initialization. Calculate the number of pages and offsets of each Mip layer according to the configuration parameters and establish a static mapping relationship between pages and physical tiles. S2: Obtain camera world coordinates, calculate the loading area in Mip layers, and traverse page slots through a parallel task compiled on the local machine to complete page state determination and classification; S3: Performs frame-by-frame truncation processing on category pages, prioritizes rendering high-Mip, low-precision pages, completes physical texture rendering through the GPU pipeline, and updates indirect textures in batches according to configuration mode. S4: Monitors the idle status of terminator resources. When the idle time reaches a threshold, intermediate rendering resources are automatically released. When rendering needs are triggered, they are rebuilt on demand.
[0011] Furthermore, the system initialization in step S1 includes: S11, Page data initialization; S12. Tile and physical texture initialization, including calculating the tile row and column arrangement based on tile size and physical texture size, pre-calculating the pixel coordinates and depth layer of each tile in the physical texture; and creating a two-dimensional texture array as the physical texture according to the texture format. S13. Indirect texture resource initialization, including creating a computation buffer to store write requests, loading the indirect texture to update the computation shader and obtain the kernel index, and initializing the indirect texture to a full-white invalid mapping; S14. Finalizer resource initialization, including distinguishing between resident mode, lazy mode, and immediate release mode based on idle release threshold, wherein: In resident mode, intermediate rendering textures and VT encoders are created directly. Lazy mode only creates the data container and rebuilds the resources on the first render. Instant release mode destroys intermediate textures immediately after each rendering is complete.
[0012] Furthermore, step S11, page data initialization, specifically includes: S111 Load Range Configuration: Set the global default load range DefaultLoadRange as the base load range for all Mip levels, and configure the overrideLoadRanges array with Mip level as index; Mip levels with corresponding index data use their own load range to override DefaultLoadRange, and Mip levels without configuration use DefaultLoadRange as fallback. S112. Page count calculation: Based on the maximum Mip level and the independent loading range of each level, calculate MipSize = loadRange × 2 + 2, and the total number of pages pageNum = mipSize². S113, Mip Skip Mask Generation: Generate an integer skip Mip bit mask SkipMipMask from the SkipMips list. The number of Mip level pages marked for skipping by the mask is set to 0 and no page resources are allocated. Mip0, the highest precision level, and MaxMip, the lowest precision level, cannot be skipped. S114, Mask Filtering Rules: Parallel computing tasks and indirect texture writing processes are uniformly passed to SkipMipMask. The judgment formula (SkipMipMask>>Mip&1) != 0 is used to identify the current Mip index Mip; if the judgment is true, all page updates and indirect texture writing processes of that Mip are skipped directly.
[0013] Furthermore, in step S2, traversing the page includes incremental update mode and page integrity verification mode, wherein: The incremental update mode only traverses the page slots within the camera loading range. When the page world coordinates change, the old position is added to the list to be cleared, and no independent list of pages to be eliminated is generated. The page integrity verification mode traverses all page slots and calculates the expected world coordinates of the slots using the ClosestWorldCoord back-calculation algorithm. The algorithm calculation logic is as follows: centerLocal=PosMod(center,totalRange) diff=local-centerLocal If diff>totalRange / 2, then diff=diff-totalRange; if diff<-totalRange / 2, then diff=diff+totalRange; Expected world coordinates = center + diff; In the formula: local represents the local coordinates of the slot, center represents the center coordinates of the current Mip level, and totalRange=loadRange×2+2 represents the total range of the Mip level; Furthermore, the method for page frame truncation processing in step S3 is as follows: Pages to be processed are sorted from highest to lowest according to Mip level, and the maximum processing page quota for each frame is allocated accordingly. Pages that have not exceeded the quota limit are marked as loaded and added to the drawing list; pages that have exceeded the quota are marked as rollback pages and added to the rollback list. Prioritize processing high-Mip, low-precision pages to avoid blank texture blocks appearing in the distance of the scene.
[0014] Furthermore, in step S3, physical texture rendering is implemented through two GPU rendering pipelines, specifically: The single-page rendering pipeline includes sequentially performing full-screen mesh drawing, multi-render target MRT output, VT encoder GPU-side compression, and texture copying to physical texture for a single page. Each drawing independently performs render target setting and clearing operations. The Atlas batch rendering pipeline includes rendering multiple pages to different viewport areas of the same Atlas intermediate texture, performing render target setting and clearing only once; when the page exceeds the Atlas capacity, it is rendered in batches, and the encoding scheduling is performed only according to the texture layer number.
[0015] Furthermore, the indirect texture update in step S3 includes indirect texture reconstruction mode, incremental patch mode, and automatic selection mode, wherein: S31, Indirect texture reconstruction modes include: S311. Bind the indirect texture to the render target and clear it to a white invalid mapping; S312. Collect indirect texture write requests for all valid pages within the currently loaded range; S313. Execute SetRenderTarget (None) to unbind the render target binding and eliminate the resource state conflict when the render target RT switches to the unordered access view UAV. S314, Schedule computation shaders to write batches of indirect textures; S32, incremental patch mode includes: S321. Collect ancestor tile write requests for four types of objects: discarded pages, cleared pages, loaded pages, and back pages. S322. Using the width of the pixel block covered by the write request (width = 2^Mip level) as the sorting key, perform a descending stable sorting, and retain the original collection order for requests of the same Mip level; write low-precision large block requests first and high-precision small block requests last, and write high-precision tiles over low-precision mappings to avoid texture misalignment. S323. Schedule the compute shader to execute all write requests serially; S33. Automatic selection mode includes: configuring single frame update threshold and cumulative update threshold. When the number of page updates in this frame reaches the single frame threshold or the total number of cumulative updates reaches the cumulative threshold, switch to reconstruction mode and reset the cumulative count. The remaining frames adopt incremental patch mode.
[0016] Furthermore, the switching between rebuild mode and incremental patch mode is achieved through consistency repair of the NeedsITRefresh flag built into the page data structure, specifically as follows: When the reconstruction mode traverses the page, if the page is loaded but outside the current camera loading range, the NeedsITRefresh flag is set and the indirect texture mapping of the page is not written. When the camera moves and the page re-enters the loading range, the incremental mode detects the set NeedsITRefresh flag and automatically rewrites the indirect texture mapping data of the page, eliminating abnormal page texture display.
[0017] Furthermore, it also includes two working modes for the memory pre-computation auxiliary process, specifically: Runtime Precise Statistics Mode: Traverse all runtime resource objects and separately count the memory usage of CPU-side pages, tiles, and temporary lists, and the memory usage of GPU-side indirect textures, physical textures, and encoder buffers. Configuration prediction mode: Based solely on initial configuration parameters, Mip skip bit mask, and Atlas grid size, it predicts the total CPU and GPU memory usage without needing to start the runtime program; Both modes output structured memory usage details, summarizing the total memory consumption of CPU and GPU.
[0018] This application also provides a Clipmap-based virtual texture parallel page management system for executing the Clipmap-based virtual texture parallel page management method, characterized in that it includes a configuration module, a page management module, a GPU rendering and indirect texture update module, and a dynamic resource control module, wherein: The configuration module is used to create page data containers, tile data containers, indirect texture resources, physical texture resources, and finalizer resources; it calculates the number of pages and offsets at each Mip level based on the configuration parameters, and establishes a static mapping relationship between pages and physical tiles. The page management module is used to obtain the camera's world coordinates, calculate the loading area in Mip layers, and traverse the page slots through a parallel task of local compilation to complete the page state determination and classification. The GPU rendering and indirect texture update module is used to process the frame segmentation of the classification page, prioritize the rendering of high-Mip low-precision pages, complete the physical texture rendering through the GPU pipeline, and update the indirect texture in batches according to the configuration mode. The dynamic resource management module monitors the idle status of the finalizer resources. When the idle time reaches a threshold, intermediate rendering resources are automatically released, and rendering resources are rebuilt as needed when a rendering requirement is triggered.
[0019] This invention addresses the problems of existing technologies by proposing a new technical solution that significantly improves the performance and memory efficiency of Clipmap virtual texture management while ensuring rendering quality. It can be widely applied in large-scale 3D terrain scenes, virtual reality, game development, and other fields, as detailed below: To address the issues of low computational efficiency and high GC overhead in page updates, this invention compiles the core page management algorithm into native code. This code is then executed concurrently on a multi-core CPU without locks through parallel computing tasks (such as Unity's IJob system). The state judgment and state transition of each page slot are completed independently under lock-free conditions, without generating GC memory allocation throughout the process, thus achieving zero-GC parallel page state management.
[0020] To address the issue of low efficiency in indirect texture updates, this invention employs a scheme of lightweight collection of write requests on the CPU side and batch writing by the GPU-side compute shaders. All write requests are submitted in the same graphics command buffer and executed in conjunction with other operations in the GPU rendering pipeline, thus eliminating CPU-GPU synchronization overhead.
[0021] To address the lack of GPU-side optimization in the physically texture rendering pipeline, this invention adopts a GPU-first rendering pipeline of "drawing a full-screen mesh → multiple render targets (MRT) → VT encoder compression → texture copying to physical texture". All operations are executed sequentially on the GPU without CPU intervention, making full use of the GPU's parallel computing capabilities.
[0022] To address the lack of batch rendering optimization, this invention supports Atlas batch rendering paths, rendering multiple pages to different viewport areas of the same Atlas intermediate rendering texture, performing only one set rendering target and clear operation, significantly reducing rendering state switching and the number of DrawCalls.
[0023] To address the issue of insufficient flexibility in Mip-level management, this invention supports skipping page and tile allocations at a specified Mip level. By passing the bitmask to the parallel computing task, it automatically skips page updates and indirect texture writes, flexibly reducing the total number of pages and texture memory usage.
[0024] To address the lack of consistency repair during indirect texture update mode switching, this invention sets a NeedsITRefresh flag in the page data structure. When the reconstruction mode skips loaded pages that are outside the loading range, this flag is set. When the page returns to the loading range, the indirect texture mapping data is rewritten by the incremental mode, ensuring texture consistency during mode switching. Attached Figure Description
[0025] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0026] Figure 1 This is a schematic diagram illustrating the process of single-frame data from camera input to texture output in an embodiment of this application.
[0027] Figure 2 This is a schematic diagram illustrating the various mode selection processes for indirect textures in embodiments of this application.
[0028] Figure 3 This is a schematic diagram of the system structure according to an embodiment of this application. Detailed Implementation
[0029] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0030] This application provides a method for parallel page management of virtual textures based on Clipmap, including the following steps: S1: Create page data container, tile data container, indirect texture resource, physical texture resource and finalizer resource and perform system initialization. Calculate the number of pages and offsets of each Mip layer according to the configuration parameters and establish a static mapping relationship between pages and physical tiles. S2: Obtain camera world coordinates, calculate the loading area in Mip layers, and traverse page slots through a parallel task compiled on the local machine to complete page state determination and classification; S3: Performs frame-by-frame truncation processing on category pages, prioritizes rendering high-Mip, low-precision pages, completes physical texture rendering through the GPU pipeline, and updates indirect textures in batches according to configuration mode. S4: Monitors the idle status of terminator resources. When the idle time reaches a threshold, intermediate rendering resources are automatically released. When rendering needs are triggered, they are rebuilt on demand.
[0031] Please see Figure 1 , Figure 1 This is a schematic diagram of the process from camera input to texture output of a single frame of data according to an embodiment of this application. The technical solutions of this application and various preferred and alternative technical solutions are described in detail below with reference to various preferred embodiments.
[0032] S1: Create page data container, tile data container, indirect texture resource, physical texture resource and finalizer resource and perform system initialization. Calculate the number of pages and offsets of each Mip layer according to the configuration parameters, and establish a static mapping relationship between pages and physical tiles.
[0033] This step involves creating various resource containers and completing system initialization, calculating Mip page parameters, and establishing a static mapping between pages and tiles. It is the basic execution flow, comprising three layers: the resource container creation layer, the Mip parameter calculation layer, and the page tile mapping layer. Resource container creation: Separate storage containers are created in CPU memory and GPU video memory respectively. Five types of containers isolate data to avoid memory read and write conflicts; the page container stores all page states and world coordinates; the tile container stores tile pixels and depth indexes; the indirect / physical texture container stores GPU texture handles; and the terminator container stores Atlas textures and VT encoder resource handles.
[0034] MIP parameter calculation: Read the global MaxMip maximum level and the loading configuration of each level, calculate the number of pages in rows and columns and the global offset index of the page level by level, and use it for fast addressing of page world coordinates.
[0035] Static mapping establishment: Generate a one-dimensional index array to bind page IDs and tile IDs one by one. During the rendering stage, there is no need for real-time matching; tile information can be read directly by index.
[0036] In a preferred embodiment, system initialization in step S1 of this application includes: S11. Page data initialization, specifically including: S111 Load Range Configuration: Set the global default load range DefaultLoadRange as the base load range for all Mip levels, and configure the overrideLoadRanges array with Mip level as index; Mip levels with corresponding index data use their own load range to override DefaultLoadRange, and Mip levels without configuration use DefaultLoadRange as fallback. S112. Page Count Calculation: Based on the maximum Mip level and the independent loading range of each level, the calculation formula is mipSize = loadRange × 2 + 2, and the total number of pages is pageNum = mipSize². In the formula, loadRange is the loading radius of the current level, ×2 achieves bidirectional buffering on the left and right / top and bottom, and +2 reserves boundary pages to avoid circular texture tearing.
[0037] S113, Mip Skip Mask Generation: Generate an integer skip Mip bit mask SkipMipMask from the SkipMips list. The number of Mip level pages marked for skipping by the mask is set to 0 and no page resources are allocated. Mip0, the highest precision level, and MaxMip, the lowest precision level, cannot be skipped.
[0038] One specific implementation is as follows: read the SkipMips skip level list and convert it into an integer bitmask SkipMipMask; the i-th bit of the mask being 1 means that Mipi will not be allocated resources; force the Mip0 (highest precision) and MaxMip (lowest precision) mask bits to always be 0 and cannot be skipped; the pageNum of the marked level is directly set to 0, and no CPU page array or GPU tile memory is allocated.
[0039] S114. Mask Filtering Rules: Parallel computing tasks and indirect texture writing processes are uniformly passed to SkipMipMask. The current Mip index is identified using the judgment formula (SkipMipMask>>Mip&1) != 0. If the judgment is true, all page updates and indirect texture writing processes for that Mip are skipped. In this judgment formula: Mip is the index of the current loop level, >> shifts the mask right by m bits to extract the target level binary bits, and &1 reads the least significant bit. When the judgment result is true, all calculation logic for that Mip is skipped.
[0040] S12. Initialize tiles and physical textures, including calculating the tile row and column arrangement based on tile size and physical texture size, pre-calculating the pixel coordinates (TileX, TileY pixel coordinates) and depth layer of each tile in the physical texture; create a two-dimensional texture array as the physical texture according to the texture format, and set the texture filtering mode to bilinear and the wrapping mode to Clamp.
[0041] This step uses a two-dimensional texture array as an alternative implementation method. It can be replaced with a global single large Atlas texture or a three-dimensional texture to store tile data, adapting to different GPU memory layout characteristics.
[0042] S13. Indirect texture resource initialization, including creating a computation buffer to store write requests, loading the indirect texture to update the computation shader and obtain the kernel index, and initializing the indirect texture to a full-white invalid mapping.
[0043] S14. Finalizer resource initialization, configuring the FinalizerIdleThreshold parameter to divide the three running modes, specifically: Resident mode (threshold=-1): Initializes synchronous creation of Atlas intermediate rendering textures and multiple VT encoders; Lazy generic mode (threshold > 0): Only creates empty resource handle containers, and allocates them on demand during rendering; Instant Release Mode (Threshold = 0): Destroy intermediate textures immediately after each rendering is complete.
[0044] The technical effects achieved in step S1 include the following: 1. Layered initialization decouples resource creation logic, skipping useless Mip layers as needed during startup, significantly reducing peak CPU and video memory usage during program startup; 2. Mip's independent loading range adapts to the rendering needs of close-up high-precision small-area and distant low-precision large-area, reducing the total amount of page traversal per frame; 3. Static bitmask unified filtering skips all levels throughout the process, eliminating the need to repeatedly check the list during runtime and reducing CPU loop overhead per frame; 4. Tile coordinates and page mapping are pre-calculated, eliminating the need for real-time calculations during the rendering stage and freeing up the main thread's computing power; 5. The three-level terminator resource mode balances smoothness with the need to release idle video memory on memory-constrained devices.
[0045] S2: Obtain camera world coordinates, calculate the loading area in Mip layers, and traverse page slots through a local compilation parallel task to complete page state determination and classification.
[0046] This step describes the method for updating each frame of the page, specifically including: S21: Read the camera world coordinates output by the rendering pipeline, convert them into terrain local coordinates to offset the scene origin offset, that is, obtain the current position of the camera in world space and convert it into terrain local coordinates (minus the origin offset).
[0047] S22: Based on the loading range of each Mip obtained from the initialization in S1, the rectangular areas of the page slots that need to be traversed are defined layer by layer.
[0048] S23: Execute the page update parallel computing task: Compile the page traversal logic into a local lock-free parallel IJob task, traverse all target slots in parallel using multiple threads, compare the world coordinates of the old and new pages, and divide the list of pages to be added and pages to be cleared. Specifically: The page management module selects either an incremental update task or a page integrity validation task based on the UseFullValidate configuration. When UseFullValidate is true, the page integrity validation task is used; otherwise, the incremental update task is used. Setting the global refresh flag ForceRefreshAllPages forces all active pages to be reset to stateless, allowing them to be reloaded in the next frame.
[0049] During task execution, the temporary list of the previous frame is cleared, and processing is performed layer by layer from the highest Mip (lowest precision) to the lowest Mip (highest precision). For each Mip layer, the center coordinates (worldPos / pageSize) of the camera under that Mip are calculated based on the load range configured independently for that Mip (overriding by Mip through OverrideLoadRanges, and falling back to DefaultLoadRange if not overridden), and all slots within the load range are traversed.
[0050] The system supports two page management modes: Incremental update mode: Only page slots within the currently loaded range are traversed. For each slot, its current world coordinates are compared with the world coordinates to be mapped: if they match and the page state is rolled back, it is added to the pending list; if they do not match, the new world coordinates and world space rectangle are calculated, and the rectangle is checked against the AABB union boundary (SectorBounds) of the loaded tiles to see if it is within the loaded tile range. If the check passes, the old world coordinates are saved, the page data is updated, and it is added to the pending list. When the page world coordinates change, its old position is directly added to the pending list, without generating a separate pending page list.
[0051] Page integrity verification mode: Traverse all page slots and calculate the expected world coordinates of each slot using the ClosestWorldCoord algorithm. The mathematical principle of this algorithm is as follows: Given the local coordinates of the slot (local), the center coordinates of the current Mip level (center), and the total range of the Mip level (totalRange = loadRange × 2 + 2), first calculate the positive modulus value of center under totalRange: centerLocal = PosMod(center,totalRange) Then calculate the difference: diff = local - centerLocal If diff>totalRange / 2, then diff =diff-totalRange; if diff<-totalRange / 2, then diff =diff+totalRange.
[0052] The final expected world coordinates are: Expected world coordinates = center + diff Where: local is the local relative coordinate of the slot, center is the current Mip camera center coordinate, totalRange=loadRange×2+2 is the complete ring span of the layer, and PosMod is the ring modulo operation.
[0053] This method takes into account the wraparound characteristics of the circular buffer and takes the world coordinate mapping closest to the center coordinates.
[0054] For active pages, a dual replacement decision rule is adopted: the page is replaced only when the new expected world coordinates simultaneously meet the two conditions of "being within the current Mip loading range" and "passing the AABB union boundary detection of loaded plots" (the old page is added to the list to be cleared); otherwise, the old page remains unchanged to ensure that the indirect texture and physical texture are synchronized effectively.
[0055] The parallel task internally implements lock-free page state transitions, with page states including stateless, pending addition, loaded, loading, rollback, and evicted. The state judgment and state transition of each page slot are executed independently under lock-free conditions, with no garbage collection memory allocation throughout the process.
[0056] As an alternative implementation, the basic solution in this step uses a circular buffer slot to store pages, which can be replaced by a hash table or a quadtree spatial index structure to store page mapping, adapting to ultra-large sparse scenarios.
[0057] In addition, this step is based on static SkipMipMask filtering of Mips, which can be replaced by real-time frame rate acquisition and dynamic adjustment of the GPU load to skip the Mip list, achieving runtime adaptive memory balancing.
[0058] Step S2 utilizes a locally compiled parallel computing task, allowing page updates to be executed concurrently on a multi-core CPU. This fully leverages the parallel computing capabilities of modern CPUs, utilizing multi-core CPUs and the SIMD instruction set, reducing page traversal time in megawatt scenes by over 60%. The page integrity verification mode uses the ClosestWorldCoord back-pushing algorithm to verify the correctness of the current mapping of each slot, perfectly adapting to the page circular buffer, eliminating boundary texture breaks, and ensuring the effectiveness of synchronization between indirect and physical textures. The lock-free design and zero-GC allocation completely eliminate thread synchronization overhead and garbage collection pauses in traditional managed code implementations, guaranteeing frame rate stability.
[0059] S3: Performs frame-by-frame truncation processing on category pages, prioritizes rendering high-Mip, low-precision pages, completes physical texture rendering through the GPU pipeline, and updates indirect textures in batches according to configuration modes.
[0060] This step involves page scheduling and rendering. As a preferred implementation method, the page frame truncation process is as follows: All pages to be processed are sorted from highest to lowest according to Mip level (i.e. Mip value), and the maximum page quota MaxPagePerFrame for each frame is allocated accordingly. Pages that do not exceed the quota limit are marked as loaded and added to the drawing list; pages that exceed the quota are marked as rollback pages, added to the rollback list, and carried over to the next frame for rendering.
[0061] Prioritize processing high-Mip low-precision pages (i.e., distant low-precision pages) to avoid blank texture blocks in the distance of the scene and prevent large blank areas in the scene when the camera is looking into the distance.
[0062] In this step, physically based texture rendering is achieved through two GPU rendering pipelines, specifically: The single-page rendering pipeline includes sequentially performing tasks such as drawing a full-screen mesh, multi-render target MRT output, VT encoder GPU-side compression, and texture copying to physical textures for a single page. Each drawing independently performs render target setting and clearing operations.
[0063] This solution uses a full-screen grid drawing page as an alternative implementation method, which can be replaced by directly rendering terrain grid geometry to achieve pixel-level accurate terrain matching.
[0064] The Atlas batch rendering pipeline includes rendering multiple pages to different viewport areas of the same Atlas intermediate texture, with only one render target setup, binding, and clearing performed throughout the process; when a page exceeds the Atlas mesh capacity, it is automatically rendered in batches, with only one VT encoding scheduling performed according to the texture layer number, which can significantly reduce the number of DrawCalls and rendering state switching overhead. The Atlas batch rendering function can be independently turned on and off on mobile devices.
[0065] In addition, this method uses a fixed grid Atlas layout as an alternative implementation method, which can be replaced by a dynamic packing layout that adaptively allocates viewports according to page size, thereby improving the utilization of Atlas texture space.
[0066] Please see Figure 2 , Figure 2 This is a schematic diagram of the various mode selection processes for indirect textures in an embodiment of this application. Step S3, updating the indirect texture, includes indirect texture reconstruction mode, incremental patch mode, and automatic selection mode, wherein: S31, Indirect texture reconstruction modes include: S311. Bind the indirect texture to the render target and clear it to a white invalid mapping; S312. Collect indirect texture write requests for all valid pages within the currently loaded range; S313. Execute `SetRenderTarget(None)` to unbind the render target, eliminating resource state conflicts when switching from the render target (RT) to the unordered access view (UAV). This step is crucial: without explicit state transitions, the same indirect texture resource will first be cleared as a render target, and then immediately written as an unordered access view of the compute shader. In different graphics APIs, if the resource state transition (such as `ResourceBarrier` or Vulkan's `PipelineBarrier`) is not performed correctly when the same resource switches from the render target state to the UAV write state, the write result may be undefined.
[0067] S314, Schedule computation shaders to write in batches to indirect textures.
[0068] The basic reconstruction scheme in this step clears the space interface texture by rendering the target. As an alternative implementation method, it can be replaced by directly clearing the dedicated compute shader kernel, completely avoiding RT / UAV resource conflicts.
[0069] S32, incremental patch mode includes: S321. Collect ancestor tile write requests for four types of objects: EvictPages, ClearPages, DrawPageIndices, and FallbackIndices. S322. Using the width of the pixel block covered by the write request (width = 2^Mip level) as the sorting key, perform a descending stable sorting, and retain the original collection order for requests of the same Mip level; write low-precision large block requests first and high-precision small block requests last, and write high-precision tiles over low-precision mappings to avoid texture misalignment. S323, Schedule the compute shader to execute all write requests serially.
[0070] The incremental patching mode in this application embodiment collects write requests on the CPU side. As a preferred alternative, it can be replaced by the GPU side compute shader directly reading the page to generate requests, completely eliminating the CPU collection overhead.
[0071] S33. Automatic selection mode includes: configuring single frame update threshold and cumulative update threshold. When the number of page updates in this frame reaches the single frame threshold or the total number of cumulative updates reaches the cumulative threshold, switch to reconstruction mode and reset the cumulative count. The remaining frames adopt incremental patch mode.
[0072] Based on step S3, this application also provides a preferred embodiment, providing a cross-mode consistency repair mechanism, namely, the switching between rebuild mode and incremental patch mode, which is achieved through consistency repair of the NeedsITRefresh flag bit built into the page data structure, specifically as follows: When the reconstruction mode traverses the page, if the page is loaded but outside the current camera loading range, the NeedsITRefresh flag is set and the indirect texture mapping of the page is not written. When the camera moves and the page re-enters the loading range, the incremental mode detects the set NeedsITRefresh flag and automatically rewrites the indirect texture mapping data of the page, eliminating abnormal page texture display.
[0073] Therefore, it can be seen that the series of improvements in this step have achieved good technical results in several aspects: 1. The high-Mip priority frame splitting strategy balances the GPU load of a single frame, completely solving the rendering defect of blank distant scenes; 2. Atlas batch rendering can reduce the number of DrawCalls by 70%~90%, significantly reducing GPU pipeline interruptions; 3. MRT multi-output + GPU built-in VT compression eliminates the need for offline CPU compression, significantly reducing physical texture memory usage; 4. Three indirect texture modes adaptively balance performance and image precision, and the incremental sorting mechanism permanently eliminates residual misalignment in tile mapping; 5. Explicitly unbind resources in rebuild mode to avoid undefined rendering behaviors of DX12 / Vulkan and reduce occasional texture black screen bugs; 6. The NeedsITRefresh automatic repair mechanism does not require reloading physical textures, but only rewrites indirect mappings, resulting in no flickering or blanking during mode switching.
[0074] S4: Monitors the idle status of terminator resources. When the idle time reaches a threshold, intermediate rendering resources are automatically released. When rendering needs are triggered, they are rebuilt on demand.
[0075] This step involves counting the number of consecutive idle frames for the finalizer Atlas intermediate texture and VT encoder at the end of each frame rendering process; when the number of idle frames exceeds the configured threshold, the intermediate rendering texture is automatically released; when the next frame detects a page rendering task, the missing intermediate resources are recreated.
[0076] In addition, this application provides a memory pre-computation auxiliary process, which is divided into two working modes for global memory evaluation, specifically: Runtime Precise Statistics Mode: Traverse all runtime resource objects and separately count the memory usage of CPU-side pages, tiles, and temporary lists, and the memory usage of GPU-side indirect textures, physical textures, and encoder buffers. Configuration prediction mode: Based solely on initial configuration parameters, Mip skip bit mask, and Atlas grid size, it predicts the total CPU and GPU memory usage without requiring the runtime program to be started, and can be used for parameter tuning during the development phase.
[0077] Both modes output structured memory usage details, summarizing total CPU and GPU memory consumption. With the accompanying dual-mode memory statistics tool, parameters can be quickly optimized during development to balance image quality and hardware memory limits. After deployment, it allows for real-time monitoring of VRAM leaks and abnormal continuous memory growth.
[0078] In summary, the technical effects achieved by the embodiments of this application are as follows: First, it significantly improves page update performance: by compiling the core page management algorithm into native code and executing it in parallel on a multi-core CPU, it achieves zero-GC parallel page state management, completely eliminating the thread synchronization overhead and garbage collection pauses in traditional managed code implementations, and ensuring frame rate stability.
[0079] Second, significantly improve the efficiency of indirect texture updates: By using a solution of lightweight collection of write requests on the CPU side and batch writing by the GPU side compute shaders, all write requests are submitted in the same graphics command buffer, eliminating CPU-GPU synchronization overhead and realizing batch updates of indirect textures on the GPU side.
[0080] Third, optimize the physical texture rendering pipeline: adopt a GPU-first rendering pipeline of "drawing full-screen mesh → multiple rendering targets → VT encoder compression → texture copying to physical texture", make full use of the GPU's parallel computing capabilities, and improve the storage efficiency and rendering throughput of physical textures.
[0081] Fourth, reduce the number of DrawCalls: By optimizing Atlas batch rendering, multiple pages are rendered to different viewport areas of the same Atlas intermediate texture, which significantly reduces rendering state switching and the number of DrawCalls, and improves GPU utilization.
[0082] Fifth, flexibly reduce memory usage: Through the Mip level skipping mechanism, developers are allowed to skip unnecessary Mip levels based on texture usage features, flexibly reducing the total number of pages and texture memory usage.
[0083] Sixth, ensure texture consistency during mode switching: Through the NeedsITRefresh flag mechanism, ensure that the indirect texture mapping of the already loaded page can be automatically restored when switching between indirect texture reconstruction mode and incremental mode, thus avoiding abnormal texture display.
[0084] Please see Figure 3 , Figure 3 This is a schematic diagram of the system structure of an embodiment of this application. Based on the above embodiment, this application also provides a virtual texture parallel page management system based on Clipmap, including a configuration module, a page management module, a GPU rendering and indirect texture update module, and a dynamic resource management module. All four modules rely on a data container module as a common underlying storage, and the data container module is the underlying data carrier shared by the four modules; wherein: The configuration module is used to create page data containers, tile data containers, indirect texture resources, physical texture resources, and finalizer resources; it calculates the number of pages and offsets at each Mip level based on the configuration parameters, and establishes a static mapping relationship between pages and physical tiles. The page management module is used to obtain the camera world coordinates, calculate the loading area in Mip layers, and traverse the page slots through a local compilation parallel task to complete the page state determination and classification. The GPU rendering and indirect texture update module specifically includes: an indirect texture update module, an indirect texture update mode decision-maker, a terminator module, and a page renderer module. It performs frame-by-frame truncation processing on classified pages, prioritizes rendering high-Mip, low-precision pages, completes physical texture rendering through the GPU pipeline, and updates indirect textures in batches according to the configuration mode. The dynamic resource management module, located in the finalizer module, is used to monitor the idle status of finalizer resources. When the idle status reaches a threshold, intermediate rendering resources are automatically released, and rendering resources are rebuilt on demand when a rendering requirement is triggered.
[0085] This application also provides a computer storage medium that can store an executable program. When the executable program is run on a computer, the computer executes the above-described Clipmap-based virtual texture parallel page management method.
[0086] This application also provides an electronic device, which includes a processor and a memory. The memory is used to store an executable program, and the processor is used to execute the executable program to implement the above-described Clipmap-based virtual texture parallel page management method.
[0087] It should be noted that those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, which may include, but is not limited to, read-only memory (ROM), random-access memory (RAM), magnetic disk or optical disk, etc.
[0088] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for parallel page management of virtual textures based on Clipmap, characterized in that, Includes the following steps: S1: Create page data container, tile data container, indirect texture resource, physical texture resource and finalizer resource and perform system initialization. Calculate the number of pages and offsets of each Mip layer according to the configuration parameters and establish a static mapping relationship between pages and physical tiles. S2: Obtain camera world coordinates, calculate the loading area in Mip layers, and traverse page slots through a parallel task compiled on the local machine to complete page state determination and classification; S3: Performs frame-by-frame truncation processing on category pages, prioritizes rendering high-Mip, low-precision pages, completes physical texture rendering through the GPU pipeline, and updates indirect textures in batches according to configuration mode. S4: Monitors the idle status of terminator resources. When the idle time reaches a threshold, intermediate rendering resources are automatically released. When rendering needs are triggered, they are rebuilt on demand.
2. The virtual texture parallel page management method based on Clipmap according to claim 1, characterized in that, The system initialization in step S1 includes: S11, Page data initialization; S12. Tile and physical texture initialization, including calculating the tile row and column arrangement based on tile size and physical texture size, pre-calculating the pixel coordinates and depth layer of each tile in the physical texture; and creating a two-dimensional texture array as the physical texture according to the texture format. S13. Indirect texture resource initialization, including creating a computation buffer to store write requests, loading the indirect texture to update the computation shader and obtain the kernel index, and initializing the indirect texture to a full-white invalid mapping; S14. Finalizer resource initialization, including distinguishing between resident mode, lazy mode, and immediate release mode based on idle release threshold, wherein: In resident mode, intermediate rendering textures and VT encoders are created directly. Lazy mode only creates the data container and rebuilds the resources on the first render. Instant release mode destroys intermediate textures immediately after each rendering is complete.
3. The method for parallel page management of virtual textures based on Clipmap according to claim 2, characterized in that, Step S11, page data initialization, specifically includes: S111 Load Range Configuration: Set the global default load range DefaultLoadRange as the base load range for all Mip levels, and configure the overrideLoadRanges array with Mip level as index; Mip levels with corresponding index data use their own load range to override DefaultLoadRange, and Mip levels without configuration use DefaultLoadRange as fallback. S112. Page count calculation: Based on the maximum Mip level and the independent loading range of each level, calculate MipSize = loadRange × 2 + 2, and the total number of pages pageNum = mipSize². S113, Mip Skip Mask Generation: Generate an integer skip Mip bit mask SkipMipMask from the SkipMips list. The number of Mip level pages marked for skipping by the mask is set to 0 and no page resources are allocated. Mip0, the highest precision level, and MaxMip, the lowest precision level, cannot be skipped. S114, Mask Filtering Rules: Parallel computing tasks and indirect texture writing processes are uniformly passed to SkipMipMask. The judgment formula (SkipMipMask >> Mip & 1) != 0 is used to identify the current Mip index Mip. If the judgment is true, all page updates and indirect texture writing processes of that Mip are skipped directly.
4. The virtual texture parallel page management method based on Clipmap according to claim 1, characterized in that, In step S2, page traversal includes incremental update mode and page integrity verification mode, wherein: Incremental update mode only traverses page slots within the camera loading range. When the page world coordinates change, the old position is added to the list to be cleared, and no separate list of pages to be eliminated is generated. The page integrity verification mode iterates through all page slots and calculates the expected world coordinates of the slots using the ClosestWorldCoord back-calculation algorithm. The algorithm calculation logic is as follows: centerLocal=PosMod(center,totalRange) diff=local-centerLocal If diff>totalRange / 2, diff=diff-totalRange; if diff< -totalRange / 2, then diff=diff+totalRange; Expected world coordinates = center + diff; In the formula: local represents the local coordinates of the slot, center represents the center coordinates of the current Mip level, and totalRange=loadRange×2+2 represents the total range of the Mip level.
5. The virtual texture parallel page management method based on Clipmap according to claim 1, characterized in that, The method for page frame truncation processing in step S3 is as follows: Pages to be processed are sorted from high to low according to Mip level, and the maximum processing page quota is allocated to each frame accordingly. Pages that have not exceeded the quota limit are marked as loaded and added to the drawing list; Pages exceeding the quota are marked as rollback pages and added to the rollback list; Prioritize processing high-Mip, low-precision pages to avoid blank texture blocks appearing in the distance of the scene.
6. The virtual texture parallel page management method based on Clipmap according to claim 1, characterized in that, In step S3, physical texture rendering is achieved through two GPU rendering pipelines, specifically: The single-page rendering pipeline includes sequentially performing full-screen mesh drawing, multi-render target MRT output, VT encoder GPU-side compression, and texture copying to physical texture for a single page. Each drawing independently performs render target setting and clearing operations. The Atlas batch rendering pipeline includes rendering multiple pages to different viewport areas of the same Atlas intermediate texture, performing render target setting and clearing only once; when the page exceeds the Atlas capacity, it is rendered in batches, and the encoding scheduling is performed only according to the texture layer number.
7. The virtual texture parallel page management method based on Clipmap according to claim 1, characterized in that, The indirect texture update in step S3 includes indirect texture reconstruction mode, incremental patch mode, and automatic selection mode, wherein: S31, Indirect texture reconstruction modes include: S311. Bind the indirect texture to the render target and clear it to a white invalid mapping; S312. Collect indirect texture write requests for all valid pages within the currently loaded range; S313. Execute SetRenderTarget (None) to unbind the render target binding and eliminate the resource state conflict when the render target RT switches to the unordered access view UAV. S314, Schedule computation shaders to write batches of indirect textures; S32, incremental patch mode includes: S321. Collect ancestor tile write requests for four types of objects: discarded pages, cleared pages, loaded pages, and back pages. S322. Using the width of the pixel block covered by the write request (width = 2^Mip level) as the sorting key, perform a descending stable sorting, and retain the original collection order for requests of the same Mip level; write low-precision large block requests first and high-precision small block requests last, and write high-precision tiles over low-precision mappings to avoid texture misalignment. S323. Schedule the compute shader to execute all write requests serially; S33. Automatic selection mode includes: configuring single frame update threshold and cumulative update threshold. When the number of page updates in this frame reaches the single frame threshold or the total number of cumulative updates reaches the cumulative threshold, switch to reconstruction mode and reset the cumulative count. The remaining frames adopt incremental patch mode.
8. The virtual texture parallel page management method based on Clipmap according to claim 6, characterized in that, The switching between rebuild mode and incremental patch mode is achieved through consistency repair of the NeedsITRefresh flag built into the page data structure, specifically as follows: When the reconstruction mode traverses the page, if the page is loaded but outside the current camera loading range, the NeedsITRefresh flag is set and the indirect texture mapping of the page is not written. When the camera moves and the page re-enters the loading range, the incremental mode detects the set NeedsITRefresh flag and automatically rewrites the indirect texture mapping data of the page, eliminating abnormal page texture display.
9. The virtual texture parallel page management method based on Clipmap according to claim 1, characterized in that, It also includes two working modes for the memory pre-computation auxiliary process, specifically: Runtime Precise Statistics Mode: Traverse all runtime resource objects and separately count the memory usage of CPU-side pages, tiles, and temporary lists, and the memory usage of GPU-side indirect textures, physical textures, and encoder buffers. Configuration prediction mode: Based solely on initial configuration parameters, Mip skip bit mask, and Atlas grid size, it predicts the total CPU and GPU memory usage without needing to start the runtime program; Both modes output structured memory usage details, summarizing the total memory consumption of CPU and GPU.
10. A Clipmap-based virtual texture parallel page management system, used to execute the Clipmap-based virtual texture parallel page management method according to any one of claims 1-9, characterized in that, It includes a configuration module, a page management module, a GPU rendering and indirect texture update module, and a dynamic resource management module, among which: The configuration module is used to create page data containers, tile data containers, indirect texture resources, physical texture resources, and finalizer resources; it calculates the number of pages and offsets at each Mip level based on the configuration parameters, and establishes a static mapping relationship between pages and physical tiles. The page management module is used to obtain the camera's world coordinates, calculate the loading area in Mip layers, and traverse the page slots through a parallel task of local compilation to complete the page state determination and classification. The GPU rendering and indirect texture update module is used to process the frame segmentation of the classification page, prioritize the rendering of high-Mip low-precision pages, complete the physical texture rendering through the GPU pipeline, and update the indirect texture in batches according to the configuration mode. The dynamic resource management module monitors the idle status of the finalizer resources. When the idle time reaches a threshold, intermediate rendering resources are automatically released, and rendering resources are rebuilt as needed when a rendering requirement is triggered.
