Search

CN-121614179-B - Direct3D rendering model compatible method based on dynamic template pool

CN121614179BCN 121614179 BCN121614179 BCN 121614179BCN-121614179-B

Abstract

The invention discloses a Direct3D rendering model compatible method based on a dynamic template pool, which comprises the steps of establishing three types of mapping tables between D3D and Vulkan and constructing resource metadata when compiling DXVK, establishing a core, expanding and temporary three-level template pool according to the mapping tables after starting, initializing metadata, checking parameters and distributing physical memory and grouping when a D3D application establishes resources, pre-checking a resource group to generate a batch binding command to complete memory binding and update metadata, matching templates from the template pool when establishing a resource view, generating handles and associating resource handles and binding descriptors after instantiation, respectively converting the mapping tables into Vulkan related states and instructions when setting a rendering state and executing the rendering instructions, inquiring PSO (program storage) buffer areas and submitting command buffer areas to a GPU (graphics processing unit) queue to execute drawing, and realizing the compatible operation of the D3D application on a Vulkan operating system platform under the condition that the GPU does not support VK KHR _main processing 5 and VK_ KHR _main processing 6 expansion.

Inventors

  • WEN YAN
  • LIU DONG

Assignees

  • 北京麟卓信息科技有限公司

Dates

Publication Date
20260508
Application Date
20260130

