Shader dynamic modification method and device, graph rendering method and device and related equipment

By inserting a hook control layer into the graphics processing application to intercept the resource creation interface and using the LLVM compilation framework to dynamically edit the shader, the problems of difficult access to shader source code and low editing and modification efficiency are solved, and efficient and flexible shader editing and graphics rendering are achieved.

CN120687099APending Publication Date: 2025-09-23MOORE THREADS TECH CO LTD

Patent Information

Application Number
CN202510812077.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-17
Publication Date
2025-09-23

AI Technical Summary

Technical Problem

In the prior art, the source code of the shader is difficult to obtain and the editing and modification efficiency is low, resulting in insufficient flexibility and efficiency in the editing and modification of the shader.

Method used

By inserting a hook control layer during the running process of the graphics processing application, intercepting the resource creation interface to obtain creation parameters, determining whether there is a shader to be modified, and using the LLVM compilation framework to dynamically edit the shader, generating the modified shader code, and creating a new pipeline state object to perform graphics rendering tasks.

Benefits of technology

Improves the efficiency and flexibility of shader editing and modification, ensures that the modified shader is available in graphics processing applications, and enables real-time debugging of shaders and efficient execution of graphics rendering tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120687099A_ABST
    Figure CN120687099A_ABST
Patent Text Reader

Abstract

The invention provides a shader dynamic modification method, a graph rendering method and device and related equipment, and the method comprises the steps: obtaining creation parameters in a resource creation interface when it is detected that a graph processing application calls the resource creation interface, and the resource creation interface is used for creating a pipeline state object, the creation parameter comprises a plurality of shaders, and the plurality of shaders are expressed in the form of a first intermediate language code; under the condition that a to-be-modified first shader exists in the creation parameters, in response to a modification operation on the first shader, determining a modified second shader; a second pipeline state object is created according to the second shader, and the second pipeline state object is used for calling a graphic interface event by the graphic processing application and executing a graphic rendering task of the graphic interface event. According to the embodiment of the invention, the method can achieve the dynamic modification of the shader, and improves the modification efficiency and flexibility of the shader.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a shader dynamic modification method, a graphics rendering method and device, a shader dynamic modification system, an electronic device, a computer-readable storage medium, and a computer program product. Background Art

[0002] In modern graphics, shaders, which run on a graphics processing unit (GPU), often undergo multiple compilation steps to convert them into a machine-executable language. With the advancement of computer technology and increasing user demands, developers need to optimize the rendering behavior of their applications or debug shaders, often requiring editing and modification of the shaders.

[0003] In practical applications, shader source code is often obtained for editing and modification. However, editing and modifying the shader source code often has problems such as the difficulty in obtaining the shader source code and the low efficiency of repeatedly editing and modifying the shader source code. Therefore, how to improve the efficiency and flexibility of editing and modifying the shader is crucial. Summary of the Invention

[0004] The present disclosure provides a shader dynamic modification method, a graphics rendering method and device, a shader dynamic modification system, an electronic device, a computer-readable storage medium, and a computer program product.

[0005] In a first aspect, the present disclosure provides a method for dynamically modifying a shader, comprising:

[0006] When detecting that a graphics processing application calls a resource creation interface, and the resource creation interface is used to create a pipeline state object, obtaining creation parameters in the resource creation interface, wherein the creation parameters include a plurality of shaders, and the plurality of shaders are represented in the form of a first intermediate language code;

[0007] In a case where there is a first shader to be modified in the creation parameters, determining a modified second shader in response to a modification operation on the first shader;

[0008] A second pipeline state object is created according to the second shader, wherein the second pipeline state object is used by the graphics processing application to call a graphics interface event and execute a graphics rendering task of the graphics interface event.

[0009] In a second aspect, the present disclosure provides a graphics rendering method, comprising:

[0010] In response to a graphics rendering instruction, obtaining a second pipeline state object and a root signature corresponding to the second pipeline state object, wherein the second pipeline state object is created based on the above-mentioned shader dynamic modification method;

[0011] Based on the second pipeline state object and the root signature corresponding to the second pipeline state object, a graphics interface event corresponding to the second pipeline state object is called, wherein the graphics interface event is used to render and generate a target graphic corresponding to the graphics rendering instruction.

[0012] In a third aspect, the present disclosure provides a shader dynamic modification system, comprising: a graphics processing application and a hook control layer;

[0013] The graphics processing application is configured to: receive a graphics rendering instruction of a graphics rendering task, and call a resource creation interface in response to the graphics rendering instruction;

[0014] The hook control layer is configured to: upon detecting that the graphics processing application calls the resource creation interface, and the resource creation interface is used to create a pipeline state object, obtain creation parameters in the resource creation interface, wherein the creation parameters include a plurality of shaders, and the plurality of shaders are represented in the form of a first intermediate language code; if a first shader to be modified is included in the creation parameters, determine a modified second shader in response to a modification operation on the first shader; and create a second pipeline state object according to the second shader;

[0015] The graphics processing application is further configured to: call a graphics interface event corresponding to the second pipeline state object based on the second pipeline state object, and execute a graphics rendering task of the graphics interface event.

[0016] In a fourth aspect, the present disclosure provides a shader dynamic modification device, comprising:

[0017] a detection module configured to, upon detecting that a graphics processing application calls a resource creation interface, and the resource creation interface is used to create a pipeline state object, obtain creation parameters in the resource creation interface, wherein the creation parameters include a plurality of shaders, and the plurality of shaders are represented in the form of a first intermediate language code;

[0018] a response module configured to, when there is a first shader to be modified in the creation parameters, determine a modified second shader in response to a modification operation on the first shader;

[0019] A creation module is configured to create a second pipeline state object according to the second shader, wherein the second pipeline state object is used by the graphics processing application to call a graphics interface event and perform a graphics rendering task of the graphics interface event.

[0020] In a fifth aspect, the present disclosure provides a graphics rendering device, comprising:

[0021] an acquisition module configured to, in response to a graphics rendering instruction, acquire a second pipeline state object and a root signature corresponding to the second pipeline state object, wherein the second pipeline state object is created based on the above-mentioned shader dynamic modification method;

[0022] A calling module is configured to call a graphics interface event corresponding to the second pipeline state object based on the second pipeline state object and the root signature corresponding to the second pipeline state object, wherein the graphics interface event is used to render and generate a target graphic corresponding to the graphics rendering instruction.

[0023] In a sixth aspect, the present disclosure provides an electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores one or more computer programs executable by the at least one processor, and one or more of the computer programs are executed by the at least one processor to enable the at least one processor to execute the above-mentioned shader dynamic modification method or graphics rendering method.

[0024] In a seventh aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the above-mentioned shader dynamic modification method or graphics rendering method when executed by a processor.

[0025] In an eighth aspect, the present disclosure provides a computer program product comprising a computer-readable code, or a non-volatile computer-readable storage medium carrying a computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above-mentioned shader dynamic modification method or graphics rendering method.

[0026] The embodiments provided by the present disclosure can determine the resource creation interface called by a graphics processing application during its execution. If the resource creation interface is determined to be an interface for creating a pipeline state object, the application can further determine whether the creation parameters in the resource creation interface include a first shader that needs to be modified. If so, a modified second shader can be determined in response to the modification operation on the first shader, thereby dynamically modifying the shader that needs to be modified during the execution of the graphics processing application. After determining the modified second shader, a second pipeline state object is created based on the second shader, so that the graphics processing application can subsequently call graphics interface events based on the newly created second pipeline state object and perform graphics rendering tasks corresponding to the graphics interface events. By detecting the behavior of the graphics processing application during its execution, the application can promptly determine whether the interface called by the application is related to the pipeline state object. If the shader that needs to be modified is included in the creation parameters of the pipeline state object, the shader can be dynamically edited and modified, thereby improving the efficiency and flexibility of shader editing and modification. To ensure that the modified shader is available, a new pipeline state object may be created according to the modified shader, so that the graphics processing application performs graphics rendering tasks based on the new pipeline state object.

