Movatterモバイル変換


[0]ホーム

URL:


CN110064198A - Processing method and processing device, storage medium and the electronic device of resource - Google Patents

Processing method and processing device, storage medium and the electronic device of resource
Download PDF

Info

Publication number
CN110064198A
CN110064198ACN201910289095.6ACN201910289095ACN110064198ACN 110064198 ACN110064198 ACN 110064198ACN 201910289095 ACN201910289095 ACN 201910289095ACN 110064198 ACN110064198 ACN 110064198A
Authority
CN
China
Prior art keywords
thread
task
queue
image data
load
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
CN201910289095.6A
Other languages
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.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network 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 Netease Hangzhou Network Co LtdfiledCriticalNetease Hangzhou Network Co Ltd
Priority to CN201910289095.6ApriorityCriticalpatent/CN110064198A/en
Publication of CN110064198ApublicationCriticalpatent/CN110064198A/en
Pendinglegal-statusCriticalCurrent

Links

Classifications

Landscapes

Abstract

The present invention provides a kind of processing method and processing device of resource, storage medium and electronic devices;Wherein, this method comprises: multiple tasks relevant to texture resource are loaded into load thread pool in the task queue of at least one load thread;Pending task is obtained from the task queue of at least one load thread, and loads the pending task to generate image data.Through the invention, it solves the problems, such as in the related technology in a short time to put vast resources loading procedure into and carries out causing game main thread to generate Caton phenomenon in game main thread.

Description

