CN117392266A - Wire frame drawing method, wire frame drawing device, electronic equipment and computer readable storage medium - Google Patents

Wire frame drawing method, wire frame drawing device, electronic equipment and computer readable storage medium Download PDF

Info

Publication number
CN117392266A
CN117392266A CN202311441842.6A CN202311441842A CN117392266A CN 117392266 A CN117392266 A CN 117392266A CN 202311441842 A CN202311441842 A CN 202311441842A CN 117392266 A CN117392266 A CN 117392266A
Authority
CN
China
Prior art keywords
primitive
index data
vertex index
drawn
basic graph
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
CN202311441842.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.)
Nanjing Sietium Semiconductor Co ltd
Original Assignee
Nanjing Sietium Semiconductor 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 Nanjing Sietium Semiconductor Co ltd filed Critical Nanjing Sietium Semiconductor Co ltd
Priority to CN202311441842.6A priority Critical patent/CN117392266A/en
Publication of CN117392266A publication Critical patent/CN117392266A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/20Drawing from basic elements, e.g. lines or circles
    • G06T11/203Drawing of straight lines or curves
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/005General purpose rendering architectures
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The embodiment of the disclosure discloses a wire frame drawing method, a device, electronic equipment and a computer readable storage medium, belonging to the technical field of image processing, wherein the method comprises the following steps: acquiring original vertex index data of a primitive to be drawn and an initial primitive type, wherein the initial primitive type is a surface primitive; determining a basic graph for forming the primitive to be drawn according to the initial primitive type; determining target vertex index data and drawing sequence corresponding to each basic graph according to the initial primitive type in the original vertex index data of the primitive to be drawn; and drawing line primitives corresponding to each basic graph according to the target vertex index data corresponding to each basic graph and the drawing sequence when the rendering task of the line frame mode is executed, so as to obtain a line diagram of the line primitives to be drawn. The drawing of the line block diagram can be accomplished without increasing the flow of the rendering pipeline when the GPU does not support drawing the line block diagram of the graphics.

Description

