Skip to content

Commit 24cccf6

Browse files
committed
Resolved conflicts
2 parents d1a6017 + e7a536b commit 24cccf6

File tree

176 files changed

+10628
-5253
lines changed

Some content is hidden

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

176 files changed

+10628
-5253
lines changed

3rdparty/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ update_git_submodule(./openssl)
2424
update_git_submodule(./libjpeg-turbo)
2525
update_git_submodule(./libjpeg) # soon to be killed
2626
update_git_submodule(./parallel-hashmap)
27+
update_git_submodule(./gli)
2728
# exceptions that get automatically cloned
2829
update_git_submodule(./glm)
2930
update_git_submodule(./freetype2)
@@ -444,6 +445,9 @@ if (NBL_COMPILE_WITH_CUDA)
444445
endif()
445446

446447
set(NBL_3RDPARTY_TARGETS
448+
RadeonRays
449+
CLW
450+
Calc
447451
lzma
448452
lz4
449453
aesGladman
@@ -497,4 +501,4 @@ install(
497501
DIRECTORY ./parallel-hashmap/parallel_hashmap
498502
DESTINATION ./relwithdebinfo/include/parallel-hashmap
499503
CONFIGURATIONS RelWithDebInfo
500-
)
504+
)

3rdparty/spirv_cross

Submodule spirv_cross updated 93 files

cmake/common.cmake

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function(update_git_submodule _PATH)
2222
endfunction()
2323

2424

25-
# REDO THIS WHOLE THING AS FUNCTIONS
25+
# TODO: REDO THIS WHOLE THING AS FUNCTIONS
2626
# https://github.com/buildaworldnet/IrrlichtBAW/issues/311 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
2727

2828
# Macro creating project for an executable
@@ -251,6 +251,7 @@ macro(irr_create_ext_library_project EXT_NAME LIB_HEADERS LIB_SOURCES LIB_INCLUD
251251
)
252252
endmacro()
253253

254+
# End of TODO, rest are all functions
254255

255256
function(irr_get_conf_dir _OUTVAR _CONFIG)
256257
string(TOLOWER ${_CONFIG} CONFIG)
@@ -281,3 +282,47 @@ function(irr_install_config_header _CONF_HDR_NAME)
281282
install(FILES ${file_deb} DESTINATION debug/include CONFIGURATIONS Debug)
282283
install(FILES ${file_relWithDebInfo} DESTINATION relwithdebinfo/include CONFIGURATIONS RelWithDebInfo)
283284
endfunction()
285+
286+
287+
# TODO: check the license for this https://gist.github.com/oliora/4961727299ed67337aba#gistcomment-3494802
288+
289+
# Start to track variables for change or adding.
290+
# Note that variables starting with underscore are ignored.
291+
macro(start_tracking_variables_for_propagation_to_parent)
292+
get_cmake_property(_fnvtps_cache_vars CACHE_VARIABLES)
293+
get_cmake_property(_fnvtps_old_vars VARIABLES)
294+
295+
foreach(_i ${_fnvtps_old_vars})
296+
if (NOT "x${_i}" MATCHES "^x_.*$")
297+
list(FIND _fnvtps_cache_vars ${_i} _fnvtps_is_in_cache)
298+
if(${_fnvtps_is_in_cache} EQUAL -1)
299+
set("_fnvtps_old${_i}" ${${_i}})
300+
#message(STATUS "_fnvtps_old${_i} = ${_fnvtps_old${_i}}")
301+
endif()
302+
endif()
303+
endforeach()
304+
endmacro()
305+
306+
# forward_changed_variables_to_parent_scope([exclusions])
307+
# Forwards variables that was added/changed since last call to start_track_variables() to the parent scope.
308+
# Note that variables starting with underscore are ignored.
309+
macro(propagate_changed_variables_to_parent_scope)
310+
get_cmake_property(_fnvtps_cache_vars CACHE_VARIABLES)
311+
get_cmake_property(_fnvtps_vars VARIABLES)
312+
set(_fnvtps_cache_vars ${_fnvtps_cache_vars} ${ARGN})
313+
314+
foreach(_i ${_fnvtps_vars})
315+
if (NOT "x${_i}" MATCHES "^x_.*$")
316+
list(FIND _fnvtps_cache_vars ${_i} _fnvtps_is_in_cache)
317+
318+
if (${_fnvtps_is_in_cache} EQUAL -1)
319+
list(FIND _fnvtps_old_vars ${_i} _fnvtps_is_old)
320+
321+
if(${_fnvtps_is_old} EQUAL -1 OR NOT "${${_i}}" STREQUAL "${_fnvtps_old${_i}}")
322+
set(${_i} ${${_i}} PARENT_SCOPE)
323+
#message(STATUS "forwarded var ${_i}")
324+
endif()
325+
endif()
326+
endif()
327+
endforeach()
328+
endmacro()

