Reinforcement learning for light transport

A method for light transport includes steps of initializing a data structure that is configured to provide an importance value for each incident sample in a three-dimensional (3D) scene and tracing, in a direction from an origin, a ray of a plurality of rays through the 3D scene to intersect an object at a hitpoint. Additional steps include selecting a next direction of the ray according to a distribution of the importance values at the hitpoint, tracing the ray in the next direction to find a next hitpoint, updating a first importance value corresponding to the hitpoint using a second importance value corresponding to the next hitpoint, and setting the hitpoint of the ray to the next hitpoint. The additional steps are repeated until the next hitpoint is an endpoint. A contribution, based on each hitpoint and the endpoint, to a pixel that is intersected by the ray is recorded.

FIELD OF THE INVENTION

The present invention relates to ray tracing, and more particularly to reinforcement learning for light transport.

BACKGROUND

One application of light transport simulation is the computational synthesis of images that cannot be distinguished from real photographs. In such simulation algorithms, light transport is modeled by a Fredholm integral equation of the second kind and pixel colors are determined by estimating functionals of the solution of the Fredholm integral equation. The estimators are averages of the contribution of sampled light transport paths or rays that connect light sources and camera sensors.

Compared to reality, where photons and trajectories are abundant, a computer may only consider a tiny fraction of path space, which is one of the dominant reasons that images have noise artifacts. Because the number of paths that may be traced is limited, increasing the number of light transport paths that have an important contribution to the image produces a higher quality image. While research in computer graphics has focused on importance sampling to increase the number of light transport paths that contribute to the image, for some time there has not been a simple and efficient online method that can substantially reduce the number of light transport paths having zero contribution to the image.

FIG. 1Aillustrates a prior art diagram100of a light path. The surface is directly illuminated by the light source. As shown inFIG. 1A, multiple rays are scattered from a surface102. When importance sampling is used, most of the rays are cast from the surface102in the direction of the light source. Radiance is integrated by sampling from a probability density function p that is proportional to the product of emitted radiance Leand the bidirectional scattering distribution function ƒrrepresenting the physical surface properties. The fraction of radiance that is incident perpendicular to the surface, is taken into account by the cosine of the angle θ between the surface normal and the direction of incidence.

FIG. 1Billustrates a prior art diagram110of an occluded light transport path. The surface102should be indirectly illuminated by the light source because the object105occludes the light path. Importance sampling does not consider occluding objects, so all of the rays fail to reach the light source. Light transport paths with zero contribution to the image cannot be avoided unless visibility is considered. For example, when a portion of a scene is lit by a light behind a door and the door position changes from open to nearly closed, the occlusion problem can be made arbitrarily more difficult to solve. There is a need for addressing these issues and/or other issues associated with the prior art.

SUMMARY

A method, computer readable medium, and system are disclosed for learning light transport. The method includes the steps of initializing a data structure that is configured to provide an importance value for each incident sample in a three-dimensional (3D) scene and tracing, in a direction from an origin, a first ray of a plurality of rays through the 3D scene to intersect an object at a hitpoint. Additional steps include selecting a next direction of the first ray according to a distribution of the importance values at the hitpoint, tracing the first ray in the next direction from the hitpoint to find a next hitpoint, updating, in the data structure, a first importance value corresponding to the hitpoint of the first ray using a second importance value in the data structure corresponding to the next hitpoint, and setting the hitpoint of the first ray to the next hitpoint. Selecting the next direction, tracing the first ray in the next direction from the hitpoint, updating the data structure, and setting the hitpoint are repeated until the next hitpoint is an endpoint. A contribution, based on each hitpoint and the endpoint, to a first pixel that is intersected by the first ray is recorded.

DETAILED DESCRIPTION

Reinforcement learning is a machine learning technique that enables a policy to be developed by learning from feedback. Correct or desirable actions are reinforced, and over time, as the policy is implemented, the policy evolves to take actions that are more correct or produce greater rewards. The Q-learning algorithm developed by Watkins in 1989 is based on a table of values, Q, and the inputs to the table are a current state and a next action. The values in the table Q correspond to an expected reward. The values are initialized and, over time, the values in Q are learned as the policy is applied and the values in Q converge. In other words, the policy learns to maximize the expected reward. Given a limited number of next actions for each current state, the values for each next action may be considered and the best value may be selected for the next action.

The techniques used for reinforcement learning may be applied to light transport simulation. The current state becomes a position in a scene, an action becomes selection of a next direction for a ray being traced along a light transport path, and the reward becomes the emitted radiance incident seen at the position coming from the next direction. In the context of the following description, a ray is traced from a sensor (e.g., camera or light source) to intersect objects in a scene. A light transport path is defined by segments of the ray through the scene. A light transport path may be defined starting at a camera and ending at a light source or starting at a light source and ending at a camera.

FIG. 1Cillustrates a flowchart115of a method for learning light transport, in accordance with one embodiment. Although method115is described in the context of a processing unit, the method115may also be performed by a program, custom circuitry, or by a combination of custom circuitry and a program. For example, the method115may be executed by a GPU (graphics processing unit), CPU (central processing unit), or any processor capable of executing the program instructions. Furthermore, persons of ordinary skill in the art will understand that any system that performs method115is within the scope and spirit of embodiments of the present invention.

At step120, a data structure is initialized that is configured to provide an importance value for each incident sample in a three-dimensional (3D) scene. The data structure stores incident radiance values and can be queried given a position in a three-dimensional (3D) scene and a direction. For example, the data structure Q(x,ω) may be used to store importance values, where a combination of the position x and the direction ω of a ray having an origin at x specifies an incident sample. In one embodiment, the importance values are each initialized to a value of one and then updated as rays are traced. In another embodiment, the importance values are each initialized to a predetermined value other than one.

At step125, a first ray of a plurality of rays is traced in a direction from an origin through the 3D scene to intersect an object at a hitpoint. In one embodiment, during path tracing (i.e., light transport simulation), rays are traced from a camera through each pixel of an image plane into the 3D scene. The pixels are shaded based on radiance contributed by the light transport paths that are traced. In one embodiment, the origin is a camera. In one embodiment, the origin is a light source.