Wire frame drawing method, wire frame drawing device, electronic equipment and computer readable storage medium
Technical Field
The present disclosure relates to the field of graphics processing technologies, and in particular, to a wire frame drawing method, a wire frame drawing device, an electronic device, and a computer readable storage medium.
Background
With the development of computer graphics, most of the existing electronic devices are provided with microprocessors, such as graphics processors (Graphics Processing Unit, GPUs), which are dedicated to image and graphics related operations. The process of executing the rendering task once by the GPU is that a user sets parameter information such as vertex data, vertex index data, primitive types, shader information and the like of an object to be drawn through a graphics application program interface (ApplicationProgramming Interface, API), the GPU user state driving software packages the parameter information set by the user into a data packet which can be identified by the GPU and transmits the data packet to the GPU kernel state driving software, the GPU kernel state driving software copies the data packet to a video memory, and the GPU analyzes the data packet in the video memory and executes the rendering task.
In computer graphics, it is often necessary to draw a line-block diagram of a graphic, i.e. to display only the line-frame outline of the graphic without surface details such as color, texture or illumination. The existing line block diagram for drawing graphics requires the support of the GPU. In the case where the GPU does not support wire frame mode, it is often necessary for the user to add a Geometry Shader (Geometry Shader) function in the rendering pipeline, which generates a wire frame diagram of the primitives to be drawn from the input vertex data. However, adding a geometry shader in the rendering pipeline increases the steps of manual processing for the user and increases the rendering flow, resulting in reduced rendering efficiency for the GPU.
Therefore, in the case where the GPU does not support the wire frame mode, how to implement drawing of a wire frame diagram of a primitive to be drawn without increasing the flow of the rendering pipeline.
Disclosure of Invention
The present disclosure provides a wire frame drawing method, apparatus, electronic device, and computer-readable storage medium; the drawing of the line block diagram can be achieved when the GPU hardware does not support the drawing of the line block diagram of the graphics, and the flow of the rendering pipeline is not increased.
In a first aspect, the present disclosure provides a wire frame drawing method, the method comprising: acquiring original vertex index data of a primitive to be drawn and an initial primitive type, wherein the initial primitive type is a surface primitive; determining a basic graph forming the primitive to be drawn according to the initial primitive type, wherein the basic graph comprises triangles and polygons; determining target vertex index data and drawing sequence corresponding to each basic graph according to the initial primitive type in the original vertex index data of the primitive to be drawn; and drawing line primitives corresponding to each basic graph according to the target vertex index data corresponding to each basic graph and the drawing sequence when the rendering task of the line frame mode is executed, so as to obtain a line diagram of the to-be-drawn line primitives.
In a second aspect, the present disclosure provides a wire frame drawing apparatus comprising: the device comprises an acquisition module, a determination module, a modification module and a drawing module; the acquisition module is used for acquiring original vertex index data of the primitive to be drawn and an initial primitive type, wherein the initial primitive type is a face primitive; the determining module is used for determining a basic graph for forming the primitive to be drawn according to the initial primitive type, wherein the basic graph comprises triangles and polygons; the determining module is further used for determining target vertex index data and drawing sequences corresponding to each basic graph according to the initial primitive types in the original vertex index data of the primitives to be drawn; the drawing module is used for drawing line primitives corresponding to each basic graph according to the target vertex index data corresponding to each basic graph and the drawing sequence when the rendering task of the line frame mode is executed, so as to obtain a line diagram of the to-be-drawn line primitives.
In a third aspect, the present disclosure provides an electronic device comprising a processor, a memory and a program or instructions stored on the memory and executable on the processor, which when executed by the processor, implement the steps of the wireframe drawing method as in the first aspect.
In a fourth aspect, the present disclosure provides a computer readable storage medium having stored thereon a program or instructions which when executed by a processor performs the steps of the wire frame drawing method as the first aspect.
In a fifth aspect, the present disclosure provides a computer program product, wherein the computer program product comprises a computer program or instructions which, when run on a processor, cause the processor to execute the computer program or instructions to carry out the steps of the wire frame drawing method as in the first aspect.
In a sixth aspect, the present disclosure provides a chip comprising a processor and a communication interface coupled to the processor for running a program or instructions implementing a wire frame drawing method as in the first aspect.
The present disclosure provides a wire frame drawing method, which determines to form a basic graph of an element to be drawn by acquiring original vertex index data of the element to be drawn and an initial primitive type; determining target vertex index data and drawing sequence corresponding to each basic graph according to the original vertex index data and the initial primitive type of the primitive to be drawn; and finally, when the rendering task of the line frame mode is executed according to the target vertex index data and the rendering sequence corresponding to each basic graph, drawing the line primitive corresponding to each basic graph to obtain a line diagram of the to-be-drawn primitive. Therefore, when a user needs to draw a line block diagram and the GPU does not support line frame drawing, the user only needs to start a line frame mode, so that hardware cost is saved; moreover, compared with the case that a user manually adds a geometric shader in a rendering pipeline to realize a wire frame function, the scheme can reduce the cost of manual operation of the user and has high rendering efficiency.
Drawings
Fig. 1 is a schematic flow chart of a wire frame drawing method according to an embodiment of the disclosure;
FIG. 2 is a schematic diagram of a line primitive provided by an embodiment of the present disclosure;
FIG. 3 is a schematic diagram of a surface primitive provided by an embodiment of the present disclosure;
FIG. 4 is a schematic diagram of a drawing direction of a surface primitive provided in an embodiment of the present disclosure;
FIG. 5 is a schematic diagram of a line block diagram of an primitive to be depicted provided in an embodiment of the present disclosure;
FIG. 6 is a second flow chart of a wire frame drawing method according to an embodiment of the disclosure;
FIG. 7 is a schematic diagram of a comparison of a non-closed segment and a closed segment provided by an embodiment of the present disclosure;
FIG. 8 is a third flow chart of a wire frame drawing method according to an embodiment of the disclosure;
FIG. 9 is a flowchart of a wire frame drawing method according to an embodiment of the present disclosure;
fig. 10 is a block diagram of a wire frame drawing apparatus according to an embodiment of the present disclosure;
fig. 11 is a schematic hardware structure of an electronic device according to an embodiment of the disclosure.
Detailed Description
The technical solutions of the present disclosure will be clearly described below with reference to the drawings in the present disclosure, and it is apparent that the described embodiments are some embodiments of the present disclosure, but not all embodiments. All other embodiments obtained by one of ordinary skill in the art based on the embodiments in this disclosure are within the scope of the present disclosure.
The terms first, second and the like in the description and in the claims, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate, such that embodiments of the disclosure may be implemented in sequences other than those illustrated or described herein, and that the objects identified by "first," "second," etc. are generally of the same type and are not limited to the number of objects, such as the first object may be one or more. Furthermore, in the description and claims, "and/or" means at least one of the connected objects, and the character "/", generally means that the associated object is an "or" relationship.
The wire frame drawing method provided by the embodiment of the present disclosure is described in detail below with reference to the accompanying drawings.
In an embodiment of the present disclosure, as shown in fig. 1, a wire frame drawing method is provided, which includes the following steps 101 to 104.
101. And acquiring original vertex index data of the primitive to be drawn and an initial primitive type.
Wherein the initial primitive type is a face primitive.
It should be noted that, when it is detected that the user has set the wire frame mode, steps 101 to 105 are performed, and the user only needs to enable the wire frame mode, without performing other operations.
Specifically, one original vertex index data is used to indicate one connection point in the primitives to be drawn, and the number of the original vertex index data included in each primitive to be drawn is greater than or equal to 3.
The drawing primitives to be drawn are the smallest units constituting the drawing figures to be drawn, and any drawing figure to be drawn is composed of at least one drawing primitive to be drawn.
Primitive types fall into three major categories: a dot pattern element, a line pattern element and a face pattern element.
Single set of vertices (gl_points): the specified vertices are used to create a single point.
As shown in fig. 2, the line elements include three kinds of sets of dual vertex line segments (gl_lines): using the designated vertices to create line segments, designating a single line segment by two vertices, and if the number of vertices is odd, ignoring the last vertex; non-closed LINE segment (gl_line_strip): using the specified vertices to create line segments, the vertex following each vertex specifying the next vertex to which the line extends; closed LINE segment (gl_line_loop): the specified vertices are used to create line segments, the vertex following each vertex specifies the next vertex to which the line extends, and the last line segment is drawn between the specified last and first vertices.
As shown in fig. 3, the face primitive includes the following six, sets of independently populated triangles (gl_ TRIANGLES): using the designated vertices to construct triangles, designating a new triangle for every three vertices, and if the number of vertices is not a multiple of three, the redundant vertices will be ignored; linear continuous fill TRIANGLE (gl_triangle_strip): using the specified vertices to create triangles, after specifying the first three vertices, each subsequent vertex is used with its two preceding vertices to construct the next triangle, each vertex triplet (after the initial group) automatically rearranging to ensure consistency of triangle drawing order; sector continuous fill triangle (gl_track_fan): the designated vertexes are used for constructing a triangle sector, the first vertex serves as an origin, and every two subsequent vertexes and the origin form a triangle; sets of independent filled quadrilaterals (gl_quads): a group of four vertices is used to construct a quadrilateral, and if the number of vertices is not a multiple of four, redundant vertices are ignored; continuously filled quadrilaterals (gl_query_strip): the designated vertexes are used for constructing quadrilaterals, after the first pair of vertexes, each pair of vertexes defines a quadrilateral, and the order of the vertexes of each pair of vertexes is different from that of the vertexes of GL_QUADS, and the vertexes of each pair are used in the reverse order of the designated order so as to ensure the consistency of the drawing order; single simple filled convex POLYGON (gl_polygon): the designated vertices are used to construct a convex polygon, the edges of which can never intersect, and the last vertex is automatically connected to the first vertex to ensure that the polygon is closed.
The numerals 0,1,2,3,4,5, etc. shown in fig. 2 and 3 are used to indicate vertex index data. Vertex data is coordinates of each vertex, and one vertex index data is used for identifying one vertex.
The initial primitive type is any one of GL_ TRIANGLES, GL _TRIANGLE_STRIP, GL_TRAINGLE_FAN, GL_QUADS_STRIP, GL_QUADS, GL_POLYGON. However, this is not a limitation of the present disclosure, and the initial primitive type may be other face primitives.
102. And determining a basic graph for forming the primitive to be drawn according to the initial primitive type.
Wherein the basic pattern includes triangles and polygons.
Specifically, in the case where the initial primitive type is gl_ TRIANGLES, GL _triangle_stream or gl_triangle_fan, the base primitive type is determined to be TRIANGLE; in the case that the initial primitive type is GL_QUADS_STRIP or GL_QUADS, determining that the basic graphic type is quadrilateral; in the case where the initial primitive type is gl_polygon, the basic graphic type is determined to be a convex POLYGON.
103. And determining target vertex index data and drawing sequence corresponding to each basic graph according to the initial primitive type in the original vertex index data of the primitive to be drawn.
Specifically, according to the initial primitive type and the original vertex index data of the primitive to be drawn, determining target vertex index data corresponding to the basic graphic. Such as: the original vertex index data are (0, 1,2,3,4, 5), and under the condition that the initial primitive type is GL_ TRIANGLES, the basic graph is determined to be two triangles, and the target vertex index data corresponding to the two triangles are respectively (0, 1, 2), (3, 4, 5); under the condition that the initial primitive type is GL_TRIANGLE_STRIP, determining that the basic graph is four TRIANGLEs, and the target vertex index data corresponding to the four TRIANGLEs are (0, 1, 2), (1, 2, 3), (2, 3, 4), (3, 4, 5) respectively; under the condition that the initial primitive type is GL_TRAINGLE_FAN, determining that the basic graph is four triangles, and respectively determining that target vertex index data corresponding to the four triangles is (0, 1, 2), (0, 2, 3), (0, 3, 4) and (0,4,5); under the condition that the initial primitive type is GL_QUADS_STRIP, determining that the basic graph is two quadrangles, wherein target vertex index data corresponding to the two quadrangles are (0, 1,2, 3), (2, 3,4, 5) respectively; under the condition that the initial primitive type is GL_QUADS, determining that the basic graph is a quadrangle, and determining that target vertex index data corresponding to the quadrangle is (0, 1,2, 3); in the case that the initial primitive type is gl_poly, it is determined that the basic pattern is a convex hexagon, and the target vertex index data corresponding to the convex hexagon is (0, 1,2,3,4, 5).
Each type of primitive has a default drawing direction, such as clockwise or counter-clockwise. According to the default drawing direction of the primitive types, the drawing order of each original vertex index data can be determined, so that the drawing order of the target vertex index data and the original vertex index data is identical.
Illustratively, as shown in FIG. 4, the initial primitive types are: gl_trigger_strip, the default drawing direction is counterclockwise, i.e., the arrow direction shown in fig. 4. The original vertex index data are (0, 1,2,3, 4), the target vertex index data corresponding to the three TRIANGLEs are (0, 1, 2), (1, 2, 3), (2, 3, 4), and after changing the drawing sequence of the target vertex index data according to the default drawing direction of GL_TRIANGLE_STRIP, the target vertex index data corresponding to the three TRIANGLEs are (0, 1, 2), (2, 1, 3), (2, 3, 4).
104. And drawing line primitives corresponding to each basic graph according to the target vertex index data corresponding to each basic graph and the drawing sequence when the rendering task of the line frame mode is executed, so as to obtain a line diagram of the to-be-drawn line primitives.
Specifically, the target vertex index data and the drawing sequence of each basic graph are determined through a graph API, the GPU user mode driving software packages the target vertex index data and the drawing sequence into data packets and transmits the data packets to the GPU kernel mode driving software, the GPU kernel mode driving software stores the data packets in a video memory, the GPU acquires the data packets from the video memory, and a rendering task is executed according to the target vertex index data and the drawing sequence obtained through analysis, so that a line block diagram of a to-be-drawn primitive is drawn.
Illustratively, as shown in fig. 5, the left side is a drawing primitive to be drawn based on the original vertex index data and the original primitive type, and the right side is a line block diagram of the drawing primitive to be drawn based on the target vertex index data and the drawing order of the respective original graphics. The color of the drawing primitive to be drawn is unchanged, namely the color of the line diagram is the same as the far filling color of the drawing primitive to be drawn. In practical applications, the color of the line block diagram may be rearranged as required, and the embodiments of the disclosure are not limited.
Alternatively, in order to facilitate drawing, before drawing the line primitive, the primitive type is set as the target primitive type (line primitive), and at the time of drawing, each basic graphic may be directly drawn as a corresponding line primitive.
It should be noted that, steps 101 to 104 in the embodiments of the present disclosure are used as built-in functions of the graphics API, and when a user needs to draw a line block diagram, the user only needs to call the function to draw the line block diagram.
In the embodiment of the disclosure, original vertex index data of an element to be drawn and an initial primitive type are obtained, wherein the initial primitive type is a surface primitive; determining a basic graph forming the primitive to be drawn according to the initial primitive type, wherein the basic graph comprises triangles and polygons; determining target vertex index data and drawing sequence corresponding to each basic graph according to the initial primitive type in the original vertex index data of the primitive to be drawn; and drawing line primitives corresponding to each basic graph according to the target vertex index data corresponding to each basic graph and the drawing sequence when the rendering task of the line frame mode is executed, so as to obtain a line diagram of the to-be-drawn line primitives. Therefore, when a user needs to draw a line block diagram and the GPU does not support line frame drawing, the user only needs to start a line frame mode, so that hardware cost is saved; moreover, compared with the case that a user manually adds a geometric shader in a rendering pipeline to realize a wire frame function, the scheme can reduce the cost of manual operation of the user and has high rendering efficiency.
In some embodiments of the present disclosure, when the line primitive is a closed line segment, a complete line diagram of the to-be-drawn primitive may be obtained through steps 101 to 104, but the line primitive is a non-closed line segment, and the last vertex is not connected to the first vertex by default extension, so in order to obtain the closed line diagram, vertex index data located at the first position is added in the target vertex index data. Specifically, with reference to fig. 1, as shown in fig. 6, after the above step 103, the wire frame drawing method further includes the following step 105.
105. And adding first vertex index data at the tail end of the target vertex index data corresponding to each basic graph when the line element is a non-closed line segment.
The first vertex index data is the first vertex in the target vertex index data corresponding to each basic figure.
Illustratively, as shown in FIG. 7, the original vertex index data is (0, 1,2,3, 4), the initial primitive type is GL_TRIANGLE_STRIP, and the primitive drawn is the primitive in the region indicated by reference numeral 701. In the case where the target primitive type is gl_line_strip (non-closed LINE segment) and the target vertex index data is (0, 1, 2), (1, 2, 3), (2, 3, 4), the primitive to be drawn is the primitive in the region indicated by reference numeral 702; when the target vertex index data is (0,1,2,0), (1,2,3,1), or (2,3,4,2) after adding the first vertex index data, the primitive to be drawn is the primitive in the region indicated by reference numeral 703. In the case where the target primitive type is gl_line_loop (closed LINE segment) and the target vertex index data is (0, 1, 2), (1, 2, 3), (2, 3, 4), the primitive to be drawn is the primitive in the region indicated by reference numeral 703.
In the embodiment of the disclosure, when the line element is a non-closed line segment, adding first vertex index data at the end of target vertex index data corresponding to each basic graph. When the line diagram is drawn, whether the line diagram is drawn by a closed line segment or a non-closed line segment, the complete line diagram of the graph to be drawn can be obtained.
In some embodiments of the present disclosure, the types of the initial primitives are different, and the strategies for obtaining the target vertex index data from the initial vertex index data are different, specifically, as shown in fig. 8 in conjunction with fig. 6, the above step 103 may be specifically implemented by the following steps 103a and 103c or 103b and 103 c.
103a, in the case that the initial primitive type indicates that a plurality of basic graphics forming the primitive to be drawn are continuous, determining any continuous N original vertex index data as target vertex index data corresponding to one basic graphics in the original vertex index data of the primitive to be drawn.
Wherein N is an integer greater than 2.
It should be noted that, the initial primitive types are different, and the values of N are different, for example: the basic graph determined according to the initial primitive type is a triangle, and N is 3; the basic graph determined according to the initial primitive type is a quadrilateral, and N is 4.
The plurality of base patterns are continuous, i.e., each two of the plurality of base patterns share at least one vertex.
And under the condition that the initial primitive type indicates that a plurality of basic graphs forming the primitive to be drawn are continuous, determining target vertex index data corresponding to each basic graph by taking N arbitrary continuous basic vertex index data in the original vertex index data as target vertex index data corresponding to one basic graph. It can be understood that a sliding window with a window size of N is set, and the sliding window continuously slides from the first vertex data of the initial vertex index data according to a step size of 1, and three vertex index data falling in the sliding window each time are target vertex index data corresponding to a basic graph. Such as: the original vertex index data is (0, 1,2,3, 4), the initial primitive type is gl_triangle_strip, and N is 3, and the target vertex index data corresponding to the three TRIANGLEs is (0, 1, 2), (1, 2, 3), (2, 3, 4).
103b, in the case that the initial primitive type indicates that a plurality of basic graphics forming the primitive to be drawn are independent, determining each M consecutive original vertex index data as target vertex index data corresponding to one basic graphics and drawing order in the original vertex index data of the primitive to be drawn.
Wherein M is an integer greater than 2.
It should be noted that, the plurality of basic patterns are independent, i.e., any two basic patterns in the plurality of basic patterns have no common vertex.
When the initial primitive type indicates that a plurality of basic graphics forming the primitive to be drawn are independent, determining target vertex index data corresponding to each basic graphics by taking each M continuous basic graphics as target vertex index data corresponding to one basic graphics in the original vertex index data. It can be understood that a sliding window with a window size of M is set, and the sliding window continuously slides from the first vertex data of the initial vertex index data according to a step length of M, and three vertex index data falling in the sliding window each time are target vertex index data corresponding to a basic graph. Such as: the original vertex index data is (0, 1,2,3,4, 5), the initial primitive type is gl_ TRIANGLES, N is 3, and the target vertex index data corresponding to the two triangles is (0, 1, 2), (3, 4, 5).
103c, according to the initial primitive types, adjusting the drawing sequence corresponding to the target vertex index data corresponding to each basic graph.
Each initial primitive type has a default drawing direction, and the target vertex index data sequence in each basic graph is adjusted according to the drawing direction indicated by the primitive type, so that when a rendering task is executed, the target vertex index data is drawn according to the adjusted drawing sequence, and a line diagram of the primitive to be drawn is obtained.
In the embodiment of the disclosure, when the initial primitive type indicates that a plurality of basic graphics forming an primitive to be drawn are continuous, determining any continuous N pieces of original vertex index data as target vertex index data corresponding to one basic graphics in the original vertex index data of the primitive to be drawn; when the initial primitive type indicates that a plurality of basic graphics forming the primitive to be drawn are independent, determining each M continuous original vertex index data in the original vertex index data of the primitive to be drawn as target vertex index data corresponding to one basic graphics and drawing sequence; according to the initial primitive types, adjusting the drawing sequence corresponding to the target vertex index data corresponding to each basic graph; thus, whether the primitive type indicates that the drawn primitive is continuous or independent, the method of the scheme can accurately draw the line and block diagram of the primitive to be drawn.
In some embodiments of the present disclosure, the GPU needs to call a drawing method once every time the GPU draws the basic graphics, but the drawing method needs to consume resources when the number of basic graphics is large, and the GPU needs to consume a lot of resources. Therefore, the embodiment is used for drawing a plurality of basic graphics in one drawing method call, so as to reduce the resource consumption of the GPU. Specifically, as shown in fig. 9 in conjunction with fig. 1, after the above step 103, the wire frame drawing method further includes the following steps 106 and 107.
106. And adding a primitive restarting identifier at the tail end of the target vertex index data corresponding to each basic graph.
107. The primitive restart mode is started to draw the primitive to be drawn in one drawing.
Primitive restart (Primitive Restart) is a special rendering technique that provides more flexible rendering control when rendering multiple sequential geometric primitives. When primitive restart is enabled, the end of the drawn sequence of geometric primitives may be marked by setting a particular index value and then starting the next sequence of geometric primitives. For example, when drawing a series of triangles, a particular index value (e.g., an invalid index) may be used in the index array to indicate that the drawing of the current sequence of geometric primitives is to be ended and the drawing of the next sequence of geometric primitives is to be started. Primitive restart when drawing multiple disjoint Triangle strips (Triangle strips) or Triangle fans (Triangle Fan), multiple geometric primitives can be drawn in a single independent draw call without splitting into multiple calls by using primitive restart.
Illustratively, the original vertex index data is (0, 1,2,3,4, 5), the initial primitive type is gl_ TRIANGLES, N is 3, and then the target vertex index data corresponding to the two triangles is (0, 1, 2), (3, 4, 5); the target primitive type is GL_LINE_LOOP, under the condition that primitive restarting is not started, two times of drawing are required to be called to complete the LINE frame drawing of two triangles, and each time of drawing is called, the GPU is required to consume corresponding resources, the resource consumption of the GPU is increased when the drawing is called for multiple times, and the rendering efficiency is influenced; under the condition that the primitive restarting is started, the target vertex index data corresponding to the two triangles is (0, 1,2,0xFF,3,4, 5); after the primitive is restarted, the drawing of the two triangle wire frames can be completed by calling one drawing. Wherein 0xFF is an invalid identifier.
In the embodiment of the disclosure, a primitive restarting identifier is added at the end of target vertex index data corresponding to each basic graph; the primitive restart mode is started to draw the primitive to be drawn in one drawing. Therefore, when a plurality of independent basic graphics are drawn, the drawing can be completed by only calling one time, and particularly when a large number of independent basic graphics with the same primitive type are required to be drawn, the rendering efficiency can be greatly improved.
In some embodiments of the present disclosure, before the step 106, the wire frame drawing method further includes a step 108, where the step 107 may be specifically implemented by the step 107 a.
108. And determining whether the number of basic graphics included in the primitive to be drawn is greater than 1 according to the initial primitive type and the original vertex index data.
Specifically, the initial primitive type is gl_ TRIANGLES, the number of vertex indexes is greater than or equal to 6, namely, the number of basic graphics is determined to be greater than 1; the initial primitive type is GL_triangle_STRIP or GL_TRAINGL_FAN, and the number of vertex indexes is greater than or equal to 4, namely, the number of basic graphs is determined to be greater than 1; the initial primitive type is GL_QUADS, and the number of vertex indexes is greater than or equal to 8, namely, the number of basic graphics is determined to be greater than 1; the initial primitive type is GL_QUADS_STRIP, the number of vertex indexes is more than or equal to 6, namely, the number of basic graphics is determined to be more than 1; the initial primitive type is GL_POLYGON, and the number of basic graphics is determined to be not more than 1.
107a, adding a primitive restart identifier at the end of the target vertex index data corresponding to each basic graph when the number is greater than 1.
When the number of the basic graphics to be drawn is larger than 1, starting the primitive restart can finish drawing of the block diagrams of a plurality of basic graphics in one drawing; under the condition that the number of the basic graphs to be drawn is equal to 1, namely, only one drawing is needed, at the moment, a primitive restarting identifier is not needed to be added and primitive restarting is not needed to be started, and the operation steps are reduced.
In the embodiment of the disclosure, according to the initial primitive type and the original vertex index data, determining whether the number of basic graphics included in the primitive to be drawn is greater than 1; and adding a primitive restarting identifier at the tail end of the target vertex index data corresponding to each basic graph under the condition that the number is greater than 1. Therefore, under the condition that the primitive to be drawn needs to be drawn for multiple times to obtain the line diagram, the line diagram is obtained by restarting the primitive once, so that the consumption of the GPU is reduced; under the condition that the drawing of the primitive to be drawn is only needed once to obtain the line block diagram, the primitive restarting identification and the primitive restarting mode are not needed to be added in an operation mode, the operation steps are reduced, and therefore the rendering efficiency is improved.
Fig. 10 is a block diagram of a wire frame drawing apparatus according to an embodiment of the present disclosure, and as shown in fig. 10, includes: an acquisition module 1001, a determination module 1002 and a drawing module 1003; the obtaining module 1001 is configured to obtain original vertex index data of a primitive to be drawn and an initial primitive type, where the initial primitive type is a surface primitive; the determining module 1002 is configured to determine, according to an initial primitive type, a basic graphic that forms a primitive to be drawn, where the basic graphic includes a triangle and a polygon; the determining module 1002 is further configured to determine, in the original vertex index data of the primitives to be drawn, target vertex index data and a drawing order corresponding to each basic graphic according to the initial primitive type; the drawing module 1003 is configured to draw line primitives corresponding to each basic graphic according to the target vertex index data and the drawing order corresponding to each basic graphic, when performing the rendering task of the line frame mode, so as to obtain a line diagram of the to-be-drawn line primitive.
In some embodiments of the present disclosure, the line element is a non-closed line segment; the apparatus further comprises: adding a module; the adding module is used for adding first vertex index data at the tail end of the target vertex index data corresponding to each basic graph after determining the target vertex index data corresponding to each basic graph and the drawing sequence according to the initial primitive type in the original vertex index data of the primitive to be drawn, wherein the first vertex index data is the first vertex in the target vertex index data corresponding to each basic graph.
In some embodiments of the present disclosure, the initial primitive type indicates that a plurality of base graphics forming the primitive to be drawn are contiguous; the determining module 1002 is specifically configured to determine, from among the original vertex index data of the primitive to be drawn, any continuous N original vertex index data as target vertex index data corresponding to a basic graph, where N is an integer greater than 2; and according to the initial primitive types, adjusting the drawing sequence corresponding to the target vertex index data corresponding to each basic graph.
In some embodiments of the present disclosure, the initial primitive type indicates that the base graphics forming the plurality of primitives to be drawn are independent; the determining module 1002 is specifically configured to determine, among original vertex index data of primitives to be drawn, each M consecutive original vertex index data as target vertex index data corresponding to a basic graph, where M is an integer greater than 2; and according to the initial primitive types, adjusting the drawing sequence corresponding to the target vertex index data corresponding to each basic graph.
In some embodiments of the present disclosure, the apparatus further comprises: starting a module; the adding module is further configured to determine, according to an initial primitive type, target vertex index data corresponding to each basic graph and a drawing order in original vertex index data of primitives to be drawn, and then add a primitive restart identifier at the end of the target vertex index data corresponding to each basic graph; the starting module is used for starting a primitive restarting mode so as to draw the primitive to be drawn in one drawing.
In some embodiments of the present disclosure, the determining module 1002 is further configured to determine, before adding a primitive restart identifier at the end of the target vertex index data corresponding to each primitive, whether the number of primitives included in the primitive to be drawn is greater than 1 according to the initial primitive type and the original vertex index data; the adding module is specifically configured to add a primitive restart identifier at the end of the target vertex index data corresponding to each basic graph when the number is greater than 1.
It should be noted that, the wire frame drawing device may be an electronic device in the foregoing method embodiment of the disclosure, or may be a functional module and/or a functional entity in the electronic device that can implement a function of the device embodiment, and the embodiment of the disclosure is not limited.
In the embodiment of the disclosure, each module may implement the wire frame drawing method provided in the embodiment of the method, and may achieve the same technical effects, so that repetition is avoided, and no description is repeated here.
Fig. 11 is a block diagram of a computing device according to an embodiment of the present disclosure. In some examples, computing device 1100 may be at least one of a smart phone, a smart watch, a desktop computer, a laptop computer, a virtual reality terminal, an augmented reality terminal, a wireless terminal, and a laptop portable computer. The computing device 1100 has communication capabilities and can access a wired network or a wireless network. Computing device 1100 may refer broadly to one of a plurality of terminals, and those skilled in the art will recognize that the number of terminals may be greater or lesser. It is to be appreciated that the computing device 1100 is responsible for computing and processing the aspects of the present disclosure, which is not limited by the present disclosure.
As shown in fig. 11, a computing device in the present disclosure may include one or more of the following components: a processor 1110 and a memory 1120.
In the alternative, processor 1110 utilizes various interfaces and lines to connect various portions of the overall computing device, performing various functions of the computing device and processing data by executing or executing instructions, programs, code sets, or instruction sets stored in memory 1120, and invoking data stored in memory 1120. Alternatively, the processor 1110 may be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field-Programmable gate array (FPGA), programmable Logic Array (PLA). The processor 1110 may integrate one or a combination of several of a central processing unit (Central Processing Unit, CPU), an image processing unit (Graphics Processing Unit, GPU), a Neural network processing unit (Neural-network Processing Unit, NPU), and a baseband chip, etc. The CPU mainly processes an operating system, a user interface, an application program and the like; the GPU is used for rendering and drawing the content required to be displayed by the touch display screen; the NPU is used to implement artificial intelligence (Artificial Intelligence, AI) functionality; the baseband chip is used for processing wireless communication. It will be appreciated that the baseband chip may not be integrated into the processor 1110 and may be implemented by a single chip.
The Memory 1120 may include a random access Memory (RandomAccess Memory, RAM) or a Read-Only Memory (ROM). Optionally, the memory 1120 includes a non-transitory computer readable medium (non-transitory computer-readable storage medium). Memory 1120 may be used to store instructions, programs, code, sets of codes, or instruction sets. The memory 1120 may include a stored program area and a stored data area, wherein the stored program area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playing function, an image playing function, etc.), instructions for implementing the above respective method embodiments, etc.; the storage data area may store data created from the use of the computing device, and the like.
In addition, those skilled in the art will appreciate that the structure of the computing device shown in the above-described figures is not limiting of the computing device, and that the computing device may include more or fewer components than shown, or may combine certain components, or a different arrangement of components. For example, the computing device further includes a display screen, a camera component, a microphone, a speaker, a radio frequency circuit, an input unit, a sensor (such as an acceleration sensor, an angular velocity sensor, a light sensor, etc.), an audio circuit, a WiFi module, a power supply, a bluetooth module, etc., which are not described herein.
The present disclosure also provides a computer-readable storage medium storing at least one instruction for execution by a processor to implement the wire frame drawing method described in the various embodiments above.
The present disclosure also provides a computer program product comprising computer instructions stored in a computer-readable storage medium; the processor of the computing device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions so that the computing device executes to implement the wire frame drawing method described in the above embodiments.
The embodiment of the disclosure further provides a chip, where the chip includes a processor and a communication interface, where the communication interface is coupled to the processor, and the processor is configured to run a program or an instruction, implement each process of the above embodiment of the wire frame drawing method, and achieve the same technical effect, so that repetition is avoided, and no further description is given here.
It should be understood that the chips referred to in the embodiments of the present disclosure may also be referred to as system-on-chip chips, chip systems, or system-on-chip chips, etc.
Those of skill in the art will appreciate that in one or more of the examples described above, the functions described in this disclosure may be implemented in hardware, software, firmware, or any combination thereof. When implemented in software, these functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes both computer storage media and communication media including any medium that facilitates transfer of a computer program from one place to another. A storage media may be any available media that can be accessed by a general purpose or special purpose computer.
It should be noted that: the embodiments described in the present disclosure may be arbitrarily combined without any collision.
The foregoing is merely illustrative of the present invention, and the present invention is not limited thereto, and any person skilled in the art will readily recognize that variations or substitutions are within the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims (10)