examples_tests/03.GPU_Mesh/main.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,9 @@ struct VertexStruct
3030
const char* vertexSource = R"===(
3131
#version 430 core
3232
33-
#include "irr/builtin/glsl/broken_driver_workarounds/amd.glsl"
34-
3533
layout(location = 0) in vec4 vPos; //only a 3d position is passed from irrlicht, but last (the W) coordinate gets filled with default 1.0
3634
layout(location = 1) in vec4 vCol;
3735
38-
#include <irr/builtin/glsl/broken_driver_workarounds/amd.glsl>
39-
4036
layout( push_constant, row_major ) uniform Block {
4137
mat4 modelViewProj;
4238
} PushConstants;
@@ -45,7 +41,7 @@ layout(location = 0) out vec4 Color; //per vertex output color, will be interpol
4541
4642
void main()
4743
{
48-
gl_Position = irr_builtin_glsl_workaround_AMD_broken_row_major_qualifier(PushConstants.modelViewProj)*vPos; //only thing preventing the shader from being core-compliant
44+
gl_Position = PushConstants.modelViewProj*vPos; //only thing preventing the shader from being core-compliant
4945
Color = vCol;
5046
}
5147
)===";

examples_tests/08.HardwareInstancing/clearCameraDrawcalls.comp

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
#version 430 core
2+
3+
#include "common.glsl"
4+
layout(local_size_x = _IRR_GLSL_WORKGROUP_SIZE_) in;
5+
6+
shared uint scratch[_IRR_GLSL_WORKGROUP_SIZE_];
7+
#define _IRR_GLSL_SCRATCH_SHARED_DEFINED_ scratch
8+
#define _IRR_GLSL_SCRATCH_SHARED_SIZE_DEFINED_ _IRR_GLSL_WORKGROUP_SIZE_
9+
#include "shaderCommon.glsl"
10+
11+
12+
// TODO: figure out the descirptor set assignment of the resources
13+
layout(set = 0, binding = 0, std430, row_major) restrict readonly buffer Objects
14+
{
15+
SceneNode_t objects[];
16+
};
17+
layout(set = 0, binding = 1, std430) restrict readonly buffer Meshes
18+
{
19+
Mesh_t meshes[];
20+
};
21+
layout(set = 0, binding = 2, std430) restrict readonly buffer MeshBuffers
22+
{
23+
MeshBuffer_t meshes[];
24+
};
25+
26+
layout(set = 1, binding = 0, std430) restrict coherent buffer IndirectDispatches
27+
{
28+
irr_glsl_DispatchIndirectCommand_t histogramDispatch;
29+
irr_glsl_DispatchIndirectCommand_t expandDispatch;
30+
uint visibleMeshesCount;
31+
};
32+
layout(set = 1, binding = 1, std430, row_major) restrict writeonly buffer VisibleMeshes
33+
{
34+
VisibleMesh_t visibleMeshes[];
35+
};
36+
layout(set = 1, binding = 2, std430) restrict writeonly buffer VisibleMeshBuffersHistogram
37+
{
38+
uint visibleMeshBuffersHistogram[];
39+
};
40+
41+
layout(set = 2, binding = 0, std140, row_major) uniform Cameras
42+
{
43+
// NOTE: could be an unsized array and we could use `gl_GlobalInvocationID.y` to index cameras (or subdivide the X dimension of a workgroup), but then should probably allow separate object indices per camera
44+
Camera_t camera;
45+
};
46+
layout(set = 2, binding = 1, std430) restrict readonly buffer ObjectIndexBuffer
47+
{
48+
uint objectUUIDs[];
49+
};
50+
layout(set = 2, binding = 2, std430) restrict readonly buffer LoDData
51+
{
52+
uint meshLoDData[];
53+
};
54+
layout(set = 2, binding = 3, std430) restrict readonly buffer InIndirectCommandBuffer
55+
{
56+
uint data[];
57+
} inIndirectCommandBuffer;
58+
layout(set = 2, binding = 4, std430) restrict writeonly buffer OutIndirectCommandBuffer
59+
{
60+
uint data[];
61+
} outIndirectCommandBuffer;
62+
63+
64+
layout(push_constant) uniform PushConstants
65+
{
66+
uint objectCount;
67+
uint drawDataArrayDWORDSize;
68+
} pc;
69+
70+
71+
72+
73+
void clearDrawcalls()
74+
{
75+
uint dword = gl_GlobalInvocationID.x;
76+
if (dword<pc.drawDataArrayDWORDSize)
77+
outIndirectCommandBuffer.data[camera.nextFrameMDIDWORDOffset+dword] = inIndirectCommandBuffer.data[camera.sourceMDIDWORDOffset+dword];
78+
}
79+
80+
void cullObjects()
81+
{
82+
Mesh_t mesh; mesh.meshBuffersCount = 0u;
83+
mat4 modelViewProjectionMatrix;
84+
uint objectUUID;
85+
86+
if (gl_GlobalInvocationID.x<pc.objectCount)
87+
{
88+
objectUUID = objectUUIDs[gl_GlobalInvocationID.x];
89+
90+
mat4x3 worldMatrix = irr_builtin_glsl_workaround_AMD_broken_row_major_qualifier(objects[objectUUID].worldTransform);
91+
92+
int lod = objects[objectUUID].LoDLevelCount;
93+
{
94+
const vec3 toCamera = vec3(camera.posX,camera.posY,camera.posZ)-worldMatrix[3];
95+
const float distanceSq = dot(toCamera,toCamera);
96+
97+
const uint levelsLoD = lod;
98+
const uint distancesOffset = objects[objectUUID].LoDDistancesSqOffset;
99+
for (uint i=0; i<lod; i++)
100+
if (distanceSq<uintBitsToFloat(meshLoDData[distancesOffset+i]))
101+
lod = i;
102+
}
103+
104+
if (lod<levelsLoD)
105+
{
106+
mesh = meshes[meshLoDData[objects[objectUUID].LoDMeshesOffset+lod]];
107+
108+
modelViewProjectionMatrix = irr_glsl_pseudoMul4x4with4x3(camera.viewProjMatrix,worldMatrix);
109+
110+
mat2x3 bbox;
111+
{
112+
bbox[0] = mesh.MinEdge;
113+
bbox[1] = mesh.MaxEdge;
114+
}
115+
// Somewhere around here we could add occlusion culling (if we had camera Z-Buffer)
116+
if (!irr_glsl_couldBeVisible(modelViewProjectionMatrix,bbox))
117+
mesh.meshBuffersCount = 0u;
118+
}
119+
}
120+
121+
const uint partialMeshBufferHistogram = irr_glsl_workgroupInclusiveAdd(mesh.meshBuffersCount);
122+
barrier();
123+
memoryBarrierShared();
124+
125+
// a boolean inclusive prefix sum to figure out where to store visible object
126+
irr_glsl_workgroupBallot(mesh.meshBuffersCount!=0u);
127+
const uint localOffsetPlus1 = irr_glsl_workgroupBallotInclusiveBitCount();
128+
{
129+
if (gl_LocalInvocationIndex==_IRR_GLSL_WORKGROUP_SIZE_-1u)
130+
scratch[0u] = atomicAdd(visibleMeshesCount,localOffsetPlus1);
131+
barrier();
132+
memoryBarrierShared();
133+
}
134+
const uint outputIndex = scratch[0u]+localOffsetPlus1-1u;
135+
136+
if (mesh.meshBuffersCount!=0u)
137+
{
138+
mat3 worldNormalMatrix = inverse(mat3(
139+
objects[objectUUID].worldNormalMatrixRow0,
140+
objects[objectUUID].worldNormalMatrixRow1,
141+
objects[objectUUID].worldNormalMatrixRow2
142+
));
143+
mat3 normalMatrixT = mat3(camera.viewMatrixInverseRow0,camera.viewMatrixInverseRow1,camera.viewMatrixInverseRow2)*worldNormalMatrix;
144+
145+
visibleMeshes[outputIndex].modelViewProjectionMatrix = modelViewProjectionMatrix;
146+
visibleMeshes[outputIndex].normalMatrixCol0 = normalMatrixT[0];
147+
visibleMeshes[outputIndex].cameraUUID = 0u; // we only support one camera/viewpoint for this demo
148+
visibleMeshes[outputIndex].normalMatrixCol1 = normalMatrixT[1];
149+
visibleMeshes[outputIndex].objectUUID = objectUUID;
150+
visibleMeshes[outputIndex].normalMatrixCol2 = normalMatrixT[2];
151+
visibleMeshes[outputIndex].meshBuffersOffset = mesh.meshBuffersOffset;
152+
153+
visibleMeshBuffersHistogram[outputIndex] = partialMeshBufferHistogram;
154+
}
155+
// set up indirect dispatches
156+
if (gl_LocalInvocationIndex==_IRR_GLSL_WORKGROUP_SIZE_-1u)
157+
{
158+
const uint roundedUpLevel2Groups = outputIndex/_IRR_GLSL_WORKGROUP_SIZE_+1u;
159+
atomicMax(histogramDispatch.num_groups_x,roundedUpLevel2Groups);
160+
}
161+
}
162+
163+
void main()
164+
{
165+
clearDrawcalls();
166+
cullObjects();
167+
}
168+
169+
170+
/**
171+
We know what objects we want to draw with which mesh and for what camera.
172+
Per-camera MDIs have been cleared, and a partial histogram of meshbuffers (in _IRR_GLSL_WORKGROUP_SIZE_ chunks) has been built
173+
174+
visibleMeshes now contains an implicit **scrambled** list of meshbuffer to draw.
175+
176+
177+
in the end they need to be expanded to MeshBuffers sorted by Camera, Pipeline and then Instance (although instance needs not be sorted)
178+
its pointless to sort before expansion, because we can only sort by camera as pipelines are unknown
179+
**/

0 commit comments

Comments
 (0)