Rendering command generation method and device, equipment and medium
By using preset rendering commands and unified function interfaces in the new generation of graphics APIs, the binding commands for rendering channel resources are automatically generated, which solves the problem of complexity in rendering command generation under the new generation of APIs, and simplified rendering command generation and improved development efficiency are achieved.
Patent Information
- Application Number
- CN202411575289.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-06
- Publication Date
- 2025-02-25
AI Technical Summary
The large amount of freedom open to the new generation of graphics APIs improves the utilization of hardware performance, but at the same time increases the complexity of program development, especially in terms of rendering channel resource binding, developers need to manually write complex rendering commands.
Through the unified function interface of the general rendering command class among the preset N rendering commands, combined with the binding information of the formal parameters and actual parameters of the rendering channel, the rendering command for binding resources is automatically generated, simplifying the generation process of rendering commands.
Developers do not need to manually write programs during each binding process of formal parameters and actual parameters, which simplifies the generation of rendering commands and improves the development and maintenance efficiency of three-dimensional software under image API systems such as Vulkan, Metal and D3D12.
Smart Images

Figure CN119516070A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of image rendering, and in particular relates to a rendering command generation method, device, equipment and medium. Background Art
[0002] With the gradual popularity of the three new-generation graphics application programming interfaces (APIs), Vulkan, Metal, and D3D12, developers have greatly enhanced their control over the underlying hardware of the graphics processing unit (GPU), allowing the behavior of the hardware to be controlled more accurately, thereby maximizing the use of hardware performance. However, the large amount of freedom opened up by the new-generation graphics APIs has greatly increased the complexity of program development while liberating hardware performance. Specifically, with regard to rendering channel resource binding, the new-generation APIs leave all the relevant details to the developer, resulting in more complex generation of rendering commands. Summary of the invention
[0003] In view of the above-mentioned shortcomings of the prior art, an object of the present invention is to provide a rendering command generation method, device, equipment and medium to solve the above-mentioned problems.
[0004] The rendering command generation method provided by the present invention comprises:
[0005] Receive a preset first rendering command, wherein the preset first rendering command is any one of N preset rendering commands; wherein the N preset rendering commands all include a general rendering command class, wherein the general rendering command class includes a unified function interface, wherein the unified function interface is determined according to common parameters of the N rendering commands in a graphics application programming interface (API), wherein the N preset rendering commands also include corresponding member variables, wherein the corresponding member variables are determined according to non-common parameters corresponding to the N rendering commands in the graphics API, and N is an integer greater than 1;
[0006] Receive binding information of formal parameters and actual parameters corresponding to a rendering pass, where the binding information is obtained by binding the actual parameters to the formal parameters of the rendering pass;
[0007] The unified function interface is called to generate a first rendering command for binding resources based on the preset first rendering command and the binding information.
[0008] In one embodiment of the present invention, the member variables corresponding to the preset N rendering commands are initialized through a constructor.
[0009] In one embodiment of the present invention, after receiving the binding information of the formal parameters and actual parameters corresponding to the rendering pass, the method further includes:
[0010] Determining a demand state of a target resource in the rendering channel based on binding information of formal parameters and actual parameters of the rendering channel;
[0011] Determining whether the required state of the target resource is consistent with the current state of the target resource in the rendering channel;
[0012] In the rendering channel, when the required state of the target resource is inconsistent with the current state of the target resource, a conversion command for converting the state of the target resource in the rendering channel to the required state is generated.
[0013] In an embodiment of the present invention, after generating a conversion command for converting the state of the target resource in the rendering channel to the required state, the method further includes:
[0014] In the running stage, the conversion command is run;
[0015] After executing the conversion command, executing the first rendering command of the bound resource.
[0016] In one embodiment of the present invention, the conversion command is generated in a compile phase before the run phase.
[0017] In an embodiment of the present invention, after generating a conversion command for converting the state of the target resource in the rendering channel to the required state, the method further includes:
[0018] During the compilation phase, the conversion command is loaded into a data container;
[0019] In the compiling stage, after the conversion command is loaded into the data container, the first rendering command of the bound resource is loaded into the data container;
[0020] During the running phase, the data container is traversed from the beginning to the end in the order in which the commands are loaded.
[0021] In one embodiment of the present invention, the calling of the unified function interface to generate the first rendering command of the bound resource based on the preset first rendering command and the binding information includes:
[0022] In the compiling stage, the unified function interface is called to generate a first rendering command for an initial binding resource based on the preset first rendering command and the binding information;
[0023] During the compilation stage, based on preset conversion rules, the formal parameters in the first rendering command of the initial binding resource are converted into digital indexes recognizable by the graphics API, and the actual parameters in the first rendering command of the initial binding resource are converted into digital indexes recognizable by the graphics API, so as to obtain the first rendering command of the binding resource.
[0024] The rendering command generating device provided by the present invention comprises:
[0025] A first receiving module is used to receive a preset first rendering command, wherein the preset first rendering command is any one of N preset rendering commands; wherein the N preset rendering commands all include a general rendering command class, wherein the general rendering command class includes a unified function interface, wherein the unified function interface is determined according to common parameters of the N rendering commands in a graphics application programming interface (API), wherein the N preset rendering commands also include corresponding member variables, wherein the corresponding member variables are determined according to non-common parameters corresponding to the N rendering commands in the graphics API, and N is an integer greater than 1;
[0026] A second receiving module is used to receive binding information of formal parameters and actual parameters corresponding to a rendering channel, where the binding information is obtained by binding the actual parameters to the formal parameters of the rendering channel;
[0027] The first generating module is used to call the unified function interface and generate a first rendering command for binding resources based on the preset first rendering command and the binding information.
[0028] In one embodiment of the present invention, the member variables corresponding to the preset N rendering commands are initialized through a constructor.
[0029] In one embodiment of the present invention, the device further comprises:
[0030] A determination module, which determines the demand state of the target resource in the rendering channel based on the binding information of the formal parameters and the actual parameters of the rendering channel;
[0031] A judgment module, used for judging whether the required state of the target resource is consistent with the current state of the target resource in the rendering channel;
[0032] The second generating module is used to generate a conversion command for converting the state of the target resource in the rendering channel into the required state when the required state of the target resource is inconsistent with the current state of the target resource in the rendering channel.
[0033] In one embodiment of the present invention, the device further includes an operation module, configured to:
[0034] In the running stage, the conversion command is run;
[0035] After executing the conversion command, executing the first rendering command of the bound resource.
[0036] In one embodiment of the present invention, the conversion command is generated in a compile phase before the run phase.
[0037] In one embodiment of the present invention, the device further comprises:
[0038] A first loading module, used for loading the conversion command into a data container during the compiling stage;
[0039] A second loading module is used for loading the first rendering command of the bound resource into the data container after the conversion command is loaded into the data container during the compiling phase;
[0040] The running module is used to traverse the data container from the beginning to the end according to the order of command loading during the running stage.
[0041] In one embodiment of the present invention, the first generating module is specifically used for:
[0042] In the compiling stage, the unified function interface is called to generate a first rendering command for an initial binding resource based on the preset first rendering command and the binding information;
[0043] During the compilation stage, based on preset conversion rules, the formal parameters in the first rendering command of the initial binding resource are converted into digital indexes recognizable by the graphics API, and the actual parameters in the first rendering command of the initial binding resource are converted into digital indexes recognizable by the graphics API, so as to obtain the first rendering command of the binding resource.
[0044] The electronic device provided by the present invention comprises:
[0045] one or more processors;
[0046] The storage device is used to store one or more programs, and when the one or more programs are executed by the one or more processors, the electronic device implements the rendering command generation method.
[0047] The computer-readable storage medium provided by the present invention stores a computer program, and when the computer program is executed by a processor of a computer, the computer is enabled to execute the rendering command generating method.
[0048] Beneficial effects of the present technical solution: The N rendering commands preset in the present technical solution all include a general rendering command class. The unified function interface in the general rendering command is determined by extracting the common parameters of the N rendering commands in the graphics API. By calling the unified function interface, the function implementation can automatically generate a program that binds actual parameters to formal parameters. Based on this, after receiving the preset first rendering command and the binding information of the formal parameters and actual parameters corresponding to the rendering channel, the present solution calls the unified function interface to automatically generate the first rendering command for binding resources. It can be seen that the adoption of the present technical solution does not require developers to manually write relevant programs in each process of binding formal parameters and actual parameters. By automatically generating a program for binding rendering channel resources in the rendering command, the generation of rendering commands can be simplified.
[0049] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present application, and together with the specification, are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0051] Figure 1 is one of the flowcharts of an exemplary embodiment of the present application showing a method for generating a rendering command;
[0052] Figure 2 is a flow chart of a digital index conversion method shown in an exemplary embodiment of the present application;
[0053] Figure 3 is a second flowchart of a method for generating a rendering command according to an exemplary embodiment of the present application;
[0054] Figure 4 is a schematic structural diagram of an exemplary embodiment of the present application showing a rendering command generating device;
[0055] Figure 5 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION
[0056] The following will describe the embodiments of the present invention with reference to the accompanying drawings and preferred embodiments. Those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. The present invention can also be implemented or applied through other different specific embodiments, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present invention. It should be understood that the preferred embodiments are only for illustrating the present invention, not for limiting the scope of protection of the present invention.
[0057] It should be noted that the illustrations provided in the following embodiments are only schematic illustrations of the basic concept of the present invention, and thus the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the type, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.
[0058] In the following description, numerous details are discussed to provide a more thorough explanation of the embodiments of the present invention. However, it is obvious to those skilled in the art that the embodiments of the present invention can be implemented without these specific details. In other embodiments, well-known structures and devices are shown in the form of block diagrams rather than in detail to avoid making the embodiments of the present invention difficult to understand.
[0059] See also Figure 1 , Figure 1 FIG. 1 is one of the flowcharts of a rendering command generation method shown in an exemplary embodiment of the present application. Figure 1 As shown, the method includes steps S110 to S130, which are described in detail as follows:
[0060] Step 110: receiving a preset first rendering command, wherein the preset first rendering command is any one of N preset rendering commands; wherein the N preset rendering commands all include a general rendering command class, wherein the general rendering command class includes a unified function interface, wherein the unified function interface is determined according to common parameters of the N rendering commands in a graphics application programming interface (API), wherein the N preset rendering commands also include corresponding member variables, wherein the corresponding member variables are determined according to non-common parameters corresponding to the N rendering commands in the graphics API, and N is an integer greater than 1;
[0061] Step 120: Receive binding information of formal parameters and actual parameters corresponding to a rendering pass, where the binding information is obtained by binding the actual parameters to the formal parameters of the rendering pass;
[0062] Step 130: Call the unified function interface to generate a first rendering command for binding resources based on the preset first rendering command and the binding information.
[0063] In step 110, the preset N rendering commands are N templates preset by the developer. None of the preset N rendering commands are bound to specific channel resources, and the preset N rendering commands can be understood as preset N rendering command object classes. The preset N rendering commands are used to generate rendering commands bound to resources, that is, to generate rendering command objects, based on the binding information of rendering channel formal parameters and actual parameters during the rendering process.
[0064] The above-mentioned N preset rendering commands all include a general rendering command class. In some embodiments, the general rendering command class can be used as a base class of the N preset rendering commands, and the N preset rendering commands are inherited from the general rendering command class as subclasses. The above-mentioned generated rendering command object can be represented by the general rendering command class.
[0065] The general rendering command class includes a unified function interface. Before determining the preset N rendering commands, you first need to determine the unified function interface. The unified function interface is determined based on the common parameters of the N rendering commands in the graphics API. That is, the above-mentioned unified function interface can be formed by extracting the common parameters of the N rendering commands in the graphics API. The unified function interface is used to declare that the above-mentioned common parameters are submitted to the GPU (regardless of which command among the preset N rendering commands, the above-mentioned common parameters need to be submitted to the GPU). And by calling the unified function interface, the implementation inside the function can bind formal parameters and actual parameters, and automatically generate related programs for resource binding.
[0066] The preset N rendering commands also include corresponding member variables, and the corresponding member variables are determined according to the non-common parameters corresponding to the N rendering commands in the graphics API. For example, among the N rendering commands, rendering command A includes parameter a but does not include parameter b, and rendering command b includes parameter b but does not include parameter a. Then, it can be obtained that the member variables of the preset rendering command A include parameter a, and the member variables of the preset rendering command B include parameter b.
[0067] It should be understood that the N rendering commands in the graphics API refer to the official command prototypes in the graphics API (Vulkan, Metal or D3D12). The N rendering commands preset in this application are obtained by structural improvement based on the N rendering command prototypes, but the actual core content has not changed. For example, the N rendering commands preset in this application include a preset rendering target setting command, which has the same core content as the rendering target setting command in the graphics API but has a different structure. Specifically, the rendering target setting command preset in this application uses the general rendering command class as the base class, and its corresponding member variables are set as subclass members.
[0068] In step 102, binding information of formal parameters and actual parameters corresponding to the rendering pass is received, and the binding information is obtained by binding the actual parameters to the formal parameters of the rendering pass, that is, by setting the actual parameters corresponding to the formal parameters of the rendering pass. In some embodiments, a set of codes can be pre-set to set the actual parameters corresponding to the formal parameters of the rendering pass.
[0069] In step 103, a unified function interface (overridable in a subclass) is called, and based on a preset first rendering command and binding information, a binding program of formal parameters and actual parameters can be automatically generated, thereby obtaining a first rendering command with bound resources.
[0070] In the embodiment of the present application, the rendering command submission code is digitized, and the common parameters of the N rendering commands in the graphics API are extracted to determine the unified function interface in the general rendering command class; the general rendering command class is used as the base class of the above-mentioned preset N rendering commands, and the corresponding non-common parameters are used as member variables corresponding to the preset N rendering commands. In the specific rendering process, by receiving the preset first rendering command and the binding information of the formal parameters and actual parameters corresponding to the rendering channel, and calling the unified function interface, the first rendering command for binding resources can be automatically generated. It can be seen that the technical solution of the present application does not require developers to manually write relevant programs in each process of binding formal parameters and actual parameters, which can simplify the generation of rendering commands and effectively improve the development and maintenance efficiency of three-dimensional software under the image API system represented by Vulkan, Metal and D3D12.
[0071] In one embodiment of the present invention, the member variables corresponding to the preset N rendering commands are initialized through a constructor.
[0072] Initializing member variables through the constructor allows each newly created object to start from a known and valid state, helping to prevent objects from being in an uncertain or invalid state after creation.
[0073] In one embodiment of the present invention, after receiving the binding information of the formal parameters and actual parameters corresponding to the rendering pass, the method further includes:
[0074] Determining a demand state of a target resource in the rendering channel based on binding information of formal parameters and actual parameters of the rendering channel;
[0075] Determining whether the required state of the target resource is consistent with the current state of the target resource in the rendering channel;
[0076] In the rendering channel, when the required state of the target resource is inconsistent with the current state of the target resource, a conversion command for converting the state of the target resource in the rendering channel to the required state is generated.
[0077] In this implementation, based on the binding information of the formal parameters and actual parameters of the rendering channel, the required state of the target resource under the rendering channel can be derived. For example, if the formal parameter of the rendering channel is depth write and the binding actual parameter is texture 1, then the resource of the rendering channel (texture 1) should be in the depth write state, that is, the required state of the target resource under the rendering channel is the depth write state.
[0078] The embodiment of the present application determines whether the required state of the target resource is consistent with the current state of the target resource in the rendering channel. If they are consistent, there is no need to generate a state conversion command. If they are inconsistent, a conversion command is generated to convert the state of the target resource in the rendering channel to the required state.
[0079] By adopting the technical solution of the embodiment of the present application, it is automatically determined whether the state conversion of resources is required, which effectively improves the development and maintenance efficiency of three-dimensional software under the image API system represented by Vulkan, Metal and D3D12.
[0080] In an embodiment of the present invention, after generating a conversion command for converting the state of the target resource in the rendering channel to the required state, the method further includes:
[0081] In the running stage, the conversion command is run;
[0082] After executing the conversion command, executing the first rendering command of the bound resource.
[0083] In the embodiment of the present application, when a conversion command exists, the conversion command is executed first and then the first rendering command of the bound resource is executed, which is beneficial to the correctness of the rendering result.
[0084] In one embodiment of the present invention, the conversion command is generated in a compile phase before the run phase.
[0085] In the embodiment of the present application, when it is necessary to generate a conversion command, it is directly generated in the compilation stage, which is beneficial to the operating efficiency in the running stage.
[0086] In an embodiment of the present invention, after generating a conversion command for converting the state of the target resource in the rendering channel to the required state, the method further includes:
[0087] During the compilation phase, the conversion command is loaded into a data container;
[0088] In the compiling stage, after the conversion command is loaded into the data container, the first rendering command of the bound resource is loaded into the data container;
[0089] During the running phase, the data container is traversed from the beginning to the end in the order in which the commands are loaded.
[0090] In an embodiment of the present application, the conversion command and the first rendering command of the bound resource are sequentially loaded into the data container in the above order. During the running stage, the data container can be traversed in the order of loading from first to last to implement the call to the graphics API, thereby completing the rendering.
[0091] In one embodiment of the present invention, the calling of the unified function interface to generate the first rendering command of the bound resource based on the preset first rendering command and the binding information includes:
[0092] In the compiling stage, the unified function interface is called to generate a first rendering command for an initial binding resource based on the preset first rendering command and the binding information;
[0093] During the compilation stage, based on preset conversion rules, the formal parameters in the first rendering command of the initial binding resource are converted into digital indexes recognizable by the graphics API, and the actual parameters in the first rendering command of the initial binding resource are converted into digital indexes recognizable by the graphics API, so as to obtain the first rendering command of the binding resource.
[0094] See also Figure 2 During the compilation phase, based on the rendering channel file and preset conversion rules (such as the mapping relationship between formal parameters and binding point numeric indexes, the binding relationship between formal parameters and actual parameters, etc.), formal parameters can be converted into numeric indexes recognizable by the graphics API, and actual parameters can be converted into numeric indexes recognizable by the graphics API.
[0095] This application converts the above parameters into digital indexes recognizable by the graphics API during the compilation phase, and directly transmits the digital indexes to the graphics API during the runtime phase, thereby enabling direct and efficient API calls.
[0096] Among them, it is worth noting that Figure 3 As shown, when there is a state conversion command, the state conversion command needs to be inserted into the data container first, and then the rendering command object is inserted into the data container.
[0097] In order to more clearly understand the technical solution of the embodiments of the present application, an exemplary description is given below in conjunction with specific embodiments.
[0098] Taking D3D12 as an example, two common rendering commands are setting the rendering target and binding the resource root signature, and their official API prototypes correspond to:
[0099]
[0100]
[0101] In the above two codes a and b, we can see that the common point between setting the rendering target and resource root signature binding is that they both require an ID3D12GraphicsCommandList object, so a parameter of type ID3D12GraphicsCommandList* can be used as a common parameter, and the remaining information such as UINTNumRenderTargetDescriptors, const D3D12_CPU_DESCRIPTOR_HANDLE*pRenderTargetDescriptors and UINT RootParameterIndex are used as non-common information to become member variables of the corresponding rendering command object class (i.e., the preset rendering command), and its initialization scheme can be initialized directly by the constructor. Taking D3D12 as an example, the rendering command object class corresponding to the rendering target can be preset as:
[0102]
[0103] List*cmdList)const override is to call the unified function interface, which actually calls the D3D12 official API-OMSetRenderTargets. When calling this interface, the caller only needs to provide the specific ID3D12GraphicsCommandList* parameter, and the other parameters required by OMSetRenderTargets are directly provided by the member variables of the DrawCallMetaData_RenderTarget object, such as numRTVs, which is the parameter UINT NumRenderTargetDescriptors of OMSetRenderTargets. The initialization of numRTVs is completed by the constructor.
[0104] From the above code, we can see that the general rendering command class DrawCallMetaData_Interface is used as a base class to represent different rendering command object classes. Its code is as follows:
[0105]
[0106] Using the DrawCallMetaData_Interface* type as a general type can represent different rendering command objects. Through the parameter-actual parameter binding information of the rendering channel, the above rendering command objects can be automatically generated in batches, that is, rendering commands for binding resources are generated. Taking the setting of the rendering command object corresponding to the rendering target as an example, the C++ code can be set to maintain the parameter-actual parameter binding information of the shader, for example:
[0107] Shaders["ShaderName"]["RenderTargetName"]=
[0108] Resources["ResourceName"]["DescriptorHandleName"];
[0109] The above code sets the render target parameter named "RenderTargetName" in the shader named "ShaderName" to the D3D12_CPU_DESCRIPTOR_HANDLE type object named "DescriptorHandleName" under "ResourceName". Based on this parameter-argument binding information, the setting of DrawCallMetaData_RenderTarget::RenderTargetInfo::rtvs can be realized through program automation. Based on this, this application can automatically generate rendering command objects in batches.
[0110] After obtaining the binding information of the formal and actual parameters of the rendering channel, it is also necessary to determine whether the state of the resource needs to be converted in the rendering channel. An exemplary implementation scheme is:
[0111] a1. Based on the parameter-argument binding information of the rendering channel, deduce the state required by the resource during the running of the rendering channel:
[0112] auto stateOld=RenderPasses["Last"]["ParameterName"];
[0113] auto stateCurrent=RenderPasses["Current"]["ParameterName"];
[0114] Among them, stateOld represents the current state of the resources in the rendering channel, and stateCurrent represents the required state of the resources in the rendering channel.
[0115] a2. Read the required state of the resource and compare it with the existing state. Based on the state comparison, decide whether a state transition is required before starting this rendering pass. If necessary, automatically add a state transition command:
[0116] if(stateOld!=stateCurrent)
[0117] pDrawCallMetaData=new DrawCallMetaData_StateTransition{stateOld,stateCurrent};
[0118] In this implementation, by comparing the current state stateOld of the resource in the rendering channel with the required state of the resource in the rendering channel, it can be determined whether a state transition is required.
[0119] When a state transition is required, a state transition command object of type DrawCallMetaData_StateTransition (pointed to by pDrawCallMetaData) may be generated.
[0120] It is worth mentioning that if Figure 2 and Figure 3 As shown, before inserting the rendering command object into the data container, the input actual parameter can also be converted into a numerical index recognizable by the graphics API, and then inserted into the data container in sequence. An exemplary implementation scheme is:
[0121] b1. Generate a rendering command object based on the actual parameters and the parameter binding information corresponding to the rendering channel. Taking the rendering target setting as an example, the code includes:
[0122]
[0123] Here, the parameter ID "RenderTargetName" is converted to the numeric index renderTargetIndex recognizable by the graphics API, and the correct actual parameter Resources["ResourceName"]["DescriptorHandleName"] is filled in the corresponding position in the rendering command object cmdObject accordingly, realizing the conversion of the actual parameter to the numeric index recognizable by the graphics API;
[0124] b2: See Figure 3 , load the rendering command objects in b1 into the data container in order, and insert the resource state conversion command objects as needed. At this point, the compilation phase has been completed. The specific code example is as follows:
[0125]
[0126] Here, drawCmds represents the data container. If the state transition object pDrawCallMetaData_StateTransition exists, it is added to drawCmds first, and then the standard rendering command object pDrawCallMetaData is added to the container in sequence.
[0127] b3: During the running phase, the data container described in b2 is traversed in order to call the rendering API, thereby completing the rendering:
[0128] for(auto const&item:drawCmds)item->CmdListSubmit(cmdList);
[0129] At run time, by directly traversing the data container in order, similar to the range-based-for method provided by C++, and calling the CmdListSubmit function in order, the submission of rendering commands and subsequent rendering work can be completed.
[0130] In addition, it is worth noting that at this time, drawCmds stores digital indexes that are directly identifiable by the graphics API rather than IDs (formal parameter strings and actual parameter strings). Therefore, no overhead is incurred in the runtime phase to find resources by ID. ID search only occurs in the compilation phase b2 after the user configures the rendering pipeline resource binding information.
[0131] The above-mentioned compile-run dual-stage design framework is conducive to the convenience of configuring the rendering pipeline and the efficiency of runtime.
[0132] Figure 4 FIG. 1 is a block diagram of a rendering command generating device shown in an exemplary embodiment of the present application. Figure 4 As shown, the device comprises:
[0133] The first receiving module 410 is used to receive a preset first rendering command, wherein the preset first rendering command is any one of the preset N rendering commands; wherein the preset N rendering commands all include a general rendering command class, wherein the general rendering command class includes a unified function interface, wherein the unified function interface is determined according to common parameters of the N rendering commands in a graphics application programming interface (API), wherein the preset N rendering commands also include corresponding member variables, wherein the corresponding member variables are determined according to non-common parameters corresponding to the N rendering commands, and N is an integer greater than 1;
[0134] A second receiving module 420 is used to receive binding information of formal parameters and actual parameters corresponding to a rendering channel, where the binding information is obtained by binding the actual parameters to the formal parameters of the rendering channel;
[0135] The first generating module 430 is used to call the unified function interface and generate a first rendering command for binding resources based on the preset first rendering command and the binding information.
[0136] In one embodiment of the present invention, the member variables corresponding to the preset N rendering commands are initialized through a constructor.
[0137] In one embodiment of the present invention, the device further comprises:
[0138] A determination module, which determines the demand state of the target resource in the rendering channel based on the binding information of the formal parameters and the actual parameters of the rendering channel;
[0139] A judgment module, used for judging whether the required state of the target resource is consistent with the current state of the target resource in the rendering channel;
[0140] The second generating module is used to generate a conversion command for converting the state of the target resource in the rendering channel into the required state when the required state of the target resource is inconsistent with the current state of the target resource in the rendering channel.
[0141] In one embodiment of the present invention, the device further includes an operation module, configured to:
[0142] In the running stage, the conversion command is run;
[0143] After executing the conversion command, executing the first rendering command of the bound resource.
[0144] In one embodiment of the present invention, the conversion command is generated in a compile phase before the run phase.
[0145] In one embodiment of the present invention, the device further comprises:
[0146] A first loading module, used for loading the conversion command into a data container during the compiling stage;
[0147] A second loading module is used for loading the first rendering command of the bound resource into the data container after the conversion command is loaded into the data container during the compiling phase;
[0148] The running module is used to traverse the data container from the beginning to the end according to the order of command loading during the running stage.
[0149] In one embodiment of the present invention, the first generating module 430 is specifically used for:
[0150] In the compiling stage, the unified function interface is called to generate a first rendering command for an initial binding resource based on the preset first rendering command and the binding information;
[0151] During the compilation stage, based on preset conversion rules, the formal parameters in the first rendering command of the initial binding resource are converted into digital indexes recognizable by the graphics API, and the actual parameters in the first rendering command of the initial binding resource are converted into digital indexes recognizable by the graphics API, so as to obtain the first rendering command of the binding resource.
[0152] It should be noted that the rendering command generation device provided in the above embodiment and the rendering command generation method provided in the above embodiment belong to the same concept, wherein the specific manner in which each module and unit performs the operation has been described in detail in the method embodiment, and will not be repeated here. In actual application, the # device provided in the above embodiment can distribute the above functions to different functional modules as needed, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not limited here.
[0153] An embodiment of the present application also provides an electronic device, comprising: one or more processors; a storage device for storing one or more programs, and when the one or more programs are executed by the one or more processors, the electronic device implements the rendering command generation method provided in the above-mentioned embodiments.
[0154] Figure 5 The structure diagram of the computer system suitable for implementing the electronic device of the embodiment of the present application is shown. It should be noted that: Figure 5 The computer system 500 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0155] like Figure 5 As shown, the computer system 500 includes a central processing unit (CPU) 501, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 502 or the program loaded from the storage part 508 to the random access memory (RAM) 503, such as executing the method described in the above embodiment. In the RAM 503, various programs and data required for system operation are also stored. The CPU 501, the ROM 502 and the RAM 503 are connected to each other through the bus 504. The input / output (I / O) interface 505 is also connected to the bus 504.
[0156] The following components are connected to the I / O interface 505: an input section 506 including a keyboard, a mouse, etc.; an output section 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker; a storage section 508 including a hard disk, etc.; and a communication section 509 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the I / O interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed so that a computer program read therefrom is installed into the storage section 508 as needed.
[0157] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a computer program for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 509, and / or installed from a removable medium 511. When the computer program is executed by a central processing unit (CPU) 501, various functions defined in the system of the present application are executed.
[0158] It should be noted that the computer-readable medium shown in the embodiment of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium can be, for example, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable computer program is carried. This propagated data signal can take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. A computer program contained on a computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0159] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0160] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0161] Another aspect of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor of a computer, the computer executes the method as described above. The computer-readable storage medium may be included in the electronic device described in the above embodiment, or may exist independently without being assembled into the electronic device.
[0162] Another aspect of the present application also provides a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. A processor of a computer device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the computer device executes the method provided in each of the above embodiments.
[0163] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the technology may modify or change the above embodiments without violating the spirit and scope of the present invention. Therefore, all equivalent modifications or changes made by a person of ordinary skill in the art without departing from the spirit and technical ideas disclosed by the present invention shall still be covered by the claims of the present invention.
Claims
1. A rendering command generation method, characterized in that: include: Receiving a preset first rendering command, where the preset first rendering command is any one of N preset rendering commands; The preset N rendering commands all include a general rendering command class, the general rendering command class includes a unified function interface, the unified function interface is determined according to common parameters of the N rendering commands in a graphics application programming interface API, the preset N rendering commands also include corresponding member variables, the corresponding member variables are determined according to non-common parameters corresponding to the N rendering commands in the graphics API, and N is an integer greater than 1; Receive binding information of formal parameters and actual parameters corresponding to a rendering pass, where the binding information is obtained by binding the actual parameters to the formal parameters of the rendering pass; The unified function interface is called to generate a first rendering command for binding resources based on the preset first rendering command and the binding information.
2. The method according to claim 1, characterized in that The member variables corresponding to the preset N rendering commands are initialized through the constructor.
3. The method according to claim 1, characterized in that After receiving the binding information of the formal parameters and actual parameters corresponding to the rendering channel, the method further includes: Determining a demand state of a target resource in the rendering channel based on binding information of formal parameters and actual parameters of the rendering channel; Determining whether the required state of the target resource is consistent with the current state of the target resource in the rendering channel; In the rendering channel, when the required state of the target resource is inconsistent with the current state of the target resource, a conversion command for converting the state of the target resource in the rendering channel to the required state is generated.
4. The method according to claim 3, characterized in that After generating a conversion command for converting the state of the target resource in the rendering channel into the required state, the method further includes: In the running stage, the conversion command is run; After executing the conversion command, executing the first rendering command of the bound resource.
5. The method according to claim 3, characterized in that: The conversion command is generated in the compile phase before the run phase.
6. The method according to claim 5, characterized in that After generating a conversion command for converting the state of the target resource in the rendering channel into the required state, the method further includes: During the compilation phase, the conversion command is loaded into a data container; In the compiling stage, after the conversion command is loaded into the data container, the first rendering command of the bound resource is loaded into the data container; During the running phase, the data container is traversed from the beginning to the end in the order in which the commands are loaded.
7. The method according to any one of claims 1 to 6, characterized in that The calling of the unified function interface to generate the first rendering command of the bound resource based on the preset first rendering command and the binding information includes: In the compiling stage, the unified function interface is called to generate a first rendering command for an initial binding resource based on the preset first rendering command and the binding information; During the compilation stage, based on preset conversion rules, the formal parameters in the first rendering command of the initial binding resource are converted into digital indexes recognizable by the graphics API, and the actual parameters in the first rendering command of the initial binding resource are converted into digital indexes recognizable by the graphics API, so as to obtain the first rendering command of the binding resource.
8. A rendering command generating device, characterized in that: include: A first receiving module, configured to receive a preset first rendering command, wherein the preset first rendering command is any one of the preset N rendering commands; The preset N rendering commands all include a general rendering command class, the general rendering command class includes a unified function interface, the unified function interface is determined according to common parameters of the N rendering commands in a graphics application programming interface API, the preset N rendering commands also include corresponding member variables, the corresponding member variables are determined according to non-common parameters corresponding to the N rendering commands in the graphics API, and N is an integer greater than 1; A second receiving module is used to receive binding information of formal parameters and actual parameters corresponding to a rendering channel, where the binding information is obtained by binding the actual parameters to the formal parameters of the rendering channel; The first generating module is used to call the unified function interface and generate a first rendering command for binding resources based on the preset first rendering command and the binding information.
9. A device, characterized in that: include: one or more processors and memory, A computer program is stored in the memory, and when the one or more processors execute the computer program, the device is caused to perform the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, which, when executed by one or more processors, causes the device to perform the method according to any one of claims 1 to 7.