[0027] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the embodiments of the present disclosure, they are used to explain the present disclosure and do not constitute a limitation of the present disclosure. The above and other features and advantages will become more apparent to those skilled in the art by describing detailed example embodiments with reference to the accompanying drawings. In the accompanying drawings:

[0029] Figure 1 A flowchart of a method for dynamically modifying a shader provided by an embodiment of the present disclosure;

[0030] Figure 2 A flowchart of creating a second pipeline state object provided by an embodiment of the present disclosure;

[0031] Figure 3 A flowchart of calling a graphical interface event provided by an embodiment of the present disclosure;

[0032] Figure 4 A processing flow chart of a shader dynamic modification method provided by an embodiment of the present disclosure;

[0033] Figure 5 A flowchart of a graphics rendering method provided by an embodiment of the present disclosure;

[0034] Figure 6 An application flow chart of a shader dynamic modification system provided by an embodiment of the present disclosure;

[0035] Figure 7 A block diagram of a shader dynamic modification device provided by an embodiment of the present disclosure;

[0036] Figure 8 A block diagram of a graphics rendering device provided in an embodiment of the present disclosure;

[0037] Figure 9 A block diagram of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0038] To enable those skilled in the art to better understand the technical solutions of the present disclosure, exemplary embodiments of the present disclosure are described below in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding. These details should be considered merely exemplary. Therefore, those skilled in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0039] In the absence of conflict, the various embodiments of the present disclosure and the various features therein may be combined with each other.

[0040] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.

[0041] The terms used herein are only used to describe specific embodiments and are not intended to limit the present disclosure. As used herein, the singular forms "a" and "the" are also intended to include the plural forms, unless the context clearly indicates otherwise. It will also be understood that when the terms "comprising" and / or "made of" are used in this specification, the presence of the features, wholes, steps, operations, elements and / or components is specified, but the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof is not excluded. Similar words such as "connected" or "connected" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect.

[0042] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and the present disclosure, and will not be interpreted as having an idealized or overly formal meaning unless expressly defined as such herein.

[0043] In DirectX 12 (DX12) applications, since HLSL (High-Level Shader Language) is developed using a high-level language, the HLSL code is highly readable and it is relatively easy to directly edit and modify the HLSL before compiling and replacing it. However, obtaining the HLSL source code is quite difficult, resulting in poor versatility in modifying shaders by editing and modifying the HLSL.

[0044] Relatively speaking, in DX12 applications, DXIL (DirectX Intermediate Language) code, an intermediate code optimized by the front-end compiler, is relatively easy to obtain, so editing the DXIL code to modify the shader is relatively easy and convenient. However, in current practical applications, editing DXIL code is often achieved through static editing. Static editing requires using DXIL syntax to directly modify the DXIL source code and then replace the original DXIL file. Every time there is a DXIL code that needs to be modified, the DXIL file needs to be re-edited and replaced. Modifying the shader is inefficient and has poor flexibility.

[0045] Based on this, the embodiments of the present disclosure provide a shader dynamic modification method, a graphics rendering method, a shader dynamic modification device, a graphics rendering device, a shader dynamic modification system, an electronic device, a computer-readable storage medium, and a computer program product, which are described in detail one by one in the following embodiments.