At step130, a next direction of the first ray is selected according to a distribution of the importance values at the hitpoint. When a ray intersects a surface at a hitpoint, the data structure is used to determine a next direction for the ray to trace. The hitpoint is used to access the data structure to obtain an importance value for each possible next direction (i.e., scattering direction) for the ray. The next direction is selected based on a policy, such as a distribution of the importance values for different possible next directions at the hitpoint. At step135, the first ray is traced through the 3D scene in the next direction from the hitpoint to find a next hitpoint.

At step150, a first importance value in the data structure that corresponds to the hitpoint of the first ray is updated using a second importance value in the data structure corresponding to the next hitpoint. In one embodiment, the importance value corresponding to the hitpoint and the next direction is updated when the next hitpoint is identified. Importantly, the first importance value at the origin of the ray (the hitpoint) is updated based on the second importance value corresponding to the next hitpoint. Thus, the importance values effectively approximate the incident radiance for each incident sample. In other words, as the importance values stored in the data structure are updated, the directions that contribute to radiance (and pixel shading) are reinforced. Thus, the rays are guided in directions associated with higher importance that therefore contribute to the radiance of the pixels.

In one embodiment, Equation (1) is used to update the first importance value, where Q(x,ω) is the current first importance value and Q′(x,ω) is the updated first importance value.
Q′(x,ω)=(1·α)·Q(x,ω)+α·(Le(y,·ω)+∫s+(y)Q(y,ωi)ƒs(ωi,y,−ω)cos θidωi)  (1)
The integral accounts for all radiance that is incident over a hemisphere centered at the next hitpoint y. In equation (1) the hitpoint x is the origin of the ray, ω is the next direction, y is the next hitpoint, α is the learning rate where α∈[0,1], Leis the emitted radiance as observed from the origin x, and θ is the angle between the surface normal n at the hitpoint x and the next direction ω. Q (x,ω) is also called an irradiance field.

At step160, the hitpoint of the first ray x is set to the next hitpoint y to trace another segment of the first ray. At step165, a determination is made whether the next hitpoint is an endpoint. When the light transport path originates at a camera, the endpoint may be a light source. When the light transport path originates at a light source, the endpoint may be a camera. If the next hitpoint is an endpoint, then at step170, a contribution, based on each hitpoint and the endpoint, to a first pixel that is intersected by the first ray is recorded. In one embodiment, the contribution is a radiance value that is used to shade a pixel corresponding to the first ray.

When, at step165, a determination is made that the next hitpoint is not an endpoint, then steps130,135,150,160, and165are repeated until an endpoint is reached. In one embodiment, when an endpoint has not been reached after tracing the light transport path for a predetermined number of segments, tracing is terminated and the radiance is set to the radiance of the ambient light in the 3D scene. In one embodiment, when the ray fails to hit either an endpoint or an object in the scene, a radiance value is obtained from an environment map. The fields of the ray data structure then may be used as inputs to obtain the radiance from the environment map.

Reinforcement Learning and Light Transport

The equations for reinforcement learning and light transport simulation are related integral equations. Based on this correspondence, a technique may be implemented to learn importance during path space sampling. A consistent light transport simulation technique uses reinforcement learning to progressively learn probability density functions for importance sampling to generate images. By employing reinforcement learning, the light transport simulation technique is able to guide paths around obstructions so that more paths contribute to the radiance of the image. The number of paths with non-zero radiance contribution can be dramatically increased and noise artifacts in the rendered images may be reduced. Overall, the paths may be shortened as a result of guiding the paths using the learned importance values.

The radiance that is projected onto the image plane is computed to synthesize images. For the purposes of the following description, an example of a simple conventional forward path tracer is used. From a virtual camera, rays are traced through the pixels of the screen. Upon the first intersection of the rays with the scene geometry, the light transport path is continued into a scattering direction determined according to the surface properties. Scattering and ray tracing are repeated until a light source is hit. The contribution of each complete light transport path is added to the pixel pierced by the initial ray of this light transport path when started at the camera. In the simple form, the images that are produced are quite noisy.

The noise may be reduced by importance sampling, when the importance values are progressively approximated using reinforcement learning as rays are traced by a modified path tracer. As previously described, the integral in Equation (1) accounts for all radiance that is incident over a hemisphere centered at the next hitpoint y.

FIG. 2Aillustrates a hemisphere200having equally sized patches, in accordance with one embodiment. For selected points y in space, the hemisphere200is stratified into the patches and one importance value Qi(y) is stored per patch, i.e. stratum i. When the hemisphere200is centered at a position on a surface, each patch corresponds to a different set of next directions ω. The integral in Equation (1) can be estimated by using one uniform random direction ωi(ξ) in each stratum i. In other embodiments, an irradiance volume representing an irradiance field is used to approximate the importance values. In other embodiments, the hemispheres200may be replaced with other representations of irradiance probes.

FIG. 2Billustrates a Voronoi diagram210for a scene, in accordance with one embodiment. The scene includes a cube resting on a plane and the Voronoi diagram210results from mapping a two-dimensional low discrepancy sequence onto the scene surface forming a grid of polygons. At the center of each polygon is a position, where a hemisphere200may be centered. In one embodiment, the density of the grid may increased or decreased compared withFIG. 2B. When a ray intersects the surface, the hemisphere200with the center that is nearest to the intersection is selected for accessing the data structure Q storing the importance values. In other words, the nearest-neighbor may be used to locate a hemisphere200. Identifying a nearest intersection may include checking other attributes, such as surface normals, for similarity.

