Graph rendering method and device, equipment and storage medium
By combining the use of shaders of different types of graphics programming interfaces such as OpenGL and Metal, the problem of unavailability of graphics rendering applications on low-version devices is solved, and the reuse of functions and the shortening of development cycles is achieved.
Patent Information
- Application Number
- CN202311065922.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-22
- Publication Date
- 2025-02-25
AI Technical Summary
In the prior art, when a graphic rendering application is ported to a device that does not support the latest version of the graphics programming interface, some functions may be unavailable, and the development cycle of redevelopment of new graphic rendering applications is long and the workload of R&D personnel is large.
By calling the first graphical programming interface (such as OpenGL) and the second graphical programming interface (such as Metal), using the first shader and the second shader to render the graphics rendering request, solving the problem of unavailability of the functionality caused by the version supported by the device being lower than the target version.
It realizes that without the need to develop new graphics rendering applications from scratch, the multiplexed part can be used functions shortened, the development cycle is reduced, the workload of R&D personnel is reduced, and the functional integrity of graphics rendering applications is ensured.
Smart Images

Figure CN119516065A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of graphics processing technology, and in particular to a graphics rendering method, device, electronic device and computer-readable storage medium. Background Art
[0002] In the related art, graphics rendering application developers will develop graphics rendering applications for one of the graphics programming interfaces (such as OpenGL interface) and deploy the graphics rendering applications they developed to different operating systems. However, some manufacturers have launched other types of graphics programming interfaces specifically for the characteristics of their own hardware, and gradually stopped following up on the new versions of graphics programming interfaces required by graphics rendering application developers. As a result, some functions in the graphics rendering applications cannot be used after the graphics rendering applications are ported to certain devices. Summary of the invention
[0003] In view of this, the present application provides a graphics rendering method, device, electronic device and computer-readable storage medium.
[0004] Specifically, the present application is implemented through the following technical solutions:
[0005] According to a first aspect of an embodiment of the present application, a graphics rendering method is provided, comprising:
[0006] Receive graphics rendering requests;
[0007] By calling a first graphics programming interface and calling a second graphics programming interface, the graphics indicated by the graphics rendering request are rendered using a first shader indicated by the first graphics programming interface and a second shader indicated by the second graphics programming interface; the first graphics programming interface and the second graphics programming interface belong to different types of graphics programming interfaces.
[0008] Optionally, the first graphics programming interface includes an OpenGL interface, and the second graphics programming interface includes a Metal interface.
[0009] Optionally, calling a first graphics programming interface and calling a second graphics programming interface to jointly render the graphics indicated by the graphics rendering request using a first shader indicated by the first graphics programming interface and a second shader indicated by the second graphics programming interface includes:
[0010] Passing the rendering parameters indicated by the graphics rendering request to the second shader through the second graphics programming interface for parallel calculation to obtain a calculation result; the calculation result is returned through the second graphics programming interface;
[0011] The calculation result is passed to the first shader through the first graphics programming interface for rendering.
[0012] Optionally, the graphics indicated by the graphics rendering request include a three-dimensional model;
[0013] The graphics rendering request is generated in response to a user's selection operation on the three-dimensional model displayed in the interactive interface;
[0014] The selection operation indicates processing of three-dimensional points within at least one selected area of the three-dimensional model.
[0015] Optionally, calling a first graphics programming interface and calling a second graphics programming interface to jointly render the graphics indicated by the graphics rendering request using a first shader indicated by the first graphics programming interface and a second shader indicated by the second graphics programming interface includes:
[0016] Passing the rendering parameters indicated by the graphics rendering request to the second shader through the second graphics programming interface for parallel calculation, so as to calculate whether each three-dimensional point in the three-dimensional model is a to-be-processed point in the selected area, and obtaining a calculation result; the calculation result is returned through the second graphics programming interface;
[0017] The calculation result is passed to the first shader through the first graphics programming interface to render the three-dimensional model according to the calculation result.
[0018] Optionally, the selection operation includes a penetration selection operation and a non-penetration selection operation; wherein the penetration selection operation indicates processing all three-dimensional points in at least one selected area of the three-dimensional model; and the non-penetration selection operation indicates processing three-dimensional points displayed in the interactive interface in at least one selected area of the three-dimensional model;
[0019] If the graphics rendering request is generated in response to the penetration selection operation, the points to be processed include three-dimensional points located within the selected area;
[0020] If the graphics rendering request is generated in response to the non-penetrating selection operation, the points to be processed include three-dimensional points located in the selected area and displayed in the interactive interface.
[0021] Optionally, the step of passing the rendering parameters indicated by the graphics rendering request to the second shader through the second graphics programming interface for parallel computing includes:
[0022] The rendering parameters indicated by the graphics rendering request are passed to the second graphics programming interface via the conversion interface, and then passed to the second shader by the second graphics programming interface for parallel calculation to obtain a calculation result; wherein the calculation result is returned in sequence via the second graphics programming interface and the conversion interface.
[0023] Optionally, the graphics rendering request is received and processed by a graphics rendering application;
[0024] All second graphics programming interfaces that need to be called by different rendering functions provided in the graphics rendering application are configured to provide a unified interface externally;
[0025] The step of passing the rendering parameters indicated by the graphics rendering request to the second shader through the second graphics programming interface for parallel computing includes:
[0026] The rendering parameters carried by the graphics rendering request are passed to the second shader for parallel calculation through the unified interface, the conversion interface and the second graphics programming interface in sequence to obtain a calculation result; wherein the calculation result is returned via the second graphics programming interface, the conversion interface and the unified interface in sequence.
[0027] Optionally, the conversion interface includes a Metal-cpp interface.
[0028] According to a second aspect of an embodiment of the present application, a graphics rendering device is provided, including:
[0029] A request receiving module, used for receiving a graphics rendering request;
[0030] A rendering module is used to render the graphics indicated by the graphics rendering request by calling a first graphics programming interface and calling a second graphics programming interface, using a first shader indicated by the first graphics programming interface and a second shader indicated by the second graphics programming interface; the first graphics programming interface and the second graphics programming interface belong to different types of graphics programming interfaces.
[0031] According to a third aspect of an embodiment of the present application, there is provided an electronic device, including a memory, a processor, and executable instructions stored in the memory and executable on the processor;
[0032] Wherein, when the processor executes the executable instructions, the steps in the method as described in any one of the first aspects are implemented.
[0033] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which computer instructions are stored. When the computer instructions are executed by a processor, the steps of any one of the methods described in the first aspect are implemented.
[0034] The technical solution provided by the embodiments of the present application may have the following beneficial effects:
[0035] In the embodiment of the present application, by calling the first graphics programming interface and the second graphics programming interface, the first shader and the second shader are used to jointly render the graphics indicated by the graphics rendering request. This solves the problem that the graphics rendering application developed according to the target version is ported to an electronic device, and the version supported by the electronic device is lower than the target version, resulting in some functions in the ported graphics rendering application being unable to be used on the electronic device; from another perspective, it is also possible to reuse some of the available functions in the graphics rendering application without having to develop a new graphics rendering application from scratch, which is conducive to shortening the development cycle and reducing the workload of R&D personnel.
[0036] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0038] Figure 1 It is a flowchart of a graphics rendering method shown in an exemplary embodiment of the present application.
[0039] Figure 2 It is a schematic diagram of a first rendering process shown in an exemplary embodiment of the present application.
[0040] Figure 3 is a schematic diagram of a second rendering process shown in an exemplary embodiment of the present application.
[0041] Figure 4 It is a schematic diagram of a third rendering process shown in an exemplary embodiment of the present application.
[0042] Figure 5 It is a schematic diagram of a fourth rendering process shown in an exemplary embodiment of the present application.
[0043] Figure 6 It is a schematic diagram of the structure of an electronic device shown in an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0044] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0045] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms of "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0046] It should be understood that although the terms first, second, third, etc. may be used in the present application to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0047] In the related art, there is a problem that a graphics rendering application developer will develop a graphics rendering application for one of the graphics programming interfaces (such as the OpenGL interface), and there is a need to deploy it to different operating systems. However, if it is deployed in a device that does not follow the new version of the graphics programming interface, some functions will be unusable.
[0048] Take OpenGL as an example: OpenGL (Open Graphics Library) is a cross-platform graphics programming interface that provides a set of function libraries for rendering 2D and 3D graphics. The design goal of OpenGL is to provide a general, high-performance graphics programming interface that enables developers to use hardware-accelerated graphics rendering. It can be used to develop various graphics applications, including computer games, virtual reality, scientific visualization, computer-aided design (CAD), etc.
[0049] OpenGL has the following features: (1) Cross-platform: OpenGL can run on multiple operating systems, including Windows, macOS, Linux, and various embedded systems. (2) Hardware acceleration: OpenGL can use graphics hardware to accelerate graphics rendering and provide high-performance graphics processing capabilities. (3) Openness: OpenGL is an open standard with broad support and community, and can be easily extended and customized. (4) 2D and 3D support: OpenGL supports the rendering of 2D and 3D graphics and provides rich graphics drawing and transformation functions. (5) Graphics pipeline: OpenGL uses a graphics pipeline to process graphics data, including vertex processing, rasterization, fragment processing and other stages, allowing developers to control every aspect of graphics rendering.
[0050] The main interface of OpenGL is based on C language, but there are also binding libraries and encapsulation tools for other programming languages (such as C++, Python, etc.). In addition, over time, the version of OpenGL is constantly updated, introducing new features and extensions, such as OpenGL ES for mobile devices, WebGL for web browsers, etc.
[0051] Graphics rendering application developers need to deploy their graphics rendering applications to different operating systems. For example, in the field of dental scanning, developers need to provide an application to present the scanned teeth for the next treatment or diagnosis process; and the application needs to be deployed to different operating systems to adapt to devices with different operating systems, such as Windows operating system and Apple operating system.
[0052] Considering the cross-platform characteristics of OpenGL, some graphics rendering application developers will consider developing graphics rendering applications based on OpenGL. However, some manufacturers have launched graphics programming interfaces specifically for their own hardware characteristics, and gradually stopped following up on new versions of OpenGL. For example, Apple has launched Metal technology.
[0053] The fact that some manufacturers stop following the new version of OpenGL brings difficulties to the application deployment needs of graphics rendering application developers. If the OpenGL application developed according to the latest version of OpenGL or a higher version is ported to the platform that stops following the new version of OpenGL, some functions in the OpenGL application may not be available. If a new graphics rendering application is redeveloped for the new graphics programming interface, the development cycle is long and the workload of R&D personnel is heavy.
[0054] In response to the problems in the related art, an embodiment of the present application provides a graphics rendering method, which implements a graphics rendering application developed according to the latest version or a higher version of a first graphics programming interface (such as OpenGL) and then ported to a platform that stops following the new version of the first graphics programming interface. By calling a second graphics programming interface provided by the platform that is different from the first graphics programming interface, some functions in the graphics rendering application that cannot be used on the platform are implemented. The first graphics programming interface and the second graphics programming interface cooperate to support business functions. From another perspective, there is no need to develop a new graphics rendering application from scratch, and some of the available functions in the graphics rendering application developed according to the target version can continue to be reused, which is conducive to shortening the development cycle and reducing the workload of R&D personnel.
[0055] The graphics rendering method provided in the embodiments of the present application can be executed by an electronic device, and the electronic device includes but is not limited to a smart phone / mobile phone, a tablet computer, a personal digital assistant (PDA), a laptop computer, a desktop computer, a media content player, a video game station / system, a virtual reality system, an augmented reality system, a wearable device (e.g., a watch, glasses, gloves, headwear (e.g., a hat, a helmet, a virtual reality headset, an augmented reality headset, a head-mounted device (HMD), a headband), a pendant, an armband, a leg ring, a shoe, a vest), a remote control, or any other device with a graphics processing function.
[0056] Exemplarily, the electronic device integrates a computer program product, and when the electronic device executes the computer program product, the graphics rendering method provided in the embodiment of the present application is implemented.
[0057] In some embodiments, see Figure 1 , Figure 1 A schematic diagram of a flow chart of a graphics rendering method provided by an embodiment of the present application is shown. The method comprises:
[0058] In S101 , a graphics rendering request is received.
[0059] In S102, a first graphics programming interface and a second graphics programming interface are called to render the graphics indicated by the graphics rendering request using a first shader indicated by the first graphics programming interface and a second shader indicated by the second graphics programming interface; the first graphics programming interface and the second graphics programming interface belong to different types of graphics programming interfaces.
[0060] This embodiment uses the first shader and the second shader to jointly render the graphics indicated by the graphics rendering request by calling the first graphics programming interface and the second graphics programming interface. This solves the problem that the graphics rendering application developed according to the target version is transplanted to the electronic device, and the version supported by the electronic device is lower than the target version, resulting in some functions in the transplanted graphics rendering application being unable to be used on the electronic device; from another perspective, it also realizes that there is no need to develop a new graphics rendering application from scratch, and some usable functions in the graphics rendering application can continue to be reused, which is conducive to shortening the development cycle and reducing the workload of R&D personnel.
[0061] Among them, the graphics rendering application transplanted into the electronic device is developed according to the target version, and the graphics rendering request is received and processed by the graphics rendering application. It is understandable that the embodiment of the present application does not impose any restrictions on the specific version number of the target version, and can be specifically set according to the actual application scenario. For example, taking the graphics rendering application as OpenGL as an example, the target version includes OpenGL4.3 version, or a version higher than OpenGL4.3.
[0062] In a possible implementation, the electronic device is a device installed with iOS, tvOS or macOS. iOS is a mobile operating system developed by Apple. tvOS is a television operating system based on iOS developed by Apple. Mac OS is an operating system developed by Apple that runs on Macintosh series computers.
[0063] The first graphics programming interface includes an OpenGL interface, and the second graphics programming interface includes a Metal interface. Metal is a graphics application programming interface that is closer to hardware than OpenGL, and provides the lowest layer required by software to ensure that the software can run on different graphics chips.
[0064] In some embodiments, the graphics rendering request is received and processed by a graphics rendering application transplanted into the electronic device. Specifically, the graphics rendering request is received by a first graphics programming interface in the graphics rendering application, and then the graphics indicated by the graphics rendering request are rendered by calling the first graphics programming interface and calling the second graphics programming interface to use the first shader indicated by the first graphics programming interface and the second shader indicated by the second graphics programming interface.
[0065] Here we take OpenGL as an example to illustrate the shader program:
[0066] (1) Create and compile shader programs: Using OpenGL interface functions, you can create vertex shaders and fragment shaders, and compile the shader source code into executable shader programs.
[0067] (2) Setting up the shader program: Through the OpenGL interface function, the shader program can be bound to the corresponding stage of the rendering pipeline, for example, the vertex shader can be bound to the vertex processing stage, and the fragment shader can be bound to the fragment processing stage.
[0068] (3) Passing data to the shader: Using the OpenGL interface function, you can pass vertex data and other related data (such as texture coordinates, lighting parameters, etc.) to OpenGL, and then OpenGL passes this data to the corresponding shader program for processing.
[0069] (4) Execute drawing commands: After the shader program and related data are prepared, you can use the OpenGL interface function to issue drawing commands to trigger the rendering process. In this process, OpenGL will automatically call the corresponding vertex shader and fragment shader to process vertex and pixel data based on the current state and bound shader program.
[0070] Therefore, by calling the OpenGL interface, you can run the configured shader program, bind it to the corresponding stage of the rendering pipeline, and pass the relevant data. Then, by issuing drawing commands, OpenGL automatically calls the shader program to process the vertex and pixel data in graphics rendering.
[0071] In some embodiments, after a graphics rendering request is received by a first graphics programming interface in a graphics rendering application, rendering parameters indicated by the graphics rendering request can be passed to the second shader through the second graphics programming interface for parallel calculation to obtain calculation results; then, the calculation results are returned through the second graphics programming interface, and then the calculation results are passed to the first shader through the first graphics programming interface for rendering processing to obtain rendered graphics.
[0072] Here, OpenGL is used as an example. When data (such as vertex data, texture coordinates, lighting parameters, etc.) needs to be passed to the shader program for processing, the functions provided by the OpenGL interface can be used to complete the data transfer process. These functions allow data to be passed from the application to the shader program in the rendering pipeline.
[0073] Specifically, you can use the following OpenGL interface functions to pass data to the shader:
[0074] (1) glVertexAttribPointer: This function is used to specify the layout of vertex data and pass the data to the vertex shader. You can specify the location, data type, step size and other information of the vertex attributes and bind the vertex data to the corresponding vertex shader input variables.
[0075] (2) glUniform*: This group of functions is used to pass data to uniform variables in the shader program. You can select the appropriate function according to the type of the uniform variable (such as float, vec3, mat4, etc.) and pass the corresponding data to the uniform variable.
[0076] (3)glBindTexture: This function is used to bind a texture object and pass the texture data to the fragment shader for texture sampling. You can select different texture units and bind the texture object to the corresponding texture unit.
[0077] By calling these OpenGL interface functions, data can be passed from the application to the shader program, so that the shader can obtain and process the data. This method can realize the flow of data in the rendering pipeline, thereby affecting the results of graphics rendering.
[0078] In a possible implementation, if the first graphics programming interface and the second graphics programming interface use the same calling language and the two interfaces support data transfer between each other, data can be directly transferred between the first graphics programming interface and the second graphics programming interface. Figure 2 The rendering parameters indicated by the graphics rendering request can be passed to the second shader through the second graphics programming interface for parallel calculation. After obtaining the calculation result, it is returned through the second graphics programming interface, and then the first graphics programming interface is directly called to pass the calculation result to the first shader for rendering processing to obtain the rendered graphics.
[0079] Exemplarily, the first graphics programming interface includes an OpenGL interface and can be called through Swift language or Object C language, and the second graphics programming interface includes a Metal interface and can also be called through Swift language or Object C language.
[0080] In another possible implementation, when the calling languages of the first graphics programming interface and the second graphics programming interface are different, a conversion interface is required to perform conversion processing. Figure 3 , the rendering parameters indicated by the graphics rendering request can be passed to the second graphics programming interface via the conversion interface, and then passed to the second shader by the second graphics programming interface for parallel calculation to obtain a calculation result. The calculation result is output by the second graphics programming interface, and then passed to the first graphics programming interface via the conversion interface, and the first graphics programming interface passes the calculation result to the first shader for rendering processing to obtain a rendered graphic.
[0081] Exemplarily, the first graphics programming interface includes an OpenGL interface and can be called through the C++ language. The second graphics programming interface includes a Metal interface and can be called through the Swift language or the Objective C language, and the conversion interface includes a Metal-cpp interface. Through the Metal-cpp interface, developers can use the syntax and features of C++ to write Metal applications, and use the functions of Metal to implement GPU-accelerated graphics and computing tasks. The Metal-cpp interface bridges C++ code with Objective-C or Swift code. The Metal-cpp interface provides a set of classes and functions that encapsulate Metal's Objective-C and Swift interfaces, so that C++ code can directly call these interfaces without writing Objective-C or Swift code in C++ code. In this way, developers can use the syntax and features of C++ to write Metal applications, and can easily access and use Metal's functions. In other words, the role of the Metal-cpp interface is to convert the operation of calling the Metal interface with C++ into the operation of calling the Metal interface with Objective-C and Swift languages.
[0082] In some embodiments, considering that different rendering functions provided in the graphics rendering application may need to call more than two second graphics programming interfaces, if a calling program is written for each second graphics programming interface, it will increase the development burden of the developer. Therefore, the present application implements that all second graphics programming interfaces that need to be called by different rendering functions provided in the graphics rendering application are set to provide a unified interface to the outside.
[0083] In a possible implementation, when the calling languages of the first graphics programming interface and the second graphics programming interface are the same and the two interfaces support data transfer between each other, the calling of the second graphics programming interface may be: Figure 4 , passing the rendering parameters carried by the graphics rendering request to the second graphics programming interface via the unified interface, and then passing them to the second shader by the second graphics programming interface for parallel calculation to obtain a calculation result, the calculation result is returned to the unified interface via the second graphics programming interface, output by the unified interface, and then directly calling the first graphics programming interface to pass the calculation result to the first shader for rendering processing to obtain a rendered graphic.
[0084] In another possible implementation, when the first graphics programming interface and the second graphics programming interface have different calling languages, the calling of the second graphics programming interface may be: Figure 5, the rendering parameters carried by the graphics rendering request are passed to the second shader through the unified interface, the conversion interface and the second graphics programming interface in sequence for parallel calculation to obtain calculation results, and then the calculation results are output through the second graphics programming interface, the conversion interface and the unified interface in sequence.
[0085] For example, the rendering parameters carried by the graphics rendering request can be passed to the Metal-cpp interface through a unified interface, and then passed to the Metal interface by the Metal-cpp interface. Finally, the Metal interface passes the rendering parameters to the second shader for parallel calculation to obtain the calculation results. The calculation results are output in turn through the Metal interface, the Metal-cpp interface and the unified interface.
[0086] In an exemplary embodiment, the graphics indicated by the graphics rendering request include a three-dimensional model, such as a tooth model. The graphics rendering request is generated in response to a user's selection operation on the three-dimensional model displayed in the interactive interface; the selection operation includes but is not limited to a box selection operation, a click operation, or inputting coordinate information of a selected area. In an exemplary embodiment, the graphics indicated by the graphics rendering request include a three-dimensional model, such as a three-dimensional scanned model of a tooth. The graphics rendering request is generated in response to a user's selection operation on the three-dimensional model displayed in the interactive interface; the selection operation includes but is not limited to a box selection operation, a click operation, or inputting coordinate information of a selected area.
[0087] The selection operation indicates processing of the 3D points in at least one selected area of the 3D model (e.g., the 3D scanned model). Exemplarily, the selection operation may indicate at least one of the following processing methods: (1) deleting the 3D points in at least one selected area of the 3D model; (2) modifying the color of the 3D points in at least one selected area of the 3D model; (3) performing transparent or semi-transparent processing on the 3D points in at least one selected area of the 3D model; (4) performing highlight processing on the 3D points in at least one selected area of the 3D model. But not limited thereto.
[0088] After receiving a graphics rendering request generated in response to the above-mentioned selection operation through the first graphics programming interface, the second graphics programming interface can be called to pass the rendering parameters indicated by the graphics rendering request to the second shader for parallel calculation to calculate whether each three-dimensional point in the three-dimensional model is a point to be processed in the selected area to obtain a calculation result; the calculation result is returned through the second graphics programming interface, and then the first graphics programming interface is called to pass the calculation result to the first shader for processing, so as to render the three-dimensional model according to the calculation result.
[0089] Exemplarily, for the first processing method described above, the first shader may choose to render only the three-dimensional points outside the selected area according to the calculation result.
[0090] Exemplarily, for the second processing method described above, the first shader may render the three-dimensional points outside the selected area according to the original color and render the three-dimensional points within the selected area according to the modified color based on the calculation result.
[0091] Exemplarily, for the third processing method described above, the first shader may render the three-dimensional points outside the selected area according to the original transparency information based on the calculation result, and render the three-dimensional points within the selected area according to the modified transparency information.
[0092] In some embodiments, the selection operation includes a penetration selection operation, and the penetration selection operation indicates that all three-dimensional points in at least one selected area of the three-dimensional model are processed. After receiving a graphics rendering request generated in response to the above selection operation through the first graphics programming interface, the rendering parameters indicated by the graphics rendering request can be passed to the second shader through the second graphics programming interface for parallel calculation to calculate whether each three-dimensional point in the three-dimensional model is a point to be processed in the selected area, and obtain a calculation result. The calculation result is returned through the second graphics programming interface.
[0093] In some other embodiments, the selection operation includes a non-penetrating selection operation; the non-penetrating selection operation indicates processing of the 3D points displayed in the interactive interface within at least one selected area of the 3D model. Considering that the user can observe the 3D model from different perspectives, some 3D points are visible and some are invisible when observing the 3D model from different perspectives; for example, when observing the 3D model from a front perspective, the 3D points on the front of the 3D model are visible, while the 3D points on the back of the 3D model are invisible, therefore, the 3D points displayed in the interactive interface can be understood as the 3D points visible to the user at the current perspective.
[0094] After receiving the graphics rendering request generated in response to the above selection operation through the first graphics programming interface, the rendering parameters indicated by the graphics rendering request can be passed to the second shader through the second graphics programming interface for parallel calculation to calculate whether each 3D point in the 3D model is a to-be-processed point in the selected area and displayed in the interactive interface, and obtain a calculation result. The calculation result is returned through the second graphics programming interface.
[0095] In a possible implementation, the first graphics programming interface includes an OpenGL interface and can be called through the C++ language. The second graphics programming interface includes a Metal interface and can be called through the Swift language or the Object C language, and the conversion interface includes a Metal-cpp interface. After receiving a graphics rendering request generated in response to the above-mentioned selection operation through the first graphics programming interface, it is necessary to pass the rendering parameters indicated by the graphics rendering request to the second graphics programming interface via the conversion interface, and then pass it to the second shader by the second graphics programming interface for parallel calculation to calculate whether each three-dimensional point in the three-dimensional model is a point to be processed in the selected area, and obtain the calculation result. The calculation result is output through the second graphics programming interface and the conversion interface in turn.
[0096] In order to reduce the development burden of developers, this application implements that all second graphics programming interfaces that need to be called by different rendering functions provided in the graphics rendering application are set to provide a unified interface to the outside. After receiving the graphics rendering request generated in response to the above-mentioned selection operation through the first graphics programming interface, the rendering parameters carried by the graphics rendering request can be passed to the second shader for parallel calculation through the unified interface, the conversion interface and the second graphics programming interface in turn, so as to calculate whether each three-dimensional point in the three-dimensional model is a point to be processed in the selected area, and obtain the calculation result. Then the calculation result is output through the second graphics programming interface, the conversion interface and the unified interface in turn.
[0097] In another possible implementation, when the calling language of the first graphics programming interface and the second graphics programming interface is the same and the two interfaces support data transfer between each other, there is no need to resort to the above-mentioned conversion interface. The specific process can be found in the above-mentioned related description and will not be repeated here.
[0098] In an exemplary embodiment, the first graphics programming interface is an OpenGL interface, and the second graphics programming interface is a Metal interface. Assume that a three-dimensional model is displayed in the interactive interface, and the three-dimensional model contains a number of three-dimensional points. Based on actual needs, the user cuts out a certain area in the three-dimensional model with the help of a cutout tool, and performs a penetration selection operation. At this time, it is necessary to render and display the three-dimensional model after cutting out the specified area. The OpenGL application receives a graphics rendering request through the OpenGL interface. The rendering parameters indicated by the graphics rendering request include a number of three-dimensional point data of the three-dimensional model, and coordinate information of the cutout area.
[0099] The OpenGL application can pass the rendering parameters indicated by the graphics rendering request to the second shader via the Metal-cpp interface and the Metal interface for parallel computing, and parallelly calculate whether each 3D point in the 3D model is within the area to be deleted to determine the points to be deleted, obtain the parallel computing results and return them to the OpenGL application via the Metal interface and the Metal-cpp interface. Taking a certain 3D point in the 3D model as an example, the calculation result of the 3D point is that the 3D point is marked as a point to be deleted, or the 3D point is not marked as a point to be deleted. The OpenGL application can pass the parallel computing results to the first shader via the OpenGL interface, so that the first shader renders other 3D points that are not marked as points to be deleted according to the parallel computing results, so that the 3D model after the specified area is deleted can be displayed in the interactive interface.
[0100] It is not difficult to understand that the schemes described in the above embodiments can be combined when there is no conflict, and they are not listed one by one in the embodiments of the present application.
[0101] Correspondingly, an embodiment of the present application also provides an electronic device, including a memory, a processor, and executable instructions stored in the memory and executable on the processor; wherein the processor implements the steps in the above method when executing the executable instructions.
[0102] Exemplarily, the processor includes but is not limited to a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processor (DSP), an application specific integrated circuit (ASIC), or a field-programmable gate array (FPGA).
[0103] Exemplarily, the memory may include at least one type of storage medium, the storage medium including flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc.
[0104] Figure 6 is a schematic structural diagram of an electronic device provided by an exemplary embodiment. Figure 6At the hardware level, the device includes a processor 602, an internal bus 604, a network interface 606, a memory 608, and a non-volatile memory 610, and may also include hardware required for other services. One or more embodiments of this specification may be implemented based on software, such as the processor 602 reading the corresponding computer program from the non-volatile memory 610 into the memory 608 and then running it. Of course, in addition to the software implementation, one or more embodiments of this specification do not exclude other implementations, such as logic devices or a combination of software and hardware, etc., that is, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0105] In some embodiments, the present application also provides a graphics rendering device, which is applied to Figure 6 In the electronic device shown, the device includes:
[0106] A request receiving module, used for receiving a graphics rendering request;
[0107] A rendering module is used to render the graphics indicated by the graphics rendering request by calling a first graphics programming interface and calling a second graphics programming interface, using a first shader indicated by the first graphics programming interface and a second shader indicated by the second graphics programming interface; the first graphics programming interface and the second graphics programming interface belong to different types of graphics programming interfaces.
[0108] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.
[0109] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory including instructions, and the above instructions can be executed by a processor of the device to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.
[0110] A non-transitory computer-readable storage medium, when the instructions in the storage medium are executed by a processor of a terminal, enables the terminal to execute the above method.
[0111] Although this specification includes many specific implementation details, these should not be interpreted as limiting the scope of any invention or the scope of protection claimed, but are mainly used to describe the features of the specific embodiments of specific inventions. Certain features described in multiple embodiments in this specification may also be implemented in combination in a single embodiment. On the other hand, the various features described in a single embodiment may also be implemented separately in multiple embodiments or in any suitable sub-combination. In addition, although features may work in certain combinations as described above and even initially claim protection, one or more features from the claimed combination may be removed from the combination in some cases, and the claimed combination may point to a sub-combination or a variation of a sub-combination.
[0112] Similarly, although operations are depicted in a particular order in the accompanying drawings, this should not be understood as requiring that these operations be performed in the particular order shown or performed sequentially, or requiring that all illustrated operations be performed to achieve the desired results. In some cases, multitasking and parallel processing may be advantageous. In addition, the separation of various system modules and components in the above-described embodiments should not be understood as requiring such separation in all embodiments, and it should be understood that the described program components and systems can generally be integrated together in a single software product, or packaged into multiple software products.
[0113] Thus, specific embodiments of the subject matter have been described. Other embodiments are within the scope of the appended claims. In some cases, the actions recited in the claims can be performed in a different order and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the particular order or sequential order shown to achieve the desired results. In some implementations, multitasking and parallel processing may be advantageous.
[0114] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A graphics rendering method, characterized in that: include: Receive graphics rendering requests; By calling a first graphics programming interface and calling a second graphics programming interface, a first shader indicated by the first graphics programming interface and a second shader indicated by the second graphics programming interface are used to jointly render the graphics indicated by the graphics rendering request; The first graphical programming interface and the second graphical programming interface belong to different types of graphical programming interfaces.
2. The method according to claim 1, characterized in that The first graphics programming interface includes an OpenGL interface, and the second graphics programming interface includes a Metal interface.
3. The method according to claim 1, characterized in that The method of calling a first graphics programming interface and a second graphics programming interface to jointly render the graphics indicated by the graphics rendering request using a first shader indicated by the first graphics programming interface and a second shader indicated by the second graphics programming interface includes: Passing the rendering parameters indicated by the graphics rendering request to the second shader through the second graphics programming interface for parallel calculation to obtain a calculation result; the calculation result is returned through the second graphics programming interface; The calculation result is passed to the first shader through the first graphics programming interface for rendering.
4. The method according to claim 1 or 2, characterized in that: The graphics indicated by the graphics rendering request include a three-dimensional model; The graphics rendering request is generated in response to a user's selection operation on the three-dimensional model displayed in the interactive interface; The selection operation indicates processing of three-dimensional points within at least one selected area of the three-dimensional model.
5. The method according to claim 4, characterized in that The method of calling a first graphics programming interface and a second graphics programming interface to jointly render the graphics indicated by the graphics rendering request using a first shader indicated by the first graphics programming interface and a second shader indicated by the second graphics programming interface includes: Passing the rendering parameters indicated by the graphics rendering request to the second shader through the second graphics programming interface for parallel calculation, so as to calculate whether each three-dimensional point in the three-dimensional model is a to-be-processed point in the selected area, and obtaining a calculation result; the calculation result is returned through the second graphics programming interface; The calculation result is passed to the first shader through the first graphics programming interface to render the three-dimensional model according to the calculation result.
6. The method according to claim 5, characterized in that The selection operation includes a penetration selection operation and a non-penetration selection operation; wherein the penetration selection operation indicates processing all three-dimensional points in at least one selected area of the three-dimensional model; and the non-penetration selection operation indicates processing three-dimensional points displayed in the interactive interface in at least one selected area of the three-dimensional model; If the graphics rendering request is generated in response to the penetration selection operation, the points to be processed include three-dimensional points located within the selected area; If the graphics rendering request is generated in response to the non-penetrating selection operation, the points to be processed include three-dimensional points located in the selected area and displayed in the interactive interface.
7. The method according to claim 3 or 5, characterized in that: The step of passing the rendering parameters indicated by the graphics rendering request to the second shader through the second graphics programming interface for parallel computing includes: The rendering parameters indicated by the graphics rendering request are passed to the second graphics programming interface via the conversion interface, and then passed to the second shader by the second graphics programming interface for parallel calculation to obtain a calculation result; wherein the calculation result is returned in sequence via the second graphics programming interface and the conversion interface.
8. The method according to claim 7, characterized in that The graphics rendering request is received and processed by the graphics rendering application; All second graphics programming interfaces that need to be called by different rendering functions provided in the graphics rendering application are configured to provide a unified interface externally; The step of passing the rendering parameters indicated by the graphics rendering request to the second shader through the second graphics programming interface for parallel computing includes: The rendering parameters carried by the graphics rendering request are passed to the second shader for parallel calculation through the unified interface, the conversion interface and the second graphics programming interface in sequence to obtain a calculation result; wherein the calculation result is returned via the second graphics programming interface, the conversion interface and the unified interface in sequence.
9. The method according to claim 7, characterized in that: The conversion interface includes a Metal-cpp interface.
10. A graphics rendering device, characterized in that: include: A request receiving module, used for receiving a graphics rendering request; A rendering module, configured to render the graphics indicated by the graphics rendering request by calling a first graphics programming interface and calling a second graphics programming interface, using a first shader indicated by the first graphics programming interface and a second shader indicated by the second graphics programming interface; The first graphical programming interface and the second graphical programming interface belong to different types of graphical programming interfaces.
11. An electronic device, characterized in that: including a memory, a processor, and executable instructions stored in the memory and executable on the processor; Wherein, when the processor executes the executable instructions, the steps in the method as described in any one of claims 1 to 9 are implemented.
12. A computer-readable storage medium having computer instructions stored thereon, characterized in that: When the computer instructions are executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.