Skip to content

Commit cf98437

Browse files
backport some fixes
1 parent 61b5288 commit cf98437

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

examples_tests/22.RaytracedAO/Renderer.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ core::smart_refctd_ptr<IGPUImageView> Renderer::createScreenSizedTexture(E_FORMA
655655
return m_driver->createGPUImageView(std::move(viewparams));
656656
}
657657

658-
constexpr uint16_t m_maxDepth = 5u;
658+
constexpr uint16_t m_maxDepth = 3u;
659659
constexpr uint16_t m_UNUSED_russianRouletteDepth = 5u;
660660
bool extractIntegratorInfo(const ext::MitsubaLoader::CElementIntegrator& integrator, uint32_t &bxdfSamples, uint32_t &maxNEESamples)
661661
{
@@ -869,7 +869,10 @@ void Renderer::init(const SAssetBundle& meshes, core::smart_refctd_ptr<ICPUBuffe
869869
};
870870
auto createEmptyInteropBufferAndSetUpInfo = [&](IGPUDescriptorSet::SDescriptorInfo* info, InteropBuffer& interopBuffer, size_t size) -> void
871871
{
872-
interopBuffer.buffer = m_driver->createDeviceLocalGPUBufferOnDedMem(size);
872+
if (static_cast<COpenGLDriver*>(m_driver)->runningInRenderdoc()) // makes Renderdoc capture the modifications done by OpenCL
873+
interopBuffer.buffer = m_driver->createUpStreamingGPUBufferOnDedMem(size);
874+
else
875+
interopBuffer.buffer = m_driver->createDeviceLocalGPUBufferOnDedMem(size);
873876
interopBuffer.asRRBuffer = m_rrManager->linkBuffer(interopBuffer.buffer.get(), CL_MEM_READ_ONLY);
874877

875878
info->buffer.size = size;
@@ -1359,11 +1362,11 @@ uint32_t Renderer::traceBounce(uint32_t raycount)
13591362
{
13601363
m_driver->copyBuffer(m_rayCountBuffer.get(),m_littleDownloadBuffer.get(),sizeof(uint32_t)*m_raytraceCommonData.rayCountWriteIx,0u,sizeof(uint32_t));
13611364
static_assert(core::isPoT(RAYCOUNT_N_BUFFERING),"Raycount Buffer needs to be PoT sized!");
1362-
m_raytraceCommonData.rayCountWriteIx = (++m_raytraceCommonData.rayCountWriteIx)&RAYCOUNT_N_BUFFERING_MASK;
13631365
glFinish(); // sync CPU to GL
13641366
const uint32_t nextTraceRaycount = *reinterpret_cast<uint32_t*>(m_littleDownloadBuffer->getBoundMemory()->getMappedPointer());
13651367
if (nextTraceRaycount==0u)
13661368
return 0u;
1369+
m_raytraceCommonData.rayCountWriteIx = (++m_raytraceCommonData.rayCountWriteIx)&RAYCOUNT_N_BUFFERING_MASK;
13671370

13681371
auto commandQueue = m_rrManager->getCLCommandQueue();
13691372
const cl_mem clObjects[] = {m_rayBuffer[writeIx].asRRBuffer.second,m_intersectionBuffer[writeIx].asRRBuffer.second};

examples_tests/22.RaytracedAO/closestHit.comp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ void main()
7676
if (_continue)
7777
{
7878
// if we ever support spatially varying emissive, we'll need to hoist barycentric computation and UV fetching to the position fetching
79-
const vec2 compactBary = intersection.uvwt.xy;
79+
const vec2 compactBary = vec2(1.f-intersection.uvwt.x-intersection.uvwt.y,intersection.uvwt.x); // radeon rays is a special boy
8080

8181
const nbl_glsl_xoroshiro64star_state_t scramble_start_state = load_aux_vertex_attrs(compactBary,indices,batchInstanceData,material,outPixelLocation,vertex_depth
8282
#ifdef TEX_PREFETCH_STREAM

examples_tests/22.RaytracedAO/raytraceCommon.glsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ nbl_glsl_xoroshiro64star_state_t load_aux_vertex_attrs(
206206
const vec3 normal = normals*nbl_glsl_barycentric_expand(compactBary);
207207

208208
// init scramble while waiting for getting the instance's normal matrix
209-
const nbl_glsl_xoroshiro64star_state_t scramble_start_state = imageLoad(scramblebuf,ivec3(outPixelLocation,vertex_depth_mod_2)).rg;
209+
const nbl_glsl_xoroshiro64star_state_t scramble_start_state = imageLoad(scramblebuf,ivec3(outPixelLocation,1u/*vertex_depth_mod_2*/)).rg;
210210

211211
// while waiting for the scramble state
212212
normalizedN.x = dot(batchInstanceData.normalMatrixRow0,normal);
@@ -265,7 +265,7 @@ for (uint i=1u; i!=vertex_depth; i++)
265265
// TODO: improve ray offset (maybe using smooth normal wouldn't be a sin)
266266
vec3 geomNormal = cross(dPdBary[0],dPdBary[1]);
267267
const vec3 absGeomNormal = abs(geomNormal);
268-
geomNormal /= max(max(absGeomNormal.x,absGeomNormal.y),max(absGeomNormal.z,0.001f))*32.f;
268+
geomNormal /= max(max(absGeomNormal.x,absGeomNormal.y),max(absGeomNormal.z,0.001f))*64.f;
269269
uint offset = 0u;
270270
for (uint i=0u; i<maxRaysToGen; i++)
271271
if (maxT[i]!=0.f)

0 commit comments

Comments
 (0)