1. A wire frame drawing method, comprising:
acquiring original vertex index data of a primitive to be drawn and an initial primitive type, wherein the initial primitive type is a surface primitive;
determining a basic graph forming the primitive to be drawn according to the initial primitive type, wherein the basic graph comprises triangles and polygons;
determining target vertex index data and drawing sequence corresponding to each basic graph according to the initial primitive type in the original vertex index data of the primitive to be drawn;
and drawing line primitives corresponding to each basic graph according to the target vertex index data corresponding to each basic graph and the drawing sequence when the rendering task of the line frame mode is executed, so as to obtain a line diagram of the to-be-drawn line primitives.
2. The method of any of claims 1, wherein the line element is a non-closed line segment; the method further comprises the steps of after determining the target vertex index data corresponding to each basic graph and the drawing sequence in the original vertex index data of the primitive to be drawn according to the initial primitive type:
adding first vertex index data at the tail end of the target vertex index data corresponding to each basic graph, wherein the first vertex index data is the first vertex in the target vertex index data corresponding to each basic graph.
3. The method of claim 2, wherein the initial primitive type indicates that a plurality of primitive patterns forming the primitive to be drawn are sequential; in the original vertex index data of the primitive to be drawn, determining target vertex index data and drawing sequence corresponding to each basic graph according to the initial primitive type, including:
in the original vertex index data of the drawing primitive, determining any continuous N original vertex index data as target vertex index data corresponding to a basic graph, wherein N is an integer greater than 2;
and according to the initial primitive types, adjusting the drawing sequence corresponding to the target vertex index data corresponding to each basic graph.
4. The method of claim 2, wherein the initial primitive type indicates that a plurality of base graphics forming the primitive to be drawn are independent; the determining, in the original vertex index data of the primitive to be drawn, target vertex index data and drawing order corresponding to each basic graphic according to the initial primitive type includes:
determining continuous every M original vertex index data as target vertex index data corresponding to a basic graph in the original vertex index data of the drawing primitive to be drawn, wherein M is an integer greater than 2;
and according to the initial primitive types, adjusting the drawing sequence corresponding to the target vertex index data corresponding to each basic graph.
5. The method according to any one of claims 1 to 4, wherein after determining, in the original vertex index data of the primitive to be drawn, target vertex index data and drawing order corresponding to each basic figure according to the initial primitive type, the method further comprises:
adding a primitive restarting identifier at the tail of the target vertex index data corresponding to each basic graph;
and starting a primitive restarting mode to draw the primitive to be drawn in one drawing.
6. The method according to claim 5, wherein before adding the primitive restart identifier at the end of the target vertex index data corresponding to each basic graph, the method further comprises:
determining whether the number of basic graphics included in the primitive to be drawn is greater than 1 according to the initial primitive type and the original vertex index data;
adding a primitive restart identifier at the end of the target vertex index data corresponding to each basic graph, including:
and adding a primitive restarting identifier at the tail end of the target vertex index data corresponding to each basic graph under the condition that the number is larger than 1.
7. A wire frame drawing apparatus, characterized in that the apparatus comprises: the device comprises an acquisition module, a determination module and a drawing module;
the acquisition module is used for acquiring original vertex index data of the primitive to be drawn and an initial primitive type, wherein the initial primitive type is a face primitive;
the determining module is used for determining a basic graph forming the primitive to be drawn according to the initial primitive type, wherein the basic graph comprises triangles and polygons;
the determining module is further configured to determine, in the original vertex index data of the primitive to be drawn, target vertex index data and a drawing order corresponding to each basic graphic according to the initial primitive type;
and the drawing module is used for drawing the line elements corresponding to each basic graph according to the target vertex index data corresponding to each basic graph and the drawing sequence when the rendering task of the line frame mode is executed, so as to obtain the line diagram of the to-be-drawn line elements.
8. The apparatus of claim 7, wherein the line element is a non-closed line segment; the apparatus further comprises: adding a module;
the adding module is configured to determine, in the original vertex index data of the primitive to be drawn, target vertex index data corresponding to each basic graph and a drawing order according to the initial primitive type, and then add first vertex index data at the end of the target vertex index data corresponding to each basic graph, where the first vertex index data is a first vertex in the target vertex index data corresponding to each basic graph.
9. An electronic device comprising a processor, a memory and a program or instruction stored on the memory and executable on the processor, which when executed by the processor, implements the steps of the wireframe drawing method as claimed in any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores thereon a program or instructions which, when executed by a processor, implement the steps of the wire frame drawing method according to any one of claims 1 to 6.
CN202311441842.6A 2023-11-01 2023-11-01 Wire frame drawing method, wire frame drawing device, electronic equipment and computer readable storage medium Pending CN117392266A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311441842.6A CN117392266A (en) 2023-11-01 2023-11-01 Wire frame drawing method, wire frame drawing device, electronic equipment and computer readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311441842.6A CN117392266A (en) 2023-11-01 2023-11-01 Wire frame drawing method, wire frame drawing device, electronic equipment and computer readable storage medium

