Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
f2ea51d
Morton code tests
Fletterio Mar 23, 2025
8f4e452
Morton codes creating properly
Fletterio Mar 25, 2025
0aedfd9
All tests passing, HLSL compiles fine!
Fletterio Mar 28, 2025
ea42d5b
Rename example
Fletterio Apr 1, 2025
2ba08a4
Add tests for AddCarry and SUbBorrow intrinsics
Fletterio Apr 1, 2025
f00bbf6
Disable intrinsic tests for uSUbBorrow for the time being, start copy…
Fletterio Apr 7, 2025
b2d87c3
Added extensive tests for Morton codes
Fletterio Apr 24, 2025
c68c336
Done with tests
Fletterio Apr 28, 2025
d906bb2
Merged master
Fletterio Apr 28, 2025
f05dec4
Clarifying comment for blocker issue
Fletterio Apr 28, 2025
b13fdc7
Merge branch 'master' into mortons
Nov 19, 2025
08c898d
Reindex mortons example from 12 to 73
Nov 27, 2025
7f8dd73
Global variable of hlsl to use NBL_CONSTEXPR_INLINE_NSPC_SCOPE_VAR
Nov 28, 2025
43b8634
Add test for operator-
Dec 1, 2025
ba6641f
Use 1, 1, 1 workgroup dimension
Dec 1, 2025
e830c34
Enable previously failed test because of bug in glm
Dec 1, 2025
e35e61d
Example 73 to 15 and fix compile error
Dec 5, 2025
2e5642a
Remove example 73 mortons
Dec 8, 2025
197b46a
Enable second test set
Dec 9, 2025
6692311
Delete fillSecondTestValues
Dec 9, 2025
4287ed1
Fix morton test
Dec 10, 2025
6a7b003
Remove unnecessary code
Dec 10, 2025
f012a1a
Add some comment for the reason we have to CTester
Dec 10, 2025
f415e8c
Remove dummy code
Dec 10, 2025
8f72b9e
Fix compiler warning for shader compilation
Dec 11, 2025
3042409
Add back second test to first in commented form
Dec 12, 2025
7011ea0
Fix example 28 to use select instead of ternary_op
Dec 12, 2025
02eed2e
Fix example 28
Dec 12, 2025
30b4f52
prefix select with hlsl::
Dec 12, 2025
3e443b1
Add nbl prefix to hlsl::select
Dec 12, 2025
84eb1f7
Merge branch 'master' into mortons
Dec 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions 12_Mortons/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
include(common RESULT_VARIABLE RES)
if(NOT RES)
message(FATAL_ERROR "common.cmake not found. Should be in {repo_root}/cmake directory")
endif()

nbl_create_executable_project("" "" "" "" "${NBL_EXECUTABLE_PROJECT_CREATION_PCH_TARGET}")

if(NBL_EMBED_BUILTIN_RESOURCES)
set(_BR_TARGET_ ${EXECUTABLE_NAME}_builtinResourceData)
set(RESOURCE_DIR "app_resources")

get_filename_component(_SEARCH_DIRECTORIES_ "${CMAKE_CURRENT_SOURCE_DIR}" ABSOLUTE)
get_filename_component(_OUTPUT_DIRECTORY_SOURCE_ "${CMAKE_CURRENT_BINARY_DIR}/src" ABSOLUTE)
get_filename_component(_OUTPUT_DIRECTORY_HEADER_ "${CMAKE_CURRENT_BINARY_DIR}/include" ABSOLUTE)

file(GLOB_RECURSE BUILTIN_RESOURCE_FILES RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCE_DIR}" CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${RESOURCE_DIR}/*")
foreach(RES_FILE ${BUILTIN_RESOURCE_FILES})
LIST_BUILTIN_RESOURCE(RESOURCES_TO_EMBED "${RES_FILE}")
endforeach()

ADD_CUSTOM_BUILTIN_RESOURCES(${_BR_TARGET_} RESOURCES_TO_EMBED "${_SEARCH_DIRECTORIES_}" "${RESOURCE_DIR}" "nbl::this_example::builtin" "${_OUTPUT_DIRECTORY_HEADER_}" "${_OUTPUT_DIRECTORY_SOURCE_}")

LINK_BUILTIN_RESOURCES_TO_TARGET(${EXECUTABLE_NAME} ${_BR_TARGET_})
endif()
13 changes: 13 additions & 0 deletions 12_Mortons/app_resources/common.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//#include "nbl/builtin/hlsl/morton.hlsl"
#include "nbl/builtin/hlsl/cpp_compat.hlsl"

NBL_CONSTEXPR uint32_t bufferSize = 256;

// Proper coverage would require writing tests for ALL possible sign, dimensions and width configurations
//using morton_t2 = nbl::hlsl::morton::code<true, 8, 2>; // Fits in an int16_t
using vector_t2 = nbl::hlsl::vector<int16_t, 3>;

struct PushConstantData
{
uint64_t deviceBufferAddress;
};
18 changes: 18 additions & 0 deletions 12_Mortons/app_resources/shader.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "app_resources/common.hlsl"
#include "nbl/builtin/hlsl/bda/legacy_bda_accessor.hlsl"

[[vk::push_constant]] PushConstantData pushConstants;