FIG. 2Cillustrates an example discretization of importance values220for a uniform set of positions on a plane, in accordance with one embodiment. The stippling density indicates magnitude, where small values are less dense and large values are more dense. The large importance values on each hemisphere point towards the part of the scene, where the light is coming from. For example, under the big area light source215, most radiance is incident as reflected radiance from the wall opposite to the light source215. Therefore, the larger importance values on the hemispheres221are on the upper right portion of each hemisphere. For the hemispheres223, approximately equal radiance is received directly from the light source215and reflected from the wall opposite the light source215, so larger importance values are near the tops of the hemispheres223. For the hemispheres224, most radiance is received directly from the light source215, so larger importance values are on the upper left portion of the hemispheres224.

The importance values200are updated based on reinforcement learning as rays are traced in the scene. For a ray intersecting a point nearest to the position centered within a hemisphere216, a next direction that is selected for the ray should point from the hitpoint towards the larger importance values on the upper left portion of the hemisphere216. In one embodiment, for most but not all rays, the next direction corresponding to the highest importance value is selected. In other words, the next action having the highest reward is not always selected.

In one embodiment, a probability density function resulting from normalizing the importance values at the hitpoint x is used to select a next direction for each ray. As a consequence, more and more light transport paths are generated that contribute to the image. Because the importance values are learned during path tracing, preprocessing is not needed. The importance values are initialized before the paths are traced and then updated as the paths are traced. In another embodiment, the importance values may be computed in a preprocess. In yet another embodiment, the importance values may be updated throughout a series of rendered images in an animation.

FIG. 2Dillustrates a flowchart of another method225for learning light transport, in accordance with one embodiment. Although method225is described in the context of a processing unit, the method225may also be performed by a program, custom circuitry, or by a combination of custom circuitry and a program. For example, the method225may be executed by a GPU (graphics processing unit), CPU (central processing unit), or any processor capable of executing the program instructions. Furthermore, persons of ordinary skill in the art will understand that any system that performs method225is within the scope and spirit of embodiments of the present invention.

Steps120,125,130,135,150, and160are performed as previously described in conjunction withFIG. 1C. At step120, a data structure is initialized that is configured to provide an importance value for each incident sample in a 3D scene. In one embodiment, to guarantee ergodicity, meaning that every light transport path remains possible, all importance values are initialized with a positive value; for example, a uniform probability density or a value proportional to a factor of the integrand shown in Equation (1) may be utilized as initialization values. In one embodiment, during simulation importance values may not be allowed to become zero in order to maintain ergodicity.

At step222, a throughput, an origin, and a direction are initialized for a ray of a plurality of rays. In one embodiment, the throughput is initialized to a value of one. In one embodiment, the origin is initialized to a position of a sensor. In one embodiment, a direction is initialized to point from the origin through a pixel in an image plane.

At step125, the ray is traced in a direction from the origin through the 3D scene to intersect an object at a hitpoint. At step227, a determination is made whether the hitpoint is a light source. If, at step227, the hitpoint is a light source, then at step230a radiance of the light source scaled by the throughput is accumulated for the pixel corresponding to the ray. At step230, a contribution of radiance of the light source scaled by the throughput is accumulated into a first pixel that is intersected by the ray. In one embodiment, the contribution is used to shade a pixel corresponding to the first ray.

At step235, a determination is made whether tracing paths for an image is complete, and, if not, the process returns to step222to trace another path. Otherwise, at step240, the image is produced based on the traced paths.

If, at step227, the hitpoint is not a light source, then steps130,135, and150are completed. At step130, a next direction of the ray is selected according to a distribution of the importance values at the hitpoint. At step135, the ray is traced through the 3D scene starting from the hitpoint towards the next direction to find a next hitpoint. At step150, a first importance value in the data structure that corresponds to the hitpoint of the ray is updated using a second importance value in the data structure corresponding to the next hitpoint.

The radiance at a point x on a surface into direction ω is modeled by a Fredholm integral equation of the second kind, as shown in Equation (1). Leis the source radiance and the integral accounts for all radiance that is incident over the hemisphere S+(x) aligned by the surface normal in x and transported into direction w. A hitpoint function h(x,ω) traces a ray from the hitpoint x into direction wand returns the first surface point that is intersected (i.e., the next hitpoint y). The radiance from the next hitpoint is attenuated by the bidirectional scattering distribution function ƒs, where the cosine term of the angle θ between surface normal and ωiaccounts for only the fraction that is perpendicular to the surface. The importance values are the radiance Li(x,ω) incident in x from direction ω and are described by the Fredholm integral equation of the second kind.

In one embodiment, at step150, the first importance value Q(x,ω), at the hitpoint x and direction ω is updated according to Equation (1). Specifically, the first importance value is updated to the sum of Q(x,ω) scaled by one minus the learning rate α, the emitted radiance as observed from the location x, Le(y,−ω)=Le(h(x,ω),−ω) scaled by α, and all radiance that is incident over a hemisphere centered at the next hitpoint y,
(∫s+(y)Q(y,ωi)ƒs(ωi,y,−ω)cos θidωi) scaled by α.

To ensure that renderer introduced artifacts, such as noise, are reduced or eliminated over time, the importance values should converge. Convergence may be accomplished by using a vanishing learning rate α. In one embodiment, the number of visits to each incident sample (x,ω) is counted using the following equation:

In one embodiment, the learning rate α may depend on the total number of visits to a position x alone, or even may be chosen to vanish independent of x and w. The parameters that may be controlled are the discretization (i.e., the number of patches or stratum i) and the learning rate α. In one embodiment, sampling according to the learned importance values Q is realized by normalizing the importance values Q in at least one selected point x and computing the cumulative distribution function thereof to perform the sampling by inverting the cumulative distribution function. For many selected points normalizing and building the cumulative distribution function may be executed in parallel every frame to be accumulated.

At step255, the throughput for the ray is updated according to the 3D scene, the next direction, and the hitpoint. At step160, the hitpoint x of the ray is set to the next hitpoint y to trace another segment of the light transport path. Steps125,227,130,135,150,255, and160are repeated until an endpoint is reached. In one embodiment, when an endpoint has not been reached after tracing the path for a predetermined number of segments, tracing is terminated and the radiance is set to the radiance of the ambient light in the 3D scene before proceeding to step230.

