[go: up one dir, main page]

WO2025227968A1 - Application texture rendering method and apparatus, and electronic device, computer-readable storage medium and computer program product - Google Patents

Application texture rendering method and apparatus, and electronic device, computer-readable storage medium and computer program product

Info

Publication number
WO2025227968A1
WO2025227968A1 PCT/CN2025/083002 CN2025083002W WO2025227968A1 WO 2025227968 A1 WO2025227968 A1 WO 2025227968A1 CN 2025083002 W CN2025083002 W CN 2025083002W WO 2025227968 A1 WO2025227968 A1 WO 2025227968A1
Authority
WO
WIPO (PCT)
Prior art keywords
target
resource
texture
application
electronic device
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
Application number
PCT/CN2025/083002
Other languages
French (fr)
Chinese (zh)
Inventor
刘昕禹
肖海
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Publication of WO2025227968A1 publication Critical patent/WO2025227968A1/en
Pending legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/001Texturing; Colouring; Generation of texture or colour
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/60Generating or modifying game content before or while executing the game program, e.g. authoring tools specially adapted for game development or game-integrated level editor
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F2300/00Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
    • A63F2300/60Methods for processing data by generating or executing the game program
    • A63F2300/6009Methods for processing data by generating or executing the game program for importing or creating game content, e.g. authoring tools during game development, adapting content to different platforms, use of a scripting language to create content

Definitions

  • Texture reflects the surface structure and arrangement properties of an object, exhibiting slow or periodic changes. Simply put, texture is the pattern of the displayed object, such as the skin of a game character or the pattern on a sword.
  • Different devices use different texture compression formats. If the compression format of the application's textures is set at the factory to be different from the compression format supported by the device, the compressed textures of the application will not be rendered well, and problems will occur. If compressed textures based on various compression formats are sent to the device in advance, it will occupy the device's storage space.
  • This application provides an application texture rendering method, apparatus, electronic device, computer-readable storage medium, and computer program product, which can improve the universality of application texture rendering on terminals that support different compression formats and reduce the occupation of terminal storage space.
  • an application texture rendering method is provided, the method being executed by a first electronic device, the method comprising:
  • the target application texture resources are compressed into multiple candidate compressed texture resources according to multiple candidate compression formats
  • the system receives a resource request sent by the second electronic device.
  • the resource request is sent by the second electronic device after it obtains the placeholder data.
  • the request is for requesting a target compressed texture resource.
  • the target compressed texture resource is obtained by compressing the target application texture resource using a target compression format.
  • the target compressed texture resource is obtained from the plurality of candidate compressed texture resources, and the target compressed texture resource is sent to the second electronic device;
  • the target compressed texture resource is used for rendering the target application by the second electronic device.
  • an application texture rendering apparatus comprising:
  • the first sending unit is configured to acquire the target application texture resources and placeholder data of the target application, and send the placeholder data to the second electronic device;
  • the compression unit is configured to compress the target application texture resource into multiple candidate compressed texture resources according to multiple candidate compression formats
  • the second sending unit is configured to receive a resource request sent by the second electronic device.
  • the resource request is sent by the second electronic device after obtaining the placeholder data, and is used to request a target compressed texture resource.
  • the target compressed texture resource is obtained by compressing the target application texture resource using a target compression format. If the target compression format belongs to the plurality of candidate compression formats, the unit obtains the target compressed texture resource from the plurality of candidate compressed texture resources and sends the target compressed texture resource to the second electronic device.
  • the target compressed texture resource is used by the second electronic device to render the target application.
  • an application texture rendering method is provided, the method being executed by a second electronic device, the method comprising:
  • the target compression format supported by the second electronic device is determined
  • the resource request is used to request a target compressed texture resource.
  • the target compressed texture resource is obtained by compressing the target application texture resource using a target compression format.
  • the first electronic device When the first electronic device sends the placeholder data of the target application, it also compresses the acquired target application texture resources into multiple candidate compressed texture resources according to multiple candidate compression formats; the multiple candidate compression formats include the target compression format, and the multiple candidate compressed texture resources include the target compressed texture resource.
  • an application texture rendering apparatus comprising:
  • the determining unit is configured to determine the target compression format supported by the second electronic device in response to receiving placeholder data of the target application sent from the first electronic device;
  • the third sending unit is configured to send a resource request to the first electronic device.
  • the resource request is used to request a target compressed texture resource.
  • the target compressed texture resource is obtained by compressing a target application texture resource using a target compression format.
  • the second receiving unit is configured to receive the target compressed texture resource from the first electronic device and render the target application based on the target compressed texture resource; wherein, when the first electronic device sends the placeholder data of the target application, it also compresses the acquired target application texture resource into multiple candidate compressed texture resources according to multiple candidate compression formats; the multiple candidate compression formats include the target compression format, and the multiple candidate compressed texture resources include the target compressed texture resource.
  • an electronic device including:
  • Memory configured to store computer-executable instructions or computer programs
  • a processor When a processor is configured to execute computer-executable instructions or computer programs stored in the memory, it implements the application texture rendering method as described above.
  • the computer program product includes computer-executable instructions or a computer program
  • the processor executes the computer-executable instructions or the computer program to implement the application texture rendering method as described above.
  • a computer program product including computer executable instructions or a computer program, wherein a processor executes the computer executable instructions or computer program, causing the computer device to perform the application texture rendering method as described above.
  • the target application texture resources and placeholder data of the target application are acquired, and the target application texture resources are compressed into multiple candidate compressed texture resources according to multiple candidate compression formats and stored.
  • the placeholder data is sent to the user's second electronic device.
  • the second electronic device does not receive any compressed texture resources of any compression format.
  • the second electronic device actually renders the application, it can acquire the placeholder data, determine the target compression format it supports, and send a resource request to the first electronic device. Based on the resource request, it requests the target compressed texture resources obtained by compressing the target application texture resources using the target compression format.
  • the first electronic device Since the first electronic device has pre-stored candidate compressed texture resources of various candidate compression formats, upon receiving the resource request, it can obtain the target compressed texture resources from the candidate compressed texture resources and send them to the second electronic device, thereby enabling the second electronic device to render the target application using the target compressed texture resources.
  • the second electronic device since it has not received the actual compressed texture resource, after obtaining the placeholder data, it requests the target compressed texture resource of the target compression format from the first electronic device to obtain the target compressed texture resource for rendering.
  • This improves the universality of application texture rendering on terminals supporting different compression formats and increases the rendering efficiency of application textures.
  • the placeholder data is much smaller than the original compressed texture resource, it significantly reduces the amount of storage space occupied on the terminal, minimizing wasted space resources.
  • Figure 1 is a system architecture diagram of the application texture rendering method provided in the embodiments of this application.
  • Figure 2 is a schematic diagram of a terminal replacement scenario provided in an embodiment of this application.
  • Figure 3 is a flowchart illustrating the application texture rendering method provided in an embodiment of this application.
  • FIG. 4 is a flowchart of the application texture rendering method provided in an embodiment of this application.
  • Figure 5 is a schematic diagram of the initial resources and updated resource packages provided in the embodiments of this application.
  • Figure 6 is a schematic diagram of the process for storing multiple candidate compressed texture resources provided in an embodiment of this application.
  • Figure 7 is a schematic diagram of the compression process provided in an embodiment of this application.
  • Figure 8 is a flowchart illustrating the application texture rendering method provided in an embodiment of this application.
  • Figure 9 is a schematic diagram of a resource request provided in an embodiment of this application.
  • Figure 10 is a schematic diagram of the process of sending a resource request provided in an embodiment of this application.
  • Figure 11 is a flowchart illustrating the application texture rendering method provided in an embodiment of this application.
  • Figure 12 is a schematic diagram of the process for determining the target compressed texture resource provided in an embodiment of this application.
  • Figure 13 is a flowchart illustrating the application texture rendering method provided in an embodiment of this application.
  • Figure 14 is a flowchart illustrating the application texture rendering method provided in an embodiment of this application.
  • Figure 15 is a schematic diagram of the structure of an application texture rendering device 1500 for a first electronic device provided in an embodiment of this application;
  • Figure 16 is a schematic diagram of the structure of an application texture rendering device 1600 for a second electronic device provided in an embodiment of this application;
  • Figure 17 is a partial structural block diagram of the second electronic device using the texture rendering method provided in an embodiment of this application.
  • Figure 18 is a structural block diagram of a portion of the first electronic device for applying the texture rendering method provided in an embodiment of this application.
  • Application This typically refers to a software program or system used to perform a specific task or provide a specific function.
  • Applications can be of various types, including mobile applications, desktop applications, web applications, etc.
  • Web applications include WebGL games.
  • WebGL games are games developed using WebGL (Web Graphics Library) technology. They refer to games that run on a canvas element and conform to HTML5 standards, with rendering technology based on WebGL. Texture resources are often required for rendering WebGL games.
  • Texture resources also known as material mapping resources, refer to bitmap resources that can be wrapped around the surface of 3D models or sprites. Common texture resources are primarily in PNG and JPEG formats. Texture compression can be used to reduce the storage size of texture resources.
  • Texture compression An image compression technique specifically designed for storing texture map resources in computer graphics rendering systems. This compression algorithm optimizes storage size and random access.
  • Common texture compression formats include Ericsson Texture Compression (ETC or Ericsson Texture Compression 2, ETC2), Adaptive Scalable Texture Compression (ASTC), PowerVR Texture Compression (PVRTC), DXT1, and DXT5.
  • Unity Mini-Games Specifically refers to games developed using the Unity platform and run on mini-game platforms.
  • the Unity platform can be used to develop various types of games and can output them in WebGL format, thus creating WebGL games.
  • AssetBundle refers to the game resource archive file provided by the Unity platform, which can store non-code resources (such as models, textures, prefabs, scenes and media files) needed for game runtime.
  • First package resources Specifically refers to the resource files stored in the first scene when exporting WebGL game resources from the Unity platform. They end with the unityweb suffix by default and are the resource files that are loaded first when the Unity mini-game starts.
  • the first package resources include the resource content of the first scene and the resources of the attached AB packages.
  • Unity resource packs a collective term for resources in AB packs and the first pack.
  • the Unity platform already provides game developers with texture resource compression capabilities.
  • Unity mini-games are released independently for each device, meaning separate game clients are exported for iOS, Android, and Windows.
  • the texture resources are converted according to the format types supported by the device.
  • the resulting compressed texture resources, already in the corresponding compressed texture format, are then written into the Unity asset package. This allows for efficient texture rendering during game runtime.
  • the embodiments of this application can improve the universality of application texture rendering on terminals that support different compression formats and improve the rendering efficiency of application textures; at the same time, it reduces the occupation of terminal storage space and reduces the waste of space resources.
  • Figure 1 is a system architecture diagram of the texture rendering method provided in the embodiments of this application. It includes: terminals 110-1, 110-2 and 110-3, Internet 120, gateway 130, and server 140.
  • Terminals 110-1, 110-2, and 110-3 are devices used by the objects to render target applications (such as the WebGL game and Unity mini-game mentioned above). They include various forms such as desktop computers, laptops, personal digital assistants (PDAs), mobile phones, in-vehicle terminals, home theater terminals, and dedicated terminals. Furthermore, it can be a single device or a collection of multiple devices. For example, multiple devices can be connected via a local area network, sharing a single display device to work collaboratively, forming a single terminal. Terminals 110-1, 110-2, and 110-3 can also communicate with the Internet 120 via wired or wireless means to exchange data.
  • PDAs personal digital assistants
  • Terminals 110-1, 110-2, and 110-3 can also communicate with the Internet 120 via wired or wireless means to exchange data.
  • Gateway 130 also known as an internetwork connector or protocol converter, is a computer system or device that enables network interconnection at the transport layer and acts as a translator. It bridges the gap between two systems using different communication protocols, data formats, languages, or even completely different architectures. Gateway 130 also provides filtering and security functions. Messages sent from terminals 110-1, 110-2, and 110-3 to server 140 are forwarded to the corresponding server 140 via gateway 130. Similarly, messages sent from server 140 to terminals 110-1, 110-2, and 110-3 are also forwarded to the corresponding terminals 110-1, 110-2, and 110-3 via gateway 130.
  • Server 140 refers to a computer system capable of providing certain services to terminals 110-1, 110-2, and 110-3 (such as providing application containers for target applications, providing compressed texture resources of various formats to terminals 110-1, 110-2, and 110-3, etc.). Compared to terminals 110-1, 110-2, and 110-3, server 140 has higher requirements in terms of stability, security, and performance. Server 140 can be a single high-performance computer in a network platform, a cluster of multiple high-performance computers, a portion of a single high-performance computer (e.g., a virtual machine), or a combination of portions of multiple high-performance computers (e.g., virtual machines). Server 140 can also communicate with the Internet 120 via wired or wireless means to exchange data.
  • Figure 2 is a schematic diagram of a scenario of replacing a terminal provided by the embodiments of this application.
  • the server stores texture compression resources for different applications under various texture compression formats.
  • Application A includes candidate compressed texture resources W1 (for candidate compression format Y1), W2 (for candidate compression format Y2), and W3 (for candidate compression format Y3).
  • Application B is similar to Application A, also including texture compression resources under various compression formats, which will not be elaborated further.
  • the application container does not contain specific texture resources, but rather placeholder data.
  • the first terminal can request candidate compressed texture resources corresponding to the target compression format Y1 from the server.
  • the first terminal uses candidate compressed texture resource Y1 to render the target application.
  • the second terminal After the object changes the first terminal to a second terminal, the second terminal has the same resource package as the first terminal.
  • the object runs application A using a second terminal, since the second terminal supports the target compression format Y2, when the second terminal identifies the placeholder data in the resource package, it can request candidate compressed texture resources corresponding to the target compression format Y2 from the server.
  • the second terminal uses the candidate compressed texture resource Y2 to render the target application.
  • the object changes from the first terminal to the second terminal, it does not need to re-download the application container corresponding to the application on the second terminal or re-download the resource package (if the second terminal re-downloads, it may cause the loss of the usage records generated by the first terminal), nor will it cause rendering failure due to the compression format supported by the second terminal being different from that supported by the first terminal.
  • the second terminal can adaptively download the required compressed texture resources when rendering the application, ensuring normal texture resource rendering while avoiding the loss of application usage records.
  • the server since the server pre-stores candidate compressed texture resources in various compression formats, it can retrieve the target compressed texture resource from these and send it to the terminal for rendering of the target application.
  • the resource package since the resource package does not contain a specific compressed texture resource but uses placeholder data, the target compressed texture resource can be obtained by requesting it from the server, thus enabling rendering.
  • This improves the universality of application texture rendering on terminals supporting different compression formats and increases the rendering efficiency of application textures.
  • the placeholder data is much smaller than the original compressed texture resource, it significantly reduces the amount of storage space occupied on the terminal, minimizing wasted space resources.
  • an application texture rendering method is provided.
  • the application texture rendering method refers to a method for rendering texture resources required for running an application.
  • the application texture rendering method in the embodiments of this application is executed on a terminal and/or a server.
  • Figure 3 is a flowchart illustrating the application texture rendering method provided in this embodiment of the application.
  • the application texture rendering method (executed by a first electronic device such as a server) provided in this embodiment of the application includes:
  • Step 310 Obtain the target application texture resources and placeholder data of the target application, and send the placeholder data to the second electronic device;
  • Step 320 Compress the target application texture resources into multiple candidate compressed texture resources according to multiple candidate compression formats
  • Step 330 Receive a resource request sent by the second electronic device.
  • the resource request is sent by the second electronic device after obtaining the placeholder data, and is used to request a target compressed texture resource.
  • the target compressed texture resource is obtained by compressing the target application texture resource using a target compression format. If the target compression format belongs to multiple candidate compression formats, obtain the target compressed texture resource from the multiple candidate compressed texture resources and send the target compressed texture resource to the second electronic device.
  • the target compressed texture resource is used by the second electronic device for rendering the target application.
  • the advantage of the embodiment of steps 310-330 is that the target application texture resource is compressed into multiple candidate compressed texture resources and stored, and placeholder data is sent to the second electronic device.
  • the second electronic device if the terminal does not receive any compressed texture resources of any compressed format, can retrieve the target compressed texture resource from the candidate compressed texture resources of various compressed formats when the second electronic device sends a request to the first electronic device for the target compressed texture resource in the target compressed format, since the first electronic device has pre-stored candidate compressed texture resources of various compressed formats.
  • This target compressed texture resource can then be sent to the second electronic device for rendering of the target application.
  • this embodiment of the application can improve the universality of application texture rendering on terminals supporting different compression formats and improve the rendering efficiency of application textures; at the same time, since the placeholder data is much smaller than the original compressed texture resource, it can greatly reduce the occupation of terminal storage space and reduce the waste of space resources.
  • steps 310 to 330 The following describes in detail steps 310 to 330, the steps between steps 310 and 330, and the steps following step 330.
  • step 310 Detailed description of step 310
  • the process of obtaining the target application texture resources of the target application is to obtain the initial resource package of the target application, which includes the initial compressed texture resources of the target application in the initial compressed format; and to decompress the initial compressed texture resources to obtain the target application texture resources.
  • the target application refers to an application capable of performing a specific task or providing a specific function.
  • applications include web applications, and web applications include WebGL games; therefore, the target application could refer to a WebGL game.
  • the initial compressed texture resource refers to the target application's texture resource after compression.
  • the target application texture resource refers to the texture resource used to render the application. For instance, when running the target application on a terminal, the initial compressed texture resource needs to be decompressed into the target application texture resource, and then the target application texture resource is used to render the target application.
  • the application container is used to store data related to the application's operation. It includes an application package and an initial resource package.
  • the application package controls the application's execution process.
  • the initial resource package provides resources used for rendering during application execution.
  • the initial resource package may include target application texture resources.
  • the target application texture resources can be compressed using a compression algorithm corresponding to the initial compression format to obtain initially compressed texture resources, thus ensuring that the initial resource package includes initially compressed texture resources in the target application's initial compression format.
  • corresponding operations can be performed through the application package, and the initial resource package can be invoked for rendering.
  • the initial resource package of the target application is obtained in ways including but not limited to the following:
  • the first electronic device obtains the initial application container of the target application from the Unity platform, the initial application container including the initial resource package.
  • the first electronic device transmits the target application in the first terminal to the second terminal and obtains the initial application container of the target application from the first terminal.
  • the initial application container includes an initial resource package.
  • the target application's texture resources are obtained by decompressing the initial resource package of the target application.
  • the size of the application installation package is reduced, memory usage is optimized, and resource management is also facilitated.
  • the process of obtaining the target application texture resources of the target application is to obtain the initial resource package of the target application, which includes the initial compressed texture resources of the target application in the initial compression format; and to decompress the initial compressed texture resources to obtain the target application texture resources.
  • step 310 can be divided into: step 3101, obtaining the initial resource package of the target application, the initial resource package including the initial compressed texture resource of the target application; step 3102, decompressing the initial compressed texture resource to obtain the texture resource of the target application; step 3103, replacing the initial compressed texture resource in the initial resource package with placeholder data to obtain the updated resource package; step 3104, sending the updated resource package to the second electronic device.
  • the first electronic device can decompress the initial compressed texture resource based on the compression algorithm corresponding to the compression format name to obtain the target application texture resource.
  • the initial resource package includes not only the initial compressed texture resource but also the initial compression format name, and the first electronic device stores compression algorithms corresponding to various texture compression format names.
  • step 3102 includes: step 31021, obtaining the initial compression algorithm corresponding to the initial compression format name; step 31022, decompressing the initial compressed texture resource into the target application texture resource based on the initial compression algorithm.
  • Step 31021 includes: looking up the mapping table between format names and compression algorithms based on the initial compression format name to obtain the initial compression algorithm.
  • mapping table between format names and compression algorithms includes: looking up the mapping table between format names and compression algorithms based on the initial compression format name to obtain the initial compression algorithm.
  • the server will use the ETC algorithm as the initial compression algorithm. If the initial compression format name is ASTC, the server will use the ASTC algorithm as the initial compression algorithm. If the initial compression format name is PVRTC, the server will use the PVRTC algorithm as the initial compression algorithm. If the initial compression format name is DXT, the server will use the DXT algorithm as the initial compression algorithm.
  • the initial compressed texture resource can be decompressed based on the decompression function or decompression tool corresponding to the initial compression algorithm to obtain the target application texture resource.
  • the decompression process depends on the compression algorithm and format used. For example, the following are some common texture compression formats and decompression methods: (1) ETC (Ericsson Texture Compression): ETC is a commonly used texture compression format, often used in mobile terminals. Decompressing ETC texture resources can be done using the corresponding functions provided by graphics APIs (such as OpenGL ES). (2) ASTC (Adaptive Scalable Texture Compression): ASTC is an advanced texture compression format developed by ARM, supporting multiple compression ratios and bit depths.
  • PVRTC PowerVR Texture Compression
  • the initial compression algorithm is first determined based on the initial compression format name, and then decompression is performed based on the initial compression algorithm, thereby improving decompression efficiency.
  • the first electronic device replaces the initial compressed texture resource in the initial resource packet with placeholder data to obtain an updated resource packet.
  • Placeholder data is typically temporary data used to replace the actual data in the data packet and does not affect the parsing of the data packet.
  • using placeholder data to replace the initial compressed texture resource allows for the obtaining of an updated resource packet, and the parsing of the updated resource packet is not affected even without the initial compressed texture resource.
  • the placeholder data can be a texture resource name.
  • texture resource names can be classified according to their purpose and characteristics. For example, the following are some common texture resource names: (1) Diffuse Map: used to describe the color and lighting information of an object's surface. (2) Normal Map: used to simulate the bumps and dents of an object's surface, enhance lighting effects, and improve visual realism. (3) Specular Map: used to control the intensity and position of specular reflections on an object's surface, affecting the glossiness of the material. (4) Emission Map: used to describe the luminous parts of an object's surface, enabling self-illumination effects. (5) Roughness Map: describes the roughness of an object's surface, affecting the scattering and reflection effects of light.
  • Metallic Map describes the metallic properties of an object's surface, affecting the way light is reflected and its color.
  • Ambient Occlusion Map describes the shadows and occlusion information of an object's surface, enhancing the realism and three-dimensionality of the scene.
  • Height Map Describes the height information of an object's surface and is usually used to create bumpy terrain effects.
  • the methods for obtaining placeholder data include, but are not limited to, the following: (1) If the initial resource package also includes the name of the initial compressed texture resource, the name of the initial compressed texture resource can be obtained from the initial resource package to obtain the texture resource name, and the texture resource name can be determined as placeholder data. (2) If the initial resource package does not include the name of the initial compressed texture resource, the name can be identified based on the description function of the initial compressed texture resource to obtain the texture resource name, and the texture resource name can be determined as placeholder data.
  • the description function refers to the functions mentioned above that describe the color and lighting of the object surface, the details of the concavity and convexity, the intensity and position of the specular reflection, the luminous part, the roughness, the metallic properties, the shadow and occlusion information, and the height information.
  • the process of replacing the initial compressed texture resources in the initial resource package with the placeholder data to obtain the updated resource package can include: 1. Backing up the initial compressed texture resources; 2. Copying the placeholder data into the initial resource package, overwriting the initial compressed texture resources; 3. Updating the path or link relationship between the remaining resources in the initial resource package and the placeholder data; 4. Testing the placeholder data in the initial resource package. If it can be loaded and displayed correctly, the backup is deleted, and the initial resource package is used as the updated resource package.
  • the initial resource package stores multiple initial compressed texture resources, including initial compressed texture resource 01, initial compressed texture resource 02, and initial compressed texture resource 03, etc. Assuming the texture resource name of initial compressed texture resource 01 is diffuse map, the placeholder data is diffuse map. Replacing "initial compressed texture resource 01" with "diffuse map" in the initial resource package yields the updated resource package.
  • the updated resource package stores diffuse map, initial compressed texture resource 02, and initial compressed texture resource 03. Other initial compressed texture resources, such as initial compressed texture resource 02 and initial compressed texture resource 03, can also be replaced. Since the process is similar to replacing initial compressed texture resource 01, it will not be described in detail here.
  • the first electronic device sends an update resource package to the second electronic device. Specifically, if the terminal has not downloaded the target application, the first electronic device, in response to a download request for the target application sent by the second electronic device, sends the application container of the target application to the terminal; the application container includes application code and an update resource package. If the second electronic device has already downloaded the target application, the first electronic device, in response to a request to obtain the resource package of the target application sent by the second electronic device, sends the update resource package to the second electronic device.
  • step 32041 can be executed to change the texture resource compression format field of the updated resource package to the anchor compression format, thereby obtaining a new updated resource package; then step 3204 is executed, in which case step 3204 is implemented by step 32042, that is, the new updated resource package is sent to the second electronic device.
  • the texture resource compression format field is a field that indicates the compression format of the texture resource.
  • the initial resource package includes the initial compressed texture resource.
  • the texture resource compression format field in the initial resource package is the compression format of the initial compressed texture resource (e.g., ETC format).
  • the updated resource package no longer includes the initial compressed texture resource, but instead includes placeholder data, and the texture resource compression format field is updated to the anchor compression format.
  • the anchor compression format is a specific compression format that indicates the terminal should request texture resources from the first electronic device. Since the second electronic device may not support the anchor compression format, if the second electronic device recognizes that the texture resource compression format field is the anchor compression format, it can add a mandatory constraint to the texture processing script. This mandatory constraint indicates support for the anchor compression format. The specific process of how the second electronic device adds mandatory constraints will be described below and will not be repeated here.
  • the texture resource compression format field is changed to the anchor compression format, thereby imposing a mandatory constraint on the second electronic device.
  • the second electronic device can support the function of requesting texture resources from the first electronic device when it recognizes the anchor compression format, so that even if there are no specific texture resources in the updated resource package, the second electronic device can still obtain texture resources from the first electronic device.
  • step 320 Detailed description of step 320
  • the target application texture resource is compressed into multiple candidate compressed texture resources according to multiple candidate compression formats.
  • a candidate compression format is a data compression format used to reduce file size.
  • a candidate compression format generally corresponds to a compression algorithm.
  • candidate compression formats can include ETC, ASTC, PVRTC, DXT, etc.
  • a compression algorithm corresponding to the candidate compression format can be invoked to compress the target application texture resource to obtain a candidate compressed texture resource corresponding to the candidate compression format.
  • the candidate compression format is ETC
  • the ETC algorithm can be invoked to compress the target application texture resource to obtain a candidate compressed texture resource in ETC format.
  • step 3201 can also be executed to store multiple candidate compressed texture resources.
  • a sequence number can be set for each candidate compressed texture resource, and the candidate compressed texture resource can be stored according to the candidate storage address corresponding to the sequence number and the candidate compression format.
  • a sequence number can be set for each candidate compressed texture resource according to the order of compression time.
  • the sequence number cannot reflect the relevant information of the candidate compressed texture resource (such as the purpose of the candidate compressed texture resource), making it very cumbersome to find the candidate compressed texture resource (for example, when it is necessary to read a texture resource for a specific purpose, the candidate compressed texture resource must be read in order to determine whether it meets the requirements). Therefore, in one embodiment, the placeholder data that replaces the initial compressed texture resource in the aforementioned steps is used to determine the candidate storage address, and then the candidate compressed texture resource is stored.
  • the placeholder data is the texture resource name.
  • FIG6 is a schematic flowchart of storing multiple candidate compressed texture resources provided in the embodiments of this application.
  • step 3201 includes: step 32011, for each candidate compression format, storing the candidate compressed texture resource according to the candidate storage address corresponding to the texture resource name and the candidate compression format.
  • the candidate storage address is used to characterize the storage location of the candidate compressed texture resource corresponding to the candidate compression format.
  • step 32011 includes: obtaining a first correspondence table, which indicates the correspondence between texture resource names, candidate compression formats, and candidate storage addresses; and storing candidate compressed texture resources based on the first correspondence table.
  • a first correspondence table which indicates the correspondence between texture resource names, candidate compression formats, and candidate storage addresses.
  • the candidate storage address is XX:XX ⁇ MEh1. The same applies to other texture resource names and candidate compression formats, and will not be elaborated further.
  • the advantages of using a lookup table to determine candidate storage addresses are that it is not only simple and easy to implement, but also has low processing overhead.
  • step 32011 also includes: performing target operations on the texture resource name and candidate compression format to obtain candidate storage addresses; and storing candidate compressed texture resources according to the candidate storage addresses.
  • the target operation is a set formula or function, such as a hash function.
  • the texture resource name and candidate compression format are input into the target operation, and the output is the candidate storage address.
  • the texture resource name and candidate compression format are taken as input, a hash function generates a unique identifier, and this identifier is combined with the storage path to obtain the candidate storage address. This ensures that each candidate compressed texture resource has a unique storage address, and that candidate compressed texture resources can be retrieved based on their texture resource name and candidate compression format.
  • the method of determining candidate storage addresses through target operations is not only highly accurate, but also highly flexible as the target operations can be adjusted as needed.
  • the texture resource name is assumed to be a diffuse map.
  • the target application texture resource is compressed according to ETC format to obtain candidate compressed texture resource h1, with a candidate storage address of "XX:XX ⁇ MEh1"; the target application texture resource is compressed according to ASTC format to obtain candidate compressed texture resource MAh2, with a candidate storage address of "XX:XX ⁇ h2"; the target application texture resource is compressed according to PVRTC format to obtain candidate compressed texture resource h3, with a candidate storage address of "XX:XX ⁇ MPh3"; and the target application texture resource is compressed according to DXT format to obtain candidate compressed texture resource h4, with a candidate storage address of "XX:XX ⁇ MDh4".
  • the first electronic device stores candidate compressed texture resource h1 according to "XX:XX ⁇ MEh1"; candidate compressed texture resource h2 according to “XX:XX ⁇ MAh2"; candidate compressed texture resource h3 according to "XX:XX ⁇ MPh3"; and candidate compressed texture resource h4 according to "XX:XX ⁇ MDh4".
  • the efficiency of reading candidate compressed texture resources required by the second electronic device can be improved, while ensuring the storage of these resources is completed. For example, referring to the following, after the second electronic device identifies the placeholder data in the updated resource package, it can request candidate compressed texture resources from the first electronic device based on the placeholder data. Since the first electronic device happens to store these resources based on the placeholder data, the resource reading efficiency can be improved.
  • the first electronic device stores candidate compressed texture resources of multiple candidate compression formats, if the target compression format supported by the second electronic device may not belong to any of the multiple candidate compression formats, the first electronic device will be unable to send suitable candidate compressed texture resources to the terminal.
  • step 3201 may further include: step 32012, storing multiple candidate compressed texture resources and target application texture resources.
  • step 32012 storing multiple candidate compressed texture resources and target application texture resources.
  • step 320 A detailed description of the steps performed by the second electronic device, such as a terminal, after step 320.
  • the texture rendering method (executed by a second electronic device) includes:
  • Step 410 In response to obtaining placeholder data of the target application sent from the first electronic device, determine the target compression format supported by the second electronic device;
  • Step 420 Send a resource request to the first electronic device.
  • the resource request is used to request the target compressed texture resource.
  • the target compressed texture resource is obtained by compressing the target application texture resource using the target compression format.
  • Step 430 Receive target compressed texture resources from the first electronic device and render the target application based on the target compressed texture resources.
  • steps 410 to 430 above regardless of the compression format supported by the second electronic device, since the second electronic device does not receive the specific compressed texture resource but uses placeholder data instead, it obtains the target compressed texture resource by requesting the target compressed texture resource of the target compression format from the first electronic device, and then performs rendering. In this way, the universality of application texture rendering on terminals that support different compression formats can be improved, and the rendering efficiency of application textures can be improved.
  • the placeholder data is much smaller than the original compressed texture resource, the occupation of terminal storage space can be greatly reduced, and the waste of space resources can be reduced.
  • step 410 specifically includes receiving an application container of a target application from a first electronic device, the application container including an updated resource package, wherein the updated resource package is obtained by the first electronic device replacing the initial compressed texture resources in the initial resource package of the target application with placeholder data; in response to identifying that the updated resource package contains placeholder data, determining a target compression format supported by a second electronic device.
  • the first electronic device stores application containers for multiple candidate applications.
  • the second electronic device in response to a download operation of the target application, sends a resource download request to the first electronic device to download the resource package of the target application.
  • the multiple candidate applications include the target application.
  • the first electronic device Based on the download request from the second electronic device, sends the application container of the target application to the second electronic device.
  • the application container of the target application may include the initial resource package, but after the first electronic device executes step 3101, the initial resource package has been replaced with the updated resource package, that is, the application container of the target application sent by the first electronic device to the second electronic device includes the updated resource package.
  • the updated resource package is obtained by the first electronic device replacing the initial compressed texture resources in the target application's initial resource package with placeholder data.
  • the first electronic device can send an application container containing only the updated resource package to the second electronic device, or it can send an application container containing both the application package and the updated resource package to the second electronic device.
  • the second electronic device may need to call texture resources for rendering when running the target application.
  • the second electronic device then parses the updated resource package to extract texture resources. Since the updated resource package no longer contains actual texture resources but only placeholder data, the second electronic device cannot extract texture resources from it. Therefore, in response to recognizing the placeholder data in the resource package, the second electronic device determines the target compression format it supports, and requests compressed texture resources that the first electronic device needs to render the target application and that the second electronic device can parse, based on the target compression format.
  • step 410 includes: step 4101, running the application package through the main logic, and in response to identifying that the application package contains placeholder data during the running process, querying the target compression format supported by the second electronic device through the texture processing script.
  • this embodiment identifies placeholder data during operation through the main logic and queries the texture processing script for the target compression format through the main logic, thereby improving query efficiency.
  • the target application's runtime main logic can query the JavaScript script layer for a list of compression formats supported by the current terminal (GPU) to determine the target compression format. Because the server performs data replacement processing on the initial resource package, the "placeholder data" is not guaranteed to be supported on all terminals. Therefore, in one embodiment, when querying the list of supported compression formats, a mandatory constraint is added to the texture processing script to ensure that the "placeholder data" is always rendered by the current terminal.
  • step 4101 includes:
  • Step 41011 Run the application package through the main logic.
  • the application package contains placeholder data and the texture resource compression format field in the application package is anchor compression format
  • the mandatory constraint indicates that the anchor compression format is supported.
  • Step 41012 Send a query request to the texture processing script; wherein, the query request is used for the texture processing script to verify support for the anchor compression format based on the mandatory constraint, and to query the target compression formats supported by the second electronic device other than the anchor compression format.
  • the anchor compression format is a specific compression format that indicates the second electronic device should request texture resources from the first electronic device. Since the second electronic device may not support the anchor compression format, this embodiment adds a mandatory constraint to the texture processing script through the main logic, and this mandatory constraint indicates support for the anchor compression format.
  • the mandatory constraint is a processing script that requires support for the anchor compression format.
  • step 41012 since mandatory constraints have been added to the texture processing script, when the second electronic device sends a query request to the texture processing script, it can verify the support for the anchor compression format and obtain the supported target compression formats other than the anchor compression format.
  • the advantage of the above embodiment of adding mandatory constraints to the texture processing script is that it can ensure that any terminal can support the anchor compression format, thereby improving the effectiveness of texture resource rendering.
  • a resource request namely a request for a target compressed texture resource in a target compression format
  • This resource request may include the source address of the second electronic device, the destination address of the first electronic device, the texture resource name, and the target compression format.
  • the resource request for a target compressed texture resource in a target compression format includes the target compression format, the texture resource name, the source address, and the destination address, causing the first electronic device to send the target compressed texture resource to the second electronic device according to the target compression format and texture resource name in the resource request.
  • the resource request may also include the source address of the second electronic device, the destination address of the first electronic device, and a target storage address corresponding to the texture resource name and the target compression format, causing the first electronic device to send the target compressed texture resource to the second electronic device according to the target storage address in the request.
  • step 420 includes:
  • Step 4201 Insert a hijacking statement before the rendering function used to render the target application
  • hijacking statements refer to modifying the control flow of a computer program to execute additional operations or code. Hijacking statements are typically implemented by injecting code or modifying the program's instruction flow. Common hijacking statements include jump instructions, function calls, and variable modifications. This embodiment mainly utilizes hijacking statements to control the second electronic device to request target compressed texture resources from the first electronic device before executing the rendering function.
  • hijacking statements can be inserted before the rendering function used to render the target application in the following ways: (1) Modify the rendering loop: Add custom code directly to the rendering loop so that this code is executed before each rendering; (2) Use rendering pipeline hooks: Insert hooks at specific stages of the rendering pipeline, such as using the ID3D11 Device Context hook in DirectX or the framebuffer object hook in OpenGL; (3) Wrap the rendering function: Create a new rendering function in which custom code is executed before or after the original rendering function is called; (4) Use middleware or frameworks: Utilize the interfaces provided by existing middleware or frameworks, where the interfaces allow the insertion of custom code into the rendering process, etc. This application does not limit the scope of these methods.
  • the format within the updated resource package will definitely be "supported" by the current second electronic device. Therefore, when the target application uses texture resources for rendering, the rendering function for the target application will be executed. For example, assuming the target application is a WebGL game, the WebGLRenderingContext.compressedTexSubImage2D rendering function will ultimately be executed. By inserting a hijacking statement before the rendering function for the target application and then executing the hijacking, placeholder data in the resource package can be replaced with the target compression format, and a request for the target compressed texture resource can be sent to the first electronic device based on the target compression format in the resource package.
  • the second electronic device After the second electronic device reads the target compressed texture resource from the first electronic device into its runtime memory space, it can upload the target compressed texture resource to the GPU of the second electronic device to complete the rendering of the desired texture resource. After successful upload to the GPU, the second electronic device will immediately release the runtime memory space occupied by the target compressed texture resource.
  • the second electronic device can obtain the target compressed texture resources from the first electronic device, thereby improving the effectiveness of the target application rendering.
  • step 420 the second electronic device sends a request for the target compressed texture resource to the first electronic device. Therefore, in step 330, after receiving the request for the target compressed texture resource in the target compressed format from the second electronic device, the first electronic device can send the target compressed texture resource to the second electronic device. Then, in step 430, the second electronic device receives the target compressed texture resource from the first electronic device for rendering the target application. Therefore, step 330 will be described in detail first, followed by a detailed description of step 430.
  • step 330 Detailed description of step 330
  • step 330 is divided into: step 3301, receiving a resource request sent by the second electronic device, the resource request being sent by the second electronic device after obtaining the placeholder data, for requesting a target compressed texture resource, the target compressed texture resource being obtained by compressing the target application texture resource using a target compression format; step 3302, if the target compression format belongs to the plurality of candidate compression formats, obtaining the target compressed texture resource from the plurality of candidate compressed texture resources; step 3303, sending the target compressed texture resource to the second electronic device; wherein, the target compressed texture resource is used for the second electronic device to render the target application.
  • the resource request sent by the second electronic device to the first electronic device may include the texture resource name and the target compression format.
  • the first electronic device determines the target storage address based on the texture resource name and the target compression format in the resource request, and then obtains the target compressed texture resource based on the target storage address.
  • the resource request sent by the second electronic device to the first electronic device may directly include the target storage address (i.e., the target storage address is determined in advance by the second electronic device based on the texture resource name and the target compression format), so that the first electronic device can obtain the target compressed texture resource based on the target storage address.
  • the target storage address is determined in advance by the second electronic device based on the texture resource name and the target compression format
  • FIG11 is a flowchart of the application texture rendering method provided in the embodiments of this application.
  • step 3302 includes: step 33021a, if the target compression format belongs to multiple candidate compression formats, the target compressed texture resource is obtained according to the target storage address corresponding to the texture resource name and the target compression format, wherein the target storage address belongs to multiple candidate storage addresses.
  • the first electronic device such as a server
  • the target storage address based on the texture resource name and the target compression format, which can reduce the computational burden on the second electronic device, such as a terminal.
  • the process of storing candidate compressed texture resources according to the candidate storage address corresponding to the texture resource name and the candidate compression format can be as follows: obtaining a first correspondence table, which indicates the correspondence between the texture resource name, the candidate compression format, and the candidate storage address; and storing the candidate compressed texture resources based on the first correspondence table.
  • the target storage address can be obtained by the first electronic device by looking up the first correspondence table based on the texture resource name and the target compression format. That is, before step 33021a, if the target compression format belongs to multiple candidate compression formats, the first correspondence table can be looked up based on the texture resource name and the target compression format to obtain the target storage address; thereby, the target compressed texture resource can be obtained based on the obtained target storage address.
  • candidate compression formats include ETC, ASTC, PVRTC, and DXT formats.
  • the first correspondence table can be found in Table 2 above.
  • the first electronic device such as a server, searches the first correspondence table based on the ETC format and the diffuse map to obtain the target storage address XX:XX ⁇ MEh1.
  • the server determines the candidate compressed texture resource h1 as the target compressed texture resource based on XX:XX ⁇ MEh1 and sends it to the second electronic device, such as a terminal.
  • the server searches the first correspondence table based on the DXT format and the diffuse map to obtain the target storage address XX:XX ⁇ MDh4. The server then determines the candidate compressed texture resource h4 as the target compressed texture resource based on XX:XX ⁇ MDh4 and sends it to the terminal.
  • the process of storing candidate compressed texture resources according to the candidate storage address corresponding to the texture resource name and the candidate compression format for each candidate compression format can also be as follows: perform target operation on the texture resource name and the candidate compression format to obtain the candidate storage address; and store the candidate compressed texture resources according to the candidate storage address.
  • the target storage address can be obtained by the first electronic device by performing a target operation based on the texture resource name and the target compression format. That is, before step 33021a, a target operation can also be performed on the texture resource name and the target compression format to obtain the target storage address; thereby, the target compressed texture resource can be obtained based on the obtained target storage address.
  • the target operation is a set formula or function, such as a hash function.
  • the texture resource name and target compression format are input into the target operation, and the output is the target storage address.
  • the texture resource name and target compression format are used as input, a hash function generates a unique identifier, and this identifier is combined with the storage path to obtain the target storage address.
  • the target storage address belongs to multiple candidate storage addresses, and each candidate storage address corresponds to a candidate compressed texture resource. This allows the target compressed texture resource to be retrieved based on the target storage address.
  • determining the target storage address through target operations is not only highly accurate, but also highly flexible as the target operations can be adjusted as needed.
  • step 3302 when the resource request sent by the second electronic device to the first electronic device includes a target storage address, step 3302 includes: step 33021b, if the target compression format belongs to multiple candidate compression formats, obtain the target compressed texture resource according to the target storage address in the resource request, wherein the target storage address belongs to multiple candidate storage addresses.
  • the target storage address can be obtained by the second electronic device by looking up the first correspondence table based on the texture resource name and the target compression format, or by the second electronic device by applying a target operation to the texture resource name and the target compression format.
  • the specific implementation process of the second electronic device looking up the first correspondence table or applying the target operation can be referred to the implementation process of the first electronic device determining the target storage address above, and will not be repeated here.
  • the second electronic device such as a terminal, can determine the target storage address based on the texture resource name and the target compression format, which can reduce the computational burden on the first electronic device, such as a server.
  • the second electronic device can detect the remaining computing power of the first electronic device. If the remaining computing power is less than a predetermined computing power threshold, the second electronic device determines the target storage address based on the texture resource name and the target compression format. If the remaining computing power is greater than or equal to the predetermined computing power threshold, the second electronic device sends the texture resource name and the target compression format to the first electronic device, which then determines the target storage address based on the texture resource name and the target compression format. This balances the computing load between the second and first electronic devices.
  • step 33021a or 33021b there is one target compression format, so the target storage address determined based on the texture resource name and the target compression format is also one.
  • there are multiple target compression formats so there are multiple target storage addresses determined based on the texture resource name and multiple target compression formats, which in turn creates the need to determine the target compressed texture resource based on the target storage address corresponding to each target compression format.
  • the process of obtaining the target compressed texture resource according to the target storage address in step 33021a or step 33021b includes: if there are multiple target compression formats, obtaining the compression loss rate of each target compression format; based on the compression loss rate of each target compression format, selecting the target storage address corresponding to the target compression format with the smallest compression loss rate from the target storage addresses corresponding to each target compression format; and obtaining the target compressed texture resource based on the selected target storage address.
  • compression loss rate refers to the ratio of the amount of information lost during data compression to the total amount of original data. In lossy compression algorithms, some data is discarded to reduce file size, resulting in compression loss.
  • the target compressed texture resource can be determined based on the target storage address corresponding to the minimum compression loss rate, thereby obtaining target compressed texture resources with relatively high data quality and improving rendering accuracy.
  • the process of obtaining the target compressed texture resource according to the target storage address in step 33021a or step 33021b includes: if there are multiple target compression formats, obtaining the compression rate of each target compression format; based on the compression rate of each target compression format, selecting the target storage address corresponding to the target compression format with the largest compression rate from the target storage addresses corresponding to each target compression format; and obtaining the target compressed texture resource based on the selected target storage address.
  • the target compressed texture resource can be determined based on the target storage address corresponding to the maximum compression rate. This allows for the acquisition of target compressed texture resources with relatively small storage space, reducing the storage space occupied on the terminal. This is very suitable for terminals with limited storage space and can also improve rendering efficiency.
  • step 33021a includes:
  • Step 330211 If there are multiple target compression formats, obtain the compression loss rate and compression rate of each target compression format;
  • Step 330212 Obtain the compression gain function.
  • the compression gain function is determined based on the proportion of compressed texture resources in multiple target compression formats, the compression loss rate of each target compression format, and the compression rate.
  • Step 330213 When the compression gain function is maximized, determine the proportion of target compressed texture resources for each target compression format;
  • Step 330214 Based on the texture resource name and the target storage address corresponding to each target compression format, obtain the compressed texture resource corresponding to each target compression format, and based on the proportion of the target compressed texture resource in each target compression format and the compressed texture resource corresponding to each target compression format, obtain the compressed texture resource component corresponding to each target compression format.
  • Step 330215 Integrate the obtained compressed texture resource components of each target compression format into a target compressed texture resource.
  • this embodiment determines the target compressed texture resource based on both compression loss rate and compression rate. Furthermore, this embodiment does not simply determine the target compressed texture resource at a specific target storage address as the final target compressed texture resource; instead, it integrates the compressed texture resource components corresponding to multiple target compression formats to obtain the final target compressed texture resource.
  • the compression gain function is used to evaluate the average performance of compression algorithms corresponding to multiple target compression formats.
  • the compression gain function is determined based on the proportion of compressed texture resources in multiple target compression formats, the compression loss rate of each target compression format, and the compression rate.
  • the proportion of compressed texture resources refers to the proportion of texture resources corresponding to each target compression format.
  • the sum of the proportions of compressed texture resources of all target compression formats is 1.
  • step 330212 includes: obtaining compression gain sub-functions for each target compression format, wherein the compression gain sub-functions are determined based on the compression loss rate and compression rate of the target compression format; using the proportion of compressed texture resources of each target compression format as the weight of the compression gain sub-function of each target compression format, and performing a weighted summation of each compression gain sub-function based on the weight to obtain a compression gain function.
  • the compression loss rate and compression rate can be calculated based on the initial compressed texture resources and the target application texture resources corresponding to the target compression format.
  • the specific calculation formulas for the compression loss rate and compression rate are described above and will not be repeated here.
  • the compression gain sub-function is directly proportional to the compression loss rate and inversely proportional to the compression rate.
  • the compression gain subfunction is calculated using the following formula:
  • G ⁇ sub>t ⁇ /sub> is the compression gain subfunction of the t-th target compression format
  • R ⁇ sub> t ⁇ /sub> is the compression rate of the t-th target compression format
  • L ⁇ sub> t ⁇ /sub> is the compression loss rate of the t-th target compression format.
  • Formula (1) shows that the compression gain subfunction increases with the increase of the compression rate, that is, the higher the compression rate, the higher the compression gain coefficient.
  • Formula (1) also shows that the compression gain subfunction decreases with the increase of the compression loss rate, that is, the higher the compression loss rate, the lower the compression gain coefficient.
  • the compressed texture resource proportion indicates the proportion of texture resources in each target compression format.
  • the compression rate and compression loss rate for each target compression format are known quantities, also called constants, but the compressed texture resource proportion for each target compression format is an unknown quantity, also called a variable. Therefore, the compression gain function is a function that takes the compressed texture resource proportion of each target compression format as a variable.
  • the compression gain function is calculated using the following formula:
  • G refers to the compression gain function
  • T refers to the number of target compression formats
  • a_t is the proportion of compressed texture resources in the t-th target compression format
  • G_t is the compression gain sub-function of the t-th target compression format.
  • the target compressed texture resource proportions are known quantities, also called constants, and can be used for resource integration in subsequent steps. Therefore, in step 330213, when the compression gain function is maximized, the target compressed texture resource proportions for multiple target compression formats are determined.
  • step 330214 based on the texture resource name and the target storage address corresponding to each target compression format, the compressed texture resource corresponding to each target compression format is obtained, and based on the proportion of the target compressed texture resource in each target compression format and the compressed texture resource corresponding to each target compression format, the compressed texture resource component corresponding to each target compression format is obtained.
  • step 330215 the compressed texture resource components of each target compression format are integrated into a target compressed texture resource.
  • the three compressed texture resource components of the target compression format are integrated into a target compressed texture resource.
  • the advantage of the above embodiment which uses the maximization of the compression gain function to determine the proportion of target compressed texture resources for each target compression format, is that it can improve the accuracy and flexibility of determining the proportion of target compressed texture resources.
  • the advantage of the above embodiment which integrates compressed texture resources of various target compression formats using the target compressed texture resource ratio, is that it can improve the compression gain of the determined target compressed texture resources and improve the resource rendering quality.
  • step 430 Detailed description of step 430
  • step 430 is divided into: step 4301, receiving target compressed texture resources from the first electronic device; and step 4302, rendering the target application based on the target compressed texture resources.
  • the first electronic device sends the target compressed texture resource to the second electronic device by executing step 3303, and the second electronic device receives the target compressed texture resource from the first electronic device by executing step 4301.
  • the second electronic device can immediately execute step 4302, or it can verify the target compressed texture resource before executing step 4302. Adding a verification process can verify the validity and accuracy of the target compressed texture resource, reducing the waste of processing resources by the second electronic device due to running invalid or erroneous target compressed texture resources.
  • step 4302 includes: storing the target compressed texture resource in the target storage space and sending the target compressed texture resource to the rendering processing unit; after receiving a message from the rendering processing unit that the rendering was successful based on the target compressed texture resource, deleting the target compressed texture resource from the target storage space.
  • the target storage space refers to the storage area on the second electronic device used to store data related to the target application.
  • the target storage space stores the application container.
  • the application container includes the application package and the update resource package. If the second electronic device can store the target compressed texture resource into the update resource package, then after successful storage, the update resource package will include the target compressed texture resource.
  • the second electronic device can also store the target compressed texture resource in a space within the target storage space other than the application container.
  • the rendering processing unit is a processing unit configured to perform resource rendering, typically referring to the GPU.
  • the second electronic device After the second electronic device receives the target compressed texture resource from the first electronic device, it reads it into the target storage space of the target application and uploads it to the GPU to complete the rendering of the texture resource. After the rendering is successful, the second electronic device will immediately release the storage space occupied by the target compressed texture resource, thereby reducing space occupation while realizing rendering.
  • the corresponding texture color value can be obtained from the bound texture object through texture coordinates and texture samplers.
  • Rendering the object When rendering the object, the second electronic device mixes the texture color into the final pixel color according to the required texture information and texture coordinates to achieve the texture mapping effect.
  • the process of rendering using target compressed texture resources by the second electronic device involves steps such as loading texture resources, creating texture objects, binding texture objects, using textures in shaders, and rendering objects. These steps need to be performed in the rendering processing unit to achieve the texture mapping effect.
  • the application of texture resource rendering methods also includes a detailed description of the steps.
  • the premise for the first electronic device to send the target compressed texture resource to the terminal is that the target compression format belongs to multiple candidate compression formats.
  • the target compression format may not belong to multiple candidate compression formats, causing the first electronic device to be unable to determine the target compressed texture resource from the candidate compressed texture resources and send it to the terminal. Therefore, as mentioned above, based on Figure 6, in step 32012, not only are multiple candidate compressed texture resources stored, but also the target application texture resource is stored so that the target application texture resource can be directly sent to the second electronic device.
  • the application texture rendering method further includes: step 340 (executed by the first electronic device) and step 440 (executed by the second electronic device).
  • Step 340 can be divided into: step 3401, receiving a resource request from the second electronic device, the resource request being used to request a target compressed texture resource, the target compressed texture resource being obtained by compressing the target application texture resource using a target compression format; step 3402, if the target compression format does not belong to multiple candidate compression formats, obtaining the stored target application texture resource; step 3403, sending the target application texture resource to the second electronic device; wherein, the target compressed texture resource is used by the second electronic device to render the target application using the target application texture resource.
  • Step 440 can be divided into: step 4401, receiving the target application texture resource from the first electronic device; step 4402, rendering the target application using the target application texture resource.
  • the resource request sent by the second electronic device to the first electronic device may include a texture resource name and a target compression format.
  • the first electronic device determines the target storage address based on the texture resource name and target compression format in the request, and then obtains the target compressed texture resource based on the target storage address.
  • the resource request sent by the second electronic device to the first electronic device may directly include the target storage address (i.e., the target storage address is determined in advance by the second electronic device based on the texture resource name and the target compression format), so that the first electronic device can obtain the target compressed texture resource based on the target storage address.
  • the target storage address is determined in advance by the second electronic device based on the texture resource name and the target compression format
  • step 3402 since the target compression format does not belong to the multiple candidate compression formats, the target storage address does not belong to the multiple candidate storage addresses, which causes the first electronic device to be unable to obtain the target compressed texture resource based on the target storage address. Therefore, the first electronic device obtains the stored target application texture resource.
  • step 3403 the first electronic device sends the target application texture resource to the second electronic device.
  • step 4401 unlike step 4301 where the target compressed texture resource is received, the target compression format supported by the second electronic device does not belong to multiple candidate compression formats. Even if the target compressed texture resource is obtained, it cannot be parsed normally. Therefore, the second electronic device receives the target application texture resource, which can complete the resource rendering without terminal parsing, thus improving the effectiveness of resource rendering.
  • the advantage of the embodiments of steps 340 and 440 described above is that even if the target compression format supported by the second electronic device does not belong to multiple candidate compression formats, the second electronic device will still receive the target application texture resource sent by the server, enabling the second electronic device to perform normal rendering and improving the effectiveness of application texture resource rendering.
  • FIG. 14 is a flowchart illustrating the application texture rendering method provided in an embodiment of this application, the implementation details of the application texture rendering method in the following exemplary description will be provided in detail.
  • the server obtains the initial resource package of the target application, which includes the initial compressed texture resources of the target application in the initial compressed format.
  • the initial compression format is ETC format and the initial compressed texture resource is an initial compressed diffuse map resource
  • the initial resource package includes an initial compressed diffuse map resource in ETC format
  • the texture resource compression format field in the initial resource package is ETC format.
  • the server decompresses the initial compressed texture resources into the target application texture resources, replaces the initial compressed texture resources in the initial resource package with placeholder data to obtain the updated resource package, changes the texture resource compression format field of the updated resource package to the anchor compression format, and sends the updated resource package to the terminal.
  • the server decompresses the initial compressed diffuse map resource into the target application's diffuse map resource, replaces the initial compressed diffuse map resource in the initial resource package with placeholder data (the placeholder data is specifically "diffuse map"), and the server also changes the texture resource compression format field from ETC format to anchor compression format, and sends the updated resource package to the terminal.
  • the server compresses the target application texture resources into multiple candidate compressed texture resources according to multiple candidate compression formats.
  • candidate compression formats can be ETC, ASTC, PVRTC, and DXT formats.
  • the corresponding candidate compressed texture resource is h1 for ETC format, h2 for ASTC format, h3 for PVRTC format, and h4 for DXT format.
  • the server stores multiple candidate compressed texture resources according to the candidate storage address corresponding to the texture resource name and candidate compression format, as well as the target application texture resources.
  • multiple candidate storage addresses include: XX:XX ⁇ MEh1 for ETC format, XX:XX ⁇ MAh2 for ASTC format, XX:XX ⁇ MPh3 for PVRTC format, and XX:XX ⁇ MDh4 for DXT format, etc.
  • the terminal receives the application container of the target application from the server.
  • the application container includes an application package and an update resource package.
  • the update resource package includes placeholder data and a texture resource compression format field.
  • the terminal runs the application package through the main logic.
  • a mandatory constraint is added to the texture processing script.
  • the mandatory constraint indicates that the anchor compression format is supported.
  • the terminal sends a query request to the texture processing script so that the texture processing script can verify support for the anchor compression format based on mandatory constraints and query the target compression formats supported by the terminal other than the anchor compression format.
  • the target compression format supported by the terminal is the ASTC format.
  • the terminal inserts a hijacking statement before the rendering function used to render the target application; then the terminal executes the hijacking statement to replace the placeholder data in the update resource package with the target compression format.
  • the terminal sends a request for the target compressed texture resource to the server based on the target compression format in the resource package.
  • the request may include the texture resource name and the target compression format.
  • the terminal replaces placeholder data in the update resource pack with ASTC format, and the request sent by the terminal to the server includes diffuse texture and ASTC format.
  • the server When the server receives a request from the terminal for a target compressed texture resource in a target compression format supported by the terminal, if the target compression format belongs to multiple candidate compression formats, the server retrieves the target compressed texture resource according to the target storage address corresponding to the texture resource name and the target compression format, and sends it to the terminal.
  • the server receives a request from the terminal for a target compressed texture resource in a target compression format supported by the terminal, if the target compression format does not belong to multiple candidate compression formats, the server retrieves the stored target application texture resource and sends it to the terminal.
  • the terminal receives the target compressed texture resource from the server to render the target application; or, the terminal receives the target application texture resource from the server to render the target application.
  • This application effectively solves the problem of fixed compression formats in personalized resource packages for target applications (such as WebGL games) distributed by the Unity platform on different terminals.
  • the texture resources in this application are truly loaded on demand—that is, only loaded into memory when rendering is required—and the texture resource file is used as the smallest granularity, the granularity is finer than the Unity resource package solution provided by the Unity platform, avoiding additional memory consumption caused by other idle resources within the AB package. It also eliminates the problem of redundant disk and memory space usage caused by the same resource being repeatedly packaged in multiple Unity resource packages.
  • this application only processes the exported application container, so no modification or editing of the application package's code is required.
  • the conversion can be completed simply through the panel, making it easy to use widely.
  • This application has high universality and reduces the memory space occupied on the terminal.
  • steps in the above flowcharts are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated in the embodiments of this application, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the above flowcharts may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps.
  • Figure 15 is a structural schematic diagram of an application texture rendering apparatus 1500 applied to a first electronic device according to an embodiment of this application. Based on Figure 15, the application texture rendering apparatus 1500 specifically includes:
  • the first sending unit 1510 is configured to acquire the target application texture resources and placeholder data of the target application, and send the placeholder data to the second electronic device.
  • Compression unit 1520 is configured to compress the target application texture resource into multiple candidate compressed texture resources according to multiple candidate compression formats
  • the second sending unit 1530 is configured to receive a resource request sent by the second electronic device.
  • the resource request is sent by the second electronic device after obtaining the placeholder data, and is used to request a target compressed texture resource.
  • the target compressed texture resource is obtained by compressing the target application texture resource using a target compression format. If the target compression format belongs to the plurality of candidate compression formats, the target compressed texture resource is obtained from the plurality of candidate compressed texture resources, and the target compressed texture resource is sent to the second electronic device.
  • the target compressed texture resource is used by the second electronic device to render the target application.
  • the first transmitting unit 1510 is further configured to:
  • the initial resource package of the target application including the initial compressed texture resources of the target application in the initial compression format
  • the initial compressed texture resource is decompressed to obtain the target application texture resource.
  • the initial resource packet further includes an initial compression format name; the first sending unit 1510 is also configured to:
  • the initially compressed texture resources are decompressed into the target application texture resources.
  • the apparatus further includes a first acquisition unit, configured to:
  • the initial resource package includes the initial compressed texture resources of the target application
  • the first transmitting unit 1510 is also configured as follows:
  • the apparatus further includes an updating unit, configured to:
  • the first transmitting unit 1510 is also configured as follows:
  • the second electronic device When the second electronic device identifies the texture resource compression format field as the anchor compression format, it adds a mandatory constraint to the texture processing script, the mandatory constraint indicating support for the anchor compression format.
  • the placeholder data is a texture resource name
  • the resource request includes the texture resource name and the target compression format
  • the apparatus further includes a storage unit configured as follows:
  • the candidate compressed texture resources are stored according to the candidate storage address corresponding to the texture resource name and the candidate compression format;
  • the second sending unit 1530 is further configured to: if the target compression format belongs to the plurality of candidate compression formats, obtain the target compressed texture resource according to the target storage address corresponding to the texture resource name and the target compression format, wherein the target storage address belongs to the plurality of candidate storage addresses.
  • the storage unit is further configured as follows:
  • the second transmitting unit 1530 is also configured as follows:
  • the target operation is performed on the texture resource name and the target compression format to obtain the target storage address.
  • the storage unit is further configured as follows:
  • the candidate compressed texture resources are stored
  • the second transmitting unit 1530 is also configured as follows:
  • the placeholder data is a texture resource name
  • the resource request includes a target storage address
  • the target storage address is determined by the second electronic device based on the texture resource name and the target compression format
  • the storage unit is further configured as follows:
  • the candidate compressed texture resources are stored according to the candidate storage address corresponding to the texture resource name and the candidate compression format;
  • the second transmitting unit 1530 is also configured as follows:
  • the number of target compression formats is multiple;
  • the second transmitting unit 1530 is also configured as follows:
  • the compression gain function which is determined based on the proportion of compressed texture resources in multiple target compression formats, the compression loss rate of each target compression format, and the compression rate.
  • the proportion of target compressed texture resources for each target compression format is determined.
  • each target compression format Based on the texture resource name and the target storage address corresponding to each target compression format, obtain the compressed texture resources corresponding to each target compression format. Based on the proportion of the target compressed texture resources in each target compression format and the compressed texture resources corresponding to each target compression format, obtain the compressed texture resource components corresponding to each target compression format. Integrate the obtained compressed texture resource components of each target compression format into a target compressed texture resource.
  • the second transmitting unit 1530 is further configured to:
  • the compression gain sub-function is determined based on the compression loss rate and compression rate of the target compression format.
  • the proportion of compressed texture resources in each target compression format is used as the weight of the compression gain sub-function of each target compression format. Based on this weight, the compression gain sub-functions are weighted and summed to obtain the compression gain function.
  • the second transmitting unit 1530 is further configured to:
  • the target storage address corresponding to the target compression format with the highest compression rate is selected from the target storage addresses corresponding to each target compression format;
  • the target compressed texture resource is obtained.
  • the second transmitting unit 1530 is further configured to:
  • the stored target application texture resource is obtained and sent to the second electronic device.
  • FIG 16 is a schematic diagram of an application texture rendering apparatus 1600 for a second electronic device provided in an embodiment of this application.
  • the application texture rendering apparatus 1600 specifically includes:
  • the determining unit 1610 is configured to determine a target compression format supported by the second electronic device in response to receiving placeholder data of a target application sent from the first electronic device.
  • the third sending unit 1620 is configured to send a resource request to the first electronic device.
  • the resource request is used to request a target compressed texture resource.
  • the target compressed texture resource is obtained by compressing a target application texture resource using a target compression format.
  • the first receiving unit 1630 is configured to receive the target compressed texture resource from the first electronic device and render the target application based on the target compressed texture resource; wherein, when the first electronic device sends the placeholder data of the target application, it also compresses the acquired target application texture resource into multiple candidate compressed texture resources according to multiple candidate compression formats; the multiple candidate compression formats include the target compression format, and the multiple candidate compressed texture resources include the target compressed texture resource.
  • the determining unit 1610 is further configured to:
  • the application package is run by the main logic.
  • a mandatory constraint is added to the texture processing script.
  • the mandatory constraint indicates support for the anchor compression format.
  • a query request is sent to the texture processing script; wherein the query request is used for the texture processing script to verify support for the anchor compression format based on the mandatory constraints, and to query the target compression formats supported by the second electronic device other than the anchor compression format.
  • the third transmitting unit 1620 is configured as follows:
  • the hijacking statement is executed to replace the placeholder data in the application package with the target compression format and to send the resource request to the first electronic device based on the target compression format in the application package.
  • the first receiving unit 1630 is configured as follows:
  • the target compressed texture resource is stored in the target storage space, and the target compressed texture resource is sent to the rendering processing unit;
  • the second electronic device may be a terminal, including: a radio frequency (RF) circuit 1710, a memory 1715, an input unit 1730, a display unit 1740, a sensor 1750, an audio circuit 1760, a wireless fidelity (WiFi) module 1770, a processor 1780, and a power supply 1790, etc.
  • RF radio frequency
  • the memory 1715 can be configured to store software programs and modules, and the processor 1780 executes various functional applications and data processing of the content terminal by running the software programs and modules stored in the memory 1715.
  • the input unit 1730 can be configured to receive input numeric or character information, and to generate key signal inputs related to the settings and function control of the content terminal.
  • the input unit 1730 may include a touch panel 1731 and other input devices 1732.
  • Audio circuitry 1760, speaker 1761, and microphone 1762 provide an audio interface.
  • the processor 1780 included in the terminal can execute the application texture rendering method of the previous embodiment.
  • FIG. 18 is a partial structural block diagram of a first electronic device using the texture rendering method provided in an embodiment of this application.
  • the first electronic device such as a server, can vary significantly depending on its configuration or performance. It may include one or more central processing units (CPUs) 1822 (e.g., one or more processors) and a memory 1832, and one or more storage media 1830 (e.g., one or more mass storage devices) storing application programs 1842 or data 1844.
  • the memory 1832 and storage media 1830 may be temporary or persistent storage.
  • the program stored in the storage media 1830 may include one or more modules (not shown in the figure), each module including a series of instruction operations on the server.
  • the CPU 1822 may be configured to communicate with the storage media 1830 and execute the series of instruction operations in the storage media 1830 on the server.
  • This application provides a computer-readable storage medium storing computer-executable instructions.
  • the processor will execute the application texture rendering method provided in this application.
  • This application provides a computer program product including computer-executable instructions stored in a computer-readable storage medium.
  • a processor of an electronic device reads the computer-executable instructions from the computer-readable storage medium and executes the computer-executable instructions, causing the computer device to perform the application texture rendering method described above.
  • At least one (item) refers to one or more, and “more than one” refers to two or more.
  • “And/or” is used to describe the relationship between related content, indicating that three relationships can exist. For example, “A and/or B” can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character “/” generally indicates that the preceding and following related content are in an “or” relationship. "At least one (item) of the following” or similar expressions refer to any combination of these items, including any combination of single or plural items.
  • At least one (item) of a, b, or c can represent: a, b, c, "a and b", “a and c", “b and c", or "a and b and c", where a, b, and c can be single or multiple.
  • the disclosed systems, apparatuses, and methods can be implemented in other ways.
  • the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods.
  • multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.
  • the couplings or direct couplings or communication connections shown or discussed may be indirect couplings or communication connections between devices or units through some interfaces, and may be electrical, mechanical, or other forms.
  • the units described as separate components may or may not be physically separate.
  • the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
  • the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
  • the integrated unit can be implemented in hardware or as a software functional unit.
  • the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium.
  • This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server 130, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application.
  • the aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Image Generation (AREA)

Abstract

Provided in the present application are an application texture rendering method and apparatus, and an electronic device, a computer-readable storage medium and a computer program product. The method comprises: acquiring a target application texture resource and placeholder data of a target application, and sending the placeholder data to a second electronic device; according to a plurality of candidate compression formats, respectively compressing the target application texture resource into a plurality of candidate compressed texture resources; receiving a resource request sent by the second electronic device, wherein the resource request is sent by the second electronic device after acquiring the placeholder data, and the resource request is used for requesting a target compressed texture resource, the target compressed texture resource being obtained by using a target compression format to compress the target application texture resource; and if the target compression format is one of the plurality of candidate compression formats, acquiring the target compressed texture resource from among the plurality of candidate compressed texture resources, and sending the target compressed texture resource to the second electronic device.

Description

应用纹理渲染方法、装置、电子设备、计算机可读存储介质以及计算机程序产品Applications of texture rendering methods, apparatuses, electronic devices, computer-readable storage media, and computer program products

相关申请的交叉引用Cross-references to related applications

本申请实施例基于申请号为202410517067.6、申请日为2024年04月28日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请实施例作为参考。This application is based on Chinese Patent Application No. 202410517067.6, filed on April 28, 2024, and claims priority to that Chinese Patent Application, the entire contents of which are incorporated herein by reference.

技术领域Technical Field

本申请涉及图像渲染领域,特别是涉及一种应用纹理渲染方法、装置、电子设备、计算机可读存储介质以及计算机程序产品。This application relates to the field of image rendering, and in particular to an applied texture rendering method, apparatus, electronic device, computer-readable storage medium, and computer program product.

背景技术Background Technology

目前,在诸如电子游戏的应用中,随着用户使用到应用的不同阶段,需要根据该阶段的各显示对象的纹理,进行纹理渲染,得到显示的应用画面。纹理体现了物体表面的具有缓慢变化或者周期性变化的表面结构组织排列属性。通俗地理解,纹理是显示的对象的图案,例如游戏人物皮肤、宝剑上的图案等。Currently, in applications such as video games, as users progress through different stages of the application, texture rendering is required based on the textures of the displayed objects at each stage to obtain the displayed application screen. Texture reflects the surface structure and arrangement properties of an object, exhibiting slow or periodic changes. Simply put, texture is the pattern of the displayed object, such as the skin of a game character or the pattern on a sword.

不同的终端具有不同的纹理压缩格式。如果在应用出厂时设置的应用的纹理的压缩格式不同于终端中支持的压缩格式,则应用的压缩纹理得不到很好的渲染,使用会出现问题;如果要将基于各种压缩格式的压缩纹理都提前发送给终端,则占用终端存储空间。Different devices use different texture compression formats. If the compression format of the application's textures is set at the factory to be different from the compression format supported by the device, the compressed textures of the application will not be rendered well, and problems will occur. If compressed textures based on various compression formats are sent to the device in advance, it will occupy the device's storage space.

发明内容Summary of the Invention

本申请实施例提供了一种应用纹理渲染方法、装置、电子设备、计算机可读存储介质以及计算机程序产品,能够提高应用纹理渲染在支持不同压缩格式的终端上的普适性,并减少对终端存储空间的占用。This application provides an application texture rendering method, apparatus, electronic device, computer-readable storage medium, and computer program product, which can improve the universality of application texture rendering on terminals that support different compression formats and reduce the occupation of terminal storage space.

根据本申请实施例的一方面,提供了一种应用纹理渲染方法,所述方法由第一电子设备执行,所述方法包括:According to one aspect of the embodiments of this application, an application texture rendering method is provided, the method being executed by a first electronic device, the method comprising:

获取目标应用的目标应用纹理资源及占位符数据,并发送所述占位符数据至第二电子设备;Obtain the target application texture resources and placeholder data of the target application, and send the placeholder data to the second electronic device;

按照多个候选压缩格式,将所述目标应用纹理资源分别压缩为多个候选压缩纹理资源;The target application texture resources are compressed into multiple candidate compressed texture resources according to multiple candidate compression formats;

接收所述第二电子设备发送的资源请求,所述资源请求为所述第二电子设备获取到所述占位符数据后发送的,用于请求目标压缩纹理资源,所述目标压缩纹理资源为,采用目标压缩格式对所述目标应用纹理资源进行压缩得到的;The system receives a resource request sent by the second electronic device. The resource request is sent by the second electronic device after it obtains the placeholder data. The request is for requesting a target compressed texture resource. The target compressed texture resource is obtained by compressing the target application texture resource using a target compression format.

如果所述目标压缩格式属于所述多个候选压缩格式,从所述多个候选压缩纹理资源中获取所述目标压缩纹理资源,并将所述目标压缩纹理资源发送到所述第二电子设备;If the target compression format belongs to the plurality of candidate compression formats, the target compressed texture resource is obtained from the plurality of candidate compressed texture resources, and the target compressed texture resource is sent to the second electronic device;

其中,所述目标压缩纹理资源用于,供所述第二电子设备进行所述目标应用的渲染。The target compressed texture resource is used for rendering the target application by the second electronic device.

根据本申请实施例的一方面,提供了一种应用纹理渲染装置,所述装置包括:According to one aspect of the embodiments of this application, an application texture rendering apparatus is provided, the apparatus comprising:

第一发送单元,配置为获取目标应用的目标应用纹理资源及占位符数据,并发送所述占位符数据至第二电子设备;The first sending unit is configured to acquire the target application texture resources and placeholder data of the target application, and send the placeholder data to the second electronic device;

压缩单元,配置为按照多个候选压缩格式,将所述目标应用纹理资源分别压缩为多个候选压缩纹理资源;The compression unit is configured to compress the target application texture resource into multiple candidate compressed texture resources according to multiple candidate compression formats;

第二发送单元,配置为接收所述第二电子设备发送的资源请求,所述资源请求为所述第二电子设备获取到所述占位符数据后发送的,用于请求目标压缩纹理资源,所述目标压缩纹理资源为,采用目标压缩格式对所述目标应用纹理资源进行压缩得到的;如果所述目标压缩格式属于所述多个候选压缩格式,从所述多个候选压缩纹理资源中获取所述目标压缩纹理资源,并将所述目标压缩纹理资源发送到所述第二电子设备;其中,所述目标压缩纹理资源用于,供所述第二电子设备进行所述目标应用的渲染。The second sending unit is configured to receive a resource request sent by the second electronic device. The resource request is sent by the second electronic device after obtaining the placeholder data, and is used to request a target compressed texture resource. The target compressed texture resource is obtained by compressing the target application texture resource using a target compression format. If the target compression format belongs to the plurality of candidate compression formats, the unit obtains the target compressed texture resource from the plurality of candidate compressed texture resources and sends the target compressed texture resource to the second electronic device. The target compressed texture resource is used by the second electronic device to render the target application.

根据本申请实施例的一方面,提供了一种应用纹理渲染方法,所述方法由第二电子设备执行,所述方法包括:According to one aspect of the embodiments of this application, an application texture rendering method is provided, the method being executed by a second electronic device, the method comprising:

响应于获取到从第一电子设备发送的目标应用的占位符数据,确定所述第二电子设备支持的目标压缩格式;In response to receiving placeholder data of the target application sent from the first electronic device, the target compression format supported by the second electronic device is determined;

向所述第一电子设备发送资源请求,所述资源请求用于请求目标压缩纹理资源,所述目标压缩纹理资源为,采用目标压缩格式对目标应用纹理资源进行压缩得到的;Send a resource request to the first electronic device. The resource request is used to request a target compressed texture resource. The target compressed texture resource is obtained by compressing the target application texture resource using a target compression format.

从所述第一电子设备接收所述目标压缩纹理资源,并基于所述目标压缩纹理资源进行所述目标应用的渲染;Receive the target compressed texture resource from the first electronic device, and render the target application based on the target compressed texture resource;

其中,所述第一电子设备发送所述目标应用的占位符数据时,还按照多个候选压缩格式,将获取的目标应用纹理资源分别压缩为多个候选压缩纹理资源;所述多个候选压缩格式包括所述目标压缩格式,多个所述候选压缩纹理资源包括所述目标压缩纹理资源。When the first electronic device sends the placeholder data of the target application, it also compresses the acquired target application texture resources into multiple candidate compressed texture resources according to multiple candidate compression formats; the multiple candidate compression formats include the target compression format, and the multiple candidate compressed texture resources include the target compressed texture resource.

根据本申请实施例的一方面,提供了一种应用纹理渲染装置,所述装置包括:According to one aspect of the embodiments of this application, an application texture rendering apparatus is provided, the apparatus comprising:

确定单元,配置为响应于获取到从第一电子设备发送的目标应用的占位符数据,确定所述第二电子设备支持的目标压缩格式;The determining unit is configured to determine the target compression format supported by the second electronic device in response to receiving placeholder data of the target application sent from the first electronic device;

第三发送单元,配置为向所述第一电子设备发送资源请求,所述资源请求用于请求目标压缩纹理资源,所述目标压缩纹理资源为,采用目标压缩格式对目标应用纹理资源进行压缩得到的;The third sending unit is configured to send a resource request to the first electronic device. The resource request is used to request a target compressed texture resource. The target compressed texture resource is obtained by compressing a target application texture resource using a target compression format.

第二接收单元,配置为从所述第一电子设备接收所述目标压缩纹理资源,并基于所述目标压缩纹理资源进行所述目标应用的渲染;其中,所述第一电子设备发送所述目标应用的占位符数据时,还按照多个候选压缩格式,将获取的目标应用纹理资源分别压缩为多个候选压缩纹理资源;所述多个候选压缩格式包括所述目标压缩格式,多个所述候选压缩纹理资源包括所述目标压缩纹理资源。The second receiving unit is configured to receive the target compressed texture resource from the first electronic device and render the target application based on the target compressed texture resource; wherein, when the first electronic device sends the placeholder data of the target application, it also compresses the acquired target application texture resource into multiple candidate compressed texture resources according to multiple candidate compression formats; the multiple candidate compression formats include the target compression format, and the multiple candidate compressed texture resources include the target compressed texture resource.

根据本申请实施例的一方面,提供了一种电子设备,包括:According to one aspect of the embodiments of this application, an electronic device is provided, including:

存储器,配置为存储计算机可执行指令或计算机程序;Memory, configured to store computer-executable instructions or computer programs;

处理器,配置为执行所述存储器中存储的计算机可执行指令或计算机程序时,实现如上所述的应用纹理渲染方法。When a processor is configured to execute computer-executable instructions or computer programs stored in the memory, it implements the application texture rendering method as described above.

根据本申请实施例的一方面,该计算机程序产品包括计算机可执行指令或计算机程序,处理器执行该计算机可执行指令或计算机程序,实现如上所述的应用纹理渲染方法。According to one aspect of the embodiments of this application, the computer program product includes computer-executable instructions or a computer program, and the processor executes the computer-executable instructions or the computer program to implement the application texture rendering method as described above.

根据本申请实施例的一方面,提供了一种计算机程序产品,该计算机程序产品包括计算机可执行指令或计算机程序,处理器执行该计算机可执行指令或计算机程序,使得该计算机设备执行如上所述的应用纹理渲染方法。According to one aspect of the embodiments of this application, a computer program product is provided, the computer program product including computer executable instructions or a computer program, wherein a processor executes the computer executable instructions or computer program, causing the computer device to perform the application texture rendering method as described above.

本申请实施例中,在第一电子设备端出厂配置时,获取目标应用的目标应用纹理资源及占位符数据,并按照多个候选压缩格式,将目标应用纹理资源压缩为多个候选压缩纹理资源存储起来;然后,将占位符数据发送用户的第二电子设备。这样,第二电子设备没有接收到任何压缩格式的压缩纹理资源,当第二电子设备实际进行应用的渲染时,第二电子设备可以获取到占位符数据,于是确定第二电子设备支持的目标压缩格式,向第一电子设备发送资源请求,从而基于资源请求,请求采用目标压缩格式对目标应用纹理资源压缩得到的目标压缩纹理资源。由于第一电子设备事先存储了各种候选压缩格式的候选压缩纹理资源,因此,在接收到资源请求后,就可以基于资源请求,从候选压缩纹理资源中获取目标压缩纹理资源,并将目标压缩纹理资源发送到第二电子设备,从而第二电子设备利用目标压缩纹理资源进行目标应用的渲染。在这个过程中,无论第二电子设备支持哪一种压缩格式,由于没有接收到具体的压缩纹理资源,因此,在获取到占位符数据后,通过向第一电子设备请求目标压缩格式的目标压缩纹理资源,来获得目标压缩纹理资源,从而进行渲染。这样,能够提高应用纹理渲染在支持不同压缩格式的终端上的普适性,提高了应用纹理的渲染效率;同时,由于占位符数据远比始压缩纹理资源要小,可以大大减少对终端存储空间的占用,减少了空间资源的浪费。In this embodiment, during factory configuration of the first electronic device, the target application texture resources and placeholder data of the target application are acquired, and the target application texture resources are compressed into multiple candidate compressed texture resources according to multiple candidate compression formats and stored. Then, the placeholder data is sent to the user's second electronic device. Thus, the second electronic device does not receive any compressed texture resources of any compression format. When the second electronic device actually renders the application, it can acquire the placeholder data, determine the target compression format it supports, and send a resource request to the first electronic device. Based on the resource request, it requests the target compressed texture resources obtained by compressing the target application texture resources using the target compression format. Since the first electronic device has pre-stored candidate compressed texture resources of various candidate compression formats, upon receiving the resource request, it can obtain the target compressed texture resources from the candidate compressed texture resources and send them to the second electronic device, thereby enabling the second electronic device to render the target application using the target compressed texture resources. In this process, regardless of the compression format supported by the second electronic device, since it has not received the actual compressed texture resource, after obtaining the placeholder data, it requests the target compressed texture resource of the target compression format from the first electronic device to obtain the target compressed texture resource for rendering. This improves the universality of application texture rendering on terminals supporting different compression formats and increases the rendering efficiency of application textures. Simultaneously, because the placeholder data is much smaller than the original compressed texture resource, it significantly reduces the amount of storage space occupied on the terminal, minimizing wasted space resources.

本申请实施例的其他特征和优点将在随后的说明书中阐述,并且,部分地从说明书中变得显而易见,或者通过本申请实施例而了解。本申请实施例的目的和其他优点可通过在说明书、权利要求书以及附图中所特别指出的结构来实现和获得。Other features and advantages of the embodiments of this application will be set forth in the following description, and will be apparent in part from the description, or may be learned by means of the embodiments of this application. The objects and other advantages of the embodiments of this application may be realized and obtained by means of the structures particularly pointed out in the description, claims, and drawings.

附图说明Attached Figure Description

附图用来提供对本申请实施例的技术方案的进一步理解,并且构成说明书的一部分,与本申请实施例一起用于解释本申请的技术方案,并不构成对本申请实施例的技术方案的限制。The accompanying drawings are used to provide a further understanding of the technical solutions of the embodiments of this application and constitute a part of the specification. They are used together with the embodiments of this application to explain the technical solutions of this application and do not constitute a limitation on the technical solutions of the embodiments of this application.

图1是本申请实施例提供的应用纹理渲染方法所应用的系统构架图;Figure 1 is a system architecture diagram of the application texture rendering method provided in the embodiments of this application;

图2是本申请实施例提供的更换终端的场景的示意图;Figure 2 is a schematic diagram of a terminal replacement scenario provided in an embodiment of this application;

图3是本申请实施例提供的应用纹理渲染方法的流程示意图;Figure 3 is a flowchart illustrating the application texture rendering method provided in an embodiment of this application;

图4是本申请实施例提供的应用纹理渲染方法的流程图;Figure 4 is a flowchart of the application texture rendering method provided in an embodiment of this application;

图5是本申请实施例提供的初始资源和更新资源包的示意图;Figure 5 is a schematic diagram of the initial resources and updated resource packages provided in the embodiments of this application;

图6是本申请实施例提供的存储多个候选压缩纹理资源的流程示意图;Figure 6 is a schematic diagram of the process for storing multiple candidate compressed texture resources provided in an embodiment of this application;

图7是本申请实施例提供的压缩过程的示意图;Figure 7 is a schematic diagram of the compression process provided in an embodiment of this application;

图8是本申请实施例提供的应用纹理渲染方法的流程示意图;Figure 8 is a flowchart illustrating the application texture rendering method provided in an embodiment of this application;

图9是本申请实施例提供的资源请求的示意图;Figure 9 is a schematic diagram of a resource request provided in an embodiment of this application;

图10是本申请实施例提供的发送资源请求的流程示意图;Figure 10 is a schematic diagram of the process of sending a resource request provided in an embodiment of this application;

图11是本申请实施例提供的应用纹理渲染方法的流程示意图;Figure 11 is a flowchart illustrating the application texture rendering method provided in an embodiment of this application;

图12是本申请实施例提供的确定目标压缩纹理资源的流程示意图;Figure 12 is a schematic diagram of the process for determining the target compressed texture resource provided in an embodiment of this application;

图13是本申请实施例提供的应用纹理渲染方法的流程示意图;Figure 13 is a flowchart illustrating the application texture rendering method provided in an embodiment of this application;

图14是本申请实施例提供的应用纹理渲染方法的流程示意图;Figure 14 is a flowchart illustrating the application texture rendering method provided in an embodiment of this application;

图15是本申请实施例提供的应用于第一电子设备的应用纹理渲染装置1500的结构示意图;Figure 15 is a schematic diagram of the structure of an application texture rendering device 1500 for a first electronic device provided in an embodiment of this application;

图16是本申请实施例提供的应用于第二电子设备的应用纹理渲染装置1600的结构示意图;Figure 16 is a schematic diagram of the structure of an application texture rendering device 1600 for a second electronic device provided in an embodiment of this application;

图17是本申请实施例提供的应用纹理渲染方法的第二电子设备的部分的结构框图;Figure 17 is a partial structural block diagram of the second electronic device using the texture rendering method provided in an embodiment of this application;

图18是本申请实施例提供的应用纹理渲染方法的第一电子设备的部分的结构框图。Figure 18 is a structural block diagram of a portion of the first electronic device for applying the texture rendering method provided in an embodiment of this application.

具体实施方式Detailed Implementation

为了使本申请实施例的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请实施例进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本申请实施例,并不用于限定本申请实施例。To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the embodiments of this application will be further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the embodiments of this application and are not intended to limit the embodiments of this application.

对本申请实施例进行进一步详细说明之前,对本申请实施例中涉及的名词和术语进行说明,本申请实施例中涉及的名词和术语适用于如下的解释:Before providing a further detailed description of the embodiments of this application, the nouns and terms used in the embodiments of this application are explained, and the nouns and terms used in the embodiments of this application shall be interpreted as follows:

应用:通常指的是软件程序或系统,用于执行特定任务或提供特定功能。应用程序可以是各种类型,包括移动应用、桌面应用、Web应用等。Web应用包括WebGL游戏。Application: This typically refers to a software program or system used to perform a specific task or provide a specific function. Applications can be of various types, including mobile applications, desktop applications, web applications, etc. Web applications include WebGL games.

WebGL游戏:是使用WebGL(Web Graphics Library)技术开发的游戏。指遵循HTML5标准下运行于画布(Canvas)元素中,渲染技术基于WebGL实现的游戏作品。对WebGL游戏的渲染中常常需要用到纹理资源。WebGL games are games developed using WebGL (Web Graphics Library) technology. They refer to games that run on a canvas element and conform to HTML5 standards, with rendering technology based on WebGL. Texture resources are often required for rendering WebGL games.

纹理资源:又称材质贴图资源,指一种可用于包裹在3D模型表面、精灵上的位图资源。较为常见的贴图资源以PNG、JPEG格式为主。为了减小纹理资源的存储大小,可以进行纹理压缩。Texture resources, also known as material mapping resources, refer to bitmap resources that can be wrapped around the surface of 3D models or sprites. Common texture resources are primarily in PNG and JPEG formats. Texture compression can be used to reduce the storage size of texture resources.

纹理压缩:一种专为计算机图形渲染系统中存储纹理贴图资源的图像压缩技术,该压缩算法对存储大小以及随机存取做了优化。常见的纹理压缩格式名称为爱立信纹理压缩(Ericsson Texture Compression,ETC或Ericsson Texture Compression 2,ETC2)、自适应可伸缩纹理压缩(Adaptive Scalable Texture Compression,ASTC)、PowerVR纹理压缩(PowerVR Texture Compression,PVRTC)、DXT1、DXT5等。Texture compression: An image compression technique specifically designed for storing texture map resources in computer graphics rendering systems. This compression algorithm optimizes storage size and random access. Common texture compression formats include Ericsson Texture Compression (ETC or Ericsson Texture Compression 2, ETC2), Adaptive Scalable Texture Compression (ASTC), PowerVR Texture Compression (PVRTC), DXT1, and DXT5.

Unity小游戏:特指使用Unity平台开发并在小游戏平台中运行的游戏作品。Unity平台可以用来开发各种类型的游戏,并且可以输出为WebGL格式,从而得到WebGL游戏。Unity Mini-Games: Specifically refers to games developed using the Unity platform and run on mini-game platforms. The Unity platform can be used to develop various types of games and can output them in WebGL format, thus creating WebGL games.

AB包:全名AssetBundle,指Unity平台提供的游戏资源存档文件,可存储游戏运行时所需要的非代码资源(比如模型、纹理、预制体、场景以及媒体文件)。AB package: full name AssetBundle, refers to the game resource archive file provided by the Unity platform, which can store non-code resources (such as models, textures, prefabs, scenes and media files) needed for game runtime.

首包资源:特指Unity平台导出WebGL游戏资源时的存储首场景中的资源文件,默认以unityweb后缀结尾,在Unity小游戏启动时被优先加载的资源文件,首包资源中包含首场景资源内容及附属AB包资源。First package resources: Specifically refers to the resource files stored in the first scene when exporting WebGL game resources from the Unity platform. They end with the unityweb suffix by default and are the resource files that are loaded first when the Unity mini-game starts. The first package resources include the resource content of the first scene and the resources of the attached AB packages.

Unity资源包:对AB包、首包资源的统称。Unity resource packs: a collective term for resources in AB packs and the first pack.

相关技术中,Unity平台已为游戏开发者提供纹理资源的压缩处理能力,通常而言Unity小游戏是以终端独立发行的方式进行游戏发布,即iOS、Android、Windows分别导出不同的游戏客户端。通过对各个终端所支持的纹理资源的格式进行区分配置,在游戏资源导出Unity资源包时将纹理资源根据终端支持的格式类型进行转换,写入Unity资源包内已经是对应的压缩纹理格式的压缩纹理资源,从而在游戏运行阶段可直接使用压缩纹理资源实现高效的纹理渲染。In related technologies, the Unity platform already provides game developers with texture resource compression capabilities. Typically, Unity mini-games are released independently for each device, meaning separate game clients are exported for iOS, Android, and Windows. By configuring the texture resource formats supported by each device differently, when exporting game resources to the Unity asset package, the texture resources are converted according to the format types supported by the device. The resulting compressed texture resources, already in the corresponding compressed texture format, are then written into the Unity asset package. This allows for efficient texture rendering during game runtime.

目前缺少一种使应用(比如上述的Unity小游戏)能够在各种支持不同压缩格式的终端上都能正常渲染的技术。如果要将基于各种压缩格式的压缩纹理都提前放入资源包,则占用终端存储空间。Currently, there is a lack of technology that enables applications (such as the aforementioned Unity game) to render correctly on various terminals that support different compression formats. If compressed textures based on various compression formats are pre-loaded into the asset package, it will consume terminal storage space.

本申请实施例能够提高应用纹理渲染在支持不同压缩格式的终端上的普适性,提高了应用纹理的渲染效率;同时,减少对终端存储空间的占用,减少了空间资源的浪费。The embodiments of this application can improve the universality of application texture rendering on terminals that support different compression formats and improve the rendering efficiency of application textures; at the same time, it reduces the occupation of terminal storage space and reduces the waste of space resources.

本申请实施例应用的系统体系构架及场景说明System architecture and scenario description used in the embodiments of this application

图1是本申请实施例提供的应用纹理渲染方法所应用的系统构架图。它包括:终端110-1、110-2以及110-3、互联网120、网关130、与服务器140。Figure 1 is a system architecture diagram of the texture rendering method provided in the embodiments of this application. It includes: terminals 110-1, 110-2 and 110-3, Internet 120, gateway 130, and server 140.

终端110-1、110-2以及110-3是对象用来对目标应用(比如上述的WebGL游戏,Unity小游戏等)进行渲染的设备。它包括桌面电脑、膝上型电脑、个人数字助理(Personal Digital Assistant,PDA)、手机、车载终端、家庭影院终端、专用终端等多种形式。另外,它可以是单台设备,也可以是多台设备组成的集合。例如,多台设备通过局域网连接,公用一台显示设备进行协同工作,共同构成一个终端。终端110-1、110-2以及110-3也可以以有线或无线的方式与互联网120进行通信,交换数据。Terminals 110-1, 110-2, and 110-3 are devices used by the objects to render target applications (such as the WebGL game and Unity mini-game mentioned above). They include various forms such as desktop computers, laptops, personal digital assistants (PDAs), mobile phones, in-vehicle terminals, home theater terminals, and dedicated terminals. Furthermore, it can be a single device or a collection of multiple devices. For example, multiple devices can be connected via a local area network, sharing a single display device to work collaboratively, forming a single terminal. Terminals 110-1, 110-2, and 110-3 can also communicate with the Internet 120 via wired or wireless means to exchange data.

网关130又称网间连接器、协议转换器。网关130在传输层上实现网络互连,是一种充当转换作用的计算机系统或设备。在使用不同的通信协议、数据格式或语言,甚至体系结构完全不同的两种系统之间,网关130是一个翻译器。同时,网关130也可以提供过滤和安全功能。终端110-1、110-2以及110-3向服务器140发送的消息要通过网关130发送到相应的服务器140。服务器140向终端110-1、110-2以及110-3发送的消息也要通过网关130发送到相应的终端110-1、110-2以及110-3。Gateway 130, also known as an internetwork connector or protocol converter, is a computer system or device that enables network interconnection at the transport layer and acts as a translator. It bridges the gap between two systems using different communication protocols, data formats, languages, or even completely different architectures. Gateway 130 also provides filtering and security functions. Messages sent from terminals 110-1, 110-2, and 110-3 to server 140 are forwarded to the corresponding server 140 via gateway 130. Similarly, messages sent from server 140 to terminals 110-1, 110-2, and 110-3 are also forwarded to the corresponding terminals 110-1, 110-2, and 110-3 via gateway 130.

服务器140是指能向终端110-1、110-2以及110-3提供某些服务(比如向终端110-1、110-2以及110-3提供目标应用的应用容器、向终端提供各种格式的压缩纹理资源等)的计算机系统。相对于终端110-1、110-2以及110-3来说,服务器140在稳定性、安全性、性能等方面都要求更高。服务器140可以是网络平台中的一台高性能计算机、多台高性能计算机的集群、一台高性能计算机中划出的一部分(例如虚拟机)、多台高性能计算机中划出的一部分(例如虚拟机)的组合等。服务器140也可以通过有线或无线的方式与互联网120进行通信,交换数据。Server 140 refers to a computer system capable of providing certain services to terminals 110-1, 110-2, and 110-3 (such as providing application containers for target applications, providing compressed texture resources of various formats to terminals 110-1, 110-2, and 110-3, etc.). Compared to terminals 110-1, 110-2, and 110-3, server 140 has higher requirements in terms of stability, security, and performance. Server 140 can be a single high-performance computer in a network platform, a cluster of multiple high-performance computers, a portion of a single high-performance computer (e.g., a virtual machine), or a combination of portions of multiple high-performance computers (e.g., virtual machines). Server 140 can also communicate with the Internet 120 via wired or wireless means to exchange data.

本申请实施例可以应用在多种场景下,例如图2所示,图2是本申请实施例提供的更换终端的场景的示意图等。The embodiments of this application can be applied in various scenarios, such as Figure 2, which is a schematic diagram of a scenario of replacing a terminal provided by the embodiments of this application.

基于图2,对象在长时间的使用某个终端(称第一终端)之后,可能会需要更换为新的终端(称第二终端)。在更换终端时,往往需要把在第一终端上各个应用的数据(比如应用容器、对象的注册信息、应用的运行数据等)也导入到第二终端,以保留各个应用的使用记录。由于第一终端与第二终端在终端类型存在不同,导致支持的纹理压缩格式也不同,从而在第二终端运行应用时无法解析出压缩纹理资源而影响对应用的纹理资源渲染。因此,产生了在对象将第一终端更换为第二终端时,不影响进行应用的纹理资源渲染的需求。Based on Figure 2, after an object has used a certain terminal (referred to as the first terminal) for an extended period, it may need to be switched to a new terminal (referred to as the second terminal). When switching terminals, it is often necessary to import the data of various applications from the first terminal (such as application containers, object registration information, application runtime data, etc.) to the second terminal to preserve the usage records of each application. Because the first and second terminals differ in terminal type, they support different texture compression formats. Consequently, when running applications on the second terminal, compressed texture resources cannot be parsed, affecting the rendering of application texture resources. Therefore, there is a need to ensure that the rendering of application texture resources is not affected when the object switches from the first terminal to the second terminal.

如图2所示,服务器上存储有不同应用在各个纹理压缩格式下的纹理压缩资源。其中,应用A包括候选压缩格式为Y1时的候选压缩纹理资源W1、候选压缩格式为Y2时的候选压缩纹理资源W2、以及候选压缩格式为Y3时的候选压缩纹理资源W3。应用B与应用A类似,也包括各个纹理压缩格式下的纹理压缩资源,不再赘述。在第一终端上,应用容器中不包括具体的纹理资源,而是占位符数据。在对象使用第一终端运行应用A时,由于第一终端支持的目标压缩格式为Y1,第一终端在识别出占位符数据时,可以向服务器请求与目标压缩格式为Y1对应的候选压缩纹理资源,从而第一终端利用候选压缩纹理资源Y1进行目标应用的渲染。在对象将第一终端更换为第二终端之后,第二终端拥有与第一终端一样的资源包。在对象使用第二终端运行应用A时,由于第二终端支持的目标压缩格式为Y2,第二终端在识别出资源包中的占位符数据时,可以向服务器请求与目标压缩格式为Y2对应的候选压缩纹理资源,从而第二终端利用候选压缩纹理资源Y2进行目标应用的渲染。可见,在对象将第一终端更换为第二终端时,无需重新下载第二终端所对应应用的应用容器或者重新下载资源包(如果由第二终端重新下载,则可能会导致原先第一终端产生的使用记录丢失),也不会因为第二终端支持的压缩格式与第一终端支持的压缩格式不同而导致渲染失败。第二终端在进行应用渲染时可以自适应下载所需的压缩纹理资源,在能够正常进行纹理资源渲染的同时,可以避免应用的使用记录的丢失。As shown in Figure 2, the server stores texture compression resources for different applications under various texture compression formats. Application A includes candidate compressed texture resources W1 (for candidate compression format Y1), W2 (for candidate compression format Y2), and W3 (for candidate compression format Y3). Application B is similar to Application A, also including texture compression resources under various compression formats, which will not be elaborated further. On the first terminal, the application container does not contain specific texture resources, but rather placeholder data. When the object runs Application A using the first terminal, since the first terminal supports the target compression format Y1, upon recognizing the placeholder data, the first terminal can request candidate compressed texture resources corresponding to the target compression format Y1 from the server. Thus, the first terminal uses candidate compressed texture resource Y1 to render the target application. After the object changes the first terminal to a second terminal, the second terminal has the same resource package as the first terminal. When the object runs application A using a second terminal, since the second terminal supports the target compression format Y2, when the second terminal identifies the placeholder data in the resource package, it can request candidate compressed texture resources corresponding to the target compression format Y2 from the server. Thus, the second terminal uses the candidate compressed texture resource Y2 to render the target application. Therefore, when the object changes from the first terminal to the second terminal, it does not need to re-download the application container corresponding to the application on the second terminal or re-download the resource package (if the second terminal re-downloads, it may cause the loss of the usage records generated by the first terminal), nor will it cause rendering failure due to the compression format supported by the second terminal being different from that supported by the first terminal. The second terminal can adaptively download the required compressed texture resources when rendering the application, ensuring normal texture resource rendering while avoiding the loss of application usage records.

如此,由于服务器事先存储了各种候选压缩格式的候选压缩纹理资源,就可以从中获取目标压缩纹理资源,发送到终端,供终端利用目标压缩纹理资源进行目标应用的渲染。在这个过程中,无论终端能够支持的压缩格式如何,由于资源包中没有具体的压缩纹理资源,是用占位符数据代替的,因此通过向服务器请求目标压缩格式的目标压缩纹理资源,都能够获得目标压缩纹理资源,从而进行渲染。它能够提高应用纹理渲染在支持不同压缩格式的终端上的普适性,提高了应用纹理的渲染效率;同时,由于占位符数据远比始压缩纹理资源要小,可以大大减少对终端存储空间的占用,减少了空间资源的浪费。Thus, since the server pre-stores candidate compressed texture resources in various compression formats, it can retrieve the target compressed texture resource from these and send it to the terminal for rendering of the target application. In this process, regardless of the compression format supported by the terminal, since the resource package does not contain a specific compressed texture resource but uses placeholder data, the target compressed texture resource can be obtained by requesting it from the server, thus enabling rendering. This improves the universality of application texture rendering on terminals supporting different compression formats and increases the rendering efficiency of application textures. Simultaneously, because the placeholder data is much smaller than the original compressed texture resource, it significantly reduces the amount of storage space occupied on the terminal, minimizing wasted space resources.

本申请实施例的总体说明General Description of Embodiments in this Application

根据本申请的一个实施例,提供了一种应用纹理渲染方法。According to one embodiment of this application, an application texture rendering method is provided.

应用纹理渲染方法是指对运行应用所需的纹理资源进行渲染的方法。本申请实施例的应用纹理渲染方法在终端、和/或服务器执行。The application texture rendering method refers to a method for rendering texture resources required for running an application. The application texture rendering method in the embodiments of this application is executed on a terminal and/or a server.

如图3所示,图3是本申请实施例提供的应用纹理渲染方法的流程示意图,基于图3,本申请实施例提供的应用纹理渲染方法(第一电子设备如服务器执行)包括:As shown in Figure 3, Figure 3 is a flowchart illustrating the application texture rendering method provided in this embodiment of the application. Based on Figure 3, the application texture rendering method (executed by a first electronic device such as a server) provided in this embodiment of the application includes:

步骤310,获取目标应用的目标应用纹理资源及占位符数据,并发送占位符数据至第二电子设备;Step 310: Obtain the target application texture resources and placeholder data of the target application, and send the placeholder data to the second electronic device;

步骤320,按照多个候选压缩格式,将目标应用纹理资源分别压缩为多个候选压缩纹理资源;Step 320: Compress the target application texture resources into multiple candidate compressed texture resources according to multiple candidate compression formats;

步骤330,接收第二电子设备发送的资源请求,资源请求为第二电子设备获取到占位符数据后发送的,用于请求目标压缩纹理资源,目标压缩纹理资源为,采用目标压缩格式对目标应用纹理资源进行压缩得到的;如果目标压缩格式属于多个候选压缩格式,从多个候选压缩纹理资源中获取目标压缩纹理资源,并将目标压缩纹理资源发送到第二电子设备;其中,目标压缩纹理资源用于,供第二电子设备进行目标应用的渲染。Step 330: Receive a resource request sent by the second electronic device. The resource request is sent by the second electronic device after obtaining the placeholder data, and is used to request a target compressed texture resource. The target compressed texture resource is obtained by compressing the target application texture resource using a target compression format. If the target compression format belongs to multiple candidate compression formats, obtain the target compressed texture resource from the multiple candidate compressed texture resources and send the target compressed texture resource to the second electronic device. The target compressed texture resource is used by the second electronic device for rendering the target application.

该步骤310-330的实施例的优点在于,将目标应用纹理资源压缩为多个候选压缩纹理资源存储起来,且将占位符数据发送给第二电子设备。这样,第二电子设备如终端没有接收到任何压缩格式的压缩纹理资源。当第二电子设备向第一电子设备发送目标压缩格式的目标压缩纹理资源的请求时,由于第一电子设备事先存储了各种候选压缩格式的候选压缩纹理资源,就可以从中获取目标压缩纹理资源,发送到第二电子设备,供第二电子设备利用目标压缩纹理资源进行目标应用的渲染。这样,本申请实施例能够提高应用纹理渲染在支持不同压缩格式的终端上的普适性,提高了应用纹理的渲染效率;同时,由于占位符数据远比始压缩纹理资源要小,可以大大减少对终端存储空间的占用,减少了空间资源的浪费。The advantage of the embodiment of steps 310-330 is that the target application texture resource is compressed into multiple candidate compressed texture resources and stored, and placeholder data is sent to the second electronic device. In this way, the second electronic device, if the terminal does not receive any compressed texture resources of any compressed format, can retrieve the target compressed texture resource from the candidate compressed texture resources of various compressed formats when the second electronic device sends a request to the first electronic device for the target compressed texture resource in the target compressed format, since the first electronic device has pre-stored candidate compressed texture resources of various compressed formats. This target compressed texture resource can then be sent to the second electronic device for rendering of the target application. Thus, this embodiment of the application can improve the universality of application texture rendering on terminals supporting different compression formats and improve the rendering efficiency of application textures; at the same time, since the placeholder data is much smaller than the original compressed texture resource, it can greatly reduce the occupation of terminal storage space and reduce the waste of space resources.

下面对步骤310至步骤330、步骤310至步骤330之间包括的步骤、以及步骤330之后还包括的步骤,进行详细描述。The following describes in detail steps 310 to 330, the steps between steps 310 and 330, and the steps following step 330.

步骤310的详细描述Detailed description of step 310

在一些实施例中,在步骤310中,获取目标应用的目标应用纹理资源的过程,也即获取目标应用的初始资源包,初始资源包包括目标应用的初始压缩格式的初始压缩纹理资源;对初始压缩纹理资源进行解压,得到目标应用纹理资源。In some embodiments, in step 310, the process of obtaining the target application texture resources of the target application is to obtain the initial resource package of the target application, which includes the initial compressed texture resources of the target application in the initial compressed format; and to decompress the initial compressed texture resources to obtain the target application texture resources.

其中,目标应用是指能够执行特定任务或提供特定功能的应用。例如,参照上文,应用包括Web应用,而Web应用包括WebGL游戏,因此目标应用可以是指WebGL游戏。初始压缩纹理资源是指经过压缩处理的目标应用纹理资源。目标应用纹理资源是指用于渲染应用的纹理资源。比如,在终端运行目标应用时,需要将初始压缩纹理资源解压为目标应用纹理资源,然后利用目标应用纹理资源对目标应用进行渲染。In this context, the target application refers to an application capable of performing a specific task or providing a specific function. For example, referring to the above, applications include web applications, and web applications include WebGL games; therefore, the target application could refer to a WebGL game. The initial compressed texture resource refers to the target application's texture resource after compression. The target application texture resource refers to the texture resource used to render the application. For instance, when running the target application on a terminal, the initial compressed texture resource needs to be decompressed into the target application texture resource, and then the target application texture resource is used to render the target application.

需要说明的是,开发人员在设计应用时,需要设计应用的应用容器。应用容器是用于存放与应用的运行相关的数据的容器。应用容器包括应用程序包和初始资源包。应用程序包用于控制应用的运行过程。初始资源包用于提供应用的运行过程中用作渲染的资源。初始资源包可以包括目标应用纹理资源。为了减小初始资源包的存储大小,可以用初始压缩格式对应的压缩算法对目标应用纹理资源进行压缩得到初始压缩纹理资源,从而使初始资源包包括目标应用的初始压缩格式的初始压缩纹理资源。在一些实施例中,在终端运行应用时,可以通过应用程序包执行相应的操作,并调用初始资源包进行渲染。It's important to note that developers need to design an application container when designing an application. The application container is used to store data related to the application's operation. It includes an application package and an initial resource package. The application package controls the application's execution process. The initial resource package provides resources used for rendering during application execution. The initial resource package may include target application texture resources. To reduce the storage size of the initial resource package, the target application texture resources can be compressed using a compression algorithm corresponding to the initial compression format to obtain initially compressed texture resources, thus ensuring that the initial resource package includes initially compressed texture resources in the target application's initial compression format. In some embodiments, when the application runs on the terminal, corresponding operations can be performed through the application package, and the initial resource package can be invoked for rendering.

在一些实施例中,目标应用的初始资源包的获取包括但不限于以下方式:In some embodiments, the initial resource package of the target application is obtained in ways including but not limited to the following:

(1)第一电子设备响应于开发人员在Unity平台上设计目标应用并发布,从Unity平台获取目标应用的初始应用容器,初始应用容器包括初始资源包。(1) In response to the developer designing and publishing the target application on the Unity platform, the first electronic device obtains the initial application container of the target application from the Unity platform, the initial application container including the initial resource package.

(2)第一电子设备响应于对象请求将第一终端中的目标应用传输至第二终端,从第一终端获取目标应用的初始应用容器,初始应用容器包括初始资源包。(2) In response to an object request, the first electronic device transmits the target application in the first terminal to the second terminal and obtains the initial application container of the target application from the first terminal. The initial application container includes an initial resource package.

应用上述实施例,通过对目标应用的初始资源包进行解压来得到目标应用纹理资源,这样,通过对目标应用纹理资源在打包压缩,以减少应用安装包的大小,优化内存使用,也便于资源管理。By applying the above embodiments, the target application's texture resources are obtained by decompressing the initial resource package of the target application. In this way, by packaging and compressing the target application's texture resources, the size of the application installation package is reduced, memory usage is optimized, and resource management is also facilitated.

在一些实施例中,如上文所述,获取目标应用的目标应用纹理资源的过程,也即获取目标应用的初始资源包,初始资源包包括目标应用的初始压缩格式的初始压缩纹理资源;对初始压缩纹理资源进行解压,得到目标应用纹理资源;In some embodiments, as described above, the process of obtaining the target application texture resources of the target application is to obtain the initial resource package of the target application, which includes the initial compressed texture resources of the target application in the initial compression format; and to decompress the initial compressed texture resources to obtain the target application texture resources.

基于此,参照图4,图4是本申请实施例提供的应用纹理渲染方法的流程图,基于图4,步骤310可以划分为:步骤3101,获取目标应用的初始资源包,初始资源包包括目标应用的初始压缩纹理资源;步骤3102,对初始压缩纹理资源进行解压,得到目标应用纹理资源;步骤3103,将初始资源包中的初始压缩纹理资源替换为占位符数据,得到更新资源包;步骤3104,将更新资源包发送到第二电子设备。Based on this, referring to Figure 4, which is a flowchart of the application texture rendering method provided in the embodiment of this application, step 310 can be divided into: step 3101, obtaining the initial resource package of the target application, the initial resource package including the initial compressed texture resource of the target application; step 3102, decompressing the initial compressed texture resource to obtain the texture resource of the target application; step 3103, replacing the initial compressed texture resource in the initial resource package with placeholder data to obtain the updated resource package; step 3104, sending the updated resource package to the second electronic device.

在一些实施例的步骤3102中,第一电子设备可以基于压缩格式名称对应的压缩算法对初始压缩纹理资源进行解压,得到目标应用纹理资源。其中,初始资源包除了包括初始压缩纹理资源之外,还包括初始压缩格式名称,且第一电子设备存储有与各种纹理压缩格式名称对应的压缩算法。In step 3102 of some embodiments, the first electronic device can decompress the initial compressed texture resource based on the compression algorithm corresponding to the compression format name to obtain the target application texture resource. The initial resource package includes not only the initial compressed texture resource but also the initial compression format name, and the first electronic device stores compression algorithms corresponding to various texture compression format names.

示例性地,继续参照图4,基于图4,步骤3102包括:步骤31021,获取初始压缩格式名称对应的初始压缩算法;步骤31022,基于初始压缩算法,将初始压缩纹理资源解压为目标应用纹理资源。For example, continuing to refer to Figure 4, based on Figure 4, step 3102 includes: step 31021, obtaining the initial compression algorithm corresponding to the initial compression format name; step 31022, decompressing the initial compressed texture resource into the target application texture resource based on the initial compression algorithm.

需要说明的是,第一电子设备存储有格式名称与压缩算法映射表。步骤31021包括:根据初始压缩格式名称查找格式名称与压缩算法映射表,得到初始压缩算法。如下是一个格式名称与压缩算法映射表的例子。
It should be noted that the first electronic device stores a mapping table between format names and compression algorithms. Step 31021 includes: looking up the mapping table between format names and compression algorithms based on the initial compression format name to obtain the initial compression algorithm. Below is an example of a mapping table between format names and compression algorithms.

表1Table 1

参照表1,如果初始压缩格式名称为ETC,则服务器将ETC算法作为初始压缩算法。如果初始压缩格式名称为ASTC,则服务器将ASTC算法作为初始压缩算法。如果初始压缩格式名称为PVRTC,则服务器将PVRTC算法作为初始压缩算法。如果初始压缩格式名称为DXT,则服务器将DXT算法作为初始压缩算法。Referring to Table 1, if the initial compression format name is ETC, the server will use the ETC algorithm as the initial compression algorithm. If the initial compression format name is ASTC, the server will use the ASTC algorithm as the initial compression algorithm. If the initial compression format name is PVRTC, the server will use the PVRTC algorithm as the initial compression algorithm. If the initial compression format name is DXT, the server will use the DXT algorithm as the initial compression algorithm.

在实际实施时,除了查表,还可以采用其它方式获取初始压缩算法,本实施例对此不作具体限定。In practice, in addition to looking up tables, other methods can be used to obtain the initial compression algorithm, and this embodiment does not impose specific limitations on this.

在一些实施例的步骤31022中,可以基于与初始压缩算法对应的解压函数或解压工具对初始压缩纹理资源进行解压,得到目标应用纹理资源。具体来说,在对初始压缩纹理资源进行解压时,解压的过程取决于使用的压缩算法和格式。示例性地,以下是一些常见的纹理压缩格式和解压方式:(1)ETC(Ericsson Texture Compression):ETC是一种常用的纹理压缩格式,常用于移动终端。解压ETC纹理资源可以通过图形API(如OpenGL ES)提供的相应函数进行解压。(2)ASTC(Adaptive Scalable Texture Compression):ASTC是一种由ARM开发的高级纹理压缩格式,支持多种压缩率和位深度。解压ASTC纹理资源通常需要使用支持ASTC格式的图形API或库提供的相应函数进行解码。(3)PVRTC(PowerVR Texture Compression):PVRTC是一种由Imagination Technologies开发的纹理压缩格式,常用于iOS设备。解压PVRTC纹理资源需要使用PVRTexTool等工具进行解码。In step 31022 of some embodiments, the initial compressed texture resource can be decompressed based on the decompression function or decompression tool corresponding to the initial compression algorithm to obtain the target application texture resource. Specifically, when decompressing the initial compressed texture resource, the decompression process depends on the compression algorithm and format used. For example, the following are some common texture compression formats and decompression methods: (1) ETC (Ericsson Texture Compression): ETC is a commonly used texture compression format, often used in mobile terminals. Decompressing ETC texture resources can be done using the corresponding functions provided by graphics APIs (such as OpenGL ES). (2) ASTC (Adaptive Scalable Texture Compression): ASTC is an advanced texture compression format developed by ARM, supporting multiple compression ratios and bit depths. Decompressing ASTC texture resources usually requires decoding using the corresponding functions provided by graphics APIs or libraries that support the ASTC format. (3) PVRTC (PowerVR Texture Compression): PVRTC is a texture compression format developed by Imagination Technologies, often used in iOS devices. Decompressing PVRTC texture resources requires using tools such as PVRTexTool for decoding.

应用上述实施例,先基于初始压缩格式名称确定出初始压缩算法,再基于初始压缩算法进行解压,提高了解压效率。By applying the above embodiments, the initial compression algorithm is first determined based on the initial compression format name, and then decompression is performed based on the initial compression algorithm, thereby improving decompression efficiency.

在一些实施例的步骤3103中,第一电子设备将初始资源包中的初始压缩纹理资源替换为占位符数据,得到更新资源包。占位符数据通常是用来代替数据包中的真实数据的临时数据,且不影响对数据包的解析。本申请实施例使用占位符数据代替初始压缩纹理资源,可以得到更新资源包,且即使没有初始压缩纹理资源也不影响对更新资源包的解析。占位符数据可以为纹理资源名称。In step 3103 of some embodiments, the first electronic device replaces the initial compressed texture resource in the initial resource packet with placeholder data to obtain an updated resource packet. Placeholder data is typically temporary data used to replace the actual data in the data packet and does not affect the parsing of the data packet. In this embodiment, using placeholder data to replace the initial compressed texture resource allows for the obtaining of an updated resource packet, and the parsing of the updated resource packet is not affected even without the initial compressed texture resource. The placeholder data can be a texture resource name.

需要说明的是,不同的纹理资源名称可以根据其用途和特性进行分类。示例性地,以下是一些常见的纹理资源名称:(1)漫反射贴图(Diffuse Map):用于描述物体表面的颜色和光照信息。(2)法线贴图(Normal Map):用于模拟物体表面的凹凸细节,增强光照效果,提高视觉真实感。(3)高光贴图(Specular Map):用于控制物体表面的高光反射强度和位置,影响材质的光泽度。(4)发光贴图(Emission Map):用于描述物体表面发光的部分,可以实现自发光效果。(5)粗糙度贴图(Roughness Map):描述物体表面的粗糙程度,影响光照的散射和反射效果。(6)金属度贴图(Metallic Map):描述物体表面的金属属性,影响光照的反射方式和颜色。(7)环境光遮蔽贴图(Ambient Occlusion Map):描述物体表面的阴影和遮蔽信息,增强场景的真实感和立体感。(8)高度贴图(Height Map):描述物体表面的高度信息,通常用于创建凹凸地形效果。It should be noted that different texture resource names can be classified according to their purpose and characteristics. For example, the following are some common texture resource names: (1) Diffuse Map: used to describe the color and lighting information of an object's surface. (2) Normal Map: used to simulate the bumps and dents of an object's surface, enhance lighting effects, and improve visual realism. (3) Specular Map: used to control the intensity and position of specular reflections on an object's surface, affecting the glossiness of the material. (4) Emission Map: used to describe the luminous parts of an object's surface, enabling self-illumination effects. (5) Roughness Map: describes the roughness of an object's surface, affecting the scattering and reflection effects of light. (6) Metallic Map: describes the metallic properties of an object's surface, affecting the way light is reflected and its color. (7) Ambient Occlusion Map: describes the shadows and occlusion information of an object's surface, enhancing the realism and three-dimensionality of the scene. (8) Height Map: Describes the height information of an object's surface and is usually used to create bumpy terrain effects.

需要说明的是,占位符数据的获取方式包括但不限于以下方式:(1)若初始资源包还包括初始压缩纹理资源的名称,可以从初始资源包获取初始压缩纹理资源的名称,得到纹理资源名称,将纹理资源名称确定为占位符数据。(2)若初始资源包不包括初始压缩纹理资源的名称,可以基于初始压缩纹理资源的描述功能进行名称识别,得到纹理资源名称,将纹理资源名称确定为占位符数据。其中,描述功能是指上述的描述物体表面的颜色和光照、凹凸细节、高光反射强度和位置、发光的部分、粗糙度、金属属性、阴影和遮蔽信息、以及高度信息等功能。It should be noted that the methods for obtaining placeholder data include, but are not limited to, the following: (1) If the initial resource package also includes the name of the initial compressed texture resource, the name of the initial compressed texture resource can be obtained from the initial resource package to obtain the texture resource name, and the texture resource name can be determined as placeholder data. (2) If the initial resource package does not include the name of the initial compressed texture resource, the name can be identified based on the description function of the initial compressed texture resource to obtain the texture resource name, and the texture resource name can be determined as placeholder data. Among them, the description function refers to the functions mentioned above that describe the color and lighting of the object surface, the details of the concavity and convexity, the intensity and position of the specular reflection, the luminous part, the roughness, the metallic properties, the shadow and occlusion information, and the height information.

在实际实施时,在确定占位符数据之后,将初始资源包中的初始压缩纹理资源替换为占位符数据,得到更新资源包的过程,可以包括:1、将初始压缩纹理资源进行备份;2、将占位符数据复制到初始资源包中,覆盖初始压缩纹理资源;3、更新初始资源包的其余资源与占位符数据之间的路径或链接关系;4、测试初始资源包中的占位符数据,若能够正确加载和显示,则删除备份,且将初始资源包作为更新资源包。In practice, after determining the placeholder data, the process of replacing the initial compressed texture resources in the initial resource package with the placeholder data to obtain the updated resource package can include: 1. Backing up the initial compressed texture resources; 2. Copying the placeholder data into the initial resource package, overwriting the initial compressed texture resources; 3. Updating the path or link relationship between the remaining resources in the initial resource package and the placeholder data; 4. Testing the placeholder data in the initial resource package. If it can be loaded and displayed correctly, the backup is deleted, and the initial resource package is used as the updated resource package.

在一些实施例中,如图5所示,图5是本申请实施例提供的初始资源和更新资源包的示意图,基于图5,初始资源包存储有多个初始压缩纹理资源,包括初始压缩纹理资源01、初始压缩纹理资源02、以及初始压缩纹理资源03等。假定初始压缩纹理资源01的纹理资源名称为漫反射贴图,则占位符数据为漫反射贴图。用“漫反射贴图”在初始资源包中替换“初始压缩纹理资源01”,得到更新资源包。更新资源包存储有漫反射贴图、初始压缩纹理资源02、以及初始压缩纹理资源03。也可以对初始压缩纹理资源02和初始压缩纹理资源03等其他初始压缩纹理资源进行替换,基于与替换初始压缩纹理资源01的过程类似,不再赘述。In some embodiments, as shown in FIG5, which is a schematic diagram of the initial resource and updated resource package provided in the embodiments of this application, the initial resource package stores multiple initial compressed texture resources, including initial compressed texture resource 01, initial compressed texture resource 02, and initial compressed texture resource 03, etc. Assuming the texture resource name of initial compressed texture resource 01 is diffuse map, the placeholder data is diffuse map. Replacing "initial compressed texture resource 01" with "diffuse map" in the initial resource package yields the updated resource package. The updated resource package stores diffuse map, initial compressed texture resource 02, and initial compressed texture resource 03. Other initial compressed texture resources, such as initial compressed texture resource 02 and initial compressed texture resource 03, can also be replaced. Since the process is similar to replacing initial compressed texture resource 01, it will not be described in detail here.

在一些实施例的步骤3204中,第一电子设备将更新资源包发送到第二电子设备。其中,如果终端未下载过目标应用,则第一电子设备响应于第二电子设备发送的目标应用的下载请求,将目标应用的应用容器发送到终端,应用容器包括应用程序代码和更新资源包;如果第二电子设备已经下载了目标应用,则第一电子设备响应于第二电子设备发送的目标应用的资源包的获取请求,将更新资源包发送到第二电子设备。In step 3204 of some embodiments, the first electronic device sends an update resource package to the second electronic device. Specifically, if the terminal has not downloaded the target application, the first electronic device, in response to a download request for the target application sent by the second electronic device, sends the application container of the target application to the terminal; the application container includes application code and an update resource package. If the second electronic device has already downloaded the target application, the first electronic device, in response to a request to obtain the resource package of the target application sent by the second electronic device, sends the update resource package to the second electronic device.

在一实施例中,在执行步骤3204之前,还可以执行步骤32041,将更新资源包的纹理资源压缩格式字段改为锚压缩格式,得到新的更新资源包;从而再执行步骤3204,此时,步骤3204通过步骤32042所实现,即将新的更新资源包发送到第二电子设备。纹理资源压缩格式字段是一个指示纹理资源的压缩格式的字段。In one embodiment, before executing step 3204, step 32041 can be executed to change the texture resource compression format field of the updated resource package to the anchor compression format, thereby obtaining a new updated resource package; then step 3204 is executed, in which case step 3204 is implemented by step 32042, that is, the new updated resource package is sent to the second electronic device. The texture resource compression format field is a field that indicates the compression format of the texture resource.

需要说明的是,在第一电子设备未进行数据替换之前,初始资源包中包括初始压缩纹理资源,则初始资源包中的纹理资源压缩格式字段为初始压缩纹理资源的压缩格式(比如为ETC格式)。在第一电子设备进行数据替换之后,更新资源包不再包括初始压缩纹理资源,而是包括占位符数据,且纹理资源压缩格式字段更新为锚压缩格式。其中,锚压缩格式是一种特定的压缩格式,指示终端应向第一电子设备请求纹理资源。由于第二电子设备可能不支持锚压缩格式,如果第二电子设备在识别出纹理资源压缩格式字段为锚压缩格式时,可以向纹理处理脚本中添加强制约束,强制约束指示支持锚压缩格式。这里,关于第二电子设备如何添加强制约束的具体过程将在下文描述,此处不做赘述。It should be noted that before the first electronic device performs data replacement, the initial resource package includes the initial compressed texture resource. In this case, the texture resource compression format field in the initial resource package is the compression format of the initial compressed texture resource (e.g., ETC format). After the first electronic device performs data replacement, the updated resource package no longer includes the initial compressed texture resource, but instead includes placeholder data, and the texture resource compression format field is updated to the anchor compression format. The anchor compression format is a specific compression format that indicates the terminal should request texture resources from the first electronic device. Since the second electronic device may not support the anchor compression format, if the second electronic device recognizes that the texture resource compression format field is the anchor compression format, it can add a mandatory constraint to the texture processing script. This mandatory constraint indicates support for the anchor compression format. The specific process of how the second electronic device adds mandatory constraints will be described below and will not be repeated here.

可以理解的是,部分第二电子设备如果没有施加强制约束,则在第二电子设备发现更新资源包中没有纹理资源而是占位符数据之后,可能无法向第一电子设备请求纹理资源,从而导致纹理资源渲染失败。Understandably, if some second electronic devices do not impose mandatory constraints, they may be unable to request texture resources from the first electronic device after discovering that the updated resource package contains placeholder data instead of texture resources, thus causing texture resource rendering to fail.

应用上述实施例,将纹理资源压缩格式字段改为锚压缩格式,从而用于第二电子设备施加强制约束,这样,可以使第二电子设备在识别出锚压缩格式时可以支持向第一电子设备请求纹理资源的功能,以便即使更新资源包中无具体的纹理资源,第二电子设备也能够从第一电子设备获取到纹理资源。By applying the above embodiments, the texture resource compression format field is changed to the anchor compression format, thereby imposing a mandatory constraint on the second electronic device. In this way, the second electronic device can support the function of requesting texture resources from the first electronic device when it recognizes the anchor compression format, so that even if there are no specific texture resources in the updated resource package, the second electronic device can still obtain texture resources from the first electronic device.

步骤320的详细描述Detailed description of step 320

参照图3,对于步骤320,按照多个候选压缩格式,将目标应用纹理资源分别压缩为多个候选压缩纹理资源。Referring to Figure 3, for step 320, the target application texture resource is compressed into multiple candidate compressed texture resources according to multiple candidate compression formats.

需要说明的是,候选压缩格式是一种用于减小文件大小的数据压缩格式。一个候选压缩格式一般对应一种压缩算法。参照上文,候选压缩格式可以包括ETC、ASTC、PVRTC、DXT等。It should be noted that a candidate compression format is a data compression format used to reduce file size. A candidate compression format generally corresponds to a compression algorithm. Referring to the above, candidate compression formats can include ETC, ASTC, PVRTC, DXT, etc.

在一些实施例的步骤320中,可以调用与候选压缩格式对应的压缩算法对目标应用纹理资源进行压缩,得到候选压缩格式对应的候选压缩纹理资源。比如,候选压缩格式为ETC,则可以调用ETC算法对目标应用纹理资源进行压缩,得到格式为ETC的候选压缩纹理资源。In step 320 of some embodiments, a compression algorithm corresponding to the candidate compression format can be invoked to compress the target application texture resource to obtain a candidate compressed texture resource corresponding to the candidate compression format. For example, if the candidate compression format is ETC, the ETC algorithm can be invoked to compress the target application texture resource to obtain a candidate compressed texture resource in ETC format.

在实际实施时,在执行步骤320之后,还可以执行步骤3201,存储多个候选压缩纹理资源。In actual implementation, after executing step 320, step 3201 can also be executed to store multiple candidate compressed texture resources.

需要说明的是,在一些实施例的步骤3201中,可以为每个候选压缩纹理资源设置序号,按照与序号和候选压缩格式对应的候选存储地址,存储候选压缩纹理资源。比如按照压缩时间的先后为每个候选压缩纹理资源设置序号。但序号无法反映候选压缩纹理资源相关的信息(比如无法反映候选压缩纹理资源的用途),导致查找候选压缩纹理资源十分繁琐(比如在需要读取某个特定用途的纹理资源时,需读取出候选压缩纹理资源,才能确定是否符合要求)。为此,在一实施例中,利用前述步骤中替换初始压缩纹理资源的占位符数据确定候选存储地址,然后对候选压缩纹理资源进行存储。占位符数据为纹理资源名称。It should be noted that in step 3201 of some embodiments, a sequence number can be set for each candidate compressed texture resource, and the candidate compressed texture resource can be stored according to the candidate storage address corresponding to the sequence number and the candidate compression format. For example, a sequence number can be set for each candidate compressed texture resource according to the order of compression time. However, the sequence number cannot reflect the relevant information of the candidate compressed texture resource (such as the purpose of the candidate compressed texture resource), making it very cumbersome to find the candidate compressed texture resource (for example, when it is necessary to read a texture resource for a specific purpose, the candidate compressed texture resource must be read in order to determine whether it meets the requirements). Therefore, in one embodiment, the placeholder data that replaces the initial compressed texture resource in the aforementioned steps is used to determine the candidate storage address, and then the candidate compressed texture resource is stored. The placeholder data is the texture resource name.

在一些实施例中,参照图6,图6是本申请实施例提供的存储多个候选压缩纹理资源的流程示意图,基于图6,步骤3201包括:步骤32011,针对各候选压缩格式,按照与纹理资源名称和候选压缩格式对应的候选存储地址,存储候选压缩纹理资。In some embodiments, referring to FIG6, FIG6 is a schematic flowchart of storing multiple candidate compressed texture resources provided in the embodiments of this application. Based on FIG6, step 3201 includes: step 32011, for each candidate compression format, storing the candidate compressed texture resource according to the candidate storage address corresponding to the texture resource name and the candidate compression format.

其中,候选存储地址用于表征候选压缩格式对应的候选压缩纹理资源所在的存储位置。Among them, the candidate storage address is used to characterize the storage location of the candidate compressed texture resource corresponding to the candidate compression format.

在实际实施时,步骤32011包括:获取第一对应关系表,第一对应关系表指示纹理资源名称、候选压缩格式、与候选存储地址的对应关系;基于第一对应关系表,存储候选压缩纹理资源。如下是一个第一对应关系表的例子:
In actual implementation, step 32011 includes: obtaining a first correspondence table, which indicates the correspondence between texture resource names, candidate compression formats, and candidate storage addresses; and storing candidate compressed texture resources based on the first correspondence table. The following is an example of a first correspondence table:

表2Table 2

参照表2,如果纹理资源名称为漫反射贴图、且候选压缩格式为ETC,则候选存储地址为XX:XX\MEh1。其余纹理资源名称和候选压缩格式同理,不再赘述。Referring to Table 2, if the texture resource name is diffuse map and the candidate compression format is ETC, then the candidate storage address is XX:XX\MEh1. The same applies to other texture resource names and candidate compression formats, and will not be elaborated further.

如此,利用查表确定候选存储地址的实施例的优点,不仅简便易行,同时处理开销小。Thus, the advantages of using a lookup table to determine candidate storage addresses are that it is not only simple and easy to implement, but also has low processing overhead.

在实际实施时,步骤32011还包括:对纹理资源名称和候选压缩格式执行目标运算,得到候选存储地址;按照候选存储地址,存储候选压缩纹理资源。In actual implementation, step 32011 also includes: performing target operations on the texture resource name and candidate compression format to obtain candidate storage addresses; and storing candidate compressed texture resources according to the candidate storage addresses.

需要说明的是,目标运算是事项设置的运算公式或运算函数,比如哈希函数。将纹理资源名称和候选压缩格式输入目标运算,输出结果为候选存储地址。在一例子中,将纹理资源名称和候选压缩格式作为输入,然后通过哈希函数生成一个唯一的标识符,再将该标识符与存储路径进行组合以得到候选存储地址。这样可以确保每个候选压缩纹理资源都有一个唯一的存储地址,且可以根据纹理资源名称和候选压缩格式来检索候选压缩纹理资源。It's important to note that the target operation is a set formula or function, such as a hash function. The texture resource name and candidate compression format are input into the target operation, and the output is the candidate storage address. In one example, the texture resource name and candidate compression format are taken as input, a hash function generates a unique identifier, and this identifier is combined with the storage path to obtain the candidate storage address. This ensures that each candidate compressed texture resource has a unique storage address, and that candidate compressed texture resources can be retrieved based on their texture resource name and candidate compression format.

如此,通过目标运算确定候选存储地址的方式,不仅精确性高,且目标运算能够根据需要调整,灵活性强。Thus, the method of determining candidate storage addresses through target operations is not only highly accurate, but also highly flexible as the target operations can be adjusted as needed.

在一些实施例中,假定纹理资源名称为漫反射贴图。将目标应用纹理资源按照ETC格式进行压缩,得到候选压缩纹理资源h1,候选存储地址为“XX:XX\MEh1”;将目标应用纹理资源按照ASTC格式进行压缩,得到候选压缩纹理资源MAh2,候选存储地址为“XX:XX\h2”;将目标应用纹理资源按照PVRTC格式进行压缩,得到候选压缩纹理资源h3,候选存储地址为“XX:XX\MPh3”;将目标应用纹理资源按照DXT格式进行压缩,得到候选压缩纹理资源h4,候选存储地址为“XX:XX\MDh4”。如图7所示,图7是本申请实施例提供的压缩过程的示意图,基于图7,第一电子设备按照“XX:XX\MEh1”存储候选压缩纹理资源h1;按照“XX:XX\MAh2”存储候选压缩纹理资源h2;按照“XX:XX\MPh3”存储候选压缩纹理资源h3;按照“XX:XX\MDh4”存储候选压缩纹理资源h4。In some embodiments, the texture resource name is assumed to be a diffuse map. The target application texture resource is compressed according to ETC format to obtain candidate compressed texture resource h1, with a candidate storage address of "XX:XX\MEh1"; the target application texture resource is compressed according to ASTC format to obtain candidate compressed texture resource MAh2, with a candidate storage address of "XX:XX\h2"; the target application texture resource is compressed according to PVRTC format to obtain candidate compressed texture resource h3, with a candidate storage address of "XX:XX\MPh3"; and the target application texture resource is compressed according to DXT format to obtain candidate compressed texture resource h4, with a candidate storage address of "XX:XX\MDh4". As shown in Figure 7, which is a schematic diagram of the compression process provided in this embodiment, based on Figure 7, the first electronic device stores candidate compressed texture resource h1 according to "XX:XX\MEh1"; candidate compressed texture resource h2 according to "XX:XX\MAh2"; candidate compressed texture resource h3 according to "XX:XX\MPh3"; and candidate compressed texture resource h4 according to "XX:XX\MDh4".

应用上述实施例,利用占位符数据存储候选压缩纹理资源,在能够完成将候选压缩纹理资源进行存储的基础上,可以提高从第一电子设备读取第二电子设备所需的候选压缩纹理资源的效率。例如参照下文,第二电子设备在更新资源包中识别出占位符数据之后,可以依据占位符数据向第一电子设备请求候选压缩纹理资源,而恰好第一电子设备是基于占位符数据进行存储的,能够提高资源读取效率。By applying the above embodiments and utilizing placeholder data to store candidate compressed texture resources, the efficiency of reading candidate compressed texture resources required by the second electronic device can be improved, while ensuring the storage of these resources is completed. For example, referring to the following, after the second electronic device identifies the placeholder data in the updated resource package, it can request candidate compressed texture resources from the first electronic device based on the placeholder data. Since the first electronic device happens to store these resources based on the placeholder data, the resource reading efficiency can be improved.

需要说明的是,虽然第一电子设备存储了多个候选压缩格式的候选压缩纹理资源,但如果第二电子设备支持的目标压缩格式可能不属于多个候选压缩格式中的任意一个,则第一电子设备无法向终端无法发送适合的候选压缩纹理资源。It should be noted that although the first electronic device stores candidate compressed texture resources of multiple candidate compression formats, if the target compression format supported by the second electronic device may not belong to any of the multiple candidate compression formats, the first electronic device will be unable to send suitable candidate compressed texture resources to the terminal.

基于此,在一实施例中,参照图6,步骤3201还可以包括:步骤32012,存储多个候选压缩纹理资源和目标应用纹理资源。如此,在后续终端向服务器请求纹理资源时,即使终端支持的目标压缩格式不属于多个候选压缩格式,服务器也能将目标应用纹理资源发送给终端,确保了终端能够正常对目标应用进行渲染。Based on this, in one embodiment, referring to FIG6, step 3201 may further include: step 32012, storing multiple candidate compressed texture resources and target application texture resources. Thus, when the terminal subsequently requests texture resources from the server, even if the target compression format supported by the terminal is not among the multiple candidate compression formats, the server can still send the target application texture resources to the terminal, ensuring that the terminal can render the target application normally.

在步骤320之后,由第二电子设备如终端执行的步骤的详细描述A detailed description of the steps performed by the second electronic device, such as a terminal, after step 320.

如图3所示,根据本申请的一个实施例,应用纹理渲染方法(第二电子设备执行)包括:As shown in Figure 3, according to one embodiment of this application, the texture rendering method (executed by a second electronic device) includes:

步骤410,响应于获取到从第一电子设备发送的目标应用的占位符数据,确定第二电子设备支持的目标压缩格式;Step 410: In response to obtaining placeholder data of the target application sent from the first electronic device, determine the target compression format supported by the second electronic device;

步骤420,向第一电子设备发送资源请求,资源请求用于请求目标压缩纹理资源,目标压缩纹理资源为,采用目标压缩格式对目标应用纹理资源进行压缩得到的;Step 420: Send a resource request to the first electronic device. The resource request is used to request the target compressed texture resource. The target compressed texture resource is obtained by compressing the target application texture resource using the target compression format.

步骤430,从第一电子设备接收目标压缩纹理资源,并基于目标压缩纹理资源进行目标应用的渲染。Step 430: Receive target compressed texture resources from the first electronic device and render the target application based on the target compressed texture resources.

在上述步骤410至步骤430中,无论第二电子设备能够支持的压缩格式如何,由于第二电子设备没有接收到具体的压缩纹理资源,而是用占位符数据代替的,因此通过向第一电子设备请求目标压缩格式的目标压缩纹理资源,来获得目标压缩纹理资源,从而进行渲染;这样,能够提高应用纹理渲染在支持不同压缩格式的终端上的普适性,提高了应用纹理的渲染效率;同时,由于占位符数据远比始压缩纹理资源要小,可以大大减少对终端存储空间的占用,减少了空间资源的浪费。In steps 410 to 430 above, regardless of the compression format supported by the second electronic device, since the second electronic device does not receive the specific compressed texture resource but uses placeholder data instead, it obtains the target compressed texture resource by requesting the target compressed texture resource of the target compression format from the first electronic device, and then performs rendering. In this way, the universality of application texture rendering on terminals that support different compression formats can be improved, and the rendering efficiency of application textures can be improved. At the same time, since the placeholder data is much smaller than the original compressed texture resource, the occupation of terminal storage space can be greatly reduced, and the waste of space resources can be reduced.

在一些实施例,步骤410的过程,具体包括,从第一电子设备接收目标应用的应用容器,应用容器中包括更新资源包,其中,更新资源包通过由第一电子设备将目标应用的初始资源包中的初始压缩纹理资源替换为占位符数据而得到;响应于识别出更新资源包中含有占位符数据,确定第二电子设备支持的目标压缩格式。In some embodiments, step 410 specifically includes receiving an application container of a target application from a first electronic device, the application container including an updated resource package, wherein the updated resource package is obtained by the first electronic device replacing the initial compressed texture resources in the initial resource package of the target application with placeholder data; in response to identifying that the updated resource package contains placeholder data, determining a target compression format supported by a second electronic device.

需要说明的是,第一电子设备存储有多个候选应用的应用容器。第二电子设备可以响应于对象对目标应用的下载操作,向第一电子设备发送资源下载请求,以下载目标应用的资源包。多个候选应用包括目标应用。第一电子设备基于第二电子设备的下载请求向第二电子设备发送目标应用的应用容器。It should be noted that the first electronic device stores application containers for multiple candidate applications. The second electronic device, in response to a download operation of the target application, sends a resource download request to the first electronic device to download the resource package of the target application. The multiple candidate applications include the target application. Based on the download request from the second electronic device, the first electronic device sends the application container of the target application to the second electronic device.

需要说明的是,在第一电子设备侧,目标应用的应用容器可以包括初始资源包,但在第一电子设备执行步骤3101之后,初始资源包已替换为更新资源包,即第一电子设备发送给第二电子设备的目标应用的应用容器包括更新资源包。It should be noted that, on the first electronic device side, the application container of the target application may include the initial resource package, but after the first electronic device executes step 3101, the initial resource package has been replaced with the updated resource package, that is, the application container of the target application sent by the first electronic device to the second electronic device includes the updated resource package.

更新资源包通过由第一电子设备将目标应用的初始资源包中的初始压缩纹理资源替换为占位符数据而得到。结合上文可知,第一电子设备可以把只包括更新资源包的应用容器发送给第二电子设备,也可以把同时包括应用程序包和更新资源包的应用容器发送给第二电子设备。The updated resource package is obtained by the first electronic device replacing the initial compressed texture resources in the target application's initial resource package with placeholder data. As discussed above, the first electronic device can send an application container containing only the updated resource package to the second electronic device, or it can send an application container containing both the application package and the updated resource package to the second electronic device.

在一些实施例的步骤410中,第二电子设备在运行目标应用时可能需要调用纹理资源进行渲染,则第二电子设备会对更新资源包进行解析,目的是从更新资源包提取出纹理资源。由于更新资源包中不再有具体的纹理资源,而是占位符数据,导致第二电子设备无法从更新资源包提取出纹理资源。为此,第二电子设备响应于识别出资源包中含有占位符数据,确定第二电子设备支持的目标压缩格式,以便基于目标压缩格式向第一电子设备请求渲染目标应用所需的、且第二电子设备能够解析的压缩纹理资源。In step 410 of some embodiments, the second electronic device may need to call texture resources for rendering when running the target application. The second electronic device then parses the updated resource package to extract texture resources. Since the updated resource package no longer contains actual texture resources but only placeholder data, the second electronic device cannot extract texture resources from it. Therefore, in response to recognizing the placeholder data in the resource package, the second electronic device determines the target compression format it supports, and requests compressed texture resources that the first electronic device needs to render the target application and that the second electronic device can parse, based on the target compression format.

在一些实施例中,参照图8,图8是本申请实施例提供的应用纹理渲染方法的流程示意图,基于图8,步骤410包括:步骤4101,通过主逻辑运行应用程序包,响应于在运行过程中识别出应用程序包中含有占位符数据,通过纹理处理脚本查询第二电子设备支持的目标压缩格式。In some embodiments, referring to FIG8, which is a flowchart of the application texture rendering method provided in the embodiments of this application, step 410 includes: step 4101, running the application package through the main logic, and in response to identifying that the application package contains placeholder data during the running process, querying the target compression format supported by the second electronic device through the texture processing script.

主逻辑是指终端运行目标应用的进程/线程。纹理处理脚本是指渲染目标应用时的脚本。在一例子中,Unity平台导出的目标应用(WebGL游戏)的渲染均基于WebGL API实现,WebGL API均使用JavaScript脚本完成调用,所以Unity平台导出的应用程序包需要最终以JavaScript脚本实现基本的调用。The main logic refers to the process/thread on the terminal that runs the target application. Texture processing scripts refer to the scripts used to render the target application. In one example, the rendering of the target application (WebGL game) exported from the Unity platform is all based on the WebGL API. Since the WebGL API is called using JavaScript, the application package exported from the Unity platform ultimately needs to implement basic calls using JavaScript.

如此,该实施例通过主逻辑在运行过程识别出占位符数据,且通过主逻辑向纹理处理脚本查询目标压缩格式,提高了查询效率。Thus, this embodiment identifies placeholder data during operation through the main logic and queries the texture processing script for the target compression format through the main logic, thereby improving query efficiency.

需要说明的是,目标应用运行时主逻辑可以向JavaScript脚本层询问当前终端(GPU)所支持的压缩格式列表,以从压缩格式列表确定目标压缩格式。由于经过服务器对初始资源包的数据替换处理,其中“占位符数据”并不能保证在所有的终端中均能够支持。因此在一实施例中,在询问支持的压缩格式列表时,将在纹理处理脚本中增加强制约束,以便始终支持“占位符数据”是当前终端所支持渲染的。It should be noted that the target application's runtime main logic can query the JavaScript script layer for a list of compression formats supported by the current terminal (GPU) to determine the target compression format. Because the server performs data replacement processing on the initial resource package, the "placeholder data" is not guaranteed to be supported on all terminals. Therefore, in one embodiment, when querying the list of supported compression formats, a mandatory constraint is added to the texture processing script to ensure that the "placeholder data" is always rendered by the current terminal.

在该实施例具体实现时,参照图8,步骤4101包括:In a specific implementation of this embodiment, referring to Figure 8, step 4101 includes:

步骤41011,通过主逻辑运行应用程序包,响应于在运行过程中识别出应用程序包中含有占位符数据、且应用程序包中的纹理资源压缩格式字段为锚压缩格式,向纹理处理脚本中添加强制约束,强制约束指示支持锚压缩格式;Step 41011: Run the application package through the main logic. In response to the identification during the running process that the application package contains placeholder data and the texture resource compression format field in the application package is anchor compression format, add a mandatory constraint to the texture processing script. The mandatory constraint indicates that the anchor compression format is supported.

步骤41012,向纹理处理脚本发送查询请求;其中,查询请求用于供纹理处理脚本,基于强制约束验证对锚压缩格式的支持,并查询第二电子设备支持的除锚压缩格式之外的目标压缩格式。Step 41012: Send a query request to the texture processing script; wherein, the query request is used for the texture processing script to verify support for the anchor compression format based on the mandatory constraint, and to query the target compression formats supported by the second electronic device other than the anchor compression format.

在步骤41011中,锚压缩格式是一种特定的压缩格式,指示第二电子设备应向第一电子设备请求纹理资源。由于第二电子设备可能不支持锚压缩格式,因此本申请实施例通过主逻辑向纹理处理脚本中添加强制约束,且该强制约束指示支持锚压缩格式。强制约束是一段要求支持锚压缩格式的处理脚本。In step 41011, the anchor compression format is a specific compression format that indicates the second electronic device should request texture resources from the first electronic device. Since the second electronic device may not support the anchor compression format, this embodiment adds a mandatory constraint to the texture processing script through the main logic, and this mandatory constraint indicates support for the anchor compression format. The mandatory constraint is a processing script that requires support for the anchor compression format.

在步骤41012中,由于纹理处理脚本中已被添加强制约束,在第二电子设备向纹理处理脚本发送查询请求时,可以验证对锚压缩格式的支持,并获取支持的除锚压缩格式之外的目标压缩格式。In step 41012, since mandatory constraints have been added to the texture processing script, when the second electronic device sends a query request to the texture processing script, it can verify the support for the anchor compression format and obtain the supported target compression formats other than the anchor compression format.

如此,上述对纹理处理脚本添加强制约束的实施例的优点在于,可以确保任何终端均能够支持锚压缩格式,提高纹理资源渲染的有效性。Thus, the advantage of the above embodiment of adding mandatory constraints to the texture processing script is that it can ensure that any terminal can support the anchor compression format, thereby improving the effectiveness of texture resource rendering.

在一些实施例的步骤420中,向第一电子设备发送资源请求,也即目标压缩格式的目标压缩纹理资源的请求;该资源请求可以包括第二电子设备的源地址、第一电子设备的目的地址、纹理资源名称以及目标压缩格式。在一例子中,如图9所示,图9是本申请实施例提供的资源请求的示意图,基于图9,目标压缩格式的目标压缩纹理资源的资源请求包括目标压缩格式、纹理资源名称、源地址以及目的地址,使得第一电子设备根据资源请求中的目标压缩格式和纹理资源名称将目标压缩纹理资源发送给第二电子设备。该资源请求也可以包括第二电子设备的源地址、第一电子设备的目的地址、以及与纹理资源名称和目标压缩格式对应的目标存储地址,使得第一电子设备根据请求中的目标存储地址将目标压缩纹理资源发送给第二电子设备。In step 420 of some embodiments, a resource request, namely a request for a target compressed texture resource in a target compression format, is sent to a first electronic device. This resource request may include the source address of the second electronic device, the destination address of the first electronic device, the texture resource name, and the target compression format. In one example, as shown in FIG9, which is a schematic diagram of a resource request provided in an embodiment of this application, the resource request for a target compressed texture resource in a target compression format includes the target compression format, the texture resource name, the source address, and the destination address, causing the first electronic device to send the target compressed texture resource to the second electronic device according to the target compression format and texture resource name in the resource request. The resource request may also include the source address of the second electronic device, the destination address of the first electronic device, and a target storage address corresponding to the texture resource name and the target compression format, causing the first electronic device to send the target compressed texture resource to the second electronic device according to the target storage address in the request.

在一实施例中,参照图10,图10是本申请实施例提供的发送资源请求的流程示意图,基于图10,步骤420包括:In one embodiment, referring to FIG10, which is a schematic flowchart of sending a resource request provided in an embodiment of this application, step 420 includes:

步骤4201,在用于渲染目标应用的渲染函数之前插入劫持语句;Step 4201: Insert a hijacking statement before the rendering function used to render the target application;

步骤4202,执行劫持语句,劫持语句用于用目标压缩格式替换应用程序包中的占位符数据,并基于应用程序包中的目标压缩格式,向第一电子设备发送资源请求。Step 4202: Execute the hijacking statement, which is used to replace the placeholder data in the application package with the target compression format and send a resource request to the first electronic device based on the target compression format in the application package.

需要说明的是,劫持语句是指在计算机程序中,通过修改程序的控制流程,以执行额外的操作或代码。劫持语句通常是通过注入代码或修改程序的指令流来实现的,常见的劫持语句包括跳转指令、函数调用、变量修改等。本实施例主要利用劫持语句控制第二电子设备在执行渲染函数之前向第一电子设备请求目标压缩纹理资源。It should be noted that hijacking statements refer to modifying the control flow of a computer program to execute additional operations or code. Hijacking statements are typically implemented by injecting code or modifying the program's instruction flow. Common hijacking statements include jump instructions, function calls, and variable modifications. This embodiment mainly utilizes hijacking statements to control the second electronic device to request target compressed texture resources from the first electronic device before executing the rendering function.

在实际实施时,可以通过以下方式在用于渲染目标应用的渲染函数之前插入劫持语句:(1)修改渲染循环:直接在渲染循环中加入自定义代码,这样每次渲染前都会执行这些代码;(2)使用渲染管线钩子:渲染管线的特定阶段插入钩子,例如在DirectX中使用ID3D11 Device Context的钩子或在OpenGL中使用帧缓冲区对象的钩子;(3)渲染函数包装:创建一个新的渲染函数,在其中调用原始的渲染函数之前或之后执行自定义代码;(4)使用中间件或框架:利用已有的中间件或框架提供的接口,其中,该接口允许在渲染流程中插入自定义代码等。对此,本申请实施例不做限定。In practical implementation, hijacking statements can be inserted before the rendering function used to render the target application in the following ways: (1) Modify the rendering loop: Add custom code directly to the rendering loop so that this code is executed before each rendering; (2) Use rendering pipeline hooks: Insert hooks at specific stages of the rendering pipeline, such as using the ID3D11 Device Context hook in DirectX or the framebuffer object hook in OpenGL; (3) Wrap the rendering function: Create a new rendering function in which custom code is executed before or after the original rendering function is called; (4) Use middleware or frameworks: Utilize the interfaces provided by existing middleware or frameworks, where the interfaces allow the insertion of custom code into the rendering process, etc. This application does not limit the scope of these methods.

由于前述步骤已经在纹理处理脚本中添加强制约束,因此更新资源包内的格式一定能够被当前第二电子设备所“支持”,所以目标应用在使用纹理资源进行渲染时,将会执行至渲染目标应用的渲染函数。比如,假定目标应用为WebGL游戏,则将最终执行至WebGL的WebGLRenderingContext.compressedTexSubImage2D渲染函数。在用于渲染目标应用的渲染函数之前插入劫持语句,然后执行劫持,可以在用目标压缩格式替换资源包中的占位符数据,并基于资源包中的目标压缩格式,向第一电子设备发送目标压缩纹理资源的请求。在第二电子设备从第一电子设备将目标压缩纹理资源读取到运行内存空间之后,可以将目标压缩纹理资源上传至第二电子设备的GPU中即可完成最终所期望的纹理资源的渲染,上传GPU成功后,第二电子设备将立即释放目标压缩纹理资源所占用运行内存空间。Since the aforementioned steps have already added mandatory constraints to the texture processing script, the format within the updated resource package will definitely be "supported" by the current second electronic device. Therefore, when the target application uses texture resources for rendering, the rendering function for the target application will be executed. For example, assuming the target application is a WebGL game, the WebGLRenderingContext.compressedTexSubImage2D rendering function will ultimately be executed. By inserting a hijacking statement before the rendering function for the target application and then executing the hijacking, placeholder data in the resource package can be replaced with the target compression format, and a request for the target compressed texture resource can be sent to the first electronic device based on the target compression format in the resource package. After the second electronic device reads the target compressed texture resource from the first electronic device into its runtime memory space, it can upload the target compressed texture resource to the GPU of the second electronic device to complete the rendering of the desired texture resource. After successful upload to the GPU, the second electronic device will immediately release the runtime memory space occupied by the target compressed texture resource.

如此,通过利用在执行渲染函数之前的劫持语句,确保第二电子设备能够从第一电子设备获取到目标压缩纹理资源,提高了目标应用渲染的有效性。Thus, by using hijacking statements before the execution of the rendering function, the second electronic device can obtain the target compressed texture resources from the first electronic device, thereby improving the effectiveness of the target application rendering.

在实际实施时,在步骤420中,第二电子设备向第一电子设备发送目标压缩纹理资源的请求,从而在步骤330中,第一电子设备接收到第二电子设备发送的目标压缩格式的目标压缩纹理资源的请求之后,可以向第二电子设备发送目标压缩纹理资源,进而在步骤430中,第二电子设备从第一电子设备接收目标压缩纹理资源,以进行目标应用的渲染。因此下面先对步骤330进行详细描述,再对步骤430进行详细描述。In actual implementation, in step 420, the second electronic device sends a request for the target compressed texture resource to the first electronic device. Therefore, in step 330, after receiving the request for the target compressed texture resource in the target compressed format from the second electronic device, the first electronic device can send the target compressed texture resource to the second electronic device. Then, in step 430, the second electronic device receives the target compressed texture resource from the first electronic device for rendering the target application. Therefore, step 330 will be described in detail first, followed by a detailed description of step 430.

步骤330的详细描述Detailed description of step 330

参照图3,步骤330被划分为,步骤3301,接收第二电子设备发送的资源请求,资源请求为第二电子设备获取到占位符数据后发送的,用于请求目标压缩纹理资源,目标压缩纹理资源为,采用目标压缩格式对目标应用纹理资源进行压缩得到的;步骤3302,如果目标压缩格式属于所述多个候选压缩格式,从多个候选压缩纹理资源中获取目标压缩纹理资源;步骤3303,将目标压缩纹理资源发送到第二电子设备;其中,目标压缩纹理资源用于,供第二电子设备进行目标应用的渲染。Referring to Figure 3, step 330 is divided into: step 3301, receiving a resource request sent by the second electronic device, the resource request being sent by the second electronic device after obtaining the placeholder data, for requesting a target compressed texture resource, the target compressed texture resource being obtained by compressing the target application texture resource using a target compression format; step 3302, if the target compression format belongs to the plurality of candidate compression formats, obtaining the target compressed texture resource from the plurality of candidate compressed texture resources; step 3303, sending the target compressed texture resource to the second electronic device; wherein, the target compressed texture resource is used for the second electronic device to render the target application.

需要说明的是,第二电子设备向第一电子设备发送的资源请求可以包括纹理资源名称和目标压缩格式,从而由第一电子设备根据资源请求中的纹理资源名称和目标压缩格式确定目标存储地址,再由第一电子设备根据目标存储地址获取目标压缩纹理资源。It should be noted that the resource request sent by the second electronic device to the first electronic device may include the texture resource name and the target compression format. The first electronic device then determines the target storage address based on the texture resource name and the target compression format in the resource request, and then obtains the target compressed texture resource based on the target storage address.

又或者,第二电子设备向第一电子设备发送的资源请求还可以直接包括目标存储地址(即由第二电子设备提前根据纹理资源名称和目标压缩格式确定目标存储地址),从而由第一电子设备根据目标存储地址获取目标压缩纹理资源。Alternatively, the resource request sent by the second electronic device to the first electronic device may directly include the target storage address (i.e., the target storage address is determined in advance by the second electronic device based on the texture resource name and the target compression format), so that the first electronic device can obtain the target compressed texture resource based on the target storage address.

在一些实施例中,参照图11,图11是本申请实施例提供的应用纹理渲染方法的流程示意图,基于图11,在第二电子设备向第一电子设备发送的资源请求包括纹理资源名称和目标压缩格式的情况下,步骤3302包括:步骤33021a,如果目标压缩格式属于多个候选压缩格式,按照与纹理资源名称和目标压缩格式对应的目标存储地址,获取目标压缩纹理资源,其中,目标存储地址属于多个候选存储地址。In some embodiments, referring to FIG11, FIG11 is a flowchart of the application texture rendering method provided in the embodiments of this application. Based on FIG11, when the resource request sent by the second electronic device to the first electronic device includes a texture resource name and a target compression format, step 3302 includes: step 33021a, if the target compression format belongs to multiple candidate compression formats, the target compressed texture resource is obtained according to the target storage address corresponding to the texture resource name and the target compression format, wherein the target storage address belongs to multiple candidate storage addresses.

如此,由第一电子设备如服务器根据纹理资源名称和目标压缩格式确定目标存储地址,可以减少第二电子设备如终端的运算压力。In this way, the first electronic device, such as a server, can determine the target storage address based on the texture resource name and the target compression format, which can reduce the computational burden on the second electronic device, such as a terminal.

在实际实施时,如前文所述,针对各所述候选压缩格式,按照与纹理资源名称和候选压缩格式对应的候选存储地址,存储候选压缩纹理资的过程,可以是,获取第一对应关系表,第一对应关系表指示纹理资源名称、候选压缩格式、与候选存储地址的对应关系;基于第一对应关系表,存储候选压缩纹理资源;In actual implementation, as mentioned above, for each of the candidate compression formats, the process of storing candidate compressed texture resources according to the candidate storage address corresponding to the texture resource name and the candidate compression format can be as follows: obtaining a first correspondence table, which indicates the correspondence between the texture resource name, the candidate compression format, and the candidate storage address; and storing the candidate compressed texture resources based on the first correspondence table.

基于此,目标存储地址可以由第一电子设备基于纹理资源名称和目标压缩格式查找第一对应关系表得到。也即,在步骤33021a之前,还可以,如果目标压缩格式属于多个候选压缩格式,基于纹理资源名称和目标压缩格式查找所述第一对应关系表,得到目标存储地址;从而,基于获取到的目标存储地址,获取目标压缩纹理资源。Based on this, the target storage address can be obtained by the first electronic device by looking up the first correspondence table based on the texture resource name and the target compression format. That is, before step 33021a, if the target compression format belongs to multiple candidate compression formats, the first correspondence table can be looked up based on the texture resource name and the target compression format to obtain the target storage address; thereby, the target compressed texture resource can be obtained based on the obtained target storage address.

结合上文,候选压缩格式包括ETC格式、ASTC格式、PVRTC格式和DXT格式等。第一对应关系表可参照上文的表2。在一例子中,假定目标压缩格式为ETC格式,且纹理资源名称为漫反射贴图,则第一电子设备如服务器根据ETC格式和漫反射贴图查找第一对应关系表,得到目标存储地址为XX:XX\MEh1,服务器根据XX:XX\MEh1把候选压缩纹理资源h1确定为目标压缩纹理资源,然后发送到第二电子设备如终端。在另一例子中,假定目标压缩格式为DXT格式,且纹理资源名称为漫反射贴图,则服务器根据DXT格式和漫反射贴图查找第一对应关系表,得到目标存储地址为XX:XX\MDh4,服务器根据XX:XX\MDh4把候选压缩纹理资源h4确定为目标压缩纹理资源,然后发送到终端。Based on the above, candidate compression formats include ETC, ASTC, PVRTC, and DXT formats. The first correspondence table can be found in Table 2 above. In one example, assuming the target compression format is ETC and the texture resource name is a diffuse map, the first electronic device, such as a server, searches the first correspondence table based on the ETC format and the diffuse map to obtain the target storage address XX:XX\MEh1. The server then determines the candidate compressed texture resource h1 as the target compressed texture resource based on XX:XX\MEh1 and sends it to the second electronic device, such as a terminal. In another example, assuming the target compression format is DXT and the texture resource name is a diffuse map, the server searches the first correspondence table based on the DXT format and the diffuse map to obtain the target storage address XX:XX\MDh4. The server then determines the candidate compressed texture resource h4 as the target compressed texture resource based on XX:XX\MDh4 and sends it to the terminal.

如此,利用查表确定目标存储地址的,不仅简便易行,而且处理开销小。Thus, using table lookup to determine the target storage address is not only simple and easy to implement, but also has low processing overhead.

在实际实施时,如前文所述,针对各所述候选压缩格式,按照与纹理资源名称和候选压缩格式对应的候选存储地址,存储候选压缩纹理资的过程,还可以是,对纹理资源名称和候选压缩格式执行目标运算,得到候选存储地址;按照候选存储地址,存储候选压缩纹理资源。In actual implementation, as mentioned above, the process of storing candidate compressed texture resources according to the candidate storage address corresponding to the texture resource name and the candidate compression format for each candidate compression format can also be as follows: perform target operation on the texture resource name and the candidate compression format to obtain the candidate storage address; and store the candidate compressed texture resources according to the candidate storage address.

基于此,目标存储地址可以由第一电子设备基于纹理资源名称和目标压缩格式执行目标运算得到。也即,在步骤33021a之前,还可以,对纹理资源名称和目标压缩格式执行目标运算,得到目标存储地址;从而,基于获取到的目标存储地址,获取目标压缩纹理资源。Based on this, the target storage address can be obtained by the first electronic device by performing a target operation based on the texture resource name and the target compression format. That is, before step 33021a, a target operation can also be performed on the texture resource name and the target compression format to obtain the target storage address; thereby, the target compressed texture resource can be obtained based on the obtained target storage address.

需要说明的是,目标运算是事项设置的运算公式或运算函数,比如哈希函数。将纹理资源名称和目标压缩格式输入目标运算,输出结果为目标存储地址。在一例子中,将纹理资源名称和目标压缩格式作为输入,然后通过哈希函数生成一个唯一的标识符,再将该标识符与存储路径进行组合以得到目标存储地址。目标存储地址属于多个候选存储地址,每一候选存储地址对应一个候选压缩纹理资源。这样可以根据目标存储地址获取目标压缩纹理资源。It's important to note that the target operation is a set formula or function, such as a hash function. The texture resource name and target compression format are input into the target operation, and the output is the target storage address. In one example, the texture resource name and target compression format are used as input, a hash function generates a unique identifier, and this identifier is combined with the storage path to obtain the target storage address. The target storage address belongs to multiple candidate storage addresses, and each candidate storage address corresponds to a candidate compressed texture resource. This allows the target compressed texture resource to be retrieved based on the target storage address.

