US9123151B2 - Exchanging data between vertex shaders and fragment shaders on a graphics processing unit - Google Patents
Exchanging data between vertex shaders and fragment shaders on a graphics processing unit Download PDFInfo
- Publication number
- US9123151B2 US9123151B2 US12/185,998 US18599808A US9123151B2 US 9123151 B2 US9123151 B2 US 9123151B2 US 18599808 A US18599808 A US 18599808A US 9123151 B2 US9123151 B2 US 9123151B2
- Authority
- US
- United States
- Prior art keywords
- vertex
- shader
- fragment
- fragment shader
- varying
- 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.)
- Active, expires
Links
- 239000012634 fragment Substances 0.000 title claims abstract description 72
- 238000012545 processing Methods 0.000 title claims abstract description 8
- 238000000034 method Methods 0.000 claims description 5
- 238000004040 coloring Methods 0.000 claims description 3
- 230000006870 function Effects 0.000 abstract description 4
- 238000004590 computer program Methods 0.000 description 8
- 238000010586 diagram Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 230000037303 wrinkles Effects 0.000 description 2
- 239000000969 carrier Substances 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 238000005457 optimization Methods 0.000 description 1
- 230000001151 other effect Effects 0.000 description 1
- 238000007781 pre-processing Methods 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 238000012546 transfer Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T15/00—3D [Three Dimensional] image rendering
- G06T15/005—General purpose rendering architectures
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T1/00—General purpose image data processing
- G06T1/60—Memory management
Definitions
- a three-dimensional object typically is defined by a mesh, which is defined as a set of vertices and edges among those vertices.
- the set of edges and vertices define faces, where each face typically is a triangle, but may in some cases be some other polygon, or even nonplanar.
- GLSL OpenGL Shader Language
- a vertex shader is written to run on a vertex processor in an OpenGL pipeline.
- the vertex processor is a programmable unit that operates on incoming vertices and their associated data.
- the vertex processor operates on one vertex at a time. It does not replace graphics operations that require knowledge of several vertices at a time.
- a fragment shader is written to run on a fragment processor in an OpenGL pipeline.
- the fragment processor is a programmable unit that operates on fragment values and their associated data. A fragment shader cannot change a fragment's x/y position. Access to neighboring fragments is not allowed.
- the values computed by the fragment shader are ultimately used to update frame-buffer memory or texture memory, depending on the current OpenGL state and the OpenGL command that caused the fragments to be generated.
- a kind of variable in GLSL, a kind of variable, called a “varying,” provides the interface between the vertex shaders and the fragment shaders.
- Vertex shaders compute values per vertex and write them to variables declared with the varying qualifier.
- varying variables are set per vertex and are interpolated in a perspective-correct manner over the primitive being rendered.
- a fragment shader may read from varying variables and the value read will be the interpolated value, as a function of the fragment's position within the primitive. For example, if each vertex of a triangle has a different color associated with it, then the fragment shader, when applied to a fragment of that triangle, would receive an interpolated color value, based on the position of that fragment within the triangle.
- a fragment shader may have access to non-interpolated values for each vertex of the primitive in which the fragment is located.
- a fragment shader may use the distortion of the primitive with respect to an original state of the primitive as part of the function the fragment shader performs. Due to the specification of fragment shaders and vertex shaders, fragments shaders receive only interpolated values, and thus cannot receive non-interpolated values of, for example, the coordinates in three-dimensional space of each vertex.
- one solution to this problem would be to modify the processing engine for the shader language, and the shader specifications themselves, so that a fragment shader can receive non-interpolated values from the vertices of the primitive on which the fragment is located. Desirable values to receive would be at least the vertex coordinates.
- Another solution is to specify and use varyings in a manner that pass data to a fragment shader that permit the fragment shader to reconstruct the non-interpolated values.
- One way to achieve this is to a. allocate varyings and assign them indices, b. assign indices to the vertices and c. have each a shader contribute only to those varyings having the same index as the vertex being processed, and otherwise contribute a null value, such as 0, to the varyings with other indices.
- the indexed varying contains the contribution of only one vertex, scaled by an interpolation parameter.
- Another indexed varying can be used to pass the interpolation parameter, allowing the original value for the vertex to be computed by the fragment shader.
- FIG. 1 is data flow diagram illustrating a GPU programmed using a vertex shader and a fragment shader.
- FIG. 2 is an illustration of how values associated with vertices are interpolated.
- FIG. 3 is a flow chart describing an example implementation of reconstructing of vertex values in a GPU.
- FIG. 1 shows a GPU 100 on which a vertex shader 102 and a fragment shader 104 are executed.
- Information produced by the vertex shader 102 includes, but is not limited to, varyings 106 .
- a kind of variable provides the interface between the vertex shaders and the fragment shaders.
- Vertex shaders compute values per vertex and write them to variables declared with the varying qualifier.
- varying variables are set per vertex and are interpolated in a perspective-correct manner over the primitive being rendered.
- a primitive shown as a triangle in this example
- v 1 , v 2 and v 3 a vertex v 1 has an associated attribute a 1
- vertex v 2 has an associated attribute a 2
- vertex v 3 has an associated attribute a 3
- the fragment shader when operating on a location v on the primitive, will receive the interpolated value a at that location.
- One solution to this problem would be to modify the processing engine for the shader language, and the shader specifications themselves, so that a fragment shader can receive non-interpolated values from the vertices of the primitive on which the fragment is located. Desirable values to receive would be at least the vertex coordinates.
- varyings are allocated and indices are assigned to them. For example, instead of allocating a varying A, three varyings are allocated and assigned indices, namely A 1 , A 2 an A 3 . Second, indices are assigned to the vertices. In this example, as shown in FIG. 2 , the vertices are V 1 , V 2 and V 3 , with the indices being 1 , 2 and 3 respectively.
- the vertex shader when a vertex shader computes its values for V 1 , V 2 and V 3 , the vertex shader contributes only to those varyings having the same index as the vertex being processed, and otherwise contributes a null value, such as 0, to the varying with other indices.
- the indexed varying contains the contribution of only one vertex, scaled by an interpolation parameter.
- Another indexed varying can be used to pass the interpolation parameter, allowing the original value for the vertex to be computed by the fragment shader.
- the indexed varying contains the value of “1”, scaled by an interpolation parameter for that vertex, which is thus the interpolation parameter used to produce the values of the varying provided to a fragment shader.
- the original value for A for each of the vertices can be determined by computing A 1 /B 1 , A 2 /B 2 and A 3 /B 3 .
- the original coordinates for each vertex can be computed by the fragment shader by defining varyings for each coordinate value in this manner.
- FIG. 3 is a flowchart describing an example implementation of the processing performed to enable such reconstruction of values by a fragment shader.
- the mesh that is going to be processed by the vertex and fragment shaders is indexed ( 300 ). That is, an index is assigned to each vertex. However, for each primitive, i.e., face in the mesh, each vertex has a unique index. In other words, no two vertices in the same primitive have the same index. Thus, for example, referring to FIG. 2 , if there were another triangle having, as one of its edges, the edge between V 1 and V 3 , its other vertex would have the index V 2 . However, in a complex mesh, it generally is not possible to meet this constraint.
- the vertex In order to meet the constraint in an indexing algorithm, if a vertex that is part of two primitives cannot be labeled uniquely in both primitives, then the vertex is divided into two vertices (having the same coordinates). But, one vertex is placed in one primitive, and the other vertex is placed in the other primitive.
- indexing is described in “Efficiently Four-Coloring Planar Graphs”, by N. Robertson D. Sanders, P. Seymour and R. Thomas, in Proc. Of the 28 th Annual ACM Symp. On Theory of computing , pp. 571-575, 1996.
- Using four indices reduces the likelihood that a vertex would need to be split, thus reducing the amount of memory used to represent the mesh.
- one of the resulting four varyings received by the fragment shader will be not valid, i.e., the one that is zero and for which the barycentric coordinate value is zero.
- Each vertex shader is designed so as to provide the varyings for the barycentric coordinates as described above. Accordingly, when a vertex shader executes, it defines ( 302 ) the varyings for these barycentric coordinates for each vertex.
- a vertex shader also is designed so as to provide the varyings for the variables which the fragment shader will reconstruct, in the manner described above. Accordingly, when a vertex shader executes, it defines ( 304 ) the varyings for these desired variables for each vertex. Particularly useful variables are variables representing the vertex coordinates.
- the vertex shader executes on a vertex, it fills ( 305 ) the varyings based on the vertex index with the original data.
- the other varyings are filled with zero.
- the fragment shader receives, as it processes a current location, or fragment, on a primitive, the interpolating varyings representing the barycentric coordinates and the desired values, and processes them 306 to reconstruct the original values.
- the fragment shader then can utilize 308 these values.
- a fragment shader could use the vertex coordinates of a rest pose and a current pose on a primitive to determine an estimate of stress, which in turn could be used to apply wrinkle or skin coloration effects, as described in U.S. Patent Application entitled “Producing Wrinkles and Other Effects for a Computer-Generated Character Based on Surface Stress,” by Ian Stewart, and filed on even date herewith.
- a memory usage optimization can be implemented when the vertices are indexed using a four-color algorithm. As noted above, one in four of each of the varyings defined in this manner would be invalid, i.e., zero and not used. All of the values from the varyings can be grouped together by index and then placed in a texture. The offset of these values for a given index can then be passed to the fragment shader along with the texture. The invalid values may be placed in the texture, but then are simply ignored by virtue of using the offsets to access the values.
- the texture is generated by the application that uses the vertex shader and fragment shader.
- the techniques described above also can be implemented in digital electronic circuitry, or in computer hardware, firmware, software, or in combinations of them.
- the techniques can be implemented as a computer program product, i.e., a computer program tangibly embodied in a tangible information carrier, e.g., in a machine-readable storage device, for execution by, or to control the operation of, data processing apparatus, e.g., a programmable processor, a computer, or multiple computers.
- a computer program can be written in any form of programming language, including compiled or interpreted languages, and it can be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
- a computer program can be deployed to be executed on one computer or on multiple computers at one site or distributed across multiple sites and interconnected by a communication network.
- Each computer may implemented using one or more programmable processors executing a computer program to perform functions described herein by operating on input data and generating output, or using special purpose logic circuitry, e.g., an FPGA (field programmable gate array) or an ASIC (application-specific integrated circuit).
- special purpose logic circuitry e.g., an FPGA (field programmable gate array) or an ASIC (application-specific integrated circuit).
- processors suitable for the execution of a computer program include, by way of example, both general and special purpose microprocessors, and any one or more processors of any kind of digital computer.
- a processor will receive instructions and data from a read-only memory or a random access memory or both.
- the computer includes a processor for executing instructions and one or more memory devices for storing instructions and data.
- a computer will also include, or be operatively coupled to receive data from or transfer data to, or both, one or more mass storage devices for storing data, e.g., magnetic, magneto-optical disks, or optical disks.
- Information carriers suitable for embodying computer program instructions and data include all forms of non-volatile memory, including by way of example semiconductor memory devices, e.g., EPROM, EEPROM, and flash memory devices; magnetic disks, e.g., internal hard disks or removable disks; magneto-optical disks; and CD-ROM and DVD-ROM disks.
- semiconductor memory devices e.g., EPROM, EEPROM, and flash memory devices
- magnetic disks e.g., internal hard disks or removable disks
- magneto-optical disks e.g., CD-ROM and DVD-ROM disks.
- the processor and the memory can be supplemented by, or incorporated in special purpose logic circuitry.
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Computer Graphics (AREA)
- Image Generation (AREA)
Abstract
Description
Claims (6)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US12/185,998 US9123151B2 (en) | 2008-08-05 | 2008-08-05 | Exchanging data between vertex shaders and fragment shaders on a graphics processing unit |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US12/185,998 US9123151B2 (en) | 2008-08-05 | 2008-08-05 | Exchanging data between vertex shaders and fragment shaders on a graphics processing unit |
Publications (2)
Publication Number | Publication Date |
---|---|
US20100033483A1 US20100033483A1 (en) | 2010-02-11 |
US9123151B2 true US9123151B2 (en) | 2015-09-01 |
Family
ID=41652481
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
US12/185,998 Active 2034-06-11 US9123151B2 (en) | 2008-08-05 | 2008-08-05 | Exchanging data between vertex shaders and fragment shaders on a graphics processing unit |
Country Status (1)
Country | Link |
---|---|
US (1) | US9123151B2 (en) |
Families Citing this family (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10096079B2 (en) * | 2013-06-10 | 2018-10-09 | Sony Interactive Entertainment Inc. | Fragment shaders perform vertex shader computations |
KR20160074154A (en) * | 2014-12-18 | 2016-06-28 | 삼성전자주식회사 | Compiler |
US9786098B2 (en) * | 2015-07-06 | 2017-10-10 | Mediatek Inc. | Apparatus for performing tessellation operation and methods utilizing the same |
CN110648385B (en) * | 2018-06-27 | 2024-10-18 | 北京京东尚科信息技术有限公司 | Triangular surface picking method, triangular surface picking device, electronic equipment and computer readable medium |
CN111831273B (en) * | 2019-04-30 | 2022-10-28 | 厦门雅基软件有限公司 | Data processing method and device based on shader and electronic equipment |
US20240404167A1 (en) * | 2023-06-02 | 2024-12-05 | Advanced Micro Devices, Inc. | Scalable graphics processing using dynamic shader engine allocation |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080180440A1 (en) * | 2006-12-08 | 2008-07-31 | Martin Stich | Computer Graphics Shadow Volumes Using Hierarchical Occlusion Culling |
US20090033672A1 (en) * | 2007-07-30 | 2009-02-05 | Guofang Jiao | Scheme for varying packing and linking in graphics systems |
US20090295804A1 (en) * | 2008-05-30 | 2009-12-03 | Advanced Micro Devices Inc. | Merged Shader for Primitive Amplification |
-
2008
- 2008-08-05 US US12/185,998 patent/US9123151B2/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080180440A1 (en) * | 2006-12-08 | 2008-07-31 | Martin Stich | Computer Graphics Shadow Volumes Using Hierarchical Occlusion Culling |
US20090033672A1 (en) * | 2007-07-30 | 2009-02-05 | Guofang Jiao | Scheme for varying packing and linking in graphics systems |
US20090295804A1 (en) * | 2008-05-30 | 2009-12-03 | Advanced Micro Devices Inc. | Merged Shader for Primitive Amplification |
Non-Patent Citations (1)
Title |
---|
N. Robertson D. Sanders, P. Seymour and R. Thomas, "Efficiently Four-Coloring Planar Graphs", 1996, in Proc. Of the 28th Annual ACM Symp. On Theory of computing, pp. 571-575. * |
Also Published As
Publication number | Publication date |
---|---|
US20100033483A1 (en) | 2010-02-11 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US11830143B2 (en) | Tessellation method using recursive sub-division of triangles | |
Loop et al. | Real-time GPU rendering of piecewise algebraic surfaces | |
US8786606B2 (en) | Point containment for quadratic Bèzier strokes | |
US7142215B1 (en) | Method and apparatus for processing stencil data using a programmable graphics processor | |
US8289323B2 (en) | Drawing processing apparatus, texture processing apparatus, and tessellation method | |
Panozzo et al. | Weighted averages on surfaces | |
US9530241B2 (en) | Clipping of graphics primitives | |
US8698802B2 (en) | Hermite gregory patch for watertight tessellation | |
US9123151B2 (en) | Exchanging data between vertex shaders and fragment shaders on a graphics processing unit | |
KR102598915B1 (en) | Graphics processing | |
EP3803777B1 (en) | Compiler-assisted techniques for memory use reduction in graphics pipeline | |
GB2504815A (en) | A graphics processing unit and method for performing tessellation operations | |
US10134171B2 (en) | Graphics processing systems | |
US8558833B1 (en) | System and method for symmetric parameterization of independently tessellated patches | |
US20060022990A1 (en) | Generating subdivision surfaces on a graphics hardware with floating-point fragment shaders | |
US20230039364A1 (en) | Image processing using filtering function covariance | |
Safko | Tessellation of trimmed NURBS surfaces. | |
Loop | Hardware Subdivision and Tessellation of Catmull-Clark Surfaces | |
Hemingway | GPU-Based NURBS Geometry Evaluation and Rendering. | |
Hahmann et al. | Hierarchical modeling with parametric surfaces |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
AS | Assignment |
Owner name: AVID TECHNOLOGY, INC.,MASSACHUSETTS Free format text: ASSIGNMENT OF ASSIGNORS INTEREST;ASSIGNORS:STEWART, IAN;LAFLAMME, DOMINIC;CABOT, ERIC;REEL/FRAME:021555/0732 Effective date: 20080916 Owner name: AVID TECHNOLOGY, INC., MASSACHUSETTS Free format text: ASSIGNMENT OF ASSIGNORS INTEREST;ASSIGNORS:STEWART, IAN;LAFLAMME, DOMINIC;CABOT, ERIC;REEL/FRAME:021555/0732 Effective date: 20080916 |
|
AS | Assignment |
Owner name: AUTODESK, INC.,CALIFORNIA Free format text: ASSIGNMENT OF ASSIGNORS INTEREST;ASSIGNOR:AVID TECHNOLOGY, INC.;REEL/FRAME:021962/0974 Effective date: 20081117 Owner name: AUTODESK, INC., CALIFORNIA Free format text: ASSIGNMENT OF ASSIGNORS INTEREST;ASSIGNOR:AVID TECHNOLOGY, INC.;REEL/FRAME:021962/0974 Effective date: 20081117 |
|
STCF | Information on status: patent grant |
Free format text: PATENTED CASE |
|
MAFP | Maintenance fee payment |
Free format text: PAYMENT OF MAINTENANCE FEE, 4TH YEAR, LARGE ENTITY (ORIGINAL EVENT CODE: M1551); ENTITY STATUS OF PATENT OWNER: LARGE ENTITY Year of fee payment: 4 |
|
MAFP | Maintenance fee payment |
Free format text: PAYMENT OF MAINTENANCE FEE, 8TH YEAR, LARGE ENTITY (ORIGINAL EVENT CODE: M1552); ENTITY STATUS OF PATENT OWNER: LARGE ENTITY Year of fee payment: 8 |