The previously described simple path tracer may be modified to implement an importance driven forward path tracer that employs reinforcement learning.FIG. 2Eillustrates pseudo code for implementing a path tracer with reinforcement learned importance sampling, in accordance with one embodiment. Two routines are added, a first function270for updating a data structure Q that stores the importance values and a second function for selecting a scattering direction (i.e., next direction) that is proportional to the importance values. Normalizing an importance value Qiat a next hitpoint y then results in a probability density that is used for importance sampling during scattering by inverting the cumulative distribution function.

The pathTrace function receives a camera position and geometry for a 3D scene. A throughput and ray are initialized. As shown inFIG. 2E, the throughput is initialized to one which corresponds to 100%. The ray origin is initialized to the camera position and the direction of the ray is initialized by a selected pixel of the image. The value i is incremented for each segment of the path that is traced for the ray. An intersect function traces a ray into the 3D scene and returns a hitpoint y and a surface normal vector n of the surface. For the first segment (i=0), the data structure for Q is not updated.

If the hitpoint is invalid, meaning that no surfaces or objects are intersected by the ray, then the hitpoint is considered an environment hitpoint and a radiance value is read from an environment map using the getRadianceFromEnvironment function. If the hitpoint is a light source, then the getRadianceFromAreaLight function returns the radiance value for the light source. The returned radiance value is scaled by the throughput and the path is terminated.

If the hitpoint is not an endpoint (environment or light source), a sampleScatteringDirectionProportionalToQ function280is executed to generate values for a bidirectional scattering distribution function ƒs, a next direction ω, and a probability pωassociated with the next direction that is based on both the material properties of the surface at the hitpoint and the data structure for Q queried in the ray origin point x. In one embodiment, the hemisphere200having a center closest to the hitpoint is located by the query. For the located hemisphere200, the cumulative distribution function is determined and used to select the scattering direction ω proportional to Q. A probability pωassociated with the selected direction ω is provided.

The throughput is updated according to the surface color contribution of the light returned from the hitpoint back to the camera. Specifically, the throughput is updated by scaling the throughput by the bidirectional scattering distribution function ƒsand the cosine term of the angle θ between the surface normal n and ω that accounts for the fraction of radiance that is perpendicular to the surface, and dividing by the probability pω. In addition to updating the throughput, the origin of the ray is updated to start a next segment of the path at the hitpoint and the direction of the ray is updated to the next direction.

When i is incremented to be greater than one, the data structure storing the importance values (Q) is updated according to Equation (1). Importantly, before the data structure is updated, a next hitpoint is determined. The update procedure requires the ray origin x and its direction ω, the next hitpoint y and the normal vector at the next hitpoint y. In one embodiment, the closest point to the next hitpoint on a surface where a hemisphere is centered is located by the query.

In one embodiment, the importance value stored in the data structure for Q is scaled by (1−α) and summed with the product of α and a numerical evaluation of the integral in Equation (1). The integral may be approximated by at least one of the maximum value of Q at the query point or the sum of importance values of Q in the query point multiplied by weights depending on the bidirectional scattering distribution function. Locating a closest point may include locating a closest point with a similar normal in order not to use importance values from locations that are too different in terms of geometry.

Assuming that a decreases over time as more paths are traced, then the update value is weighed more heavily for the earlier paths. As the importance values evolve during the learning process, the weight of the update value is reduced. A path tracer that is augmented to incorporate reinforcement learning for importance sampling along each path that is traced updates the importance values stored in the data structure and selects scattering directions that are proportional to the importance values learned so far at each hitpoint.

In another embodiment, the exponential average as used in Equation (1) to update the importance values may be replaced by a simple average, where updates are simply summed up and on query are divided by the number of updates so far. In yet another embodiment, the data structure for Q may be at least one of an irradiance volume or a spatially adaptive data structure to store Q and use other representations for Q for a query point, which may include at least Gaussian mixture models.

As described in conjunction withFIG. 2E, when no surfaces or objects are intersected by a ray, an environment map may be used to determine a radiance value. Rendering sun and sky to produce an environment map is usually done by distributing samples proportional to the brightness of pixels in the environment map. More samples should end up in brighter regions, which may be achieved by constructing and sampling from a cumulative distribution function. Furthermore, the sun may be separated from the sky and simulated separately. The efficiency of such importance sampling is highly dependent on occlusion, i.e., the part of the environment that can be seen from the point to be shaded.

To consider the actual contribution including occlusion, an action space is defined by partitioning the environment map into tiles and learning the importance per tile. Noise artifacts may be significantly reduced when reinforcement learning is used to generate importance values for each tile of the environment map.

When a scene includes one or more reflective surfaces such as chrome, mirrors, and the like, light tracing may be used to generate the image. Light tracing generates rays starting from the light sources and terminating at the camera. For guiding light transport paths starting from the light sources, a transported measurement contribution function W is learned instead of the importance values corresponding to incident radiance. W values may be stored in a separate data structure or in the same data structure as the importance values. Learning Win addition to the importance values enables the implementation of bidirectional path tracing with reinforcement learning for importance sampling to guide both light and camera path segments and incorporate visibility information. Note that guiding light transport paths using reinforcement learning may reduce the time needed to render images and/or greatly improve the image quality.

For light sources having a smaller size, the resolution of the data structure to store importance values may be increased to reliably guide rays to hit a light source. A next event estimation technique may be used to improve the path tracing, even when small light sources are present. A probability per light source may be determined by the number of successful shadow rays divided by the total number of shadow rays shot.

When reinforcement learning is used, a state space may be defined as a regular grid over the scene, where in each grid cell c for each light source l a value Vc,lis stored that is initialized with zero. Whenever a sample on a light source l is visible to a point x to be illuminated in the cell c upon next event estimation, the value of Vc,lis updated using the following equation:
V′c,l=(1−α)Vc,l+a·∥Cl(x)∥∞(3)
Vc,lis updated to the value computed for V′c,lthat uses the norm of the contribution Cl(x). Building a cumulative distribution function from all values Vc,lwithin a cell c, light sources may be selected based on importance sampling.