Processing method and processing device, storage medium and the electronic device of resource
Technical field
The present invention relates to computer field, in particular to a kind of processing method and processing device of resource, storage medium andElectronic device.
Background technique
Network game client when rendering game picture needs that texture resource is loaded into memory from storage equipmentIn, and it is converted to the picture format that can be rendered, and pass data to graphics processor (Graphics ProcessingUnit, referred to as GPU) it is rendered.And the process of memory is loaded into from storage equipment, often process is very slow, and game is needed to openOriginator is specifically handled and is optimized to loading procedure, otherwise may result in game Caton, resource loaded it is slow etc. badExperience.
Currently, resource loading scheme commonly used in the prior art has: (1) synchronous load, this mode loaded resourceJourney is placed into the progress of game main thread, and rendering program is enable to obtain resource data with prestissimo.(2) the asynchronous load of single thread.This mode is put resource loading procedure into a specified thread and is executed, etc. after the completion of resources load, by data back to wash with watercoloursContaminate thread.In this way, rendering thread cannot obtain resource data at once, but the calculation amount of the thread can be greatly decreased.
Above-mentioned resource loading scheme in the prior art can preferably solve the resource loading problem under most of scene, butThere is also following drawbacks: (1) synchronous loading method cannot load excessive, excessive resource simultaneously in a short time, otherwise loadProcess is deposited in game main thread, it will so that game main thread generates serious Caton phenomenon, game experiencing is deteriorated.(2) singleIf the asynchronous load of thread encounters short time excessive resource load condition, although not will lead to main thread Caton, load speedDegree is still limited to the computing capability and disk I/O speed of the thread, and causing rendering program to obtain the speed of resource data mayIt is very slow.
In view of the above problems in the related art, not yet there is effective solution at present.
Summary of the invention
The embodiment of the invention provides a kind of processing method and processing device of resource, storage medium and electronic devices, at leastSolution, which in the related technology in a short time puts vast resources loading procedure into, to be carried out leading to game main thread in game main threadLead to the problem of Caton phenomenon.
According to one embodiment of present invention, a kind of processing method of resource is provided, comprising: will be related to texture resourceMultiple tasks be loaded into load thread pool at least one load thread task queue in;From at least one described loaded linePending task is obtained in the task queue of journey, and loads the pending task to generate image data.
According to one embodiment of present invention, a kind of processing unit of resource is provided, comprising: loading module, being used for willMultiple tasks relevant to texture resource are loaded into load thread pool in the task queue of at least one load thread;At firstModule is managed, for obtaining pending task from the task queue of at least one load thread, and is loaded described pendingTask is to generate image data.
According to still another embodiment of the invention, a kind of storage medium is additionally provided, meter is stored in the storage mediumCalculation machine program, wherein the computer program is arranged to execute the step in any of the above-described embodiment of the method when operation.
According to still another embodiment of the invention, a kind of electronic device, including memory and processor are additionally provided, it is describedComputer program is stored in memory, the processor is arranged to run the computer program to execute any of the above-describedStep in embodiment of the method.
Through the invention, multiple tasks are loaded into the task queue of at least one of thread pool load thread, are madeObtaining multiple tasks can record simultaneously, be the equal of the asynchronous load of multithreading, increase the handling capacity of transient resource load, butIt is not that task load is carried out by main thread, puts vast resources loading procedure into game main thread in a short time to solveIn carry out that game main thread is caused to lead to the problem of Caton phenomenon.
Detailed description of the invention
The drawings described herein are used to provide a further understanding of the present invention, constitutes part of this application, this hairBright illustrative embodiments and their description are used to explain the present invention, and are not constituted improper limitations of the present invention.In the accompanying drawings:
Fig. 1 is the processing method flow chart of resource according to an embodiment of the present invention;
Fig. 2 is code schematic diagram one according to an embodiment of the present invention;
Fig. 3 is code schematic diagram two according to an embodiment of the present invention;
Fig. 4 is code schematic diagram three according to an embodiment of the present invention;
Fig. 5 is code schematic diagram four according to an embodiment of the present invention;
Fig. 6 is code schematic diagram five according to an embodiment of the present invention;
Fig. 7 is code schematic diagram six according to an embodiment of the present invention;
Fig. 8 is code schematic diagram seven according to an embodiment of the present invention;
Fig. 9 is code schematic diagram eight according to an embodiment of the present invention;
Figure 10 is the structural block diagram of the processing unit of resource according to an embodiment of the present invention;
Figure 11 is the alternative construction block diagram of the processing unit of resource according to an embodiment of the present invention.
Specific embodiment
Hereinafter, the present invention will be described in detail with reference to the accompanying drawings and in combination with Examples.It should be noted that not conflictingIn the case of, the features in the embodiments and the embodiments of the present application can be combined with each other.
It should be noted that description and claims of this specification and term " first " in above-mentioned attached drawing, "Two " etc. be to be used to distinguish similar objects, without being used to describe a particular order or precedence order.
Embodiments herein provides a kind of processing method of resource, and Fig. 1 is resource according to an embodiment of the present inventionProcessing method flow chart, as shown in Figure 1, the process includes the following steps:
Multiple tasks relevant to texture resource are loaded at least one load thread in load thread pool by step S102Task queue in;
Step S104 obtains pending task from the task queue of at least one load thread, and loads pendingBusiness is to generate image data.
Multiple tasks are loaded at least one of thread pool load thread by S102 and step S104 through the above stepsTask queue in, multiple tasks are recorded simultaneously, is the equal of the asynchronous load of multithreading, increases transient resource and addThe handling capacity of load, but be not that task load is carried out by main thread, vast resources was loaded in a short time to solveIt carries out that game main thread is caused to lead to the problem of Caton phenomenon in Cheng Fangjin game main thread.
It should be noted that the executing subject of the method and step in the embodiment of the present application can be with terminal, server etc..
In addition, being to determine the number for loading thread in load thread pool according to the core number of processor in the embodiment of the present applicationAmount.For example, this is then arranged after having got the core amounts of processor of the equipment for executing the application method and stepThe thread amount of the load thread of thread pool is 2 times of processor core quantity in embodiment.Certainly above-mentioned is only to illustrate, can alsoTo be 1.5 times or 3 times etc., can be arranged accordingly according to the actual situation.
In the optional embodiment of the present embodiment, add for what is be related in the present embodiment step S104 from least oneIt carries in the task queue of thread and obtains pending task, and load pending task in a manner of generating image data, Ke YitongIt crosses such as under type and realizes:
Step S104-11 obtains the identification information of current load thread;
Step S104-12, according to the determining task queue corresponding with current load thread of identification information;
Step S104-13, in the case where the currently corresponding task queue of load thread is non-empty, from current load threadPending task is obtained in corresponding task queue, and loads pending task to generate image data.
S104-11 to step S104-13 through the above steps, for the loading procedure of task, it is necessary first to pass through loadThe determining task queue corresponding with current load thread of the identification information of thread, only just in the case where task queue is non-emptyThe operation of loading tasks can be executed.Certainly, if task queue is sky, load thread is allowed to enter wait state.
In the another embodiment of the present embodiment, obtained from the task queue of at least one load thread in step S104Pending task is taken, and after loading pending task to generate image data, the method for the present embodiment further include:
The image data of generation is input in the consumption queue of main thread by step S106;
It should be noted that the main thread being related in the application is for being responsible for game picture rendering, game logic executesThe thread of equal related works;And thread is loaded for being responsible for the thread of texture resource loading tasks.
Step S108 obtains the image data for being no more than preset quantity from consumption queue to execute texture and generates operation;
It should be noted that the preset quantity being related in above-mentioned steps S106 and step S108 is that the every frame of main thread is maximumThe View data quantity that can be handled.
As it can be seen that only needing to load the image data based on generation for main thread, without to texture resourceMultiple tasks are loaded;Moreover, because the quantity for executing the image data that texture generates operation does not exceed the every frame of main threadThe View data quantity that maximum can be handled, avoids the Caton of main thread.
The application is illustrated below with reference to the alternative embodiment of the present embodiment.
How optimization Cocos2dx game engine is passed through in concrete application scene with the application in this alternative embodimentMode to realize is illustrated.
Firstly, modification engine CCTextureCache module, supports the asynchronous load based on thread pool.
Modification this sector of breakdown data structure as shown in Figure 2, wherein
_ loadingThreads indicates all thread objects in thread pool;
_ asyncStructQueueOnOneThread indicates the loading tasks queue on some current thread;
_ asyncStructQueueMutexOnOneThread indicates the task queue operation mutual exclusion device of some thread;
_ sleepConditionOnOneThread indicates the waiting conditional-variable of some thread;
_ maxCbPerFrame indicates manageable stock number when the every frame of main thread is adjusted back;
_ ioThreadNum indicates the thread amount in current thread pond, can be configured according to actual needs;
_ curThreadIdxToPutTask indicates next task thread to be assigned to;
Then TextureCache::addImageAsync function is modified, as shown in figure 3, in 149~155 rows, when puttingWhen entering a new task, whether the lower thread that will handle this task of judgement has been created, if not having, creates a loadThread executes TextureCache::loadImage function, and creates a task queue for it.In 166 rows, according to parameter,Generate task structure.The task structure that 166 rows generate is put into the task queue of the thread by 169~172 rows.174 rows lead toIt crosses conditional-variable and wakes up the thread.176 rows modify next Thread Id that will receive task.
As it can be seen that by modifying this function, asynchronous operation request will alternately be put into these threads in order and be heldRow.
As shown in figure 4, then modifying TextureCache::loadImage function, in function parameter, we can knowThe ID of road current thread, i.e. threadIdx.By this variable, we can take the task queue of the thread, and take out theOne task carries out IO load.If task queue is sky, the thread is allowed to enter wait state, waited correspondingSleepCondtion conditional-variable issues notify event.It loads and completes to IO, and after generating image data, image dataIt is placed in the consumption queue of main thread, main thread is waited to generate real texture object.
As shown in figure 5, TextureCache::addImageAsyncCallBack function is next modified, due to main lineJourney is limited in the execution time of every frame, it is not desired that main thread processes more image datas in the readjustment of every frame,Cause main thread that Caton occurs.Therefore it joined maxCbPerFrame, control the image data number that every frame maximum can be handled., can be by the way that maxCbPerFrame parameter be arranged such as 335~336 rows, then this function is at most executed from image data queueTexture generation operation is carried out by maxCbPerFrame data are no more than.
As shown in fig. 6, addition TextureCache::setIOThreadNum interface, setting load thread amount.
As shown in fig. 7, addition TextureCache::setMaxCbPerFrame interface, the every frame readjustment of setting main threadAmount.
Secondly, the modification asynchronous loading module of script, is arranged thread amount and readjustment amount, and connect with association's asynchronous load of journey encapsulationMouthful.
As shown in figure 8, in the asynchronous loading module of script, the code in frame above, most provided with the every frame of main threadBig readjustment amount, the code in following frame first obtain the CPU quantity of this equipment, are then provided with 2 times of CPU numbersThe thread amount of amount, for executing asynchronous load operation.
As shown in figure 9, the association Cheng Gongneng provided by Lua language, packaged asynchronous loading interface.Allow to by sameThe written in code asynchronous logic of step form.
Through the above description of the embodiments, those skilled in the art can be understood that according to above-mentioned implementationThe method of example can be realized by means of software and necessary general hardware platform, naturally it is also possible to by hardware, but it is very muchIn the case of the former be more preferably embodiment.Based on this understanding, technical solution of the present invention is substantially in other words to existingThe part that technology contributes can be embodied in the form of software products, which is stored in a storageIn medium (such as ROM/RAM, magnetic disk, CD), including some instructions are used so that a terminal device (can be mobile phone, calculateMachine, server or network equipment etc.) execute method described in each embodiment of the present invention.
A kind of processing unit of resource is additionally provided in embodiments herein, the device is for realizing above-described embodimentAnd preferred embodiment, the descriptions that have already been made will not be repeated.As used below, term " module " may be implemented to make a reservation forThe combination of the software and/or hardware of function.It is hard although device described in following embodiment is preferably realized with softwareThe realization of the combination of part or software and hardware is also that may and be contemplated.
Figure 10 is the structural block diagram of the processing unit of resource according to an embodiment of the present invention, as shown in Figure 10, the device packetIt includes: loading module 22, for multiple tasks relevant to texture resource to be loaded at least one loaded line in load thread poolIn the task queue of journey;First processing module 24 is of coupled connections with loading module 22, for appointing from least one load threadPending task is obtained in business queue, and loads pending task to generate image data.
Optionally, first processing module includes: acquiring unit, for obtaining the identification information of current load thread;It determinesUnit, for according to the determining task queue corresponding with current load thread of identification information;Processing unit, for being loaded currentlyIn the case that the corresponding task queue of thread is non-empty, pending is obtained from the corresponding task queue of current load threadBusiness, and pending task is loaded to generate image data.
Figure 11 is the alternative construction block diagram of the processing unit of resource according to an embodiment of the present invention, as shown in figure 11, the dressIt sets further include: input module 32 is of coupled connections with first processing module 24, in the task team from least one load threadPending task is obtained in column, and after loading pending task to generate image data, the image data of generation is input toIn the consumption queue of main thread;Second processing module 34 is of coupled connections with input module 32, for obtaining not from consumption queueOperation is generated more than the image data of preset quantity to execute texture.
It should be noted that above-mentioned modules can be realized by software or hardware, for the latter, Ke YitongFollowing manner realization is crossed, but not limited to this: above-mentioned module is respectively positioned in same processor;Alternatively, above-mentioned modules are with anyCombined form is located in different processors.
Embodiments herein additionally provides a kind of storage medium, is stored with computer program in the storage medium, whereinThe computer program is arranged to execute the step in any of the above-described embodiment of the method when operation.
Optionally, in the present embodiment, above-mentioned storage medium can be set to store by executing based on following stepsCalculation machine program:
Multiple tasks relevant to texture resource are loaded into the task of at least one load thread in load thread pool by S1In queue;
S2 obtains pending task from the task queue of at least one load thread, and loads pending task with lifeAt image data.
Optionally, in the present embodiment, above-mentioned storage medium can include but is not limited to: USB flash disk, read-only memory (Read-Only Memory, referred to as ROM), it is random access memory (Random Access Memory, referred to as RAM), mobile hardThe various media that can store computer program such as disk, magnetic or disk.
Embodiments herein additionally provides a kind of electronic device, including memory and processor, stores in the memoryThere is computer program, which is arranged to run computer program to execute the step in any of the above-described embodiment of the methodSuddenly.
Optionally, above-mentioned electronic device can also include transmission device and input-output equipment, wherein the transmission deviceIt is connected with above-mentioned processor, which connects with above-mentioned processor.
Optionally, in the present embodiment, above-mentioned processor can be set to execute following steps by computer program:
Multiple tasks relevant to texture resource are loaded into the task of at least one load thread in load thread pool by S1In queue;
S2 obtains pending task from the task queue of at least one load thread, and loads pending task with lifeAt image data.
Optionally, the specific example in the present embodiment can be with reference to described in above-described embodiment and optional embodimentExample, details are not described herein for the present embodiment.
Obviously, those skilled in the art should be understood that each module of the above invention or each step can be with generalComputing device realize that they can be concentrated on a single computing device, or be distributed in multiple computing devices and formedNetwork on, optionally, they can be realized with the program code that computing device can perform, it is thus possible to which they are storedIt is performed by computing device in the storage device, and in some cases, it can be to be different from shown in sequence execution hereinOut or description the step of, perhaps they are fabricated to each integrated circuit modules or by them multiple modules orStep is fabricated to single integrated circuit module to realize.In this way, the present invention is not limited to any specific hardware and softwares to combine.
The foregoing is only a preferred embodiment of the present invention, is not intended to restrict the invention, for the skill of this fieldFor art personnel, the invention may be variously modified and varied.It is all within principle of the invention, it is made it is any modification, etc.With replacement, improvement etc., should all be included in the protection scope of the present invention.

