Depth Buffer Prepass
The depth buffer pre-pass technique optimizes graphics rendering by determining visible primitives first, reducing unnecessary shading of hidden primitives, thus improving efficiency in graphics processing systems.
Patent Information
- Application Number
- JP2023515324
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2020-09-24
- Filing Date
- 2021-09-23
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2041-09-23
AI Technical Summary
Existing graphics rendering techniques face inefficiencies when dealing with occlusion issues, particularly in scenarios where multiple primitives overlap, leading to excessive pixel shading of hidden primitives.
Implementing a depth buffer pre-pass technique that renders only the depth portion of the virtual scene to determine visible and hidden primitives, followed by a color pass that skips shading for hidden primitives, thereby optimizing rendering efficiency.
This approach significantly reduces the computational load by avoiding pixel shading for hidden primitives, enhancing rendering performance and efficiency, especially in applications with a high percentage of overlapping primitives.
Smart Images

Figure 0007554915000007 
Figure 0007554915000002 
Figure 0007554915000013
Abstract
Description
[Background technology]
[0001] Description of Related Art Graphics processors are often used within computer graphics processing systems to generate computer-generated images from geometric models. The geometric models define the various objects, details, light sources, and other elements of a virtual scene. The computing system determines how to render a given scene based on the geometric models and other inputs from software applications. These inputs include graphical objects such as points, lines, polygons, three-dimensional solids, and other objects. These objects may be more generally referred to as "primitives."
[0002] A graphics processing unit (GPU) or other type of processor processes inputs and a geometric model to generate a two- or three-dimensional array of color values for pixels that represent a desired image or video frame. Each pixel in a frame has multiple attributes associated with it, including color and texture. Typically, a shader is used to perform arithmetic and logical operations on the attributes of each pixel to arrive at a final value that represents the pixel. The final values are placed into a frame buffer and used when the pixel is sent to a display device.
[0003] When multiple primitives are rendered and projected onto the same pixel on the screen, the rendering engine needs to determine which primitives are visible and which are hidden. One technique for solving occlusion issues involves a pixel shader performing a depth test using a depth buffer. For each pixel on the screen, the distance from the eye to the nearest object is stored in the depth buffer. A depth test is performed to determine whether the rendered primitive is closer to the screen (i.e., the eye) than the nearest previously rendered primitive when the primitive is projected onto a given pixel in screen space. If the primitive is closer to the eye than the previously rendered primitive, the primitive passes the test. Otherwise, if the primitive is farther away from the eye than the previously rendered primitive, the primitive fails the test. The eye is defined by a virtual camera that represents the user's eye-point or perspective.
[0004] In a first technique, the application assigns a value of 1.0 to distances far from the viewpoint and a value of 0.0 to locations at or very close to the viewpoint. In the first technique, when a new primitive is rendered, the primitive's depth value is compared to the current value in the depth buffer for each pixel covered by the primitive. If the primitive's depth value is less than the current value in the depth buffer for the given pixel, the primitive passes the test and the primitive's depth value is written to the depth buffer for the given pixel. Otherwise, if the primitive's depth value is greater than the current value in the depth buffer for the given pixel, the primitive fails the test and the depth buffer value remains the same. In a second technique, the application assigns a value of 0.0 to distances far from the viewpoint and a value of 1.0 to locations at or very close to the viewpoint. In the second technique, the determination of what constitutes a pass or fail result is reversed compared to the first technique. Other approaches may use ranges other than 0.0 to 1.0 and assign other values to distances far from the viewpoint and distances close to the viewpoint.
[0005] The advantages of the methods and mechanisms described herein may be better understood by referring to the following description in conjunction with the accompanying drawings. [Brief description of the drawings]
[0006] [Figure 1] FIG. 1 is a block diagram of one embodiment of a computing system. [Diagram 2] FIG. 2 is a logical block diagram of another embodiment of a system for rendering graphics. [Diagram 3] FIG. 1 is a block diagram of one embodiment of a computing system. [Figure 4] FIG. 13 illustrates an example of pseudocode for performing a depth buffer pre-pass. [Diagram 5]FIG. 2 is a generalized flow diagram illustrating one embodiment of a method for performing a depth buffer pre-pass. [Figure 6] FIG. 1 is a generalized flow diagram illustrating one embodiment of a method for performing separate portions of work for each tile in different passes through a shader pipeline. [Figure 7] FIG. 1 is a generalized flow diagram illustrating one embodiment of a method for determining which primitives to send through a depth pre-pass. [Figure 8] FIG. 1 is a generalized flow diagram illustrating one embodiment of a method for changing a depth test function between passes. [Figure 9] FIG. 1 is a generalized flow diagram illustrating one embodiment of a method for changing a depth test function between passes. [Figure 10] FIG. 1 is a generalized flow diagram illustrating one embodiment of a method for performing a depth prepass. [Figure 11] FIG. 2 is a generalized flow diagram illustrating one embodiment of a method for performing a color pass. [Figure 12] FIG. 1 is a generalized flow diagram illustrating one embodiment of a method for modifying the depth function used by the color pass depth test. [Figure 13] FIG. 1 is a generalized flow diagram illustrating one embodiment of a method for selecting primitives for processing by a depth prepass. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0007] In the following description, numerous specific details are described to provide a thorough understanding of the methods and mechanisms presented herein. However, those skilled in the art should appreciate that various embodiments may be practiced without these specific details. In some instances, well-known structures, components, signals, computer program instructions and techniques are not shown in detail to avoid obscuring the approaches described herein. It will be understood that for simplicity and clarity of illustration, elements shown in the figures are not necessarily drawn to scale. For example, the dimensions of some elements may be exaggerated relative to other elements.
[0008] Various systems, devices, and methods for implementing a depth buffer pre-pass are disclosed herein. A processor executes an application to render a virtual scene. In one embodiment, an application executing on the processor causes a depth pre-pass to be performed before a pixel shader is invoked. During the depth pre-pass, only the depth portion of the virtual scene is rendered to determine which primitives are visible and which are hidden. The scene is then redrawn, but the hidden primitives are not sent to the pixel shader. In cases where a relatively large percentage of primitives overlap, this technique increases the efficiency of the rendering application, since pixel shading can be avoided for the hidden primitives.
[0009] In one embodiment, the above techniques are employed in conjunction with binning, where only a small region of the screen is drawn at a time. In one embodiment, the system includes a batch binner, where a certain number of primitives are accumulated and then small portions (i.e., tiles) of the screen are rendered. In one embodiment, the primitives for a batch are stored in a cache to reduce the access latency involved in fetching the primitives. In one embodiment, the number of primitives in a batch is determined based on the size of the cache. In this embodiment, the cache is sized according to the color and / or depth surfaces being rendered.
[0010] In one embodiment, a given frame of a virtual scene is divided into tiles, and the scene is rendered tile by tile. Each tile (i.e., bin) contains any number of primitives, and primitives can span multiple tiles, and these primitives can be reproduced multiple times. While the system is processing a tile, the depth portion of each primitive in the tile is rendered first, and then the tile is processed again for color information associated with each primitive that passes a pre-pass depth test. During the color pass, pixel shaders shade pixels to represent the virtual scene. The pixels can then be provided to a display controller to be sent to a display. This process can be repeated for each frame of a video game, movie, or other application.
[0011] 1, a block diagram of one embodiment of a computing system 100 is shown. In one embodiment, computing system 100 includes at least processors 105A-105N, an input / output (I / O) interface 120, a bus 125, a memory controller 130, a network interface 135, a memory device 140, a display controller 150, and a display 155. In other embodiments, computing system 100 includes other components and / or is configured in a different manner. Processors 105A-105N represent any number of processors included in system 100.
[0012] In one embodiment, processor 105A is a general-purpose processor, such as a central processing unit (CPU). In this embodiment, processor 105A executes driver 110 (e.g., a graphics driver) for communicating with and / or controlling the operation of one or more of the other processors in system 100. It should be noted that, depending on the embodiment, driver 110 can be implemented using any suitable combination of hardware, software, and / or firmware. In one embodiment, processor 105N is a data parallel processor having a highly parallel architecture. Data parallel processors include graphics processing units (GPUs), digital signal processors (DSPs), field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), and the like. In some embodiments, processors 105A-105N include multiple data parallel processors. In one embodiment, processor 105N is a GPU that provides pixels to display controller 150 to be sent to display 155.
[0013] The memory controller 130 represents any number and type of memory controller accessible by the processors 105A-105N. Although the memory controller 130 is shown as separate from the processors 105A-105N, it should be understood that this represents just one possible embodiment. In other embodiments, the memory controller 130 may be embedded within one or more of the processors 105A-105N and / or the memory controller 130 may be located on the same semiconductor die as one or more of the processors 105A-105N. The memory controller 130 is coupled to any number and type of memory devices 140. The memory devices 140 represent any number and type of memory devices. For example, types of memory in the memory devices 140 may include Dynamic Random Access Memory (DRAM), Static Random Access Memory (SRAM), NAND flash memory, NOR flash memory, Ferroelectric Random Access Memory (FeRAM), etc.
[0014] I / O interface 120 represents any number and type of I / O interfaces (e.g., peripheral component interconnect (PCI) bus, PCI-Extended (PCI-X), PCI Express (PCIE) bus, gigabit Ethernet (GBE) bus, universal serial bus (USB)). Various types of peripheral devices (not shown) are coupled to I / O interface 120. Such peripheral devices include, but are not limited to, displays, keyboards, mice, printers, scanners, joysticks, other types of game controllers, media recording devices, external storage devices, network interface cards, and the like. Network interface 135 can receive and transmit network messages over a network.
[0015] In various embodiments, computing system 100 is a computer, a laptop, a mobile device, a game console, a server, a streaming device, a wearable device, or any of a variety of other types of computing systems or devices. It should be noted that the number of components of computing system 100 varies from embodiment to embodiment. For example, in other embodiments, there are more or fewer components than those shown in FIG. 1. It should also be noted that in other embodiments, computing system 100 includes other components not shown in FIG. 1. Additionally, in other embodiments, computing system 100 is constructed in a manner other than that shown in FIG. 1.
[0016] Referring to FIG. 2, a logical block diagram of one embodiment of a system 200 for rendering graphics is shown. In one embodiment, the system 200 includes components such as a processing element 202, an application 205, and a memory 225. The processing element 202 includes at least shaders 210A-210N and a control unit 220. The shaders 210A-210N represent any number and types of shaders (e.g., geometry shaders, light shaders, pixel shaders). The processing element 202 includes one or more CPUs, GPUs, FPGAs, ASICs, DSPs, and / or other processing resources. It should be noted that the system 200 may also include any number and types of other components, which may vary from implementation to implementation. In one embodiment, the application 205 is a graphics application for rendering pixels to represent scenes of a video game, movie, or other application. In one embodiment, the application 205 includes program instructions stored in the memory 225 and executed on the processing element 202. The application 205 may run on a general purpose processor or on fixed hardware such as an FPGA or ASIC. Similarly, the shaders 210A-210N may be implemented using any suitable combination of software and / or hardware.
[0017] In various embodiments, the shaders 210A-210N include geometry shaders that generate depth values for scene geometry of a given scene projected onto a projection surface. During a depth buffer pre-pass, geometry for a primitive 217 is generated and a depth buffer test is performed on the primitive 217 using the depth buffer 240. In one embodiment, the primitive 217 corresponds to a single tile of a screen. In this embodiment, the application 205 renders a frame tile by tile. During a depth buffer pre-pass, a primitive is rasterized into pixel samples (i.e., fragments), the visible pixel samples are identified, and corresponding indicators are stored in the pre-pass buffer 235. As used herein, a "pixel sample" is defined as the data required to generate a portion of a primitive, the portion being projected onto a single pixel in screen space. It should be noted that the terms "pixel sample," "sample," and "fragment" may be used interchangeably herein.
[0018] After the depth buffer pre-pass, a color pass is performed on the visible pixel samples to render the color values of the pixel samples. The color values are then stored in a color buffer 245. Hidden pixel samples are not rendered in the color pass, which helps to reduce the amount of work performed by the pixel shader. The pixel shader generates the color and additional appearance attributes that are applied to each pixel of the rendered object. Finally, the shaded pixels are written to a frame buffer 250 to be sent to a display (e.g., display 155 of FIG. 1).
[0019] 3, a block diagram of one embodiment of a computing system 300 is shown. In one embodiment, the computing system 300 includes at least a geometry buffer 305, a control unit 310, a pre-pass buffer 315, and a shader pipeline 320. The control unit 310 may be implemented using any suitable combination of software and / or hardware. It should be noted that the control unit 310 may also be referred to as control logic 310. The computing system 300 may include any number of other components (e.g., memory devices, frame buffers, displays) that are not shown to avoid obscuring the figure.
[0020] In one embodiment, the control unit 310 causes pixels of the geometry buffer 305 to be processed by the shader pipeline 320 in a depth buffer pre-pass. The depth buffer pre-pass may be sparse (i.e., selected primitives are tested and written) or the depth buffer pre-pass may be full (i.e., all primitives are tested and written). During the depth buffer pre-pass, visible pixel samples are identified and this information is recorded in the pre-pass buffer 315. For example, in one embodiment, each pixel sample covered by a primitive has a corresponding indicator in the pre-pass buffer 315. In this embodiment, if a primitive is visible at a given pixel location, the indicator corresponding to the given pixel location is set to a first value (e.g., 1) during the depth buffer pre-pass. It should be noted that a primitive may be processed pixel sample by pixel sample, and each pixel sample may be processed individually.
[0021] After the depth buffer pre-pass, a color pass is invoked on the rendered primitive through the shader pipeline 320. If a full depth buffer pre-pass is performed, the color pass is skipped for a given pixel sample of a primitive being processed by the color pass if the corresponding indicator in the pre-pass buffer 315 is set to a second value (e.g., 0) for the given pixel sample. This makes the color pass more efficient since fewer pixel samples are processed during the color pass. If a sparse depth buffer pre-pass is performed, and the given primitive was not processed during the sparse depth buffer pre-pass, all pixel samples of the given primitive are processed during the color pass, regardless of the value of the corresponding indicator in the pre-pass buffer 315.
[0022] If a full depth buffer pre-pass is performed, each visible pixel sample has a bit set in the pre-pass buffer 315. After the full depth buffer pre-pass, the depth buffer contains the final depth values such that the EQUAL depth function is true for the visible samples. In this case, if the depth function is LESS or GREATER, the depth function will be changed for the visible samples (i.e., samples that have a corresponding indicator set in the pre-pass buffer 315). In this case, the LESS depth function is changed to LESS_OR_EQUAL and the GREATER depth function is changed to GREATER_OR_EQUAL. In one embodiment, the rendered pixel sample consumes the pre-pass indicator. This means that only one primitive is rendered per pixel sample when the less-than or greater-than depth function is used. However, for primitives that already have a less-than-equal or greater-than-equal depth function, there may be multiple primitives rendered at the same depth. If multiple primitives are rendered at the same depth, the last primitive rendered remains visible.
[0023] When a sparse depth buffer prepass is performed, the depth buffer is not in its final state at the start of the color pass. Any primitives that were not processed during the sparse depth buffer prepass cannot have their visibility determined based solely on the prepass buffer content. Rather, pixel samples of primitives that were not processed during the sparse depth buffer prepass will not be skipped if the corresponding prepass buffer value is a second value (e.g., 0). Also, in one embodiment, the depth buffer is updated during the color pass for visible pixel samples of primitives that were not processed during the sparse depth buffer prepass.
[0024] The shader pipeline 320 includes any number of shader units 325A-325N, from 1 to N, where N is a positive integer greater than 1. Note that the shader units 325A-325N may also be referred to as shader stages 325A-325N. The shader units 325A-325N may include any number and types of shaders, such as vertex shaders, light shaders, rasterizer stages, pixel shaders, geometry shaders, fragment shaders, compute shaders, etc. In one embodiment, the output of the color pass through the shader pipeline 320 includes a number of pixels representing the scene. The output of the second pass may undergo further processing, may be stored, and / or may be sent to a display.
[0025] Referring to FIG. 4, one embodiment of pseudocode 400 for performing a depth buffer pre-pass is shown. For pseudocode 400, Q is a subset of primitives P selected for depth pre-pass 405. If Q includes all of primitives P, this means that a full depth pre-pass is being performed. If Q includes a subset of primitives P, this is a sparse depth pre-pass. For each primitive p in Q, each sample [x,y] is processed to determine if the depth value (i.e., z) is less than the value stored in the depth buffer (i.e., z_buffer). Note that coordinates [x,y] refer to the [x,y] pixel location in screen space. For the purposes of this description, it is assumed that a LESS THAN function is used in pseudocode 400. In another embodiment, a GREATER THAN function may be used for the depth pre-pass. In this embodiment, pseudocode similar to pseudocode 400 can be used, with corresponding changes in the steps to use a greater than function instead of a less than function.
[0026] If the depth value of a sample is less than the depth buffer value for a particular pixel location, this means that the sample is closer than any sample previously rendered for this pixel location, and the sample is visible. Thus, if the depth value of a sample is less than the depth buffer value for a given pixel location, a pre-pass indicator is set for that given pixel location. The pre-pass indicator is designated as "p_buffer[x,y]" in pseudocode 400. Also, the depth buffer is updated to store the depth value of the sample.
[0027] After the depth prepass 405 is completed for a primitive p in Q, the color pass 410 is launched. If primitive p is in Q (i.e., primitive p was included in the depth prepass 405), the prepass buffer value is "0", and the depth function is LESS THAN, then the pixel sample is optionally skipped during the color pass 410. Otherwise, for each primitive p in P and for each sample [x,y] in p, a conditional step is performed. The first part of the conditional step determines whether the depth value of the sample (i.e., pz[x,y]) is less than the depth buffer value of the pixel location (i.e., z_buffer[x,y]). The second part of the conditional step determines whether the prepass buffer indicator (i.e., p_buffer[x,y]) is set and whether the depth value of the sample is equal to the depth buffer value of the pixel location. If either the first or second part of the conditional step is true, the pixel is shaded (i.e., shade(p,x,y)), the pre-pass buffer indicator is cleared, and if p is not in Q (i.e., the primitive was not included in the depth pre-pass), the depth buffer at the pixel location is updated with the depth value of the sample. Note that pseudocode 400 is an example of pseudocode that may be executed in a particular implementation. In other embodiments, other pseudocode examples having other steps may be executed.
[0028] Note that in the case of a LESS THAN depth function, if the depth buffer prepass includes all of the primitives, any pixel sample that has its prepass buffer indicator set during the depth buffer prepass will be shaded exactly once during the color pass. Primitives that are not included in the depth buffer prepass may have these pixel samples rendered additional times during the color pass. Similarly, if a GREATER THAN depth function is used for the depth buffer prepass, and if the depth buffer prepass includes all of the primitives, any pixel sample that has its prepass buffer indicator set during the depth buffer prepass will be shaded exactly once during the color pass.
[0029] With reference to FIG. 5, one embodiment of a method 500 for performing a depth buffer pre-pass is shown. For purposes of illustration, the steps in this embodiment and in FIGS. 6-13 are shown in sequence. However, it should be noted that in various embodiments of the described method, one or more of the described elements may be performed simultaneously, in a different order than that shown, or may be omitted entirely. Other additional elements may also be performed, as desired. Any of the various systems or devices described herein may be configured to perform the method 500.
[0030] The control unit performs a first depth buffer test with a first depth function on the primitives (block 505). In one embodiment, the primitives are stored in a cache, and the primitives correspond to a given tile of the screen. In one embodiment, the first depth function is a LESS THAN comparison. In another embodiment, the first depth function is a GREATER THAN comparison. The control unit then sets an indicator for each pixel sample that passes the first depth buffer test (block 510). In other words, the control unit stores an indicator for each pixel sample of the primitive that is closer to the viewpoint than other pixel samples of other primitives that are projected onto the same screen pixel. Note that the pixel samples are not shaded as a result of the first depth buffer test.
[0031] The control unit then performs a second depth buffer test on the plurality of primitives (block 515). At block 515, for pixel samples with cleared indicators, a second depth buffer test is performed using the first depth function. For pixel samples with their indicators set, the second depth buffer test is performed using a second depth function, where the second depth function is different from the first depth function. In one embodiment, if the first depth function is GREATER THAN, then the second depth function is GREATER THAN OR EQUAL TO. In another embodiment, if the first depth function is LESS THAN, then the second depth function is LESS THAN OR EQUAL TO. The pixel shader then shades only those pixel samples that pass the second depth buffer test. The pixel shader also clears the indicators for the shaded pixels (block 520). The control unit then sends the shaded pixels to the display (block 525). After block 525, the method 500 ends.
[0032] Referring to FIG. 6, one embodiment of a method 600 for performing separate portions of work for each tile in different passes through a shader pipeline is shown. An application runs a plurality of primitives through a shader pipeline for a first portion of processing associated with rendering a given tile of a scene (block 605). In one embodiment, the first portion of processing includes a depth buffer pre-pass for rendering depth portions of the plurality of primitives. For example, in one embodiment, block 605 is implemented by executing method 1000 (of FIG. 10). During the first portion of processing, a first test is performed on pixel samples of the plurality of primitives (block 610). In one embodiment, the first test is a depth buffer test. In other embodiments, the first test may be other types of tests. The application then runs pixel samples that pass the first test through a shader pipeline for a second portion of processing associated with rendering a given tile of a scene (block 615). In one embodiment, the second portion of processing includes performing color shading of those primitives that pass the first test. For example, in one embodiment, block 615 is performed by executing method 1100 (of FIG. 11). The shader pipeline then generates shaded pixels for the given tile as a result of the second portion of the processing (block 620). If there are more tiles of the scene to render (conditional block 625, "yes"), method 600 returns to block 605. Otherwise, if all tiles of the scene have been rendered (conditional block 625, "no"), method 600 ends.
[0033] Referring to FIG. 7, one embodiment of a method 700 for determining which primitives to send through a depth buffer pre-pass is shown. A control unit receives an indication that a tile of primitives is ready to be processed (block 705). In response, the control unit determines which primitives from the tile should undergo a depth buffer pre-pass (block 710). If there is only a single layer of primitives in the tile (conditional block 715, "yes"), the control unit skips the depth buffer pre-pass for the tile (block 720). After block 720, the control unit begins a color pass through the pixel shader for the tile (block 725). After block 725, the method 700 ends.
[0034] Otherwise, if there are more than one layer of primitives in the tile (conditional branch block 715, "no"), the control unit analyzes the primitives layer by layer for primitives that are part of the same layer (block 730). In another embodiment, the control unit analyzes the primitives primitive by primitive at block 730. For each primitive, if the area of the primitive's layer is less than the threshold (conditional branch block 735, "yes"), the control unit skips the depth buffer pre-pass for the primitive (block 740). Otherwise, if the area of the primitive's layer is greater than or equal to the threshold (conditional branch block 735, "no"), the control unit sends the primitive through a depth buffer pre-pass (block 745). After blocks 740 and 745, if there are more primitives to analyze (conditional branch block 750, "yes"), the method 700 returns to conditional branch block 735. Otherwise, if there are no more primitives to analyze (conditional branch block 750, "No"), method 700 jumps to block 725. Note that in other embodiments, other conditions may be checked to determine whether to send the primitive through a depth buffer pre-pass.
[0035] Referring to FIG. 8, one embodiment of a method for changing a depth test function between passes is shown. The control unit uses a LESS THAN depth test when processing a tile during a depth buffer pre-pass (block 805). For each pixel sample covered by a primitive of the tile, if the depth of the primitive at the pixel sample location is less than the depth buffer value for that pixel location (conditional branch block 810, "yes"), the control unit sets a corresponding indicator in the pre-pass buffer and updates the depth buffer value with the depth value of the primitive at that pixel location (block 815). If the depth of the primitive at the pixel sample location is greater than or equal to the depth buffer value for that pixel location (conditional branch block 810, "no"), the control unit does not change (modify) the corresponding indicator in the pre-pass buffer (block 820). Then, after the depth buffer pre-pass is finished, the control unit starts a color pass for the primitives of the tile (block 825).
[0036] For each pixel sample covered by the primitive, the control unit determines whether the primitive has passed a depth pre-pass, whether the pre-pass buffer indicator for the sample is clear (i.e., 0), and whether the depth function for the primitive is LESS THAN (conditional branch block 830). If the primitive has passed a depth pre-pass, if the pre-pass buffer indicator for the sample is clear, and if the depth function for the primitive is LESS THAN (conditional branch block 830, "YES"), the control unit skips the color pass for the sample (block 835). Otherwise, if the primitive has not been processed by a depth pre-pass, if the pre-pass buffer indicator for the sample is set (i.e., 1), or if the depth function for the primitive is LESS THAN OR EQUAL TO (conditional branch block 830, "NO"), the control unit determines whether the depth of the primitive at the pixel location is less than the depth buffer value for that pixel location (conditional branch block 840).
[0037] If the depth of the primitive at the pixel location is less than the depth buffer value for that pixel location (conditional branch block 840, "yes"), the control unit causes the primitive at that pixel location to be shaded (block 850). Also, the pre-pass buffer indicator for that pixel location is cleared (block 855). If the primitive was not processed by a depth pre-pass (conditional branch block 860, "no"), the depth buffer value for that pixel location is updated with the depth value of the primitive at that pixel location (block 865). Otherwise, if the primitive was processed by a depth pre-pass (conditional branch block 860, "yes"), the depth buffer value remains unchanged (block 870).
[0038] If the depth of the primitive at the pixel location is greater than or equal to the depth buffer value for that pixel location (conditional branch block 840, "no"), the control unit determines whether a pre-pass buffer indicator is set for that pixel location and whether the depth value of the primitive at that pixel location is equal to the depth buffer value for that pixel location (conditional branch block 845). If the pre-pass buffer indicator is set for that pixel location and the depth value of the primitive at that pixel location is equal to the depth buffer value for that pixel location (conditional branch block 845, "yes"), the control unit causes the primitive at that pixel location to be shaded (block 850). Otherwise, if the pre-pass buffer indicator for that pixel location is cleared or the depth value for the primitive at that pixel location is greater than the depth buffer value for that pixel location (conditional branch block 845, "no"), the control unit skips the color pass for that sample (block 835).
[0039] Referring to FIG. 9, one embodiment of a method for changing a depth test function between passes is shown. The control unit uses a GREATER THAN depth test when processing a tile during a depth buffer pre-pass (block 905). For each pixel sample covered by a primitive of the tile, if the depth of the primitive at the pixel sample location is greater than the depth buffer value for that pixel location (conditional branch block 910, "yes"), the control unit sets a corresponding indicator in the pre-pass buffer and updates the depth buffer value with the depth value of the primitive at that pixel location (block 915). If the depth of the primitive at the pixel sample location is less than or equal to the depth buffer value for that pixel location (conditional branch block 910, "no"), the control unit does not change (modify) the corresponding indicator in the pre-pass buffer (block 920). Then, after the depth buffer pre-pass is finished, the control unit starts a color pass for the primitives of the tile (block 925).
[0040] For each pixel sample covered by the primitive, the control unit determines whether the primitive has passed a depth prepass, whether the prepass buffer indicator for the sample is cleared, and whether the depth function for the primitive is GREATER THAN (conditional block 930). If the primitive has passed a depth prepass, if the prepass buffer indicator for the sample is cleared, and if the depth function for the primitive is GREATER THAN (conditional block 930, "YES"), the control unit skips the color pass for the sample (block 935). Otherwise, if the primitive has not been processed by a depth prepass, if the prepass buffer indicator is set for the sample, or if the depth function for the primitive is GREATER THAN OR EQUAL TO (conditional block 930, "NO"), the control unit determines whether the depth of the primitive at the pixel location is greater than the depth buffer value for that pixel location (conditional block 940).
[0041] If the depth of the primitive at the pixel location is greater than the depth buffer value for that pixel location (conditional branch block 940, "yes"), the control unit causes the primitive to be shaded for that pixel location (block 950). Also, the pre-pass buffer indicator for that pixel location is cleared (block 955). If the primitive was not processed by a depth pre-pass (conditional branch block 960, "no"), the depth buffer value for that pixel location is updated with the depth value of the primitive at that pixel location (block 965). Otherwise, if the primitive was processed by a depth pre-pass (conditional branch block 960, "yes"), the depth buffer value remains unchanged (block 970).
[0042] If the depth of the primitive at the pixel location is less than or equal to the depth buffer value for that pixel location (conditional block 940, "no"), the control unit determines whether a pre-pass buffer indicator is set for that pixel location and whether the depth value for the primitive at that pixel location is equal to the depth buffer value for that pixel location (conditional block 945). If the pre-pass buffer indicator for that pixel location is set and the depth value for the primitive at that pixel location is equal to the depth buffer value for that pixel location (conditional block 945, "yes"), the control unit causes the primitive at that pixel location to be shaded (block 950). Otherwise, if the pre-pass buffer indicator for that pixel location is cleared or the depth value for the primitive at that pixel location is less than the depth buffer value for that pixel location (conditional block 945, "no"), the control unit skips the color pass for that sample (block 935).
[0043] Referring to FIG. 10, one embodiment of a method 1000 for performing a depth prepass is shown. A depth prepass is initiated for selected primitives in a tile (block 1005). The primitives are then provided to a rasterizer to determine which screen pixels are covered by each primitive and output a fragment for each covered pixel sample (block 1010). An early depth test is then performed for each fragment generated by the rasterizer for the selected primitive (conditional block 1015). An early depth test is performed for each fragment to determine if the fragment is visible. If a fragment of a primitive fails the early depth test (conditional block 1015, "Fail"), the depth buffer and the prepass buffer are left unchanged (block 1020). Note that samples are a factor in the depth buffer resolution. In other words, the resolution of the depth buffer is at the level of samples. It should also be noted that the terms "sample" and "fragment" may be used interchangeably herein.
[0044] Otherwise, if the fragment of the primitive passes the initial depth test (conditional block 1015, "PASS"), the depth buffer value of the corresponding pixel sample is updated and a corresponding indicator in the pre-pass buffer at the sample location is updated (block 1025). Also, shading is skipped for the fragment (block 1030). Note that each of the pre-pass buffer indicators has a corresponding depth buffer value. After block 1030, method 1000 ends.
[0045] Referring to FIG. 11, one embodiment of a method 1100 for performing a color pass is shown. The color pass is invoked for all primitives in a tile (block 1105). The primitives are then provided to a rasterizer to determine which screen pixels are covered by each primitive and output a fragment for each covered pixel sample (block 1110). The pre-pass buffer indicator is then read for each sample covered by each primitive fragment (conditional branch block 1115). If the pre-pass buffer indicator is set for a given pixel sample (conditional branch block 1115, "yes"), a modified (modified) depth function is used (block 1125). For example, if the original depth function was less than, the modified depth function becomes less than equal. Alternatively, if the original depth function was greater than, the modified depth function becomes greater than equal.
[0046] If the pre-pass buffer indicator is not set (conditional branch block 1115, "no"), the control unit optionally determines whether the primitive was included in a depth pre-pass and whether the depth function is less than or greater than (conditional branch block 1120). If the primitive was included in a depth pre-pass and the depth function is less than or greater than (conditional branch block 1120, "yes"), the depth buffer and the pre-pass buffer remain unchanged (block 1140). After block 1140, the method 1100 ends for the given sample. If the primitive was not included in a depth pre-pass or the depth function is less than or equal to or greater than or equal to (conditional branch block 1120, "no"), the original depth function is used (block 1130). Note that conditional branch block 1120 is optional and does not need to be executed. If conditional branch block 1120 has not been performed, the method 1100 proceeds directly from the "no" leg of conditional branch block 1115 to block 1130. After block 1130, an initial depth test is performed (conditional branch block 1135).
[0047] If the fragment fails the initial depth test (conditional branch block 1135, "FAIL"), the depth buffer and the pre-pass buffer are left unchanged (block 1140). Otherwise, if the fragment passes the initial depth test (conditional branch block 1135, "PASS"), the control unit determines whether the primitive was included in the depth pre-pass (conditional branch block 1145). If the primitive was included in the depth pre-pass (conditional branch block 1145, "YES"), which means the depth values are known to be equal, the control unit clears the corresponding indicator in the pre-pass buffer at the sample location (block 1155). The control unit then proceeds to shading for the fragment (block 1160). After block 1160, the method 1100 is finished for the fragment. If the primitive was not included in the pre-pass (conditional branch block 1145, "No"), the depth buffer value is updated (block 1150) and the control unit clears the corresponding indicator in the pre-pass buffer at the sample location (block 1155). In another embodiment, conditional branch block 1145 is forced to "No" and method 1100 proceeds in this case from the "pass" leg of conditional branch block 1135 directly to block 1150. After block 1155, the control unit proceeds to shading the fragment (block 1160).
[0048] Referring to FIG. 12, one embodiment of a method 1200 for modifying a depth function used by a color path depth test is shown. The control unit performs a first depth buffer test on selected primitives of the plurality of primitives using either a less-than or greater-than depth function (block 1205). In one embodiment, the plurality of primitives are stored in a cache, and the plurality of primitives correspond to a given tile of a screen. The control unit then updates depth buffer values based on the results of the first depth buffer test (block 1210). The control unit then performs a second depth buffer test on the plurality of primitives using either a less-than or equal depth function (block 1215). For example, if the first depth buffer test used a less-than function, the second depth test uses a less-than or equal depth function. Alternatively, if the first depth buffer test used a greater-than function, the second depth test uses a greater-than or equal depth function.
[0049] The pixel shader then shades only those primitives that pass the second depth buffer test (block 1220). The control unit then sends the shaded pixels to the display (block 1225). After block 1225, the method 1200 ends. When implementing the method 1200, since a pre-pass buffer is not used, if there are multiple samples with equal depth values, all of the Z equal samples will be shaded and the last sample will be displayed. In contrast, if a pre-pass buffer is used and a pre-pass indicator is stored for the samples processed by the pre-pass, only the first Z equal samples will be shaded, as in a single pass system.
[0050] Referring to FIG. 13, an embodiment of a method 1300 for selecting primitives for processing by a depth prepass is shown. A control unit receives a sequence of primitives ready to be processed (block 1305). In one embodiment, the control unit receives only a subset of the complete set of primitives generated by the geometry processing step. In this embodiment, the primitives are pre-filtered by removing some primitives based on the face direction of the primitives. For example, in one scenario, back-facing primitives are removed. Also, in one embodiment, the primitives are pre-filtered based on the view frustum such that only those primitives within the view frustum are received by the control unit. In one embodiment, primitives that intersect the view frustum boundary are clipped to the frustum. Also, in one embodiment, the input sequence of primitives is pre-filtered based on the screen position of the primitives. For example, if processing is performed on multiple tiles simultaneously in parallel, the tiles may be distributed across multiple processing units.
[0051] Next, the control unit selects a primitive to analyze from the received sequence of primitives (block 1310). The control unit then determines whether the selected primitive forms a continuous layer with any previous input primitive (block 1315). In one embodiment, the control unit determines whether the primitive forms a continuous layer with the previous primitive by checking whether the primitive has a shared vertex. Note that in one embodiment, the vertex check does not have to use the full vertex coordinates, but each vertex can be reduced to a hash that has a smaller number of bits to check and store. If the selected primitive forms a continuous layer with the previous primitive (conditional branch block 1320, "Yes"), the control unit calculates the cumulative area of the primitive in the continuous layer (block 1325). In one embodiment, the control unit maintains a separate cumulative area sum for each separate layer of the primitive. For the first primitive selected, by default, the "Yes" leg should be selected in conditional branch block 1320, and then the control unit will calculate the area of the single primitive. If the selected primitive does not form a continuous layer with the previous primitive (conditional block 1320, "no"), the control unit sets a multi-layer flag to indicate that the tile contains multiple layers of primitives (block 1330). If the multi-layer flag was previously set, block 1330 may be skipped. Alternatively, in another embodiment, the control unit maintains a counter to track the total number of distinct layers. After (or simultaneously with) block 1330, the control unit calculates the area of the primitive (block 1335).
[0052] After blocks 1325 and 1335, if there are more primitives of the tile that have not yet been analyzed (conditional branch block 1340, "yes"), the method 1300 returns to block 1310. Otherwise, if all primitives of the tile have been analyzed (conditional branch block 1340, "no"), if the multi-layer flag is not set (conditional branch block 1345, "no"), the control unit does not send the primitives of the tile through the depth buffer pre-pass (block 1350). After block 1350, the method 1300 ends. In another embodiment, if the control unit maintains a counter that tracks the total number of layers, the counter can be compared to a threshold in conditional branch block 1345. If the multi-layer flag is set (conditional branch block 1345, "yes"), for each primitive, if the corresponding cumulative area of the primitive's layers is greater than the threshold (conditional branch block 1355, "yes"), the control unit sends the primitive through the depth buffer pre-pass (block 1360). Otherwise, if the corresponding cumulative area of the primitive's layer is less than or equal to the threshold (conditional block 1355, "No"), the control unit skips the depth buffer pre-pass for the primitive (block 1365). After blocks 1360 and 1365, method 1300 ends. In one embodiment, after a depth buffer pre-pass is performed on the primitive selected in method 1300, all of the primitives in the tile are processed in the color pass.
[0053] In various embodiments, program instructions of a software application are used to implement the methods and / or mechanisms described herein. For example, program instructions executable by a general purpose or special purpose processor are contemplated. In various embodiments, such program instructions are expressed in a high level programming language. In other embodiments, the program instructions are compiled from the high level programming language into a binary, intermediate or other form. Alternatively, program instructions are written that describe the operation or design of hardware. Such program instructions are expressed in a high level programming language such as C. Alternatively, a hardware design language (HDL) such as Verilog is used. In various embodiments, the program instructions are stored in any of a variety of non-transitory computer readable storage media. The storage media are accessible by the computing system during use to provide the program instructions to the computing system for program execution. Generally speaking, such a computing system includes at least one or more memories and one or more processors configured to execute the program instructions.
[0054] It should be emphasized that the above-described embodiments are merely non-limiting examples of embodiments. Numerous variations and modifications will become apparent to those skilled in the art once the above disclosure is fully appreciated. It is intended that the following claims be interpreted to include all such variations and modifications.
Claims
1. 1. An apparatus comprising: A cache that stores multiple primitives in a scene; a control unit coupled to the cache; The control unit performing a first portion of processing associated with rendering the scene on a selected one of the plurality of primitives stored in the cache, the first portion of processing including a first test; performing a second portion of processing on the plurality of primitives based on a result of the first test, the second portion of processing being associated with rendering the scene; and generating shaded pixels of the scene as a result of a second portion of the processing; and sending the shaded pixels to a display; and 4. The method of claim 3, Device.
2. the first test is a depth buffer pre-pass test, the plurality of primitives corresponding to a given tile of the scene; The control unit identifying a first subset of pixel samples that pass the depth buffer pre-pass test; identifying a second subset of pixel samples that fail the depth buffer pre-pass test; and further configured to:
2. The apparatus of claim 1.
3. A second part of the processing includes color shading; The control unit performing color shading on only the first subset of pixel samples to generate shaded pixels corresponding to the first subset of pixel samples; skipping color shading for said second subset of pixel samples; and and further configured to:
3. The apparatus of claim 2.
4. The control unit performing the depth buffer pre-pass test for a given pixel sample using a first depth function; performing a second depth buffer test for the given pixel sample using a second depth function; and further configured to: the second depth function is different from the first depth function; 4. The apparatus of claim 3.
5. the first depth function is a less than function and the second depth function is a less than or equal to function; 5. The apparatus of claim 4.
6. The control unit setting, for the given pixel sample, a corresponding indicator in a pre-pass buffer to a first value in response to the pixel sample passing the depth buffer pre-pass test; performing the second depth buffer test using the second depth function for the given pixel sample in response to the corresponding indicator having the first value; shading the given pixel sample and setting the corresponding indicator in the pre-pass buffer to a second value in response to the given pixel sample passing the second depth buffer test; and further configured to: The system of claim 4.
7. the control unit is further configured to discard the one or more primitives prior to performing the depth buffer pre-pass test in response to the one or more primitives satisfying one or more conditions.
5. The apparatus of claim 4.
8. 1. A method comprising: performing a first portion of processing associated with rendering a scene on a selected one of a plurality of primitives of the scene stored in a cache, the first portion of processing including a first test; performing a second portion of processing on the plurality of primitives based on a result of the first test, the second portion of processing being associated with rendering the scene; and generating shaded pixels of the scene as a result of a second portion of the processing; and sending the shaded pixels to a display. method.
9. the first test is a depth buffer pre-pass test, the plurality of primitives corresponding to a given tile of the scene; The method comprises: identifying a first subset of pixel samples that pass the depth buffer pre-pass test; and identifying a second subset of pixel samples that fail the depth buffer pre-pass test. The method of claim 8.
10. A second part of the processing includes color shading; The method comprises: performing color shading on only the first subset of pixel samples to generate shaded pixels corresponding to the first subset of pixel samples; skipping color shading for the second subset of pixel samples.
10. The method of claim 9.
11. performing the depth buffer pre-pass test for a given pixel sample using a first depth function; performing a second depth buffer test for the given pixel sample using a second depth function; the second depth function is different from the first depth function; The method of claim 10.
12. the first depth function is a greater than function and the second depth function is a greater than or equal to function.
12. The method of claim 11.
13. setting, for the given pixel sample, a corresponding indicator in a pre-pass buffer to a first value in response to the given pixel sample passing the depth buffer pre-pass test; performing the second depth buffer test using the second depth function for the given pixel sample in response to the corresponding indicator having the first value; and responsive to the given pixel sample passing the second depth buffer test, shading the given pixel sample and setting the corresponding indicator in the pre-pass buffer to a second value.
12. The method of claim 11.
14. and, in response to one or more primitives satisfying one or more conditions, discarding the one or more primitives prior to performing the depth buffer pre-pass test.
12. The method of claim 11.
15. 1. A system comprising: a memory for storing a plurality of primitives of a scene; a processor coupled to the memory, The processor, performing a first portion of processing associated with rendering the scene on selected ones of the plurality of primitives stored in the memory, the first portion of processing including a first test; performing a second portion of processing on the plurality of primitives based on a result of the first test, the second portion of processing being associated with rendering the scene; and generating shaded pixels of the scene as a result of a second portion of the processing; and sending the shaded pixels to a display; and [0023] system.
16. the first test is a depth buffer pre-pass test, the plurality of primitives corresponding to a given tile of the scene; The processor, identifying a first subset of pixel samples that pass the depth buffer pre-pass test; identifying a second subset of pixel samples that fail the depth buffer pre-pass test; and further configured to:
16. The system of claim 15.
17. A second part of the processing includes color shading; The processor, performing color shading on only the first subset of pixel samples to generate shaded pixels corresponding to the first subset of pixel samples; skipping color shading for said second subset of pixel samples; and and further configured to:
17. The system of claim 16.
18. The processor, performing the depth buffer pre-pass test for a given pixel sample using a first depth function; performing a second depth buffer test for the given pixel sample using a second depth function; and further configured to: the second depth function is different from the first depth function; 20. The system of claim 17.
19. the first depth function is a less than function and the second depth function is a less than or equal to function; 20. The system of claim 18.
20. The processor, setting, for the given pixel sample, a corresponding indicator in a pre-pass buffer to a first value in response to the given pixel sample passing the depth buffer pre-pass test; performing the second depth buffer test using the second depth function for the given pixel sample in response to the corresponding indicator having the first value; shading the given pixel sample and setting the corresponding indicator in the pre-pass buffer to a second value in response to the given pixel sample passing the second depth buffer test; and further configured to:
20. The system of claim 18.
Citation Information
Patent Citations
Position-limited shading pipeline
JP2017531254A
Two-pass cache tile processing for visibility testing in a tile-based architecture
US20140118347A1
Method and apparatus for masked occlusion culling
US20190295313A1
Arithmetic processing device
WO2007052682A1
