-
Notifications
You must be signed in to change notification settings - Fork 13
Adds tests for the new Morton Code class #187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
f2ea51d
8f4e452
0aedfd9
ea42d5b
2ba08a4
f00bbf6
b2d87c3
c68c336
d906bb2
f05dec4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. t2 but it has dimension of 3 ? |
||
|
||
struct PushConstantData | ||
{ | ||
uint64_t deviceBufferAddress; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,14 +3,16 @@ | |
|
||
[[vk::push_constant]] PushConstantData pushConstants; | ||
|
||
using namespace nbl::hlsl; | ||
|
||
[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); | ||
//accessor.set(0, foo.value); | ||
*/ | ||
uint32_t bar = _static_cast<uint32_t>(0xCAFEDEADDEADBEEF); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC its not gonna be a uint64 literal without |
||
accessor.set(0, bar); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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)); | ||
|
@@ -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; | ||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Przemog1 why is this example testing |
||
|
||
performCpuTests(testInput, expected); | ||
performGpuTests(testInput, expected); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recursion with templates, why not