[0046] The shader dynamic modification method or graphics rendering method according to the embodiment of the present disclosure can be executed by an electronic device such as a terminal device or a server. The terminal device can be an in-vehicle device, a user equipment (UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (PDA), a handheld device, a computing device, an in-vehicle device, a wearable device, etc. The method can be implemented by a processor calling computer-readable program instructions stored in a memory. Alternatively, the method can be executed by a server.

[0047] See also Figure 1 , Figure 1A flowchart of a method for dynamically modifying a shader provided in an embodiment of the present disclosure specifically includes the following steps:

[0048] Step 102: When it is detected that the graphics processing application calls a resource creation interface, and the resource creation interface is used to create a pipeline state object, obtain creation parameters in the resource creation interface.

[0049] In practical applications, the process from writing shaders in graphics processing applications (such as DX12 applications) to executing them on the GPU is roughly as follows: shaders are written in the HLSL language, then compiled into the intermediate language code (DXIL) by a front-end compiler, and then processed and compiled into the machine-executable language by a compiler in the User Mode Driver (UMD). Because HLSL source code is more difficult to obtain, while DXIL code is less difficult to obtain, the shader dynamic modification method provided in this disclosure dynamically modifies shaders by obtaining the DXIL code from the graphics processing application and dynamically modifying the DXIL code while the graphics processing application is running.

[0050] Among them, the graphics processing application can be a DX12 application or other types of graphics processing applications. The present disclosure does not limit the specific type of graphics processing application. The resource creation interface refers to the interface used to create resources in the graphics processing application. The resource creation interface includes an interface for creating pipeline state objects and also includes an interface for creating other resources. The pipeline state object is PSO (Pipeline State Object). PSO encapsulates all state information related to the rendering pipeline, including shaders, rasterization settings, blending modes, depth / stencil testing, etc.

[0051] Specifically, the shader dynamic modification method provided by the present disclosure is specifically applied to the hook layer (i.e., the Hook Layer). During the operation of the graphics processing application, the hook layer detects the behavior of the graphics processing application in real time. When it is detected that the graphics processing application calls the resource creation interface, the resource creation interface is intercepted by the resource management part of the hook layer. Since the shader data used for the rendering pipeline is included in the creation parameters of the pipeline state object, it is necessary to determine whether the intercepted resource creation interface is used to create the pipeline state object, so as to facilitate the modification of the shader in the subsequent process.

[0052] The disclosed embodiment implements the insertion of a hook layer (i.e., a Hook Layer) at the front end of a graphics processing application. The hook layer intercepts the resource creation interface called by the graphics processing application during its operation to determine whether the intercepted resource creation interface is used to create a pipeline state object, thereby improving the efficiency of subsequent shader modifications.

[0053] Furthermore, after determining that the intercepted resource creation interface is used to create a pipeline state object, creation parameters in the resource creation interface are obtained to determine whether there is a shader that needs to be modified in the creation parameters.

[0054] The creation parameters are used to create the first pipeline state object. The creation parameters include multiple shaders, including shaders at different stages, such as vertex shaders, pixel shaders, and geometry shaders. In actual applications, developers may have different requirements for optimizing the rendering behavior of graphics processing applications, which may lead to different requirements for editing and modifying shaders. For example, if a developer needs to modify the position or geometry of an object, they will need to modify the vertex position coordinates of the vertex shader.

[0055] Based on this, after obtaining the creation parameters in the resource creation interface, it is necessary to determine whether there is a shader that needs to be modified among multiple shaders in the creation parameters.

[0056] In a specific embodiment provided by the present disclosure, after obtaining the creation parameters in the resource creation interface, the method further includes:

[0057] Generating shader identifiers of the plurality of shaders respectively according to the shader data of the plurality of shaders;

[0058] In the case where there is a first shader to be modified in the creation parameters, the method includes:

[0059] In a case where the shader identifier of the first shader exists in the plurality of shader identifiers, it is determined that the first shader exists in the creation parameters.

[0060] Among them, shader data refers to the relevant data of the shader, for example, the shader data can be the source code of the shader, etc. The shader identifier is the unique identifier of the shader, which is used to distinguish different shaders. The shader identifier can be the hash value of the shader, or other data used to identify the shader. The shader identifier can be generated based on the shader data of the shader. For example, the hash value of the shader can be generated using a hash function based on the source code of the shader. The first shader refers to the shader that needs to be dynamically modified.

[0061] Specifically, after obtaining the creation parameters in the resource creation interface, shader identifiers of the plurality of shaders are generated based on the shader data of the plurality of shaders in the creation parameters, and it is determined whether the shader identifier of the first shader exists among the plurality of shader identifiers. If so, it is determined that the first shader exists in the creation parameters.

[0062] The embodiment of the present disclosure realizes that after obtaining the creation parameters in the resource creation interface, by judging whether there is a shader identifier of a first shader that needs to be modified among the shader identifiers of multiple shaders, it is determined whether there is a first shader that needs to be modified in the creation parameters, so as to make corresponding modifications to the first shader in the subsequent process.

[0063] Step 104: When there is a first shader to be modified in the creation parameters, determine a modified second shader in response to a modification operation on the first shader.

[0064] After determining that there is a first shader that needs to be modified in the creation parameters, the hook control layer can display the shader data of the first shader to the developer so that the developer can edit and modify the shader data of the first shader; the hook control layer can also obtain the developer's modification requirements and edit and modify the shader data of the first shader according to the modification requirements. The specific details can be determined based on the actual application situation.

[0065] In actual applications, the LLVM (Low Level Virtual Machine) compilation framework can be used to modify the first shader. The specific implementation is as follows:

[0066] In a specific embodiment provided by the present disclosure, the method further comprises:

[0067] Calling a dynamic editing interface to convert the first intermediate language code of the first shader into a second intermediate language code;

[0068] In response to a modification operation on the first shader, determining a modified second shader includes:

[0069] In response to the modification operation on the second intermediate language code, a modified third intermediate language code is obtained;

[0070] The dynamic editing interface is called to convert the third intermediate language code into a fourth intermediate language code to obtain a second shader corresponding to the fourth intermediate language code, wherein the first intermediate language code and the fourth intermediate language code are of the same type.

[0071] Among them, the dynamic editing interface specifically refers to the shader dynamic editing interface of LLVM. LLVM supports the compilation and optimization of multiple programming languages ​​and can generate efficient machine code on different hardware platforms. The first intermediate language code refers to the DXIL code of the first shader; the second intermediate language code refers to the first shader code in the form of LLVM IR; LLVMIR (LLVM Intermediate Representation) is the LLVM intermediate representation, which is the intermediate stage representation of program code in the compilation process of the LLVM compilation framework. It does not depend on any hardware or operating system and can be used on various platforms. The third intermediate language code refers to the modified first shader code in the form of LLVM IR; the fourth intermediate language code refers to the modified DXIL code of the first shader. The second shader is the shader obtained after modifying the first shader.

[0072] Specifically, after determining that there is a first shader that needs to be modified in the creation parameters, the LLVM shader dynamic editing interface is called to convert the first intermediate language code (i.e., DXIL code) of the first shader into a second intermediate language code (i.e., LLVM IR). In response to the developer's modification operation on the second intermediate language code, the modified third intermediate language code (i.e., modified LLVM IR) can be obtained, and then the LLVM shader dynamic editing interface is called to convert the third intermediate language code into a fourth intermediate language code (i.e., modified DXIL code). Thus, the second shader corresponding to the fourth intermediate language code can be obtained.

[0073] The embodiments provided by the present disclosure can convert the code of the shader that needs to be modified by calling a dynamic editing interface, so that the developer can dynamically edit the shader that needs to be modified according to his editing needs to obtain a modified second shader.

[0074] Furthermore, after modifying the first shader and obtaining the fourth intermediate language code, the fourth intermediate language code needs to be checked for legality to ensure that the fourth intermediate language code complies with operating specifications and can be successfully executed in the graphics processing application.

[0075] Based on this, in a specific embodiment provided by the present disclosure, after calling the dynamic editing interface to convert the third intermediate language code into a fourth intermediate language code, the method further includes:

[0076] Performing a validity check on the fourth intermediate language code;

[0077] If the validity check of the fourth intermediate language code passes, a second shader corresponding to the fourth intermediate language code is obtained.

[0078] Among them, the legality check includes but is not limited to syntax check, logic check, etc. Specifically, the converted fourth intermediate language code is subjected to syntax check, logic check and other legality checks. For example, the syntax check can check whether there are missing symbols in the fourth intermediate language code, whether the variable name is misspelled, etc., and the logic check can check whether the fourth intermediate language code can achieve the expected function (for example, whether the number of loops can reach the expected number, etc.). If the legality check of the fourth intermediate language code passes, the second shader corresponding to the fourth intermediate language code can be obtained; if the legality check of the fourth intermediate language code fails, the fourth intermediate language code needs to be modified until the legality check passes.

[0079] The validity of the second shader corresponding to the fourth intermediate language code is ensured by performing a validity check on the modified fourth intermediate language code, so that the second shader can be successfully run in the graphics processing application in a subsequent process.

[0080] Furthermore, since the root signature defines how the shader accesses resources during execution, after obtaining the second shader corresponding to the fourth intermediate language code, it is necessary to determine whether the parameters used to create the root signature in the shader have been modified. If so, it is necessary to recreate the root signature based on the modified parameters to redefine how the second shader accesses the required resources during execution. If not, the original root signature can continue to be used.

[0081] Therefore, in a specific embodiment provided by the present disclosure, after determining the modified second shader, the method further includes:

[0082] Obtaining a first parameter of the first shader and a second parameter of the second shader, wherein the first parameter includes resources required when the first shader is running, and the second parameter includes resources required when the second shader is running;

[0083] When the first parameter is different from the second parameter, a new root signature corresponding to the second pipeline state object is created according to the second parameter, wherein the new root signature is used by the graphics processing application to call the graphics interface event based on the second pipeline state object and the new root signature.

[0084] Among them, the first parameter refers to the Signature parameter in the first shader, that is, the signature parameter, which includes the resources required for the first shader to run; the second parameter refers to the Signature parameter in the second shader, that is, the signature parameter, which includes the resources required for the second shader to run. In actual applications, the Signature parameter can specifically include parameters such as Sampler, texture, RWBuffer (read-write buffer), and cbuffer (constant buffer). The Sampler parameter defines the texture sampling method; the texture parameter provides image data or other types of data sets (such as normal maps, height maps, etc.) used in the rendering process. The texture can be one-dimensional, two-dimensional, three-dimensional, or a cube map; the RWBuffer parameter allows the resource type to read and write data in the shader program; the cbuffer parameter is used to store various constant data required by the shader, such as transformation matrices, material properties, lighting parameters, etc. The root signature, that is, RootSignature, defines how the shader accesses resources (constant buffers, textures, samplers, etc.).

[0085] Specifically, after determining the modified second shader, it is necessary to determine whether the Signature parameter in the shader has been modified during this dynamic modification. If the Signature parameter of the shader has not been modified (i.e., the first parameter of the first shader is the same as the second parameter of the second shader), there is no need to create a new root signature; if the Signature parameter of the shader has been modified (i.e., the first parameter of the first shader is different from the second parameter of the second shader), it is necessary to recreate a new root signature based on the modified Signature parameter (i.e., the second parameter), and store the new root signature in the resource management part of the hook control layer, so that the graphics processing application can call the corresponding graphics interface event based on the new root signature in the subsequent process to perform graphics rendering tasks.

[0086] In the embodiment provided by the present disclosure, after determining that there is a first shader that needs to be modified in the creation parameters, a dynamic editing interface can be called to convert the code form of the first shader, so that the developer can dynamically edit and modify the first shader according to their editing needs, thereby improving the flexibility of dynamically modifying the first shader; after obtaining the modified fourth intermediate language code, the fourth intermediate language code is checked for legitimacy, so that the second shader corresponding to the fourth intermediate language code can be successfully run in the graphics processing application; and by judging whether the Signature parameter is modified, it is determined whether a new root signature needs to be created, thereby further improving the availability of the second shader.

[0087] Step 106: Create a second pipeline state object according to the second shader, wherein the second pipeline state object is used by the graphics processing application to call a graphics interface event and execute a graphics rendering task of the graphics interface event.

[0088] Since the first shader has been modified, it is also necessary to create a new pipeline state object based on the modified second shader, namely the second pipeline state object, and store the second pipeline state object in the resource management part of the hook control layer for use by the graphics processing application in the process of calling graphics interface events.

[0089] See also Figure 2 , Figure 2 A flowchart of creating a second pipeline state object is provided in an embodiment of the present disclosure. Figure 2 As shown, during the operation of the graphics processing application, the hook control layer performs real-time detection of the operation of the graphics processing application. When it is detected that the graphics processing application calls the resource creation interface, the resource management part of the hook control layer intercepts the resource creation interface ( Figure 2 (not shown). When the resource creation interface for creating a PSO (Pipeline State Object) is intercepted, the creation parameters in the resource creation interface are obtained, and it is determined whether there is a first shader to be modified in the creation parameters. If not, the PSO is created according to the normal process, such as Figure 2 The process shown ends. If so, the dynamic editing interface is called to convert the DXIL code of the first shader into LLVM IR, and in response to the editing and modification operation of the LLVM IR, the edited and modified LLVM IR is obtained, and the edited and modified LLVM IR is converted back into DXIL code. The edited and modified DXIL code is checked for legitimacy, and after the legitimacy check passes, the DXIL code result is obtained, that is, the second shader corresponding to the DXIL code. Further, it is determined whether the first parameter in the first shader is the same as the second parameter in the second shader. If they are the same, it means that the first parameter has not been modified, and there is no need to create a new root signature. A new second PSO is directly created based on the second shader, and the second PSO is stored in the resource management part of the hook control layer; if they are different, it means that the first parameter has been modified to the second parameter, and a new root signature needs to be created based on the second parameter, and a new second PSO is created based on the second shader, and the new root signature and second PSO are stored in the resource management part of the hook control layer.

[0090] The disclosed embodiments detect the behavior of a graphics processing application during its operation, promptly determining whether an interface called by the graphics processing application is related to a pipeline state object. If a shader that needs to be modified is included in the pipeline state object's creation parameters, the shader can be dynamically edited and modified, thereby improving the efficiency and flexibility of shader editing and modification. To ensure that the modified shader is usable, a new pipeline state object can also be created based on the modified shader, allowing the graphics processing application to perform graphics rendering tasks based on the new pipeline state object.

[0091] Furthermore, after obtaining the modified second shader and second pipeline state object, it is necessary to run the second shader and second pipeline state object and perform the corresponding graphics rendering task based on the second shader and second pipeline state object. Specifically, the pipeline state object originally called by the graphics processing application can be replaced with the newly created second pipeline state object. If a new root signature is created, the original root signature can be replaced with the newly created root signature. If a new root signature is not created, no replacement is required.

[0092] Based on this, in a specific embodiment provided by the present disclosure, after creating the second pipeline state object according to the second shader, the method further includes:

[0093] When detecting that the graphics processing application calls a state setting interface, acquiring and storing object state information in the state setting interface;

[0094] In a case where it is detected that the graphics processing application calls a graphics interface event, determining, according to the object state information, whether the first shader exists among a plurality of shaders corresponding to the graphics interface event;

[0095] In a case where the first shader exists, the second pipeline state object is determined as the pipeline state object corresponding to the graphics interface event, and the new root signature is determined as the root signature corresponding to the graphics interface event.

[0096] Among them, the state setting interface is the interface used to set the rendering pipeline state, such as SetPipelineState, SetRootSignature and other related interfaces. The SetPipelineState interface is specifically used to set the pipeline state object; the SetRootSignature interface is specifically used to set the root signature. Object state information refers to the state information of the set rendering pipeline, including the set pipeline state object, root signature, parameters of different positions of the root signature, viewport size, etc. Graphics interface events are graphics API (Application Programming Interface) events, such as Draw events, Dispatch events, etc. The Draw event is mainly used in the graphics rendering process and is responsible for converting geometric graphics into image frames; the Dispatch event focuses on using the parallel computing capabilities of the GPU to perform computing tasks and is not directly related to graphics output.

[0097] Specifically, when the hook control layer detects that the graphics processing application calls the state setting interface, the state management part of the hook control layer will intercept the state setting interface and obtain the object state information in the state setting interface, including the set pipeline state object, root signature, parameters of different positions of the root signature, viewport size, etc., and store the obtained object state information in the state management part of the hook control layer.

[0098] When the hook control layer detects that a graphics processing application has called a graphics interface event, the state management portion of the hook control layer intercepts the graphics interface event and, based on the object state information stored in the state management portion, determines whether a first shader that needs to be edited or modified exists among the multiple shaders executed by the graphics interface event. If so, the second pipeline state object and new root signature stored in the resource management portion of the hook control layer are obtained, and the second pipeline state object is determined as the pipeline state object corresponding to the graphics interface event, and the new root signature is determined as the root signature corresponding to the graphics interface event. If the resource management portion of the hook control layer does not store a new root signature, that is, if a new root signature has not been created, the original root signature can continue to be used without replacement.

[0099] It should be noted that after resetting the second pipeline state object and the corresponding root signature, the graphics interface event called by the graphics processing application can be the original graphics interface event or a new graphics interface event, which is determined according to the actual needs of the developer.

[0100] The following explains a specific implementation method for determining whether there is a first shader that needs to be edited and modified among multiple shaders executed by a graphics interface event based on object state information.

[0101] In a specific embodiment provided by the present disclosure, determining whether the first shader exists among the plurality of shaders corresponding to the graphics interface event according to the object state information includes:

[0102] Determining, according to the object state information, an original first pipeline state object of the graphics interface event from a plurality of pipeline state objects;

[0103] Determine whether the shader identifier of the first shader exists among the shader identifiers of the plurality of shaders of the first pipeline state object;

[0104] In a case where the shader identifier of the first shader exists among the plurality of shader identifiers, it is determined that the first shader exists among the plurality of shaders of the first pipeline state object.

[0105] Specifically, based on the object state information stored in the state management portion, a first pipeline state object corresponding to the first pipeline state object is determined from among the plurality of pipeline state objects that the graphics processing application needs to execute. That is, the first pipeline state object originally associated with the current graphics interface event is called. A determination is made as to whether the shader identifier of the first shader exists among the plurality of shader identifiers of the first pipeline state object. If so, it is determined that the first shader exists among the plurality of shaders of the first pipeline state object.

[0106] It should be noted that after obtaining the modified second shader, the backend compiler can be called to compile the modified fourth intermediate language code. This disclosure does not limit the compilation process, and the editing can be completed before using the second pipeline state object.

[0107] Furthermore, in a specific embodiment provided by the present disclosure, the method further comprises:

[0108] When it is detected that the graphics processing application ends calling the graphics interface event, the second pipeline state object is restored to the original first pipeline state object of the graphics interface event, and the new root signature is restored to the original root signature of the graphics interface event.

[0109] Specifically, after detecting that the graphics processing application has finished calling the graphics interface event, the hook control layer needs to restore the state of the graphics interface event, that is, restore the second pipeline state object to the first pipeline state object, and restore the new root signature to the original root signature.

[0110] See also Figure 3 , Figure 3 A flowchart of calling a graphical interface event is provided in an embodiment of the present disclosure. Figure 3As shown, during the operation of the graphics processing application, the hook control layer performs real-time detection on the operation of the graphics processing application. In the case of detecting that the graphics processing application calls the state setting interface, the state management part of the hook control layer will intercept the state setting interface, obtain the object state information in the state setting interface, and store it in the state management part. In the case of detecting that the graphics processing application calls a graphics API event, the state management part of the hook control layer will intercept the graphics API event, and determine the first PSO corresponding to it among the multiple PSOs that the graphics processing application needs to use based on the object state information stored in the state management part. Determine whether the shader identifier of the first shader exists among the shader identifiers of the multiple shaders in the first PSO. If not, ignore this interception, such as Figure 3 The process ends; if so, the newly created second PSO is determined as the PSO corresponding to the graphics API event (i.e., the second PSO replaces the original PSO), and the new root signature (if a new root signature is created) or the old root signature (if a new root signature is not created) is determined as the root signature corresponding to the graphics API event, so that the graphics processing application calls the graphics API event based on the second PSO and the corresponding root signature. When it is detected that the graphics processing application has finished calling the graphics API event, the state of the graphics API event is restored.

[0111] The disclosed embodiments enable a graphics processing application to call a graphics interface event based on a recreated second pipeline state object (including a modified second shader), thereby implementing real-time debugging of the modified second shader; by dynamically modifying the shader, integrating it with the operation of the graphics interface event, thereby implementing adjustment of the graphics interface event during the runtime of the graphics processing application.

[0112] The present disclosure provides a method for dynamically modifying shaders, comprising: upon detecting that a graphics processing application calls a resource creation interface, and the resource creation interface is used to create a pipeline state object, obtaining creation parameters in the resource creation interface, wherein the creation parameters include multiple shaders, and the multiple shaders are represented in the form of a first intermediate language code; upon detecting that a first shader to be modified exists in the creation parameters, determining a modified second shader in response to a modification operation on the first shader; and creating a second pipeline state object based on the second shader, wherein the second pipeline state object is used by the graphics processing application to call a graphics interface event and execute a graphics rendering task of the graphics interface event.

[0113] The disclosed embodiment achieves this by detecting the behavior of a graphics processing application during its operation, promptly determining whether the interface called by the graphics processing application is related to a pipeline state object, and, if a shader that needs to be modified is included in the creation parameters of the pipeline state object, calling a dynamic editing interface to formally convert the first intermediate language code of the shader that needs to be modified, allowing developers to dynamically edit and modify the shader that needs to be modified according to their editing needs to obtain a modified second shader, thereby improving the efficiency and flexibility of shader editing and modification. To ensure that the modified shader is available, a new pipeline state object can also be created based on the modified shader, so that the graphics processing application performs graphics rendering tasks based on the new pipeline state object.

[0114] The following combined Figure 4 , taking a DX12 application as an example of a graphics processing application, the shader dynamic modification method provided by the embodiment of the present disclosure is further explained, Figure 4 A flowchart of a method for dynamically modifying a shader provided in an embodiment of the present disclosure specifically includes the following steps:

[0115] Step 402: When it is detected that the DX12 application calls the resource creation interface, it is determined whether the resource creation interface is used to create a PSO.

[0116] Specifically, during the running of the DX12 application, the Hook Layer detects the behavior of the DX12 application in real time. When it detects that the DX12 application calls the resource creation interface, it intercepts the resource creation interface and determines whether the resource creation interface is used to create a PSO.

[0117] Step 404: When it is determined that the resource creation interface is used to create a PSO, the creation parameters in the resource creation interface are obtained.

[0118] Step 406: Determine whether there is a first shader to be modified in the creation parameters.

[0119] Specifically, based on the shader data of the multiple shaders in the creation parameters, hash values ​​of the multiple shaders are generated respectively, and it is determined whether the hash value of the first shader exists among the hash values ​​of the multiple shaders. If so, it is determined that the first shader exists in the creation parameters.

[0120] Step 408: When the first shader exists in the creation parameters, call the dynamic editing interface to convert the first intermediate language code into a second intermediate language code.

[0121] Specifically, when there is a first shader in the creation parameters, the shader dynamic editing interface of LLVM is called to convert the first intermediate language code (ie, DXIL code) of the first shader into a second intermediate language code (ie, LLVMIR).

[0122] Step 410: In response to the modification operation on the second intermediate language code, a modified third intermediate language code is obtained.

[0123] Step 412: Call the dynamic editing interface to convert the third intermediate language code into a fourth intermediate language code.

[0124] Specifically, the shader dynamic editing interface of LLVM is called to convert the third intermediate language code (ie, the modified LLVMIR) into the fourth intermediate language code (ie, the modified DXIL code).

[0125] Step 414: Perform a validity check on the fourth intermediate language code. If the fourth intermediate language code passes the validity check, obtain a second shader corresponding to the fourth intermediate language code.

[0126] Specifically, if the fourth intermediate language code fails the validity check, the fourth intermediate language code is modified until the validity check passes.

[0127] Step 416: Create a new PSO according to the second shader.

[0128] Determine whether the Signature parameters in the first shader are the same as the Signature parameters in the second shader. If they are the same, it means that the Signature parameters have not been modified, and there is no need to create a new root signature. Create a new PSO based on the second shader directly, and store the PSO in the resource management part of the Hook Layer. If they are different, it means that the Signature parameters have been modified, and it is necessary to create a new root signature based on the modified Signature parameters, and create a new PSO based on the second shader, and store the new root signature and new PSO in the resource management part of the Hook Layer.

[0129] Step 418: When it is detected that the DX12 application calls the state setting interface, the object state information in the state setting interface is obtained and stored.

[0130] Specifically, when the Hook Layer detects that a DX12 application has called a state setting interface, it intercepts the interface and obtains the object state information from the interface. The object state information includes the set PSO, root signature, parameters at different positions of the root signature, viewport size, etc. The obtained object state information is then stored in the state management part of the Hook Layer.

[0131] Step 420: When it is detected that the DX12 application calls a graphics API event, determine whether a first shader exists among the multiple shaders corresponding to the graphics API event according to the object state information.

[0132] Specifically, when the Hook Layer detects that the DX12 application calls a graphics API event, it intercepts the graphics API event and determines whether the first shader exists among multiple shaders that need to be executed by the graphics API event based on the object state information stored in the Hook Layer state management part.

[0133] Step 422: If the first shader exists, determine the new PSO as the PSO corresponding to the graphics API event.

[0134] Specifically, if it exists, obtain the new PSO and root signature stored in the state management part of the Hook Layer, set the new PSO as the PSO corresponding to the graphics API event, and set the obtained root signature as the root signature corresponding to the graphics API event.

[0135] Step 424: When it is detected that the DX12 application ends calling the graphics API event, the state of the graphics API event is restored.

[0136] Specifically, when the Hook Layer detects that the DX12 application ends calling the graphics API event, it restores the state of the graphics API event.

[0137] The disclosed embodiments implement a method of inserting a hook layer to intercept resource creation interfaces called by a DX12 application during its execution. If the resource creation interface is determined to be an interface for creating a PSO, the method further determines whether the creation parameters in the resource creation interface include a first shader that needs to be modified. If so, a modified second shader can be obtained in response to the modification operation on the first shader, thereby dynamically modifying the shader that needs to be modified during the execution of the DX12 application. After obtaining the modified second shader, a new PSO is created based on the second shader, allowing the DX12 application to subsequently call graphics API events based on the newly created PSO and perform graphics rendering tasks corresponding to the graphics API events. By detecting the behavior of the DX12 application during its execution, it is possible to promptly determine whether the interface called by the DX12 application is related to the PSO. If a shader that needs to be modified is included in the PSO's creation parameters, the shader can be dynamically edited and modified, thereby improving the efficiency and flexibility of shader editing and modification. A new PSO may also be created based on the modified shader, so that the DX12 application performs graphics rendering tasks based on the new PSO, thereby ensuring the availability of the modified shader.

[0138] See also Figure 5 , Figure 5 A flowchart of a graphics rendering method provided in an embodiment of the present disclosure specifically includes the following steps:

[0139] Step 502: In response to a graphics rendering instruction, obtain a second pipeline state object and a root signature corresponding to the second pipeline state object, wherein the second pipeline state object is created based on the above-mentioned shader dynamic modification method.

[0140] The graphics rendering method uses a graphics processing application. An image rendering instruction is an instruction initiated by a terminal device for rendering a target graphic. The target graphic is a graphic generated by rendering based on the second pipeline state object and the root signature corresponding to the second pipeline state object.

[0141] Specifically, when the graphics processing application receives a graphics rendering instruction, it responds to the graphics rendering instruction and obtains the second pipeline state object created by the hook control layer and the root signature corresponding to the second pipeline state object. The second pipeline state object is created based on the above-mentioned shader dynamic modification method.

[0142] Step 504: Based on the second pipeline state object and the root signature corresponding to the second pipeline state object, call a graphics interface event corresponding to the second pipeline state object, wherein the graphics interface event is used to render and generate a target graphic corresponding to the graphics rendering instruction.

[0143] Specifically, the graphics processing application calls a graphics interface event corresponding to the second pipeline state object based on the acquired second pipeline state object and the root signature corresponding to the second pipeline state object, so as to render and generate target graphics.

[0144] The graphics rendering method provided by the present disclosure can call the corresponding graphics interface event according to the second pipeline state object created by the hook control layer and the root signature corresponding to the second pipeline state object, and render to generate the target graphics, thereby realizing real-time rendering after dynamic modification of the shader.

[0145] It is understood that the above-mentioned various method embodiments mentioned in this disclosure can be combined with each other to form combined embodiments without violating the principle logic. Due to space limitations, this disclosure will not go into details. It is understood by those skilled in the art that in the above-mentioned methods of specific implementation, the specific execution order of each step should be determined by its function and possible internal logic.

[0146] See also Figure 6 , Figure 6 This is an application flow chart of a shader dynamic modification system provided by an embodiment of the present disclosure. The embodiment of the shader dynamic modification system provided by the present disclosure is as follows:

[0147] The shader dynamic modification system includes: a graphics processing application 601 and a hook control layer 602;

[0148] The graphics processing application 601 is configured to: receive a graphics rendering instruction of a graphics rendering task, and call a resource creation interface in response to the graphics rendering instruction;

[0149] The hook control layer 602 is configured to: upon detecting that the graphics processing application calls the resource creation interface, and the resource creation interface is used to create a pipeline state object, obtain creation parameters in the resource creation interface, wherein the creation parameters include multiple shaders, and the multiple shaders are represented in the form of a first intermediate language code; if a first shader to be modified is included in the creation parameters, determine a modified second shader in response to a modification operation on the first shader; and create a second pipeline state object based on the second shader;

[0150] The graphics processing application 601 is further configured to: call a graphics interface event corresponding to the second pipeline state object based on the second pipeline state object, and execute a graphics rendering task of the graphics interface event.

[0151] Specifically, the shader dynamic modification system includes a graphics processing application and a hook control layer. In actual applications, the graphics processing application is used to receive rendering instructions for graphics rendering tasks and call a resource creation interface in response to the graphics rendering instructions. During the operation of the graphics processing application, the hook control layer detects the behavior of the graphics processing application. When it is detected that the graphics processing application calls the resource creation interface, it intercepts and determines whether the resource creation interface is used to create a pipeline state object. When it is determined that the resource creation interface is used to create a pipeline state object, the creation parameters for creating the pipeline state object in the resource creation interface are obtained, and it is determined whether there is a first shader that needs to be modified in the creation parameters. If so, in response to the modification operation on the first shader, the modified second shader is determined, and a new second pipeline state object is created based on the second shader. The graphics processing application obtains the second pipeline state object, calls a graphics interface event based on the second pipeline state object, and executes the graphics rendering task of the graphics interface event.

[0152] The specific application of the graphics processing application and the hook control layer in the shader dynamic modification system can be referred to the above-mentioned shader dynamic modification method or graphics rendering method, and will not be repeated in this disclosure.

[0153] The shader dynamic modification system provided by the present disclosure realizes that during the operation of the graphics processing application, the resource creation interface called by the graphics processing application is intercepted by the hook control layer, and when it is determined that the resource creation interface is used to create the pipeline state object, it is further determined whether there is a first shader that needs to be modified in the creation parameters of the resource creation interface. If so, a modified second shader can be obtained in response to the modification operation of the first shader, thereby realizing the dynamic modification of the shader that needs to be modified during the operation of the graphics processing application through the interaction between the graphics processing application and the hook control layer. After obtaining the modified second shader, a new pipeline state object is created according to the second shader, so that the graphics processing application can call the graphics interface event based on the newly created pipeline state object in the subsequent process, and execute the graphics rendering task corresponding to the graphics interface event.

[0154] In addition, the present disclosure also provides a shader dynamic modification device, a graphics rendering device, an electronic device, a computer-readable storage medium, and a computer program product, all of which can be used to implement any shader dynamic modification method or graphics rendering method provided by the present disclosure. The corresponding technical solutions and descriptions are referred to the corresponding records in the method section and will not be repeated here.

[0155] Figure 7 This is a block diagram of a shader dynamic modification device provided by an embodiment of the present disclosure. Figure 7 The embodiment of the present disclosure provides a shader dynamic modification device, the shader dynamic modification device comprising:

[0156] The detection module 702 is configured to, upon detecting that a graphics processing application calls a resource creation interface, and the resource creation interface is used to create a pipeline state object, obtain creation parameters in the resource creation interface, wherein the creation parameters include a plurality of shaders, and the plurality of shaders are represented in the form of a first intermediate language code;

[0157] A response module 704 is configured to, when there is a first shader to be modified in the creation parameters, determine a modified second shader in response to a modification operation on the first shader;

[0158] The creation module 706 is configured to create a second pipeline state object according to the second shader, wherein the second pipeline state object is used by the graphics processing application to call a graphics interface event and perform a graphics rendering task of the graphics interface event.

[0159] Optionally, the device further includes a generating module configured to:

[0160] Generating shader identifiers of the plurality of shaders respectively according to the shader data of the plurality of shaders;

[0161] The response module 704 is further configured to:

[0162] In a case where the shader identifier of the first shader exists in the plurality of shader identifiers, it is determined that the first shader exists in the creation parameters.

[0163] Optionally, the device further includes an interface calling module configured to:

[0164] Calling a dynamic editing interface to convert the first intermediate language code of the first shader into a second intermediate language code;

[0165] The response module 704 is further configured to:

[0166] In response to the modification operation on the second intermediate language code, a modified third intermediate language code is obtained;

[0167] The dynamic editing interface is called to convert the third intermediate language code into a fourth intermediate language code to obtain a second shader corresponding to the fourth intermediate language code, wherein the first intermediate language code and the fourth intermediate language code are of the same type.

[0168] Optionally, the device further includes a checking module configured to:

[0169] Performing a validity check on the fourth intermediate language code;

[0170] If the validity check of the fourth intermediate language code passes, a second shader corresponding to the fourth intermediate language code is obtained.

[0171] Optionally, the apparatus further includes a signature creation module configured to:

[0172] Obtaining a first parameter of the first shader and a second parameter of the second shader, wherein the first parameter includes resources required when the first shader is running, and the second parameter includes resources required when the second shader is running;

[0173] When the first parameter is different from the second parameter, a new root signature corresponding to the second pipeline state object is created according to the second parameter, wherein the new root signature is used by the graphics processing application to call the graphics interface event based on the second pipeline state object and the new root signature.

[0174] Optionally, the apparatus further includes a determining module configured to:

[0175] When detecting that the graphics processing application calls a state setting interface, acquiring and storing object state information in the state setting interface;

[0176] In a case where it is detected that the graphics processing application calls a graphics interface event, determining, according to the object state information, whether the first shader exists among a plurality of shaders corresponding to the graphics interface event;

[0177] In a case where the first shader exists, the second pipeline state object is determined as the pipeline state object corresponding to the graphics interface event, and the new root signature is determined as the root signature corresponding to the graphics interface event.

[0178] Optionally, the determining module is further configured to:

[0179] Determining, according to the object state information, an original first pipeline state object of the graphics interface event from a plurality of pipeline state objects;

[0180] Determine whether the shader identifier of the first shader exists among the shader identifiers of the plurality of shaders of the first pipeline state object;

[0181] In a case where the shader identifier of the first shader exists among the plurality of shader identifiers, it is determined that the first shader exists among the plurality of shaders of the first pipeline state object.

[0182] Optionally, the device further includes a recovery module configured to:

[0183] When it is detected that the graphics processing application ends calling the graphics interface event, the second pipeline state object is restored to the original first pipeline state object of the graphics interface event, and the new root signature is restored to the original root signature of the graphics interface event.

[0184] The shader dynamic modification device provided by the present disclosure includes: a detection module, configured to obtain creation parameters in the resource creation interface when detecting that a graphics processing application calls a resource creation interface and the resource creation interface is used to create a pipeline state object, wherein the creation parameters include multiple shaders, and the multiple shaders are expressed in the form of a first intermediate language code; a response module, configured to determine a modified second shader in response to a modification operation on the first shader when a first shader to be modified exists in the creation parameters; and a creation module, configured to create a second pipeline state object based on the second shader, wherein the second pipeline state object is used by the graphics processing application to call a graphics interface event and perform a graphics rendering task of the graphics interface event.

[0185] The disclosed embodiment achieves this by detecting the behavior of a graphics processing application during its operation, promptly determining whether the interface called by the graphics processing application is related to a pipeline state object, and, if a shader that needs to be modified is included in the creation parameters of the pipeline state object, calling a dynamic editing interface to convert the code of the shader that needs to be modified, allowing developers to dynamically edit and modify the shader that needs to be modified according to their editing needs to obtain a modified second shader, thereby improving the efficiency and flexibility of shader editing and modification. To ensure that the modified shader is available, a new pipeline state object can also be created based on the modified shader, so that the graphics processing application can perform graphics rendering tasks based on the new pipeline state object.

[0186] Figure 8 A block diagram of a graphics rendering device provided by an embodiment of the present disclosure. Figure 8 , an embodiment of the present disclosure provides a graphics rendering device, the graphics rendering device comprising:

[0187] An acquisition module 802 is configured to, in response to a graphics rendering instruction, acquire a second pipeline state object and a root signature corresponding to the second pipeline state object, wherein the second pipeline state object is created based on the above-mentioned shader dynamic modification method;

[0188] The calling module 804 is configured to call a graphics interface event corresponding to the second pipeline state object based on the second pipeline state object and the root signature corresponding to the second pipeline state object, wherein the graphics interface event is used to render and generate a target graphic corresponding to the graphics rendering instruction.

[0189] The embodiment of the present disclosure realizes that according to the second pipeline state object created by the hook control layer and the root signature corresponding to the second pipeline state object, the corresponding graphics interface event can be called and the target graphics can be rendered to achieve real-time rendering after the shader is dynamically modified.

[0190] Figure 9 A block diagram of an electronic device provided in an embodiment of the present disclosure.

[0191] See also Figure 9 An embodiment of the present disclosure provides an electronic device, which includes: at least one processor 901; at least one memory 902, and one or more I / O interfaces 903, connected between the processor 901 and the memory 902; wherein the memory 902 stores one or more computer programs that can be executed by the at least one processor 901, and the one or more computer programs are executed by the at least one processor 901 to enable the at least one processor 901 to perform the above-mentioned shader dynamic modification method or graphics rendering method.

[0192] The present disclosure also provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the above-mentioned method for dynamically modifying a shader or a method for rendering graphics. The computer-readable storage medium may be a volatile or non-volatile computer-readable storage medium.

[0193] An embodiment of the present disclosure also provides a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the above-mentioned shader dynamic modification method or graphics rendering method.

[0194] It will be understood by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In a hardware implementation, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable storage medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium).

[0195] As is well known to those skilled in the art, the term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information (such as computer-readable program instructions, data structures, program modules or other data). Computer storage media includes, but is not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), static random access memory (SRAM), flash memory or other memory technology, portable compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical disc storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, as is well known to those skilled in the art, communication media typically contains computer-readable program instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.

[0196] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions to be stored in the computer-readable storage medium in each computing / processing device.

[0197] The computer program instructions for performing the operations of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Smalltalk, C++, and conventional procedural programming languages ​​such as "C" language or similar programming languages. Computer-readable program instructions may be executed entirely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., utilizing an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be personalized by utilizing the state information of the computer-readable program instructions. The electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.

[0198] The computer program product described herein may be implemented in hardware, software, or a combination thereof. In one embodiment, the computer program product is implemented as a computer storage medium. In another embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).

[0199] Various aspects of the present disclosure are described herein with reference to flowcharts and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the present disclosure. It should be understood that each block of the flowcharts and / or block diagrams, and combinations of blocks in the flowcharts and / or block diagrams, can be implemented by computer-readable program instructions.

[0200] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device is generated that implements the functions / actions specified in one or more blocks in the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium, where these instructions cause the computer, programmable data processing device, and / or other device to operate in a specific manner. Thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing various aspects of the functions / actions specified in one or more blocks in the flowchart and / or block diagram.

[0201] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operational steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more blocks in the flowchart and / or block diagram.

[0202] The flow charts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the systems, methods and computer program products according to multiple embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and the part of the module, program segment or instruction contains one or more executable instructions for realizing the prescribed logical function. In some alternative implementations, the functions marked in the box can also occur in a sequence different from that marked in the accompanying drawings. For example, two consecutive boxes 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 and / or flow chart, and the combination of the boxes in the block diagram and / or flow chart can be implemented by a dedicated hardware-based system that performs the prescribed function or action, or can be implemented by a combination of dedicated hardware and computer instructions.

[0203] Example embodiments have been disclosed herein, and although specific terms are employed, they are used and should be interpreted only in a general illustrative sense and not for purposes of limitation. In some instances, it will be apparent to those skilled in the art that, unless otherwise expressly indicated, features, characteristics, and / or elements described in conjunction with a particular embodiment may be used alone or in combination with features, characteristics, and / or elements described in conjunction with other embodiments. Therefore, it will be understood by those skilled in the art that various changes in form and detail may be made without departing from the scope of the present disclosure as set forth in the appended claims.

Claims

1. A method for dynamically modifying a shader, characterized in that: include: When detecting that a graphics processing application calls a resource creation interface, and the resource creation interface is used to create a pipeline state object, obtaining creation parameters in the resource creation interface, wherein the creation parameters include a plurality of shaders, and the plurality of shaders are represented in the form of a first intermediate language code; In a case where there is a first shader to be modified in the creation parameters, determining a modified second shader in response to a modification operation on the first shader; A second pipeline state object is created according to the second shader, wherein the second pipeline state object is used by the graphics processing application to call a graphics interface event and execute a graphics rendering task of the graphics interface event.

2. The method according to claim 1, wherein The method further comprises: Generating shader identifiers of the plurality of shaders respectively according to the shader data of the plurality of shaders; In the case where there is a first shader to be modified in the creation parameters, the method includes: In a case where the shader identifier of the first shader exists in the plurality of shader identifiers, it is determined that the first shader exists in the creation parameters.