如此,通过目标运算确定目标存储地址,不仅精确性高,而且目标运算能够根据需要调整,灵活性强。Thus, determining the target storage address through target operations is not only highly accurate, but also highly flexible as the target operations can be adjusted as needed.

在另一些实施例中,继续参照图11,基于图11,在第二电子设备向第一电子设备发送的资源请求包括目标存储地址的情况下,步骤3302包括:步骤33021b,如果目标压缩格式属于多个候选压缩格式,按照资源请求中的目标存储地址,获取目标压缩纹理资源,其中,目标存储地址属于多个候选存储地址。In some other embodiments, continuing to refer to FIG11, based on FIG11, when the resource request sent by the second electronic device to the first electronic device includes a target storage address, step 3302 includes: step 33021b, if the target compression format belongs to multiple candidate compression formats, obtain the target compressed texture resource according to the target storage address in the resource request, wherein the target storage address belongs to multiple candidate storage addresses.

需要说明的是,目标存储地址可以由第二电子设备基于纹理资源名称和目标压缩格式查找第一对应关系表得到,目标存储地址也可以由第二电子设备通过对纹理资源名称和目标压缩格式施加目标运算得到。由第二电子设备查找第一对应关系表或施加目标运算的具体实现过程可参照上文中第一电子设备确定目标存储地址的实现过程,此处不再赘述。It should be noted that the target storage address can be obtained by the second electronic device by looking up the first correspondence table based on the texture resource name and the target compression format, or by the second electronic device by applying a target operation to the texture resource name and the target compression format. The specific implementation process of the second electronic device looking up the first correspondence table or applying the target operation can be referred to the implementation process of the first electronic device determining the target storage address above, and will not be repeated here.

如此,由第二电子设备如终端根据纹理资源名称和目标压缩格式确定目标存储地址,可以减少第一电子设备如服务器的运算压力。In this way, the second electronic device, such as a terminal, can determine the target storage address based on the texture resource name and the target compression format, which can reduce the computational burden on the first electronic device, such as a server.

在一实施例中,第二电子设备可以检测第一电子设备的剩余运算能力,如果剩余运算能力小于预定运算能力阈值,则第二电子设备根据纹理资源名称和目标压缩格式确定目标存储地址,如果剩余运算能力大于或等于预定运算能力阈值,则将纹理资源名称和目标压缩格式发送给第一电子设备,由第一电子设备根据纹理资源名称和目标压缩格式确定目标存储地址。这样一来,可以平衡第二电子设备和第一电子设备之间的运算压力。In one embodiment, the second electronic device can detect the remaining computing power of the first electronic device. If the remaining computing power is less than a predetermined computing power threshold, the second electronic device determines the target storage address based on the texture resource name and the target compression format. If the remaining computing power is greater than or equal to the predetermined computing power threshold, the second electronic device sends the texture resource name and the target compression format to the first electronic device, which then determines the target storage address based on the texture resource name and the target compression format. This balances the computing load between the second and first electronic devices.

需要说明的是,上述步骤33021a或33021b中目标压缩格式是一个,因此根据纹理资源名称和目标压缩格式确定的目标存储地址也是一个,但在一些实施例中,目标压缩格式的数量为多个,从而根据纹理资源名称和多个目标压缩格式确定的目标存储地址是多个,进而产生了基于各个目标压缩格式对应的目标存储地址确定目标压缩纹理资源的需求。It should be noted that in step 33021a or 33021b above, there is one target compression format, so the target storage address determined based on the texture resource name and the target compression format is also one. However, in some embodiments, there are multiple target compression formats, so there are multiple target storage addresses determined based on the texture resource name and multiple target compression formats, which in turn creates the need to determine the target compressed texture resource based on the target storage address corresponding to each target compression format.

下面分多种实施例对基于各个目标压缩格式对应的目标存储地址确定目标压缩纹理资源的过程进行描述。The process of determining the target compressed texture resource based on the target storage address corresponding to each target compression format is described below using various embodiments.

在第一种实施例中,步骤33021a或步骤33021b中按照目标存储地址,获取目标压缩纹理资源的过程,包括:如果目标压缩格式的数量为多个,获取每个目标压缩格式的压缩损失率;基于各目标压缩格式的压缩损失率,从各目标压缩格式对应的目标存储地址中,选取压缩损失率最小的目标压缩格式所对应的目标存储地址;基于选取的目标存储地址,获取目标压缩纹理资源。In the first embodiment, the process of obtaining the target compressed texture resource according to the target storage address in step 33021a or step 33021b includes: if there are multiple target compression formats, obtaining the compression loss rate of each target compression format; based on the compression loss rate of each target compression format, selecting the target storage address corresponding to the target compression format with the smallest compression loss rate from the target storage addresses corresponding to each target compression format; and obtaining the target compressed texture resource based on the selected target storage address.

需要说明的是,压缩损失率是指在数据压缩过程中丢失的信息量与原始数据总量之比。在有损压缩算法中,为了减小文件大小,会舍弃一部分数据,这样就会导致压缩损失。压缩损失率可以用以下公式表示:压缩损失率=(目标应用纹理资源的大小-候选压缩纹理资源的大小)/目标应用纹理资源的大小。压缩损失率通常以百分比的形式表示,可以帮助衡量压缩算法对数据的影响程度。较低的压缩损失率意味着压缩算法在保留数据质量的同时实现了较好的压缩效果。It's important to note that compression loss rate refers to the ratio of the amount of information lost during data compression to the total amount of original data. In lossy compression algorithms, some data is discarded to reduce file size, resulting in compression loss. The compression loss rate can be expressed by the following formula: Compression Loss Rate = (Size of Target Application Texture Resource - Size of Candidate Compressible Texture Resource) / Size of Target Application Texture Resource. Compression loss rate is usually expressed as a percentage and helps measure the impact of the compression algorithm on the data. A lower compression loss rate means that the compression algorithm achieves better compression results while preserving data quality.

应用上述实施例,基于压缩损失率最小对应的目标存储地址确定目标压缩纹理资源的,可以获取数据质量比较高的目标压缩纹理资源,提高渲染准确性。By applying the above embodiments, the target compressed texture resource can be determined based on the target storage address corresponding to the minimum compression loss rate, thereby obtaining target compressed texture resources with relatively high data quality and improving rendering accuracy.

在第二种实施例中,步骤33021a或步骤33021b中按照目标存储地址,获取目标压缩纹理资源的过程,包括:如果目标压缩格式的数量为多个,获取每个目标压缩格式的压缩速率;基于各目标压缩格式的压缩速率,从各目标压缩格式对应的目标存储地址中,选取压缩速率最大的目标压缩格式所对应的目标存储地址;基于选取的目标存储地址,获取目标压缩纹理资源。In the second embodiment, the process of obtaining the target compressed texture resource according to the target storage address in step 33021a or step 33021b includes: if there are multiple target compression formats, obtaining the compression rate of each target compression format; based on the compression rate of each target compression format, selecting the target storage address corresponding to the target compression format with the largest compression rate from the target storage addresses corresponding to each target compression format; and obtaining the target compressed texture resource based on the selected target storage address.

压缩速率是指数据压缩后的大小与原始数据大小的比率。它表示了数据在压缩后的相对大小,通常以比例或百分比表示。压缩速率可以用以下公式表示:压缩速率=候选压缩纹理资源的大小/目标应用纹理资源的大小。压缩速率越高,表示压缩效果越好,即数据被有效地压缩了。通常情况下,压缩速率越高,压缩后的数据文件大小就越小,占用的存储空间就越少。压缩速率是衡量压缩算法效果的重要指标之一,对于需要在有限存储空间内存储大量数据的场景非常重要。Compression rate refers to the ratio of the compressed data size to the original data size. It represents the relative size of the data after compression, usually expressed as a ratio or percentage. Compression rate can be expressed by the following formula: Compression rate = Size of candidate compressed texture resource / Size of target applied texture resource. A higher compression rate indicates better compression, meaning the data is effectively compressed. Generally, a higher compression rate results in a smaller compressed file size and less storage space. Compression rate is a crucial indicator of compression algorithm performance and is particularly important for scenarios requiring the storage of large amounts of data within limited storage space.

在实际应用中,基于压缩速率最大对应的目标存储地址确定目标压缩纹理资源,可以获取存储空间比较小的目标压缩纹理资源,减少对终端的存储空间的占用,这样,十分适合存储空间比较小的终端,还可以提高渲染效率。In practical applications, the target compressed texture resource can be determined based on the target storage address corresponding to the maximum compression rate. This allows for the acquisition of target compressed texture resources with relatively small storage space, reducing the storage space occupied on the terminal. This is very suitable for terminals with limited storage space and can also improve rendering efficiency.

在第三种实施例中,参照图12,图12是本申请实施例提供的确定目标压缩纹理资源的流程示意图,基于图12,步骤33021a包括:In the third embodiment, referring to Figure 12, which is a flowchart illustrating the process of determining the target compressed texture resource provided in an embodiment of this application, step 33021a includes:

步骤330211,如果目标压缩格式的数量为多个,获取每个目标压缩格式的压缩损失率和压缩速率;Step 330211: If there are multiple target compression formats, obtain the compression loss rate and compression rate of each target compression format;

步骤330212,获取压缩增益函数,压缩增益函数基于多个目标压缩格式的压缩纹理资源占比、每个目标压缩格式的压缩损失率和压缩速率确定;Step 330212: Obtain the compression gain function. The compression gain function is determined based on the proportion of compressed texture resources in multiple target compression formats, the compression loss rate of each target compression format, and the compression rate.

步骤330213,当压缩增益函数最大化时,确定每个目标压缩格式的目标压缩纹理资源占比;Step 330213: When the compression gain function is maximized, determine the proportion of target compressed texture resources for each target compression format;

步骤330214,基于与纹理资源名称和各个目标压缩格式对应的目标存储地址,获取各目标压缩格式对应的压缩纹理资源,并基于每个目标压缩格式的目标压缩纹理资源占比、和各目标压缩格式对应的压缩纹理资源,获取各个目标压缩格式对应的压缩纹理资源分量;Step 330214: Based on the texture resource name and the target storage address corresponding to each target compression format, obtain the compressed texture resource corresponding to each target compression format, and based on the proportion of the target compressed texture resource in each target compression format and the compressed texture resource corresponding to each target compression format, obtain the compressed texture resource component corresponding to each target compression format.

步骤330215,将获取的各个目标压缩格式的压缩纹理资源分量整合为目标压缩纹理资源。Step 330215: Integrate the obtained compressed texture resource components of each target compression format into a target compressed texture resource.

不同于上述根据压缩损失率或压缩速率确定目标纹理资源的实施例,本实施例将同时基于压缩损失率和压缩速率确定目标压缩纹理资源。此外,本实施例不是简单的把某个目标存储地址的目标压缩纹理资源确定为最终的目标压缩纹理资源,而是基于多个目标压缩格式对应的压缩纹理资源分量进行整合得到最终的目标压缩纹理资源。Unlike the embodiments described above that determine the target texture resource based on compression loss rate or compression rate, this embodiment determines the target compressed texture resource based on both compression loss rate and compression rate. Furthermore, this embodiment does not simply determine the target compressed texture resource at a specific target storage address as the final target compressed texture resource; instead, it integrates the compressed texture resource components corresponding to multiple target compression formats to obtain the final target compressed texture resource.

需要说明的是,步骤330211中的压缩损失率和压缩速率已在上文解释,此处不再赘述。压缩增益函数用于评估多个目标压缩压缩格式对应的压缩算法的平均性能。压缩增益函数基于多个目标压缩格式的压缩纹理资源占比、每个目标压缩格式的压缩损失率和压缩速率确定。压缩纹理资源占比是指每个目标压缩格式对应的纹理资源的占比。所有的目标压缩格式的压缩纹理资源占比的总和为1。It should be noted that the compression loss rate and compression rate in step 330211 have already been explained above and will not be repeated here. The compression gain function is used to evaluate the average performance of compression algorithms corresponding to multiple target compression formats. The compression gain function is determined based on the proportion of compressed texture resources in multiple target compression formats, the compression loss rate of each target compression format, and the compression rate. The proportion of compressed texture resources refers to the proportion of texture resources corresponding to each target compression format. The sum of the proportions of compressed texture resources of all target compression formats is 1.

在一些实施例中,步骤330212包括:获取各个目标压缩格式的压缩增益子函数,压缩增益子函数基于目标压缩格式的压缩损失率和压缩速率确定;将各个目标压缩格式的压缩纹理资源占比,作为各个目标压缩格式的压缩增益子函数的权重,并基于该权重,对各个压缩增益子函数进行加权求和,得到压缩增益函数。In some embodiments, step 330212 includes: obtaining compression gain sub-functions for each target compression format, wherein the compression gain sub-functions are determined based on the compression loss rate and compression rate of the target compression format; using the proportion of compressed texture resources of each target compression format as the weight of the compression gain sub-function of each target compression format, and performing a weighted summation of each compression gain sub-function based on the weight to obtain a compression gain function.

针对每个目标压缩格式,可以根据目标压缩格式对应的初始压缩纹理资源和目标应用纹理资源计算得到压缩损失率,也可以计算得到压缩速率。关于压缩损失率和压缩速率的具体计算公式可参照上文,此处不再赘述。压缩增益子函数与压缩损失率成正比,且压缩增益子函数与压缩速率成反比。For each target compression format, the compression loss rate and compression rate can be calculated based on the initial compressed texture resources and the target application texture resources corresponding to the target compression format. The specific calculation formulas for the compression loss rate and compression rate are described above and will not be repeated here. The compression gain sub-function is directly proportional to the compression loss rate and inversely proportional to the compression rate.

在一例子中,压缩增益子函数通过以下公式计算得到:
In one example, the compression gain subfunction is calculated using the following formula:

在公式(1)中,Gt为第t个目标压缩格式的压缩增益子函数,Rt为第t个目标压缩格式的压缩速率,Lt为第t个目标压缩格式的压缩损失率。公式(1)说明了压缩增益子函数随着压缩速率的增加而增加,即压缩速率越高,压缩增益系数也越高。公式(1)也说明了压缩增益子函数随着压缩损失率的增加而减少,即压缩损失率越高,压缩增益系数也越低。In formula (1), G <sub>t</sub> is the compression gain subfunction of the t-th target compression format, R<sub>t</sub> is the compression rate of the t-th target compression format, and L<sub>t</sub> is the compression loss rate of the t-th target compression format. Formula (1) shows that the compression gain subfunction increases with the increase of the compression rate, that is, the higher the compression rate, the higher the compression gain coefficient. Formula (1) also shows that the compression gain subfunction decreases with the increase of the compression loss rate, that is, the higher the compression loss rate, the lower the compression gain coefficient.

压缩纹理资源占比用于指示每个目标压缩格式的纹理资源的占比。上述的每个目标压缩格式对应的压缩速率和压缩损失率是已知量,也叫常量,但各个目标压缩格式的压缩纹理资源占比是一个未知量,也叫变量。因此压缩增益函数是指一个以各个目标压缩格式的压缩纹理资源占比为变量的函数。The compressed texture resource proportion indicates the proportion of texture resources in each target compression format. The compression rate and compression loss rate for each target compression format are known quantities, also called constants, but the compressed texture resource proportion for each target compression format is an unknown quantity, also called a variable. Therefore, the compression gain function is a function that takes the compressed texture resource proportion of each target compression format as a variable.

在一例子中,压缩增益函数通过以下公式计算得到:
In one example, the compression gain function is calculated using the following formula:

在公式(2)中,G是指压缩增益函数,T是指目标压缩格式的数目,at为第t个目标压缩格式的压缩纹理资源占比,Gt为第t个目标压缩格式的压缩增益子函数。In formula (2), G refers to the compression gain function, T refers to the number of target compression formats, a_t is the proportion of compressed texture resources in the t-th target compression format, and G_t is the compression gain sub-function of the t-th target compression format.

在确定压缩增益函数之后,需要对压缩增益函数进行求解,以便得到各个目标压缩格式的目标压缩纹理资源占比。求解出的目标压缩纹理资源占比是已知量,也叫常量,能够用于后续步骤中的资源整合。因此,在步骤330213中,当压缩增益函数最大化时,确定多个目标压缩格式的目标压缩纹理资源占比。After determining the compression gain function, it needs to be solved to obtain the target compressed texture resource proportions for each target compression format. The solved target compressed texture resource proportions are known quantities, also called constants, and can be used for resource integration in subsequent steps. Therefore, in step 330213, when the compression gain function is maximized, the target compressed texture resource proportions for multiple target compression formats are determined.

然后在步骤330214中,基于与纹理资源名称和各个目标压缩格式对应的目标存储地址,获取各目标压缩格式对应的压缩纹理资源,并基于每个目标压缩格式的目标压缩纹理资源占比、和各目标压缩格式对应的压缩纹理资源,获取各个目标压缩格式对应的压缩纹理资源分量。Then, in step 330214, based on the texture resource name and the target storage address corresponding to each target compression format, the compressed texture resource corresponding to each target compression format is obtained, and based on the proportion of the target compressed texture resource in each target compression format and the compressed texture resource corresponding to each target compression format, the compressed texture resource component corresponding to each target compression format is obtained.

在一例子中,假定T=3,即有3个目标压缩格式,且假定G1=1、G2=2、G3=3。需要最大化压缩增益函数G=a1G1+a2G2+a3G3=a1*1+a2*2+a3*3,且约束条件为a1+a2+a3=1,且a1,a2,a3均大于或等于0。在G=3时,可以得到{a1=0,a2=0,a3=1}。因此在该例子中,t=1的目标压缩格式的目标压缩纹理资源占比为0,t=2的目标压缩格式的目标压缩纹理资源占比为0,t=3的目标压缩格式的目标压缩纹理资源占比为1。按照目标压缩纹理资源占比为{a1=0,a2=0,a3=1}、可以获取t=1的目标压缩格式的压缩纹理资源分量为0,获取t=2的目标压缩格式的压缩纹理资源分量也为0,获取t=3的目标压缩格式的压缩纹理资源分量为1;In one example, assume T = 3, meaning there are 3 target compression formats, and assume G1 = 1, G2 = 2, and G3 = 3. We need to maximize the compression gain function G = a1G1 + a2G2 + a3G3 = a1 *1 + a2 *2 + a3 *3, with the constraint that a1 + a2 + a3 = 1 , and a1 , a2 , and a3 are all greater than or equal to 0. When G = 3 , we get { a1 = 0, a2 = 0, a3 = 1}. Therefore, in this example, the target compressed texture resource ratio for the target compression format at t = 1 is 0, the target compressed texture resource ratio for the target compression format at t = 2 is 0, and the target compressed texture resource ratio for the target compression format at t = 3 is 1. Based on the target compressed texture resource ratio of { a1 = 0, a2 = 0, a3 = 1}, we can obtain that the compressed texture resource component of the target compressed format at t=1 is 0, the compressed texture resource component of the target compressed format at t=2 is also 0, and the compressed texture resource component of the target compressed format at t=3 is 1.

最后在步骤330215中,将获取的各个目标压缩格式的压缩纹理资源分量整合为目标压缩纹理资源。Finally, in step 330215, the compressed texture resource components of each target compression format are integrated into a target compressed texture resource.

接上述示例,将获取的3个目标压缩格式的压缩纹理资源分量整合为目标压缩纹理资源。Following the example above, the three compressed texture resource components of the target compression format are integrated into a target compressed texture resource.

上述利用最大化压缩增益函数确定各个目标压缩格式的目标压缩纹理资源占比的实施例的优点在于,可以提高确定目标压缩纹理资源占比的准确性和灵活性。The advantage of the above embodiment, which uses the maximization of the compression gain function to determine the proportion of target compressed texture resources for each target compression format, is that it can improve the accuracy and flexibility of determining the proportion of target compressed texture resources.

上述利用目标压缩纹理资源占比将各个目标压缩格式的压缩纹理资源进行整合得到目标压缩纹理资源的实施例的优点在于,可以提高确定的目标压缩纹理资源具有较高的压缩增益,能够提高资源渲染质量。The advantage of the above embodiment, which integrates compressed texture resources of various target compression formats using the target compressed texture resource ratio, is that it can improve the compression gain of the determined target compressed texture resources and improve the resource rendering quality.

步骤430的详细描述Detailed description of step 430

参照图3,步骤430被划分为:步骤4301,从第一电子设备接收目标压缩纹理资源;步骤4302,基于目标压缩纹理资源进行目标应用的渲染。Referring to Figure 3, step 430 is divided into: step 4301, receiving target compressed texture resources from the first electronic device; and step 4302, rendering the target application based on the target compressed texture resources.

在实际实施时,第一电子设备通过执行步骤3303,完成将目标压缩纹理资源发送给第二电子设备,从而第二电子设备通过执行步骤4301,完成从第一电子设备接收目标压缩纹理资源。在第二电子设备接收到目标压缩纹理资源之后,可以立即执行步骤4302,也可以对目标压缩纹理资源进行验证之后,再执行步骤4302。增加验证过程可以验证目标压缩纹理资源的有效性和准确性,减少第二电子设备因运行无效或出错的目标压缩纹理资源导致的处理资源的浪费。In practice, the first electronic device sends the target compressed texture resource to the second electronic device by executing step 3303, and the second electronic device receives the target compressed texture resource from the first electronic device by executing step 4301. After receiving the target compressed texture resource, the second electronic device can immediately execute step 4302, or it can verify the target compressed texture resource before executing step 4302. Adding a verification process can verify the validity and accuracy of the target compressed texture resource, reducing the waste of processing resources by the second electronic device due to running invalid or erroneous target compressed texture resources.

在一实施例中,步骤4302包括:将目标压缩纹理资源存储在目标存储空间,并将目标压缩纹理资源发送到渲染处理单元;在接收到渲染处理单元基于目标压缩纹理资源渲染成功的消息后,从目标存储空间中删除目标压缩纹理资源。In one embodiment, step 4302 includes: storing the target compressed texture resource in the target storage space and sending the target compressed texture resource to the rendering processing unit; after receiving a message from the rendering processing unit that the rendering was successful based on the target compressed texture resource, deleting the target compressed texture resource from the target storage space.

需要说明的是,目标存储空间是指第二电子设备上用于存储与目标应用的相关数据的存储区域。目标存储空间存储应用容器。参照上文,应用容器包括应用程序包和更新资源包。第二电子设备可以将目标压缩纹理资源存储至更新资源包中,则存储成功之后更新资源包包括目标压缩纹理资源。第二电子设备还可以将目标压缩纹理资源存储至目标存储空间中除应用容器之外的空间。渲染处理单元是配置为进行资源渲染的处理单元,通常是指GPU。It should be noted that the target storage space refers to the storage area on the second electronic device used to store data related to the target application. The target storage space stores the application container. Referring to the above, the application container includes the application package and the update resource package. If the second electronic device can store the target compressed texture resource into the update resource package, then after successful storage, the update resource package will include the target compressed texture resource. The second electronic device can also store the target compressed texture resource in a space within the target storage space other than the application container. The rendering processing unit is a processing unit configured to perform resource rendering, typically referring to the GPU.

应用上述实施例,第二电子设备从第一电子设备接收目标压缩纹理资源后读取到目标应用的目标存储空间上并上传至GPU中即可完成对纹理资源的渲染,且渲染成功后,第二电子设备将立即释放目标压缩纹理资源所占用的存储空间,在实现渲染的同时减少空间占用。Using the above embodiments, after the second electronic device receives the target compressed texture resource from the first electronic device, it reads it into the target storage space of the target application and uploads it to the GPU to complete the rendering of the texture resource. After the rendering is successful, the second electronic device will immediately release the storage space occupied by the target compressed texture resource, thereby reducing space occupation while realizing rendering.

在一例子中,第二电子设备基于目标压缩纹理资源进行目标应用的渲染的过程包括:(1)加载目标压缩纹理资源:第二电子设备需要根据支持的目标压缩格式对目标压缩纹理资源进行解压缩为目标应用纹理资源,可以是图片文件(如PNG、JPEG等格式)或其他类型的纹理数据。这些数据包含了纹理的颜色信息和其他属性。(2)创建纹理对象:第二电子设备会将加载的纹理数据转换为纹理对象,通常是在渲染处理单元(比如GPU)中创建,以便后续的渲染操作。(3)绑定纹理对象:在渲染之前,终端需要将所需的纹理对象绑定到渲染管线的特定纹理单元上,以便在渲染过程中使用。(4)在着色器中使用纹理:在顶点着色器和片段着色器中,通过纹理坐标和纹理采样器,可以从绑定的纹理对象中获取对应的纹理颜色值。(5)渲染对象:第二电子设备在渲染对象时,根据需要的纹理信息和纹理坐标,将纹理颜色混合到最终的像素颜色中,以实现纹理贴图效果。总的来说,第二电子设备利用目标压缩纹理资源进行渲染的过程涉及加载纹理资源、创建纹理对象、绑定纹理对象、在着色器中使用纹理以及渲染对象等步骤。这些步骤需要在渲染处理单元中进行,以实现纹理贴图效果。In one example, the process of rendering a target application based on a target compressed texture resource by the second electronic device includes: (1) Loading the target compressed texture resource: The second electronic device needs to decompress the target compressed texture resource into a target application texture resource according to the supported target compression format. This can be an image file (such as PNG, JPEG, etc.) or other types of texture data. This data contains the texture's color information and other attributes. (2) Creating a texture object: The second electronic device will convert the loaded texture data into a texture object, usually created in the rendering processing unit (such as the GPU) for subsequent rendering operations. (3) Binding the texture object: Before rendering, the terminal needs to bind the required texture object to a specific texture unit of the rendering pipeline for use during the rendering process. (4) Using the texture in the shader: In the vertex shader and fragment shader, the corresponding texture color value can be obtained from the bound texture object through texture coordinates and texture samplers. (5) Rendering the object: When rendering the object, the second electronic device mixes the texture color into the final pixel color according to the required texture information and texture coordinates to achieve the texture mapping effect. In summary, the process of rendering using target compressed texture resources by the second electronic device involves steps such as loading texture resources, creating texture objects, binding texture objects, using textures in shaders, and rendering objects. These steps need to be performed in the rendering processing unit to achieve the texture mapping effect.

应用纹理资源渲染方法还包括的步骤的详细描述The application of texture resource rendering methods also includes a detailed description of the steps.

需要说明的是,上述实施例中,第一电子设备能够向终端发送目标压缩纹理资源的前提是目标压缩格式属于多个候选压缩格式。但在一些实施例中,目标压缩格式可能不属于多个候选压缩格式,导致第一电子设备无法从候选压缩纹理资源中确定目标压缩纹理资源并发送给终端。为此,如前文所述,基于图6,在步骤32012中,不仅存储了多个候选压缩纹理资源,还存储了目标应用纹理资源,以便可以给第二电子设备直接发送目标应用纹理资源。It should be noted that in the above embodiments, the premise for the first electronic device to send the target compressed texture resource to the terminal is that the target compression format belongs to multiple candidate compression formats. However, in some embodiments, the target compression format may not belong to multiple candidate compression formats, causing the first electronic device to be unable to determine the target compressed texture resource from the candidate compressed texture resources and send it to the terminal. Therefore, as mentioned above, based on Figure 6, in step 32012, not only are multiple candidate compressed texture resources stored, but also the target application texture resource is stored so that the target application texture resource can be directly sent to the second electronic device.

基于此,参照图13,图13是本申请实施例提供的应用纹理渲染方法的流程示意图,基于图13,应用纹理渲染方法还包括:步骤340(第一电子设备执行)和步骤440(第二电子设备执行)。步骤340可以划分为:步骤3401,从第二电子设备接收到第二电子设备发送的资源请求,资源请求用于请求目标压缩纹理资源,目标压缩纹理资源为,采用目标压缩格式对目标应用纹理资源进行压缩得到的;步骤3402,如果目标压缩格式不属于多个候选压缩格式,获取存储的目标应用纹理资源;步骤3403,将目标应用纹理资源发送到第二电子设备;其中,目标压缩纹理资源用于供第二电子设备利用目标应用纹理资源进行目标应用的渲染。步骤440可以划分为:步骤4401,从第一电子设备接收目标应用纹理资源;步骤4402,利用目标应用纹理资源进行目标应用的渲染。Based on this, referring to Figure 13, which is a flowchart illustrating the application texture rendering method provided in this embodiment, the application texture rendering method further includes: step 340 (executed by the first electronic device) and step 440 (executed by the second electronic device). Step 340 can be divided into: step 3401, receiving a resource request from the second electronic device, the resource request being used to request a target compressed texture resource, the target compressed texture resource being obtained by compressing the target application texture resource using a target compression format; step 3402, if the target compression format does not belong to multiple candidate compression formats, obtaining the stored target application texture resource; step 3403, sending the target application texture resource to the second electronic device; wherein, the target compressed texture resource is used by the second electronic device to render the target application using the target application texture resource. Step 440 can be divided into: step 4401, receiving the target application texture resource from the first electronic device; step 4402, rendering the target application using the target application texture resource.

在步骤3401中,第二电子设备向第一电子设备发送的资源请求可以包括纹理资源名称和目标压缩格式,从而由第一电子设备根据请求中的纹理资源名称和目标压缩格式确定目标存储地址,再由第一电子设备根据目标存储地址获取目标压缩纹理资源。In step 3401, the resource request sent by the second electronic device to the first electronic device may include a texture resource name and a target compression format. The first electronic device then determines the target storage address based on the texture resource name and target compression format in the request, and then obtains the target compressed texture resource based on the target storage address.

又或者,第二电子设备向第一电子设备发送的资源请求还可以直接包括目标存储地址(即由第二电子设备提前根据纹理资源名称和目标压缩格式确定目标存储地址),从而由第一电子设备根据目标存储地址获取目标压缩纹理资源。Alternatively, the resource request sent by the second electronic device to the first electronic device may directly include the target storage address (i.e., the target storage address is determined in advance by the second electronic device based on the texture resource name and the target compression format), so that the first electronic device can obtain the target compressed texture resource based on the target storage address.

在步骤3402中,由于目标压缩格式不属于多个候选压缩格式,从而目标存储地址不属于多个候选存储地址,导致第一电子设备无法根据目标存储地址获取目标压缩纹理资源,因此第一电子设备获取的是存储的目标应用纹理资源。In step 3402, since the target compression format does not belong to the multiple candidate compression formats, the target storage address does not belong to the multiple candidate storage addresses, which causes the first electronic device to be unable to obtain the target compressed texture resource based on the target storage address. Therefore, the first electronic device obtains the stored target application texture resource.

然后,在步骤3403中,第一电子设备将目标应用纹理资源发送到第二电子设备。Then, in step 3403, the first electronic device sends the target application texture resource to the second electronic device.

在步骤4401中,与步骤4301接收的是目标压缩纹理资源不同,由于第二电子设备支持的目标压缩格式不属于多个候选压缩格式,即使获取到目标压缩纹理资源也无法正常解析,因此第二电子设备接收的是目标应用纹理资源,无需终端解析也能够完成资源渲染,提高资源渲染有效性。In step 4401, unlike step 4301 where the target compressed texture resource is received, the target compression format supported by the second electronic device does not belong to multiple candidate compression formats. Even if the target compressed texture resource is obtained, it cannot be parsed normally. Therefore, the second electronic device receives the target application texture resource, which can complete the resource rendering without terminal parsing, thus improving the effectiveness of resource rendering.

上述步骤340和440的实施例的优点在于,即使第二电子设备支持的目标压缩格式不属于多个候选压缩格式,第二电子设备也会接收到服务器发送的目标应用纹理资源,使得第二电子设备能够进行正常渲染,提高了应用纹理资源渲染的有效性。The advantage of the embodiments of steps 340 and 440 described above is that even if the target compression format supported by the second electronic device does not belong to multiple candidate compression formats, the second electronic device will still receive the target application texture resource sent by the server, enabling the second electronic device to perform normal rendering and improving the effectiveness of application texture resource rendering.

本申请实施例的应用纹理渲染方法的总体实现示意图A schematic diagram illustrating the overall implementation of the texture rendering method in this application embodiment.

下面参照图14,图14是本申请实施例提供的应用纹理渲染方法的流程示意图,基于图14,接下来详细示例性说明本申请实施例的应用纹理渲染方法的实施细节。Referring to Figure 14, which is a flowchart illustrating the application texture rendering method provided in an embodiment of this application, the implementation details of the application texture rendering method in the following exemplary description will be provided in detail.

