Skip to content

Commit 7cc4679

Browse files
committed
Merge with irrlichtbaw-merge branch
2 parents e7a0900 + f76e73e commit 7cc4679

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1492
-1691
lines changed

.github/workflows/repo_mirroring_workflow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
jobs:
99
repo-sync:
10-
runs-on: self-hosted
10+
runs-on: ubuntu-latest
1111
steps:
1212
- uses: actions/checkout@v2
1313
with:

examples_tests/22.RaytracedAO/InstanceDataPerCamera.glsl

Lines changed: 0 additions & 12 deletions
This file was deleted.
-503 KB
Binary file not shown.

examples_tests/22.RaytracedAO/common.glsl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,35 @@
33

44
#define MAX_ACCUMULATED_SAMPLES (1024*1024)
55

6+
#define WORKGROUP_SIZE 256
67

78
#ifdef __cplusplus
9+
#define uint uint32_t
10+
struct uvec2
11+
{
12+
uint32_t x,y;
13+
};
14+
struct vec2
15+
{
16+
float x,y;
17+
};
18+
struct vec3
19+
{
20+
float x,y,z;
21+
};
822
#define mat4 nbl::core::matrix4SIMD
923
#define mat4x3 nbl::core::matrix3x4SIMD
1024
#endif
1125

1226

27+
struct RaytraceShaderCommonData_t
28+
{
29+
uvec2 imageDimensions;
30+
uint samplesPerPixelPerDispatch;
31+
uint samplesPerRowPerDispatch;
32+
};
33+
34+
1335
struct SLight
1436
{
1537
#ifdef __cplusplus
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#version 430 core
2+
3+
4+
#include "drawCommon.glsl"
5+
layout(local_size_x = WORKGROUP_SIZE) in;
6+
7+
8+
#include <nbl/builtin/glsl/utils/indirect_commands.glsl>
9+
layout(set=1, binding=0, std430, row_major) restrict readonly buffer PerInstanceStatic
10+
{
11+
ObjectStaticData_t staticData[];
12+
};
13+
layout(set=1, binding=1, row_major) writeonly restrict buffer PerInstancePerCamera
14+
{
15+
DrawData_t data[];
16+
} instanceDataPerCamera;
17+
layout(set=1, binding=2, std430, row_major) restrict readonly buffer PerInstanceCull
18+
{
19+
CullData_t cullData[];
20+
};
21+
layout(set=1, binding=3, std430) restrict coherent buffer IndirectDraws
22+
{
23+
nbl_glsl_DrawElementsIndirectCommand_t draws[];
24+
} commandBuff[2];
25+
26+
27+
28+
layout(push_constant, row_major) uniform PushConstants
29+
{
30+
CullShaderData_t data;
31+
} pc;
32+
33+
34+
35+
#include <nbl/builtin/glsl/utils/culling.glsl>
36+
#include <nbl/builtin/glsl/utils/transform.glsl>
37+
38+
39+
// base instance remains unchanged
40+
// we just do atomic add on the instance count
41+
void main()
42+
{
43+
uint globalObjectID = gl_GlobalInvocationID.x;
44+
if (globalObjectID>=pc.data.maxObjectCount)
45+
return;
46+
47+
const mat4x3 worldMatrix = cullData[globalObjectID].worldMatrix;
48+
const uint drawID = cullData[globalObjectID].drawID;
49+
50+
// clear drawcount for next buffer
51+
commandBuff[pc.data.currentCommandBufferIx^0x1u].draws[drawID].instanceCount = 0u;
52+
53+
// cull
54+
const mat4 MVP = nbl_glsl_pseudoMul4x4with4x3(pc.data.viewProjMatrix,worldMatrix);
55+
bool notCulled = true;
56+
if (false)
57+
{
58+
mat2x3 bbox;
59+
bbox[0] = cullData[globalObjectID].aabbMinEdge;
60+
bbox[1] = cullData[globalObjectID].aabbMaxEdge;
61+
notCulled = nbl_glsl_couldBeVisible(MVP,bbox);
62+
}
63+
64+
if (notCulled)
65+
{
66+
const uint instanceID = atomicAdd(commandBuff[pc.data.currentCommandBufferIx].draws[drawID].instanceCount,1u)+cullData[globalObjectID].baseInstance;
67+
68+
instanceDataPerCamera.data[instanceID].MVP = MVP;
69+
instanceDataPerCamera.data[instanceID].detMVP = pc.data.viewProjDeterminant*staticData[globalObjectID].detWorldMatrix;
70+
instanceDataPerCamera.data[instanceID].objectID = globalObjectID;
71+
}
72+
}

0 commit comments

Comments
 (0)