3. The method according to claim 1, wherein The method further comprises: Calling a dynamic editing interface to convert the first intermediate language code of the first shader into a second intermediate language code; In response to a modification operation on the first shader, determining a modified second shader includes: In response to the modification operation on the second intermediate language code, a modified third intermediate language code is obtained; The dynamic editing interface is called to convert the third intermediate language code into a fourth intermediate language code to obtain a second shader corresponding to the fourth intermediate language code, wherein the first intermediate language code and the fourth intermediate language code are of the same type.

4. The method according to claim 3, wherein The method further comprises: Performing a validity check on the fourth intermediate language code; If the validity check of the fourth intermediate language code passes, a second shader corresponding to the fourth intermediate language code is obtained.

5. The method according to claim 1, wherein The method further comprises: Obtaining a first parameter of the first shader and a second parameter of the second shader, wherein the first parameter includes resources required when the first shader is running, and the second parameter includes resources required when the second shader is running; When the first parameter is different from the second parameter, a new root signature corresponding to the second pipeline state object is created according to the second parameter, wherein the new root signature is used by the graphics processing application to call the graphics interface event based on the second pipeline state object and the new root signature.

6. The method according to claim 5, wherein The method further comprises: When detecting that the graphics processing application calls a state setting interface, acquiring and storing object state information in the state setting interface; In a case where it is detected that the graphics processing application calls a graphics interface event, determining, according to the object state information, whether the first shader exists among a plurality of shaders corresponding to the graphics interface event; In a case where the first shader exists, the second pipeline state object is determined as the pipeline state object corresponding to the graphics interface event, and the new root signature is determined as the root signature corresponding to the graphics interface event.