Reinforcement learning may also be used when virtual point light sources are present in a 3D scene. The vertices generated by tracing light paths can be considered a photon map. Furthermore, the vertices may be used as a set of virtual point light sources for when an instant radiosity algorithm is employed. Continuously updating and learning the measurement contribution function W across frames and using the same seed for the pseudo- or quasi-random sequences allows for generating virtual point light sources that expose a certain coherency over time, which reduces temporal artifacts when rendering animations with global illumination.

When reinforcement learning is used, the number of paths actually connecting to a light source (or to a camera) is dramatically improved compared with conventional importance sampling. As a result, more non-zero contributions are accumulated when the same number of paths are traced and the image quality is improved. In particular, noise artifacts are reduced and the noise that remains is more uniform and lacking the typical splotchy structure inherent in the local space exploration used by conventional techniques, such as Metropolis sampling. Note, however, that the reinforcement learning importance sampling scheme described herein could also be combined with Metropolis sampling.

Importantly, updating the importance values based on the weighted average of all possible next actions according to Equation (1) produces higher quality images compared with updating the importance values based on a “best possible action” strategy where a next direction associated with a maximum incident radiance is selected.

Shooting rays towards where the radiance comes from naturally shortens the average path length. As a consequence when the algorithm described in conjunction withFIGS. 1C, 2D, and2E is used for the same budget of light transport paths, a speed increase of approximately 20% may be achieved compared with using conventional path tracing without reinforcement learning. A significant gain in image quality results due to the dramatic increase of non-zero contribution light transport paths, even under complex lighting.

Reinforcement learning is applied during image synthesis to guide paths and evolve the importance values. Additionally, reinforcement learning for light transport simulation can be applied during image synthesis and/or across frames, because the importance values can be updated over time. Parameters that may control the reinforcement learning process are the learning rate and the discretization of the angles for each hemisphere. Increasing the density of patches may reduce the learning speed while decreasing the density of patches may cause the importance values to converge more slowly. Instead of taking into account only the next direction corresponding to the highest importance value, equation (1) considers all possible next directions in a continuous space and weighs the importance values for the next directions by a transition kernel to update the importance value for a ray origin and direction. The amount of storage needed for the data structure storing the importance values is limited, therefore the memory footprint is also limited. In one embodiment, a data structure of 2 Mbytes of memory may be used.

Parallel Processing Architecture

FIG. 3illustrates a parallel processing unit (PPU)300, in accordance with one embodiment. The PPU300may be configured to implement a path tracer with reinforcement learned importance sampling. In one embodiment, the PPU300includes one or more functional units configured to perform importance sampling operations, such as the functions shown inFIG. 2E.

In one embodiment, the PPU300is a multi-threaded processor that is implemented on one or more integrated circuit devices. The PPU300is a latency hiding architecture designed to process many threads in parallel. A thread (i.e., a thread of execution) is an instantiation of a set of instructions configured to be executed by the PPU300. In one embodiment, the PPU300is a graphics processing unit (GPU) configured to implement a graphics rendering pipeline for processing three-dimensional (3D) graphics data in order to generate two-dimensional (2D) image data for display on a display device such as a liquid crystal display (LCD) device. In other embodiments, the PPU300may be utilized for performing general-purpose computations. While one exemplary parallel processor is provided herein for illustrative purposes, it should be strongly noted that such processor is set forth for illustrative purposes only, and that any processor may be employed to supplement and/or substitute for the same.

As shown inFIG. 3, the PPU300includes an Input/Output (I/O) unit305, a host interface unit310, a front end unit315, a scheduler unit320, a work distribution unit325, a hub330, a crossbar (Xbar)370, one or more general processing clusters (GPCs)350, and one or more partition units380. The PPU300may be connected to a host processor or other peripheral devices via a system bus302. The PPU300may also be connected to a local memory comprising a number of memory devices304. In one embodiment, the local memory may comprise a number of dynamic random access memory (DRAM) devices.

The I/O unit305is configured to transmit and receive communications (i.e., commands, data, etc.) from a host processor (not shown) over the system bus302. The I/O unit305may communicate with the host processor directly via the system bus302or through one or more intermediate devices such as a memory bridge. In one embodiment, the I/O unit305implements a Peripheral Component Interconnect Express (PCIe) interface for communications over a PCIe bus. In alternative embodiments, the I/O unit305may implement other types of well-known interfaces for communicating with external devices.

The I/O unit305is coupled to a host interface unit310that decodes packets received via the system bus302. In one embodiment, the packets represent commands configured to cause the PPU300to perform various operations. The host interface unit310transmits the decoded commands to various other units of the PPU300as the commands may specify. For example, some commands may be transmitted to the front end unit315. Other commands may be transmitted to the hub330or other units of the PPU300such as one or more copy engines, a video encoder, a video decoder, a power management unit, etc. (not explicitly shown). In other words, the host interface unit310is configured to route communications between and among the various logical units of the PPU300.

In one embodiment, a program executed by the host processor encodes a command stream in a buffer that provides workloads to the PPU300for processing. A workload may comprise several instructions and data to be processed by those instructions. The buffer is a region in a memory that is accessible (i.e., read/write) by both the host processor and the PPU300. For example, the host interface unit310may be configured to access the buffer in a system memory connected to the system bus302via memory requests transmitted over the system bus302by the I/O unit305. In one embodiment, the host processor writes the command stream to the buffer and then transmits a pointer to the start of the command stream to the PPU300. The host interface unit310provides the front end unit315with pointers to one or more command streams. The front end unit315manages the one or more streams, reading commands from the streams and forwarding commands to the various units of the PPU300.

The front end unit315is coupled to a scheduler unit320that configures the various GPCs350to process tasks defined by the one or more streams. The scheduler unit320is configured to track state information related to the various tasks managed by the scheduler unit320. The state may indicate which GPC350a task is assigned to, whether the task is active or inactive, a priority level associated with the task, and so forth. The scheduler unit320manages the execution of a plurality of tasks on the one or more GPCs350.

The scheduler unit320is coupled to a work distribution unit325that is configured to dispatch tasks for execution on the GPCs350. The work distribution unit325may track a number of scheduled tasks received from the scheduler unit320. In one embodiment, the work distribution unit325manages a pending task pool and an active task pool for each of the GPCs350. The pending task pool may comprise a number of slots (e.g., 32 slots) that contain tasks assigned to be processed by a particular GPC350. The active task pool may comprise a number of slots (e.g., 4 slots) for tasks that are actively being processed by the GPCs350. As a GPC350finishes the execution of a task, that task is evicted from the active task pool for the GPC350and one of the other tasks from the pending task pool is selected and scheduled for execution on the GPC350. If an active task has been idle on the GPC350, such as while waiting for a data dependency to be resolved, then the active task may be evicted from the GPC350and returned to the pending task pool while another task in the pending task pool is selected and scheduled for execution on the GPC350.

The work distribution unit325communicates with the one or more GPCs350via XBar370. The XBar370is an interconnect network that couples many of the units of the PPU300to other units of the PPU300. For example, the XBar370may be configured to couple the work distribution unit325to a particular GPC350. Although not shown explicitly, one or more other units of the PPU300are coupled to the host interface unit310. The other units may also be connected to the XBar370via a hub330.

The tasks are managed by the scheduler unit320and dispatched to a GPC350by the work distribution unit325. The GPC350is configured to process the task and generate results. The results may be consumed by other tasks within the GPC350, routed to a different GPC350via the XBar370, or stored in the memory304. The results can be written to the memory304via the partition units380, which implement a memory interface for reading and writing data to/from the memory304. In one embodiment, the PPU300includes a number U of partition units380that is equal to the number of separate and distinct memory devices304coupled to the PPU300. A partition unit380will be described in more detail below in conjunction withFIG. 4B.

In one embodiment, a host processor executes a driver kernel that implements an application programming interface (API) that enables one or more applications executing on the host processor to schedule operations for execution on the PPU300. An application may generate instructions (i.e., API calls) that cause the driver kernel to generate one or more tasks for execution by the PPU300. The driver kernel outputs tasks to one or more streams being processed by the PPU300. Each task may comprise one or more groups of related threads, referred to herein as a warp. A thread block may refer to a plurality of groups of threads including instructions to perform the task. Threads in the same group of threads may exchange data through shared memory. In one embodiment, a group of threads comprises 32 related threads.

FIG. 4Aillustrates a GPC350within the PPU300ofFIG. 3, in accordance with one embodiment. As shown inFIG. 4A, each GPC350includes a number of hardware units for processing tasks. In one embodiment, each GPC350includes a pipeline manager410, a pre-raster operations unit (PROP)415, a raster engine425, a work distribution crossbar (WDX)480, a memory management unit (MMU)490, and one or more Texture Processing Clusters (TPCs)420. It will be appreciated that the GPC350ofFIG. 4Amay include other hardware units in lieu of or in addition to the units shown inFIG. 4A.

In one embodiment, the operation of the GPC350is controlled by the pipeline manager410. The pipeline manager410manages the configuration of the one or more TPCs420for processing tasks allocated to the GPC350. In one embodiment, the pipeline manager410may configure at least one of the one or more TPCs420to implement at least a portion of a graphics rendering pipeline. For example, a TPC420may be configured to execute a vertex shader program on the programmable streaming multiprocessor (SM)440. The pipeline manager410may also be configured to route packets received from the work distribution unit325to the appropriate logical units within the GPC350. For example, some packets may be routed to fixed function hardware units in the PROP415and/or raster engine425while other packets may be routed to the TPCs420for processing by the primitive engine435or the SM440.

The PROP unit415is configured to route data generated by the raster engine425and the TPCs420to a Raster Operations (ROP) unit in the partition unit380, described in more detail below. The PROP unit415may also be configured to perform optimizations for color blending, organize pixel data, perform address translations, and the like.

Each TPC420included in the GPC350includes an M-Pipe Controller (MPC)430, a primitive engine435, one or more SMs440, and one or more texture units445. The MPC430controls the operation of the TPC420, routing packets received from the pipeline manager410to the appropriate units in the TPC420. For example, packets associated with a vertex may be routed to the primitive engine435, which is configured to fetch vertex attributes associated with the vertex from the memory304. In contrast, packets associated with a shader program may be transmitted to the SM440.

In one embodiment, the texture units445are configured to load texture maps (e.g., a 2D array of texels) from the memory304and sample the texture maps to produce sampled texture values for use in shader programs executed by the SM440. The texture units445implement texture operations such as filtering operations using mip-maps (i.e., texture maps of varying levels of detail). The texture unit445is also used as the Load/Store path for SM440to MMU490. In one embodiment, each TPC420includes two (2) texture units445.

The SM440comprises a programmable streaming processor that is configured to process tasks represented by a number of threads. Each SM440is multi-threaded and configured to execute a plurality of threads (e.g., 32 threads) from a particular group of threads concurrently. In one embodiment, the SM440implements a SIMD (Single-Instruction, Multiple-Data) architecture where each thread in a group of threads (i.e., a warp) is configured to process a different set of data based on the same set of instructions. All threads in the group of threads execute the same instructions. In another embodiment, the SM440implements a SIMT (Single-Instruction, Multiple Thread) architecture where each thread in a group of threads is configured to process a different set of data based on the same set of instructions, but where individual threads in the group of threads are allowed to diverge during execution. In other words, when an instruction for the group of threads is dispatched for execution, some threads in the group of threads may be active, thereby executing the instruction, while other threads in the group of threads may be inactive, thereby performing a no-operation (NOP) instead of executing the instruction. The SM440is described in more detail below in conjunction withFIG. 5.

The MMU490provides an interface between the GPC350and the partition unit380. The MMU490may provide translation of virtual addresses into physical addresses, memory protection, and arbitration of memory requests. In one embodiment, the MMU490provides one or more translation lookaside buffers (TLBs) for performing translation of virtual addresses into physical addresses in the memory304.

FIG. 4Billustrates a memory partition unit380of the PPU300ofFIG. 3, in accordance with one embodiment. As shown inFIG. 4B, the memory partition unit380includes a Raster Operations (ROP) unit450, a level two (L2) cache460, a memory interface470, and an L2 crossbar (XBar)465. The memory interface470is coupled to the memory304. Memory interface470may implement 16, 32, 64, 128-bit data buses, or the like, for high-speed data transfer. In one embodiment, the PPU300incorporates U memory interfaces470, one memory interface470per partition unit380, where each partition unit380is connected to a corresponding memory device304. For example, PPU300may be connected to up to U memory devices304, such as graphics double-data-rate, version 5, synchronous dynamic random access memory (GDDR5 SDRAM). In one embodiment, the memory interface470implements a DRAM interface and U is equal to 8.

In one embodiment, the PPU300implements a multi-level memory hierarchy. The memory304is located off-chip in SDRAM coupled to the PPU300. Data from the memory304may be fetched and stored in the L2 cache460, which is located on-chip and is shared between the various GPCs350. As shown, each partition unit380includes a portion of the L2 cache460associated with a corresponding memory device304. Lower level caches may then be implemented in various units within the GPCs350. For example, each of the SMs440may implement a level one (L1) cache. The L1 cache is private memory that is dedicated to a particular SM440. Data from the L2 cache460may be fetched and stored in each of the L1 caches for processing in the functional units of the SMs440. The L2 cache460is coupled to the memory interface470and the XBar370.

The ROP unit450includes a ROP Manager455, a Color ROP (CROP) unit452, and a Z ROP (ZROP) unit454. The CROP unit452performs raster operations related to pixel color, such as color compression, pixel blending, and the like. The ZROP unit454implements depth testing in conjunction with the raster engine425. The ZROP unit454receives a depth for a sample location associated with a pixel fragment from the culling engine of the raster engine425. The ZROP unit454tests the depth against a corresponding depth in a depth buffer for a sample location associated with the fragment. If the fragment passes the depth test for the sample location, then the ZROP unit454updates the depth buffer and transmits a result of the depth test to the raster engine425. The ROP Manager455controls the operation of the ROP unit450. It will be appreciated that the number of partition units380may be different than the number of GPCs350and, therefore, each ROP unit450may be coupled to each of the GPCs350. Therefore, the ROP Manager455tracks packets received from the different GPCs350and determines which GPC350that a result generated by the ROP unit450is routed to. The CROP unit452and the ZROP unit454are coupled to the L2 cache460via an L2 XBar465.

FIG. 5illustrates the streaming multi-processor440ofFIG. 4A, in accordance with one embodiment. As shown inFIG. 5, the SM440includes an instruction cache505, one or more scheduler units510, a register file520, one or more processing cores550, one or more special function units (SFUs)552, one or more load/store units (LSUs)554, an interconnect network580, a shared memory/L1 cache570.

As described above, the work distribution unit325dispatches tasks for execution on the GPCs350of the PPU300. The tasks are allocated to a particular TPC420within a GPC350and, if the task is associated with a shader program, the task may be allocated to an SM440. The scheduler unit510receives the tasks from the work distribution unit325and manages instruction scheduling for one or more groups of threads (i.e., warps) assigned to the SM440. The scheduler unit510schedules threads for execution in groups of parallel threads, where each group is called a warp. In one embodiment, each warp includes 32 threads. The scheduler unit510may manage a plurality of different warps, scheduling the warps for execution and then dispatching instructions from the plurality of different warps to the various functional units (i.e., cores550, SFUs552, and LSUs554) during each clock cycle.

Each dispatch unit515is configured to transmit instructions to one or more of the functional units. In the embodiment shown inFIG. 5, the scheduler unit510includes two dispatch units515that enable two different instructions from the same warp to be dispatched during each clock cycle. In alternative embodiments, each scheduler unit510may include a single dispatch unit515or additional dispatch units515.

Each SM440includes a register file520that provides a set of registers for the functional units of the SM440. In one embodiment, the register file520is divided between each of the functional units such that each functional unit is allocated a dedicated portion of the register file520. In another embodiment, the register file520is divided between the different warps being executed by the SM440. The register file520provides temporary storage for operands connected to the data paths of the functional units.

Each SM440comprises L processing cores550. In one embodiment, the SM440includes a large number (e.g., 128, etc.) of distinct processing cores550. Each core550may include a fully-pipelined, single-precision processing unit that includes a floating point arithmetic logic unit and an integer arithmetic logic unit. The core550may also include a double-precision processing unit including a floating point arithmetic logic unit. In one embodiment, the floating point arithmetic logic units implement the IEEE 754-2008 standard for floating point arithmetic. Each SM440also comprises M SFUs552that perform special functions (e.g., attribute evaluation, reciprocal square root, and the like), and N LSUs554that implement load and store operations between the shared memory/L1 cache570and the register file520. In one embodiment, the SM440includes 128 cores550, 32 SFUs552, and 32 LSUs554.

Each SM440includes an interconnect network580that connects each of the functional units to the register file520and the LSU554to the register file520, shared memory/L1 cache570. In one embodiment, the interconnect network580is a crossbar that can be configured to connect any of the functional units to any of the registers in the register file520and connect the LSUs554to the register file and memory locations in shared memory/L1 cache570.

The shared memory/L1 cache570is an array of on-chip memory that allows for data storage and communication between the SM440and the primitive engine435and between threads in the SM440. In one embodiment, the shared memory/L1 cache570comprises 64 KB of storage capacity and is in the path from the SM440to the partition unit380. The shared memory/L1 cache570can be used to cache reads and writes.

The PPU300described above may be configured to perform highly parallel computations much faster than conventional CPUs. Parallel computing has advantages in graphics processing, data compression, neural networks, deep learning, biometrics, stream processing algorithms, and the like.

