Skip to content

Commit 8af185e

Browse files
fix bug in pushing push constants of non-square matrices that didnt take row_major into account properly
1 parent 5947dd0 commit 8af185e

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

examples_tests/22.RaytracedAO/dirty_source/ExtraCrap.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ void Renderer::init(const SAssetBundle& meshes,
630630

631631
// set up raycount buffer for RR
632632
{
633-
m_rayCountBuffer.buffer = m_driver->createFilledDeviceLocalGPUBufferOnDedMem(sizeof(uint32_t),&raygenBufferSize);
633+
m_rayCountBuffer.buffer = m_driver->createFilledDeviceLocalGPUBufferOnDedMem(sizeof(uint32_t),&m_maxRaysPerDispatch);
634634
m_rayCountBuffer.asRRBuffer = m_rrManager->linkBuffer(m_rayCountBuffer.buffer.get(), CL_MEM_READ_ONLY);
635635

636636
ocl::COpenCLHandler::ocl.pclEnqueueAcquireGLObjects(m_rrManager->getCLCommandQueue(), 1u, &m_rayCountBuffer.asRRBuffer.second, 0u, nullptr, nullptr);
@@ -1028,17 +1028,17 @@ void Renderer::render(nbl::ITimer* timer)
10281028
m_cullPushConstants.currentCommandBufferIx ^= 0x01u;
10291029
}
10301030

1031-
// generate rays
1031+
// generate rays ( TODO: move the camera part)
10321032
{
10331033
const auto cameraPosition = core::vectorSIMDf().set(camera->getAbsolutePosition());
10341034
{
10351035
auto frustum = camera->getViewFrustum();
1036-
m_raytraceCommonData.frustumCorners.rows[1] = frustum->getFarLeftDown();
1037-
m_raytraceCommonData.frustumCorners.rows[0] = frustum->getFarRightDown()-m_raytraceCommonData.frustumCorners.rows[1];
1038-
m_raytraceCommonData.frustumCorners.rows[1] -= cameraPosition;
1039-
m_raytraceCommonData.frustumCorners.rows[3] = frustum->getFarLeftUp();
1040-
m_raytraceCommonData.frustumCorners.rows[2] = frustum->getFarRightUp()-m_raytraceCommonData.frustumCorners.rows[3];
1041-
m_raytraceCommonData.frustumCorners.rows[3] -= cameraPosition;
1036+
core::matrix4SIMD corners;
1037+
corners[0] = frustum->getFarLeftDown()-cameraPosition;
1038+
corners[1] = frustum->getFarRightDown()-cameraPosition-corners[0];
1039+
corners[2] = frustum->getFarLeftUp()-cameraPosition;
1040+
corners[3] = frustum->getFarRightUp()-cameraPosition-corners[2];
1041+
m_raytraceCommonData.frustumCorners = core::transpose(corners).extractSub3x4();
10421042
}
10431043
camera->getViewMatrix().getSub3x3InverseTranspose(m_raytraceCommonData.normalMatrixAndCameraPos);
10441044
m_raytraceCommonData.normalMatrixAndCameraPos.setTranslation(cameraPosition);
@@ -1066,7 +1066,7 @@ void Renderer::render(nbl::ITimer* timer)
10661066
else
10671067
glFinish();
10681068

1069-
if (false) // TODO
1069+
if (true)
10701070
{
10711071
auto commandQueue = m_rrManager->getCLCommandQueue();
10721072

include/nbl/builtin/glsl/ext/RadeonRays/intersection.glsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef __NBL_EXT_RADEON_RAYS_INTERSECTION_INCLUDED__
2-
#define __NBL_EXT_RADEON_RAYS_INTERSECTION_INCLUDED__
1+
#ifndef _NBL_EXT_RADEON_RAYS_INTERSECTION_INCLUDED_
2+
#define _NBL_EXT_RADEON_RAYS_INTERSECTION_INCLUDED_
33

44
// for the love of god, lets optimize this into 16 bytes
55
struct nbl_glsl_ext_RadeonRays_Intersection

src/nbl/video/IOpenGLPipeline.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class IOpenGLPipeline
7373

7474
uint8_t* valueptr = state+m.offset;
7575

76-
uint32_t arrayStride = 0u;
76+
uint32_t arrayStride = 0u; // TODO: @Crisspl this calculation is 100% wrong with `row_major` and arrays of matrices (for both std140 and std430)
7777
{
7878
uint32_t arrayStride1 = 0u;
7979
if (is_scalar_or_vec())
@@ -100,8 +100,8 @@ class IOpenGLPipeline
100100
// pack the constant data as OpenGL uniform update functions expect packed arrays
101101
{
102102
const bool isRowMajor = is_scalar_or_vec() || m.rowMajor;
103-
const uint32_t rowOrColCnt = isRowMajor ? m.mtxColCnt : m.mtxRowCnt;
104-
const uint32_t len = isRowMajor ? m.mtxRowCnt : m.mtxColCnt;
103+
const uint32_t rowOrColCnt = isRowMajor ? m.mtxRowCnt : m.mtxColCnt;
104+
const uint32_t len = isRowMajor ? m.mtxColCnt : m.mtxRowCnt;
105105
for (uint32_t i = 0u; i < count; ++i)
106106
for (uint32_t c = 0u; c < rowOrColCnt; ++c)
107107
{

0 commit comments

Comments
 (0)