Skip to content

Commit e07e96c

Browse files
bigger batches -> happier BVH
1 parent cedef49 commit e07e96c

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

examples_tests/22.RaytracedAO/Renderer.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ Renderer::InitializationData Renderer::initSceneObjects(const SAssetBundle& mesh
247247
// one instance data per instance of a batch
248248
core::smart_refctd_ptr<ICPUBuffer> newInstanceDataBuffer;
249249

250-
constexpr uint16_t minTrisBatch = 256u;
250+
constexpr uint16_t minTrisBatch = MAX_TRIANGLES_IN_BATCH>>1u;
251251
constexpr uint16_t maxTrisBatch = MAX_TRIANGLES_IN_BATCH;
252252
constexpr uint8_t minVertexSize =
253253
asset::getTexelOrBlockBytesize<asset::EF_R32G32B32_SFLOAT>()+
@@ -474,6 +474,14 @@ Renderer::InitializationData Renderer::initSceneObjects(const SAssetBundle& mesh
474474
}
475475
}
476476
}
477+
printf("Scene Bound: %f,%f,%f -> %f,%f,%f\n",
478+
m_sceneBound.MinEdge.X,
479+
m_sceneBound.MinEdge.Y,
480+
m_sceneBound.MinEdge.Z,
481+
m_sceneBound.MaxEdge.X,
482+
m_sceneBound.MaxEdge.Y,
483+
m_sceneBound.MaxEdge.Z
484+
);
477485
instanceDataDescPtr->buffer = {0u,cullData.size()*sizeof(ext::MitsubaLoader::instance_data_t)};
478486
instanceDataDescPtr->desc = std::move(newInstanceDataBuffer); // TODO: trim the buffer
479487
retval.mdiFirstIndices.resize(cullData.size());
@@ -1131,6 +1139,7 @@ void Renderer::deinit()
11311139

11321140
m_raytraceCommonData = {vec3(),0,0,0,0u};
11331141
m_staticViewData = {{0.f,0.f,0.f},0u,{0u,0u},0u,0u};
1142+
m_totalRaysCast = 0ull;
11341143
m_rcpPixelSize = {0.f,0.f};
11351144
m_framesDispatched = 0u;
11361145
std::fill_n(m_prevView.pointer(),12u,0.f);
@@ -1363,6 +1372,7 @@ uint32_t Renderer::traceBounce(uint32_t raycount)
13631372
const uint32_t nextTraceRaycount = *reinterpret_cast<uint32_t*>(m_littleDownloadBuffer->getBoundMemory()->getMappedPointer());
13641373
if (nextTraceRaycount==0u)
13651374
return 0u;
1375+
m_totalRaysCast += nextTraceRaycount;
13661376
m_raytraceCommonData.rayCountWriteIx = (++m_raytraceCommonData.rayCountWriteIx)&RAYCOUNT_N_BUFFERING_MASK;
13671377

13681378
auto commandQueue = m_rrManager->getCLCommandQueue();

examples_tests/22.RaytracedAO/Renderer.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ class Renderer : public nbl::core::IReferenceCounted, public nbl::core::Interfac
4646
const auto framesDispatched = static_cast<uint64_t>(m_framesDispatched);
4747
return framesDispatched*samplesPerDispatch;
4848
}
49+
uint64_t getTotalRaysCast() const
50+
{
51+
return m_totalRaysCast;
52+
}
4953

5054
//! Brief guideline to good path depth limits
5155
// Want to see stuff with indirect lighting on the other side of a pane of glass
@@ -132,6 +136,7 @@ class Renderer : public nbl::core::IReferenceCounted, public nbl::core::Interfac
132136
nbl::core::aabbox3df m_sceneBound;
133137
uint32_t m_framesDispatched;
134138
vec2 m_rcpPixelSize;
139+
uint64_t m_totalRaysCast;
135140
StaticViewData_t m_staticViewData;
136141
RaytraceShaderCommonData_t m_raytraceCommonData;
137142

examples_tests/22.RaytracedAO/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#define RAYCOUNT_N_BUFFERING 4
66
#define RAYCOUNT_N_BUFFERING_MASK (RAYCOUNT_N_BUFFERING-1)
77

8-
#define MAX_TRIANGLES_IN_BATCH 512
8+
#define MAX_TRIANGLES_IN_BATCH 16384
99
#define MAX_ACCUMULATED_SAMPLES 0x10000
1010

1111

examples_tests/22.RaytracedAO/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,9 @@ int main()
306306
{
307307
std::wostringstream str;
308308
auto samples = renderer->getTotalSamplesComputed();
309+
auto rays = renderer->getTotalRaysCast();
309310
str << L"Raytraced Shadows Demo - Nabla Engine MegaSamples: " << samples/1000000ull << " MRay/s: "
310-
<< double(samples)/double(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now()-start).count());
311+
<< double(rays)/double(std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::steady_clock::now()-start).count());
311312

312313
device->setWindowCaption(str.str());
313314
lastFPSTime = time;

0 commit comments

Comments
 (0)