(1)服务器(第一电子设备)获取目标应用的初始资源包,初始资源包包括目标应用的初始压缩格式的初始压缩纹理资源。(1) The server (first electronic device) obtains the initial resource package of the target application, which includes the initial compressed texture resources of the target application in the initial compressed format.

例如,假定初始压缩格式为ETC格式且假定初始压缩纹理资源为初始压缩漫反射贴图资源,则初始资源包包括ETC格式的初始压缩漫反射贴图资源,且初始资源包中的纹理资源压缩格式字段为ETC格式。For example, assuming the initial compression format is ETC format and the initial compressed texture resource is an initial compressed diffuse map resource, then the initial resource package includes an initial compressed diffuse map resource in ETC format, and the texture resource compression format field in the initial resource package is ETC format.

(2)服务器将初始压缩纹理资源解压为目标应用纹理资源,将初始资源包中的初始压缩纹理资源替换为占位符数据,得到更新资源包,将更新资源包的纹理资源压缩格式字段改为锚压缩格式,并将更新资源包发送到终端。(2) The server decompresses the initial compressed texture resources into the target application texture resources, replaces the initial compressed texture resources in the initial resource package with placeholder data to obtain the updated resource package, changes the texture resource compression format field of the updated resource package to the anchor compression format, and sends the updated resource package to the terminal.

例如,服务器将初始压缩漫反射贴图资源解压为目标应用漫反射贴图资源,将初始资源包中的初始压缩漫反射贴图资源替换为占位符数据(占位符数据具体为“漫反射贴图”),以及服务器还将纹理资源压缩格式字段由ETC格式改为锚压缩格式,得到并将更新资源包发送给终端。For example, the server decompresses the initial compressed diffuse map resource into the target application's diffuse map resource, replaces the initial compressed diffuse map resource in the initial resource package with placeholder data (the placeholder data is specifically "diffuse map"), and the server also changes the texture resource compression format field from ETC format to anchor compression format, and sends the updated resource package to the terminal.

(3)服务器将目标应用纹理资源分别按照多个候选压缩格式,压缩为多个候选压缩纹理资源。(3) The server compresses the target application texture resources into multiple candidate compressed texture resources according to multiple candidate compression formats.

例如,候选压缩格式可以为ETC格式、ASTC格式、PVRTC格式和DXT格式等。ETC格式对应候选压缩纹理资源h1、ASTC格式对应候选压缩纹理资源h2、PVRTC格式对应候选压缩纹理资源h3、DXT格式对应候选压缩纹理资源h4。For example, candidate compression formats can be ETC, ASTC, PVRTC, and DXT formats. The corresponding candidate compressed texture resource is h1 for ETC format, h2 for ASTC format, h3 for PVRTC format, and h4 for DXT format.

(4)服务器按照与纹理资源名称和候选压缩格式对应的候选存储地址存储多个候选压缩纹理资源,以及存储目标应用纹理资源。(4) The server stores multiple candidate compressed texture resources according to the candidate storage address corresponding to the texture resource name and candidate compression format, as well as the target application texture resources.

服务器根据纹理资源名称和候选压缩格式确定候选存储地址的具体过程已在前文描述,此处不再赘述。例如,多个候选存储地址包括:ETC格式对应的候选存储地址为XX:XX\MEh1、ASTC格式对应的候选存储地址为XX:XX\MAh2、PVRTC格式对应的候选存储地址为XX:XX\MPh3、以及DXT格式对应的候选存储地址为XX:XX\MDh4等等。The specific process by which the server determines the candidate storage address based on the texture resource name and candidate compression format has been described above and will not be repeated here. For example, multiple candidate storage addresses include: XX:XX\MEh1 for ETC format, XX:XX\MAh2 for ASTC format, XX:XX\MPh3 for PVRTC format, and XX:XX\MDh4 for DXT format, etc.

(5)终端(第二电子设备)从服务器接收目标应用的应用容器,应用容器中包括应用程序包和更新资源包。参照步骤(1),更新资源包中包括占位符数据和纹理资源压缩格式字段。(5) The terminal (second electronic device) receives the application container of the target application from the server. The application container includes an application package and an update resource package. Referring to step (1), the update resource package includes placeholder data and a texture resource compression format field.

(6)终端通过主逻辑运行应用程序包,响应于在运行过程中识别出更新资源包中含有占位符数据且更新资源包中的纹理资源压缩格式字段为锚压缩格式,向纹理处理脚本中添加强制约束,强制约束指示支持锚压缩格式。(6) The terminal runs the application package through the main logic. In response to the identification during the operation that the updated resource package contains placeholder data and the texture resource compression format field in the updated resource package is the anchor compression format, a mandatory constraint is added to the texture processing script. The mandatory constraint indicates that the anchor compression format is supported.

(7)终端向纹理处理脚本发送查询请求,以便纹理处理脚本基于强制约束验证对锚压缩格式的支持,并查询终端支持的除锚压缩格式之外的目标压缩格式。例如,终端支持的目标压缩格式为ASTC格式。(7) The terminal sends a query request to the texture processing script so that the texture processing script can verify support for the anchor compression format based on mandatory constraints and query the target compression formats supported by the terminal other than the anchor compression format. For example, the target compression format supported by the terminal is the ASTC format.

(8)终端在用于渲染目标应用的渲染函数之前插入劫持语句;接着终端执行劫持语句,以便用目标压缩格式替换更新资源包中的占位符数据。(8) The terminal inserts a hijacking statement before the rendering function used to render the target application; then the terminal executes the hijacking statement to replace the placeholder data in the update resource package with the target compression format.

(9)终端基于资源包中的目标压缩格式,向服务器发送目标压缩纹理资源的请求。请求可以包括纹理资源名称和目标压缩格式。(9) The terminal sends a request for the target compressed texture resource to the server based on the target compression format in the resource package. The request may include the texture resource name and the target compression format.

例如,终端用ASTC格式替换更新资源包中的占位符数据,且终端向服务器发送的请求包括漫反射贴图和ASTC格式。For example, the terminal replaces placeholder data in the update resource pack with ASTC format, and the request sent by the terminal to the server includes diffuse texture and ASTC format.

(10)服务器当从终端接收到终端支持的目标压缩格式的目标压缩纹理资源的请求时,如果目标压缩格式属于多个候选压缩格式,服务器按照与纹理资源名称和目标压缩格式对应的目标存储地址,获取目标压缩纹理资源,发送到终端。或者,服务器当从终端接收到终端支持的目标压缩格式的目标压缩纹理资源的请求时,如果目标压缩格式不属于多个候选压缩格式,获取存储的目标应用纹理资源,发送到终端。(10) When the server receives a request from the terminal for a target compressed texture resource in a target compression format supported by the terminal, if the target compression format belongs to multiple candidate compression formats, the server retrieves the target compressed texture resource according to the target storage address corresponding to the texture resource name and the target compression format, and sends it to the terminal. Alternatively, when the server receives a request from the terminal for a target compressed texture resource in a target compression format supported by the terminal, if the target compression format does not belong to multiple candidate compression formats, the server retrieves the stored target application texture resource and sends it to the terminal.

例如,由于终端支持的ASTC格式属于多个候选压缩格式中的ASTC格式,因此服务器可以根据漫反射贴图和ASTC格式从多个候选存储地址中确定目标存储地址为XX:XX\MAh2,并基于XX:XX\MAh2获取目标压缩纹理资源。For example, since the ASTC format supported by the terminal is one of the multiple candidate compression formats, the server can determine the target storage address as XX:XX\MAh2 from multiple candidate storage addresses based on the diffuse map and the ASTC format, and obtain the target compressed texture resource based on XX:XX\MAh2.

(11)终端从服务器接收目标压缩纹理资源,以进行目标应用的渲染;或者,终端从服务器接收目标应用纹理资源,以进行目标应用的渲染。(11) The terminal receives the target compressed texture resource from the server to render the target application; or, the terminal receives the target application texture resource from the server to render the target application.

本申请实施例能够有效解决Unity平台按终端发行目标应用(比如WebGL游戏)的个性资源包存在的压缩格式比较固定的问题,使得目标应用具备在不同终端/设备下对纹理资源充分利用GPU计算与存储带来的渲染性能提升能力。从应用运行上而言,由于本申请实施例中纹理资源是真正意义上的按需加载,即需要渲染时才被加载到内存中使用,以纹理资源文件作为最小粒度单位,相比于Unity平台所提供的Unity资源包方案的粒度更细,不会造成AB包内其他闲置资源导致的额外内存占用。同时也消除了同一份资源可能在多个Unity资源包中重复打包引发的磁盘、内存空间冗余占用问题。从应用开发者角度而言,本申请实施例是对导出的应用容器进行相应的处理,因此无需对应用程序包中的代码上做任何修改与编辑,使用方式仅通过面板即可完成转换,易于广泛的使用。本申请实施例具有较高的普适性,且达到减少了对终端的内存空间的占用。This application effectively solves the problem of fixed compression formats in personalized resource packages for target applications (such as WebGL games) distributed by the Unity platform on different terminals. This allows the target application to fully utilize the rendering performance improvements brought by GPU computing and storage across different terminals/devices. From an application operation perspective, because the texture resources in this application are truly loaded on demand—that is, only loaded into memory when rendering is required—and the texture resource file is used as the smallest granularity, the granularity is finer than the Unity resource package solution provided by the Unity platform, avoiding additional memory consumption caused by other idle resources within the AB package. It also eliminates the problem of redundant disk and memory space usage caused by the same resource being repeatedly packaged in multiple Unity resource packages. From the application developer's perspective, this application only processes the exported application container, so no modification or editing of the application package's code is required. The conversion can be completed simply through the panel, making it easy to use widely. This application has high universality and reduces the memory space occupied on the terminal.

本申请实施例的装置和设备描述Description of apparatus and devices in embodiments of this application

可以理解的是,虽然上述各个流程图中的各个步骤按照箭头的表征依次显示,但是这些步骤并不是必然按照箭头表征的顺序依次执行。除非本申请实施例中有明确的说明,这些步骤的执行并没有严格的顺序限制,这些步骤可以以其它的顺序执行。而且,上述流程图中的至少一部分步骤可以包括多个步骤或者多个阶段,这些步骤或者阶段并不必然是在同一时间执行完成,而是可以在不同的时间执行,这些步骤或者阶段的执行顺序也不必然是依次进行,而是可以与其它步骤或者其它步骤中的步骤或者阶段的至少一部分轮流或者交替地执行。It is understood that although the steps in the above flowcharts are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated in the embodiments of this application, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the above flowcharts may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps.

需要说明的是,在本申请的各个具体实施方式中,当涉及到需要根据对象属性信息或属性信息集合等与对象特性相关的数据进行相关处理时,都会先获得对象的许可或者同意,而且,对这些数据的收集、使用和处理等,都会遵守相关法律法规和标准。此外,当本申请实施例需要获取对象属性信息时,会通过弹窗或者跳转到确认页面等方式获得对象的单独许可或者单独同意,在明确获得对象的单独许可或者单独同意之后,再获取用于使本申请实施例能够正常运行的必要的对象相关数据。It should be noted that in various specific embodiments of this application, when processing data related to object characteristics, such as object attribute information or sets of attribute information, is required, the object's permission or consent will be obtained first. Furthermore, the collection, use, and processing of this data will comply with relevant laws, regulations, and standards. In addition, when embodiments of this application require obtaining object attribute information, separate permission or consent from the object will be obtained through pop-ups or redirection to a confirmation page. Only after obtaining the object's separate permission or consent will the necessary object-related data for the proper functioning of these embodiments be acquired.

图15是本申请实施例提供的应用于第一电子设备的应用纹理渲染装置1500的结构示意图。基于图15,其中,该应用纹理渲染装置1500具体包括:Figure 15 is a structural schematic diagram of an application texture rendering apparatus 1500 applied to a first electronic device according to an embodiment of this application. Based on Figure 15, the application texture rendering apparatus 1500 specifically includes:

第一发送单元1510,配置为获取目标应用的目标应用纹理资源及占位符数据,并发送所述占位符数据至第二电子设备;The first sending unit 1510 is configured to acquire the target application texture resources and placeholder data of the target application, and send the placeholder data to the second electronic device.

压缩单元1520,配置为按照多个候选压缩格式,将所述目标应用纹理资源分别压缩为多个候选压缩纹理资源;Compression unit 1520 is configured to compress the target application texture resource into multiple candidate compressed texture resources according to multiple candidate compression formats;

第二发送单元1530,配置为接收所述第二电子设备发送的资源请求,所述资源请求为所述第二电子设备获取到所述占位符数据后发送的,用于请求目标压缩纹理资源,所述目标压缩纹理资源为,采用目标压缩格式对所述目标应用纹理资源进行压缩得到的;如果所述目标压缩格式属于所述多个候选压缩格式,从所述多个候选压缩纹理资源中获取所述目标压缩纹理资源,并将所述目标压缩纹理资源发送到所述第二电子设备;其中,所述目标压缩纹理资源用于,供所述第二电子设备进行所述目标应用的渲染。The second sending unit 1530 is configured to receive a resource request sent by the second electronic device. The resource request is sent by the second electronic device after obtaining the placeholder data, and is used to request a target compressed texture resource. The target compressed texture resource is obtained by compressing the target application texture resource using a target compression format. If the target compression format belongs to the plurality of candidate compression formats, the target compressed texture resource is obtained from the plurality of candidate compressed texture resources, and the target compressed texture resource is sent to the second electronic device. The target compressed texture resource is used by the second electronic device to render the target application.

在一实施例中,第一发送单元1510,还配置为:In one embodiment, the first transmitting unit 1510 is further configured to:

获取所述目标应用的初始资源包,所述初始资源包包括所述目标应用的初始压缩格式的初始压缩纹理资源;Obtain the initial resource package of the target application, the initial resource package including the initial compressed texture resources of the target application in the initial compression format;

对所述初始压缩纹理资源进行解压,得到所述目标应用纹理资源。The initial compressed texture resource is decompressed to obtain the target application texture resource.

在一实施例中,初始资源包还包括初始压缩格式名称;第一发送单元1510,还配置为:In one embodiment, the initial resource packet further includes an initial compression format name; the first sending unit 1510 is also configured to:

获取初始压缩格式名称对应的初始压缩算法;Obtain the initial compression algorithm corresponding to the initial compression format name;

基于初始压缩算法,将初始压缩纹理资源解压为目标应用纹理资源。Based on the initial compression algorithm, the initially compressed texture resources are decompressed into the target application texture resources.

在一实施例中,所述装置还包括第一获取单元,第一获取单元,配置为:In one embodiment, the apparatus further includes a first acquisition unit, configured to:

获取所述目标应用的初始资源包,所述初始资源包包括所述目标应用的初始压缩纹理资源;Obtain the initial resource package of the target application, wherein the initial resource package includes the initial compressed texture resources of the target application;

将所述初始资源包中的所述初始压缩纹理资源替换为占位符数据,得到更新资源包;Replace the initial compressed texture resources in the initial resource package with placeholder data to obtain the updated resource package;

第一发送单元1510,还配置为:The first transmitting unit 1510 is also configured as follows:

发送所述更新资源包至第二电子设备。Send the updated resource package to the second electronic device.

在一实施例中,所述装置还包括更新单元,更新单元,配置为:In one embodiment, the apparatus further includes an updating unit, configured to:

将所述更新资源包的纹理资源压缩格式字段改为锚压缩格式,得到新的更新资源包;Change the texture resource compression format field of the updated resource package to the anchor compression format to obtain a new updated resource package;

第一发送单元1510,还配置为:The first transmitting unit 1510 is also configured as follows:

将所述新的更新资源包发送到所述第二电子设备;Send the new update resource package to the second electronic device;

其中,所述第二电子设备在识别出所述纹理资源压缩格式字段为所述锚压缩格式时,向纹理处理脚本中添加强制约束,所述强制约束指示支持所述锚压缩格式。When the second electronic device identifies the texture resource compression format field as the anchor compression format, it adds a mandatory constraint to the texture processing script, the mandatory constraint indicating support for the anchor compression format.

在一实施例中,占位符数据为纹理资源名称,资源请求包括纹理资源名称和目标压缩格式;所述装置还包括存储单元,存储单元,配置为:In one embodiment, the placeholder data is a texture resource name, and the resource request includes the texture resource name and the target compression format; the apparatus further includes a storage unit configured as follows:

针对各所述候选压缩格式,按照与所述纹理资源名称和所述候选压缩格式对应的候选存储地址,存储所述候选压缩纹理资源;For each of the candidate compression formats, the candidate compressed texture resources are stored according to the candidate storage address corresponding to the texture resource name and the candidate compression format;

第二发送单元1530,还配置为:如果所述目标压缩格式属于所述多个候选压缩格式,按照与所述纹理资源名称和所述目标压缩格式对应的目标存储地址,获取所述目标压缩纹理资源,其中,所述目标存储地址属于多个所述候选存储地址。The second sending unit 1530 is further configured to: if the target compression format belongs to the plurality of candidate compression formats, obtain the target compressed texture resource according to the target storage address corresponding to the texture resource name and the target compression format, wherein the target storage address belongs to the plurality of candidate storage addresses.

在一实施例中,存储单元,还配置为:In one embodiment, the storage unit is further configured as follows:

对所述纹理资源名称和所述候选压缩格式执行目标运算,得到所述候选存储地址;Perform a target operation on the texture resource name and the candidate compression format to obtain the candidate storage address;

按照所述候选存储地址,存储所述候选压缩纹理资源;Store the candidate compressed texture resources according to the candidate storage addresses;

第二发送单元1530,还配置为:The second transmitting unit 1530 is also configured as follows:

如果所述目标压缩格式属于所述多个候选压缩格式,对所述纹理资源名称和所述目标压缩格式执行所述目标运算,得到所述目标存储地址。If the target compression format belongs to the plurality of candidate compression formats, the target operation is performed on the texture resource name and the target compression format to obtain the target storage address.

在一实施例中,存储单元,还配置为:In one embodiment, the storage unit is further configured as follows:

获取第一对应关系表,所述第一对应关系表指示所述纹理资源名称、所述候选压缩格式、与候选存储地址的对应关系;Obtain a first correspondence table, which indicates the correspondence between the texture resource name, the candidate compression format, and the candidate storage address;

基于所述第一对应关系表,存储所述候选压缩纹理资源;Based on the first correspondence table, the candidate compressed texture resources are stored;

第二发送单元1530,还配置为:The second transmitting unit 1530 is also configured as follows:

如果所述目标压缩格式属于所述多个候选压缩格式,基于所述纹理资源名称和所述目标压缩格式查找所述第一对应关系表,得到所述目标存储地址。If the target compression format belongs to the plurality of candidate compression formats, the first correspondence table is searched based on the texture resource name and the target compression format to obtain the target storage address.

在一实施例中,所述占位符数据为纹理资源名称,所述资源请求包括目标存储地址,所述目标存储地址由所述第二电子设备根据所述纹理资源名称和所述目标压缩格式确定出;存储单元,还配置为:In one embodiment, the placeholder data is a texture resource name, the resource request includes a target storage address, the target storage address is determined by the second electronic device based on the texture resource name and the target compression format; the storage unit is further configured as follows:

针对各所述候选压缩格式,按照与所述纹理资源名称和所述候选压缩格式对应的候选存储地址,存储所述候选压缩纹理资源;For each of the candidate compression formats, the candidate compressed texture resources are stored according to the candidate storage address corresponding to the texture resource name and the candidate compression format;

第二发送单元1530,还配置为:The second transmitting unit 1530 is also configured as follows:

如果所述目标压缩格式属于所述多个候选压缩格式,按照所述资源请求中的所述目标存储地址,获取所述目标压缩纹理资源,其中,所述目标存储地址属于多个所述候选存储地址。If the target compression format belongs to the plurality of candidate compression formats, the target compressed texture resource is obtained according to the target storage address in the resource request, wherein the target storage address belongs to the plurality of candidate storage addresses.

在一实施例中,第二发送单元1530,还配置为:In one embodiment, the second transmitting unit 1530 is further configured to:

如果目标压缩格式的数量为多个,获取每个所述目标压缩格式的压缩损失率;If there are multiple target compression formats, obtain the compression loss rate for each target compression format;

基于各所述目标压缩格式的压缩损失率,从各所述目标压缩格式对应的目标存储地址中,选取压缩损失率最小的目标压缩格式所对应的目标存储地址;Based on the compression loss rate of each target compression format, the target storage address corresponding to the target compression format with the smallest compression loss rate is selected from the target storage addresses corresponding to each target compression format.

基于选取的所述目标存储地址,获取目标压缩纹理资源。Based on the selected target storage address, the target compressed texture resource is obtained.

在一实施例中,目标压缩格式的数量为多个;In one embodiment, the number of target compression formats is multiple;

第二发送单元1530,还配置为:The second transmitting unit 1530 is also configured as follows:

如果目标压缩格式的数量为多个,获取每个目标压缩格式的压缩损失率和压缩速率;If there are multiple target compression formats, obtain the compression loss rate and compression rate for each target compression format;

获取压缩增益函数,压缩增益函数基于多个目标压缩格式的压缩纹理资源占比、每个目标压缩格式的压缩损失率和压缩速率确定;Obtain the compression gain function, which is determined based on the proportion of compressed texture resources in multiple target compression formats, the compression loss rate of each target compression format, and the compression rate.

当压缩增益函数最大化时,确定每个目标压缩格式的目标压缩纹理资源占比;When the compression gain function is maximized, the proportion of target compressed texture resources for each target compression format is determined.

基于与纹理资源名称和各个目标压缩格式对应的目标存储地址,获取各目标压缩格式对应的压缩纹理资源,并基于每个目标压缩格式的目标压缩纹理资源占比、和各目标压缩格式对应的压缩纹理资源,获取各个目标压缩格式对应的压缩纹理资源分量;将获取的各个目标压缩格式的压缩纹理资源分量整合为目标压缩纹理资源。Based on the texture resource name and the target storage address corresponding to each target compression format, obtain the compressed texture resources corresponding to each target compression format. Based on the proportion of the target compressed texture resources in each target compression format and the compressed texture resources corresponding to each target compression format, obtain the compressed texture resource components corresponding to each target compression format. Integrate the obtained compressed texture resource components of each target compression format into a target compressed texture resource.

在一实施例中,第二发送单元1530,还配置为:In one embodiment, the second transmitting unit 1530 is further configured to:

获取各个目标压缩格式的压缩增益子函数,压缩增益子函数基于目标压缩格式的压缩损失率和压缩速率确定;Obtain the compression gain sub-function for each target compression format. The compression gain sub-function is determined based on the compression loss rate and compression rate of the target compression format.

将各个目标压缩格式的压缩纹理资源占比,作为各个目标压缩格式的压缩增益子函数的权重,并基于该权重,对各个压缩增益子函数进行加权求和,得到压缩增益函数。The proportion of compressed texture resources in each target compression format is used as the weight of the compression gain sub-function of each target compression format. Based on this weight, the compression gain sub-functions are weighted and summed to obtain the compression gain function.

在一实施例中,第二发送单元1530,还配置为:In one embodiment, the second transmitting unit 1530 is further configured to:

如果目标压缩格式的数量为多个,获取每个所述目标压缩格式的压缩速率;If there are multiple target compression formats, obtain the compression rate of each target compression format;

基于各所述目标压缩格式的压缩速率,从各所述目标压缩格式对应的目标存储地址中,选取压缩速率最大的目标压缩格式所对应的目标存储地址;Based on the compression rate of each target compression format, the target storage address corresponding to the target compression format with the highest compression rate is selected from the target storage addresses corresponding to each target compression format;

基于选取的所述目标存储地址,获取目标压缩纹理资源。Based on the selected target storage address, the target compressed texture resource is obtained.

在一实施例中,第二发送单元1530,还配置为:In one embodiment, the second transmitting unit 1530 is further configured to:

存储所述多个候选压缩纹理资源和所述目标应用纹理资源;Store the plurality of candidate compressed texture resources and the target application texture resource;

如果所述目标压缩格式不属于所述多个候选压缩格式,获取存储的所述目标应用纹理资源,发送到所述第二电子设备。If the target compression format does not belong to the plurality of candidate compression formats, the stored target application texture resource is obtained and sent to the second electronic device.

需要说明的是,上述应用纹理资源渲染装置的具体实施方式与上述应用纹理资源渲染方法的具体实施例基本相同,在此不再赘述。It should be noted that the specific implementation of the above-mentioned texture resource rendering device is basically the same as the specific implementation of the above-mentioned texture resource rendering method, and will not be repeated here.

图16是本申请实施例提供的应用于第二电子设备的应用纹理渲染装置1600的结构示意图。该应用纹理渲染装置1600具体包括:Figure 16 is a schematic diagram of an application texture rendering apparatus 1600 for a second electronic device provided in an embodiment of this application. The application texture rendering apparatus 1600 specifically includes:

确定单元1610,配置为响应于获取到从第一电子设备发送的目标应用的占位符数据,确定所述第二电子设备支持的目标压缩格式;;The determining unit 1610 is configured to determine a target compression format supported by the second electronic device in response to receiving placeholder data of a target application sent from the first electronic device.

第三发送单元1620,配置为向所述第一电子设备发送资源请求,所述资源请求用于请求目标压缩纹理资源,所述目标压缩纹理资源为,采用目标压缩格式对目标应用纹理资源进行压缩得到的;The third sending unit 1620 is configured to send a resource request to the first electronic device. The resource request is used to request a target compressed texture resource. The target compressed texture resource is obtained by compressing a target application texture resource using a target compression format.

第一接收单元1630,配置为从所述第一电子设备接收所述目标压缩纹理资源,并基于所述目标压缩纹理资源进行所述目标应用的渲染;其中,所述第一电子设备发送所述目标应用的占位符数据时,还按照多个候选压缩格式,将获取的目标应用纹理资源分别压缩为多个候选压缩纹理资源;所述多个候选压缩格式包括所述目标压缩格式,多个所述候选压缩纹理资源包括所述目标压缩纹理资源。The first receiving unit 1630 is configured to receive the target compressed texture resource from the first electronic device and render the target application based on the target compressed texture resource; wherein, when the first electronic device sends the placeholder data of the target application, it also compresses the acquired target application texture resource into multiple candidate compressed texture resources according to multiple candidate compression formats; the multiple candidate compression formats include the target compression format, and the multiple candidate compressed texture resources include the target compressed texture resource.

在一实施例中,占位符数据存在于应用程序包;确定单元1610,配置为:通过主逻辑运行所述应用程序包,响应于在运行过程中识别出所述应用程序包中含有占位符数据,通过纹理处理脚本查询所述第二电子设备支持的目标压缩格式。In one embodiment, placeholder data exists in the application package; the determining unit 1610 is configured to: run the application package through the main logic, and in response to identifying that the application package contains placeholder data during the operation, query the target compression format supported by the second electronic device through a texture processing script.

在一实施例中,确定单元1610,还配置为:In one embodiment, the determining unit 1610 is further configured to:

通过主逻辑运行所述应用程序包,响应于在运行过程中识别出所述应用程序包中含有占位符数据、且所述应用程序包中的纹理资源压缩格式字段为锚压缩格式,向所述纹理处理脚本中添加强制约束,所述强制约束指示支持所述锚压缩格式;The application package is run by the main logic. In response to the identification during the operation that the application package contains placeholder data and that the texture resource compression format field in the application package is an anchor compression format, a mandatory constraint is added to the texture processing script. The mandatory constraint indicates support for the anchor compression format.

向所述纹理处理脚本发送查询请求;其中,所述查询请求用于供所述纹理处理脚本,基于所述强制约束验证对所述锚压缩格式的支持,并查询所述第二电子设备支持的除所述锚压缩格式之外的目标压缩格式。A query request is sent to the texture processing script; wherein the query request is used for the texture processing script to verify support for the anchor compression format based on the mandatory constraints, and to query the target compression formats supported by the second electronic device other than the anchor compression format.

在一实施例中,第三发送单元1620,配置为:In one embodiment, the third transmitting unit 1620 is configured as follows:

在用于渲染所述目标应用的渲染函数之前插入劫持语句;Insert hijacking statements before the rendering function used to render the target application;

执行所述劫持语句,所述劫持语句用于用所述目标压缩格式替换所述应用程序包中的所述占位符数据,并基于所述应用程序包中的所述目标压缩格式,向所述第一电子设备发送所述资源请求。The hijacking statement is executed to replace the placeholder data in the application package with the target compression format and to send the resource request to the first electronic device based on the target compression format in the application package.

在一实施例中,第一接收单元1630,配置为:In one embodiment, the first receiving unit 1630 is configured as follows:

将所述目标压缩纹理资源存储在目标存储空间,并将所述目标压缩纹理资源发送到渲染处理单元;The target compressed texture resource is stored in the target storage space, and the target compressed texture resource is sent to the rendering processing unit;

在接收到所述渲染处理单元基于所述目标压缩纹理资源渲染成功的消息后,从所述目标存储空间中删除所述目标压缩纹理资源。After receiving a message from the rendering processing unit that the target compressed texture resource has been successfully rendered, the target compressed texture resource is deleted from the target storage space.

需要说明的是,上述应用纹理资源渲染装置的具体实施方式与上述应用纹理资源渲染方法的具体实施例基本相同,在此不再赘述。It should be noted that the specific implementation of the above-mentioned texture resource rendering device is basically the same as the specific implementation of the above-mentioned texture resource rendering method, and will not be repeated here.

参照图17,图17是本申请实施例提供的应用纹理渲染方法的第二电子设备的部分的结构框图,该第二电子设备可以是终端,包括:射频(Radio Frequency,RF)电路1710、存储器1715、输入单元1730、显示单元1740、传感器1750、音频电路1760、无线保真(wireless fidelity,WiFi)模块1770、处理器1780、以及电源1790等部件。本领域技术人员可以理解,图17示出的电子设备结构并不构成对手机或电脑的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。Referring to Figure 17, which is a partial structural block diagram of the second electronic device using the texture rendering method provided in this embodiment of the application, the second electronic device may be a terminal, including: a radio frequency (RF) circuit 1710, a memory 1715, an input unit 1730, a display unit 1740, a sensor 1750, an audio circuit 1760, a wireless fidelity (WiFi) module 1770, a processor 1780, and a power supply 1790, etc. Those skilled in the art will understand that the electronic device structure shown in Figure 17 does not constitute a limitation on a mobile phone or computer, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

RF电路1710可配置为收发信息或通话过程中,信号的接收和发送,特别地,将基站的下行信息接收后,给处理器1780处理;另外,将设计上行的数据发送给基站。The RF circuit 1710 can be configured to receive and transmit signals during information transmission or calls. Specifically, it receives downlink information from the base station and processes it with the processor 1780; in addition, it transmits uplink data designed to be sent to the base station.

存储器1715可配置为存储软件程序以及模块,处理器1780通过运行存储在存储器1715的软件程序以及模块,从而执行内容终端的各种功能应用以及数据处理。The memory 1715 can be configured to store software programs and modules, and the processor 1780 executes various functional applications and data processing of the content terminal by running the software programs and modules stored in the memory 1715.

输入单元1730可配置为接收输入的数字或字符信息,以及产生与内容终端的设置以及功能控制有关的键信号输入。其中,输入单元1730可包括触控面板1731以及其他输入装置1732。The input unit 1730 can be configured to receive input numeric or character information, and to generate key signal inputs related to the settings and function control of the content terminal. The input unit 1730 may include a touch panel 1731 and other input devices 1732.

显示单元1740可配置为显示输入的信息或提供的信息以及内容终端的各种菜单。显示单元1740可包括显示面板1741。Display unit 1740 can be configured to display input or provided information, as well as various menus of the content terminal. Display unit 1740 may include display panel 1741.

音频电路1760、扬声器1761,传声器1762可提供音频接口。Audio circuitry 1760, speaker 1761, and microphone 1762 provide an audio interface.

在本申请实施例中,该终端所包括的处理器1780可以执行前面实施例的应用纹理渲染方法。In this embodiment, the processor 1780 included in the terminal can execute the application texture rendering method of the previous embodiment.

本申请实施例的终端包括但不限于手机、电脑、智能语音交互设备、智能家电、车载终端、飞行器等。本发明实施例可应用于各种场景,包括但不限于内容分发场景、游戏场景、资源处理等。The terminals in this application embodiment include, but are not limited to, mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle terminals, and aircraft. The embodiments of this invention can be applied to various scenarios, including but not limited to content distribution scenarios, gaming scenarios, and resource processing.