7. The method according to claim 6, wherein Determining whether the first shader exists among the plurality of shaders corresponding to the graphics interface event according to the object state information includes: Determining, according to the object state information, an original first pipeline state object of the graphics interface event from a plurality of pipeline state objects; Determine whether the shader identifier of the first shader exists among the shader identifiers of the plurality of shaders of the first pipeline state object; In a case where the shader identifier of the first shader exists among the plurality of shader identifiers, it is determined that the first shader exists among the plurality of shaders of the first pipeline state object.

8. The method according to claim 6, wherein The method further comprises: When it is detected that the graphics processing application ends calling the graphics interface event, the second pipeline state object is restored to the original first pipeline state object of the graphics interface event, and the new root signature is restored to the original root signature of the graphics interface event.

9. A graphics rendering method, characterized in that: include: In response to a graphics rendering instruction, obtaining a second pipeline state object and a root signature corresponding to the second pipeline state object, wherein the second pipeline state object is created based on the method of any one of claims 1 to 8; Based on the second pipeline state object and the root signature corresponding to the second pipeline state object, a graphics interface event corresponding to the second pipeline state object is called, wherein the graphics interface event is used to render and generate a target graphic corresponding to the graphics rendering instruction.

10. A shader dynamic modification system, characterized in that: include: Graphics processing applications and hook control layer; The graphics processing application is configured to: receive a graphics rendering instruction of a graphics rendering task, and call a resource creation interface in response to the graphics rendering instruction; The hook control layer is configured to: upon detecting that the graphics processing application calls the resource creation interface, and the resource creation interface is used to create a pipeline state object, obtain creation parameters in the resource creation interface, wherein the creation parameters include a plurality of shaders, and the plurality of shaders are represented in the form of a first intermediate language code; if a first shader to be modified is included in the creation parameters, determine a modified second shader in response to a modification operation on the first shader; and create a second pipeline state object according to the second shader; The graphics processing application is further configured to: call a graphics interface event corresponding to the second pipeline state object based on the second pipeline state object, and execute a graphics rendering task of the graphics interface event.

11. A shader dynamic modification device, characterized in that: include: a detection module configured to, upon detecting that a graphics processing application calls a resource creation interface, and the resource creation interface is used to create a pipeline state object, obtain creation parameters in the resource creation interface, wherein the creation parameters include a plurality of shaders, and the plurality of shaders are represented in the form of a first intermediate language code; a response module configured to, when there is a first shader to be modified in the creation parameters, determine a modified second shader in response to a modification operation on the first shader; A creation module is configured to create a second pipeline state object according to the second shader, wherein the second pipeline state object is used by the graphics processing application to call a graphics interface event and perform a graphics rendering task of the graphics interface event.

12. A graphics rendering device, characterized in that: include: an acquisition module configured to, in response to a graphics rendering instruction, acquire a second pipeline state object and a root signature corresponding to the second pipeline state object, wherein the second pipeline state object is created based on the method of any one of claims 1 to 8; A calling module is configured to call a graphics interface event corresponding to the second pipeline state object based on the second pipeline state object and the root signature corresponding to the second pipeline state object, wherein the graphics interface event is used to render and generate a target graphic corresponding to the graphics rendering instruction.

13. An electronic device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores one or more computer programs executable by the at least one processor, and the one or more computer programs are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 9.

14. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the computer program implements the method according to any one of claims 1 to 9.

15. A computer program product, characterized in that The invention comprises a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code, wherein when the computer-readable code runs in a processor of an electronic device, the processor in the electronic device executes the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Power efficient attribute handling for tessellation and geometry shaders

    CN103996216A

  • GPU-based three-dimensional image data rendering method and device

    CN113012269A

  • Picture processing method and device

    CN113870411A

  • Special effect plug-in compiling and rendering method and device and storage medium

    CN114661324A

  • Debugging method and device for rendering problem, equipment and storage medium

    CN115357516A

Cited By

  • Shader adjusting method and device, computer equipment and storage medium

    CN120953463A

  • Shader adjustment methods, apparatus, computer equipment, and storage media

    CN120953463B