Claims (10)

  1. 1. A Direct3D rendering model compatible method based on a dynamic template pool is characterized by comprising the following steps: Step 1, building a first mapping table among purposes, formats and memory layouts of D3D resources when DXVK is compiled, building resource metadata according to a second mapping table among rendering states of D3D and Vulkan and a third mapping table among rendering instructions, generating a first configuration file of GPU capability and executing step 2 if the GPU does not support expansion of VK KHR main and VK KHR main and 6 after DXVK is started, otherwise executing DXVK standardized operation flow, and classifying the purposes into three types of class with values larger than a first threshold, class with values not larger than the first threshold and class with values not larger than a second threshold and class with values not larger than the second threshold according to the number of times of intra-frame use of resources; Step 2, DXVK, creating a three-level template pool according to a first mapping table, wherein the three-level template pool comprises a core template pool for storing resource view templates corresponding to one type of application, an extension template pool for storing resource view templates corresponding to two types of application and a temporary template pool for storing resource view templates corresponding to three types of application, and the various resource view templates are respectively stored in independent anonymous shared memories, and the corresponding resource view templates are preset in the core template pool and the extension template pool; The method comprises the steps of initializing resource metadata when a D3D application creates resources, checking creation parameters according to a first configuration file, distributing physical memory for the resources according to application and memory rules, dividing each type of resources into resource groups according to physical memory types, sizes and alignment modes, executing pre-verification on the resource groups in parallel to generate batch binding commands, executing the batch binding commands to finish binding of the physical memory to the resources to generate resource handles, updating the resource metadata, sequentially matching a core template pool and an expansion template pool to obtain templates when creating resource views, creating new templates in the temporary template pool if the resource views do not exist, creating resource view handles by the instantiated templates, associating the resource view handles with the resource handles, binding descriptors according to attributes of the resource views, acquiring context of the rendering state read descriptor binding from the resource metadata when setting rendering state, converting the rendering state into a Vulkan rendering state according to a third mapping table into Vulkan rendering command according to Vulkan when executing rendering command, inquiring PSO (program) buffer, and binding the current command to a current command buffer by the GPU (graphics processing unit) and executing the GPU; After the set frame number data is drawn, dynamically transferring the template with the use times exceeding the threshold value in the temporary template pool to the expansion template pool, destroying the template with the use times smaller than the threshold value, and releasing the corresponding shared memory page.
  2. 2. The Direct3D rendering model compatible method of claim 1, wherein the number of resources in the set of resources does not exceed a maximum single batch binding number of GPUs in the first configuration file.
  3. 3. The method of claim 1, wherein the method is performed after the batch binding command is generated by performing the pre-check on the resource group in parallel and before the batch binding command is performed, wherein the method comprises the steps of performing the quick check on the batch binding command to obtain the memory requirement including the size and the type of the resource group, comparing the memory requirement with the allocated memory blocks, screening error formation error codes which are not supported by the memory deficiency and the memory type, and then performing the batch binding command in a simulation mode to screen the depth error formation error codes which are incompatible in format, illegal in resource state and unmatched in alignment, generating complete error information comprising the ID of the resource group, the resource index, the error code, the error description and the proposal solution, and updating the batch binding command after correcting the errors one by one.
  4. 4. The Direct3D rendering model compatible method according to claim 1, wherein the binding of descriptors according to attributes of a resource view comprises: DXVK creating a three-level template pool, creating a three-level descriptor pool containing fixed, circulating and temporary, setting initial capacity of each level descriptor pool according to a first configuration file, initializing the fixed descriptor pool as an idle descriptor linked list, initializing the circulating descriptor pool as an LRU linked list and initializing the temporary descriptor pool as an intra-frame idle queue, acquiring types and life cycles of application corresponding to resource views after associating resource view handles with the resource handles, preferentially multiplexing idle slots of the fixed description Fu China for one type of long-period resource views, preferentially multiplexing idle slots of the circulating description Fu China for one type of medium-period or two types of long-period resource views, preferentially multiplexing idle slots of the temporary description Fu China for two types of medium-period or three types of short-period resource views, and completing binding of descriptors, wherein the life cycles of the resource views are long periods when being larger than a larger threshold, medium periods when being not larger than a smaller threshold, and short periods when being not larger than the smaller threshold.
  5. 5. The Direct3D rendering model compatible method according to claim 4, wherein when a class of long-period resource view multiplexes free slots of a fixed description Fu China, if there is no free space in a fixed descriptor pool, the capacity of the pool is enlarged according to a preset step size, when a class of medium-period or class of long-period resource view multiplexes cyclic descriptor pools and allocates slots according to an LRU linked list, if the cyclic descriptor pool is full, the longest unused slots are recovered and then the resource view is bound, and when a class of medium-period or class of three short-period resource view multiplexes temporary description Fu China of free slots released from a current frame, if there is no free slot, a new slot rebinding resource view is temporarily created.
  6. 6. The Direct3D rendering model compatible method according to claim 4, wherein the setting of the initial capacity of each level of descriptor pool according to the first configuration file is performed by setting the initial capacity of each level of pool according to the maximum number of single-type descriptors in the GPU capability configuration file, wherein the initial capacity allocated by the fixed descriptor pool is 30% of the maximum number of single-type descriptors, the initial capacity allocated by the cyclic descriptor pool is 20% of the maximum number of single-type descriptors, and the initial capacity allocated by the temporary descriptor pool is 10% of the maximum number of single-type descriptors.
  7. 7. The method for compatible Direct3D rendering model of claim 1, wherein the method for generating the batch binding command by executing the pre-verification on the resource groups in parallel is characterized in that a pre-verification thread pool matched with the CPU core number is initialized, an independent thread is allocated to each resource group, the pre-verification of the memory matching property, the format support property and the resource status validity of the physical memory of the resource group and the corresponding resource is executed in parallel by the thread, the pre-verification results of the verification passing and the suspected failure are obtained, the verification state of each resource group is marked according to the pre-verification results, and the batch binding command comprising the resource group list, the memory block information and the pre-verification results is formed.
  8. 8. The Direct3D rendering model compatible method of claim 1, wherein the page table entry of the shared memory page of the core template pool is set to a global page table entry and TLB cache flushing is disabled, the page table entry of the shared memory page of the extended template pool is set to a cacheable page table entry and TLB caching is enabled, and the page table entry of the shared memory page of the temporary template pool is set to a temporary page table entry and is preferentially reclaimed.
  9. 9. The Direct3D rendering model compatible method according to claim 8, wherein when the shared memory corresponding to the temporary template pool is insufficient, the kernel interface is called to expand the shared memory, and a physical memory page is allocated for the instantiation template, and an attribute of a memory page table is set according to a resource type.
  10. 10. The Direct3D rendering model compatible method according to claim 1, wherein a binary bitmap with initial values of all zero corresponding to slots is set for a descriptor set, a resource view to be bound is traversed and compared with the resource view in the previous frame data, only slots corresponding to the resource view with handles or parameters changed are marked as 1, no change is made, the slots marked as 1 in the binary bitmap are updated, handles and memory layout are updated for samplers or image descriptors, handles or offsets are updated for buffer descriptors, the descriptor set with changes larger than a set number of times is cached for each frame, and the binary bitmap and updated parameters are directly multiplexed when the same binary bitmap appears again.