[numthreads(bufferSize, 1, 1)]
void main(uint32_t3 ID : SV_DispatchThreadID)
{
/*
LegacyBdaAccessor<unsigned_scalar_t> accessor = LegacyBdaAccessor<unsigned_scalar_t>::create(pushConstants.deviceBufferAddress);

morton::code<int32_t, 2> foo = morton::code<int32_t, 2>::create(vector<int32_t, 2>(-32768, -1));

//accessor.set(0, foo.value);
*/
uint32_t bar = _static_cast<uint32_t>(0xCAFEDEADDEADBEEF);
accessor.set(0, bar);
}
28 changes: 28 additions & 0 deletions 12_Mortons/config.json.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"enableParallelBuild": true,
"threadsPerBuildProcess" : 2,
"isExecuted": false,
"scriptPath": "",
"cmake": {
"configurations": [ "Release", "Debug", "RelWithDebInfo" ],
"buildModes": [],
"requiredOptions": []
},
"profiles": [
{
"backend": "vulkan", // should be none
"platform": "windows",
"buildModes": [],
"runConfiguration": "Release", // we also need to run in Debug nad RWDI because foundational example
"gpuArchitectures": []
}
],
"dependencies": [],
"data": [
{
"dependencies": [],
"command": [""],
"outputs": []
}
]
}
418 changes: 418 additions & 0 deletions 12_Mortons/main.cpp

Large diffs are not rendered by default.

50 changes: 50 additions & 0 deletions 12_Mortons/pipeline.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import org.DevshGraphicsProgramming.Agent
import org.DevshGraphicsProgramming.BuilderInfo
import org.DevshGraphicsProgramming.IBuilder

class CStreamingAndBufferDeviceAddressBuilder extends IBuilder
{
public CStreamingAndBufferDeviceAddressBuilder(Agent _agent, _info)
{
super(_agent, _info)
}

@Override
public boolean prepare(Map axisMapping)
{
return true
}

@Override
public boolean build(Map axisMapping)
{
IBuilder.CONFIGURATION config = axisMapping.get("CONFIGURATION")
IBuilder.BUILD_TYPE buildType = axisMapping.get("BUILD_TYPE")

def nameOfBuildDirectory = getNameOfBuildDirectory(buildType)
def nameOfConfig = getNameOfConfig(config)

agent.execute("cmake --build ${info.rootProjectPath}/${nameOfBuildDirectory}/${info.targetProjectPathRelativeToRoot} --target ${info.targetBaseName} --config ${nameOfConfig} -j12 -v")

return true
}

@Override
public boolean test(Map axisMapping)
{
return true
}

@Override
public boolean install(Map axisMapping)
{
return true
}
}

def create(Agent _agent, _info)
{
return new CStreamingAndBufferDeviceAddressBuilder(_agent, _info)
}

return this
13 changes: 13 additions & 0 deletions 22_CppCompat/CIntrinsicsTester.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ class CIntrinsicsTester final : public ITester
testInput.smoothStepEdge0 = realDistributionNeg(mt);
testInput.smoothStepEdge1 = realDistributionPos(mt);
testInput.smoothStepX = realDistribution(mt);
testInput.addCarryA = std::numeric_limits<uint32_t>::max() - uintDistribution(mt);
testInput.addCarryB = uintDistribution(mt);
testInput.subBorrowA = uintDistribution(mt);
testInput.subBorrowB = uintDistribution(mt);

testInput.bitCountVec = int32_t3(intDistribution(mt), intDistribution(mt), intDistribution(mt));
testInput.clampValVec = float32_t3(realDistribution(mt), realDistribution(mt), realDistribution(mt));
Expand Down Expand Up @@ -119,6 +123,10 @@ class CIntrinsicsTester final : public ITester
testInput.refractI = float32_t3(realDistribution(mt), realDistribution(mt), realDistribution(mt));
testInput.refractN = glm::normalize(float32_t3(realDistribution(mt), realDistribution(mt), realDistribution(mt)));
testInput.refractEta = realDistribution(mt);
testInput.addCarryAVec = uint32_t3(std::numeric_limits<uint32_t>::max() - uintDistribution(mt), std::numeric_limits<uint32_t>::max() - uintDistribution(mt), std::numeric_limits<uint32_t>::max() - uintDistribution(mt));
testInput.addCarryBVec = uint32_t3(uintDistribution(mt), uintDistribution(mt), uintDistribution(mt));
testInput.subBorrowAVec = uint32_t3(uintDistribution(mt), uintDistribution(mt), uintDistribution(mt));
testInput.subBorrowBVec = uint32_t3(uintDistribution(mt), uintDistribution(mt), uintDistribution(mt));

// use std library or glm functions to determine expected test values, the output of functions from intrinsics.hlsl will be verified against these values
IntrinsicsTestValues expected;
Expand Down Expand Up @@ -188,6 +196,11 @@ class CIntrinsicsTester final : public ITester
auto inverseGlm = glm::inverse(reinterpret_cast<typename float32_t3x3::Base const&>(testInput.inverse));
expected.inverse = reinterpret_cast<float32_t3x3&>(inverseGlm);

expected.addCarry.result = glm::uaddCarry(testInput.addCarryA, testInput.addCarryB, expected.addCarry.carry);
expected.subBorrow.result = glm::usubBorrow(testInput.subBorrowA, testInput.subBorrowB, expected.subBorrow.borrow);
expected.addCarryVec.result = glm::uaddCarry(testInput.addCarryAVec, testInput.addCarryBVec, expected.addCarryVec.carry);
expected.subBorrowVec.result = glm::usubBorrow(testInput.subBorrowAVec, testInput.subBorrowBVec, expected.subBorrowVec.borrow);

performCpuTests(testInput, expected);
performGpuTests(testInput, expected);
}
Expand Down
Loading