Claims (10)

CN201910289095.6A2019-04-112019-04-11Processing method and processing device, storage medium and the electronic device of resourcePendingCN110064198A (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN201910289095.6ACN110064198A (en)2019-04-112019-04-11Processing method and processing device, storage medium and the electronic device of resource

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN201910289095.6ACN110064198A (en)2019-04-112019-04-11Processing method and processing device, storage medium and the electronic device of resource

Publications (1)

Publication NumberPublication Date
CN110064198Atrue CN110064198A (en)2019-07-30

Family

ID=67367472

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN201910289095.6APendingCN110064198A (en)2019-04-112019-04-11Processing method and processing device, storage medium and the electronic device of resource

Country Status (1)

CountryLink
CN (1)CN110064198A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN110908784A (en)*2019-11-122020-03-24苏州智加科技有限公司Image labeling method, device, equipment and storage medium
CN111831434A (en)*2020-07-012020-10-27Oppo广东移动通信有限公司 Resource allocation method, device, storage medium and electronic device
CN112604284A (en)*2020-12-292021-04-06北京冰封互娱科技有限公司Task execution method, device and equipment of game and computer readable storage medium
WO2024125273A1 (en)*2022-12-132024-06-20华为技术有限公司Task concurrency method for interpreted scripting language, and related product

Citations (2)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN102799456A (en)*2012-07-242012-11-28上海晨思电子科技有限公司Method and device for uploading resource files by game engine, and computer
CN107357650A (en)*2017-06-062017-11-17武汉斗鱼网络科技有限公司A kind of automatic method for releasing of internal memory based on picture resource and system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN102799456A (en)*2012-07-242012-11-28上海晨思电子科技有限公司Method and device for uploading resource files by game engine, and computer
CN107357650A (en)*2017-06-062017-11-17武汉斗鱼网络科技有限公司A kind of automatic method for releasing of internal memory based on picture resource and system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
刘洪江主编: "《计算机组装与维护实训教程》", 31 January 2014*

Cited By (6)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
CN110908784A (en)*2019-11-122020-03-24苏州智加科技有限公司Image labeling method, device, equipment and storage medium
CN110908784B (en)*2019-11-122022-09-20苏州智加科技有限公司Image labeling method, device, equipment and storage medium
CN111831434A (en)*2020-07-012020-10-27Oppo广东移动通信有限公司 Resource allocation method, device, storage medium and electronic device
CN112604284A (en)*2020-12-292021-04-06北京冰封互娱科技有限公司Task execution method, device and equipment of game and computer readable storage medium
CN112604284B (en)*2020-12-292024-04-16北京冰封互娱科技有限公司Game task execution method, device, equipment and computer readable storage medium
WO2024125273A1 (en)*2022-12-132024-06-20华为技术有限公司Task concurrency method for interpreted scripting language, and related product

Similar Documents

PublicationPublication DateTitle
CN110064198A (en)Processing method and processing device, storage medium and the electronic device of resource
CN103226486B (en) Method and device for optimizing browser operation
CN109542600B (en)Distributed task scheduling system and method
US9886735B2 (en)Hybrid engine for central processing unit and graphics processor
CN105741227A (en)Rending method and apparatus
CN106897132A (en)The method and device of a kind of server task scheduling
CN110162388A (en)A kind of method for scheduling task, system and terminal device
CN110427256A (en)Job scheduling optimization method, equipment, storage medium and device priority-based
CN111104210A (en)Task processing method and device and computer system
US20120204188A1 (en)Processor thread load balancing manager
CN112130977B (en)Task scheduling method, device, equipment and medium
CN110493317B (en)Method for processing cloud platform resource fragments and related equipment
CN103069390A (en)Re-scheduling workload in a hybrid computing environment
CN102902576B (en)Method, server and system for rendering webpages
US9105208B2 (en)Method and apparatus for graphic processing using multi-threading
CN102984124B (en)A kind of method and system that client gaming program is quickly implanted browser
CN108920274B (en) Performance optimization and device for image processing server
US10114679B2 (en)Logical CPU division usage heat map representation
CN112114877B (en)Method for dynamically compensating thread bundle warp, processor and computer storage medium
CN118409846A (en) Queue scheduling method, chip, system, medium and program product
CN111953503B (en)NFV resource deployment arrangement method and network function virtualization orchestrator
JP2019106031A (en)Data processing system and data analysis/processing method
CN112328532A (en)Multi-GPU communication method and device, storage medium and electronic device
CN110362394A (en)Task processing method and device, storage medium, electronic device
CN110349076A (en)The processing method and processing device of data

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
RJ01Rejection of invention patent application after publication

Application publication date:20190730

RJ01Rejection of invention patent application after publication

[8]ページ先頭

©2009-2025 Movatter.jp