图18是本申请实施例提供的应用纹理渲染方法的第一电子设备的部分的结构框图。第一电子设备如服务器可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上中央处理器(Central Processing Units,CPU)1822(例如,一个或一个以上处理器)和存储器1832,一个或一个以上存储应用程序1842或数据1844的存储介质1830(例如一个或一个以上海量存储装置)。其中,存储器1832和存储介质1830可以是短暂存储或持久存储。存储在存储介质1830的程序可以包括一个或一个以上模块(图示没标出),每个模块可以包括对服务器中的一系列指令操作。更进一步地,中央处理器1822可以设置为与存储介质1830通信,在服务器上执行存储介质1830中的一系列指令操作。Figure 18 is a partial structural block diagram of a first electronic device using the texture rendering method provided in an embodiment of this application. The first electronic device, such as a server, can vary significantly depending on its configuration or performance. It may include one or more central processing units (CPUs) 1822 (e.g., one or more processors) and a memory 1832, and one or more storage media 1830 (e.g., one or more mass storage devices) storing application programs 1842 or data 1844. The memory 1832 and storage media 1830 may be temporary or persistent storage. The program stored in the storage media 1830 may include one or more modules (not shown in the figure), each module including a series of instruction operations on the server. Furthermore, the CPU 1822 may be configured to communicate with the storage media 1830 and execute the series of instruction operations in the storage media 1830 on the server.

服务器还可以包括一个或一个以上电源1826,一个或一个以上有线或无线网络接口1850,一个或一个以上输入输出接口1858,和/或,一个或一个以上操作系统1841,例如Windows ServerTM,Mac OS XTM,UnixTM,LinuxTM,FreeBSDTM等等。The server may also include one or more power supplies 1826, one or more wired or wireless network interfaces 1850, one or more input/output interfaces 1858, and/or one or more operating systems 1841, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.

服务器中的中央处理器1822可以配置为执行本申请实施例的应用纹理渲染方法。The central processing unit 1822 in the server can be configured to execute the application texture rendering method of the embodiments of this application.

本申请实施例提供一种存储有计算机可执行指令的计算机可读存储介质,其中存储有计算机可执行指令,当计算机可执行指令被处理器执行时,将引起处理器执行本申请实施例提供的应用纹理渲染方法。This application provides a computer-readable storage medium storing computer-executable instructions. When the computer-executable instructions are executed by a processor, the processor will execute the application texture rendering method provided in this application.

本申请实施例提供了一种计算机程序产品,该计算机程序产品包括计算机可执行指令,该计算机可执行指令存储在计算机可读存储介质中。电子设备的处理器从计算机可读存储介质读取该计算机可执行指令,处理器执行该计算机可执行指令,使得该计算机设备执行实现上述的应用纹理渲染方法。This application provides a computer program product including computer-executable instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer-executable instructions from the computer-readable storage medium and executes the computer-executable instructions, causing the computer device to perform the application texture rendering method described above.

本申请实施例的说明书及上述附图中的术语“第一”、“第二”、“第三”、“第四”等(如果存在)是用于区别类似的内容,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本申请的实施例例如能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“包含”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或装置不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或装置固有的其它步骤或单元。The terms "first," "second," "third," "fourth," etc. (if present) in the specification and accompanying drawings of the embodiments of this application are used to distinguish similar content and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented, for example, in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "including," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatuses.

应当理解,在本申请实施例中,“至少一个(项)”是指一个或者多个,“多个”是指两个或两个以上。“和/或”,用于描述关联内容的关联关系,表示可以存在三种关系,例如,“A和/或B”可以表示:只存在A,只存在B以及同时存在A和B三种情况,其中A,B可以是单数或者复数。字符“/”一般表示前后关联内容是一种“或”的关系。“以下至少一项(个)”或其类似表达,是指这些项中的任意组合,包括单项(个)或复数项(个)的任意组合。例如,a,b或c中的至少一项(个),可以表示:a,b,c,“a和b”,“a和c”,“b和c”,或“a和b和c”,其中a,b,c可以是单个,也可以是多个。It should be understood that in the embodiments of this application, "at least one (item)" refers to one or more, and "more than one" refers to two or more. "And/or" is used to describe the relationship between related content, indicating that three relationships can exist. For example, "A and/or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character "/" generally indicates that the preceding and following related content are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

应了解,在本申请实施例的描述中,多个(或多项)的含义是两个以上,大于、小于、超过等理解为不包括本数,以上、以下、以内等理解为包括本数。It should be understood that in the description of the embodiments of this application, "multiple" means two or more, "greater than", "less than", "exceeding" etc. are understood to exclude the number itself, and "above", "below", "within" etc. are understood to include the number itself.

在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. The couplings or direct couplings or communication connections shown or discussed may be indirect couplings or communication connections between devices or units through some interfaces, and may be electrical, mechanical, or other forms.

作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实施例的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机装置(可以是个人计算机,服务器130,或者网络装置等)执行本申请各个实施例方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server 130, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

还应了解,本申请实施例提供的各种实施方式可以任意进行组合,以实现不同的技术效果。It should also be understood that the various implementation methods provided in this application can be combined arbitrarily to achieve different technical effects.

以上是对本申请实施例的实施方式的具体说明,但本申请实施例并不局限于上述实施方式,熟悉本领域的技术人员在不违背本申请精神的条件下还可作出种种等同的变形或替换,这些等同的变形或替换均包括在本申请权利要求所限定的范围内。The above is a detailed description of the implementation methods of the embodiments of this application. However, the embodiments of this application are not limited to the above implementation methods. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of this application. All such equivalent modifications or substitutions are included within the scope defined by the claims of this application.

Claims (22)

一种应用纹理渲染方法,所述方法由第一电子设备执行,所述方法包括:An application texture rendering method, performed by a first electronic device, the method comprising: 获取目标应用的目标应用纹理资源及占位符数据,并发送所述占位符数据至第二电子设备;Obtain the target application texture resources and placeholder data of the target application, and send the placeholder data to the second electronic device; 按照多个候选压缩格式,将所述目标应用纹理资源分别压缩为多个候选压缩纹理资源;The target application texture resources are compressed into multiple candidate compressed texture resources according to multiple candidate compression formats; 接收所述第二电子设备发送的资源请求,所述资源请求为所述第二电子设备获取到所述占位符数据后发送的,用于请求目标压缩纹理资源,所述目标压缩纹理资源为,采用目标压缩格式对所述目标应用纹理资源进行压缩得到的;The system receives a resource request sent by the second electronic device. The resource request is sent by the second electronic device after it obtains the placeholder data. The request is for requesting a target compressed texture resource. The target compressed texture resource is obtained by compressing the target application texture resource using a target compression format. 如果所述目标压缩格式属于所述多个候选压缩格式,从所述多个候选压缩纹理资源中获取所述目标压缩纹理资源,并将所述目标压缩纹理资源发送到所述第二电子设备;If the target compression format belongs to the plurality of candidate compression formats, the target compressed texture resource is obtained from the plurality of candidate compressed texture resources, and the target compressed texture resource is sent to the second electronic device; 其中,所述目标压缩纹理资源用于,供所述第二电子设备进行所述目标应用的渲染。The target compressed texture resource is used for rendering the target application by the second electronic device. 根据权利要求1所述的应用纹理渲染方法,其中,所述获取目标应用的目标应用纹理资源,包括:According to claim 1, the application texture rendering method, wherein obtaining the target application texture resource of the target application includes: 获取所述目标应用的初始资源包,所述初始资源包包括所述目标应用的初始压缩格式的初始压缩纹理资源;Obtain the initial resource package of the target application, the initial resource package including the initial compressed texture resources of the target application in the initial compression format; 对所述初始压缩纹理资源进行解压,得到所述目标应用纹理资源。The initial compressed texture resource is decompressed to obtain the target application texture resource. 根据权利要求2所述的应用纹理渲染方法,其中,所述初始资源包还包括初始压缩格式名称;According to claim 2, the application texture rendering method further includes an initial compression format name; 所述对所述初始压缩纹理资源进行解压,得到所述目标应用纹理资源,包括:The step of decompressing the initial compressed texture resource to obtain the target application texture resource includes: 获取初始压缩格式名称对应的初始压缩算法;Obtain the initial compression algorithm corresponding to the initial compression format name; 基于所述初始压缩算法,将所述初始压缩纹理资源解压为所述目标应用纹理资源。Based on the initial compression algorithm, the initially compressed texture resource is decompressed into the target application texture resource. 根据权利要求1至3任一项所述的应用纹理渲染方法,其中,所述发送所述占位符数据至第二电子设备之前,所述方法还包括:The application texture rendering method according to any one of claims 1 to 3, wherein, before sending the placeholder data to the second electronic device, the method further includes: 获取所述目标应用的初始资源包,所述初始资源包包括所述目标应用的初始压缩纹理资源;Obtain the initial resource package of the target application, wherein the initial resource package includes the initial compressed texture resources of the target application; 将所述初始资源包中的所述初始压缩纹理资源替换为占位符数据,得到更新资源包;Replace the initial compressed texture resources in the initial resource package with placeholder data to obtain the updated resource package; 所述发送所述占位符数据至第二电子设备,包括:Sending the placeholder data to the second electronic device includes: 发送所述更新资源包至第二电子设备。Send the updated resource package to the second electronic device. 根据权利要求4所述的应用纹理渲染方法,其中,所述发送所述更新资源包至第二电子设备之前,所述方法还包括:According to claim 4, the application texture rendering method, before sending the updated resource package to the second electronic device, the method further includes: 将所述更新资源包的纹理资源压缩格式字段改为锚压缩格式,得到新的更新资源包;Change the texture resource compression format field of the updated resource package to the anchor compression format to obtain a new updated resource package; 所述发送所述更新资源包至第二电子设备,包括:Sending the updated resource package to the second electronic device includes: 将所述新的更新资源包发送到所述第二电子设备;Send the new update resource package to the second electronic device; 其中,所述第二电子设备在识别出所述纹理资源压缩格式字段为所述锚压缩格式时,向纹理处理脚本中添加强制约束,所述强制约束指示支持所述锚压缩格式。When the second electronic device identifies the texture resource compression format field as the anchor compression format, it adds a mandatory constraint to the texture processing script, the mandatory constraint indicating support for the anchor compression format. 根据权利要求1至5任一项所述的应用纹理渲染方法,其中,所述占位符数据为纹理资源名称,所述资源请求包括所述纹理资源名称和所述目标压缩格式;The application texture rendering method according to any one of claims 1 to 5, wherein the placeholder data is a texture resource name, and the resource request includes the texture resource name and the target compression format; 所述按照多个候选压缩格式,将所述目标应用纹理资源分别压缩为多个候选压缩纹理资源之后,所述方法还包括:After compressing the target application texture resource into multiple candidate compressed texture resources according to multiple candidate compression formats, the method further includes: 针对各所述候选压缩格式,按照与所述纹理资源名称和所述候选压缩格式对应的候选存储地址,存储所述候选压缩纹理资源;For each of the candidate compression formats, the candidate compressed texture resources are stored according to the candidate storage address corresponding to the texture resource name and the candidate compression format; 所述如果所述目标压缩格式属于所述多个候选压缩格式,从所述多个候选压缩纹理资源中获取所述目标压缩纹理资源,包括:If the target compression format belongs to the plurality of candidate compression formats, obtaining the target compressed texture resource from the plurality of candidate compressed texture resources includes: 如果所述目标压缩格式属于所述多个候选压缩格式,按照与所述纹理资源名称和所述目标压缩格式对应的目标存储地址,获取所述目标压缩纹理资源,其中,所述目标存储地址属于多个所述候选存储地址。If the target compression format belongs to the plurality of candidate compression formats, the target compressed texture resource is obtained according to the target storage address corresponding to the texture resource name and the target compression format, wherein the target storage address belongs to the plurality of candidate storage addresses. 根据权利要求6所述的应用纹理渲染方法,其中,所述按照与所述纹理资源名称和所述候选压缩格式对应的候选存储地址,存储所述候选压缩纹理资源,包括:According to the application texture rendering method of claim 6, the step of storing the candidate compressed texture resource according to the candidate storage address corresponding to the texture resource name and the candidate compression format includes: 对所述纹理资源名称和所述候选压缩格式执行目标运算,得到所述候选存储地址;Perform a target operation on the texture resource name and the candidate compression format to obtain the candidate storage address; 按照所述候选存储地址,存储所述候选压缩纹理资源;Store the candidate compressed texture resources according to the candidate storage addresses; 所述按照与所述纹理资源名称和所述目标压缩格式对应的目标存储地址,获取所述目标压缩纹理资源之前,所述方法还包括:Before obtaining the target compressed texture resource according to the target storage address corresponding to the texture resource name and the target compression format, the method further includes: 如果所述目标压缩格式属于所述多个候选压缩格式,对所述纹理资源名称和所述目标压缩格式执行所述目标运算,得到所述目标存储地址。If the target compression format belongs to the plurality of candidate compression formats, the target operation is performed on the texture resource name and the target compression format to obtain the target storage address. 根据权利要求6所述的应用纹理渲染方法,其中,所述按照与所述纹理资源名称和所述候选压缩格式对应的候选存储地址,存储所述候选压缩纹理资源,包括:According to the application texture rendering method of claim 6, the step of storing the candidate compressed texture resource according to the candidate storage address corresponding to the texture resource name and the candidate compression format includes: 获取第一对应关系表,所述第一对应关系表指示所述纹理资源名称、所述候选压缩格式、与候选存储地址的对应关系;Obtain a first correspondence table, which indicates the correspondence between the texture resource name, the candidate compression format, and the candidate storage address; 基于所述第一对应关系表,存储所述候选压缩纹理资源;Based on the first correspondence table, the candidate compressed texture resources are stored; 所述按照与所述纹理资源名称和所述目标压缩格式对应的目标存储地址,获取所述目标压缩纹理资源之前,所述方法还包括:Before obtaining the target compressed texture resource according to the target storage address corresponding to the texture resource name and the target compression format, the method further includes: 如果所述目标压缩格式属于所述多个候选压缩格式,基于所述纹理资源名称和所述目标压缩格式查找所述第一对应关系表,得到所述目标存储地址。If the target compression format belongs to the plurality of candidate compression formats, the first correspondence table is searched based on the texture resource name and the target compression format to obtain the target storage address. 根据权利要求1至5任一项所述的应用纹理渲染方法,其中,所述占位符数据为纹理资源名称,所述资源请求包括目标存储地址,所述目标存储地址由所述第二电子设备根据所述纹理资源名称和所述目标压缩格式确定出;The application texture rendering method according to any one of claims 1 to 5, wherein the placeholder data is a texture resource name, the resource request includes a target storage address, and the target storage address is determined by the second electronic device based on the texture resource name and the target compression format; 所述按照多个候选压缩格式,将所述目标应用纹理资源分别压缩为多个候选压缩纹理资源之后,所述方法还包括:After compressing the target application texture resource into multiple candidate compressed texture resources according to multiple candidate compression formats, the method further includes: 针对各所述候选压缩格式,按照与所述纹理资源名称和所述候选压缩格式对应的候选存储地址,存储所述候选压缩纹理资源;For each of the candidate compression formats, the candidate compressed texture resources are stored according to the candidate storage address corresponding to the texture resource name and the candidate compression format; 所述如果所述目标压缩格式属于所述多个候选压缩格式,从所述多个候选压缩纹理资源中获取所述目标压缩纹理资源,包括:If the target compression format belongs to the plurality of candidate compression formats, obtaining the target compressed texture resource from the plurality of candidate compressed texture resources includes: 如果所述目标压缩格式属于所述多个候选压缩格式,按照所述资源请求中的所述目标存储地址,获取所述目标压缩纹理资源,其中,所述目标存储地址属于多个所述候选存储地址。If the target compression format belongs to the plurality of candidate compression formats, the target compressed texture resource is obtained according to the target storage address in the resource request, wherein the target storage address belongs to the plurality of candidate storage addresses. 根据权利要求6至9任一项所述的应用纹理渲染方法,其中,所述按照所述资源请求中的所述目标存储地址,获取所述目标压缩纹理资源,包括:The application texture rendering method according to any one of claims 6 to 9, wherein obtaining the target compressed texture resource according to the target storage address in the resource request includes: 如果目标压缩格式的数量为多个,获取每个所述目标压缩格式的压缩损失率;If there are multiple target compression formats, obtain the compression loss rate for each target compression format; 基于各所述目标压缩格式的压缩损失率,从各所述目标压缩格式对应的目标存储地址中,选取压缩损失率最小的目标压缩格式所对应的目标存储地址;Based on the compression loss rate of each target compression format, the target storage address corresponding to the target compression format with the smallest compression loss rate is selected from the target storage addresses corresponding to each target compression format. 基于选取的所述目标存储地址,获取目标压缩纹理资源。Based on the selected target storage address, the target compressed texture resource is obtained. 根据权利要求6至9任一项所述的应用纹理渲染方法,其中,所述按照所述资源请求中的所述目标存储地址,获取所述目标压缩纹理资源,包括:The application texture rendering method according to any one of claims 6 to 9, wherein obtaining the target compressed texture resource according to the target storage address in the resource request includes: 如果目标压缩格式的数量为多个,获取每个所述目标压缩格式的压缩速率;If there are multiple target compression formats, obtain the compression rate of each target compression format; 基于各所述目标压缩格式的压缩速率,从各所述目标压缩格式对应的目标存储地址中,选取压缩速率最大的目标压缩格式所对应的目标存储地址;Based on the compression rate of each target compression format, the target storage address corresponding to the target compression format with the highest compression rate is selected from the target storage addresses corresponding to each target compression format; 基于选取的所述目标存储地址,获取目标压缩纹理资源。Based on the selected target storage address, the target compressed texture resource is obtained. 根据权利要求1至11任一项所述的应用纹理渲染方法,其中,所述按照多个候选压缩格式,将所述目标应用纹理资源分别压缩为多个候选压缩纹理资源之后,所述方法还包括:The application texture rendering method according to any one of claims 1 to 11, wherein, after compressing the target application texture resource into multiple candidate compressed texture resources according to multiple candidate compression formats, the method further includes: 存储所述多个候选压缩纹理资源和所述目标应用纹理资源;Store the plurality of candidate compressed texture resources and the target application texture resource; 如果所述目标压缩格式不属于所述多个候选压缩格式,获取存储的所述目标应用纹理资源,发送到所述第二电子设备。If the target compression format does not belong to the plurality of candidate compression formats, the stored target application texture resource is obtained and sent to the second electronic device. 一种应用纹理渲染方法,所述方法由第二电子设备执行,所述方法包括:An application texture rendering method, performed by a second electronic device, the method comprising: 响应于获取到从第一电子设备发送的目标应用的占位符数据,确定所述第二电子设备支持的目标压缩格式;In response to receiving placeholder data of the target application sent from the first electronic device, the target compression format supported by the second electronic device is determined; 向所述第一电子设备发送资源请求,所述资源请求用于请求目标压缩纹理资源,所述目标压缩纹理资源为,采用目标压缩格式对目标应用纹理资源进行压缩得到的;Send a resource request to the first electronic device. The resource request is used to request a target compressed texture resource. The target compressed texture resource is obtained by compressing the target application texture resource using a target compression format. 从所述第一电子设备接收所述目标压缩纹理资源,并基于所述目标压缩纹理资源进行所述目标应用的渲染;Receive the target compressed texture resource from the first electronic device, and render the target application based on the target compressed texture resource; 其中,所述第一电子设备发送所述目标应用的占位符数据时,还按照多个候选压缩格式,将获取的目标应用纹理资源分别压缩为多个候选压缩纹理资源;所述多个候选压缩格式包括所述目标压缩格式,多个所述候选压缩纹理资源包括所述目标压缩纹理资源。When the first electronic device sends the placeholder data of the target application, it also compresses the acquired target application texture resources into multiple candidate compressed texture resources according to multiple candidate compression formats; the multiple candidate compression formats include the target compression format, and the multiple candidate compressed texture resources include the target compressed texture resource. 根据权利要求13所述的应用纹理渲染方法,其中,所述占位符数据存在于应用程序包;The application texture rendering method according to claim 13, wherein the placeholder data exists in the application package; 所述响应于获取到从第一电子设备发送的目标应用的占位符数据,确定所述第二电子设备支持的目标压缩格式,包括:The step of determining the target compression format supported by the second electronic device in response to receiving placeholder data of the target application sent from the first electronic device includes: 通过主逻辑运行所述应用程序包,响应于在运行过程中识别出所述应用程序包中含有占位符数据,通过纹理处理脚本查询所述第二电子设备支持的目标压缩格式。The application package is run by the main logic, and in response to the identification of placeholder data in the application package during the operation, the target compression format supported by the second electronic device is queried through the texture processing script. 根据权利要求14所述的应用纹理渲染方法,其中,所述通过主逻辑运行所述应用程序包,响应于在运行过程中识别出所述应用程序包中含有占位符数据,通过纹理处理脚本查询所述第二电子设备支持的目标压缩格式,包括:According to the application texture rendering method of claim 14, the step of running the application package through the main logic, in response to identifying that the application package contains placeholder data during the running process, and querying the target compression format supported by the second electronic device through the texture processing script, includes: 通过主逻辑运行所述应用程序包,响应于在运行过程中识别出所述应用程序包中含有占位符数据、且所述应用程序包中的纹理资源压缩格式字段为锚压缩格式,向所述纹理处理脚本中添加强制约束,所述强制约束指示支持所述锚压缩格式;The application package is run by the main logic. In response to the identification during the operation that the application package contains placeholder data and that the texture resource compression format field in the application package is an anchor compression format, a mandatory constraint is added to the texture processing script. The mandatory constraint indicates that the anchor compression format is supported. 向所述纹理处理脚本发送查询请求;其中,所述查询请求用于供所述纹理处理脚本,基于所述强制约束验证对所述锚压缩格式的支持,并查询所述第二电子设备支持的除所述锚压缩格式之外的目标压缩格式。A query request is sent to the texture processing script; wherein the query request is used for the texture processing script to verify support for the anchor compression format based on the mandatory constraints, and to query the target compression formats supported by the second electronic device other than the anchor compression format. 根据权利要求13至15任一项所述的应用纹理渲染方法,其中,所述向所述第一电子设备发送资源请求,包括:The application texture rendering method according to any one of claims 13 to 15, wherein sending a resource request to the first electronic device includes: 在用于渲染所述目标应用的渲染函数之前插入劫持语句;Insert hijacking statements before the rendering function used to render the target application; 执行所述劫持语句,所述劫持语句用于用所述目标压缩格式替换所述应用程序包中的所述占位符数据,并基于所述应用程序包中的所述目标压缩格式,向所述第一电子设备发送所述资源请求。The hijacking statement is executed to replace the placeholder data in the application package with the target compression format and to send the resource request to the first electronic device based on the target compression format in the application package. 根据权利要求13至16任一项所述的应用纹理渲染方法,其中,所述基于所述目标压缩纹理资源进行所述目标应用的渲染,包括:The application texture rendering method according to any one of claims 13 to 16, wherein rendering the target application based on the target compressed texture resource includes: 将所述目标压缩纹理资源存储在目标存储空间,并将所述目标压缩纹理资源发送到渲染处理单元;The target compressed texture resource is stored in the target storage space, and the target compressed texture resource is sent to the rendering processing unit; 在接收到所述渲染处理单元基于所述目标压缩纹理资源渲染成功的消息后,从所述目标存储空间中删除所述目标压缩纹理资源。After receiving a message from the rendering processing unit that the target compressed texture resource has been successfully rendered, the target compressed texture resource is deleted from the target storage space. 一种应用纹理渲染装置,所述装置包括:An application texture rendering apparatus, the apparatus comprising: 第一发送单元,配置为获取目标应用的目标应用纹理资源及占位符数据,并发送所述占位符数据至第二电子设备;The first sending unit is configured to acquire the target application texture resources and placeholder data of the target application, and send the placeholder data to the second electronic device; 压缩单元,配置为按照多个候选压缩格式,将所述目标应用纹理资源分别压缩为多个候选压缩纹理资源;The compression unit is configured to compress the target application texture resource into multiple candidate compressed texture resources according to multiple candidate compression formats; 第二发送单元,配置为接收所述第二电子设备发送的资源请求,所述资源请求为所述第二电子设备获取到所述占位符数据后发送的,用于请求目标压缩纹理资源,所述目标压缩纹理资源为,采用目标压缩格式对所述目标应用纹理资源进行压缩得到的;如果所述目标压缩格式属于所述多个候选压缩格式,从所述多个候选压缩纹理资源中获取所述目标压缩纹理资源,并将所述目标压缩纹理资源发送到所述第二电子设备;其中,所述目标压缩纹理资源用于,供所述第二电子设备进行所述目标应用的渲染。The second sending unit is configured to receive a resource request sent by the second electronic device. The resource request is sent by the second electronic device after obtaining the placeholder data, and is used to request a target compressed texture resource. The target compressed texture resource is obtained by compressing the target application texture resource using a target compression format. If the target compression format belongs to the plurality of candidate compression formats, the unit obtains the target compressed texture resource from the plurality of candidate compressed texture resources and sends the target compressed texture resource to the second electronic device. The target compressed texture resource is used by the second electronic device to render the target application. 一种应用纹理渲染装置,所述装置包括:An application texture rendering apparatus, the apparatus comprising: 确定单元,配置为响应于获取到从第一电子设备发送的目标应用的占位符数据,确定所述第二电子设备支持的目标压缩格式;The determining unit is configured to determine the target compression format supported by the second electronic device in response to receiving placeholder data of the target application sent from the first electronic device; 第三发送单元,配置为向所述第一电子设备发送资源请求,所述资源请求用于请求目标压缩纹理资源,所述目标压缩纹理资源为,采用目标压缩格式对目标应用纹理资源进行压缩得到的;The third sending unit is configured to send a resource request to the first electronic device. The resource request is used to request a target compressed texture resource. The target compressed texture resource is obtained by compressing a target application texture resource using a target compression format. 第二接收单元,配置为从所述第一电子设备接收所述目标压缩纹理资源,并基于所述目标压缩纹理资源进行所述目标应用的渲染;其中,所述第一电子设备发送所述目标应用的占位符数据时,还按照多个候选压缩格式,将获取的目标应用纹理资源分别压缩为多个候选压缩纹理资源;所述多个候选压缩格式包括所述目标压缩格式,多个所述候选压缩纹理资源包括所述目标压缩纹理资源。The second receiving unit is configured to receive the target compressed texture resource from the first electronic device and render the target application based on the target compressed texture resource; wherein, when the first electronic device sends the placeholder data of the target application, it also compresses the acquired target application texture resource into multiple candidate compressed texture resources according to multiple candidate compression formats; the multiple candidate compression formats include the target compression format, and the multiple candidate compressed texture resources include the target compressed texture resource. 一种电子设备,包括:An electronic device, comprising: 存储器,配置为存储计算机可执行指令或计算机程序;Memory, configured to store computer-executable instructions or computer programs; 处理器,配置为执行所述存储器中存储的计算机可执行指令或计算机程序时,实现权利要求1至17任意一项所述的应用纹理渲染方法。When a processor is configured to execute computer-executable instructions or computer programs stored in the memory, it implements the application texture rendering method according to any one of claims 1 to 17. 一种计算机可读存储介质,存储有计算机可执行指令或计算机程序,所述计算机可执行指令或计算机程序被处理器执行时,实现权利要求1至17任意一项所述的应用纹理渲染方法。A computer-readable storage medium storing computer-executable instructions or computer programs, which, when executed by a processor, implement the application texture rendering method according to any one of claims 1 to 17. 一种计算机程序产品,包括计算机可执行指令或计算机程序,所述计算机可执行指令或计算机程序被处理器执行时,实现权利要求1至17任意一项所述的应用纹理渲染方法。A computer program product comprising computer-executable instructions or a computer program, wherein when executed by a processor, the computer-executable instructions or the computer program implement the application texture rendering method according to any one of claims 1 to 17.
PCT/CN2025/083002 2024-04-28 2025-03-17 Application texture rendering method and apparatus, and electronic device, computer-readable storage medium and computer program product Pending WO2025227968A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202410517067.6A CN118096926B (en) 2024-04-28 2024-04-28 Application texture rendering method, related device and medium
CN202410517067.6 2024-04-28

Publications (1)

Publication Number Publication Date
WO2025227968A1 true WO2025227968A1 (en) 2025-11-06

Family

ID=91159715

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2025/083002 Pending WO2025227968A1 (en) 2024-04-28 2025-03-17 Application texture rendering method and apparatus, and electronic device, computer-readable storage medium and computer program product

Country Status (2)

Country Link
CN (1) CN118096926B (en)
WO (1) WO2025227968A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118096926B (en) * 2024-04-28 2024-07-05 腾讯科技(深圳)有限公司 Application texture rendering method, related device and medium
CN119450051A (en) * 2024-10-14 2025-02-14 广州极尚网络技术有限公司 Data compression method, device, storage medium and electronic equipment

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160078665A1 (en) * 2014-09-17 2016-03-17 Samsung Electronics Co., Ltd. Apparatus and method of decompressing rendering data and recording medium thereof
US20170323470A1 (en) * 2016-05-03 2017-11-09 Vmware, Inc. Virtual hybrid texture mapping
CN113327303A (en) * 2021-08-03 2021-08-31 腾讯科技(深圳)有限公司 Image processing method, image processing device, computer equipment and storage medium
CN114022343A (en) * 2021-10-29 2022-02-08 努比亚技术有限公司 Resource loading method, terminal and storage medium
CN116700941A (en) * 2022-02-24 2023-09-05 腾讯科技(深圳)有限公司 Image rendering method and device, electronic equipment and storage medium
CN118096926A (en) * 2024-04-28 2024-05-28 腾讯科技(深圳)有限公司 Application texture rendering method, related device and medium

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8069433B2 (en) * 2007-04-18 2011-11-29 Microsoft Corporation Multi-format centralized distribution of localized resources for multiple products
CN103605534B (en) * 2013-10-31 2017-04-05 优视科技有限公司 picture loading method and device
CN113797554B (en) * 2021-09-22 2023-12-26 北京有竹居网络技术有限公司 Game engine resource processing method and device, storage medium and electronic equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20160078665A1 (en) * 2014-09-17 2016-03-17 Samsung Electronics Co., Ltd. Apparatus and method of decompressing rendering data and recording medium thereof
US20170323470A1 (en) * 2016-05-03 2017-11-09 Vmware, Inc. Virtual hybrid texture mapping
CN113327303A (en) * 2021-08-03 2021-08-31 腾讯科技(深圳)有限公司 Image processing method, image processing device, computer equipment and storage medium
CN114022343A (en) * 2021-10-29 2022-02-08 努比亚技术有限公司 Resource loading method, terminal and storage medium
CN116700941A (en) * 2022-02-24 2023-09-05 腾讯科技(深圳)有限公司 Image rendering method and device, electronic equipment and storage medium
CN118096926A (en) * 2024-04-28 2024-05-28 腾讯科技(深圳)有限公司 Application texture rendering method, related device and medium

Also Published As

Publication number Publication date
CN118096926A (en) 2024-05-28
CN118096926B (en) 2024-07-05

Similar Documents

Publication Publication Date Title
WO2025227968A1 (en) Application texture rendering method and apparatus, and electronic device, computer-readable storage medium and computer program product
JP4216722B2 (en) Method and system for offloading the execution and resources of a device having constraints on networked resources
JP7464732B2 (en) Image processing method and device, server, and computer program
AU2019256257B2 (en) Processor core scheduling method and apparatus, terminal, and storage medium
WO2010053956A2 (en) Command buffers for web-based graphics rendering
CN110968395B (en) Method for processing rendering instruction in simulator and mobile terminal
CN114025238B (en) Native android application cloud virtualization method based on Linux server
JP2023523242A (en) DATA PROCESSING METHOD, DATA PROCESSING APPARATUS, COMPUTER DEVICE, AND COMPUTER PROGRAM
CN110362338B (en) Game resource packaging and resource quick access method under mobile platform
CN111722885B (en) Program running method and device and electronic equipment
CN113296781A (en) Application program installation package file compiling and constructing method and device and electronic equipment
CN111580988A (en) Method and device for realizing open platform, storage medium and computer equipment
CN118283331A (en) Playing processing method, device and computer readable storage medium
CN113031957A (en) Application program installation method, client, terminal, server and storage medium
US20220357980A1 (en) Selectively offloading the compression and decompression of files to a hardware controller
CN114090070A (en) Application program installation package file processing method and electronic equipment
CN119512550B (en) Application rendering methods, devices, equipment, and readable storage media
CN112905275B (en) Display method and display device for multiple operating systems
CN117667115A (en) Application installation method and electronic equipment
CN116149777B (en) Cross-environment texture rendering optimization method based on resource transparent mapping
CN117724726B (en) Data processing method and related device
CN113849157B (en) Animation playing management method, device, equipment and storage medium
CN118312245B (en) Method and related device for realizing loading game resources of mini game
CN110855539A (en) Device discovery method, device and storage medium
CN114327667B (en) Dynamic resource loading method and system

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 25797145

Country of ref document: EP

Kind code of ref document: A1