Publications (1)

Publication Number Publication Date
CN117392266A true CN117392266A (en) 2024-01-12

Family

ID=89440611

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311441842.6A Pending CN117392266A (en) 2023-11-01 2023-11-01 Wire frame drawing method, wire frame drawing device, electronic equipment and computer readable storage medium

Country Status (1)

Country Link
CN (1) CN117392266A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117744187A (en) * 2024-02-20 2024-03-22 广州中望龙腾软件股份有限公司 CAD drawing method, device, computer equipment and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117744187A (en) * 2024-02-20 2024-03-22 广州中望龙腾软件股份有限公司 CAD drawing method, device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
CN117392266A (en) Wire frame drawing method, wire frame drawing device, electronic equipment and computer readable storage medium
CN111583379B (en) Virtual model rendering method and device, storage medium and electronic equipment
WO2022095526A1 (en) Graphics engine and graphics processing method applicable to player
EP3050605B1 (en) A method for event detection in real-time graphic applications
WO2023197762A1 (en) Image rendering method and apparatus, electronic device, computer-readable storage medium, and computer program product
CN113313802A (en) Image rendering method, device and equipment and storage medium
EP4290464A1 (en) Image rendering method and apparatus, and electronic device and storage medium
US20120218261A1 (en) Graphic system comprising a fragment graphic module and relative rendering method
CN111798361A (en) Rendering method, rendering device, electronic equipment and computer-readable storage medium
CN109598672B (en) Map road rendering method and device
CN112184538B (en) Image acceleration method, related device, equipment and storage medium
US20160379334A1 (en) Graphics processing unit and associate graphics processing method
US20230343021A1 (en) Visible element determination method and apparatus, storage medium, and electronic device
EP4270321A1 (en) Graphic rendering method and apparatus, and storage medium
US20220164991A1 (en) Image processing method and apparatus, storage medium, and electronic device
US20230377265A1 (en) Systems for Efficiently Rendering Vector Objects
EP4231243A1 (en) Data storage management method, object rendering method, and device
CN115861510A (en) Object rendering method, device, electronic equipment, storage medium and program product
CN111111154B (en) Modeling method and device for virtual game object, processor and electronic device
CN111402348B (en) Lighting effect forming method and device and rendering engine
CN109767379B (en) Data normalization processing method and device, storage medium and electronic equipment
CN108845961B (en) Method and device for creating vertex buffer area and readable storage medium
CN113256764A (en) Rasterization device and method and computer storage medium
US9437042B1 (en) System, method, and computer program product for performing dicing on a primitive
US20240135624A1 (en) Graphics rendering method and apparatus, and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination