MCPcopy Create free account
hub / github.com/RenderKit/oidn / runBenchmark

Function runBenchmark

apps/oidnBenchmark.cpp:104–238  ·  view source on GitHub ↗

Runs a benchmark and returns the total runtime

Source from the content-addressed store, hash-verified

102
103// Runs a benchmark and returns the total runtime
104double runBenchmark(DeviceRef& device, const Benchmark& bench)
105{
106 std::cout << bench.name << " ..." << std::flush;
107
108 // Initialize the filter and the buffers
109 FilterRef filter = device.newFilter(bench.filter.c_str());
110 Random rng;
111
112 std::shared_ptr<ImageBuffer> input;
113
114 std::shared_ptr<ImageBuffer> albedo;
115 if (bench.hasInput("alb") || bench.hasInput("calb"))
116 {
117 input = albedo = newImage(device, bench.width, bench.height);
118 initImage(*albedo, rng, 0.f, 1.f);
119 filter.setImage("albedo", albedo->getBuffer(), albedo->getFormat(), bench.width, bench.height);
120 }
121
122 std::shared_ptr<ImageBuffer> normal;
123 if (bench.hasInput("nrm") || bench.hasInput("cnrm"))
124 {
125 input = normal = newImage(device, bench.width, bench.height);
126 initImage(*normal, rng, -1.f, 1.f);
127 filter.setImage("normal", normal->getBuffer(), normal->getFormat(), bench.width, bench.height);
128 }
129
130 std::shared_ptr<ImageBuffer> color;
131 if (bench.hasInput("hdr"))
132 {
133 input = color = newImage(device, bench.width, bench.height);
134 initImage(*color, rng, 0.f, 100.f);
135 filter.setImage("color", color->getBuffer(), color->getFormat(), bench.width, bench.height);
136 if (bench.filter != "RTLightmap")
137 filter.set("hdr", true);
138 }
139 else if (bench.hasInput("ldr"))
140 {
141 input = color = newImage(device, bench.width, bench.height);
142 initImage(*color, rng, 0.f, 1.f);
143 filter.setImage("color", color->getBuffer(), color->getFormat(), bench.width, bench.height);
144 filter.set("hdr", false);
145 }
146
147 if (bench.hasInput("calb") || bench.hasInput("cnrm"))
148 filter.set("cleanAux", true);
149
150 std::shared_ptr<ImageBuffer> output;
151 if (inplace)
152 output = input;
153 else
154 output = newImage(device, bench.width, bench.height);
155 filter.setImage("output", output->getBuffer(), output->getFormat(), bench.width, bench.height);
156
157 if (quality != Quality::Default)
158 filter.set("quality", quality);
159
160 if (maxMemoryMB >= 0)
161 filter.set("maxMemoryMB", maxMemoryMB);

Callers 1

mainFunction · 0.85

Calls 15

newImageFunction · 0.85
initImageFunction · 0.85
c_strMethod · 0.80
hasInputMethod · 0.80
getBufferMethod · 0.80
getFormatMethod · 0.80
toDeviceAsyncMethod · 0.80
toHostAsyncMethod · 0.80
maxFunction · 0.50
newFilterMethod · 0.45
setImageMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected