Runs a single iteration of the ground truth render thread. This function will compute a single radiance for every pixel within a tile, and blend with with the previous result.
| 1097 | // Runs a single iteration of the ground truth render thread. This function will compute |
| 1098 | // a single radiance for every pixel within a tile, and blend with with the previous result. |
| 1099 | static bool RenderDriver(RenderThreadContext& context) |
| 1100 | { |
| 1101 | if(context.CurrNumTiles == 0) |
| 1102 | return false; |
| 1103 | |
| 1104 | const uint64 tileIdx = InterlockedIncrement64(context.CurrTile) - 1; |
| 1105 | const uint64 passIdx = tileIdx / context.CurrNumTiles; |
| 1106 | const uint64 passTileIdx = tileIdx % context.CurrNumTiles; |
| 1107 | |
| 1108 | const uint64 sqrtNumSamples = context.CurrNumSamples; |
| 1109 | const uint64 numSamplesPerPixel = sqrtNumSamples * sqrtNumSamples; |
| 1110 | if(passIdx >= numSamplesPerPixel) |
| 1111 | return false; |
| 1112 | |
| 1113 | const uint64 numPixelsPerTile = TileSize * TileSize; |
| 1114 | |
| 1115 | const Float4x4 viewProjInv = context.ViewProjInv; |
| 1116 | const uint64 screenWidth = context.OutputWidth; |
| 1117 | const uint64 screenHeight = context.OutputHeight; |
| 1118 | const uint64 numTilesX = (screenWidth + (TileSize - 1)) / TileSize; |
| 1119 | const uint64 numTilesY = (screenHeight + (TileSize - 1)) / TileSize; |
| 1120 | const uint64 tileX = passTileIdx % numTilesX; |
| 1121 | const uint64 tileY = passTileIdx / numTilesX; |
| 1122 | const uint64 startX = tileX * TileSize; |
| 1123 | const uint64 startY = tileY * TileSize; |
| 1124 | const uint64 endX = std::min(startX + TileSize, screenWidth); |
| 1125 | const uint64 endY = std::min(startY + TileSize, screenHeight); |
| 1126 | |
| 1127 | const Float3x3 cameraRot = context.CameraOrientation.ToFloat3x3(); |
| 1128 | const Float3 cameraX = cameraRot.Right(); |
| 1129 | const Float3 cameraY = cameraRot.Up(); |
| 1130 | |
| 1131 | const float focusDistance = AppSettings::FocusDistance; |
| 1132 | const float apertureSize = AppSettings::ApertureWidth; |
| 1133 | |
| 1134 | const float numSides = float(AppSettings::NumBlades); |
| 1135 | const float polyAmt = AppSettings::BokehPolygonAmount; |
| 1136 | |
| 1137 | const uint64 passIdxX = passIdx % sqrtNumSamples; |
| 1138 | const uint64 passIdxY = passIdx / sqrtNumSamples; |
| 1139 | |
| 1140 | const bool32 enableDOF = AppSettings::EnableDOF; |
| 1141 | |
| 1142 | const uint64 numThreads = context.Samples->size(); |
| 1143 | const IntegrationSamples& samples = (*context.Samples)[passTileIdx % numThreads]; |
| 1144 | |
| 1145 | const int32 pathLength = AppSettings::EnableIndirectLighting ? AppSettings::MaxRenderPathLength : 2; |
| 1146 | |
| 1147 | uint64 tilePixelIdx = 0; |
| 1148 | for(uint64 y = startY; y < endY; ++y) |
| 1149 | { |
| 1150 | for(uint64 x = startX; x < endX; ++x) |
| 1151 | { |
| 1152 | const uint64 pixelIdx = (y * screenWidth + x); |
| 1153 | IntegrationSampleSet sampleSet; |
| 1154 | sampleSet.Init(samples, tilePixelIdx, passIdx); |
| 1155 | |
| 1156 | Float2 pixelSample = sampleSet.Pixel(); |
no test coverage detected