Color setting method, graphics processing unit and system on chip
By introducing a preset table into the GPU user-space driver, the problem of limited storage space for texture boundary colors is solved, enabling a wider range of color formats and higher precision texture boundary color settings, thus improving user experience and rendering effects.
Patent Information
- Application Number
- CN202511535758.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-24
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2045-10-24
AI Technical Summary
In existing technologies, the storage space for texture boundary colors is limited, which restricts the choice of color format and limits the setting of texture boundary colors, making it impossible to meet the requirements of high precision and multiple formats.
By introducing a preset table in the GPU user-space driver, the storage range of texture boundary colors is expanded. The preset table is used to store colors whose target color format exceeds the number of bits of the sampling descriptor. The first identifier points to the preset table and writes the target color into the second bit field of the sampling descriptor, so that the GPU hardware can query to set the texture boundary color.
It expands the storage format and precision of texture boundary colors, reduces storage space limitations, and improves user experience and rendering quality.
Smart Images

Figure CN121010685A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to a color setting method, a graphics processing unit and a system on chip. BACKGROUND
[0002] Texture boundary filling refers to filling a pre-configured texture boundary color to an uncovered part when a texture used in a 3D texture sampling process cannot cover a 3D graphic surface.
[0003] The texture boundary color is generally configured by a graphics processing unit (GPU) directly, and when a boundary exceeds problem occurs in a rendering process, if a border color mode is selected, the texture boundary color configured in a sampling descriptor will be taken as a filling color of the exceeding part. However, only a boundary color within a certain range can be stored in the sampling descriptor, which limits the selection of the texture boundary color. SUMMARY
[0004] In view of the above problems, the present application is proposed to provide a color setting method which can overcome the above problems or at least partially solve the above problems, and can expand the storage range of the boundary color and increase the selection of the texture boundary color.
[0005] Correspondingly, the present application also provides a color setting device, a graphics processing unit and an electronic system to ensure the implementation and application of the above method.
[0006] In a first aspect, the present application discloses a color setting method applied to a GPU user state drive, and the method comprises the following steps. In a case where a rendering preparation instruction is received, a first bit field of a sampling descriptor is set as a first identifier, the first identifier is used to point to a preset table in a memory, and the preset table is used to store a boundary color whose color format exceeds the bit number of the sampling descriptor. A target color carried in the rendering preparation instruction is written into the preset table. A second identifier of the target color in the preset table is obtained. The second identifier of the target color in the preset table is written into a second bit field of the sampling descriptor, and the sampling descriptor is sent to a GPU hardware, so that the GPU hardware implements texture boundary color setting according to the sampling descriptor.
[0007] In a second aspect, the present application discloses a color setting method applied to a GPU hardware, and the method comprises the following steps. In a case where it is identified that the coverage of the target texture does not match the to-be-rendered subject, a sampling descriptor sent by a GPU user mode driver is searched; A preset table pointed by the sampling descriptor is queried according to a second identifier in the sampling descriptor, and a target color corresponding to the second identifier in the preset table is acquired; The texture boundary color setting of the to-be-rendered subject is implemented according to the target color. In addition, the application embodiment also provides a system on chip and a graphics processing unit.
[0008] The application embodiment has the following advantages: In the application embodiment, the preset table concept is proposed, the preset table is located outside the sampling descriptor and is specifically independently located in the memory, and the target color used to implement the texture boundary color setting is stored in the preset table. Specifically, in a case where a rendering preparation instruction is received, the first bit field of the sampling descriptor is set as the first identifier, and the first identifier is used to point to the preset table; and the target color carried in the rendering preparation instruction is written into the preset table. The second identifier of the target color in the preset table is acquired, and the second identifier is stored in the second bit field of the sampling descriptor; when the GPU hardware performs the texture boundary color setting, the target color in the preset table is searched through the second identifier, so as to complete the texture boundary color setting. In the color setting method proposed in the application, the target color is stored in the preset table outside the sampling descriptor, the storage space in the preset table is larger, and various color formats and high-precision colors with high storage space requirements can be supported; compared with storing the target color in the limited preset area in the sampling descriptor, the limitation on the storage space of the target color is reduced, the format and precision of the target color storage can be expanded, the setting of the texture boundary color can be improved, and the user experience is improved. BRIEF DESCRIPTION OF DRAWINGS
[0009] Figure 1 is a schematic diagram of a color setting method applied to a GPU memory driver provided by the application; Figure 2 is a flowchart of a color setting method provided by the application; Figure 3 is a schematic diagram of a color setting method applied to a GPU hardware provided by the application; Figure 4 is a schematic diagram of a color setting device applied to a GPU user mode driver provided by the application; Figure 5 is a schematic diagram of a color setting device applied to a GPU hardware provided by the application; Figure 6 is a structural schematic diagram of an electronic device provided by the application embodiment. DETAILED DESCRIPTION
[0010] In order to make the above objectives, characteristics and advantages of the present application more apparent, further specific embodiments will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0011] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of a kind and do not limit the number of objects, for example, the first object can be one or more. In addition, the term "and / or" in the specification and claims is used to describe the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B can represent: A exists alone, A and B exist together, and B exists alone. The character " / " generally represents an "or" relationship between the associated objects. The term "multiple" in the embodiments of the present application means two or more, and other quantifiers are similar.
[0012] In three-dimensional rendering, the two-dimensional target texture is mainly fitted to the surface of the three-dimensional model (the main body to be rendered) according to the mapping coordinates, and the surface details of the model are given. When the effective area of the target texture is smaller than the surface area of the three-dimensional model (the main body to be rendered), part of the UV coordinates of the model surface will inevitably exceed the effective range of the target texture, that is, the UV coordinates break through the [0.0, 1.0] interval. The UV coordinates are the mapping coordinate system of the two-dimensional target texture, which positions the image pixels of the target texture with U (horizontal) and V (vertical) axes and maps them to the surface of the three-dimensional model, and the coordinate range is usually standardized to [0.0, 1.0]. In order to ensure the visual continuity of the surface of the three-dimensional model, a reasonable color filling scheme needs to be provided for these coordinates that exceed the effective range, that is, a setting scheme of the texture boundary color.
[0013] In the common way, a sampling descriptor is introduced as a core control structure to guide the process of color filling. The sampling descriptor not only contains the basic attributes of the target texture, but also includes key parameters specially for edge rendering, including the texture boundary color used to render the edge area that cannot be covered by the target texture, etc.
[0014] The texture border color is one of the sampling descriptors configured by a graphics processing unit (GPU) in a three-dimensional rendering process. When a target texture cannot cover the surface of a three-dimensional model (a subject to be rendered), the texture border color configured is used to fill the part of the texture that cannot be covered. In some embodiments, the texture border color to be set is directly configured into the sampling descriptor by the GPU driver. When the GPU hardware processes the problem that the border of the subject to be rendered exceeds the target texture, the texture border color stored in the sampling descriptor is used to fill the part of the target texture that cannot be covered if the border color mode is selected.
[0015] However, the space for storing the texture border color in the sampling descriptor is limited. The number of storage bits required by different color formats is different, so the color format allowed to be filled is greatly limited.
[0016] For example, if only a 32-bit register is provided for storing the texture border color, a color value in the R8G8B8A8_UNORM format can be filled. The RGBA parameters have four channels, and each channel occupies an 8-bit register, so a 32-bit register is required. If the R16G16B16A16_FLOAT format color is to be stored, a register position of 64 bits is required. In the case of only providing a 32-bit register, the storage cannot be realized, and only the storage or conversion of a lower-precision format can be realized.
[0017] To solve the above problems, the present application provides a color setting method, which expands the storage range of the border color and increases the selection of the texture border color.
[0018] Reference Figure 1 FIG. 1 shows a step flowchart of an embodiment of a color setting method of the present application. The method is applied to a GPU user state driver. The method can include the following steps: Step 101: In the case of receiving a rendering preparation instruction, a first bit field of a sampling descriptor is set as a first identifier. The first identifier is used to point to a preset table in a memory. The preset table is used to store a border color whose color format exceeds the bit number of the sampling descriptor. Step 102: A target color carried in the rendering preparation instruction is written into the preset table. Step 103: A second identifier of the target color in the preset table is obtained. Step 104: The second identifier of the target color in the preset table is written into a second bit field of the sampling descriptor, and the sampling descriptor is sent to a GPU hardware, so that the GPU hardware implements texture border color setting according to the sampling descriptor.
[0019] GPU in the computer assumes the function of display image rendering, specifically, it executes rendering commands of user programs, draws images to be presented on the display, and then transmits the drawn images to the display, at which time the user can view the drawn images through the display. The software part assisting the GPU hardware to complete the entire image rendering process is the GPU driver. According to the accessible authority of the GPU driver to system resources, the GPU driver is divided into a user state driver and a kernel state driver. The GPU user state driver is responsible for parsing rendering commands of user programs and translating the rendering commands of user programs into hardware instructions executable by the GPU hardware.
[0020] It can be understood that the GPU user state driver is an intermediate path for software and hardware interaction. The rendering-related commands of user programs are converted into a command stream executable by the GPU hardware, and resources (such as target textures, target colors, etc.) used for rendering are managed. The GPU hardware executes the aforementioned command stream and performs three-dimensional rendering on the subject to be rendered according to the resources used for rendering sent by the GPU user state driver, and finally outputs a target image.
[0021] For example, the first identifier is used to point to a preset table located in the memory, and the preset table is used to store a boundary color whose color format exceeds the bit number of the sampling descriptor. The preset table is located in the memory, i.e., outside the sampling descriptor, and therefore the size of the storage space in the preset table is not limited by the size of the sampling descriptor. It can be understood that the size of the space occupied by the preset table can be set to be greater than the size of the storage space in the sampling descriptor used to store the target color format. In this regard, the problem that the target color whose required space is relatively large cannot be stored in the sampling descriptor due to the limitation of the storage space, and the preset table can provide a larger storage space, so that the target color whose required space is relatively large can be stored, i.e., the target color of more types and higher precision can be stored, the selection range of the target color is expanded, and the user experience can be improved.
[0022] In the preset table, the boundary color stored in the preset table includes the target color carried in the rendering preparation instruction after the target color is written into the preset table. The color format of the boundary color is, for example, R8G8B8A8_UNORM, R16G16B16A16_FLOAT, etc., and the number of register bits or the number of bits of the storage space required by different color formats is different. For example, the boundary color or the target color is stored in the preset table in the form of the actual color format. The bit number of the sampling descriptor refers to the bit number of the storage space for storing the boundary color in the sampling descriptor.
[0023] The color setting method provided in the embodiments of the present application is applied to a GPU user state driver, and when the GPU implements texture boundary color setting, more color choices can be provided. Specifically, by writing the target color into a preset table outside the sampling descriptor, the storage space of the target color is expanded, and the format limitation of the storage space for storing the target color is reduced, so that the expansion of the selection range of the target color can be realized. The sampling descriptor used to implement the texture boundary color setting is improved, and a first bit field divided in the sampling descriptor can store a first identifier, and the first identifier is used to point to the preset table, and the preset table is used to store the target color. Avoiding directly storing the target color in the limited space in the sampling descriptor can provide more sufficient space for realizing the complete storage of the target color.
[0024] Specifically, in the case of receiving a rendering preparation instruction, the first bit field of the sampling descriptor is set as the first identifier. The rendering preparation instruction is used to provide the preparation parameters required for rendering to the GPU hardware before the GPU hardware renders the rendering subject, which includes the target color as the texture boundary color. At the same time, after updating the sampling descriptor according to the first identifier, the target color carried in the rendering preparation instruction is written into the preset table. The preset table is used to store the target color, for the GPU hardware to look up and call when implementing the texture boundary color setting. The GPU user state driver is also used to obtain a second identifier of the target color in the preset table, and the second identifier can be used as a guide for the GPU hardware to look up the target color in the preset table; the second identifier is stored in the second bit field of the sampling descriptor.
[0025] Referring to Table 1, an example of 32-bit registers in a sampling descriptor related to texture boundary color setting is shown. Among them, the sampling descriptor 96-127 bit registers are shown, the first bit field is, for example, located in the 127-126 bit register; the second bit field is, for example, located in any continuous position of the 107-96 bit register, or, for example, located in any continuous position of the 125-96 bit register.
[0026] Table 1
[0027] It can be understood that the boundary color table Bct is the preset table. The 125-108 bit can be set as a reserved bit to provide a reserved position for the design of the subsequent program expansion.
[0028] Among them, 01 is the first identifier, which is used to identify that the target color is obtained by using the preset table. Specifically, 01 can point to the preset table located in the memory, so that after the GPU hardware detects the first identifier 01 in the first bit field, it jumps to the position of the preset table pointed to by 01, and queries the target color in the preset table according to the second identifier.
[0029] As shown in Table 1, the sampling descriptor in the embodiment of the present application is used to provide a first bit field and a second bit field, the first bit field is used to store a method of identifying that a preset table lookup approach needs to be used to obtain the target color, and the second bit field is used to store a second identification of the target color in the preset table, and the GPU hardware can find the target color in the preset table through the second identification. That is, the role of the register in the sampling descriptor and the stored content are improved, and the 32-bit register in the sampling descriptor used to store the target color is improved to realize the storage and acquisition of the target color in combination with the preset table. The storage space of the target color is expanded, so that more formats and higher precision target colors can be stored, and the user experience is improved.
[0030] It should be noted that, according to the parameters set by different GPU hardware, the position of the corresponding sampling descriptor for storing the parameters related to the texture boundary color setting may not be the 127-96 bit register, and the above Table 1 is only an example. The positions of the first bit field and the second bit field in the sampling descriptor can be adjusted according to the related parameters of the actual used GPU hardware, so that the GPU hardware can correctly read the parameters of the first bit field and the second bit field.
[0031] Optionally, in some embodiments, for data security considerations, the GPU user state driver cannot directly send the sampling descriptor to the GPU hardware. At this time, the GPU user state driver needs to send the sampling descriptor to the GPU hardware through the secure channel established by the GPU firmware. Specifically, the GPU user state driver sends the sampling descriptor to the GPU firmware, and then the GPU firmware forwards it to the GPU hardware. That is, it can be understood that the GPU includes GPU hardware, GPU firmware, and GPU driver, and the GPU driver includes user state driver and kernel state driver. Among them, the GPU hardware is used to realize image rendering; the GPU driver translates the instructions of the application program, such as rendering instructions, into a language that the GPU hardware can understand, and sends it to the GPU hardware; when it involves hardware initialization, configuration update, and specific operations (such as part of the underlying management operation), the GPU driver needs to transmit the related data to the GPU hardware through the GPU firmware. In addition, when the GPU is mentioned alone, it usually refers to the GPU hardware.
[0032] In a specific implementation, the GPU user state driver integrates the required information of the GPU hardware in a one-time rendering process into a data packet conforming to the GPU specification, called a drawcall packet, and can include the sampling descriptor whose first bit field and second bit field have been updated in the drawcall packet for sending. That is, the GPU user state driver sends the drawcall packet containing the sampling descriptor to the GPU firmware, and the GPU firmware forwards the drawcall packet to the GPU hardware for the GPU hardware to implement the texture boundary color setting.
[0033] In the embodiment, a preset table concept is proposed, the preset table is located outside the sampling descriptor and is specifically independently located in the memory, and target colors used for implementing texture boundary color setting are stored in the preset table. Specifically, in a case where a rendering preparation instruction is received, a first bit field of the sampling descriptor is set as a first identifier, the first identifier is used for pointing to the preset table, and a target color carried in the rendering preparation instruction is written into the preset table. A second identifier of the target color in the preset table is acquired, and the second identifier is stored in a second bit field of the sampling descriptor; and the GPU hardware looks up the target color in the preset table through the second identifier to complete the texture boundary color setting when performing the texture boundary color setting. In the color setting method proposed in the application, the target color is stored in the preset table outside the sampling descriptor, the storage space in the preset table is larger, and various color formats and high-precision colors with high storage space requirements can be supported; compared with using the limited preset area in the sampling descriptor to store the target color, the limitation on the storage space of the target color is reduced, the format and precision of the target color storage can be expanded, the setting of the texture boundary color can be improved, and the user experience is improved.
[0034] In an optional embodiment of the application, before the rendering preparation instruction is received, the method further includes: S01, applying a memory space of the preset table; S02, sending an address of the memory space to the GPU hardware, so that the GPU hardware stores the address of the memory space of the preset table into an address register and updates an identifier in an enable register to an open identifier; wherein the first identifier is used for pointing to the address register, and the open identifier is used for making the GPU hardware preferentially read the first bit field in the sampling descriptor.
[0035] In the embodiment, before the sampling descriptor is updated according to the rendering preparation instruction, the related parameters of the scheme (steps 101-104) need to be initialized, for example, the target color acquisition mode through the preset table is enabled, and the preset table is set in advance.
[0036] Specifically, the preset table is stored in a piece of memory that can be accessed by the GPU, for example, can be located in a piece of memory in the CPU that can be accessed by the GPU. The content in the preset table is written by the GPU user state drive executed by the CPU, and the GPU hardware reads when needed. In the initialization process, the GPU user state drive executed by the CPU applies the memory space of the preset table, and after the memory space is acquired, the address of the memory space is sent to the GPU hardware, so that the GPU hardware looks up the preset table through the address of the memory space when used to acquire the parameters in the preset table. Wherein, the address of the memory space is written into the address register by the GPU hardware, for looking up and calling when used by the GPU hardware.
[0037] In the process of setting the texture boundary color, the GPU hardware can obtain the location of the address register through the first identifier, further identify the preset table pointed by the address stored in the address register, and obtain the target color corresponding to the second identifier in the preset table according to the second identifier.
[0038] In addition, after the address register is updated according to the received address of the memory space, the GPU hardware can also update the identifier in the enable register to the open flag. When the identifier in the enable register is the close identifier, the GPU hardware will completely read the location (for example, a 32-bit register) in the sampling descriptor for storing the target color to obtain the target color; when the identifier in the enable register is the open identifier, the GPU hardware preferentially reads the parameter in the first bit field and determines the subsequent execution step according to the parameter in the first bit field. That is, when the identifier in the enable register is the open identifier, the GPU hardware can implement the color setting scheme provided in the embodiments of the present application to implement the texture boundary color setting.
[0039] Optionally, the close identifier in the enable register is 0, and the open identifier is 1. That is, the enable register can only occupy a 1-bit register and store 1-bit data. After the GPU hardware receives the address of the memory space sent by the GPU user mode driver, the 0 in the enable register is updated to 1.
[0040] In one example, the two steps of writing the address of the memory space into the address register and updating the close identifier of the enable register to the open identifier are steps executed by the GPU hardware when the GPU hardware provides a hardware command capable of directly setting the border color table, and the isolation of the GPU firmware can be skipped; when the GPU hardware does not provide a hardware command capable of directly setting the border color table, the steps are executed by the GPU firmware. The GPU firmware is a safe transfer between the GPU user mode driver and the GPU hardware for data interaction.
[0041] Generally, if the GPU hardware provides a hardware command capable of directly setting the border color table, the hardware command is configured in the GPU hardware and is implemented through specific hardware design, and thus is related to the structure of the GPU hardware and can be determined by the GPU model. The GPU user mode driver can obtain the parameters (for example, the model, etc.) of the GPU hardware to be called in advance, and thus can determine in advance whether the address of the memory space and other parameters need to be sent to the GPU firmware or the GPU hardware for updating the address register and the enable register.
[0042] For example, the GPU user-mode driver sends the address of the memory space of the preset table to the GPU firmware or GPU hardware via a command packet. The command packet is 12 bytes in size; the first 4 bytes are the command word of the command packet, used to enable the GPU firmware or GPU hardware to recognize the command packet; the last 8 bytes are used to store the virtual address of the memory space of the preset table.
[0043] It should be noted that the address register and enable register are set in the GPU hardware. Before reading the sampling descriptor, the GPU hardware has already detected that the identifier in the enable register has been updated to the enabled identifier. At the same time, after reading the first field of the sampling descriptor based on the enabled identifier in the enable register to obtain the first identifier, the address of the preset table stored in the address register is looked up based on the first identifier to read the preset table and further obtain the target color.
[0044] In one example, such as Figure 2 The diagram illustrates the process of setting texture boundary colors through interaction between the GPU user-space driver, GPU firmware, and GPU hardware in this embodiment of the application. In the illustrated process, the GPU hardware does not provide hardware commands to directly set the border color table; therefore, the GPU firmware receives the address information of the preset table and updates parameters such as the address register and enable register.
[0045] Before updating the sampling descriptor according to the rendering preparation instructions, this embodiment of the application includes an initialization preparation process for parameters such as the preset table. This includes: allocating memory space for the preset table; after completing the allocation, the GPU's user-mode driver sends the address of the memory space to the GPU hardware; updating the address register based on the address of the memory space; and using the address register for the GPU hardware to look up the target color when implementing texture boundary color settings. Furthermore, the enable register is updated so that the GPU hardware uses the color setting method described in this application when implementing texture boundary color settings, instead of completely reading the registers in the sampling descriptor used to store colors (e.g., a continuous 32-bit register), thus avoiding data corruption issues during steps 101-103.
[0046] In one optional embodiment of this application, the rendering preparation instruction carries the format of the target texture; the step of writing the target color carried in the rendering preparation instruction into the preset table includes: S11, if it is detected that the format of the target color carried in the rendering preparation instruction is inconsistent with the format of the target texture, the format of the target color is updated according to the format of the target texture; S12, write the target color into the preset table according to the updated target color format.
[0047] That is, the rendering preparation instruction carries not only the target color but also at least the format of the target texture, for realizing preprocessing on the format of the target color.
[0048] At this time, if it is detected that the format of the target color is different from the format of the target texture, the format of the target color can be adjusted according to the format of the target texture, so that the target color and the format of the target texture are consistent. The target color after the format is updated is written into the preset table for reading by the GPU hardware when rendering.
[0049] In the embodiment, the stored format of the target color is consistent with the format of the target texture, so that the GPU can obtain the target texture and the target color as the texture boundary color by the same format reading mode when performing three-dimensional rendering on the to-be-rendered subject, the data processing complexity of the three-dimensional rendering step of the GPU hardware is reduced, the error probability of the GPU hardware during three-dimensional rendering is reduced, and the user experience is ensured.
[0050] In an optional embodiment of the present application, the preset table includes a plurality of occupied storage spaces with the same byte length, and each of the storage spaces is used for storing the target color in writing order respectively; wherein the byte length of the storage space is used in combination with the order value marked by the second identifier to obtain the target color by the GPU hardware through position calculation.
[0051] It can be understood that, when the GPU hardware reads the target color through the second identifier, since only the target color is stored in the preset table, the position of the target color can be directly determined through the stored byte length and the like. At the same time, since the storage spaces for storing the target color have the same byte length, the position of the target color can be directly calculated through the writing order value and the byte length of the storage space.
[0052] Exemplarily, the second identifier can mark the writing order of the target color. For example, the second identifier of the first target color written into the preset table is 0, the second identifier of the second target color written into the preset table is 1, the second identifier of the third target color written into the preset table is 2, and so on. The byte length of the storage space can be set to 16 bytes, that is, 128-bit registers, which can realize storage of the target color in most formats.
[0053] In the process that the GPU reads the target color in the preset table according to the second identifier, the initial address to be read is obtained in combination with the address of the memory space, the byte length of the storage space and the sequence value marked by the second identifier, and based on the initial address, a complete byte length of the storage space is read to obtain the target color. For example, the second identifier of the target color a is 1, the byte length of a storage space is 16 bytes, and the address of the memory space of the preset table is x, then the initial address to read the target color a is x+16x1=x', and the data in the 16 bytes is read completely from the next bit of x' to obtain the target color a.
[0054] Optionally, when the memory space is applied for the preset table, the storage form of the data in the table can also be defined, or the byte length of each storage space in the preset table is specified, and the spaces in the preset table are divided according to the byte length for the target color to be stored in sequence.
[0055] As shown in Table 2, it is a schematic of a preset table.
[0056] Table 2
[0057] Among them, (255, 0, 0, 255) is the unorm format of opaque red, (0, 1.0, 0, 1.0) is the float format of opaque green, and (0, 0, 255) is the srgb format of blue. That is, the preset table supports storage of multiple format colors.
[0058] It can be understood that the current preset table supports most formats required in the OpenGL specification, such as RGBA and its related R, RG, RGB, BGRA formats, or SRGB format, Luminance format, depth_stencil format, etc. That is, in the color obtaining method provided by the present application, the storage of the target color has great expansion in both format and precision. For example, the storage space for storing a target color is expanded to 16 bytes, which is four times larger than the 4 bytes (32-bit register) provided by the sampling descriptor in some related technologies, and the color precision that can be stored is greatly improved. Due to the expansion of the storage space, it also supports storage of multiple formats with large space requirements.
[0059] For example, the same color (R=0.5, G=0.5, B=0.5, A=1.0) is stored by R8G8B8A8_UNORM and R16G16B16A16_SFLOAT. R8G8B8A8_UNORM is 8 bits per channel, which needs to occupy 4 bytes, that is, a 32-bit register; R16G16B16A16_SFLOAT is 16 bits per channel, which needs to occupy 8 bytes, that is, a 128-bit register. When the storage space is only 4 bytes, that is, a 32-bit register, only the R8G8B8A8_UNORM format can be selected for storage. However, if the storage space is large enough, R16G16B16A16_SFLOAT can be selected for storage, which has higher color precision, more details, and a wider color range.
[0060] In the embodiment, only the color value of the target color is stored in the preset table, and compared with the method of storing the color value and the index, the preset table does not need to store the index value and other auxiliary query data, so the storage space required for storing the data is small, and the preset table occupies less space. At the same time, the GPU hardware generally reads information through an initial address and a certain offset, and the process of reading the parameters in the preset table through the second identifier in the present solution conforms to the general reading logic of the hardware, and the certain offset is, for example, the byte length of the storage space. In addition, compared with the method of first searching the index and then obtaining the target color according to the correspondence between the index and the target color, although there is a calculation process in the embodiment, the calculation amount and the time required for calculation are very small, which does not affect the normal work of the hardware. Therefore, the preset table obtained according to the embodiment can realize fast query and improve the user experience in the case of occupying small storage space.
[0061] In an optional embodiment of the present application, the first bit field of the sampling descriptor is updated as the first identifier in the case of receiving the rendering preparation instruction, and the first identifier is used to point to the preset table, including: S21, in the case of receiving the rendering preparation instruction, obtaining the target color carried in the rendering preparation instruction; S22, in the case that the target color is the same as any preset color, updating the first bit field of the sampling descriptor as the identifier of the preset color; S23, in the case that the target color is different from any preset color, updating the first bit field of the sampling descriptor as the first identifier, and the first identifier is used to point to the preset table.
[0062] It can be understood that preset colors exist in the embodiment, and the preset colors are, for example, several colors with high frequency of use obtained according to historical data of performing three-dimensional rendering according to a user program. If the target color carried in the rendering preparation instruction is one of the preset colors, the identification of the preset color is directly filled in the sampling descriptor, and the first bit field does not need to be set as the first identification, and then the storage and searching of the target color according to the preset table are performed.
[0063] For example, the preset colors are transparent black, opaque black and opaque white. The identification of the transparent black is 00, the identification of the opaque black is 10, and the identification of the opaque white is 11. When the target color carried in the rendering preparation instruction is the opaque black, the register of 127-126 bits (that is, the first bit field) in Table 1 is set as 10, and the related parameters in the second bit field are not updated. Under this premise, when the GPU hardware reads the first bit field as 10 in the sampling descriptor, the related parameters of the preset opaque black are used to implement the texture boundary color setting.
[0064] Optionally, the preset colors are configured in the GPU hardware, and are specifically configured in the logic circuit of a chip in the GPU hardware. After the identification of the corresponding preset color is identified, a pre-designed circuit signal is output, that is, the preset color can be quickly obtained by the GPU hardware. Compared with storing the preset color in the memory space of the CPU, the memory access is not needed, the speed of obtaining is fast, the operation process is simple, and the power consumption is low.
[0065] In the embodiment of the application, after the GPU memory driver obtains the target color according to the rendering preparation instruction, it is first judged whether the target color is consistent with the existing preset color. In the case where the target color is consistent with the preset color, the first bit field of the sampling descriptor is updated as the identification corresponding to the preset color, instead of the first identification. Then, the GPU hardware implements the texture boundary color setting by using the corresponding preset color according to the identification, and does not write or call the parameters in the preset table, so that the GPU can more conveniently read the target color and quickly complete the texture boundary color setting.
[0066] In an optional embodiment of the application, the writing of the target color carried in the rendering preparation instruction into the preset table comprises: querying whether the target color exists in the preset table; in the case where the target color does not exist in the preset table, writing the target color carried in the rendering preparation instruction into the preset table.
[0067] That is, the target color is not repeatedly stored, and the redundancy of the preset table can be further reduced.
[0068] It can be understood that the preset table is a reusable data area, and therefore stores historical target colors. Before writing the target color carried in the current rendering preparation instruction, the target color stored in the preset table is retrieved. If there is a historical target color that is the same as the current target color to be written, the current target color is not written, and the second identifier of the historical target color in the preset table is obtained as the second identifier of the target color to be written.
[0069] Optionally, the same includes the same format of the target color. For example, the same red color is represented as (255, 0, 0) in the RGB integer format, (1.0, 0.0, 0.0) in the RGB floating-point format, and #FF0000 in the hexadecimal color code (HEX) format. That is, the same color has different representations in different formats. In this scheme, only when the storage format of the current target color to be written and the historical target color is the same, it is considered to be the same color. The target color and the target texture are kept in the same format, so that the GPU hardware can read according to a unified format, and the texture boundary color setting is conveniently implemented.
[0070] Reference Figure 3 A color setting method in an embodiment of the present application is shown, which is applied to GPU hardware, and the method comprises: Step 201, in the case where it is identified that the coverage range of the target texture does not match the to-be-rendered subject, a sampling descriptor sent by a GPU user state driver is searched; Step 202, a target color corresponding to a second identifier in the preset table pointed to by the sampling descriptor is obtained by querying the preset table according to the second identifier in the sampling descriptor; Step 203, texture boundary color setting of the to-be-rendered subject is implemented according to the target color.
[0071] In this embodiment, in the process of rendering the to-be-rendered subject (such as a three-dimensional model) according to the rendering command of the user program, if it is identified that the coverage range of the target texture does not match the to-be-rendered subject, that is, the area of the target texture is insufficient to cover the surface of the to-be-rendered subject. Then, the part of the target texture that cannot be covered is filled according to the target color, that is, the texture boundary color setting of the to-be-rendered subject is implemented according to the target color.
[0072] Specifically, the sampling descriptor sent by the GPU user state driver is searched first, the preset table is queried according to the first identifier in the sampling descriptor, and the target color corresponding to the second identifier in the preset table is queried according to the second identifier in the sampling descriptor, and the texture boundary color setting is implemented according to the target color.
[0073] It can be understood that, compared with the way of storing the target color in the sample descriptor, storing the target color in the preset table reduces the limitation on the storage of the target color, can store more formats and higher precision target colors, improves the quality of the target color obtained by the GPU hardware, and guarantees the rendering quality.
[0074] The preset table is located in a memory and is used to store a boundary color with a color format exceeding a boundary of a bit number of the sample descriptor.
[0075] In the embodiment of the application, when the GPU hardware performs three-dimensional rendering, if a target texture cannot completely cover a surface of a main body to be rendered, a target color stored in the preset table is searched through the sample descriptor sent by the GPU memory driver, so as to realize the texture boundary color setting. Compared with directly searching the target color from the sample descriptor, the preset table supports storing multiple and high-precision color types, so that the storage format and precision range of the target color obtained by the GPU hardware when realizing the texture boundary color setting are wider, the texture boundary color setting can be optimized, and the user experience is improved.
[0076] In an optional embodiment of the application, before searching the sample descriptor sent by the GPU user state driver under the condition that the coverage range of the target texture does not match the main body to be rendered, the method further includes: S31, obtaining an address of a memory space of the preset table sent by the GPU user state driver; S32, storing the address of the memory space of the preset table into an address register; wherein the address register is a target pointed to by the sample descriptor; S33, updating an identifier in an enable register to an open identifier, and the open identifier is used to make the GPU hardware preferentially read a first bit field in the sample descriptor.
[0077] That is, before the GPU hardware performs rendering on the main body to be rendered according to the parameters in the sample descriptor, the GPU hardware can realize pre-configuration of the register according to the address of the memory space of the preset table sent by the GPU user state driver. The pre-configuration includes updating the address register according to the address of the memory space of the preset table, updating the off identifier in the enable register to the open identifier, and the like. Updating the enable register makes the GPU hardware update the reading mode of the sample descriptor, that is, update the obtaining mode of the target color; updating the address register makes the GPU hardware be able to query the preset table through the address register to obtain the target color.
[0078] The updating of the reading mode of the sample descriptor includes changing the way of using the continuous reading of the prescribed bit number of registers (for example, 32 bits) to obtain the complete target color to the way of first reading the parameters in the first bit field and determining the subsequent execution steps according to the parameters in the first bit field. It can be understood that in the case that the GPU hardware provides a hardware command capable of directly setting the border color table, the above steps S31-S33 are directly executed by the GPU hardware. In the case that the GPU hardware cannot provide a hardware command capable of directly setting the border color table, the above steps are executed by the GPU firmware for maintaining the security of the device data usage.
[0079] In the embodiment of the present application, when the GPU hardware receives the address of the memory space of the preset table, the GPU hardware updates the obtaining manner of the target color and updates the address of the memory space into an address register for subsequent obtaining of the target color when implementing the texture border color setting for the to-be-rendered subject. The preparation work of querying the target color through the preset table is completed, so that the GPU hardware can smoothly query the preset table to obtain the target color when implementing the texture border color setting, and the user experience is improved.
[0080] It should be noted that for the method embodiments, in order to simply describe, they are all described as a series of action combinations, but those skilled in the art should know that the embodiments of the present application are not limited to the order of the actions described, because according to the embodiments of the present application, certain steps can be performed in other order or at the same time. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions involved are not necessarily necessary for the embodiments of the present application.
[0081] In some examples, a GPU user mode driver is also provided, and the GPU user mode driver includes: A first module is configured to, in the case of receiving a rendering preparation instruction, set a first bit field of a sampling descriptor to a first identifier, the first identifier being used to indicate that a preset table is used to set a border color; the preset table is applied in memory by a user mode driver and is used to store a border color whose color format exceeds the bit number of the sampling descriptor; A second module is configured to write a second identifier indicating the position of a target color format in the preset table into a second bit field of the sampling descriptor, the second identifier being obtained by the GPU hardware from the sampling descriptor and being used by the GPU hardware as an index of the target color format.
[0082] The GPU hardware implements the texture border color setting according to the target color corresponding to the target color format.
[0083] Specifically, the first module is configured to set a sample descriptor, including adjusting a first bit field of the sample descriptor to implement texture boundary color setting by using a preset table to set the boundary color; and the second module is configured to write a second identifier representing a position of a target color format in the preset table into the sample descriptor on the basis of the method of using the preset table to set the boundary color, so that the GPU hardware indexes the target color format in the preset table through the second identifier, and the specific target color can be obtained through the target color format.
[0084] The second identifier is obtained by a GPU user state from the preset table and written into a second bit field of the sample descriptor, so that the GPU hardware obtains the second identifier in the sample descriptor and uses the second identifier as an index to search for the target color in the preset table. Meanwhile, since the target color is stored in the preset table in the form of the target color format, the target color format is searched in the preset table according to the second identifier in actual use.
[0085] For example, the second identifier can be an order value of the target color stored in the preset table. Since only the target color is stored in the preset table and the storage space used to store the target color has the same byte length, the position of the target color can be directly calculated through the order value written by the target color and the byte length of the storage space in the preset table.
[0086] In other embodiments, a graphics processing unit is also provided, including: a memory configured to store a preset table, the preset table being configured to store a boundary color whose color format exceeds a bit number of a sample descriptor; a boundary color register configured to store an address of the preset table in the memory; and a texture unit configured to query the preset table pointed to by the sample descriptor according to a second identifier in the sample descriptor, and obtain a target color corresponding to the second identifier in the preset table; implement texture boundary color setting of the to-be-rendered subject by using the target color.
[0087] A simplified modern GPU rendering pipeline is as follows: Vertex shader stage: processing vertex positions of a 3D model.
[0088] Primitive assembly: assembling vertices into triangles.
[0089] Rasterization: converting triangles into pixel fragments (i.e., fragments) on a screen.
[0090] Fragment shader stage: this is a stage of calculating a final color of each fragment.
[0091] When a fragment shader code executes a texture sampling instruction like texture(sampler, texCoord), the GPU's texture unit starts working.
[0092] The texture unit checks the texture coordinate texCoord, and if the coordinate is within the range [0.0, 1.0], it directly reads the color from the preset texture image; if the coordinate is out of the range (this is the boundary case), the texture unit will decide the behavior according to the "addressing mode" (Border color type) set in the sampling descriptor. When the addressing mode is set to 01 (i.e. the first bit field is identified as 01), the texture unit will get the "texture border color" (i.e. the target color) from the preset table in the video memory.
[0093] In other embodiments, an electronic system, such as a system on a chip (SoC), is also provided, comprising: a processor executing a user mode driver to set a first bit field of a sampling descriptor to a first identification, the first identification being used to indicate that a preset table is used to set a border color (i.e. to implement the texture border color setting); write a second identification indicating a position of the target color in the preset table into a second bit field of the sampling descriptor; and a graphics processing unit as described above.
[0094] In such an electronic system, the work of the CPU is in the resource setting stage before the rendering starts, including: resource application and management, a user mode driver executing on the CPU applies for a memory space of the preset table, and defines the format of the members in the table. For example, the user driver opens out an area in the video memory as the preset table, and determines the data format of each color entry in the table (such as R32G32B32A32_FLOAT); initialization configuration, the CPU sends a command to the firmware of the GPU through the user mode driver of the GPU, informs the GPU of the address of the preset table in the memory, and requires the GPU hardware to switch to a new border color resolution mode; data filling, the border color (exemplarily, i.e. the target color required this time) is written into the preset table, and for a complex border color (such as R32G32B32A32_FLOAT), the user mode driver of the CPU no longer directly writes the color into the sampling descriptor, but writes the high-precision color value into a certain position of the preset table; and setting instruction, the user mode driver fills in the sampling descriptor, and configures the first bit field of the border color type as using the Bct ID table lookup, and fills the ID of the color (i.e. the target color) needed to be used in the border color table into the Bct ID bit field.
[0095] The action of the GPU (hardware + firmware) includes: The firmware configures the hardware, and after the GPU firmware receives the CPU command, the GPU hardware is configured, and the border color table address is configured into the cb reg register (i.e. the address register); and Parsing descriptors, texture sampling and rendering, reading the sampling descriptor, parsing the border color type and BctID, if the border color type specifies the border color parsing mode, combining the table address (of the preset table) in the cb reg register and the Bct ID to determine and render the border texture color.
[0096] Referring to Figure 4 , a structure block diagram of a color setting device of the present application is shown, which is applied to a GPU user state drive, and the color setting device can include: An updating module 301 is configured to update a first bit field of a sampling descriptor to a first identifier in a case where a rendering preparation instruction is received, the first identifier being used to point to a preset table in a memory, and the preset table being used to store a border color whose color format exceeds the bit number of the sampling descriptor; A writing module 302 is configured to write a target color carried in the rendering preparation instruction into the preset table; A feedback module 303 is configured to obtain a second identifier of the target color in the preset table; A sending module 304 is configured to write the second identifier of the target color in the preset table into a second bit field of the sampling descriptor, and send the sampling descriptor to GPU hardware, so that the GPU hardware implements texture border color setting according to the sampling descriptor.
[0097] Optionally, before the rendering preparation instruction is received, the device further includes: An application module is configured to apply a memory space of the preset table; A sending module is configured to send an address of the memory space to GPU hardware, so that the GPU hardware stores the address of the memory space of the preset table into an address register, and updates an identifier in an enabling register to an open identifier; wherein the first identifier is used to point to the address register, and the open identifier is used to make the GPU hardware preferentially read the first bit field in the sampling descriptor.
[0098] Optionally, the rendering preparation instruction carries a format of a target texture; and the writing module 202 specifically includes: a format adjusting module, configured to update the format of the target color according to the format of the target texture, in a case where it is detected that the format of the target color carried in the rendering preparation instruction is inconsistent with the format of the target texture; a format writing module, configured to write the target color into the preset table according to the updated format of the target color.
[0099] Optionally, the preset table includes a plurality of storage spaces with the same byte length, and each of the storage spaces is configured to store the target color in a writing order; and the byte length of the storage space is configured to be used by the GPU hardware to obtain the target color through position calculation in combination with the order value marked by the second identifier.
[0100] Optionally, the updating module 301 specifically includes: an obtaining module, configured to obtain a target color carried in a rendering preparation instruction in a case where the rendering preparation instruction is received; a first updating module, configured to update a first bit field of the sampling descriptor to an identifier of a preset color, in a case where the target color is the same as any preset color. a second updating module, configured to update the first bit field of the sampling descriptor to a first identifier, in a case where the target color is different from any preset color, the first identifier being used to point to a preset table.
[0101] Embodiments of the present application provide a color setting device, and propose a preset table concept. The preset table is located outside the sampling descriptor, and the preset table stores a target color used to implement texture boundary color setting. Specifically, in a case where a rendering preparation instruction is received, a first bit field of a sampling descriptor is set to a first identifier, and the first identifier is used to point to a preset table; and a target color carried in the rendering preparation instruction is written into the preset table. A second identifier of the target color in the preset table is obtained, and the second identifier is stored in a second bit field of the sampling descriptor; and the GPU hardware looks up the target color in the preset table through the second identifier when performing texture boundary color setting, so as to complete the texture boundary color setting. In the color setting method proposed in the present application, the preset table outside the sampling descriptor is used to store the target color, the storage space in the preset table is large, and supports storage of various color formats and high-precision colors with high requirements on storage space. Compared with using a limited preset area in the sampling descriptor to store the target color, the color setting method reduces the limitation on the storage space of the target color, can expand the format and precision of the target color storage, can improve the setting of the texture boundary color, and can improve the user experience.
[0102] Reference Figure 5 FIG. 1 shows a structure block diagram of a color setting device according to an embodiment of the present application, which is applied to GPU hardware, and the color setting device includes: The searching module 401 is configured to search a sampling descriptor sent by a GPU user mode driver when it is identified that the area of the target texture does not match the subject to be rendered. The obtaining module 402 is configured to obtain a target color corresponding to the second identifier in a preset table pointed to by the sampling descriptor according to the second identifier in the sampling descriptor; the preset table is located in a memory, and the preset table is configured to store a boundary color of which a color format exceeds a bit number of the sampling descriptor. The setting module 403 is configured to realize the texture boundary color setting of the subject to be rendered according to the target color.
[0103] Optionally, before the searching module 401, the device further comprises: The address obtaining module is configured to obtain an address of a memory space of the preset table sent by the GPU user mode driver. The address storage module is configured to store the address of the memory space of the preset table into an address register; the address register is a target pointed to by the sampling descriptor. The enabling updating module is configured to update an identifier in an enabling register to an enabling identifier; the enabling identifier is configured to enable the GPU hardware to preferentially read the first bit field in the sampling descriptor.
[0104] In the embodiment of the application, when the GPU hardware performs three-dimensional rendering, if a target texture cannot completely cover a surface of a subject to be rendered, a target color stored in a preset table is searched through a sampling descriptor sent by a GPU memory driver, so as to realize texture boundary color setting. Compared with directly searching a target color from a sampling descriptor, the preset table supports storing multiple and high-precision color types, so that the storage format and the precision range of the target color obtained by the GPU hardware when realizing texture boundary color setting are wider, the texture boundary color setting can be optimized, and user experience is improved.
[0105] For the device embodiment, the description is relatively simple because it is basically similar to the method embodiment, and the related parts refer to the part of the description of the method embodiment.
[0106] Reference Figure 6 is a structural schematic diagram of an electronic device provided by the embodiment of the application. As shown in Figure 6 The electronic device comprises a processor, a memory, a communication interface and a communication bus, the processor, the memory and the communication interface complete communication with each other through the communication bus; the memory is configured to store at least one executable instruction, and the executable instruction causes the processor to execute the steps of the color setting method of the foregoing embodiment.
[0107] The embodiment of the present application provides a non-transitory computer readable storage medium, when instructions in the storage medium are executed by a program or a processor of a terminal, the terminal can execute steps of the color setting method of the foregoing embodiment. Each embodiment in the specification is described in a progressive manner, and each embodiment focuses on the difference from other embodiments, and the same or similar parts between the embodiments can be referred to each other.
[0108] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, an apparatus, an electronic device or a computer program product. Therefore, the embodiments of the present application can adopt a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the embodiments of the present application can adopt the form of a computer program product implemented on one or more computer usable storage media (including but not limited to disk memory, CD-ROM, optical memory, etc.) containing computer usable program codes.
[0109] The embodiments of the present application are described with reference to flowcharts and / or block diagrams according to the method, terminal device (system) and computer program product of the embodiments of the present application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams can be realized by computer program instructions. These computer program instructions can be provided to a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing terminal device to produce a machine, so that the instructions executed by the computer or other programmable data processing terminal device produce a device for implementing the functions specified in the flowcharts and / or block diagrams. Figure 1 The functions specified in one flow or multiple flows and / or blocks Figure 1 The functions specified in one flow or multiple flows and / or blocks
[0110] These computer program instructions can also be stored in a computer readable memory capable of causing the computer or other programmable data processing terminal device to work in a predictable manner, so that the instructions stored in the computer readable memory produce a product including instruction devices, which implement the functions specified in the flowcharts and / or block diagrams. Figure 1 The functions specified in one flow or multiple flows and / or blocks Figure 1 The functions specified in one flow or multiple flows and / or blocks
[0111] These computer program instructions can also be loaded into a computer or other programmable data processing terminal device, so that a series of operation steps are executed on the computer or other programmable terminal device to produce a computer implemented process, so that the instructions executed on the computer or other programmable terminal device provide a product for implementing the functions specified in the flowcharts and / or block diagrams. Figure 1 The functions specified in one flow or multiple flows and / or blocks Figure 1steps of a function specified in one or more blocks.
[0112] Finally, it should be noted that the terms "first" and "second", and the like, are used herein merely to distinguish one element from another, and are not necessarily intended to indicate physical or chronological order. Also, the terms "including", "containing", or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements is not necessarily limited to those elements, but can include other elements not expressly listed or inherent to such process, method, article, or apparatus. An element proceeded by "comprises... a" does not, without more constraints, exclude the existence of additional identical elements in the process, method, article, or apparatus that comprises the element.
[0113] The principles and implementations of the present application are described herein with specific examples. The above description is merely used to help understand the method and its core idea of the present application; meanwhile, for those skilled in the art, according to the idea of the present application, the specific implementation and application range can be changed, and the above description should not be understood as a limitation of the present application.
Claims
1. A color setting method characterized by, The method applied to a GPU user mode driver comprises the following steps: In the case of receiving a rendering preparation instruction, a first bit field of a sampling descriptor is set as a first identifier, the first identifier is used to point to a preset table in a memory, and the preset table is used to store a boundary color of a color format exceeding a bit number of the sampling descriptor; A target color carried in the rendering preparation instruction is written into the preset table; A second identifier of the target color in the preset table is obtained; The second identifier of the target color in the preset table is written into a second bit field of the sampling descriptor, and the sampling descriptor is sent to GPU hardware, so that the GPU hardware implements texture boundary color setting according to the sampling descriptor.
2. The color setting method according to claim 1, wherein, Before the rendering preparation instruction is received, the method further comprises the following steps: A memory space of the preset table is applied for; An address of the memory space is sent to the GPU hardware, so that the GPU hardware stores the address of the memory space of the preset table into an address register, and an identifier in an enable register is updated as an open identifier; wherein the first identifier is used to point to the address register, and the open identifier is used to make the GPU hardware preferentially read the first bit field in the sampling descriptor.
3. The color setting method according to claim 1, wherein The rendering preparation instruction carries a format of a target texture; and the target color carried in the rendering preparation instruction is written into the preset table, which comprises the following steps: In the case of detecting that a format of the target color carried in the rendering preparation instruction is inconsistent with the format of the target texture, the format of the target color is updated according to the format of the target texture; The target color is written into the preset table according to the updated format of the target color.
4. The color setting method of claim 1, wherein The preset table comprises a plurality of occupied storage spaces with the same byte length, and each storage space is used to store the target color in a writing order respectively; The byte length of the storage space is used to combine a sequence value marked by the second identifier, so that the GPU hardware obtains the target color through position calculation.
5. The color setting method of claim 1, wherein In the case of receiving a rendering preparation instruction, the first bit field of the sampling descriptor is updated as a first identifier, the first identifier is used to point to a preset table, which comprises the following steps: In the case of receiving a rendering preparation instruction, a target color carried in the rendering preparation instruction is obtained; In the case that the target color is the same as any preset color, the first bit field of the sampling descriptor is updated as an identifier of the preset color; In the case that the target color is different from any preset color, the first bit field of the sampling descriptor is updated as a first identifier, the first identifier is used to point to a preset table.
6. A color setting method characterized by, The method applied to GPU hardware comprises the following steps: In the case of identifying that a coverage range of a target texture does not match a to-be-rendered subject, a sampling descriptor sent by a GPU user mode driver is found; According to a second identifier in the sampling descriptor, a preset table pointed by the sampling descriptor is queried, and a target color corresponding to the second identifier in the preset table is obtained; According to the target color, texture boundary color setting of the to-be-rendered subject is implemented.
7. The color setting method according to claim 6, wherein The method further comprises, before searching the sampling descriptor sent by the GPU user mode driver, in a case where the coverage of the target texture is identified as not matching the subject to be rendered: obtaining an address of a memory space of the preset table sent by the GPU user mode driver; storing the address of the memory space of the preset table into an address register; wherein the address register is a target pointed to by the sampling descriptor; updating an identifier in an enable register to an open identifier, the open identifier being used to make the GPU hardware preferentially read a first bit field in the sampling descriptor.
8. A GPU user-mode driver, comprising: The GPU user mode driver comprises: a first module configured to, in a case where a rendering preparation instruction is received, set a first bit field of a sampling descriptor to a first identifier, the first identifier being used to indicate that a preset table is used to set a boundary color; the preset table being applied in a memory by the user mode driver and being used to store a boundary color whose color format exceeds a bit number of the sampling descriptor; a second module configured to write a second identifier indicating a position of a target color format in the preset table into a second bit field of the sampling descriptor, the second identifier being obtained by the GPU hardware from the sampling descriptor and being used by the GPU hardware as an index of the target color format.
9. A graphics processing unit, comprising: a memory storing a preset table, the preset table being used to store a boundary color whose color format exceeds a bit number of a sampling descriptor; a boundary color register storing an address of the preset table in the memory; and a texture unit configured to query the preset table pointed to by the sampling descriptor according to a second identifier in the sampling descriptor, and obtain a target color corresponding to the second identifier in the preset table. The target color is used to implement a texture boundary color setting of the subject to be rendered.
10. A system on chip, comprising: a processor configured to execute a user mode driver, and set a first bit field of a sampling descriptor to a first identifier, the first identifier being used to indicate that a preset table is used to set a boundary color; write a second identifier indicating a position of a target color format in the preset table into a second bit field of the sampling descriptor; and the graphics processing unit of claim 9.
Citation Information
Patent Citations
Pixel rendering method and device, equipment and storage medium
CN113205580A
Texel extraction method and device, electronic equipment and storage medium
CN117746059A
Data processing apparatus and method for processing a received workload in order to generate result data
US20120304194A1
Managing rendering targets for graphics processing units
US9928637B1
Cited By
Software and hardware combined frame texture sampling system
CN122289500A
A hardware and software combined frame texture sampling system
CN122289500B