Description

Direct3D rendering model compatible method based on dynamic template pool Technical Field The invention belongs to the technical field of computer software development, and particularly relates to a Direct3D rendering model compatible method based on a dynamic template pool. Background DXVK is used as an open source cross-platform graphic interface translation layer, and the core function of the translation layer is to convert Direct3D (D3D 9-11) interface call of a Windows platform into Vulkan interface call of a Linux platform, so that the operation of Windows application on a Linux system is realized. The conversion process is highly dependent on two Vulkan maintenance extensions of VK_ KHR _main and VK_ KHR _main, which respectively bear the core functions of VK_ KHR _main 5 creating limit by relaxing VkBufferView and VKIMAGEVIEW, optimizing resource life cycle management logic, aligning rendering state machine behaviors of D3D and Vulkan, realizing seamless mapping of a D3D resource model and rendering logic to Vulkan, and VK_ KHR _main 6 supporting NULL index buffer, providing batch memory binding error positioning capability, expanding descriptor management mechanism and combination counting control, so as to ensure the stability and high efficiency of a rendering process. However, when the GPU does not support the two extensions, the existing solution and the existing shortcomings mainly include firstly, adopting a mode of pre-creating multiple groups BufferView and IMAGEVIEW to replace flexible creation capability, leading to exponential increase of memory occupation, particularly easily causing memory overflow under the conditions of frequent switching of a buffer area and image use of a D3D game, secondly, splitting batch memory binding into binding one by one to realize error positioning, leading to rapid increase of CPU interface calling overhead, and reduction of frame rate by 30% to 50%, thirdly, supporting NULL index scene through pre-allocation placer index buffering, not only wasting memory resources, but also having the problems of inflexible format adaptation and failure of multi-vertex buffer binding scene processing, fourthly, adopting a fixed capacity design for descriptor pool management, being incapable of dynamically adapting to high-frequency switching requirements of a D3D game, easily causing contradiction of descriptor overflow or resource idle, and fifthly, not fully covering points of basic specifications of a D3D state machine and Vulkan, leading to picture distortion of state mapping such as mixed mode, depth test and the like. In summary, the existing scheme does not start from the nature of the conversion flow from D3D to Vulkan, lacks accurate simulation of the extended function, and does not fully utilize the collaborative optimization capability of the system kernel and DXVK, so that compatibility, performance and memory occupation are difficult to balance. Disclosure of Invention In view of this, the present invention provides a Direct3D rendering model compatible method based on a dynamic template pool, which realizes compatible running of D3D applications on an operating system platform supporting Vulkan without supporting vk_ KHR _main ntenance5 and vk_ KHR _main ntenance6 extensions. The invention provides a Direct3D rendering model compatible method based on a dynamic template pool, which specifically comprises the following steps: Step 1, building a first mapping table among purposes, formats and memory layouts of D3D resources when DXVK is compiled, building resource metadata according to a second mapping table among rendering states of D3D and Vulkan and a third mapping table among rendering instructions, generating a first configuration file of GPU capability and executing step 2 if the GPU does not support expansion of VK KHR main and VK KHR main and 6 after DXVK is started, otherwise executing DXVK standardized operation flow, and classifying the purposes into three types of class with values larger than a first threshold, class with values not larger than the first threshold and class with values not larger than a second threshold and class with values not larger than the second threshold according to the number of times of intra-frame use of resources; Step 2, DXVK, creating a three-level template pool according to a first mapping table, wherein the three-level template pool comprises a core template pool for storing resource view templates corresponding to one type of application, an extension template pool for storing resource view templates corresponding to two types of application and a temporary template pool for storing resource view templates corresponding to three types of application, and the various resource view templates are respectively stored in independent anonymous shared memories, and the corresponding resource view templates are preset in the core template pool and the extension template pool; The method comprises the steps of initializi