CN117710180A - Image rendering method and related equipment - Google Patents
Image rendering method and related equipment Download PDFInfo
- Publication number
- CN117710180A CN117710180A CN202311005225.1A CN202311005225A CN117710180A CN 117710180 A CN117710180 A CN 117710180A CN 202311005225 A CN202311005225 A CN 202311005225A CN 117710180 A CN117710180 A CN 117710180A
- Authority
- CN
- China
- Prior art keywords
- model
- image
- rendering
- rate
- instruction
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T1/00—General purpose image data processing
- G06T1/20—Processor architectures; Processor configuration, e.g. pipelining
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T15/00—3D [Three Dimensional] image rendering
- G06T15/005—General purpose rendering architectures
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2200/00—Indexing scheme for image data processing or generation, in general
- G06T2200/28—Indexing scheme for image data processing or generation, in general involving image processing hardware
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Computer Graphics (AREA)
- Image Generation (AREA)
Abstract
Description
技术领域Technical field
本申请涉及图像处理技术领域,具体而言,涉及一种图像渲染方法及相关设备。The present application relates to the field of image processing technology, specifically, to an image rendering method and related equipment.
背景技术Background technique
电子设备在对图像进行渲染处理时,包括对图像的着色处理。示例性的,程序开发者通过软件算法和图像后处理技术设定好着色速率以后,该着色速率应用于整个图像。电子设备的图形处理器(graphics processing unit,GPU)可以分别对图像的每个像素进行着色,进而完成对整个图像的着色处理。然而,随着图像像素的提高和图像中渲染场景越来越复杂,对图像的着色处理会对电子设备产生较高的渲染负荷,如增加渲染过程中的算力和功耗开销。When an electronic device renders an image, it includes coloring of the image. For example, after the program developer sets the shading rate through software algorithms and image post-processing technology, the shading rate is applied to the entire image. The graphics processing unit (GPU) of the electronic device can color each pixel of the image separately, thereby completing the coloring process of the entire image. However, as image pixels increase and rendering scenes in images become more and more complex, image shading processing will produce higher rendering loads on electronic devices, such as increasing computing power and power consumption during the rendering process.
发明内容Contents of the invention
本申请提供图像渲染方法及相关设备,以解决渲染过程中的算力增加和功耗开销增大的问题。This application provides image rendering methods and related equipment to solve the problems of increased computing power and increased power consumption during the rendering process.
第一方面,本申请实施例提供一种图像渲染方法,应用于电子设备,电子设备中安装有应用程序,应用程序下发渲染指令流以渲染第一图像中的第一模型,该方法包括:拦截渲染指令流中的特定指令;根据特定指令获取第一模型的中心位置,其中,中心位置为第一模型的中心点在第一图像中的位置;根据第一模型的中心位置与第一图像的目标区域确定第一模型的着色速率,其中第一模型的着色速率低于或等于目标区域的着色速率;根据第一模型的着色速率渲染第一模型。In a first aspect, embodiments of the present application provide an image rendering method, which is applied to an electronic device. An application program is installed in the electronic device, and the application program issues a rendering instruction stream to render the first model in the first image. The method includes: Intercept specific instructions in the rendering instruction stream; obtain the center position of the first model according to the specific instruction, where the center position is the position of the center point of the first model in the first image; according to the center position of the first model and the first image The target area determines the shading rate of the first model, wherein the shading rate of the first model is lower than or equal to the shading rate of the target area; the first model is rendered according to the shading rate of the first model.
本申请实施例提供的图像渲染方法,能够为待显示图像中不同的区域设置不同的着色速率,使得电子设备可以通过降低图像中部分区域的着色速率来降低电子设备对该部分区域的渲染工作量、内存和带宽。通过合理地为待显示图像中的不同区域设置不同的着色速率,以在降低渲染过程中功耗和发热的同时,所渲染的图像不会对用户的观感产生明显的影响。由此即可在降低电子设备的功耗和发热的同时,提升用户体验。具体地,针对图像中用户关注的目标区域,模型颜色精度的变化容易被用户察觉,那么针对该目标区域可以采用较高的着色速率,以获得高精度的着色效果。针对用户感知不强的区域(如目标区域之外的区域),模型颜色精度的变化不易被用户察觉,那么针对该部分区域可以采用较低的着色速率进行快速着色,减少功耗。更进一步地,通过对电子设备的软件框架进行改进,电子设备获取渲染指令流中的特定指令,进而根据特定指令可以快速准确地确定模型的中心位置,由此可以快速准确地确定模型的中心位置与图像中目标区域之间的关系,进而基于模型与目标区域之间的关系自适应地为该模型设置对应的着色速率,为后续减少渲染过程中的算力和功耗开销提供保障。The image rendering method provided by the embodiment of the present application can set different shading rates for different areas in the image to be displayed, so that the electronic device can reduce the rendering workload of the electronic device by reducing the shading rate of some areas in the image. , memory and bandwidth. By reasonably setting different shading rates for different areas in the image to be displayed, while reducing power consumption and heat generation during the rendering process, the rendered image will not have a significant impact on the user's perception. This can reduce the power consumption and heat generation of electronic devices while improving user experience. Specifically, for the target area in the image that the user is concerned about, changes in the color accuracy of the model are easily noticed by the user, so a higher coloring rate can be used for the target area to obtain a high-precision coloring effect. For areas where user perception is not strong (such as areas outside the target area), changes in model color accuracy are not easily noticed by users, so a lower coloring rate can be used for rapid coloring in this part of the area to reduce power consumption. Furthermore, by improving the software framework of the electronic device, the electronic device obtains specific instructions in the rendering instruction stream, and can quickly and accurately determine the center position of the model according to the specific instructions, thereby quickly and accurately determining the center position of the model. and the relationship between the target area in the image, and then adaptively set the corresponding shading rate for the model based on the relationship between the model and the target area, providing guarantee for subsequent reduction of computing power and power consumption in the rendering process.
在其中一种可能实现方式中,特定指令包括第一特定指令,根据特定指令获取第一模型的中心位置包括:根据第一特定指令获取第一模型各个顶点的顶点数据和第一模型对应的MVP矩阵;根据顶点数据和MVP矩阵,确定第一模型的中心点在第一图像中的位置。In one possible implementation, the specific instruction includes a first specific instruction, and obtaining the center position of the first model according to the specific instruction includes: obtaining the vertex data of each vertex of the first model and the MVP corresponding to the first model according to the first specific instruction. Matrix; determine the position of the center point of the first model in the first image based on the vertex data and MVP matrix.
通过拦截特定指令进而获得第一模型的顶点数据和MVP矩阵,进而根据第一模型的顶点数据和MVP矩阵确定第一模型的中心点在第一图像中的位置。By intercepting specific instructions, the vertex data and MVP matrix of the first model are obtained, and then the position of the center point of the first model in the first image is determined based on the vertex data and MVP matrix of the first model.
在其中一种可能实现方式中,根据第一模型的中心位置与第一图像的目标区域确定第一模型的着色速率包括:根据第一模型的中心位置与第一图像的目标区域获取第一距离,其中,第一距离为在观察空间或者裁剪空间中,第一模型的中心位置与目标区域之间的距离;根据第一距离确定第一模型对应的着色速率。其中第一距离越小,第一模型的着色速率越高。In one possible implementation, determining the shading rate of the first model based on the center position of the first model and the target area of the first image includes: obtaining the first distance based on the center position of the first model and the target area of the first image. , where the first distance is the distance between the center position of the first model and the target area in the observation space or clipping space; the shading rate corresponding to the first model is determined according to the first distance. The smaller the first distance is, the higher the shading rate of the first model is.
通过计算第一模型的中心位置与目标区域的之间的第一距离来确定第一模型与目标区域之间的关系。当第一距离越小,也即第一模型越接近目标区域,其受到用户关注的可能性越高,进而可以设置其对应的着色速率越高,以获得高精度的着色效果。当第一距离越大,也即第一模型越远离目标区域,其受到用户关注的可能性越低,进而可以设置其对应的着色速率越低,以降低功耗。The relationship between the first model and the target area is determined by calculating a first distance between the center position of the first model and the target area. When the first distance is smaller, that is, the closer the first model is to the target area, the higher the possibility that it will receive the user's attention, and the corresponding shading rate can be set higher to obtain a high-precision shading effect. When the first distance is larger, that is, the first model is further away from the target area, the less likely it is to receive the user's attention, and its corresponding shading rate can be set lower to reduce power consumption.
在其中一种可能实现方式中,根据第一模型的中心位置与第一图像的目标区域确定第一模型的着色速率包括:获取第一模型的类别;获取第一距离,其中,第一距离为在观察空间或者裁剪空间中,第一模型的中心位置与目标区域之间的距离;根据第一模型的类别和第一距离确定第一模型的着色速率。In one possible implementation, determining the shading rate of the first model based on the center position of the first model and the target area of the first image includes: obtaining the category of the first model; obtaining the first distance, where the first distance is In the observation space or clipping space, the distance between the center position of the first model and the target area; the shading rate of the first model is determined according to the category of the first model and the first distance.
通过参考第一模型的类别与第一距离可以更合理设置第一模型的着色速率,提高用户的使用体验。By referring to the category and the first distance of the first model, the shading rate of the first model can be set more reasonably, thereby improving the user experience.
在其中一种可能实现方式中,根据第一模型的类别和第一距离确定第一模型对应的着色速率包括:获取应用程序对应的特定物体类别;当第一模型的类别为特定物体类别时,将特定物体类别对应的着色速率作为第一模型对应的着色速率;当第一模型的类别不是特定物体类别时,根据第一距离确定第一模型对应的着色速率。In one possible implementation, determining the shading rate corresponding to the first model based on the category of the first model and the first distance includes: obtaining a specific object category corresponding to the application; when the category of the first model is a specific object category, The coloring rate corresponding to the specific object category is used as the coloring rate corresponding to the first model; when the category of the first model is not a specific object category, the coloring rate corresponding to the first model is determined based on the first distance.
可以根据不同应用场景下或不同游戏应用,设置模型类别所对应的着色速率,以此提高用户的使用体验。The shading rate corresponding to the model category can be set according to different application scenarios or different game applications to improve the user experience.
在其中一种可能实现方式中,特定指令包括第二特定指令,获取第一模型的类别包括:根据第二特定指令获取第一模型的模型信息;根据第一模型的模型信息确定第一模型的类别。In one of the possible implementations, the specific instruction includes a second specific instruction, and obtaining the category of the first model includes: obtaining the model information of the first model according to the second specific instruction; determining the first model based on the model information of the first model. category.
通过拦截第二特定指令,进而根据第二特定指令获得第一模型的模型信息,以此确定第一模型的类别。By intercepting the second specific instruction, the model information of the first model is obtained according to the second specific instruction, thereby determining the category of the first model.
在其中一种可能实现方式中,该方法还包括:根据应用程序的类型确定目标区域的范围;根据目标区域的范围和第一图像中目标物体的位置确定第一图像中的目标区域,其中目标物体与用户的关注点相关。In one of the possible implementations, the method further includes: determining the range of the target area according to the type of the application; determining the target area in the first image according to the range of the target area and the position of the target object in the first image, where the target Objects are relevant to the user's focus.
通过根据用户的关注点设置对应的目标区域,进而可以基于该目标区域确定各个模型的着色速率,以此在降低渲染过程中功耗和发热的同时,所渲染的图像不会对用户的观感产生明显的影响,提升用户体验。By setting the corresponding target area according to the user's focus, the shading rate of each model can be determined based on the target area. In this way, while reducing power consumption and heat generation during the rendering process, the rendered image will not affect the user's perception. Obvious impact, improving user experience.
在其中一种可能实现方式中,当第一模型的着色速率低于目标区域的着色速率时,则根据第一模型的着色速率渲染第一模型包括:根据最高的着色速率和画质增强算法渲染目标区域,并根据第一模型的着色速率渲染第一模型。In one possible implementation, when the shading rate of the first model is lower than the shading rate of the target area, rendering the first model according to the shading rate of the first model includes: rendering according to the highest shading rate and image quality enhancement algorithm target area and render the first model according to the first model's shading rate.
通过增以最高的着色速率与画质增强算法渲染目标区域,为用户提供高精度的着色效果与图像呈现效果,同时,根据低的着色速率渲染第一模型,可以降低功耗。By increasing the highest shading rate and image quality enhancement algorithm to render the target area, it provides users with high-precision shading effects and image rendering effects. At the same time, rendering the first model based on a low shading rate can reduce power consumption.
在其中一种可能实现方式中,电子设备包括中央处理器和图形处理器,根据第一模型的着色速率渲染第一模型包括:中央处理器调用与第一模型的着色速率对应的第一可变速率着色API,并根据第一可变速率着色API向图形处理器下发第一模型渲染指令;图形处理器响应于第一模型渲染指令,根据第一模型的着色速率渲染第一模型。In one possible implementation, the electronic device includes a central processing unit and a graphics processor, and rendering the first model according to the shading rate of the first model includes: the central processor calling a first variable speed corresponding to the shading rate of the first model. rate shading API, and issues a first model rendering instruction to the graphics processor according to the first variable rate shading API; the graphics processor renders the first model according to the shading rate of the first model in response to the first model rendering instruction.
通过调用与第一模型的着色速率对应的第一可变速率着色API,可以确保根据第一模型的着色速率渲染第一模型。By calling the first variable rate shading API corresponding to the shading rate of the first model, it is ensured that the first model is rendered according to the shading rate of the first model.
在其中一种可能实现方式中,第一图像还包括第二模型,该方法还包括:根据第二模型的中心位置与第一图像的目标区域获取第二距离,其中,第二距离为在观察空间或者裁剪空间中,第二模型的中心位置与目标区域之间的距离;根据第二距离确定第二模型对应的着色速率,其中,第二距离大于第一距离,第二模型的着色速率低于第一模型的着色速率;根据第二模型的着色速率渲染第二模型。In one possible implementation, the first image further includes a second model, and the method further includes: obtaining a second distance according to the center position of the second model and the target area of the first image, where the second distance is In space or clipping space, the distance between the center position of the second model and the target area; determine the shading rate corresponding to the second model based on the second distance, where the second distance is greater than the first distance, and the shading rate of the second model is low Renders the second model based on the shading rate of the first model; renders the second model based on the shading rate of the second model.
第二距离小于第一距离,相应地,所设置的第二模型的着色速率高于第一模型的着色速率。也即越接近目标区域的模型其对应的着色速率越高,越远离目标区域的模型其对应的着色速率越低。The second distance is smaller than the first distance. Correspondingly, the set shading rate of the second model is higher than the shading rate of the first model. That is, the model closer to the target area has a higher shading rate, and the model farther away from the target area has a lower shading rate.
在其中一种可能实现方式中,根据第二模型的着色速率渲染第二模型包括:中央处理器调用与第二模型的着色速率对应的第二可变速率着色API,并根据第二可变速率着色API向图形处理器下发第二模型渲染指令;图形处理器响应于第二模型渲染指令,根据第二模型的着色速率渲染第二模型。In one possible implementation manner, rendering the second model according to the shading rate of the second model includes: the central processor calls a second variable rate shading API corresponding to the shading rate of the second model, and renders the second model according to the second variable rate. The shading API issues a second model rendering instruction to the graphics processor; the graphics processor responds to the second model rendering instruction and renders the second model according to the shading rate of the second model.
不同的着色速率其对应不同的着色速率API。如,当第一距离与第二距离分布属于不同的距离范围时,其对应的着色速率不同,由此调用不同的着色速率API。Different shading rates correspond to different shading rate APIs. For example, when the first distance and the second distance distribution belong to different distance ranges, their corresponding shading rates are different, thus calling different shading rate APIs.
第二方面,本申请实施例提供一种电子设备,该电子设备包括一个或多个处理器和一个或多个存储器;一个或多个存储器与一个或多个处理器耦合,一个或多个存储器存储有计算机指令;当一个或多个处理器执行计算机指令时,使得电子设备执行如上任一项的图像渲染方法。In a second aspect, embodiments of the present application provide an electronic device. The electronic device includes one or more processors and one or more memories; the one or more memories are coupled to the one or more processors, and the one or more memories Computer instructions are stored; when one or more processors execute the computer instructions, the electronic device is caused to perform any of the above image rendering methods.
第三方面,本申请实施例提供一种计算机可读存储介质,计算机可读存储介质包括计算机指令,当计算机指令运行时,执行如上任一项的图像渲染方法。In a third aspect, embodiments of the present application provide a computer-readable storage medium. The computer-readable storage medium includes computer instructions. When the computer instructions are run, any one of the above image rendering methods is executed.
第四方面,本申请实施例提供一种芯片系统,芯片系统包括处理器和通信接口;处理器用于从存储介质中调用并运行存储介质中存储的计算机程序,执行如上任一项的图像渲染方法。In the fourth aspect, embodiments of the present application provide a chip system. The chip system includes a processor and a communication interface; the processor is configured to call and run the computer program stored in the storage medium from the storage medium, and execute any of the above image rendering methods. .
另外,第二方面至第四方面所带来的技术效果可参见上述方法部分各设计的方法相关的描述,此处不再赘述。In addition, the technical effects brought about by the second to fourth aspects can be found in the descriptions related to the respective designed methods in the above method section, and will not be described again here.
附图说明Description of the drawings
为了更清楚地说明本申请实施例的技术方案,下面将对实施例中的附图作简单地介绍,应当理解,以下附图仅示出了本申请的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present application and therefore should not be viewed as The drawings only limit the scope. For those of ordinary skill in the art, other relevant drawings can be obtained based on these drawings without exerting creative efforts.
图1为本申请实施例提供的电子设备根据应用程序的渲染指令流进行图像渲染的过程示意图;Figure 1 is a schematic diagram of the process of image rendering by an electronic device according to the rendering instruction stream of an application provided by an embodiment of the present application;
图2A为本申请实施例提供的游戏主场景示意图;Figure 2A is a schematic diagram of the main scene of the game provided by the embodiment of the present application;
图2B为图2A游戏主场景中游戏角色移动后的示意图;Figure 2B is a schematic diagram of the game character after movement in the main scene of the game in Figure 2A;
图3为本申请实施例提供的电子设备的软件结构示意图;Figure 3 is a schematic diagram of the software structure of the electronic device provided by the embodiment of the present application;
图4为本申请实施例提供的图像渲染方法流程示意图;Figure 4 is a schematic flow chart of an image rendering method provided by an embodiment of the present application;
图5为本申请实施例提供的拦截渲染指令流示意图;Figure 5 is a schematic diagram of the interception rendering instruction flow provided by the embodiment of the present application;
图6为本申请实施例提供的计算第一模型的中心位置示意图;Figure 6 is a schematic diagram of calculating the center position of the first model provided by the embodiment of the present application;
图7为本申请实施例提供的另一图像渲染方法流程示意图;Figure 7 is a schematic flow chart of another image rendering method provided by an embodiment of the present application;
图8为本申请实施例提供的另一图像渲染方法流程示意图;Figure 8 is a schematic flow chart of another image rendering method provided by an embodiment of the present application;
图9为本申请实施例提供的一种芯片系统结构示意图。Figure 9 is a schematic structural diagram of a chip system provided by an embodiment of the present application.
具体实施方式Detailed ways
在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者装置不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者装置所固有的要素。在没有更多限制的情况下,由语句“包括一个”限定的要素,并不排除在包括该要素的过程、方法、物品或者装置中还存在另外的相同要素。As used herein, the terms "comprises," "comprises," or any other variation thereof are intended to cover a non-exclusive inclusion such that a process, method, article, or apparatus that includes a list of elements includes not only those elements, but also includes not expressly Other elements listed may also include elements inherent to such process, method, article or apparatus. Without further limitation, an element defined by the statement "comprises a" does not exclude the presence of additional identical elements in a process, method, article, or apparatus that includes that element.
本申请中“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B可以表示:单独存在A,同时存在A和B,单独存在B的情况,其中A,B可以是单数或者复数。本申请的说明书和权利要求书及附图中的术语“第一”、“第二”、“第三”、“第四”等(如果存在)是用于区别类似的对象,而不是用于描述特定的顺序或先后次序。"And/or" in this application describes the relationship between associated objects, indicating that there can be three relationships. For example, A and/or B can mean: A exists alone, A and B exist simultaneously, and B exists alone, where A and B can be singular or plural. The terms "first", "second", "third", "fourth", etc. (if present) in the description, claims and drawings of this application are used to distinguish similar objects, rather than to Describe a specific order or sequence.
本申请实施例提供的图像渲染方法可以由电子设备来执行。该电子设备可以是终端设备,终端设备也可以称为终端(terminal)、用户设备(user equipment,UE)、移动台(mobile station,MS)、移动终端(mobile terminal,MT)等。终端设备可以是智能手机、电脑、智能电视、个人数字助理(personal digital assistant,PDA)、可穿戴设备、增强现实(augmented reality,AR)\虚拟现实(virtual reality,VR)设备、媒体播放器等便携式移动设备。该电子设备还可以是车载设备、物联网设备或者其他能够进行图像渲染处理的设备。该电子设备可以是运行安卓(Android)系统、IOS系统、windows系统或其他操作系统的设备。本申请实施例对电子设备的类型以及电子设备所运行的操作系统不作具体限定。The image rendering method provided by the embodiment of the present application can be executed by an electronic device. The electronic device may be a terminal device, and the terminal device may also be called a terminal (terminal), user equipment (UE), mobile station (MS), mobile terminal (MT), etc. Terminal devices can be smartphones, computers, smart TVs, personal digital assistants (PDAs), wearable devices, augmented reality (AR)\virtual reality (VR) devices, media players, etc. Portable mobile devices. The electronic device may also be a vehicle-mounted device, an Internet of Things device, or other device capable of image rendering processing. The electronic device may be a device running Android system, IOS system, Windows system or other operating systems. The embodiments of this application do not specifically limit the type of electronic device and the operating system run by the electronic device.
请参阅图1,示例性地介绍电子设备根据应用程序的渲染指令流进行图像渲染的过程。电子设备100包括中央处理器(Central Processing Unit,CPU)101、图形处理器102、存储器103和显示器104。中央处理器101用于运行应用程序111和操作系统112。应用程序111可以为游戏应用、视频应用(视频播放器)等。操作系统112提供图形库和图像合成模块。图像合成模块用于二维或三维图像的合成。图形处理器102中的渲染管线(Renderingpipeline)是图形处理器102在渲染图形或图像的过程中顺序执行的一系列操作,渲染管线包括但不限于如下操作:顶点处理(vertex processing)、图元处理(primitiveprocessing)、光栅化(rasterization)以及片段处理(fragment processing)。存储器103包括内部存储器(即内存)、缓存(cache)、显卡内存(Video Memory)以及外部存储器中的一种或多种。Please refer to Figure 1 to exemplarily introduce the process of image rendering by an electronic device according to the rendering instruction flow of the application program. The electronic device 100 includes a central processing unit (CPU) 101, a graphics processor 102, a memory 103, and a display 104. The central processing unit 101 is used to run application programs 111 and operating system 112. The application program 111 may be a game application, a video application (video player), etc. Operating system 112 provides graphics libraries and image synthesis modules. The image synthesis module is used for the synthesis of two-dimensional or three-dimensional images. The rendering pipeline (Renderingpipeline) in the graphics processor 102 is a series of operations performed sequentially by the graphics processor 102 in the process of rendering graphics or images. The rendering pipeline includes but is not limited to the following operations: vertex processing, primitive processing (primitive processing), rasterization and fragment processing. The memory 103 includes one or more of internal memory (ie, memory), cache, graphics card memory (Video Memory), and external memory.
在应用程序111需要对图像进行渲染时,下发渲染指令流。中央处理器101根据应用程序111下发的渲染指令流调用图形库中的应用程序接口(application programminginterface,API),以便于指示图形处理器102执行对应的渲染操作。图形库根据所调用的应用程序接口生成渲染管线能够识别的指令流。图形处理器102接收图形库发送的指令流,通过渲染管线执行渲染。图形处理器102执行渲染后的渲染结果可以存储在电子设备100中的存储器103(如显存)。操作系统112的图像合成模块从存储器103中获取渲染结果,将渲染结果合成后显示到显示器104。When the application program 111 needs to render an image, it issues a rendering instruction stream. The central processing unit 101 calls an application programming interface (API) in the graphics library according to the rendering instruction stream issued by the application program 111, so as to instruct the graphics processor 102 to perform the corresponding rendering operation. The graphics library generates a stream of instructions that the rendering pipeline can recognize based on the API it calls. The graphics processor 102 receives the instruction stream sent by the graphics library and performs rendering through the rendering pipeline. The rendering result after the graphics processor 102 performs rendering can be stored in the memory 103 (such as a video memory) in the electronic device 100 . The image synthesis module of the operating system 112 obtains the rendering results from the memory 103 , synthesizes the rendering results, and displays them on the display 104 .
越来越多的应用程序,例如游戏应用或者视频应用等应用程序,需要在电子设备上显示场景丰富的图像。这些图像通常是由电子设备基于模型进行渲染得到。以应用程序为游戏应用为例,游戏应用显示到显示器上的主场景如图2A所示,主场景包括各个模型,如人物模型、石块模型、草丛模型等。为了提供画质精美的图像,通常以较高的着色速率渲染图像。较高的着色速率对应的同时着色的像素数量小于较低的着色速率对应的同时着色的像素数量。比如,对比1×1的着色速率以及2×2的着色速率,那么2×2的着色速率可以为较低的着色速率,1×1的着色速率可以为较高的着色速率,1×1的着色速率表示每个像素计算一次像素颜色,2×2的着色速率表示4个像素共用计算一次像素颜色。换句话说,以较高的着色速率渲染图像时,会多次计算像素颜色,进而进行多次的着色处理,由此增加电子设备渲染过程中的算力、增加内存开销以及对电子设备造成较大的功耗,进而电子设备出现发热或者掉帧现象,影响用户体验。More and more applications, such as game applications or video applications, need to display scene-rich images on electronic devices. These images are usually rendered by electronic devices based on models. Taking the application as a game application as an example, the main scene displayed on the monitor by the game application is as shown in Figure 2A. The main scene includes various models, such as character models, stone models, grass models, etc. To provide beautiful images, images are usually rendered at a higher shading rate. A higher shading rate corresponds to a smaller number of pixels being shaded simultaneously than a lower shading rate. For example, comparing the shading rate of 1×1 and the shading rate of 2×2, then the shading rate of 2×2 can be a lower shading rate, the shading rate of 1×1 can be a higher shading rate, and the shading rate of 1×1 can be a higher shading rate. The shading rate means that the pixel color is calculated once for each pixel, and the 2×2 shading rate means that the pixel color is calculated once for 4 pixels. In other words, when rendering an image at a higher shading rate, the pixel color will be calculated multiple times, and then the shading process will be performed multiple times, thereby increasing the computing power of the electronic device during the rendering process, increasing the memory overhead, and causing greater harm to the electronic device. Large power consumption causes electronic devices to heat up or drop frames, affecting user experience.
发明人在实施本申请实施例时发现,在一些场景中,如用户使用游戏应用或看视频时,用户所关注的区域会较为集中。如图2A展示的人物模型是由玩家操控的游戏角色,玩家往往会关注游戏角色所处区域。如图2B所示,随着游戏角色的移动,图像中的画面内容也会随之变化,但是玩家关注的焦点始终是在游戏角色上,也就是图像的中心区域,相反,玩家对图像的边缘区域感知不强,如对图像中的石块模型、草丛模型感知不强。When implementing the embodiments of the present application, the inventor found that in some scenarios, such as when the user uses a game application or watches a video, the area that the user pays attention to will be relatively concentrated. The character model shown in Figure 2A is a game character controlled by the player, and the player often pays attention to the area where the game character is located. As shown in Figure 2B, as the game character moves, the content of the image will also change, but the player's focus is always on the game character, which is the center area of the image. On the contrary, the player focuses on the edges of the image. The area perception is not strong, such as the stone model and grass model in the image.
鉴于此,本申请实施例提供一种图像渲染方法以及相关设备,能够为待显示图像中不同的区域设置不同的着色速率,使得电子设备可以通过降低图像中部分区域的着色速率来降低电子设备对该部分区域的渲染工作量、内存和带宽。通过合理地为待显示图像中的不同区域设置不同的着色速率,以在降低渲染过程中功耗和发热的同时,所渲染的图像不会对用户的观感产生明显的影响。由此即可在降低电子设备的功耗和发热的同时,提升用户体验。具体地,针对图像中用户关注的目标区域,模型颜色精度的变化容易被用户察觉,那么针对该目标区域可以采用较高的着色速率,以获得高精度的着色效果。针对用户感知不强的区域(如目标区域之外的区域),模型颜色精度的变化不易被用户察觉,那么针对该部分区域可以采用较低的着色速率进行快速着色,减少功耗。更进一步地,通过对电子设备的软件框架进行改进,电子设备获取渲染指令流中的特定指令,进而根据特定指令可以快速准确地确定模型的中心位置,由此可以快速准确地确定模型的中心位置与图像中目标区域之间的关系,进而基于模型与目标区域之间的关系自适应地为该模型设置对应的着色速率,为后续减少渲染过程中的算力和功耗开销提供保障。In view of this, embodiments of the present application provide an image rendering method and related equipment, which can set different shading rates for different areas in the image to be displayed, so that the electronic device can reduce the shading rate of some areas in the image. Rendering workload, memory, and bandwidth for this area. By reasonably setting different shading rates for different areas in the image to be displayed, while reducing power consumption and heat generation during the rendering process, the rendered image will not have a significant impact on the user's perception. This can reduce the power consumption and heat generation of electronic devices while improving user experience. Specifically, for the target area in the image that the user is concerned about, changes in the color accuracy of the model are easily noticed by the user, so a higher coloring rate can be used for the target area to obtain a high-precision coloring effect. For areas where user perception is not strong (such as areas outside the target area), changes in model color accuracy are not easily noticed by users, so a lower coloring rate can be used for rapid coloring in this part of the area to reduce power consumption. Furthermore, by improving the software framework of the electronic device, the electronic device obtains specific instructions in the rendering instruction stream, and can quickly and accurately determine the center position of the model according to the specific instructions, thereby quickly and accurately determining the center position of the model. and the relationship between the target area in the image, and then adaptively set the corresponding shading rate for the model based on the relationship between the model and the target area, providing guarantee for subsequent reduction of computing power and power consumption in the rendering process.
以下结合附图对本申请实施例提供的方案进行详细说明。The solutions provided by the embodiments of the present application will be described in detail below with reference to the accompanying drawings.
上述电子设备的软件系统可以采用分层架构、事件驱动架构、微核架构、微服务架构或云架构。下面本申请实施例以分层架构的Android系统为例,示例性说明电子设备的软件结构。当然,在其他操作系统中,只要各个功能模块实现的功能和本申请实施例类似,也可以实现本申请实施例。The software system of the above-mentioned electronic device can adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture or a cloud architecture. The following embodiments of the present application take the Android system with a layered architecture as an example to illustrate the software structure of the electronic device. Of course, in other operating systems, as long as the functions implemented by each functional module are similar to those of the embodiments of the present application, the embodiments of the present application can also be implemented.
请参阅图3,示例性介绍本申请实施例提供的电子设备的软件结构。Please refer to Figure 3 for an exemplary introduction to the software structure of the electronic device provided by the embodiment of the present application.
分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,将Android系统分为四层,从上至下分别为应用程序层,应用程序框架层,系统库以及硬件层。The layered architecture divides the software into several layers, and each layer has clear roles and division of labor. The layers communicate through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: application layer, application framework layer, system library and hardware layer.
应用程序层可以包括一系列应用程序包。应用程序包可以包括游戏应用、视频应用等需要通过渲染图像向用户展示图片或者视频的应用程序。The application layer can include a series of application packages. Application packages can include game applications, video applications, and other applications that need to display pictures or videos to users by rendering images.
应用程序框架层可以为应用程序层的应用程序提供应用编程接口和编程框架。应用程序框架层包括一些预先定义的函数。The application framework layer can provide application programming interfaces and programming frameworks for applications in the application layer. The application framework layer includes some predefined functions.
示例性的,应用程序框架层可以包括窗口管理器,内容提供器,视图系统,资源管理器,活动管理器,输入管理器等。窗口管理器提供窗口管理服务(Window ManagerService,WMS),窗口管理服务可以用于窗口管理、窗口动画管理、surface管理以及作为输入系统的中转站。内容提供器用来存放和获取数据,并使这些数据可以被应用程序访问。该数据可以包括视频,图像,音频等。视图系统包括可视控件,例如显示文字的控件,显示图片的控件等。视图系统可用于构建应用程序。显示界面可以由一个或多个视图组成的。例如,包括短信通知图标的显示界面,可以包括显示文字的视图以及显示图片的视图。资源管理器为应用程序提供各种资源,比如本地化字符串,图标,图片,布局文件,视频文件等等。活动管理器可以提供活动管理服务(Activity Manager Service,AMS),用于管理各个应用程序的生命周期以及导航回退功能。AMS可以用于系统组件(例如活动、服务、内容提供者、广播接收器)的启动、切换、调度以及应用进程的管理和调度工作。输入管理器可以提供输入管理服务(Input Manager Service,IMS),IMS可以用于管理系统的输入,例如触摸屏输入、按键输入、传感器输入等。IMS从输入设备节点取出事件,通过和WMS的交互,将事件分配至合适的窗口。For example, the application framework layer may include a window manager, a content provider, a view system, a resource manager, an activity manager, an input manager, etc. The window manager provides a window management service (Window Manager Service, WMS), which can be used for window management, window animation management, surface management, and as a transfer station for the input system. Content providers are used to store and retrieve data and make this data accessible to applications. This data can include videos, images, audio, etc. The view system includes visual controls, such as controls that display text, controls that display pictures, etc. A view system can be used to build applications. The display interface can be composed of one or more views. For example, a display interface including a text message notification icon may include a view for displaying text and a view for displaying pictures. The resource manager provides various resources to applications, such as localized strings, icons, pictures, layout files, video files, etc. The activity manager can provide activity management service (AMS) to manage the life cycle of each application and the navigation fallback function. AMS can be used for the startup, switching, and scheduling of system components (such as activities, services, content providers, and broadcast receivers) as well as the management and scheduling of application processes. The input manager can provide input management service (Input Manager Service, IMS), and IMS can be used to manage system input, such as touch screen input, key input, sensor input, etc. IMS takes out events from the input device node and distributes the events to appropriate windows through interaction with WMS.
在本申请实施例中,在应用程序框架层中可以设置一个或多个功能模块,用于实现本申请实施例提供的图像渲染方法。示例性地,应用程序框架层中可以设置拦截模块和确定模块。其中,拦截模块用于拦截应用程序下发的渲染指令流中的特定指令,其中渲染指令流用于指示渲染图像中的模型。确定模块用于确定该模型的着色速率。在另一些实施例中,应用程序框架层还可以包括计算模块。计算模块用于计算该模型的中心位置。在另一些实施例中,应用程序框架层还可以包括识别模块。识别模块用于识别该模型的类别。确定模块还可以用于根据模型的中心位置和模型的类别中的一个或两个确定模型对应的着色速率。在后续示例中,将会对上述各个模块的功能进行详细说明。In this embodiment of the present application, one or more functional modules may be set in the application framework layer to implement the image rendering method provided by the embodiment of the present application. For example, an interception module and a determination module can be set in the application framework layer. Among them, the interception module is used to intercept specific instructions in the rendering instruction stream issued by the application, where the rendering instruction stream is used to instruct the model in the rendered image. The determine module is used to determine the shading rate of the model. In other embodiments, the application framework layer may also include a computing module. The calculation module is used to calculate the center position of the model. In other embodiments, the application framework layer may also include an identification module. The identification module is used to identify the category of the model. The determining module may also be used to determine the shading rate corresponding to the model according to one or both of the center position of the model and the category of the model. In subsequent examples, the functions of each of the above modules will be explained in detail.
拦截模块、计算模块、确定模块和识别模块可以分别是由电子设备上运行的一段程序,用于实现对应的功能。在另一些实施例中,识别模块可以识别当前渲染模型的类别。如预先对游戏的模型类别进行离线分析,并记录相应特征。识别模块对在游戏实时运行过程中所拦截到的数据进行特征分析,并与离线分析得到的特征进行匹配,以确定模型的类别。The interception module, calculation module, determination module and identification module may each be a program run on the electronic device to implement corresponding functions. In other embodiments, the identification module may identify the category of the current rendering model. For example, perform offline analysis on the game model categories in advance and record the corresponding characteristics. The identification module performs feature analysis on the data intercepted during the real-time running of the game and matches it with the features obtained from offline analysis to determine the category of the model.
系统库可以包括多个功能模块。例如图形库、表面管理器(surface manager)等。System libraries can include multiple functional modules. For example, graphics library, surface manager, etc.
图形库也称为绘图库,图形库用于定义跨编程语言、跨平台的应用程序编程接口,其中包含许多对图形(图像)进行处理的函数。以开放式图形库(Open Graphics Library,OpenGL)为例,OpenGL定义的API中包括用于实现对应功能的接口,例如,用于绘制二维图像或三维图像的接口,该接口包括绘制函数,例如绘制函数glDrawElements()。又例如,用于将绘制函数绘制的图像呈现到显示界面(显示器)上的接口,该接口包括呈现函数,例如函数eglSwapBuffers()),本申请实施例在此不进行一一举例。The graphics library is also called the drawing library. The graphics library is used to define cross-programming language and cross-platform application programming interfaces, which contains many functions for processing graphics (images). Take the Open Graphics Library (OpenGL) as an example. The API defined by OpenGL includes interfaces for implementing corresponding functions, for example, an interface for drawing two-dimensional images or three-dimensional images. The interface includes drawing functions, such as Drawing function glDrawElements(). As another example, an interface is used to present an image drawn by a drawing function to a display interface (display). The interface includes a rendering function, such as the function eglSwapBuffers()). The embodiments of this application will not give examples one by one here.
其中,OpenGL中的函数可以通过指令调用,例如,通过渲染指令流中的指令可以调用绘制函数,以绘制二维图像或三维图像。该渲染指令流中的指令是在游戏应用开发时开发人员根据图形库内的函数编写的指令,用于调用与指令对应的图形库的接口。Among them, functions in OpenGL can be called through instructions. For example, drawing functions can be called through instructions in the rendering instruction stream to draw two-dimensional images or three-dimensional images. The instructions in the rendering instruction stream are instructions written by developers based on functions in the graphics library when developing game applications, and are used to call the interface of the graphics library corresponding to the instructions.
其中,图形库包括但不限于:嵌入式开放图形库(open graphics library forembedded system,OpenGL ES)、柯罗诺斯平台图形界面(the khronos platform graphicsinterface)或Vulkan(一个跨平台的绘图应用程序接口)等图形库。Among them, graphics libraries include but are not limited to: open graphics library forembedded system (OpenGL ES), the khronos platform graphics interface (the khronos platform graphics interface) or Vulkan (a cross-platform graphics application program interface) and other graphics libraries.
表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了二维图层和三维图层的融合。The surface manager is used to manage the display subsystem and provides the fusion of 2D and 3D layers for multiple applications.
在本申请实施例中,系统库中的图形库(如OpenGL ES)能够提供可变速率着色的拓展功能。那么,电子设备可以在需要针对某一个Drawcall执行可变速率着色时,调用OpenGL ES中的可变速率着色API实现对当前Drawcall的可变速率着色。比如,电子设备可以使用较低的速率(如2×1,2×2,4×2,4×4等)对当前Drawcall进行着色,由此降低对当前Drawcall进行着色产生的开销。In this embodiment of the present application, the graphics library (such as OpenGL ES) in the system library can provide extended functions of variable rate shading. Then, when the electronic device needs to perform variable rate shading for a certain Drawcall, it can call the variable rate shading API in OpenGL ES to implement variable rate shading of the current Drawcall. For example, the electronic device can use a lower rate (such as 2×1, 2×2, 4×2, 4×4, etc.) to shade the current Drawcall, thereby reducing the overhead caused by shading the current Drawcall.
硬件层中可以包括处理器(如中央处理器,图形处理器等)、具有存储功能的部件(如存储器)以及具有显示功能的部件(如显示器)。中央处理器、图形处理器以及存储器的相关内容可以参考上述图1。电子设备中的中央处理器和图形处理器可以位于同一个芯片上,也可以分别为独立的芯片。The hardware layer may include a processor (such as a central processing unit, a graphics processor, etc.), components with storage functions (such as memory), and components with display functions (such as a display). For relevant contents of the central processing unit, graphics processor and memory, please refer to Figure 1 above. The central processing unit and graphics processor in electronic equipment can be located on the same chip, or they can be separate chips.
在一些实施例中,中央处理器可以用于控制应用程序框架层中的各个模块实现其各自的功能,图形处理器可以用于根据应用程序框架层中各个模块处理后的指令所调用的图形库(如OpenGL ES)中的API执行相应的渲染处理。In some embodiments, the central processing unit can be used to control each module in the application framework layer to implement their respective functions, and the graphics processor can be used to control the graphics library called according to the instructions processed by each module in the application framework layer. (such as OpenGL ES) performs the corresponding rendering processing.
为了能够对本申请实施例提供的软件架构中各个层的功能进行更加清楚的说明,以下以游戏应用进行图像渲染为例,对具有图3所示软件组成的各个组件的功能实现进行举例说明。In order to explain more clearly the functions of each layer in the software architecture provided by the embodiments of this application, the following takes image rendering in a game application as an example to illustrate the functional implementation of each component with the software components shown in Figure 3.
请参阅图4,示例性介绍本申请实施例提供的图像渲染方法流程。Please refer to Figure 4 for an exemplary introduction to the image rendering method flow provided by the embodiment of the present application.
步骤S40,游戏应用下发渲染指令流。Step S40: The game application issues a rendering instruction stream.
在本申请实施例中,电子设备中安装的应用程序可以响应于用户的操作下发渲染指令流。如游戏应用可以响应于用户的操作启动游戏、加载游戏或运行游戏,在游戏启动、加载或运行时,游戏应用向电子设备的中央处理器下发渲染指令流,以指示电子设备渲染图像。In this embodiment of the present application, the application program installed in the electronic device can issue a rendering instruction stream in response to the user's operation. For example, a game application can start a game, load a game, or run a game in response to a user's operation. When the game starts, loads, or runs, the game application sends a rendering instruction stream to the central processor of the electronic device to instruct the electronic device to render an image.
其中,一个渲染指令流对应一帧图像,渲染指令流可以用于指示对一帧图像中的一个或一个以上的模型进行渲染。针对图像中一个模型的渲染可以通过一个Drawcall下发,则渲染指令流可以包括一个或一个以上的Drawcall。例如在游戏应用需要渲染主场景图像时,游戏应用向中央处理器下发渲染主场景图像的渲染指令流,该渲染指令流可以包括针对该主场景图像的人物模型、房屋模型以及树木模型中的一个或多个的渲染,也即渲染指令流包括指示渲染人物模型的Drawcall、指示渲染房屋模型的Drawcall和指示渲染树木模型的Drawcall中的一个或多个。One rendering instruction stream corresponds to one frame of image, and the rendering instruction stream can be used to instruct one or more models in one frame of image to be rendered. Rendering for a model in an image can be issued through one Drawcall, and the rendering instruction stream can include one or more Drawcalls. For example, when a game application needs to render a main scene image, the game application issues a rendering instruction stream for rendering the main scene image to the central processor. The rendering instruction stream may include character models, house models, and tree models for the main scene image. One or more renderings, that is, the rendering instruction stream includes one or more of a Drawcall instructing to render a character model, a Drawcall instructing to render a house model, and a Drawcall instructing to render a tree model.
在本申请实施例中,以应用程序下发的渲染指令流用于指示渲染第一图像中的第一模型为例,也即渲染指令流包括指示渲染第一图像中第一模型的Drawcall。在另一些实施例中,渲染指令流可以用于指示渲染第一图像中的两个或两个以上模型(如第一模型和第二模型),针对第一图像中第一模型之外的其他模型的渲染处理可以参考第一模型,在此不再赘述。In this embodiment of the present application, the rendering instruction stream issued by the application program is used to instruct the rendering of the first model in the first image as an example. That is, the rendering instruction stream includes a Drawcall instructing the rendering of the first model in the first image. In other embodiments, the rendering instruction stream may be used to instruct rendering of two or more models (such as a first model and a second model) in the first image, for other objects other than the first model in the first image. For the rendering processing of the model, please refer to the first model and will not be described in detail here.
在本申请实施例中,渲染指令流可以包括一条或者多条指令(即函数),指示渲染第一模型的Drawcall可以包括一条或者多条指令。以电子设备中的图形库为OpenGL为例,渲染指令流可以包括下述指令(函数)中的一个或多个:glGenBuffer指令,glBindBuffer指令,glBufferData指令,glBufferSubData指令,glMapBuffer指令,glMapBufferRange指令,glUseProgram指令以及glDrawElement指令。In this embodiment of the present application, the rendering instruction stream may include one or more instructions (ie, functions), and the Drawcall indicating rendering of the first model may include one or more instructions. Taking the graphics library in an electronic device as OpenGL as an example, the rendering instruction stream may include one or more of the following instructions (functions): glGenBuffer instruction, glBindBuffer instruction, glBufferData instruction, glBufferSubData instruction, glMapBuffer instruction, glMapBufferRange instruction, glUseProgram instruction and the glDrawElement directive.
其中,glGenbuffer指令可以用于创建缓冲。即在电子设备的存储器(如内存)中划分一个或多个存储空间,每个存储空间都可以具有一个标识(ID)。该划分的存储空间可以用于存储渲染过程中的各项相关数据。比如,一些缓冲可以用于存储待渲染模型(如第一模型)的顶点坐标,一些缓冲可以用于存储该待渲染模型对应的模型-观察-投影(Model-View-Projection,MVP)矩阵等。Among them, the glGenbuffer instruction can be used to create a buffer. That is, one or more storage spaces are divided into the memory (such as memory) of the electronic device, and each storage space can have an identification (ID). The divided storage space can be used to store various related data during the rendering process. For example, some buffers can be used to store the vertex coordinates of the model to be rendered (such as the first model), and some buffers can be used to store the model-view-projection (MVP) matrix corresponding to the model to be rendered, etc.
其中,MVP矩阵包括模型(Model)矩阵(即M矩阵)、观察(View)矩阵(即V矩阵)、投影(Projection)矩阵(即P矩阵)三个矩阵。M矩阵用于将局部空间中的局部坐标转换为世界空间中的世界坐标。V矩阵用于将世界空间中的世界坐标转换为观察空间中的观察坐标。P矩阵用于将观察空间中的观察坐标转换为裁剪空间中的裁剪坐标。Among them, the MVP matrix includes three matrices: Model matrix (M matrix), View matrix (V matrix), and Projection matrix (P matrix). The M matrix is used to convert local coordinates in local space to world coordinates in world space. The V matrix is used to convert world coordinates in world space to observation coordinates in observation space. The P matrix is used to convert observation coordinates in observation space into clipping coordinates in clipping space.
其中,glBindbuffer指令可以用于绑定缓冲。通过该指令绑定缓冲,后续的渲染操作就可以使用该对应的缓冲。示例性地,以创建的缓冲包括缓冲A和缓冲B为例。通过glBindbuffer(A),在电子设备执行后续的渲染操作如写入数据(如顶点坐标)的操作时,电子设备就可以将顶点坐标写入到缓冲A进行存储。Among them, the glBindbuffer instruction can be used to bind the buffer. By binding the buffer with this instruction, subsequent rendering operations can use the corresponding buffer. As an example, the created buffer includes buffer A and buffer B. Through glBindbuffer(A), when the electronic device performs subsequent rendering operations such as writing data (such as vertex coordinates), the electronic device can write the vertex coordinates to buffer A for storage.
其中,glBufferdata指令可以用于传递数据。示例性的,在glBufferdata指令携带的数据非空(NULL),则电子设备就可以将该glBufferdata指令携带的数据(或者数据的指针)存储到已经绑定的缓冲上。比如,在glBufferdata指令携带有顶点坐标时,则电子设备就可以将该顶点坐标存储到已经绑定的帧缓冲上。又如,在glBufferdata指令携带有顶点坐标的索引时,则电子设备就可以将该顶点坐标索引存储到已经绑定的帧缓冲上。类似于glBufferdata指令,glMapBuffer指令以及glMapBufferRange指令也可以用于进行数据的传递。例如,glMapBuffer指令可以用于将一个缓冲区对象中的数据映射到电子设备中的地址空间。这样,在GPU需要使用这些数据时,可以从电子设备中的地址空间直接读取该数据。不同于glMapBuffer指令,glMapBufferRange指令可以将一部分特定的数据映射到电子设备的地址空间中,以便于后续GPU调用。Among them, the glBufferdata instruction can be used to transfer data. For example, if the data carried by the glBufferdata instruction is not empty (NULL), the electronic device can store the data (or data pointer) carried by the glBufferdata instruction into the bound buffer. For example, when the glBufferdata instruction carries vertex coordinates, the electronic device can store the vertex coordinates in the bound frame buffer. For another example, when the glBufferdata instruction carries the index of the vertex coordinate, the electronic device can store the vertex coordinate index into the bound frame buffer. Similar to the glBufferdata instruction, the glMapBuffer instruction and glMapBufferRange instruction can also be used to transfer data. For example, the glMapBuffer instruction can be used to map data in a buffer object to the address space in an electronic device. In this way, when the GPU needs to use this data, it can be read directly from the address space in the electronic device. Different from the glMapBuffer instruction, the glMapBufferRange instruction can map a part of specific data to the address space of the electronic device to facilitate subsequent GPU calls.
其中,glBufferSubData指令可以用于数据的更新。比如,游戏应用可以通过该glBufferSubData指令,实现对顶点坐标中的一部分或全部进行更新,从而达到指示电子设备(如电子设备的GPU)根据新的顶点坐标进行绘制渲染的效果。Among them, the glBufferSubData instruction can be used to update data. For example, a game application can use the glBufferSubData instruction to update part or all of the vertex coordinates, thereby instructing the electronic device (such as the GPU of the electronic device) to draw and render based on the new vertex coordinates.
其中,glUseProgram指令使用程序对象program作为当前渲染状态的一部分。Among them, the glUseProgram instruction uses the program object program as part of the current rendering state.
其中,glDrawElement指令可以用于绘制三维图像,其可以绘制由四个顶点组成的三角形。该指令包括四个参数:mode(用于指定绘制的模式)、count(用于指定绘制的顶点数)、type(用于指示顶点索引的数据类型)以及indices(用于指向索引数组的指针),也即其使用count个元素定义一个几何序列,这些元素的索引值保存在indices数组中。Among them, the glDrawElement instruction can be used to draw three-dimensional images, which can draw a triangle composed of four vertices. This instruction includes four parameters: mode (used to specify the drawing mode), count (used to specify the number of vertices to draw), type (data type used to indicate the vertex index) and indices (used to point to the index array pointer) , that is, it uses count elements to define a geometric sequence, and the index values of these elements are stored in the indices array.
在一些实施例中,渲染指令流还可以包括着色器相关的指令,如包括glLinkProgram(链接着色器对象指令),glShaderSource(关联着色器指令),glCompileShader(着色器编译指令),以及glUseProgram(着色器调用指令)等指令。本申请实施例对渲染指令流包括的指令不作具体限定。In some embodiments, the rendering instruction stream may also include shader-related instructions, such as glLinkProgram (link shader object instruction), glShaderSource (associate shader instruction), glCompileShader (shader compilation instruction), and glUseProgram (shader call instructions) and other instructions. The embodiments of this application do not specifically limit the instructions included in the rendering instruction stream.
在本申请实施例中,该渲染指令流可以包括不同的内容,对此不作具体限定。示例性地,在应用程序层中的视频应用需要渲染某个图像(如第N帧图像,即第一图像)时,可以下发起渲染指令流。渲染指令流中可以包括渲染过程中的各项相关数据,如第一图像中需要被渲染的模型的顶点数据、MVP矩阵(即M矩阵、V矩阵以及P矩阵)以及一个或多个绘制元素(Drawelement),该顶点数据可以用于指示待渲染的模型的顶点的顶点坐标,该顶点坐标可以是基于局部空间的坐标。在一些实现中,该渲染指令流还可以包括渲染该第N帧图像所需要调用的帧缓冲,以及在各个帧缓冲中需要执行的渲染操作。比如,第N帧图像需要使用FB0和FB1作为帧缓冲为例。渲染指令流可以包括bindFrameBuffer(1)指令,由此实现当前渲染操作与FB1的绑定。在绑定FB1之后,可以通过glDrawElement指令,实现在该FB1上的渲染操作。In this embodiment of the present application, the rendering instruction stream may include different contents, which is not specifically limited. For example, when the video application in the application layer needs to render a certain image (such as the Nth frame image, that is, the first image), the rendering instruction stream can be initiated. The rendering instruction stream may include various relevant data in the rendering process, such as the vertex data of the model that needs to be rendered in the first image, the MVP matrix (i.e., M matrix, V matrix, and P matrix) and one or more drawing elements ( Drawelement), the vertex data may be used to indicate the vertex coordinates of the vertices of the model to be rendered, and the vertex coordinates may be coordinates based on local space. In some implementations, the rendering instruction stream may also include the frame buffer that needs to be called to render the Nth frame image, and the rendering operations that need to be performed in each frame buffer. For example, the Nth frame image needs to use FB0 and FB1 as frame buffers. The rendering instruction stream may include the bindFrameBuffer(1) instruction, thereby binding the current rendering operation to FB1. After binding FB1, you can use the glDrawElement instruction to implement rendering operations on the FB1.
步骤S41,拦截模块拦截渲染指令流中的第一特定指令,以获得第一模型各个顶点的顶点数据和第一模型对应的MVP矩阵。Step S41: The interception module intercepts the first specific instruction in the rendering instruction stream to obtain vertex data of each vertex of the first model and the MVP matrix corresponding to the first model.
在本申请实施例中,拦截模块可以基于钩子(Hook)函数拦截渲染指令流中的特定指令,以基于特定指令获得第一模型在第一图像中的中心位置。其中钩子函数指通过拦截软件模块间的函数调用、消息传递、事件传递来修改或扩展操作系统、应用程序或其他软件组件的行为的各种技术。换句话说,钩子函数是用于处理被拦截的函数调用、事件、消息的代码。In the embodiment of the present application, the interception module can intercept specific instructions in the rendering instruction stream based on a hook function to obtain the center position of the first model in the first image based on the specific instructions. Hook functions refer to various technologies that modify or extend the behavior of operating systems, applications or other software components by intercepting function calls, message passing, and event passing between software modules. In other words, the hook function is the code used to handle intercepted function calls, events, and messages.
在本申请实施例中,上述特定指令包括第一特定指令。第一特定指令用于获取能用于计算第一模型在第一图像中的中心位置的相关数据,该相关数据例如可以包括第一模型的各个顶点的顶点数据以及第一模型对应的MVP矩阵。In this embodiment of the present application, the above-mentioned specific instructions include the first specific instructions. The first specific instruction is used to obtain relevant data that can be used to calculate the center position of the first model in the first image. The relevant data may include, for example, vertex data of each vertex of the first model and the MVP matrix corresponding to the first model.
在本申请实施例中,顶点数据至少包括各个顶点的顶点坐标以及顶点坐标的索引数据,该顶点坐标可以是基于局部空间的局部坐标。In this embodiment of the present application, the vertex data at least includes the vertex coordinates of each vertex and the index data of the vertex coordinates. The vertex coordinates may be local coordinates based on the local space.
在本申请实施例中,第一模型对应的MVP矩阵包括:将第一模型的局部坐标转换至裁剪坐标(或屏幕坐标)所需的M矩阵、V矩阵以及P矩阵三个矩阵。In this embodiment of the present application, the MVP matrix corresponding to the first model includes: three matrices: the M matrix, the V matrix, and the P matrix required to convert the local coordinates of the first model into cropping coordinates (or screen coordinates).
具体地,第一特定指令包括携带第一参数的第一指令和/或携带第二参数的第二指令。Specifically, the first specific instruction includes a first instruction carrying a first parameter and/or a second instruction carrying a second parameter.
其中,第一参数可以为指示用于传输与顶点相关的顶点数据的参数。第一参数可以包括GL_ELEMENT_ARRAY_BUFFER、GL_ARRAY_BUFFER等目标(target)以及对应的缓冲对象等。Wherein, the first parameter may be a parameter indicating a parameter used to transmit vertex data related to the vertex. The first parameter may include targets such as GL_ELEMENT_ARRAY_BUFFER, GL_ARRAY_BUFFER, and corresponding buffer objects.
可以理解,OpenGL中的缓冲是一块内存区域,将缓冲绑定到一个特定缓冲对象,也即为该缓冲赋予了对应的特定意义。例如当将缓冲对象绑定到GL_ARRAY_BUFFER的时候,该缓冲对象对应的缓冲即为用于存储顶点数据,如用于存储顶点坐标、法线、颜色、纹理坐标等。当将缓冲对象绑定到GL_ELEMENT_ARRAY_BUFFER的时候,该缓冲对象对应的缓冲即为用于存储顶点数据的索引数据。It can be understood that the buffer in OpenGL is a memory area. The buffer is bound to a specific buffer object, which means that the buffer is given a corresponding specific meaning. For example, when a buffer object is bound to GL_ARRAY_BUFFER, the buffer corresponding to the buffer object is used to store vertex data, such as vertex coordinates, normals, colors, texture coordinates, etc. When a buffer object is bound to GL_ELEMENT_ARRAY_BUFFER, the buffer corresponding to the buffer object is the index data used to store vertex data.
以第一指令为例,第一指令包括但不限于如下指令:glGenBuffers指令,其用于生成一个或多个缓冲区对象,并返回它们的标识符。glBindBuffer指令,其用于绑定一个缓冲区对象到指定的目标。glBufferData指令,其用于将数据分配给绑定到指定目标的缓冲区,并设置其使用方式。glBufferSubData指令,其用于更新绑定到指定目标的缓冲区的一部分数据。glVertexAttribPointer指令,其用于定义顶点属性,如顶点坐标、法线、颜色等。glEnableVertexAttribArray指令,其用于启用指定顶点属性。Taking the first instruction as an example, the first instruction includes but is not limited to the following instructions: glGenBuffers instruction, which is used to generate one or more buffer objects and return their identifiers. glBindBuffer instruction, which is used to bind a buffer object to the specified target. The glBufferData directive allocates data to a buffer bound to a specified target and sets how it is used. glBufferSubData directive, which is used to update a portion of the data in the buffer bound to the specified target. glVertexAttribPointer instruction, which is used to define vertex attributes, such as vertex coordinates, normals, colors, etc. glEnableVertexAttribArray directive, which is used to enable specified vertex attributes.
其中,第二参数可以为用于进行MVP矩阵传输的参数。第二参数可以包括GL_UNIFORM_BUFFER等目标以及对应的缓冲对象等。第二指令包括但不限于如下指令:glBufferSubData指令、glGenbuffer指令、glBindbuffer指令以及glBufferdata指令等。The second parameter may be a parameter used for MVP matrix transmission. The second parameter may include targets such as GL_UNIFORM_BUFFER and corresponding buffer objects. The second instructions include but are not limited to the following instructions: glBufferSubData instruction, glGenbuffer instruction, glBindbuffer instruction, glBufferdata instruction, etc.
在一些实施例中,第一指令与第二指令可以为同一指令,也即第一特定指令可以为同时携带第一参数和第二参数的指令,如glBufferSubData指令等。In some embodiments, the first instruction and the second instruction may be the same instruction, that is, the first specific instruction may be an instruction carrying both the first parameter and the second parameter, such as the glBufferSubData instruction.
在本申请实施例中,拦截模块拦截第一特定指令中的目标和缓冲对象实现顶点数据和MVP矩阵的拦截。具体地,在拦截顶点数据时,拦截模块Hook第一特定指令,拦截到目标GL_ELEMENT_ARRAY_BUFFER、GL_ARRAY_BUFFER以及缓冲对象,基于目标与缓冲对象进一步拦截获取到数据(data)并进行缓冲。在拦截MVP矩阵时:拦截模块首先分析第一模型对应的顶点着色器(VS shader),以确定第一模型对应的MVP矩阵的变量(Uniform)名称,如M矩阵为Primitive_LocalToWorldTranslated,VP矩阵为View_TranslatedWorldToClip。其次,确定MVP矩阵的传值方式。最后获取对应的MVP矩阵的值。In the embodiment of the present application, the interception module intercepts the target and buffer object in the first specific instruction to implement the interception of vertex data and MVP matrix. Specifically, when intercepting vertex data, the interception module Hook first specific instruction intercepts the target GL_ELEMENT_ARRAY_BUFFER, GL_ARRAY_BUFFER and the buffer object, and further intercepts and obtains data (data) based on the target and buffer object and buffers them. When intercepting the MVP matrix: The interception module first analyzes the vertex shader (VS shader) corresponding to the first model to determine the variable (Uniform) name of the MVP matrix corresponding to the first model. For example, the M matrix is Primitive_LocalToWorldTranslated and the VP matrix is View_TranslatedWorldToClip. Secondly, determine the value transfer method of the MVP matrix. Finally, obtain the value of the corresponding MVP matrix.
请一并参阅图5,以应用程序下发的渲染指令流包括glGenBuffer,glBindBuffer,glBufferData,glBufferSubData,glUseProgram以及glDrawElement等指令为例。第一特定指令包括第一指令和第二指令。Please refer to Figure 5 together, taking the rendering instruction stream issued by the application including glGenBuffer, glBindBuffer, glBufferData, glBufferSubData, glUseProgram and glDrawElement as an example. The first specific instruction includes a first instruction and a second instruction.
以拦截模块拦截如下第一指令为例:Take the interception module intercepting the following first instruction as an example:
拦截到glGenbuffers(1,buffer111),代表为顶点数据创建1个缓冲对象buffer111,buffer111指向一块缓冲。Intercepting glGenbuffers(1, buffer111) means creating a buffer object buffer111 for vertex data, and buffer111 points to a buffer.
拦截到glBindbuffer(GL_ARRAY_BUFFER,buffer111),代表将缓冲对象buffer111与目标GL_ARRAY_BUFFER进行绑定。Intercepting glBindbuffer(GL_ARRAY_BUFFER, buffer111) means binding the buffer object buffer111 to the target GL_ARRAY_BUFFER.
拦截到glBufferdata(GL_ARRAY_BUFFER,data1),代表向已经绑定的缓冲写入data1,即在缓冲对象buffer111与目标GL_ARRAY_BUFFER已经绑定后,通过GL_ARRAY_BUFFER这个目标就能访问到buffer111对应的缓冲,进而将data1写入Buffer111对应的缓冲;Intercepting glBufferdata(GL_ARRAY_BUFFER, data1) means writing data1 to the bound buffer. That is, after the buffer object buffer111 and the target GL_ARRAY_BUFFER have been bound, the buffer corresponding to buffer111 can be accessed through the GL_ARRAY_BUFFER target, and then data1 is written. Enter the buffer corresponding to Buffer111;
拦截到glBufferSubData(GL_ARRAY_BUFFER,data2),代表更新已经绑定的缓冲中的数据为data2。Intercepting glBufferSubData(GL_ARRAY_BUFFER, data2) means updating the data in the bound buffer to data2.
其中,data1和data2可以包括顶点数据,如顶点坐标、顶点的法向量等。Among them, data1 and data2 can include vertex data, such as vertex coordinates, normal vectors of vertices, etc.
以拦截模块拦截如下第二指令为例:Take the interception module intercepting the following second command as an example:
拦截到glGenbuffers(1,buffer111),代表为统一变量(如MVP矩阵)创建1个缓冲对象buffer111。Intercepting glGenbuffers(1, buffer111) means creating a buffer object buffer111 for a unified variable (such as MVP matrix).
拦截到glBindbuffer(GL_UNIFORM_BUFFER,buffer111),代表将缓冲对象buffer111与目标GL_UNIFORM_BUFFER进行绑定。Intercepting glBindbuffer(GL_UNIFORM_BUFFER, buffer111) means binding the buffer object buffer111 to the target GL_UNIFORM_BUFFER.
拦截到glBufferdata(GL_UNIFORM_BUFFER,data3),代表向已经绑定的缓冲写入data3即在缓冲对象buffer111与目标GL_UNIFORM_BUFFER已经绑定后,通过GL_UNIFORM_BUFFER这个目标就能访问到buffer111对应的缓冲,进而将data3写入buffer111对应的缓冲;Intercepting glBufferdata(GL_UNIFORM_BUFFER, data3) means writing data3 to the bound buffer. That is, after the buffer object buffer111 and the target GL_UNIFORM_BUFFER have been bound, the buffer corresponding to buffer111 can be accessed through the GL_UNIFORM_BUFFER target, and then data3 is written. The buffer corresponding to buffer111;
拦截到glBufferSubData(GL_UNIFORM_BUFFER,data4),代表更新已经绑定的缓冲中的数据为data4。其中,data3和data4可以包括MVP矩阵。Intercepting glBufferSubData(GL_UNIFORM_BUFFER, data4) means updating the data in the bound buffer to data4. Among them, data3 and data4 can include MVP matrices.
示例性地,使用GPU调试工具(如renderDoc)对游戏内一帧图像进行截取,以该帧图像(即第一图像)中的小黄鸭模型(即第一模型)为例,详细介绍拦截小黄鸭模型的顶点数据以及MVP矩阵。For example, use a GPU debugging tool (such as renderDoc) to intercept a frame of image in the game. Taking the little yellow duck model (that is, the first model) in this frame of image (that is, the first image) as an example, we will introduce in detail how to intercept the small yellow duck. The vertex data and MVP matrix of the yellow duck model.
拦截顶点数据:Intercept vertex data:
如表1中的第#56号Draw所对应的绘制模型为小黄鸭模型。As shown in Table 1, the drawing model corresponding to Draw No. 56 is a little yellow duck model.
表1Table 1
示例性地,小黄鸭模型对应的指令序列如表2所示的ID为979到ID为990的指令序列。For example, the instruction sequence corresponding to the little yellow duck model is the instruction sequence with ID 979 to ID 990 shown in Table 2.
表2Table 2
拦截模块通过拦截glBindBuffer指令获取小黄鸭模型对应的BufferID,并基于BufferID去拦截glBufferrData或者glBufferSubData指令。通过拦截glBufferrData或者glBufferSubData指令获取到小黄鸭模型的顶点数据data。拦截模块拦截glVertexAttribPointer指令获取相应参数,并基于该参数对buffer中的顶点数据data进行解析,以获得顶点数据。其中,glVertexAttribPointer指令中的参数代表了顶点数据在buffer中的组织形式,拦截模块通过拦截到的索引、步长、数据偏置等参数去解析buffer中的顶点数据。The interception module obtains the BufferID corresponding to the little yellow duck model by intercepting the glBindBuffer instruction, and intercepts the glBufferrData or glBufferSubData instruction based on the BufferID. Obtain the vertex data of the little yellow duck model by intercepting the glBufferrData or glBufferSubData command. The interception module intercepts the glVertexAttribPointer instruction to obtain the corresponding parameters, and parses the vertex data data in the buffer based on the parameters to obtain the vertex data. Among them, the parameters in the glVertexAttribPointer instruction represent the organization form of the vertex data in the buffer. The interception module parses the vertex data in the buffer through the intercepted parameters such as index, step size, and data offset.
拦截MVP矩阵:Interception MVP matrix:
示例性地,分析小黄鸭对应的顶点着色器为shader 2039,分析shader 2039可以确定M矩阵的变量名为Primitive_LocalToWorldTranslatedvb1,其对应的变量存储在Buffer 10626。VP矩阵的变量名为View_TranslatedWorldToClipvb0,其对应的变量存储在Buffer 2832。拦截模块拦截Buffer10626、Buffer 2832并解析得到MVP数据。For example, the vertex shader corresponding to the little yellow duck is shader 2039. By analyzing shader 2039, it can be determined that the variable name of the M matrix is Primitive_LocalToWorldTranslatedvb1, and its corresponding variable is stored in Buffer 10626. The variable name of the VP matrix is View_TranslatedWorldToClipvb0, and its corresponding variable is stored in Buffer 2832. The interception module intercepts Buffer10626 and Buffer 2832 and parses them to obtain MVP data.
步骤S42,拦截模块将获得的顶点数据和MVP矩阵存储至存储器。Step S42: The interception module stores the obtained vertex data and MVP matrix into the memory.
在本申请实施例中,拦截模块还用于对拦截的特定数据进行备份存储。如拦截模块将获得的顶点坐标和MVP矩阵存储至存储器,该存储器可以为内存等。示例性地,电子设备可以将这些数据存储在内存中CPU能够调用的区域。由此电子设备的内存中就可以存储有后续渲染过程中可能用到的顶点数据(如顶点坐标)以及MVP矩阵。可以理解的是,原生应用程序下发的渲染指令流是用于将数据传输到GPU所能够调用的存储区域的,因此,通过本示例中的备份存储,使得CPU也可以具有拦截模块所拦截到的数据的(如对顶点数据和MVP矩阵)的调用能力,由此保证后续方案的实现,如计算第一模型的中心位置。In this embodiment of the present application, the interception module is also used to back up and store intercepted specific data. For example, the interception module stores the obtained vertex coordinates and MVP matrix into a memory, which can be a memory, etc. For example, the electronic device may store these data in an area of memory that the CPU can recall. As a result, the memory of the electronic device can store vertex data (such as vertex coordinates) and MVP matrices that may be used in the subsequent rendering process. It can be understood that the rendering instruction stream issued by the native application is used to transmit data to the storage area that the GPU can call. Therefore, through the backup storage in this example, the CPU can also have an interception module to intercept The ability to call the data (such as vertex data and MVP matrix) ensures the implementation of subsequent solutions, such as calculating the center position of the first model.
步骤S43,计算模块获取顶点数据和MVP矩阵,并根据顶点数据和MVP矩阵计算出第一模型的中心位置。Step S43: The calculation module obtains the vertex data and MVP matrix, and calculates the center position of the first model based on the vertex data and MVP matrix.
在步骤S42中拦截模块将所拦截的数据进行备份存储后,计算模块可以从存储器(如内存)中获取拦截模块所拦截的数据,如顶点数据和MVP矩阵。After the interception module backs up and stores the intercepted data in step S42, the computing module can obtain the data intercepted by the interception module from the storage (such as memory), such as vertex data and MVP matrix.
在本申请实施例中,第一模型的中心位置可以为:在观察空间或裁剪空间中,第一模型的中心点在第一图像中的位置,该中心位置可以为观察坐标、裁剪坐标或屏幕坐标。In the embodiment of the present application, the center position of the first model may be: in the observation space or the cropping space, the position of the center point of the first model in the first image. The center position may be the observation coordinates, cropping coordinates, or screen coordinate.
在本申请实施例中,计算模块获取拦截模块所拦截的顶点数据和MVP矩阵,然后根据顶点数据中的顶点坐标和AABB(Axis-aligned bounding box)包围盒的思想计算出第一模型在局部空间的中心坐标V1:{X,Y,Z},其中X=(x_min+x_max)/2,Y=(y_min+y_max)/2,Z=(z_min+z_max)/2,其中,x_min、x_max、y_min、y_max、z_min以及z_max均为根据顶点数据获得的第一模型在局部空间中的局部坐标。x_min为第一模型的局部坐标在x方向上的最小值。x_max为第一模型的局部坐标在x方向上的最大值。y_min为第一模型的局部坐标在y方向上的最小值。y_max为第一模型的局部坐标在y方向上的最大值。z_min为第一模型的局部坐标在z方向上的最小值。z_max为第一模型的局部坐标在z方向上的最大值。最后计算模块将第一模型在局部空间的中心坐标V1经过MVP矩阵变化得到第一模型的中心点在第一图像中的位置,计算过程为:P*V*M*V1。In the embodiment of this application, the calculation module obtains the vertex data and MVP matrix intercepted by the interception module, and then calculates the position of the first model in the local space based on the vertex coordinates in the vertex data and the idea of AABB (Axis-aligned bounding box) bounding box. The center coordinate V1: {X, Y, Z}, where X=(x_min+x_max)/2, Y=(y_min+y_max)/2, Z=(z_min+z_max)/2, where, y_min, y_max, z_min and z_max are all the local coordinates of the first model in the local space obtained according to the vertex data. x_min is the minimum value of the local coordinates of the first model in the x direction. x_max is the maximum value of the local coordinates of the first model in the x direction. y_min is the minimum value of the local coordinates of the first model in the y direction. y_max is the maximum value of the local coordinates of the first model in the y direction. z_min is the minimum value of the local coordinates of the first model in the z direction. z_max is the maximum value of the local coordinates of the first model in the z direction. Finally, the calculation module changes the center coordinate V1 of the first model in the local space through the MVP matrix to obtain the position of the center point of the first model in the first image. The calculation process is: P*V*M*V1.
下述以中心位置为屏幕坐标为例,详细说明计算模块根据顶点坐标和MVP矩阵计算出第一模型的中心位置的过程。The following takes the center position as the screen coordinates as an example to explain in detail the process of the calculation module calculating the center position of the first model based on the vertex coordinates and the MVP matrix.
请参阅图6,以呈现在电子设备的显示器上的第一图像60包括物体61、物体62、物体63和物体64,物体61、物体62、物体63和物体64对应游戏应用下发的渲染指令流中指示渲染的模型,分别为第一模型611、第二模型621、第三模型631以及第四模型641为例。下述以计算第一模型611的中心位置进行举例说明,其他模型的中心位置计算可以参考第一模型611,在此不再赘述。Referring to FIG. 6 , the first image 60 presented on the display of the electronic device includes objects 61 , 62 , 63 and 64 . The objects 61 , 62 , 63 and 64 correspond to the rendering instructions issued by the game application. The models indicated for rendering in the stream are the first model 611, the second model 621, the third model 631 and the fourth model 641 as examples. The following uses the calculation of the center position of the first model 611 as an example. The calculation of the center positions of other models can refer to the first model 611 and will not be described again here.
游戏应用可以在下发对第一图像60的第一模型611的渲染指令流中,携带局部空间的坐标系下第一模型611的各个顶点的顶点坐标,该各个顶点的顶点坐标即局部坐标。如上述,计算模块基于局部空间的坐标系下第一模型611的各个顶点的顶点坐标和包围盒的思想计算出第一模型611的中心坐标V1,中心坐标V1为局部空间的局部坐标。The game application may carry the vertex coordinates of each vertex of the first model 611 in the coordinate system of the local space in the rendering instruction stream issued to the first model 611 of the first image 60. The vertex coordinates of each vertex are the local coordinates. As mentioned above, the calculation module calculates the center coordinate V1 of the first model 611 based on the vertex coordinates of each vertex of the first model 611 and the bounding box in the coordinate system of the local space. The center coordinate V1 is the local coordinate of the local space.
计算模块可以通过游戏应用下发的第一模型611对应的M矩阵,将第一模型611在局部空间中的中心坐标V1转换为世界空间中的坐标,得到中心坐标V2。该中心坐标V2为第一模型的中心点在世界空间中的世界坐标。如图6所示,在第一模型611转换至世界空间的坐标后,可以看到第二模型621、第三模型631以及第四模型641在世界空间中的位置。The calculation module can convert the center coordinate V1 of the first model 611 in the local space into the coordinate in the world space through the M matrix corresponding to the first model 611 issued by the game application to obtain the center coordinate V2. The center coordinate V2 is the world coordinate of the center point of the first model in world space. As shown in FIG. 6 , after the first model 611 is converted to the coordinates of the world space, the positions of the second model 621 , the third model 631 and the fourth model 641 in the world space can be seen.
计算模块在获取第一模型611的中心点在世界空间中的中心坐标V2之后,计算模块可以根据游戏应用下发的第一模型611对应的V矩阵,将第一模型611的中心点在世界空间中的中心坐标V2,转换为观察空间中的坐标,得到中心坐标V3。该中心坐标V3为第一模型611的中心点在观察空间中的观察坐标。如图6所示,在第一模型611转换至观察空间的坐标后,可以看到第二模型621、第三模型631以及第四模型641在观察空间中的位置。After the calculation module obtains the center coordinate V2 of the center point of the first model 611 in the world space, the calculation module can calculate the center point of the first model 611 in the world space according to the V matrix corresponding to the first model 611 issued by the game application. The center coordinate V2 in is converted to the coordinate in the observation space to obtain the center coordinate V3. The center coordinate V3 is the observation coordinate of the center point of the first model 611 in the observation space. As shown in FIG. 6 , after the first model 611 is converted to the coordinates of the observation space, the positions of the second model 621 , the third model 631 and the fourth model 641 in the observation space can be seen.
在本示例中,与摄像机位置对应的坐标空间可以称为观察空间。示例性的,以摄像机设置在世界空间中的y轴正方向为例。如图6所示,由于摄像机位于y轴正方向,向下进行拍摄,因此对应在观察空间中的第一模型611至第四模型641可以呈现为俯视效果。In this example, the coordinate space corresponding to the camera position can be called the observation space. As an example, take the camera set in the positive direction of the y-axis in world space. As shown in FIG. 6 , since the camera is located in the positive direction of the y-axis and shoots downward, the first to fourth models 611 to 641 corresponding to the observation space can be presented as a bird's-eye view.
在计算模块获取第一模型611的中心点在观察空间中的中心坐标V3之后,计算模块可以根据游戏应用下发的第一模型611对应的P矩阵,将第一模型611的中心点在观察空间中的中心坐标V3,转换为裁剪空间中的坐标,得到中心坐标V4。该中心坐标V4为第一模型的中心点在裁剪空间中的裁剪坐标。如图6所示,在第一模型611转换至裁剪空间的坐标后,可以看到第二模型621、第三模型631以及第四模型641在裁剪空间中的位置。After the calculation module obtains the center coordinate V3 of the center point of the first model 611 in the observation space, the calculation module can calculate the center point of the first model 611 in the observation space according to the P matrix corresponding to the first model 611 issued by the game application. The center coordinate V3 in is converted to the coordinate in the clipping space to obtain the center coordinate V4. The center coordinate V4 is the clipping coordinate of the center point of the first model in the clipping space. As shown in FIG. 6 , after the first model 611 is converted to the coordinates of the clipping space, the positions of the second model 621 , the third model 631 and the fourth model 641 in the clipping space can be seen.
通过上述MVP矩阵的变换(即M矩阵变换,V矩阵变换,以及P矩阵变换),电子设备就能够获取在显示器上显示的各个模型的中心点的坐标(即裁剪坐标)。接着,电子设备还可以将裁剪坐标变换为屏幕坐标,比如,使用视口变换(Viewport Transform)将位于-1.0到1.0范围的中心坐标V4变换到由glViewport指令所定义的坐标范围内的坐标,得到中心坐标V5。中心坐标V5即为第一图像的中心点投影至电子设备屏幕上的屏幕坐标。最后变换出来的中心坐标V5即第一模型的中心位置。该中心坐标V5将会送到光栅器,进而获取与各个像素对应的显示数据。基于这些显示数据,电子设备就可以控制显示器进行对应的显示。如图6所示,第一模型611显示在显示器上为物体61,第一模型611的中心坐标V5对应物体61中心的坐标P1。Through the above-mentioned MVP matrix transformation (ie, M matrix transformation, V matrix transformation, and P matrix transformation), the electronic device can obtain the coordinates of the center points of each model displayed on the display (ie, cropping coordinates). Then, the electronic device can also transform the cropping coordinates into screen coordinates. For example, use the viewport transformation (Viewport Transform) to transform the center coordinate V4 located in the range of -1.0 to 1.0 to the coordinates within the coordinate range defined by the glViewport command, and obtain Center coordinate V5. The center coordinate V5 is the screen coordinate of the center point of the first image projected onto the screen of the electronic device. The finally transformed center coordinate V5 is the center position of the first model. The center coordinate V5 will be sent to the rasterizer to obtain display data corresponding to each pixel. Based on these display data, the electronic device can control the display to perform corresponding display. As shown in FIG. 6 , the first model 611 is displayed as the object 61 on the display, and the center coordinate V5 of the first model 611 corresponds to the coordinate P1 of the center of the object 61 .
类似的,在游戏应用下发了在第一图像60中的对第二模型621至第四模型641的渲染指令流的情况下,通过上述MVP变换和视口变换,电子设备还可以获取第二模型至第四模型各自的中心点在屏幕中的屏幕坐标,第二模型621至第四模型641显示在显示器上为物体62至物体64,第二模型至第四模型的中心位置分别对应物体62中心的坐标P2、物体63中心的坐标P3以及物体64中心的坐标P4。在一些实施例中,计算模块hook图形绘制相关的指令,以在该指令调用GPU驱动之前执行模型的中心位置计算。如图5所示,拦截模块还拦截DrawElements指令,以在DrawElements指令调用GPU驱动之前,通过计算模块计算出第一模型的中心位置。Similarly, when the game application issues the rendering instruction stream for the second model 621 to the fourth model 641 in the first image 60, through the above-mentioned MVP transformation and viewport transformation, the electronic device can also obtain the second The screen coordinates of the respective center points of the model to the fourth model on the screen. The second model 621 to the fourth model 641 are displayed on the display as objects 62 to 64. The center positions of the second model to the fourth model respectively correspond to the object 62. The coordinates P2 of the center, the coordinates P3 of the center of the object 63 , and the coordinates P4 of the center of the object 64 . In some embodiments, the calculation module hooks instructions related to graphics drawing to perform calculation of the center position of the model before the instructions call the GPU driver. As shown in Figure 5, the interception module also intercepts the DrawElements instruction to calculate the center position of the first model through the calculation module before the DrawElements instruction calls the GPU driver.
在另一些实施例中,拦截模块拦截到特定指令(如第一特定指令)相关的数据后,将所拦截到的数据存储至存储器,并存储一个状态数据。该状态数据用于指示拦截模块所拦截的数据的相关状态信息。以第一特定指令为例,状态数据为“ok”,则指示拦截模块拦截到第一特定指令中相关的数据,如顶点数据和MVP矩阵,并且所拦截的数据已存储至存储器。当计算模块从存储器中读取到状态数据为“ok”,则计算模块可以继续从存储器中读取拦截模块所拦截的顶点数据和MVP矩阵。当计算模块从存储器中读取到状态数据不是“ok”,则计算模块不从存储器中读取拦截模块所拦截的数据。In other embodiments, after intercepting data related to a specific instruction (such as a first specific instruction), the interception module stores the intercepted data into the memory and stores a state data. This status data is used to indicate status information related to the data intercepted by the interception module. Taking the first specific instruction as an example, if the status data is "ok", it indicates that the interception module has intercepted relevant data in the first specific instruction, such as vertex data and MVP matrix, and the intercepted data has been stored in the memory. When the computing module reads the status data as "ok" from the memory, the computing module can continue to read the vertex data and MVP matrix intercepted by the interception module from the memory. When the computing module reads the status data from the memory that is not "ok", the computing module does not read the data intercepted by the interception module from the memory.
在另一些实施例中,拦截模块可以在DrawElements指令调用GPU驱动之前,触发计算模块从存储器中获取状态数据。当状态数据为“ok”时,计算模块从存储器中获取拦截模块所拦截到的数据。In other embodiments, the interception module can trigger the computing module to obtain status data from the memory before the DrawElements instruction calls the GPU driver. When the status data is "ok", the computing module obtains the data intercepted by the interception module from the memory.
可以理解的是,在本申请的不同实现中,计算模块计算各个模型的中心位置的触发机制可以是不同的。只要在向GPU下发对应的drawelement之前,确定模块能够知晓该drawelement对应的中心位置即可。比如,在本示例中,计算模块对各个模型的中心位置的计算,可以是由拦截模块拦截到drawelement触发的。It can be understood that in different implementations of the present application, the triggering mechanism for the calculation module to calculate the center position of each model may be different. As long as the module can know the center position corresponding to the drawelement before sending the corresponding drawelement to the GPU. For example, in this example, the calculation module's calculation of the center position of each model can be triggered by the interception module intercepting drawelement.
步骤S44,计算模块向确定模块发送第一模型的中心位置。Step S44: The calculation module sends the center position of the first model to the determination module.
如图6所述示例,电子设备确定中心位置为屏幕坐标,计算模块将计算得到的中心坐标V5作为第一模型的中心位置,并将中心坐标V5传输至确定模块。可以理解,当电子设备确定中心位置为裁剪坐标时,则计算模块将计算得到的中心坐标V4作为第一模型的中心位置,并将中心坐标V4传输至确定模块。As shown in the example shown in Figure 6, the electronic device determines the center position as the screen coordinates, the calculation module uses the calculated center coordinate V5 as the center position of the first model, and transmits the center coordinate V5 to the determination module. It can be understood that when the electronic device determines that the center position is the cropping coordinate, the calculation module uses the calculated center coordinate V4 as the center position of the first model, and transmits the center coordinate V4 to the determination module.
在本申请实施例中,电子设备在进行图像的渲染过程中,除了需要确定各个模型的顶点坐标之外,还需要对当前第一图像中的各个像素进行着色,即确定各个像素的颜色数据。从而根据各个像素的颜色数据,控制显示器在对应的像素位置进行对应颜色的显示。In this embodiment of the present application, during the image rendering process, in addition to determining the vertex coordinates of each model, the electronic device also needs to color each pixel in the current first image, that is, determine the color data of each pixel. Thus, according to the color data of each pixel, the display is controlled to display the corresponding color at the corresponding pixel position.
在本申请实施例中,在确定第一图像中各个像素的颜色数据时,是以第一图像中的模型为单位,决策模型所处区域的着色速率。计算模块将计算得到的第一模型的中心位置发送至确定模块,以使得确定模块根据第一模型的中心位置决策第一模型的着色速率。相应地,计算模块还可以将第一图像中的第二模型的中心位置发送至确定模块,以使得确定模块根据第二模型的中心位置决策该第二模型的着色速率。In the embodiment of the present application, when determining the color data of each pixel in the first image, the coloring rate of the area where the model is located is determined based on the model in the first image. The calculation module sends the calculated center position of the first model to the determination module, so that the determination module decides the shading rate of the first model according to the center position of the first model. Correspondingly, the calculation module may also send the center position of the second model in the first image to the determination module, so that the determination module determines the shading rate of the second model based on the center position of the second model.
步骤S45,确定模块根据第一模型的中心位置确定第一模型的着色速率。Step S45: The determining module determines the coloring rate of the first model according to the center position of the first model.
在本申请实施例中,确定模块根据第一模型的中心位置与第一图像的目标区域获取第一距离,并根据第一距离确定第一模型对应的着色速率。其中,第一距离越小,也即第一模型的中心位置与目标区域越接近,第一模型的着色速率越高。相应地,第一距离越大,也即第一模型的中心位置越远离目标区域,第一模型的着色速率越低。第一模型的着色速率低于或等于目标区域的着色速率。In this embodiment of the present application, the determination module obtains the first distance based on the center position of the first model and the target area of the first image, and determines the shading rate corresponding to the first model based on the first distance. Wherein, the smaller the first distance is, that is, the closer the center position of the first model is to the target area, the higher the shading rate of the first model is. Correspondingly, the larger the first distance is, that is, the further away the center position of the first model is from the target area, the lower the shading rate of the first model is. The shading rate of the first model is lower than or equal to the shading rate of the target area.
在本申请实施例中,第一图像的目标区域可以为第一图像的中心区域,还可以为第一图像中目标模型所处区域,如玩家操控的游戏角色所处区域。在另一些实施例中,可以通过对用户的点击、触摸、或悬停选择行为进行挖掘来确定用户对第一图像的关注点,进而将用户对第一图像的关注点所在区域确定为目标区域,本申请实施例对第一图像的目标区域的设置方式不作具体限定。In this embodiment of the present application, the target area of the first image may be the center area of the first image, or may be the area where the target model is located in the first image, such as the area where the game character controlled by the player is located. In other embodiments, the user's focus on the first image can be determined by mining the user's click, touch, or hover selection behaviors, and then the area where the user's focus on the first image is located is determined as the target area. , the embodiment of the present application does not specifically limit the setting method of the target area of the first image.
在本申请实施例中,第一模型的目标区域所对应的坐标可以为:在观察空间或裁剪空间中,第一图像中的目标区域的坐标,也即该目标区域的坐标可以为观察坐标、裁剪坐标或屏幕坐标。In the embodiment of the present application, the coordinates corresponding to the target area of the first model may be: in the observation space or the cropping space, the coordinates of the target area in the first image, that is, the coordinates of the target area may be the observation coordinates, Clipping coordinates or screen coordinates.
在本申请实施例中,第一距离为在观察空间或者裁剪空间中,第一模型的中心位置与目标区域之间的距离,而第一模型的中心位置与目标区域之间的距离可以为第一模型的中心点与目标区域的中心点的距离,还可以为第一模型的中心位置与目标区域边缘之间的距离,该目标区域边缘可以为目标区域边缘中距离第一模型最近的边缘处。第一模型的中心位置与目标区域之间的距离的定义可以根据实际情况设置,本申请实施例对此不作具体限定。In the embodiment of the present application, the first distance is the distance between the center position of the first model and the target area in the observation space or the clipping space, and the distance between the center position of the first model and the target area may be The distance between the center point of a model and the center point of the target area can also be the distance between the center position of the first model and the edge of the target area. The edge of the target area can be the edge closest to the first model among the edges of the target area. . The definition of the distance between the center position of the first model and the target area can be set according to the actual situation, and the embodiment of the present application does not specifically limit this.
在获取第一距离时,以同一空间或同一类坐标比较中心位置与目标区域之间的距离。以第一距离为第一模型的中心点与目标区域的中心点的距离为例,则获取目标区域的中心点在裁剪空间下的裁剪坐标A,并获取第一模型的中心点在裁剪空间下的裁剪坐标B,计算裁剪坐标A和裁剪坐标B之间的距离得到第一距离。When obtaining the first distance, compare the distance between the central position and the target area using the same space or the same type of coordinates. Taking the first distance as the distance between the center point of the first model and the center point of the target area as an example, obtain the clipping coordinate A of the center point of the target area in the clipping space, and obtain the center point of the first model in the clipping space. The cropping coordinate B is calculated as the distance between the cropping coordinate A and the cropping coordinate B to obtain the first distance.
在本申请实施例中,确定模块可以预先设置距离与着色速率的对应关系,比如根据不同的距离范围设置不同的着色速率。示例性地,对应关系如下表3所示:In this embodiment of the present application, the determination module may preset the corresponding relationship between distance and coloring rate, such as setting different coloring rates according to different distance ranges. For example, the corresponding relationship is as shown in Table 3 below:
表3table 3
其中,当第一距离位于第一距离范围内时,指示第一模型的中心位置位于目标区域内,此时不需要使用可变速率着色机制,确定模块可以根据表3确定当前第一模型使用1X1着色速率。也即对于中心位置位于目标区域的模型,其对应的着色速率为1X1。当第一距离位于第二距离范围内时,指示第一模型未位于目标区域内,此时需要使用可变速率着色机制,确定模块根据表3可以确定当前第一模型使用1X2着色速率。当第一距离位于第三距离范围内时,指示第一模型位于第一图像的边缘区域,此时需要使用可变速率着色机制,确定模块根据表3可以确定当前第一模型使用2X2着色速率。Among them, when the first distance is within the first distance range, it indicates that the center position of the first model is within the target area. At this time, there is no need to use the variable rate shading mechanism. The determination module can determine that the current first model uses 1X1 according to Table 3. Shading rate. That is, for a model whose center is located in the target area, its corresponding shading rate is 1X1. When the first distance is within the second distance range, it indicates that the first model is not located within the target area. At this time, a variable rate shading mechanism needs to be used. The determination module can determine that the current first model uses a 1X2 shading rate according to Table 3. When the first distance is within the third distance range, it indicates that the first model is located in the edge area of the first image. At this time, a variable rate shading mechanism needs to be used. The determination module can determine that the current first model uses a 2X2 shading rate according to Table 3.
示例性地,第一距离范围如可以为大于或等于1cm且小于或等于3cm,第二距离范围可以为大于3cm且小于或等于5cm,第三距离可以为大于5cm且小于第一图像的边缘。第一距离范围、第二距离范围以及第三距离的范围可以根据第一图像的大小、显示器的相关参数设置,在此不作具体限定。For example, the first distance range may be greater than or equal to 1 cm and less than or equal to 3 cm, the second distance range may be greater than 3 cm and less than or equal to 5 cm, and the third distance may be greater than 5 cm and less than the edge of the first image. The first distance range, the second distance range, and the third distance range can be set according to the size of the first image and relevant parameters of the display, and are not specifically limited here.
可以看到,第一距离越大,则其对应的着色速率越低,对应降低着色过程中的功耗开销。相应的,第一距离越小,则着色速率越高,对应的着色效果越清晰。It can be seen that the larger the first distance is, the lower the corresponding shading rate is, which correspondingly reduces the power consumption overhead in the shading process. Correspondingly, the smaller the first distance is, the higher the coloring rate is and the clearer the corresponding coloring effect is.
需要说明的是,上述表3所示的距离与着色速率的对应关系仅为一种示例。在本申请的另一些实施例中,距离与着色速率的对应关系也可以是不同于表3所示的对应关系,该对应关系的设置可以根据具体的应用程序以及实施过程中所应用的场景灵活调整。It should be noted that the corresponding relationship between distance and coloring rate shown in Table 3 above is only an example. In other embodiments of the present application, the corresponding relationship between distance and shading rate can also be different from the corresponding relationship shown in Table 3. The setting of the corresponding relationship can be flexibly based on the specific application and the scenarios used in the implementation process. Adjustment.
以上述表3为例,如图6所示,以第一图像60的中心区域为目标区域,边框601所围起来的区域即为目标区域,该目标区域对应第一距离范围。也即当图像中模型的中心位置在边框601所围起来的区域内,则该模型的中心位置与目标区域的第一距离在第一距离范围内。Taking the above Table 3 as an example, as shown in FIG. 6 , the central area of the first image 60 is the target area, the area enclosed by the frame 601 is the target area, and the target area corresponds to the first distance range. That is, when the center position of the model in the image is within the area enclosed by the border 601, the first distance between the center position of the model and the target area is within the first distance range.
在边框602所围起来的区域内,除去目标区域之外的区域对应第二距离范围。也即当图像中模型的中心位置在由边框601与边框602所围起来的环形区域内,则该模型的中心位置与目标区域的第一距离在第二距离范围内。Within the area enclosed by the frame 602, the area except the target area corresponds to the second distance range. That is, when the center position of the model in the image is within the annular area enclosed by the frame 601 and the frame 602, the first distance between the center position of the model and the target area is within the second distance range.
边框603为第一图像60的边缘,在边框603所围起来的区域内,除去边框602所围起来的区域之外的区域对应第三距离范围。也即当图像中模型的中心位置在由边框602与边框603所围起来的环形区域内,则该模型的中心位置与目标区域的第一距离在第三距离范围内。The frame 603 is the edge of the first image 60 . Within the area enclosed by the frame 603 , the area other than the area enclosed by the frame 602 corresponds to the third distance range. That is, when the center position of the model in the image is within the annular area enclosed by the frame 602 and the frame 603, the first distance between the center position of the model and the target area is within the third distance range.
在转换为屏幕坐标下,第一物体61的中心位置P1和第二物体62的中心位置P2均位于目标区域内,由此第一物体61和第二物体62的着色速率为第一距离范围对应的着色速率1X1。第三物体63的中心位置P3位于目标区域之外,且在边框602内,则第三物体63的着色速率为第二距离范围对应的着色速率1X2。第四物体64的中心位置P4位于目标区域之外,且在边框603内,则第四物体64的着色速率为第三距离范围对应的着色速率2X2。When converted into screen coordinates, the center position P1 of the first object 61 and the center position P2 of the second object 62 are both located in the target area, so the shading rates of the first object 61 and the second object 62 correspond to the first distance range. The shading rate is 1X1. The center position P3 of the third object 63 is located outside the target area and within the border 602, then the coloring rate of the third object 63 is the coloring rate 1X2 corresponding to the second distance range. The center position P4 of the fourth object 64 is located outside the target area and within the border 603, then the coloring rate of the fourth object 64 is the coloring rate 2X2 corresponding to the third distance range.
步骤S46,确定模块向图形库输出对应的调用指令,以调用与第一模型的着色速率对应的可变速率着色API。Step S46: The determination module outputs the corresponding calling instruction to the graphics library to call the variable rate shading API corresponding to the shading rate of the first model.
在本申请实施例中,确定模块根据上述方案确定第一模型的着色速率之后,可以调用图形库中与第一模型的着色速率对应的可变速率着色API。确定模块向图形库输出对应的调用指令,以调用与第一模型的着色速率对应的可变速率着色API。In the embodiment of the present application, after the determination module determines the shading rate of the first model according to the above solution, the variable rate shading API corresponding to the shading rate of the first model in the graphics library can be called. The determining module outputs a corresponding calling instruction to the graphics library to call the variable rate shading API corresponding to the shading rate of the first model.
示例性地,以着色速率1X1对应第一可变速率着色API,着色速率1X2对应第二可变速率着色API为例,确定模块获得第一模型与目标区域之间的第一距离,第一距离属于第一距离范围,确定模块根据第一距离确定第一模型的着色速率为1X1。确定模块可以确定执行第一模型的Drawcall中包括的drawelement时的着色速率为1X1,确定模块向图形库输出调用指令,该调用指令指示调用与着色速率1X1对应的第一可变速率着色API。确定模块获得第二模型与目标区域之间的第二距离,第二距离属于第二距离范围,确定模块根据第二距离确定第二模型的着色速率为1X2。确定模块可以确定执行第二模型的Drawcall中包括的drawelement时的着色速率为1X2,确定模块向图形库输出调用指令,该调用指令指示调用与着色速率1X2对应的第二可变速率着色API。For example, taking the shading rate 1X1 corresponding to the first variable rate shading API and the shading rate 1X2 corresponding to the second variable rate shading API as an example, the determination module obtains the first distance between the first model and the target area, the first distance It belongs to the first distance range, and the determination module determines that the shading rate of the first model is 1X1 based on the first distance. The determining module may determine that the shading rate when executing the drawelement included in the Drawcall of the first model is 1X1, and the determining module outputs a calling instruction to the graphics library, which instructs to call the first variable rate shading API corresponding to the shading rate 1X1. The determination module obtains the second distance between the second model and the target area, the second distance belongs to the second distance range, and the determination module determines the shading rate of the second model to be 1X2 based on the second distance. The determination module may determine that the shading rate when executing the drawelement included in the Drawcall of the second model is 1X2, and the determination module outputs a calling instruction to the graphics library, which instructs to call the second variable rate shading API corresponding to the shading rate 1X2.
作为一种示例,确定模块可以将调用指令与绘制指令下发至图形库,以便于图形库可以向GPU发送相应的模型渲染指令。绘制指令可以为OpenGL中的glDrawElecments指令或者是DirectX中的DrawIndexedPrimitive指令。请一并参阅图5,确定模块可以将该调用与第一模型对应的着色速率对应的可变速率着色API的调用指令与当前Drawcall中的drawelement下发给图形库。As an example, the determination module can issue the calling instructions and drawing instructions to the graphics library, so that the graphics library can send corresponding model rendering instructions to the GPU. The drawing instruction can be the glDrawElecments instruction in OpenGL or the DrawIndexedPrimitive instruction in DirectX. Please refer to Figure 5 together. The determination module can send the calling instruction of the variable rate shading API corresponding to the shading rate corresponding to the first model and the drawelement in the current Drawcall to the graphics library.
步骤S47,图形库响应于调用指令调用对应的可变速率着色API,并向图形处理器发送第一模型渲染指令。Step S47: The graphics library calls the corresponding variable rate shading API in response to the calling instruction, and sends the first model rendering instruction to the graphics processor.
以确定模块确定第一模型对应的着色速率为2X2为例,那么,经过图形库之后,传递给GPU的第一模型渲染指令就可以包括:glVRS(2X2)和glDrawElements。其中,glVRS(2X2)用于指示使用2×2的着色速率对当前模型进行着色操作。也即第一模型渲染指令用于指示在调用glDrawElements之前,使能着色glVRS(2X2)。For example, if the module determines that the shading rate corresponding to the first model is 2X2, then, after passing through the graphics library, the first model rendering instructions passed to the GPU can include: glVRS (2X2) and glDrawElements. Among them, glVRS(2X2) is used to indicate that the current model is shaded using a shading rate of 2×2. That is, the first model rendering instruction is used to indicate that shading glVRS (2X2) is enabled before calling glDrawElements.
这样,以Drawcall为单位,电子设备就可以根据第一模型的中心位置,采用对应的着色速率对第一模型进行着色,从而达到合理分配着色速率,降低着色操作的功耗开销,同时提升着色效果的目的。In this way, using Drawcall as the unit, the electronic device can color the first model using the corresponding coloring rate according to the center position of the first model, thereby achieving a reasonable distribution of the coloring rate, reducing the power consumption of the coloring operation, and at the same time improving the coloring effect. the goal of.
步骤S48,图形处理器响应于第一模型渲染指令,根据第一模型对应的着色速率对第一模型进行着色操作。In step S48, the graphics processor responds to the first model rendering instruction and performs a shading operation on the first model according to the shading rate corresponding to the first model.
其中,第一模型渲染指令可以携带第一模型对应的可变着色速率API对应的代码。GPU响应第一模型渲染指令,使用对应的参数指示的着色速率执行Drawelement。如上述示例,第一模型对应的可变着色速率API对应的代码包括glVRS(2X2)。The first model rendering instruction may carry code corresponding to the variable shading rate API corresponding to the first model. The GPU responds to the first model rendering command and executes Drawelement using the shading rate indicated by the corresponding parameter. As in the above example, the code corresponding to the variable shading rate API corresponding to the first model includes glVRS (2X2).
图形处理器响应于第一模型渲染指令进行着色操作的具体内容可以参考相关技术,在此不再赘述。For the specific content of the shading operation performed by the graphics processor in response to the first model rendering instruction, reference can be made to related technologies and will not be described again here.
在本申请实施例中,以用户关注点为核心,基于用户关注点确定目标区域,对用户关注点(目标区域)外的画面内容进行降负载操作(即降低着色速率),对于目标区域的内容可以保证其着色效果,由此既保障了画质体验又提升了电子设备的性能。通过在电子设备的操作系统上进行改进,由拦截模块拦截应用程序下发的渲染指令流中的特定指令,基于该特定指令可以快速准确地获取第一图像中第一模型的中心位置,基于中心位置可以快速准确描述第一模型与目标区域的关系。进而基于第一模型与目标区域的关系合理地为第一模型设置对应的着色速率。In the embodiment of this application, the user's focus is taken as the core, the target area is determined based on the user's focus, and the load reduction operation (that is, the coloring rate is reduced) is performed on the screen content outside the user's focus (target area). For the content in the target area The coloring effect can be guaranteed, thus ensuring the image quality experience and improving the performance of electronic devices. By improving the operating system of the electronic device, the interception module intercepts specific instructions in the rendering instruction stream issued by the application. Based on the specific instructions, the center position of the first model in the first image can be quickly and accurately obtained. Based on the center Position can quickly and accurately describe the relationship between the first model and the target area. Then, a corresponding shading rate is reasonably set for the first model based on the relationship between the first model and the target area.
请参阅图7,图7为本申请实施例提供的另一种图像渲染方法流程。图7与图4的区别在于:拦截模块所拦截的特定指令还用于获取第一模型的类别,具体地,拦截模块还拦截第二特定指令,以基于第二特定指令获取能用于识别模型所属类别的模型信息。应用程序框架层还包括识别模块,确定模块基于计算模块所计算的第一模型的中心位置与识别模块所识别到的第一模型的类别确定第一模型的着色速率。Please refer to FIG. 7 , which is a flowchart of another image rendering method provided by an embodiment of the present application. The difference between Figure 7 and Figure 4 is that the specific instructions intercepted by the interception module are also used to obtain the category of the first model. Specifically, the interception module also intercepts the second specific instructions to obtain the model that can be used to identify the model based on the second specific instructions. Model information of the category to which it belongs. The application framework layer also includes an identification module, and the determination module determines the shading rate of the first model based on the center position of the first model calculated by the calculation module and the category of the first model identified by the identification module.
步骤S700,游戏应用下发渲染指令流。Step S700: The game application issues a rendering instruction stream.
步骤S700可以参考图4中的相关内容。For step S700, please refer to the relevant content in Figure 4.
步骤S701,拦截模块拦截渲染指令流中的第一特定指令和第二特定指令,以获得第一模型各个顶点的顶点数据、第一模型对应的MVP矩阵和第一模型的模型信息。Step S701: The interception module intercepts the first specific instruction and the second specific instruction in the rendering instruction stream to obtain vertex data of each vertex of the first model, the MVP matrix corresponding to the first model, and model information of the first model.
其中,第一特定指令、顶点数据和MVP矩阵的相关内容可以参考上述,在此不再赘述。Among them, the relevant contents of the first specific instruction, vertex data and MVP matrix can be referred to the above, and will not be described again here.
在本申请实施例中,上述特定指令包括第二特定指令,第二特定指令可以为携带类别参数的指令。类别参数可以为用于识别模型所属类别的任何参数,例如类别参数包括指示特定物体的标志性特征的参数,以特定物体如烟雾、枪火、浪花等半透明粒子为例,其对应的渲染指令中携带增加半透明粒子的渲染特效参数。在另一些实施例中,类别参数还可以包括尺寸大小、贴图信息、着色器中坐标变量和数据buffer特征等。贴图信息可以包括地板模型贴图、建筑模型贴图等。In this embodiment of the present application, the above-mentioned specific instructions include a second specific instruction, and the second specific instruction may be an instruction carrying a category parameter. Category parameters can be any parameters used to identify the category to which the model belongs. For example, category parameters include parameters that indicate the iconic characteristics of specific objects. Take specific objects such as smoke, gunfire, spray and other translucent particles as an example, and their corresponding rendering instructions. It carries the rendering effect parameters for adding translucent particles. In other embodiments, category parameters may also include size, texture information, coordinate variables in the shader, data buffer characteristics, etc. Texture information can include floor model textures, building model textures, etc.
在本申请实施例中,可以划分模型所属类别包括但不限于:半透明粒子、人物模型、建筑模型等。In this embodiment of the present application, the categories to which models can be classified include but are not limited to: translucent particles, character models, architectural models, etc.
示例性地,以第一模型为烟雾,其对应指令段A,指令段A以glEnable()指令为开头,以glDisable()指令为结尾。glEnable指令使能(enable)颜色混合状态,即glEnable指令指示电子设备开始进行半透明粒子的渲染。glDisable指令指示电子设备彻底关闭当前针对半透明粒子的颜色混合操作。拦截模块拦截到glEnable指令和glDisable指令时,则可以获取第二特定指令包括glEnable()指令和glDisable()指令。拦截模块基于glEnable()指令和glDisable()指令可以获得的模型信息为半透明粒子的渲染特效。For example, the first model is smoke, which corresponds to the instruction segment A. The instruction segment A starts with the glEnable() instruction and ends with the glDisable() instruction. The glEnable instruction enables the color mixing state, that is, the glEnable instruction instructs the electronic device to start rendering translucent particles. The glDisable directive instructs the electronics to completely turn off the current color mixing operation for translucent particles. When the interception module intercepts the glEnable instruction and glDisable instruction, it can obtain the second specific instruction including the glEnable() instruction and glDisable() instruction. The model information that the interception module can obtain based on the glEnable() and glDisable() instructions is the rendering effect of translucent particles.
在另一些实施例中,以第一模型为人物模型,拦截模块拦截第二特定指令以获得的模型信息包括但不限于:人体骨骼节点坐标信息、人脸皮肤贴图信息、发型贴图信息等。In other embodiments, the first model is used as a character model, and the interception module intercepts the second specific instruction to obtain model information including but not limited to: human skeleton node coordinate information, facial skin map information, hairstyle map information, etc.
在一些实施例中,第一特定指令与第二特定指令可以为同一指令。如,可以通过上述第一指令获取顶点数据,进而可以获得模型的顶点数量。也可以基于该顶点数量确定模型信息,如模型的大小,进而根据模型的大小确定模型的类别,如建筑模型的模型大小一般大于草丛模型。In some embodiments, the first specific instruction and the second specific instruction may be the same instruction. For example, the vertex data can be obtained through the above-mentioned first instruction, and then the number of vertices of the model can be obtained. Model information, such as the size of the model, can also be determined based on the number of vertices, and then the model category is determined based on the size of the model. For example, the model size of an architectural model is generally larger than a grass model.
步骤S702,拦截模块将获得的顶点数据、MVP矩阵和模型信息存储至存储器。Step S702: The interception module stores the obtained vertex data, MVP matrix and model information into the memory.
步骤S703,计算模块获取顶点数据和MVP矩阵,并根据顶点数据和MVP矩阵计算出第一模型的中心位置。Step S703: The calculation module obtains the vertex data and MVP matrix, and calculates the center position of the first model based on the vertex data and MVP matrix.
步骤S702至步骤S703可以参考图4中的相关内容。For steps S702 to S703, please refer to the relevant content in Figure 4 .
步骤S704,识别模块获取模型信息,并根据模型信息识别第一模型的类别。Step S704: The identification module obtains model information and identifies the category of the first model based on the model information.
在本申请实施例中,识别模块从存储器中获取拦截模块所拦截的第一模型的模型信息,识别模块可以离线分析第一模型的模型信息,进而确定第一模型的类别。In this embodiment of the present application, the recognition module obtains the model information of the first model intercepted by the interception module from the memory. The recognition module can analyze the model information of the first model offline, and then determine the category of the first model.
在一些实施例中,电子设备可以预先存储特定物体类别对应的模型信息,如存储人物模型对应的模型信息A,存储透明粒子模型对应的模型信息B。识别模块将获得的第一模型的模型信息与上述模型信息A、模型信息B进行匹配,以确定第一模型的类别是否属于特定物体类别。若属于,则确定第一模型的类别是属于人物模型还是透明粒子模型。In some embodiments, the electronic device can pre-store model information corresponding to a specific object category, such as storing model information A corresponding to a character model, and storing model information B corresponding to a transparent particle model. The identification module matches the obtained model information of the first model with the above-mentioned model information A and model information B to determine whether the category of the first model belongs to a specific object category. If so, determine whether the category of the first model belongs to a character model or a transparent particle model.
识别模块从存储器中获取模型信息的触发机制可以参考上述图4中相关内容,如参考图4中计算模块计算第一模型的中心位置的触发机制,在此不再赘述。The trigger mechanism for the recognition module to obtain model information from the memory can refer to the relevant content in Figure 4 above. For example, refer to the trigger mechanism for the calculation module to calculate the center position of the first model in Figure 4, which will not be described again here.
步骤S705,计算模块向确定模块发送第一模型的中心位置。Step S705: The calculation module sends the center position of the first model to the determination module.
步骤S705可以参考图4中的相关内容。For step S705, please refer to the relevant content in Figure 4.
步骤S706,识别模块向确定模块发送第一模型的类别。Step S706: The recognition module sends the category of the first model to the determination module.
可以理解,上述步骤S703至步骤S706的执行顺序不作具体限定。如计算模块和识别模块可以同时从存储器中获取对应的数据,或计算模块和识别模块可以同时将处理后的数据发送至确定模块。It can be understood that the execution order of the above steps S703 to S706 is not specifically limited. For example, the calculation module and the recognition module can obtain corresponding data from the memory at the same time, or the calculation module and the recognition module can send the processed data to the determination module at the same time.
步骤S707,确定模块根据第一模型的中心位置和类别确定第一模型的着色速率。Step S707: The determining module determines the coloring rate of the first model according to the center position and category of the first model.
在本申请实施例中,确定模块获取应用程序对应的特定物体类别,当第一模型的类别为特定物体类别时,将特定物体类别对应的着色速率作为第一模型对应的着色速率,当第一模型的类别不是特定物体类别时,根据第一距离确定第一模型对应的着色速率。In the embodiment of the present application, the determination module obtains the specific object category corresponding to the application program. When the category of the first model is the specific object category, the coloring rate corresponding to the specific object category is used as the coloring rate corresponding to the first model. When the first model When the category of the model is not a specific object category, the shading rate corresponding to the first model is determined based on the first distance.
电子设备的存储器可以预先存储各个应用程序对应的特定物体类别,以及各个特定物体类别对应的着色速率。其中,各个应用程序员所对应的特定物体类别、特定物体类别对应的着色速率可以根据实际情况设置,本申请实施例对此不作具体限定。The memory of the electronic device can pre-store specific object categories corresponding to each application program, and the coloring rate corresponding to each specific object category. Among them, the specific object category corresponding to each application programmer and the coloring rate corresponding to the specific object category can be set according to the actual situation, which is not specifically limited in the embodiment of the present application.
示例性地,以第一游戏应用中对应的特定物体类别包括人物模型和半透明粒子模型,人物模型对应的着色速率为1X2,半透明粒子模型对应的着色速率为2X2为例。第一游戏应用指示渲染第一模型,当第一模型为人物模型时,确定第一模型的着色速率为1X2。当第一模型为半透明粒子模型时,确定第一模型的着色速率为2X2。当第一模型为草丛模型时,即第一模型的类别不属于第一游戏应用对应的特定物体类别,确定模块基于第一模型的中心位置确定第一模型的着色速率。For example, taking the corresponding specific object categories in the first game application as including character models and translucent particle models, the shading rate corresponding to the character model is 1X2, and the shading rate corresponding to the translucent particle model is 2X2. The first game application instructs to render the first model. When the first model is a character model, the shading rate of the first model is determined to be 1X2. When the first model is a translucent particle model, the shading rate of the first model is determined to be 2X2. When the first model is a grass model, that is, the category of the first model does not belong to the specific object category corresponding to the first game application, the determining module determines the shading rate of the first model based on the center position of the first model.
在本申请实施例中,可以基于各个应用程序的实际使用为模型确定对应的着色速率,进而在用户使用过程中可以为模型提供个性化的着色速率。如基于第一游戏应用为射击类的游戏,为了提升用户使用体验,可以提高该人物模型对应的着色速率。即使人物模型处于图像边缘(即目标区域之外),也可以提高该人物模型的着色速率。而对于半透明粒子模型其呈现的效果为半透明状态,即使其处于目标区域内,也可以降低其着色速率。In the embodiment of the present application, the corresponding shading rate can be determined for the model based on the actual use of each application, and then a personalized shading rate can be provided for the model during user use. For example, if the first game application is a shooting game, in order to improve the user experience, the coloring rate corresponding to the character model can be increased. The shading rate of the character model can be increased even if the character model is at the edge of the image (i.e. outside the target area). For translucent particle models, the effect is translucent. Even if it is within the target area, its shading rate can be reduced.
步骤S708,确定模块向图形库输出对应的调用指令,以调用与第一模型的着色速率对应的可变速率着色API。Step S708: The determination module outputs the corresponding calling instruction to the graphics library to call the variable rate shading API corresponding to the shading rate of the first model.
步骤S709,图形库响应于调用指令调用对应的可变速率着色API,并向图形处理器发送第一模型渲染指令。Step S709: The graphics library calls the corresponding variable rate shading API in response to the calling instruction, and sends the first model rendering instruction to the graphics processor.
步骤S710,图形处理器响应于第一模型渲染指令,根据第一模型对应的着色速率对第一模型进行着色操作。In step S710, the graphics processor responds to the first model rendering instruction and performs a shading operation on the first model according to the shading rate corresponding to the first model.
步骤S708至步骤S710可以参考图4中的相关内容。For steps S708 to S710, please refer to the relevant content in Figure 4 .
在本申请实施例中,确定模块在确定第一模型的着色速率时,还可以考虑第一模型的类别。可以根据不同应用场景下或不同游戏应用,设置模型类别所对应的着色速率,以此提高用户的使用体验。In this embodiment of the present application, the determination module may also consider the category of the first model when determining the shading rate of the first model. The shading rate corresponding to the model category can be set according to different application scenarios or different game applications to improve the user experience.
在另一些实施例中,在图4和图7中,电子设备根据应用程序的应用类型确定目标区域的范围。示例性地,以第一游戏应用为射击类应用,第二游戏应用的画面呈现整体偏黑暗,亮度区域较小为例,基于该两个游戏的游戏图像所呈现的信息以及游戏类型,可以将第一游戏应用的目标区域范围设置得比第二游戏应用的目标区域范围更大。In other embodiments, in FIGS. 4 and 7 , the electronic device determines the range of the target area according to the application type of the application program. For example, taking the first game application as a shooting application and the second game application as having an overall darker picture with a smaller brightness area, based on the information and game types presented in the game images of the two games, the game can be The target area range of the first game application is set larger than the target area range of the second game application.
在另一些实施例中,在图4和图7中,电子设备可以根据应用程序的类型确定目标区域的范围,然后根据目标区域的范围和第一图像中目标物体的位置确定第一图像中的目标区域,其中目标物体与用户的关注点相关。In other embodiments, in Figures 4 and 7, the electronic device can determine the range of the target area according to the type of the application, and then determine the range of the target area in the first image according to the range of the target area and the position of the target object in the first image. Target area, where the target object is related to the user's focus.
在另一些实施例,在图4和图7中,拦截模块可以拦截第三特定指令,第三特定指令携带中心位置相关参数。当渲染指令流中包括第三特定指令时,则可以直接拦截第三特定指令,以获得第一模型的中心位置。In other embodiments, in FIG. 4 and FIG. 7 , the interception module may intercept the third specific instruction, and the third specific instruction carries center position related parameters. When the rendering instruction stream includes the third specific instruction, the third specific instruction can be directly intercepted to obtain the center position of the first model.
在另一些实施例中,在图4和图7中,当第一模型的着色速率低于目标区域的着色速率时,则图形处理器根据第一模型的着色速率渲染第一模型时,图形处理器根据最高的着色速率和画质增强算法渲染目标区域,并根据第一模型的着色速率渲染第一模型。当目标区域的着色速率已经为最高时,则以该最高着色速率渲染该目标区域,同时使用画质增强算法渲染目标区域。当目标区域的着色速率不是最高时,则以最高着色速率和画质增强算法渲染目标区域。由此可知在功耗持平下,提高目标区域的画质。其中画质增强算法可以基于着色器语言实现。In other embodiments, in Figures 4 and 7, when the shading rate of the first model is lower than the shading rate of the target area, then when the graphics processor renders the first model according to the shading rate of the first model, the graphics processor The processor renders the target area according to the highest shading rate and image quality enhancement algorithm, and renders the first model according to the first model's shading rate. When the shading rate of the target area is already the highest, the target area is rendered at the highest shading rate, and the image quality enhancement algorithm is used to render the target area. When the shading rate of the target area is not the highest, the target area is rendered with the highest shading rate and image quality enhancement algorithm. It can be seen that the image quality of the target area is improved while maintaining the same power consumption. The image quality enhancement algorithm can be implemented based on the shader language.
下述以电子设备为执行主体介绍本申请实施例提供的图像渲染方法。The following uses an electronic device as the execution subject to introduce the image rendering method provided by the embodiment of the present application.
请参阅图8,图8为本申请实施例提供的另一种图像渲染方法流程示意图。Please refer to FIG. 8 , which is a schematic flowchart of another image rendering method provided by an embodiment of the present application.
步骤S81,电子设备安装的应用程序下发渲染指令流,其中渲染指令流用于指示渲染第一图像中的第一模型。Step S81: The application installed on the electronic device issues a rendering instruction stream, where the rendering instruction stream is used to instruct rendering of the first model in the first image.
步骤S82,电子设备拦截渲染指令流中的特定指令。Step S82: The electronic device intercepts specific instructions in the rendering instruction stream.
步骤S83,电子设备根据特定指令获取第一模型的中心位置,其中,中心位置为第一模型的中心点在第一图像中的位置。Step S83: The electronic device obtains the center position of the first model according to the specific instruction, where the center position is the position of the center point of the first model in the first image.
步骤S84,电子设备根据第一模型的中心位置与第一图像的目标区域确定第一模型的着色速率。Step S84: The electronic device determines the coloring rate of the first model based on the center position of the first model and the target area of the first image.
步骤S85,电子设备根据第一模型的着色速率渲染第一模型。Step S85: The electronic device renders the first model according to the shading rate of the first model.
图8中的相关内容可以参考上述图4、7相关内容,在此不再赘述。For the relevant content in Figure 8, please refer to the relevant content in Figures 4 and 7 above, and will not be described again here.
本申请实施例还提供了一种电子设备,该电子设备包括图1所示的硬件与软件。在另一些实施例中,电子设备至少包括:一个或多个处理器和一个或多个存储器。处理器包括中央处理器和图形处理器。一个或多个存储器与一个或多个处理器耦合,一个或多个存储器存储有计算机指令;当一个或多个处理器执行计算机指令时,使得电子设备执行上述图4、图7所示的图像渲染方法。An embodiment of the present application also provides an electronic device, which includes the hardware and software shown in Figure 1 . In other embodiments, the electronic device includes at least one or more processors and one or more memories. Processors include central processing units and graphics processors. One or more memories are coupled to one or more processors, and the one or more memories store computer instructions; when the one or more processors execute the computer instructions, the electronic device executes the images shown in Figures 4 and 7 above. Rendering method.
请参阅图9,图9为本申请实施例提供的一种芯片系统结构示意图。Please refer to FIG. 9 , which is a schematic structural diagram of a chip system provided by an embodiment of the present application.
图9示出了的一种芯片系统1600的组成示意图。该芯片系统1600可以包括:处理器1601和通信接口1602,用于支持相关设备实现上述实施例中所涉及的功能。在一种可能的设计中,芯片系统还包括存储器,用于保存电子设备必要的程序指令和数据。该芯片系统,可以由芯片构成,也可以包含芯片和其他分立器件。需要说明的是,在本申请的一些实现方式中,该通信接口1602也可称为接口电路。Figure 9 shows a schematic diagram of the composition of a chip system 1600. The chip system 1600 may include: a processor 1601 and a communication interface 1602, used to support related devices to implement the functions involved in the above embodiments. In one possible design, the chip system also includes a memory for storing necessary program instructions and data for the electronic device. The chip system may be composed of chips, or may include chips and other discrete devices. It should be noted that in some implementations of this application, the communication interface 1602 may also be called an interface circuit.
需要说明的是,上述方法实施例涉及的各步骤的所有相关内容均可以援引到对应功能模块的功能描述,在此不再赘述。It should be noted that all relevant content of each step involved in the above method embodiment can be quoted from the functional description of the corresponding functional module, and will not be described again here.
本申请实施例还提供了一种计算机程序产品,当该计算机程序产品在计算机上运行时,使得计算机执行上述相关步骤,以实现上述各方法实施例中的图像渲染方法。Embodiments of the present application also provide a computer program product. When the computer program product is run on a computer, it causes the computer to perform the above related steps to implement the image rendering method in the above method embodiments.
本申请实施例还提供一种计算机存储介质,包括计算机指令,当计算机指令在电子设备上运行时,使得电子设备执行如上述实施例的图像渲染方法。Embodiments of the present application also provide a computer storage medium that includes computer instructions. When the computer instructions are run on an electronic device, the electronic device causes the electronic device to execute the image rendering method as in the above embodiment.
其中,本申请实施例提供的电子设备、计算机存储介质、计算机程序产品或芯片系统均用于执行上文所提供的对应的方法,因此,其所能达到的有益效果可参考上文所提供的对应的方法中的有益效果,此处不再赘述。Among them, the electronic devices, computer storage media, computer program products or chip systems provided by the embodiments of the present application are all used to execute the corresponding methods provided above. Therefore, the beneficial effects they can achieve can be referred to the above provided The beneficial effects of the corresponding methods will not be described again here.
通过以上的实施方式的描述,所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,仅以上述各功能模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能模块完成,即将装置的内部结构划分成不同的功能模块,以完成以上描述的全部或者部分功能。Through the above description of the embodiments, those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above functional modules is used as an example. In actual applications, the above functions can be allocated as needed. It is completed by different functional modules, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above.
在本申请所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,该模块或单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个装置,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods, for example, multiple units or components may be combined. Either it can be integrated into another device, or some features can be ignored, or not implemented. On the other hand, the coupling or direct coupling or communication connection between each other shown or discussed may be through some interfaces, and the indirect coupling or communication connection of the devices or units may be in electrical, mechanical or other forms.
该作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是一个物理单元或多个物理单元,即可以位于一个地方,或者也可以分布到多个不同地方。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The unit described as a separate component may or may not be physically separate. The component shown as a unit may be one physical unit or multiple physical units, that is, it may be located in one place, or it may be distributed to multiple different places. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application can be integrated into one processing unit, each unit can exist physically alone, or two or more units can be integrated into one unit. The above integrated units can be implemented in the form of hardware or software functional units.
该集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该软件产品存储在一个存储介质中,包括若干指令用以使得一个设备(可以是单片机,芯片等)或处理器(processor)执行本申请各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solutions of the embodiments of the present application are essentially or contribute to the existing technology, or all or part of the technical solution can be embodied in the form of a software product, and the software product is stored in a storage medium , including several instructions to cause a device (which can be a microcontroller, a chip, etc.) or a processor to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), magnetic disk or optical disk and other media that can store program code. .
以上,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何在本申请揭露的技术范围内的变化或替换,都应涵盖在本申请的保护范围之内。The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application shall be covered by the protection scope of the present application.
Claims (14)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202311005225.1A CN117710180A (en) | 2023-08-09 | 2023-08-09 | Image rendering method and related equipment |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202311005225.1A CN117710180A (en) | 2023-08-09 | 2023-08-09 | Image rendering method and related equipment |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN117710180A true CN117710180A (en) | 2024-03-15 |
Family
ID=90150326
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202311005225.1A Pending CN117710180A (en) | 2023-08-09 | 2023-08-09 | Image rendering method and related equipment |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN117710180A (en) |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN113936089A (en) * | 2021-10-12 | 2022-01-14 | 杭州逗酷软件科技有限公司 | Interface rendering method and device, storage medium and electronic equipment |
| CN114549683A (en) * | 2022-02-25 | 2022-05-27 | Oppo广东移动通信有限公司 | Image rendering method and device and electronic equipment |
| CN115018692A (en) * | 2021-12-17 | 2022-09-06 | 荣耀终端有限公司 | Image rendering method and electronic equipment |
| CN115082609A (en) * | 2022-06-14 | 2022-09-20 | Oppo广东移动通信有限公司 | Image rendering method and device, storage medium and electronic equipment |
| US20220414950A1 (en) * | 2021-06-29 | 2022-12-29 | Advanced Micro Devices, Inc. | Per-pixel variable rate shading controls using stencil data |
-
2023
- 2023-08-09 CN CN202311005225.1A patent/CN117710180A/en active Pending
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US20220414950A1 (en) * | 2021-06-29 | 2022-12-29 | Advanced Micro Devices, Inc. | Per-pixel variable rate shading controls using stencil data |
| CN113936089A (en) * | 2021-10-12 | 2022-01-14 | 杭州逗酷软件科技有限公司 | Interface rendering method and device, storage medium and electronic equipment |
| CN115018692A (en) * | 2021-12-17 | 2022-09-06 | 荣耀终端有限公司 | Image rendering method and electronic equipment |
| CN114549683A (en) * | 2022-02-25 | 2022-05-27 | Oppo广东移动通信有限公司 | Image rendering method and device and electronic equipment |
| CN115082609A (en) * | 2022-06-14 | 2022-09-20 | Oppo广东移动通信有限公司 | Image rendering method and device, storage medium and electronic equipment |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US9928637B1 (en) | Managing rendering targets for graphics processing units | |
| WO2022116759A1 (en) | Image rendering method and apparatus, and computer device and storage medium | |
| US9715750B2 (en) | System and method for layering using tile-based renderers | |
| JP2021516820A (en) | Map rendering methods, equipment, computer equipment and computer programs | |
| CN113112579A (en) | Rendering method, rendering device, electronic equipment and computer-readable storage medium | |
| WO2024027237A1 (en) | Rendering optimization method, and electronic device and computer-readable storage medium | |
| CN111400024B (en) | Resource calling method and device in rendering process and rendering engine | |
| CN112337091B (en) | Man-machine interaction method and device and electronic equipment | |
| US11094036B2 (en) | Task execution on a graphics processor using indirect argument buffers | |
| CN111583379A (en) | Rendering method and device of virtual model, storage medium and electronic equipment | |
| CN114494024B (en) | Image rendering method, device and equipment and storage medium | |
| CN116958390A (en) | Image rendering method, device, equipment, storage medium and program product | |
| CN108269222A (en) | A kind of window rendering intent and terminal | |
| CN113192173B (en) | Image processing method and device of three-dimensional scene and electronic equipment | |
| CN112423111A (en) | Graphic engine and graphic processing method suitable for player | |
| US20250166281A1 (en) | Rendering Method and Apparatus, Device, and Storage Medium | |
| CN115228083A (en) | Resource rendering method and device | |
| CN116051387A (en) | Dynamic image blurring method, terminal device, and computer-readable storage medium | |
| US20200183566A1 (en) | Hybrid image rendering system | |
| CN116912379A (en) | Scene picture rendering method and device, storage medium and electronic equipment | |
| CN117710180A (en) | Image rendering method and related equipment | |
| CN111402375A (en) | Method and device for forming shutter effect and rendering engine | |
| CN117710548B (en) | Image rendering method and related device | |
| CN117112950B (en) | Rendering method, device, terminal and storage medium for objects in electronic map | |
| RU2810701C2 (en) | Hybrid rendering |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| CB02 | Change of applicant information |
Country or region after: China Address after: Unit 3401, unit a, building 6, Shenye Zhongcheng, No. 8089, Hongli West Road, Donghai community, Xiangmihu street, Futian District, Shenzhen, Guangdong 518040 Applicant after: Honor Terminal Co.,Ltd. Address before: 3401, unit a, building 6, Shenye Zhongcheng, No. 8089, Hongli West Road, Donghai community, Xiangmihu street, Futian District, Shenzhen, Guangdong Applicant before: Honor Device Co.,Ltd. Country or region before: China |
|
| CB02 | Change of applicant information |