When configured for general purpose parallel computation, a simpler configuration can be used. In this model, as shown inFIG. 3, fixed function graphics processing units are bypassed, creating a much simpler programming model. In this configuration, the work distribution unit325assigns and distributes blocks of threads directly to the TPCs420. The threads in a block execute the same program, using a unique thread ID in the calculation to ensure each thread generates unique results, using the SM440to execute the program and perform calculations, shared memory/L1 cache570to communicate between threads, and the LSU554to read and write Global memory through partition shared memory/L1 cache570and partition unit380. When configured for general purpose parallel computation, the SM440can also write commands that scheduler unit320can use to launch new work on the TPCs420.

In one embodiment, the PPU300comprises a graphics processing unit (GPU). The PPU300is configured to receive commands that specify shader programs for processing graphics data. Graphics data may be defined as a set of primitives such as points, lines, triangles, quads, triangle strips, and the like. Typically, a primitive includes data that specifies a number of vertices for the primitive (e.g., in a model-space coordinate system) as well as attributes associated with each vertex of the primitive. The PPU300can be configured to process the graphics primitives to generate a frame buffer (i.e., pixel data for each of the pixels of the display).

An application writes model data for a scene (i.e., a collection of vertices and attributes) to a memory such as a system memory or memory304. The model data defines each of the objects that may be visible on a display. The application then makes an API call to the driver kernel that requests the model data to be rendered and displayed. The driver kernel reads the model data and writes commands to the one or more streams to perform operations to process the model data. The commands may reference different shader programs to be implemented on the SMs440of the PPU300including one or more of a vertex shader, hull shader, domain shader, geometry shader, and a pixel shader. For example, one or more of the SMs440may be configured to execute a vertex shader program that processes a number of vertices defined by the model data. In one embodiment, the different SMs440may be configured to execute different shader programs concurrently. For example, a first subset of SMs440may be configured to execute a vertex shader program while a second subset of SMs440may be configured to execute a pixel shader program. The first subset of SMs440processes vertex data to produce processed vertex data and writes the processed vertex data to the L2 cache460and/or the memory304. After the processed vertex data is rasterized (i.e., transformed from three-dimensional data into two-dimensional data in screen space) to produce fragment data, the second subset of SMs440executes a pixel shader to produce processed fragment data, which is then blended with other processed fragment data and written to the frame buffer in memory304. The vertex shader program and pixel shader program may execute concurrently, processing different data from the same scene in a pipelined fashion until all of the model data for the scene has been rendered to the frame buffer. Then, the contents of the frame buffer are transmitted to a display controller for display on a display device.

The PPU300may be included in a desktop computer, a laptop computer, a tablet computer, a smart-phone (e.g., a wireless, hand-held device), personal digital assistant (PDA), a digital camera, a hand-held electronic device, and the like. In one embodiment, the PPU300is embodied on a single semiconductor substrate. In another embodiment, the PPU300is included in a system-on-a-chip (SoC) along with one or more other logic units such as a reduced instruction set computer (RISC) CPU, a memory management unit (MMU), a digital-to-analog converter (DAC), and the like.

In one embodiment, the PPU300may be included on a graphics card that includes one or more memory devices304such as GDDR5 SDRAM. The graphics card may be configured to interface with a PCIe slot on a motherboard of a desktop computer that includes, e.g., a northbridge chipset and a southbridge chipset. In yet another embodiment, the PPU300may be an integrated graphics processing unit (iGPU) included in the chipset (i.e., Northbridge) of the motherboard.

Various programs may be executed within the PPU300in order to implement the various layers of a neural network. For example, the device driver may launch a kernel on the PPU300to implement the neural network on one SM440(or multiple SMs440). The device driver (or the initial kernel executed by the PPU300) may also launch other kernels on the PPU300to perform other layers of the neural network. In addition, some of the layers of the neural network may be implemented on fixed unit hardware implemented within the PPU300. It will be appreciated that results from one kernel may be processed by one or more intervening fixed function hardware units before being processed by a subsequent kernel on an SM440.

Exemplary System

FIG. 6illustrates an exemplary system600in which the various architecture and/or functionality of the various previous embodiments may be implemented. The exemplary system600may be configured to support reinforcement learned importance sampling to generate light transport paths.

As shown, a system600is provided including at least one central processor601that is connected to a communication bus602. The communication bus602may be implemented using any suitable protocol, such as PCI (Peripheral Component Interconnect), PCI-Express, AGP (Accelerated Graphics Port), HyperTransport, or any other bus or point-to-point communication protocol(s). In one embodiment, the communication bus602is the system bus302shown inFIG. 3. The system600also includes a main memory604. Control logic (software) and data are stored in the main memory604which may take the form of random access memory (RAM).

The system600also includes input devices612, a graphics processor606, and a display608, i.e. a conventional CRT (cathode ray tube), LCD (liquid crystal display), LED (light emitting diode), plasma display or the like. User input may be received from the input devices612, e.g., keyboard, mouse, touchpad, microphone, and the like. In one embodiment, the graphics processor606may include a plurality of shader modules, a rasterization module, etc. Each of the foregoing modules may even be situated on a single semiconductor platform to form a graphics processing unit (GPU).

Computer programs, or computer control logic algorithms, may be stored in the main memory604and/or the secondary storage610. Such computer programs, when executed, enable the system600to perform various functions. The memory604, the storage610, and/or any other storage are possible examples of computer-readable media.

In one embodiment, the architecture and/or functionality of the various previous figures may be implemented in the context of the central processor601, the graphics processor606, an integrated circuit (not shown) that is capable of at least a portion of the capabilities of both the central processor601and the graphics processor606, a chipset (i.e., a group of integrated circuits designed to work and sold as a unit for performing related functions, etc.), and/or any other integrated circuit for that matter.

Further, while not shown, the system600may be coupled to a network (e.g., a telecommunications network, local area network (LAN), wireless network, wide area network (WAN) such as the Internet, peer-to-peer network, cable network, or the like) for communication purposes.