aboutsummaryrefslogtreecommitdiff
path: root/test/src
diff options
context:
space:
mode:
authorAnton Novoselov <[email protected]>2017-08-01 12:53:38 +0300
committerAnton Novoselov <[email protected]>2017-08-01 12:53:38 +0300
commit236f03c0b9a4982328ed1201978f7f69d192d9b2 (patch)
treee486f2fa39dba203563895541e92c60ed3e25759 /test/src
parentAdded screens to welcome page (diff)
downloadblast-236f03c0b9a4982328ed1201978f7f69d192d9b2.tar.xz
blast-236f03c0b9a4982328ed1201978f7f69d192d9b2.zip
Blast 1.1 release (windows / linux)
see docs/release_notes.txt for details
Diffstat (limited to 'test/src')
-rw-r--r--test/src/AlignedAllocator.h69
-rw-r--r--test/src/BlastBaseTest.h120
-rw-r--r--test/src/TkBaseTest.h85
-rw-r--r--test/src/perf/BlastBasePerfTest.h36
-rw-r--r--test/src/perf/SolverPerfTests.cpp40
-rw-r--r--test/src/unit/APITests.cpp541
-rw-r--r--test/src/unit/ActorTests.cpp110
-rw-r--r--test/src/unit/AssetTests.cpp410
-rw-r--r--test/src/unit/CoreTests.cpp344
-rw-r--r--test/src/unit/FamilyGraphTests.cpp62
-rw-r--r--test/src/unit/MultithreadingTests.cpp38
-rw-r--r--test/src/unit/SyncTests.cpp43
-rw-r--r--test/src/unit/TkCompositeTests.cpp103
-rw-r--r--test/src/unit/TkTests.cpp258
-rw-r--r--test/src/utils/TaskDispatcher.h28
-rw-r--r--test/src/utils/TestAssets.cpp176
-rw-r--r--test/src/utils/TestAssets.h40
-rw-r--r--test/src/utils/TestProfiler.h52
18 files changed, 1792 insertions, 763 deletions
diff --git a/test/src/AlignedAllocator.h b/test/src/AlignedAllocator.h
deleted file mode 100644
index f8bf3a5..0000000
--- a/test/src/AlignedAllocator.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
-*
-* NVIDIA CORPORATION and its licensors retain all intellectual property
-* and proprietary rights in and to this software, related documentation
-* and any modifications thereto. Any use, reproduction, disclosure or
-* distribution of this software and related documentation without an express
-* license agreement from NVIDIA CORPORATION is strictly prohibited.
-*/
-
-#ifndef ALIGNEDALLOCATOR_H
-#define ALIGNEDALLOCATOR_H
-
-#include "NvPreprocessor.h"
-
-
-/**
-Aligned allocation. First template argument has the signature of stdlib malloc.
-
-Example using malloc and 16-byte alignment:
-
-// b will lie on a 16-byte boundary and point to 50 bytes of usable memory
-void* b = alignedAlloc<malloc,16>(50);
-*/
-template<void*(*allocFn)(size_t), int A>
-void* alignedAlloc(size_t size)
-{
- NV_COMPILE_TIME_ASSERT(A > 0 && A <= 256);
- unsigned char* mem = (unsigned char*)allocFn(size + A);
- const unsigned char offset = (unsigned char)((uintptr_t)A - (uintptr_t)mem % A - 1);
- mem += offset;
- *mem++ = offset;
- return mem;
-};
-
-
-/**
-Version of alignedAlloc specialized 16-byte aligned allocation.
-*/
-template<void*(*allocFn)(size_t)>
-void* alignedAlloc(size_t size)
-{
- return alignedAlloc<allocFn, 16>(size);
-}
-
-
-/**
-Aligned deallocation. First template argument has the signature of stdlib free.
-
-Memory freed using this function MUST have been allocated using alignedAlloc.
-
-Example using free:
-
-// Using the memory pointer b from the example above (for alignedAlloc)
-alignedFree<free>(b);
-*/
-template<void(*freeFn)(void*)>
-void alignedFree(void* block)
-{
- if (block != nullptr)
- {
- unsigned char* mem = (unsigned char*)block;
- const unsigned char offset = *--mem;
- freeFn(mem - offset);
- }
-};
-
-
-#endif // ALIGNEDALLOCATOR_H
diff --git a/test/src/BlastBaseTest.h b/test/src/BlastBaseTest.h
index 2881645..350cd88 100644
--- a/test/src/BlastBaseTest.h
+++ b/test/src/BlastBaseTest.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
-*
-* NVIDIA CORPORATION and its licensors retain all intellectual property
-* and proprietary rights in and to this software, related documentation
-* and any modifications thereto. Any use, reproduction, disclosure or
-* distribution of this software and related documentation without an express
-* license agreement from NVIDIA CORPORATION is strictly prohibited.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef BLASTBASETEST_H
#define BLASTBASETEST_H
@@ -18,56 +36,31 @@
#include "NvBlast.h"
-#include "AlignedAllocator.h"
-
#include "TestAssets.h"
-#include "PxErrorCallback.h"
-#include "PxAllocatorCallback.h"
-
+#include "NvBlastGlobals.h"
#include <ostream>
template<int FailLevel, int Verbosity>
-class BlastBaseTest : public testing::Test, public physx::PxAllocatorCallback, public physx::PxErrorCallback
+class BlastBaseTest : public testing::Test, public Nv::Blast::ErrorCallback
{
public:
- static void* tkAlloc(size_t size)
- {
- Nv::Blast::TkFramework* fw = NvBlastTkFrameworkGet();
- if (fw != nullptr)
- {
- return fw->getAllocatorCallback().allocate(size, nullptr, __FILE__, __LINE__);
- }
- else
- {
- return std::malloc(size);
- }
- }
-
- static void tkFree(void* mem)
+ BlastBaseTest()
{
- Nv::Blast::TkFramework* fw = NvBlastTkFrameworkGet();
- if (fw != nullptr)
- {
- fw->getAllocatorCallback().deallocate(mem);
- }
- else
- {
- std::free(mem);
- }
+ NvBlastGlobalSetErrorCallback(this);
}
// A zeroing alloc with the same signature as malloc
- static void* alloc(size_t size)
+ static void* alignedZeroedAlloc(size_t size)
{
- return memset(alignedAlloc<tkAlloc>(size), 0, size);
+ return memset(NVBLAST_ALLOC(size), 0, size);
}
- static void free(void* mem)
+ static void alignedFree(void* mem)
{
- alignedFree<tkFree>(mem);
+ NVBLAST_FREE(mem);
}
// Message log for blast functions
@@ -96,31 +89,16 @@ public:
}
}
- // PxAllocatorCallback interface
- virtual void* allocate(size_t size, const char* typeName, const char* filename, int line) override
- {
- NV_UNUSED(typeName);
- NV_UNUSED(filename);
- NV_UNUSED(line);
- return alignedAlloc<std::malloc>(size);
- }
-
- // PxAllocatorCallback interface
- virtual void deallocate(void* ptr) override
- {
- alignedFree<std::free>(ptr);
- }
-
- // PxErrorCallback interface
- virtual void reportError(physx::PxErrorCode::Enum code, const char* message, const char* file, int line) override
+ // ErrorCallback interface
+ virtual void reportError(Nv::Blast::ErrorCode::Enum code, const char* message, const char* file, int line) override
{
uint32_t failMask = 0;
switch (FailLevel)
{
case NvBlastMessage::Debug:
- case NvBlastMessage::Info: failMask |= physx::PxErrorCode::eDEBUG_INFO;
- case NvBlastMessage::Warning: failMask |= physx::PxErrorCode::eDEBUG_WARNING;
- case NvBlastMessage::Error: failMask |= physx::PxErrorCode::eABORT | physx::PxErrorCode::eABORT | physx::PxErrorCode::eINTERNAL_ERROR | physx::PxErrorCode::eOUT_OF_MEMORY | physx::PxErrorCode::eINVALID_OPERATION | physx::PxErrorCode::eINVALID_PARAMETER;
+ case NvBlastMessage::Info: failMask |= Nv::Blast::ErrorCode::eDEBUG_INFO;
+ case NvBlastMessage::Warning: failMask |= Nv::Blast::ErrorCode::eDEBUG_WARNING;
+ case NvBlastMessage::Error: failMask |= Nv::Blast::ErrorCode::eABORT | Nv::Blast::ErrorCode::eABORT | Nv::Blast::ErrorCode::eINTERNAL_ERROR | Nv::Blast::ErrorCode::eOUT_OF_MEMORY | Nv::Blast::ErrorCode::eINVALID_OPERATION | Nv::Blast::ErrorCode::eINVALID_PARAMETER;
}
if (!(failMask & code) && Verbosity <= 0)
@@ -131,15 +109,15 @@ public:
std::string output = "NvBlast Test ";
switch (code)
{
- case physx::PxErrorCode::eNO_ERROR: break;
- case physx::PxErrorCode::eDEBUG_INFO: output += "Debug Info"; break;
- case physx::PxErrorCode::eDEBUG_WARNING: output += "Debug Warning"; break;
- case physx::PxErrorCode::eINVALID_PARAMETER: output += "Invalid Parameter"; break;
- case physx::PxErrorCode::eINVALID_OPERATION: output += "Invalid Operation"; break;
- case physx::PxErrorCode::eOUT_OF_MEMORY: output += "Out of Memory"; break;
- case physx::PxErrorCode::eINTERNAL_ERROR: output += "Internal Error"; break;
- case physx::PxErrorCode::eABORT: output += "Abort"; break;
- case physx::PxErrorCode::ePERF_WARNING: output += "Perf Warning"; break;
+ case Nv::Blast::ErrorCode::eNO_ERROR: break;
+ case Nv::Blast::ErrorCode::eDEBUG_INFO: output += "Debug Info"; break;
+ case Nv::Blast::ErrorCode::eDEBUG_WARNING: output += "Debug Warning"; break;
+ case Nv::Blast::ErrorCode::eINVALID_PARAMETER: output += "Invalid Parameter"; break;
+ case Nv::Blast::ErrorCode::eINVALID_OPERATION: output += "Invalid Operation"; break;
+ case Nv::Blast::ErrorCode::eOUT_OF_MEMORY: output += "Out of Memory"; break;
+ case Nv::Blast::ErrorCode::eINTERNAL_ERROR: output += "Internal Error"; break;
+ case Nv::Blast::ErrorCode::eABORT: output += "Abort"; break;
+ case Nv::Blast::ErrorCode::ePERF_WARNING: output += "Perf Warning"; break;
default: FAIL();
}
output += std::string(" message in ") + file + "(" + std::to_string(line) + "): " + message + "\n";
diff --git a/test/src/TkBaseTest.h b/test/src/TkBaseTest.h
index 9ea632b..2980601 100644
--- a/test/src/TkBaseTest.h
+++ b/test/src/TkBaseTest.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
-*
-* NVIDIA CORPORATION and its licensors retain all intellectual property
-* and proprietary rights in and to this software, related documentation
-* and any modifications thereto. Any use, reproduction, disclosure or
-* distribution of this software and related documentation without an express
-* license agreement from NVIDIA CORPORATION is strictly prohibited.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef TKBASETEST_H
#define TKBASETEST_H
@@ -14,17 +32,17 @@
#include "NvBlastTk.h"
#include "NvBlastTkActor.h"
+#include "NvBlastPxCallbacks.h"
#include "BlastBaseTest.h"
#include "NvBlastExtDamageShaders.h"
#include "NvBlastIndexFns.h"
-#include "NvBlastProfiler.h"
+#include "NvBlastExtCustomProfiler.h"
#include "TestProfiler.h"
+#include "NvBlastExtPxTask.h"
-#include "PxAllocatorCallback.h"
-#include "PxErrorCallback.h"
#include "PxCpuDispatcher.h"
#include "PxTask.h"
#include "PxFoundation.h"
@@ -201,9 +219,11 @@ public:
virtual void SetUp() override
{
- m_foundation = PxCreateFoundation(PX_FOUNDATION_VERSION, *this, *this);
+ m_foundation = PxCreateFoundation(PX_FOUNDATION_VERSION, NvBlastGetPxAllocatorCallback(), NvBlastGetPxErrorCallback());
- NvBlastProfilerEnablePlatform(true);
+ NvBlastProfilerSetCallback(&m_profiler);
+ NvBlastProfilerSetDetail(Nv::Blast::ProfilerDetail::LOW);
+ m_profiler.setPlatformEnabled(true);
#if USE_PHYSX_DISPATCHER
PxU32 affinity[] = { 1, 2, 4, 8 };
@@ -213,11 +233,13 @@ public:
m_cpuDispatcher = new TestCpuDispatcher(4);
#endif
- m_taskman = PxTaskManager::createTaskManager(*this, m_cpuDispatcher, nullptr);
+ m_taskman = PxTaskManager::createTaskManager(NvBlastGetPxErrorCallback(), m_cpuDispatcher, nullptr);
+ m_groupTM = ExtGroupTaskManager::create(*m_taskman);
}
virtual void TearDown() override
{
+ m_groupTM->release();
m_cpuDispatcher->release();
if (m_taskman) m_taskman->release();
if (m_foundation) m_foundation->release();
@@ -225,10 +247,7 @@ public:
void createFramework()
{
- TkFrameworkDesc desc;
- desc.allocatorCallback = this;
- desc.errorCallback = this;
- TkFramework* framework = NvBlastTkFrameworkCreate(desc);
+ TkFramework* framework = NvBlastTkFrameworkCreate();
EXPECT_TRUE(framework != nullptr);
EXPECT_EQ(framework, NvBlastTkFrameworkGet());
}
@@ -295,7 +314,7 @@ public:
testAssets.clear();
}
- NvBlastExtRadialDamageDesc getRadialDamageDesc(float x, float y, float z, float minRadius = 10.0f, float maxRadius = 10.0f, float compressive = 10.0f)
+ NvBlastExtRadialDamageDesc getRadialDamageDesc(float x, float y, float z, float minRadius = 10.0f, float maxRadius = 10.0f, float damage = 1.0f)
{
NvBlastExtRadialDamageDesc desc;
desc.position[0] = x;
@@ -304,20 +323,25 @@ public:
desc.minRadius = minRadius;
desc.maxRadius = maxRadius;
- desc.compressive = compressive;
+ desc.damage = damage;
return desc;
}
- NvBlastExtShearDamageDesc getShearDamageDesc(float x, float y, float z, float shearX = 1.0f, float shearY = 0.0f, float shearZ = 0.0f)
+ NvBlastExtShearDamageDesc getShearDamageDesc(float x, float y, float z, float shearX = 1.0f, float shearY = 0.0f, float shearZ = 0.0f, float minRadius = 10.0f, float maxRadius = 10.0f, float damage = 1.0f)
{
NvBlastExtShearDamageDesc desc;
desc.position[0] = x;
desc.position[1] = y;
desc.position[2] = z;
- desc.shear[0] = shearX;
- desc.shear[1] = shearY;
- desc.shear[2] = shearZ;
+ desc.normal[0] = shearX;
+ desc.normal[1] = shearY;
+ desc.normal[2] = shearZ;
+
+ desc.minRadius = minRadius;
+ desc.maxRadius = maxRadius;
+ desc.damage = damage;
+
return desc;
}
@@ -341,13 +365,7 @@ public:
static const NvBlastExtMaterial* getDefaultMaterial()
{
- static NvBlastExtMaterial material = {
- 0.0f,
- 0.0f,
- 0.0f,
- 0.0f,
- 0.0f
- };
+ static NvBlastExtMaterial material;
return &material;
};
@@ -364,6 +382,9 @@ public:
PxTaskManager* m_taskman;
PxFoundation* m_foundation;
+
+ ExtGroupTaskManager* m_groupTM;
+ ExtCustomProfiler m_profiler;
};
diff --git a/test/src/perf/BlastBasePerfTest.h b/test/src/perf/BlastBasePerfTest.h
index 2a4701d..fd0ba74 100644
--- a/test/src/perf/BlastBasePerfTest.h
+++ b/test/src/perf/BlastBasePerfTest.h
@@ -1,12 +1,30 @@
-/*
-* Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved.
-*
-* NVIDIA CORPORATION and its licensors retain all intellectual property
-* and proprietary rights in and to this software, related documentation
-* and any modifications thereto. Any use, reproduction, disclosure or
-* distribution of this software and related documentation without an express
-* license agreement from NVIDIA CORPORATION is strictly prohibited.
-*/
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2017 NVIDIA Corporation. All rights reserved.
+
#ifndef BLASTBASEPERFTEST_H
#define BLASTBASEPERFTEST_H
diff --git a/test/src/perf/SolverPerfTests.cpp b/test/src/perf/SolverPerfTests.cpp
index 8a53c97..673d7a1 100644
--- a/test/src/perf/SolverPerfTests.cpp
+++ b/test/src/perf/SolverPerfTests.cpp
@@ -1,3 +1,31 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2017 NVIDIA Corporation. All rights reserved.
+
+
#include "BlastBasePerfTest.h"
#include "TestAssets.h"
#include "NvBlastExtDamageShaders.h"
@@ -132,16 +160,16 @@ public:
CubeAssetGenerator::generate(testAsset, settings);
NvBlastAssetDesc desc;
- desc.chunkDescs = &testAsset.solverChunks[0];
+ desc.chunkDescs = testAsset.solverChunks.data();
desc.chunkCount = (uint32_t)testAsset.solverChunks.size();
- desc.bondDescs = &testAsset.solverBonds[0];
+ desc.bondDescs = testAsset.solverBonds.data();
desc.bondCount = (uint32_t)testAsset.solverBonds.size();
{
std::vector<char> scratch;
scratch.resize((size_t)NvBlastGetRequiredScratchForCreateAsset(&desc, messageLog));
- void* mem = alloc(NvBlastGetAssetMemorySize(&desc, messageLog));
- NvBlastAsset* asset = NvBlastCreateAsset(mem, &desc, &scratch[0], messageLog);
+ void* mem = alignedZeroedAlloc(NvBlastGetAssetMemorySize(&desc, messageLog));
+ NvBlastAsset* asset = NvBlastCreateAsset(mem, &desc, scratch.data(), messageLog);
EXPECT_TRUE(asset != nullptr);
// Generate familes
@@ -153,11 +181,11 @@ public:
actorDesc.uniformInitialBondHealth = 1.0f;
actorDesc.initialSupportChunkHealths = nullptr;
actorDesc.uniformInitialLowerSupportChunkHealth = 1.0f;
- void* mem = alloc(NvBlastAssetGetFamilyMemorySize(asset, messageLog));
+ void* mem = alignedZeroedAlloc(NvBlastAssetGetFamilyMemorySize(asset, messageLog));
NvBlastFamily* family = NvBlastAssetCreateFamily(mem, asset, messageLog);
scratch.resize((size_t)NvBlastFamilyGetRequiredScratchForCreateFirstActor(family, messageLog));
EXPECT_TRUE(family != nullptr);
- NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, &scratch[0], messageLog);
+ NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, scratch.data(), messageLog);
EXPECT_TRUE(actor != nullptr);
// Generate damage
diff --git a/test/src/unit/APITests.cpp b/test/src/unit/APITests.cpp
index c2a4a04..5919450 100644
--- a/test/src/unit/APITests.cpp
+++ b/test/src/unit/APITests.cpp
@@ -1,9 +1,38 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2017 NVIDIA Corporation. All rights reserved.
+
+
#include "BlastBaseTest.h"
#include "NvBlastIndexFns.h"
#include "NvBlastExtDamageShaders.h"
#include <algorithm>
+
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Utils / Tests Common
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -24,7 +53,7 @@ TEST_F(APITest, Basic)
const NvBlastAssetDesc& assetDesc = g_assetDescs[0];
std::vector<char> scratch((size_t)NvBlastGetRequiredScratchForCreateAsset(&assetDesc, messageLog));
- void* amem = alloc(NvBlastGetAssetMemorySize(&assetDesc, messageLog));
+ void* amem = alignedZeroedAlloc(NvBlastGetAssetMemorySize(&assetDesc, messageLog));
NvBlastAsset* asset = NvBlastCreateAsset(amem, &assetDesc, scratch.data(), messageLog);
EXPECT_TRUE(asset != nullptr);
@@ -32,7 +61,7 @@ TEST_F(APITest, Basic)
NvBlastActorDesc actorDesc;
actorDesc.initialBondHealths = actorDesc.initialSupportChunkHealths = nullptr;
actorDesc.uniformInitialBondHealth = actorDesc.uniformInitialLowerSupportChunkHealth = 1.0f;
- void* fmem = alloc(NvBlastAssetGetFamilyMemorySize(asset, messageLog));
+ void* fmem = alignedZeroedAlloc(NvBlastAssetGetFamilyMemorySize(asset, messageLog));
NvBlastFamily* family = NvBlastAssetCreateFamily(fmem, asset, messageLog);
scratch.resize((size_t)NvBlastFamilyGetRequiredScratchForCreateFirstActor(family, messageLog));
NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, scratch.data(), messageLog);
@@ -66,6 +95,7 @@ TEST_F(APITest, Basic)
NvBlastActorGenerateFracture(&events, actor, program, &programParams, messageLog, nullptr);
NvBlastActorApplyFracture(&events, actor, &events, messageLog, nullptr);
+ EXPECT_TRUE(NvBlastActorIsSplitRequired(actor, messageLog));
EXPECT_EQ(12, events.bondFractureCount);
NvBlastActor* newActors[8]; /* num lower-support chunks? plus space for deletedActor */
@@ -82,8 +112,8 @@ TEST_F(APITest, Basic)
const bool actorReleaseResult = NvBlastActorDeactivate(result.newActors[i], messageLog);
EXPECT_TRUE(actorReleaseResult);
}
- free(family);
- free(asset);
+ alignedFree(family);
+ alignedFree(asset);
}
TEST_F(APITest, DamageBondsCompressive)
@@ -105,19 +135,19 @@ TEST_F(APITest, DamageBondsCompressive)
const NvBlastBondDesc c_bonds[bondsCount] =
{
- { { 1, 2 }, { { -1.0f, 0.0f, 0.0f }, 1.0f, { 1.0f, 2.0f, 0.0f }, 0 } },
- { { 2, 3 }, { { -1.0f, 0.0f, 0.0f }, 1.0f, { -1.0f, 2.0f, 0.0f }, 0 } },
- { { 3, 4 }, { { 0.0f, -1.0f, 0.0f }, 1.0f, { -2.0f, 1.0f, 0.0f }, 0 } },
- { { 4, 5 }, { { 0.0f, -1.0f, 0.0f }, 1.0f, { -2.0f, -1.0f, 0.0f }, 0 } },
- { { 5, 6 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { -1.0f, -2.0f, 0.0f }, 0 } },
- { { 6, 7 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 1.0f, -2.0f, 0.0f }, 0 } }
+ { { {-1.0f, 0.0f, 0.0f }, 1.0f, { 1.0f, 2.0f, 0.0f }, 0 }, { 1, 2 } },
+ { { {-1.0f, 0.0f, 0.0f }, 1.0f, {-1.0f, 2.0f, 0.0f }, 0 }, { 2, 3 } },
+ { { { 0.0f,-1.0f, 0.0f }, 1.0f, {-2.0f, 1.0f, 0.0f }, 0 }, { 3, 4 } },
+ { { { 0.0f,-1.0f, 0.0f }, 1.0f, {-2.0f,-1.0f, 0.0f }, 0 }, { 4, 5 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, {-1.0f,-2.0f, 0.0f }, 0 }, { 5, 6 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 1.0f,-2.0f, 0.0f }, 0 }, { 6, 7 } }
};
// create asset
const NvBlastAssetDesc assetDesc = { 8, c_chunks, bondsCount, c_bonds };
std::vector<char> scratch((size_t)NvBlastGetRequiredScratchForCreateAsset(&assetDesc, messageLog));
- void* amem = alloc(NvBlastGetAssetMemorySize(&assetDesc, messageLog));
+ void* amem = alignedZeroedAlloc(NvBlastGetAssetMemorySize(&assetDesc, messageLog));
NvBlastAsset* asset = NvBlastCreateAsset(amem, &assetDesc, scratch.data(), messageLog);
EXPECT_TRUE(asset != nullptr);
@@ -125,7 +155,7 @@ TEST_F(APITest, DamageBondsCompressive)
NvBlastActorDesc actorDesc;
actorDesc.initialBondHealths = actorDesc.initialSupportChunkHealths = nullptr;
actorDesc.uniformInitialBondHealth = actorDesc.uniformInitialLowerSupportChunkHealth = 1.0f;
- void* fmem = alloc(NvBlastAssetGetFamilyMemorySize(asset, messageLog));
+ void* fmem = alignedZeroedAlloc(NvBlastAssetGetFamilyMemorySize(asset, messageLog));
NvBlastFamily* family = NvBlastAssetCreateFamily(fmem, asset, messageLog);
scratch.resize((size_t)NvBlastFamilyGetRequiredScratchForCreateFirstActor(family, messageLog));
NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, scratch.data(), messageLog);
@@ -187,8 +217,8 @@ TEST_F(APITest, DamageBondsCompressive)
const bool actorReleaseResult = NvBlastActorDeactivate(actor, messageLog);
EXPECT_TRUE(actorReleaseResult);
- free(family);
- free(asset);
+ alignedFree(family);
+ alignedFree(asset);
}
TEST_F(APITest, DirectFractureKillsChunk)
@@ -213,10 +243,10 @@ TEST_F(APITest, DirectFractureKillsChunk)
const NvBlastBondDesc c_bonds[4] =
{
- { { 1, 2 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 0.0f, +1.0f, 0.0f }, 0 } },
- { { 3, 4 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 0.0f, -1.0f, 0.0f }, 0 } },
- { { 1, 3 }, { { 0.0f, -1.0f, 0.0f }, 1.0f, { -1.0f, 0.0f, 0.0f }, 0 } },
- { { 2, 4 }, { { 0.0f, -1.0f, 0.0f }, 1.0f, { +1.0f, 0.0f, 0.0f }, 0 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 0.0f, 1.0f, 0.0f }, 0 }, { 1, 2 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 0.0f,-1.0f, 0.0f }, 0 }, { 3, 4 } },
+ { { { 0.0f,-1.0f, 0.0f }, 1.0f, {-1.0f, 0.0f, 0.0f }, 0 }, { 1, 3 } },
+ { { { 0.0f,-1.0f, 0.0f }, 1.0f, { 1.0f, 0.0f, 0.0f }, 0 }, { 2, 4 } },
};
NvBlastAssetDesc assetDesc;
@@ -227,7 +257,7 @@ TEST_F(APITest, DirectFractureKillsChunk)
// create asset
std::vector<char> scratch((size_t)NvBlastGetRequiredScratchForCreateAsset(&assetDesc, messageLog));
- void* amem = alloc(NvBlastGetAssetMemorySize(&assetDesc, messageLog));
+ void* amem = alignedZeroedAlloc(NvBlastGetAssetMemorySize(&assetDesc, messageLog));
NvBlastAsset* asset = NvBlastCreateAsset(amem, &assetDesc, scratch.data(), messageLog);
EXPECT_TRUE(asset != nullptr);
@@ -235,7 +265,7 @@ TEST_F(APITest, DirectFractureKillsChunk)
NvBlastActorDesc actorDesc;
actorDesc.initialBondHealths = actorDesc.initialSupportChunkHealths = nullptr;
actorDesc.uniformInitialBondHealth = actorDesc.uniformInitialLowerSupportChunkHealth = 1.0f;
- void* fmem = alloc(NvBlastAssetGetFamilyMemorySize(asset, messageLog));
+ void* fmem = alignedZeroedAlloc(NvBlastAssetGetFamilyMemorySize(asset, messageLog));
NvBlastFamily* family = NvBlastAssetCreateFamily(fmem, asset, messageLog);
scratch.resize((size_t)NvBlastFamilyGetRequiredScratchForCreateFirstActor(family, messageLog));
NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, scratch.data(), messageLog);
@@ -251,6 +281,7 @@ TEST_F(APITest, DirectFractureKillsChunk)
NvBlastFractureBuffers events = { 0, 1, nullptr, &fractureEvt };
NvBlastActorApplyFracture(&events, actor, &commands, messageLog, nullptr);
+ EXPECT_TRUE(NvBlastActorIsSplitRequired(actor, messageLog));
EXPECT_EQ(1, events.chunkFractureCount);
scratch.resize((size_t)NvBlastActorGetRequiredScratchForSplit(actor, messageLog));
@@ -271,8 +302,8 @@ TEST_F(APITest, DirectFractureKillsChunk)
const bool actorReleaseResult = NvBlastActorDeactivate(result.newActors[i], messageLog);
EXPECT_TRUE(actorReleaseResult);
}
- free(family);
- free(asset);
+ alignedFree(family);
+ alignedFree(asset);
}
TEST_F(APITest, DirectFractureKillsIslandRootChunk)
@@ -297,10 +328,10 @@ TEST_F(APITest, DirectFractureKillsIslandRootChunk)
const NvBlastBondDesc c_bonds[4] =
{
- { { 1, 2 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 0.0f, +1.0f, 0.0f }, 0 } },
- { { 3, 4 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 0.0f, -1.0f, 0.0f }, 0 } },
- { { 1, 3 }, { { 0.0f, -1.0f, 0.0f }, 1.0f, { -1.0f, 0.0f, 0.0f }, 0 } },
- { { 2, 4 }, { { 0.0f, -1.0f, 0.0f }, 1.0f, { +1.0f, 0.0f, 0.0f }, 0 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 0.0f, 1.0f, 0.0f }, 0 }, { 1, 2 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 0.0f,-1.0f, 0.0f }, 0 }, { 3, 4 } },
+ { { { 0.0f,-1.0f, 0.0f }, 1.0f, {-1.0f, 0.0f, 0.0f }, 0 }, { 1, 3 } },
+ { { { 0.0f,-1.0f, 0.0f }, 1.0f, { 1.0f, 0.0f, 0.0f }, 0 }, { 2, 4 } },
};
NvBlastAssetDesc assetDesc;
@@ -311,7 +342,7 @@ TEST_F(APITest, DirectFractureKillsIslandRootChunk)
// create asset
std::vector<char> scratch((size_t)NvBlastGetRequiredScratchForCreateAsset(&assetDesc, messageLog));
- void* amem = alloc(NvBlastGetAssetMemorySize(&assetDesc, messageLog));
+ void* amem = alignedZeroedAlloc(NvBlastGetAssetMemorySize(&assetDesc, messageLog));
NvBlastAsset* asset = NvBlastCreateAsset(amem, &assetDesc, scratch.data(), messageLog);
EXPECT_TRUE(asset != nullptr);
@@ -319,7 +350,7 @@ TEST_F(APITest, DirectFractureKillsIslandRootChunk)
NvBlastActorDesc actorDesc;
actorDesc.initialBondHealths = actorDesc.initialSupportChunkHealths = nullptr;
actorDesc.uniformInitialBondHealth = actorDesc.uniformInitialLowerSupportChunkHealth = 1.0f;
- void* fmem = alloc(NvBlastAssetGetFamilyMemorySize(asset, messageLog));
+ void* fmem = alignedZeroedAlloc(NvBlastAssetGetFamilyMemorySize(asset, messageLog));
NvBlastFamily* family = NvBlastAssetCreateFamily(fmem, asset, messageLog);
scratch.resize((size_t)NvBlastFamilyGetRequiredScratchForCreateFirstActor(family, messageLog));
NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, scratch.data(), messageLog);
@@ -335,6 +366,7 @@ TEST_F(APITest, DirectFractureKillsIslandRootChunk)
NvBlastFractureBuffers events = { 0, 1, nullptr, &fractureEvt };
NvBlastActorApplyFracture(&events, actor, &commands, messageLog, nullptr);
+ EXPECT_TRUE(NvBlastActorIsSplitRequired(actor, messageLog));
EXPECT_EQ(1, events.chunkFractureCount);
scratch.resize((size_t)NvBlastActorGetRequiredScratchForSplit(actor, messageLog));
@@ -355,8 +387,8 @@ TEST_F(APITest, DirectFractureKillsIslandRootChunk)
const bool actorReleaseResult = NvBlastActorDeactivate(result.newActors[i], messageLog);
EXPECT_TRUE(actorReleaseResult);
}
- free(family);
- free(asset);
+ alignedFree(family);
+ alignedFree(asset);
}
TEST_F(APITest, SubsupportFracture)
@@ -365,7 +397,7 @@ TEST_F(APITest, SubsupportFracture)
// create asset with chunk map
std::vector<char> scratch((size_t)NvBlastGetRequiredScratchForCreateAsset(&assetDesc, messageLog));
- void* amem = alloc(NvBlastGetAssetMemorySize(&assetDesc, messageLog));
+ void* amem = alignedZeroedAlloc(NvBlastGetAssetMemorySize(&assetDesc, messageLog));
NvBlastAsset* asset = NvBlastCreateAsset(amem, &assetDesc, scratch.data(), messageLog);
EXPECT_TRUE(asset != nullptr);
@@ -373,7 +405,7 @@ TEST_F(APITest, SubsupportFracture)
NvBlastActorDesc actorDesc;
actorDesc.initialBondHealths = actorDesc.initialSupportChunkHealths = nullptr;
actorDesc.uniformInitialBondHealth = actorDesc.uniformInitialLowerSupportChunkHealth = 1.0f;
- void* fmem = alloc(NvBlastAssetGetFamilyMemorySize(asset, messageLog));
+ void* fmem = alignedZeroedAlloc(NvBlastAssetGetFamilyMemorySize(asset, messageLog));
NvBlastFamily* family = NvBlastAssetCreateFamily(fmem, asset, messageLog);
scratch.resize((size_t)NvBlastFamilyGetRequiredScratchForCreateFirstActor(family, messageLog));
NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, scratch.data(), messageLog);
@@ -399,6 +431,7 @@ TEST_F(APITest, SubsupportFracture)
NvBlastFractureBuffers events = target;
NvBlastFractureBuffers commands = { 0, static_cast<uint32_t>(chunkFractureData.size()), nullptr, chunkFractureData.data() };
NvBlastActorApplyFracture(&events, actor, &commands, messageLog, nullptr);
+ EXPECT_TRUE(NvBlastActorIsSplitRequired(actor, messageLog));
ASSERT_EQ(4 + 8, events.chunkFractureCount); // all requested chunks take damage, and the children of one of them
}
@@ -416,6 +449,7 @@ TEST_F(APITest, SubsupportFracture)
NvBlastFractureBuffers events = target;
NvBlastFractureBuffers commands = { 0, static_cast<uint32_t>(chunkFractureData.size()), nullptr, chunkFractureData.data() };
NvBlastActorApplyFracture(&events, actor, &commands, messageLog, nullptr);
+ EXPECT_TRUE(NvBlastActorIsSplitRequired(actor, messageLog));
ASSERT_EQ(1, events.chunkFractureCount); // f3 has broken the chunk
}
@@ -443,6 +477,7 @@ TEST_F(APITest, SubsupportFracture)
{
NvBlastFractureBuffers commands = { 0, static_cast<uint32_t>(chunkFractureData.size()), nullptr, chunkFractureData.data() };
NvBlastActorApplyFracture(&events, actor, &commands, messageLog, nullptr);
+ EXPECT_TRUE(NvBlastActorIsSplitRequired(actor, messageLog));
ASSERT_EQ(4 + 8 + 8, events.chunkFractureCount); // the new fracture commands all apply, plus two of them damage their children too
}
@@ -477,8 +512,8 @@ TEST_F(APITest, SubsupportFracture)
const bool actorReleaseResult = NvBlastActorDeactivate(result.newActors[i], messageLog);
EXPECT_TRUE(actorReleaseResult);
}
- free(family);
- free(asset);
+ alignedFree(family);
+ alignedFree(asset);
}
static bool hasWarned = false;
@@ -522,17 +557,17 @@ TEST_F(APITest, FractureNoEvents)
const NvBlastBondDesc c_bonds[3] =
{
- // chunks, normal, area, centroid, userdata
- { { 1, 2 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 1.0f, 0.0f, 0.0f }, 0 } },
- { { 2, 3 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 2.0f, 0.0f, 0.0f }, 0 } },
- { { 3, 4 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 3.0f, 0.0f, 0.0f }, 0 } },
+ // normal, area, centroid, userdata, chunks
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 1.0f, 0.0f, 0.0f }, 0 }, { 1, 2 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 2.0f, 0.0f, 0.0f }, 0 }, { 2, 3 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 3.0f, 0.0f, 0.0f }, 0 }, { 3, 4 } },
};
NvBlastAssetDesc assetDesc = { chunksCount, c_chunks, 3, c_bonds };
// create asset with chunk map
std::vector<char> scratch((size_t)NvBlastGetRequiredScratchForCreateAsset(&assetDesc, myLog));
- void* amem = alloc(NvBlastGetAssetMemorySize(&assetDesc, myLog));
+ void* amem = alignedZeroedAlloc(NvBlastGetAssetMemorySize(&assetDesc, myLog));
NvBlastAsset* asset = NvBlastCreateAsset(amem, &assetDesc, scratch.data(), myLog);
EXPECT_TRUE(asset != nullptr);
@@ -540,7 +575,7 @@ TEST_F(APITest, FractureNoEvents)
NvBlastActorDesc actorDesc;
actorDesc.initialBondHealths = actorDesc.initialSupportChunkHealths = nullptr;
actorDesc.uniformInitialBondHealth = actorDesc.uniformInitialLowerSupportChunkHealth = 1.0f;
- void* fmem = alloc(NvBlastAssetGetFamilyMemorySize(asset, myLog));
+ void* fmem = alignedZeroedAlloc(NvBlastAssetGetFamilyMemorySize(asset, myLog));
NvBlastFamily* family = NvBlastAssetCreateFamily(fmem, asset, myLog);
scratch.resize((size_t)NvBlastFamilyGetRequiredScratchForCreateFirstActor(family, myLog));
NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, scratch.data(), myLog);
@@ -559,6 +594,7 @@ TEST_F(APITest, FractureNoEvents)
NvBlastFractureBuffers commands = { 0, 2, nullptr, command };
NvBlastActorApplyFracture(nullptr, actor, &commands, myLog, nullptr);
+ EXPECT_TRUE(NvBlastActorIsSplitRequired(actor, messageLog));
EXPECT_NO_WARNING; // events can be null
EXPECT_EQ(GUARD, cfData[cfData.size() - 1].userdata);
@@ -578,8 +614,8 @@ TEST_F(APITest, FractureNoEvents)
EXPECT_TRUE(actorReleaseResult);
}
- free(family);
- free(asset);
+ alignedFree(family);
+ alignedFree(asset);
EXPECT_NO_WARNING;
}
@@ -616,17 +652,17 @@ TEST_F(APITest, FractureBufferLimits)
const NvBlastBondDesc c_bonds[3] =
{
- // chunks, normal, area, centroid, userdata
- { { 1, 2 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 1.0f, 0.0f, 0.0f }, 0 } },
- { { 2, 3 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 2.0f, 0.0f, 0.0f }, 0 } },
- { { 3, 4 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 3.0f, 0.0f, 0.0f }, 0 } },
+ // normal, area, centroid, userdata, chunks
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 1.0f, 0.0f, 0.0f }, 0 }, { 1, 2 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 2.0f, 0.0f, 0.0f }, 0 }, { 2, 3 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 3.0f, 0.0f, 0.0f }, 0 }, { 3, 4 } },
};
NvBlastAssetDesc assetDesc = { chunksCount, c_chunks, 3, c_bonds };
{
// create asset with chunk map
std::vector<char> scratch((size_t)NvBlastGetRequiredScratchForCreateAsset(&assetDesc, myLog));
- void* amem = alloc(NvBlastGetAssetMemorySize(&assetDesc, myLog));
+ void* amem = alignedZeroedAlloc(NvBlastGetAssetMemorySize(&assetDesc, myLog));
NvBlastAsset* asset = NvBlastCreateAsset(amem, &assetDesc, scratch.data(), myLog);
EXPECT_TRUE(asset != nullptr);
@@ -636,7 +672,7 @@ TEST_F(APITest, FractureBufferLimits)
NvBlastActorDesc actorDesc;
actorDesc.initialBondHealths = actorDesc.initialSupportChunkHealths = nullptr;
actorDesc.uniformInitialBondHealth = actorDesc.uniformInitialLowerSupportChunkHealth = 1.0f;
- void* fmem = alloc(NvBlastAssetGetFamilyMemorySize(asset, myLog));
+ void* fmem = alignedZeroedAlloc(NvBlastAssetGetFamilyMemorySize(asset, myLog));
NvBlastFamily* family = NvBlastAssetCreateFamily(fmem, asset, myLog);
scratch.resize((size_t)NvBlastFamilyGetRequiredScratchForCreateFirstActor(family, myLog));
NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, scratch.data(), myLog);
@@ -667,7 +703,7 @@ TEST_F(APITest, FractureBufferLimits)
}
EXPECT_TRUE(NvBlastActorDeactivate(actor, myLog));
- free(family);
+ alignedFree(family);
}
{
@@ -675,7 +711,7 @@ TEST_F(APITest, FractureBufferLimits)
NvBlastActorDesc actorDesc;
actorDesc.initialBondHealths = actorDesc.initialSupportChunkHealths = nullptr;
actorDesc.uniformInitialBondHealth = actorDesc.uniformInitialLowerSupportChunkHealth = 1.0f;
- void* fmem = alloc(NvBlastAssetGetFamilyMemorySize(asset, myLog));
+ void* fmem = alignedZeroedAlloc(NvBlastAssetGetFamilyMemorySize(asset, myLog));
NvBlastFamily* family = NvBlastAssetCreateFamily(fmem, asset, myLog);
scratch.resize((size_t)NvBlastFamilyGetRequiredScratchForCreateFirstActor(family, myLog));
NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, scratch.data(), myLog);
@@ -696,6 +732,7 @@ TEST_F(APITest, FractureBufferLimits)
NvBlastFractureBuffers events = { static_cast<uint32_t>(bfData.size()), static_cast<uint32_t>(cfData.size()) - 1, bfData.data(), cfData.data() };
NvBlastActorApplyFracture(&events, actor, &commands, myLog, nullptr);
+ EXPECT_TRUE(NvBlastActorIsSplitRequired(actor, messageLog));
EXPECT_NO_WARNING;
EXPECT_EQ(14, events.chunkFractureCount);
@@ -720,10 +757,10 @@ TEST_F(APITest, FractureBufferLimits)
EXPECT_TRUE(actorReleaseResult);
}
- free(family);
+ alignedFree(family);
}
- free(asset);
+ alignedFree(asset);
}
EXPECT_NO_WARNING;
}
@@ -760,17 +797,17 @@ TEST_F(APITest, FractureBufferLimitsInSitu)
const NvBlastBondDesc c_bonds[3] =
{
- // chunks, normal, area, centroid, userdata
- { { 1, 2 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 1.0f, 0.0f, 0.0f }, 0 } },
- { { 2, 3 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 2.0f, 0.0f, 0.0f }, 0 } },
- { { 3, 4 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 3.0f, 0.0f, 0.0f }, 0 } },
+ // normal, area, centroid, userdata, chunks
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 1.0f, 0.0f, 0.0f }, 0 }, { 1, 2 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 2.0f, 0.0f, 0.0f }, 0 }, { 2, 3 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 3.0f, 0.0f, 0.0f }, 0 }, { 3, 4 } },
};
NvBlastAssetDesc assetDesc = { chunksCount, c_chunks, 3, c_bonds };
{
// create asset with chunk map
std::vector<char> scratch((size_t)NvBlastGetRequiredScratchForCreateAsset(&assetDesc, myLog));
- void* amem = alloc(NvBlastGetAssetMemorySize(&assetDesc, myLog));
+ void* amem = alignedZeroedAlloc(NvBlastGetAssetMemorySize(&assetDesc, myLog));
NvBlastAsset* asset = NvBlastCreateAsset(amem, &assetDesc, scratch.data(), myLog);
EXPECT_TRUE(asset != nullptr);
@@ -780,7 +817,7 @@ TEST_F(APITest, FractureBufferLimitsInSitu)
NvBlastActorDesc actorDesc;
actorDesc.initialBondHealths = actorDesc.initialSupportChunkHealths = nullptr;
actorDesc.uniformInitialBondHealth = actorDesc.uniformInitialLowerSupportChunkHealth = 1.0f;
- void* fmem = alloc(NvBlastAssetGetFamilyMemorySize(asset, myLog));
+ void* fmem = alignedZeroedAlloc(NvBlastAssetGetFamilyMemorySize(asset, myLog));
NvBlastFamily* family = NvBlastAssetCreateFamily(fmem, asset, myLog);
scratch.resize((size_t)NvBlastFamilyGetRequiredScratchForCreateFirstActor(family, myLog));
NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, scratch.data(), myLog);
@@ -805,6 +842,7 @@ TEST_F(APITest, FractureBufferLimitsInSitu)
NvBlastFractureBuffers events = { static_cast<uint32_t>(bfData.size()), static_cast<uint32_t>(cfData.size()) - 1, bfData.data(), cfData.data() };
NvBlastActorApplyFracture(&events, actor, &commands, myLog, nullptr);
+ EXPECT_TRUE(NvBlastActorIsSplitRequired(actor, messageLog));
EXPECT_WARNING;
EXPECT_EQ(GUARD, cfData[cfData.size() - 1].userdata);
@@ -816,7 +854,7 @@ TEST_F(APITest, FractureBufferLimitsInSitu)
EXPECT_TRUE(NvBlastActorDeactivate(actor, myLog));
- free(family);
+ alignedFree(family);
}
{
@@ -824,7 +862,7 @@ TEST_F(APITest, FractureBufferLimitsInSitu)
NvBlastActorDesc actorDesc;
actorDesc.initialBondHealths = actorDesc.initialSupportChunkHealths = nullptr;
actorDesc.uniformInitialBondHealth = actorDesc.uniformInitialLowerSupportChunkHealth = 1.0f;
- void* fmem = alloc(NvBlastAssetGetFamilyMemorySize(asset, myLog));
+ void* fmem = alignedZeroedAlloc(NvBlastAssetGetFamilyMemorySize(asset, myLog));
NvBlastFamily* family = NvBlastAssetCreateFamily(fmem, asset, myLog);
scratch.resize((size_t)NvBlastFamilyGetRequiredScratchForCreateFirstActor(family, myLog));
NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, scratch.data(), myLog);
@@ -849,6 +887,7 @@ TEST_F(APITest, FractureBufferLimitsInSitu)
NvBlastFractureBuffers events = { static_cast<uint32_t>(bfData.size()), static_cast<uint32_t>(cfData.size()) - 1, bfData.data(), cfData.data() };
NvBlastActorApplyFracture(&events, actor, &commands, myLog, nullptr);
+ EXPECT_TRUE(NvBlastActorIsSplitRequired(actor, messageLog));
EXPECT_NO_WARNING;
EXPECT_EQ(14, events.chunkFractureCount);
@@ -872,14 +911,353 @@ TEST_F(APITest, FractureBufferLimitsInSitu)
const bool actorReleaseResult = NvBlastActorDeactivate(result.newActors[i], myLog);
EXPECT_TRUE(actorReleaseResult);
}
- free(family);
+ alignedFree(family);
}
- free(asset);
+ alignedFree(asset);
}
EXPECT_NO_WARNING;
}
+/*
+This test checks if bond or chunk fracture commands passed to NvBlastActorApplyFracture do not correspond to
+the actor passed in they (commands) will be ignored and warning message will be fired.
+*/
+TEST_F(APITest, FractureWarnAndFilterOtherActorCommands)
+{
+ const uint32_t chunksCount = 17;
+ const NvBlastChunkDesc c_chunks[chunksCount] =
+ {
+ // centroid volume parent idx flags ID
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, UINT32_MAX, NvBlastChunkDesc::NoFlags, 0 },
+
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 1 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 2 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 3 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 4 },
+
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 1, NvBlastChunkDesc::NoFlags, 5 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 1, NvBlastChunkDesc::NoFlags, 6 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 2, NvBlastChunkDesc::NoFlags, 7 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 2, NvBlastChunkDesc::NoFlags, 8 },
+
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 5, NvBlastChunkDesc::NoFlags, 9 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 5, NvBlastChunkDesc::NoFlags, 10 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 6, NvBlastChunkDesc::NoFlags, 11 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 6, NvBlastChunkDesc::NoFlags, 12 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 7, NvBlastChunkDesc::NoFlags, 13 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 7, NvBlastChunkDesc::NoFlags, 14 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 8, NvBlastChunkDesc::NoFlags, 15 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 8, NvBlastChunkDesc::NoFlags, 16 },
+ };
+
+ const NvBlastBondDesc c_bonds[4] =
+ {
+ // normal, area, centroid, userdata, chunks
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 }, { 1, 2 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 }, { 2, 3 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 }, { 3, 4 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 }, { 1, 3 } }
+ };
+
+ NvBlastAssetDesc assetDesc = { chunksCount, c_chunks, 4, c_bonds };
+
+ // create asset with chunk map
+ std::vector<char> scratch((size_t)NvBlastGetRequiredScratchForCreateAsset(&assetDesc, myLog));
+ void* amem = alignedZeroedAlloc(NvBlastGetAssetMemorySize(&assetDesc, myLog));
+ NvBlastAsset* asset = NvBlastCreateAsset(amem, &assetDesc, scratch.data(), myLog);
+ EXPECT_TRUE(asset != nullptr);
+
+ // create actor
+ NvBlastActorDesc actorDesc;
+ actorDesc.initialBondHealths = actorDesc.initialSupportChunkHealths = nullptr;
+ actorDesc.uniformInitialBondHealth = actorDesc.uniformInitialLowerSupportChunkHealth = 1.0f;
+ void* fmem = alignedZeroedAlloc(NvBlastAssetGetFamilyMemorySize(asset, myLog));
+ NvBlastFamily* family = NvBlastAssetCreateFamily(fmem, asset, myLog);
+ scratch.resize((size_t)NvBlastFamilyGetRequiredScratchForCreateFirstActor(family, myLog));
+ NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, scratch.data(), myLog);
+ EXPECT_TRUE(actor != nullptr);
+
+ // split in 2
+ std::vector<NvBlastActor*> actors;
+ {
+ NvBlastBondFractureData command[] =
+ {
+ { 0, 0, 2, 10.0f },
+ { 0, 1, 2, 10.0f }
+ };
+
+ NvBlastFractureBuffers commands = { 2, 0, command, nullptr };
+ NvBlastActorApplyFracture(nullptr, actor, &commands, myLog, nullptr);
+ EXPECT_TRUE(NvBlastActorIsSplitRequired(actor, messageLog));
+
+ scratch.resize((size_t)NvBlastActorGetRequiredScratchForSplit(actor, myLog));
+ std::vector<NvBlastActor*> newActors(NvBlastActorGetMaxActorCountForSplit(actor, myLog));
+ NvBlastActorSplitEvent result;
+ result.deletedActor = nullptr;
+ result.newActors = newActors.data();
+ size_t newActorsCount = NvBlastActorSplit(&result, actor, static_cast<uint32_t>(newActors.size()), scratch.data(), myLog, nullptr);
+
+ EXPECT_EQ(2, newActorsCount);
+ EXPECT_EQ(actor, result.deletedActor);
+
+ actors.insert(actors.begin(), result.newActors, result.newActors + newActorsCount);
+ }
+
+ // damage bonds belonging to other actors, nothing expected to be broken
+ {
+ for (uint32_t i = 0; i < actors.size(); ++i)
+ {
+ NvBlastActor* actor = actors[i];
+ NvBlastActor* otherActor = actors[(i + 1) % 2];
+
+ // get graph nodes check
+ std::vector<uint32_t> graphNodeIndices;
+ graphNodeIndices.resize(NvBlastActorGetGraphNodeCount(otherActor, nullptr));
+ uint32_t graphNodesCount = NvBlastActorGetGraphNodeIndices(graphNodeIndices.data(), (uint32_t)graphNodeIndices.size(), otherActor, nullptr);
+ EXPECT_EQ(graphNodesCount, 2);
+
+ NvBlastBondFractureData command[] =
+ {
+ { 0, graphNodeIndices[0], graphNodeIndices[1], 10.0f }
+ };
+
+ NvBlastFractureBuffers commands = { 1, 0, command, nullptr };
+ NvBlastActorApplyFracture(nullptr, actor, &commands, myLog, nullptr);
+ EXPECT_WARNING;
+ EXPECT_FALSE(NvBlastActorIsSplitRequired(actor, messageLog));
+
+ scratch.resize((size_t)NvBlastActorGetRequiredScratchForSplit(actor, myLog));
+ std::vector<NvBlastActor*> newActors(NvBlastActorGetMaxActorCountForSplit(actor, myLog));
+ NvBlastActorSplitEvent result;
+ result.deletedActor = nullptr;
+ result.newActors = newActors.data();
+ size_t newActorsCount = NvBlastActorSplit(&result, actor, static_cast<uint32_t>(newActors.size()), scratch.data(), myLog, nullptr);
+
+ EXPECT_EQ(0, newActorsCount);
+ EXPECT_EQ(nullptr, result.deletedActor);
+ }
+ }
+
+ // damage bonds, split actors in 2 each
+ std::vector<NvBlastActor*> actors2;
+ {
+ for (uint32_t i = 0; i < 2; ++i)
+ {
+ NvBlastActor* actor = actors[i];
+
+ // get graph nodes check
+ std::vector<uint32_t> graphNodeIndices;
+ graphNodeIndices.resize(NvBlastActorGetGraphNodeCount(actor, nullptr));
+ uint32_t graphNodesCount = NvBlastActorGetGraphNodeIndices(graphNodeIndices.data(), (uint32_t)graphNodeIndices.size(), actor, nullptr);
+ EXPECT_EQ(graphNodesCount, 2);
+
+ NvBlastBondFractureData command[] =
+ {
+ { 0, graphNodeIndices[0], graphNodeIndices[1], 10.0f }
+ };
+
+ NvBlastFractureBuffers commands = { 1, 0, command, nullptr };
+ NvBlastActorApplyFracture(nullptr, actor, &commands, myLog, nullptr);
+ EXPECT_TRUE(NvBlastActorIsSplitRequired(actor, messageLog));
+
+ scratch.resize((size_t)NvBlastActorGetRequiredScratchForSplit(actor, myLog));
+ std::vector<NvBlastActor*> newActors(NvBlastActorGetMaxActorCountForSplit(actor, myLog));
+ NvBlastActorSplitEvent result;
+ result.deletedActor = nullptr;
+ result.newActors = newActors.data();
+ size_t newActorsCount = NvBlastActorSplit(&result, actor, static_cast<uint32_t>(newActors.size()), scratch.data(), myLog, nullptr);
+
+ EXPECT_EQ(2, newActorsCount);
+ EXPECT_EQ(actor, result.deletedActor);
+
+ actors2.insert(actors2.begin(), result.newActors, result.newActors + newActorsCount);
+ }
+ }
+
+ // damage chunk belonging to other actor (expect no split or damage taken)
+ {
+ for (uint32_t i = 0; i < actors.size(); ++i)
+ {
+ NvBlastActor* actor = actors[i];
+ NvBlastActor* otherActor = actors[(i + 1) % 2];
+
+ uint32_t chunkToDamage;
+ NvBlastActorGetVisibleChunkIndices(&chunkToDamage, 1, otherActor, myLog);
+
+ NvBlastChunkFractureData command[] =
+ {
+ { 0, chunkToDamage, 0.9f },
+ };
+
+ NvBlastFractureBuffers commands = { 0, 1, nullptr, command };
+ NvBlastActorApplyFracture(nullptr, actor, &commands, myLog, nullptr);
+ EXPECT_WARNING;
+ EXPECT_FALSE(NvBlastActorIsSplitRequired(actor, messageLog));
+
+ scratch.resize((size_t)NvBlastActorGetRequiredScratchForSplit(actor, myLog));
+ std::vector<NvBlastActor*> newActors(NvBlastActorGetMaxActorCountForSplit(actor, myLog));
+ NvBlastActorSplitEvent result;
+ result.deletedActor = nullptr;
+ result.newActors = newActors.data();
+ size_t newActorsCount = NvBlastActorSplit(&result, actor, static_cast<uint32_t>(newActors.size()), scratch.data(), myLog, nullptr);
+
+ EXPECT_EQ(0, newActorsCount);
+ EXPECT_EQ(nullptr, result.deletedActor);
+
+ EXPECT_EQ(1, NvBlastActorGetVisibleChunkCount(actor, myLog));
+ uint32_t chunkIndex;
+ NvBlastActorGetVisibleChunkIndices(&chunkIndex, 1, actor, myLog);
+ EXPECT_NE(chunkToDamage, chunkIndex);
+ }
+ }
+
+ for (NvBlastActor* actor : actors2)
+ {
+ NvBlastActorDeactivate(actor, myLog);
+ }
+
+ alignedFree(family);
+ alignedFree(asset);
+
+ EXPECT_NO_WARNING;
+}
+
+/**
+If duplicate bonds are passed asset create routine will ignore them (but fire warning)
+We pass duplicated bonds to world chunk and fully fracture actor once.
+*/
+TEST_F(APITest, FractureWithBondDuplicates)
+{
+ const uint32_t chunksCount = 17;
+ const NvBlastChunkDesc c_chunks[chunksCount] =
+ {
+ // centroid volume parent idx flags ID
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, UINT32_MAX, NvBlastChunkDesc::NoFlags, 0 },
+
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 1 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 2 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 3 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 4 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 5 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 6 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 7 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 8 },
+
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 5, NvBlastChunkDesc::NoFlags, 9 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 5, NvBlastChunkDesc::NoFlags, 10 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 6, NvBlastChunkDesc::NoFlags, 11 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 6, NvBlastChunkDesc::NoFlags, 12 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 7, NvBlastChunkDesc::NoFlags, 13 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 7, NvBlastChunkDesc::NoFlags, 14 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 8, NvBlastChunkDesc::NoFlags, 15 },
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, 8, NvBlastChunkDesc::NoFlags, 16 },
+ };
+
+ const uint32_t bondCount = 20;
+ const uint32_t world = ~(uint32_t)0; // world chunk => invalid index
+ const NvBlastBondDesc c_bonds[bondCount] =
+ {
+ // normal, area, centroid, userdata, chunks
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 },{ 1, world } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 },{ 2, 1 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 },{ 2, world } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 },{ 2, world } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 },{ 3, 1 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 },{ 4, 3 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 },{ 4, 2 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 },{ 4, world } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 },{ 5, 1 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 },{ 5, world } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 },{ 6, 5 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 },{ 6, 2 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 },{ 6, world } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 },{ 6, world } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 },{ 7, 5 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 },{ 7, 3 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 },{ 8, 7 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 },{ 8, 6 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 },{ 8, 4 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 1.0f, 0.0f, 0.0f }, 0 },{ 8, world } }
+ };
+
+ NvBlastAssetDesc assetDesc = { chunksCount, c_chunks, bondCount, c_bonds };
+
+ // create asset
+ std::vector<char> scratch((size_t)NvBlastGetRequiredScratchForCreateAsset(&assetDesc, myLog));
+ void* amem = alignedZeroedAlloc(NvBlastGetAssetMemorySize(&assetDesc, myLog));
+ NvBlastAsset* asset = NvBlastCreateAsset(amem, &assetDesc, scratch.data(), myLog);
+ EXPECT_WARNING;
+ EXPECT_TRUE(asset != nullptr);
+
+ // create actor
+ NvBlastActorDesc actorDesc;
+ actorDesc.initialBondHealths = actorDesc.initialSupportChunkHealths = nullptr;
+ actorDesc.uniformInitialBondHealth = actorDesc.uniformInitialLowerSupportChunkHealth = 1.0f;
+ void* fmem = alignedZeroedAlloc(NvBlastAssetGetFamilyMemorySize(asset, myLog));
+ NvBlastFamily* family = NvBlastAssetCreateFamily(fmem, asset, myLog);
+ scratch.resize((size_t)NvBlastFamilyGetRequiredScratchForCreateFirstActor(family, myLog));
+ NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, scratch.data(), myLog);
+ EXPECT_TRUE(actor != nullptr);
+
+ // split in 2
+ std::vector<NvBlastActor*> actors;
+ {
+ NvBlastExtRadialDamageDesc damage[] = {
+ {
+ 10.0f, // compressive
+ { 0.0f, 0.0f, 0.0f }, // position
+ 100.0f, // min radius - maximum damage
+ 100.0f // max radius - zero damage
+ } // linear falloff
+ };
+
+ NvBlastBondFractureData outBondFracture[bondCount];
+ NvBlastChunkFractureData outChunkFracture[chunksCount];
+
+ NvBlastFractureBuffers events;
+ events.bondFractureCount = 2;
+ events.bondFractures = outBondFracture;
+ events.chunkFractureCount = 2;
+ events.chunkFractures = outChunkFracture;
+
+ NvBlastProgramParams programParams;
+ programParams.damageDescCount = 1;
+ programParams.damageDescBuffer = &damage;
+
+ NvBlastDamageProgram program = {
+ NvBlastExtFalloffGraphShader,
+ NvBlastExtFalloffSubgraphShader
+ };
+
+ NvBlastActorGenerateFracture(&events, actor, program, &programParams, myLog, nullptr);
+ NvBlastActorApplyFracture(nullptr, actor, &events, myLog, nullptr);
+ EXPECT_TRUE(NvBlastActorIsSplitRequired(actor, messageLog));
+
+ scratch.resize((size_t)NvBlastActorGetRequiredScratchForSplit(actor, myLog));
+ std::vector<NvBlastActor*> newActors(NvBlastActorGetMaxActorCountForSplit(actor, myLog));
+ NvBlastActorSplitEvent result;
+ result.deletedActor = nullptr;
+ result.newActors = newActors.data();
+ size_t newActorsCount = NvBlastActorSplit(&result, actor, static_cast<uint32_t>(newActors.size()), scratch.data(), myLog, nullptr);
+
+ EXPECT_EQ(8, newActorsCount);
+ EXPECT_EQ(actor, result.deletedActor);
+
+ actors.insert(actors.begin(), result.newActors, result.newActors + newActorsCount);
+ }
+
+ for (NvBlastActor* actor : actors)
+ {
+ NvBlastActorDeactivate(actor, myLog);
+ }
+
+ alignedFree(family);
+ alignedFree(asset);
+
+ EXPECT_NO_WARNING;
+}
+
#if 0
TEST(APITest, UserChunkMap)
{
@@ -964,7 +1342,7 @@ TEST_F(APITest, NoBondsSausage)
assetDesc.bondDescs = nullptr;
std::vector<char> scratch((size_t)NvBlastGetRequiredScratchForCreateAsset(&assetDesc, messageLog));
- void* amem = alloc(NvBlastGetAssetMemorySize(&assetDesc, messageLog));
+ void* amem = alignedZeroedAlloc(NvBlastGetAssetMemorySize(&assetDesc, messageLog));
NvBlastAsset* asset = NvBlastCreateAsset(amem, &assetDesc, scratch.data(), messageLog);
const NvBlastChunk* chunks = NvBlastAssetGetChunks(asset, messageLog);
EXPECT_TRUE(asset != nullptr);
@@ -973,7 +1351,7 @@ TEST_F(APITest, NoBondsSausage)
NvBlastActorDesc actorDesc;
actorDesc.initialBondHealths = actorDesc.initialSupportChunkHealths = nullptr;
actorDesc.uniformInitialBondHealth = actorDesc.uniformInitialLowerSupportChunkHealth = 1.0f;
- void* fmem = alloc(NvBlastAssetGetFamilyMemorySize(asset, messageLog));
+ void* fmem = alignedZeroedAlloc(NvBlastAssetGetFamilyMemorySize(asset, messageLog));
NvBlastFamily* family = NvBlastAssetCreateFamily(fmem, asset, messageLog);
scratch.resize((size_t)NvBlastFamilyGetRequiredScratchForCreateFirstActor(family, messageLog));
NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, scratch.data(), messageLog);
@@ -1017,6 +1395,7 @@ TEST_F(APITest, NoBondsSausage)
NvBlastActorGenerateFracture(&events, actor, program, &programParams, messageLog, nullptr);
NvBlastActorApplyFracture(&events, actor, &events, messageLog, nullptr);
+ EXPECT_TRUE(NvBlastActorIsSplitRequired(actor, messageLog));
EXPECT_EQ(0, events.bondFractureCount);
EXPECT_EQ(1, events.chunkFractureCount);
@@ -1045,8 +1424,8 @@ TEST_F(APITest, NoBondsSausage)
EXPECT_TRUE(actorReleaseResult);
}
- free(family);
- free(asset);
+ alignedFree(family);
+ alignedFree(asset);
}
TEST_F(APITest, SplitOnlyWhenNecessary)
@@ -1081,18 +1460,18 @@ TEST_F(APITest, SplitOnlyWhenNecessary)
const NvBlastBondDesc c_bonds[4] =
{
- // chunks, normal, area, centroid, userdata
- { { 1, 2 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 1.0f, 0.0f, 0.0f }, 0 } },
- { { 2, 3 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 1.0f, 0.0f, 0.0f }, 0 } },
- { { 3, 4 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 1.0f, 0.0f, 0.0f }, 0 } },
- { { 1, 3 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 1.0f, 0.0f, 0.0f }, 0 } }
+ // normal, area, centroid, userdata, chunks
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 1.0f, 0.0f, 0.0f }, 0 }, { 1, 2 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 1.0f, 0.0f, 0.0f }, 0 }, { 2, 3 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 1.0f, 0.0f, 0.0f }, 0 }, { 3, 4 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 1.0f, 0.0f, 0.0f }, 0 }, { 1, 3 } }
};
NvBlastAssetDesc assetDesc = { chunksCount, c_chunks, 4, c_bonds };
// create asset with chunk map
std::vector<char> scratch((size_t)NvBlastGetRequiredScratchForCreateAsset(&assetDesc, myLog));
- void* amem = alloc(NvBlastGetAssetMemorySize(&assetDesc, myLog));
+ void* amem = alignedZeroedAlloc(NvBlastGetAssetMemorySize(&assetDesc, myLog));
NvBlastAsset* asset = NvBlastCreateAsset(amem, &assetDesc, scratch.data(), myLog);
EXPECT_TRUE(asset != nullptr);
@@ -1100,7 +1479,7 @@ TEST_F(APITest, SplitOnlyWhenNecessary)
NvBlastActorDesc actorDesc;
actorDesc.initialBondHealths = actorDesc.initialSupportChunkHealths = nullptr;
actorDesc.uniformInitialBondHealth = actorDesc.uniformInitialLowerSupportChunkHealth = 1.0f;
- void* fmem = alloc(NvBlastAssetGetFamilyMemorySize(asset, myLog));
+ void* fmem = alignedZeroedAlloc(NvBlastAssetGetFamilyMemorySize(asset, myLog));
NvBlastFamily* family = NvBlastAssetCreateFamily(fmem, asset, myLog);
scratch.resize((size_t)NvBlastFamilyGetRequiredScratchForCreateFirstActor(family, myLog));
NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, scratch.data(), myLog);
@@ -1118,6 +1497,7 @@ TEST_F(APITest, SplitOnlyWhenNecessary)
NvBlastFractureBuffers commands = { 3, 0, command, nullptr };
NvBlastActorApplyFracture(nullptr, actor, &commands, myLog, nullptr);
+ EXPECT_FALSE(NvBlastActorIsSplitRequired(actor, messageLog));
scratch.resize((size_t)NvBlastActorGetRequiredScratchForSplit(actor, myLog));
std::vector<NvBlastActor*> newActors(NvBlastActorGetMaxActorCountForSplit(actor, myLog));
@@ -1144,6 +1524,7 @@ TEST_F(APITest, SplitOnlyWhenNecessary)
NvBlastFractureBuffers commands = { 1, 0, command, nullptr };
NvBlastActorApplyFracture(nullptr, actor, &commands, myLog, nullptr);
+ EXPECT_TRUE(NvBlastActorIsSplitRequired(actor, messageLog));
scratch.resize((size_t)NvBlastActorGetRequiredScratchForSplit(actor, myLog));
std::vector<NvBlastActor*> newActors(NvBlastActorGetMaxActorCountForSplit(actor, myLog));
@@ -1173,6 +1554,7 @@ TEST_F(APITest, SplitOnlyWhenNecessary)
NvBlastFractureBuffers commands = { 3, 0, command, nullptr };
NvBlastActorApplyFracture(nullptr, actor, &commands, myLog, nullptr);
+ EXPECT_TRUE(NvBlastActorIsSplitRequired(actor, messageLog));
scratch.resize((size_t)NvBlastActorGetRequiredScratchForSplit(actor, myLog));
std::vector<NvBlastActor*> newActors(NvBlastActorGetMaxActorCountForSplit(actor, myLog));
@@ -1201,6 +1583,7 @@ TEST_F(APITest, SplitOnlyWhenNecessary)
NvBlastFractureBuffers commands = { 0, 1, nullptr, command };
NvBlastActorApplyFracture(nullptr, actor, &commands, myLog, nullptr);
+ EXPECT_FALSE(NvBlastActorIsSplitRequired(actor, messageLog));
scratch.resize((size_t)NvBlastActorGetRequiredScratchForSplit(actor, myLog));
std::vector<NvBlastActor*> newActors(NvBlastActorGetMaxActorCountForSplit(actor, myLog));
@@ -1224,8 +1607,8 @@ TEST_F(APITest, SplitOnlyWhenNecessary)
NvBlastActorDeactivate(actor, myLog);
}
- free(family);
- free(asset);
+ alignedFree(family);
+ alignedFree(asset);
EXPECT_NO_WARNING;
}
@@ -1325,12 +1708,12 @@ TEST_F(APITest,CExportsNoNameMangling)
{
size_t requiredsize = assetCreateRequiredScratch(&assetDesc);
std::vector<char>scratch(requiredsize);
- void* mem = alloc(assetGetMemorySize(&assetDesc));
+ void* mem = alignedZeroedAlloc(assetGetMemorySize(&assetDesc));
asset = assetCreate(mem, &assetDesc, scratch.data(), myLog);
ASSERT_TRUE(asset != nullptr);
}
- void* fmem = alloc(familyGetMemorySize(asset));
+ void* fmem = alignedZeroedAlloc(familyGetMemorySize(asset));
NvBlastFamily* family = familyCreate(fmem, asset, myLog);
{
@@ -1346,8 +1729,8 @@ TEST_F(APITest,CExportsNoNameMangling)
ASSERT_TRUE(actorRelease(actor));
}
- free(family);
- free(asset);
+ alignedFree(family);
+ alignedFree(asset);
EXPECT_NO_WARNING;
}
diff --git a/test/src/unit/ActorTests.cpp b/test/src/unit/ActorTests.cpp
index 12dc19c..522d230 100644
--- a/test/src/unit/ActorTests.cpp
+++ b/test/src/unit/ActorTests.cpp
@@ -1,3 +1,31 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2017 NVIDIA Corporation. All rights reserved.
+
+
#include "BlastBaseTest.h"
#include "AssetGenerator.h"
@@ -31,6 +59,10 @@ static bool chooseRandomGraphNodes(uint32_t* g, uint32_t count, const Nv::Blast:
{
const uint32_t c0 = m_asset.m_graph.getChunkIndices()[i0];
const uint32_t c1 = m_asset.m_graph.getChunkIndices()[i1];
+ if (Nv::Blast::isInvalidIndex(c0) || Nv::Blast::isInvalidIndex(c1))
+ {
+ return c0 < c1;
+ }
return m_asset.getChunks()[c0].userData < m_asset.getChunks()[c1].userData;
}
@@ -106,6 +138,7 @@ static void blast(std::set<NvBlastActor*>& actorsToDamage, GeneratorAsset* testA
NvBlastActorGenerateFracture(&events, actor, program, &programParams, nullptr, nullptr);
NvBlastActorApplyFracture(&events, actor, &events, nullptr, nullptr);
+ const bool isDamaged = NvBlastActorIsSplitRequired(actor, nullptr);
bool removeActor = false;
if (events.bondFractureCount + events.chunkFractureCount > 0)
@@ -116,9 +149,14 @@ static void blast(std::set<NvBlastActor*>& actorsToDamage, GeneratorAsset* testA
splitScratch.resize((size_t)NvBlastActorGetRequiredScratchForSplit(actor, nullptr));
const size_t newActorsCount = NvBlastActorSplit(&splitEvent, actor, newActorSize, splitScratch.data(), nullptr, nullptr);
+ EXPECT_TRUE(isDamaged || newActorsCount == 0);
totalNewActorsCount += newActorsCount;
removeActor = splitEvent.deletedActor != NULL;
}
+ else
+ {
+ EXPECT_FALSE(isDamaged);
+ }
if (removeActor)
{
@@ -153,12 +191,12 @@ public:
static void* alloc(size_t size)
{
- return BlastBaseTest<FailLevel, Verbosity>::alloc(size);
+ return BlastBaseTest<FailLevel, Verbosity>::alignedZeroedAlloc(size);
}
static void free(void* mem)
{
- BlastBaseTest<FailLevel, Verbosity>::free(mem);
+ BlastBaseTest<FailLevel, Verbosity>::alignedFree(mem);
}
NvBlastAsset* buildAsset(const NvBlastAssetDesc& desc)
@@ -170,14 +208,14 @@ public:
std::vector<uint32_t> chunkReorderMap(desc.chunkCount);
std::vector<char> scratch(desc.chunkCount * sizeof(NvBlastChunkDesc));
NvBlastEnsureAssetExactSupportCoverage(chunkDescs.data(), fixedDesc.chunkCount, scratch.data(), messageLog);
- NvBlastReorderAssetDescChunks(chunkDescs.data(), fixedDesc.chunkCount, bondDescs.data(), fixedDesc.bondCount, chunkReorderMap.data(), scratch.data(), messageLog);
+ NvBlastReorderAssetDescChunks(chunkDescs.data(), fixedDesc.chunkCount, bondDescs.data(), fixedDesc.bondCount, chunkReorderMap.data(), true, scratch.data(), messageLog);
fixedDesc.chunkDescs = chunkDescs.data();
fixedDesc.bondDescs = bondDescs.empty() ? nullptr : bondDescs.data();
// create asset
m_scratch.resize((size_t)NvBlastGetRequiredScratchForCreateAsset(&fixedDesc, messageLog));
void* mem = alloc(NvBlastGetAssetMemorySize(&fixedDesc, messageLog));
- NvBlastAsset* asset = NvBlastCreateAsset(mem, &fixedDesc, &m_scratch[0], messageLog);
+ NvBlastAsset* asset = NvBlastCreateAsset(mem, &fixedDesc, m_scratch.data(), messageLog);
EXPECT_TRUE(asset != nullptr);
return asset;
}
@@ -199,7 +237,7 @@ public:
void* fmem = alloc(NvBlastAssetGetFamilyMemorySize(&asset, nullptr));
NvBlastFamily* family = NvBlastAssetCreateFamily(fmem, &asset, nullptr);
std::vector<char> scratch((size_t)NvBlastFamilyGetRequiredScratchForCreateFirstActor(family, messageLog));
- NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, &scratch[0], messageLog);
+ NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, scratch.data(), messageLog);
EXPECT_TRUE(actor != nullptr);
return actor;
}
@@ -252,7 +290,7 @@ public:
NvBlastFamily* family = NvBlastActorGetFamily(actors[0], messageLog);
- const uint32_t supportChunkCount = actors[0]->getAsset()->m_graph.m_nodeCount;
+ const uint32_t supportChunkCount = NvBlastAssetGetSupportChunkCount(&asset, messageLog);
const uint32_t leafChunkCount = actors[0]->getAsset()->m_leafChunkCount;
// Now randomly partition the actors in the array, and keep going until we're down to single support chunks
@@ -290,7 +328,7 @@ public:
if (bondIndex != Nv::Blast::invalidIndex<uint32_t>())
{
a->damageBond(g[0], g[1], bondIndex, 100.0f);
- a->findIslands(&m_scratch[0]);
+ a->findIslands(m_scratch.data());
}
}
else
@@ -349,13 +387,21 @@ public:
++remainingActorCount;
- NVBLAST_ASSERT(1 == a->getVisibleChunkCount());
- EXPECT_EQ(1, a->getVisibleChunkCount());
+ NVBLAST_ASSERT(1 == a->getVisibleChunkCount() || a->isBoundToWorld());
+ EXPECT_TRUE(1 == a->getVisibleChunkCount() || a->isBoundToWorld());
if (!partitionToSubsupport)
{
EXPECT_EQ(1, a->getGraphNodeCount());
}
+ if (0 == a->getVisibleChunkCount())
+ {
+ EXPECT_TRUE(a->isBoundToWorld());
+ EXPECT_EQ(1, a->getGraphNodeCount());
+ EXPECT_EQ(a->getFamilyHeader()->m_asset->m_graph.m_nodeCount - 1, a->getFirstGraphNodeIndex());
+ --remainingActorCount; // Do not count this as a remaining actor, to be compared with leaf or support chunk counts later
+ }
+
const bool actorReleaseResult = NvBlastActorDeactivate(actors[i], nullptr);
EXPECT_TRUE(actorReleaseResult);
}
@@ -388,7 +434,11 @@ public:
std::vector<bool> isSupport(asset.m_chunkCount, false);
for (uint32_t i = 0; i < asset.m_graph.m_nodeCount; ++i)
{
- isSupport[asset.m_graph.getChunkIndices()[i]] = true;
+ const uint32_t chunkIndex = asset.m_graph.getChunkIndices()[i];
+ if (!Nv::Blast::isInvalidIndex(chunkIndex))
+ {
+ isSupport[chunkIndex] = true;
+ }
}
// Climb hierarchy to find support chunk
@@ -416,7 +466,7 @@ public:
// Mark visible nodes representing graph chunks
std::vector<bool> visibleChunkFound(asset.m_chunkCount, false);
- // Make sure every graph chunk is represented by a visible chunk
+ // Make sure every graph chunk is represented by a visible chunk, or represents the world
for (Nv::Blast::Actor::GraphNodeIt i = actor; (bool)i; ++i)
{
const uint32_t graphNodeIndex = (uint32_t)i;
@@ -433,7 +483,7 @@ public:
}
chunkIndex = chunks[chunkIndex].parentChunkIndex;
}
- EXPECT_FALSE(Nv::Blast::isInvalidIndex(chunkIndex));
+ EXPECT_TRUE(!Nv::Blast::isInvalidIndex(chunkIndex) || (graphNodeIndex == asset.m_graph.m_nodeCount-1 && actor.isBoundToWorld()));
}
// Check that all visible chunks are accounted for
@@ -564,7 +614,7 @@ public:
{
const uint32_t actorCountExpected = NvBlastFamilyGetActorCount(storageFamily, logFn);
std::vector<NvBlastActor*> blockActors(actorCountExpected);
- const uint32_t actorCountReturned = NvBlastFamilyGetActors(&blockActors[0], actorCountExpected, storageFamily, logFn);
+ const uint32_t actorCountReturned = NvBlastFamilyGetActors(blockActors.data(), actorCountExpected, storageFamily, logFn);
EXPECT_EQ(actorCountExpected, actorCountReturned);
}
compareFamilies(storageFamily, actorFamily, size, logFn);
@@ -591,7 +641,7 @@ public:
EXPECT_GE(serSizeBound, serSize);
std::vector<char>& stream = streams[i];
stream.resize(serSize);
- const uint32_t bytesWritten = NvBlastActorSerialize(&stream[0], serSize, actors[i], logFn);
+ const uint32_t bytesWritten = NvBlastActorSerialize(stream.data(), serSize, actors[i], logFn);
EXPECT_EQ(serSize, bytesWritten);
}
@@ -607,7 +657,7 @@ public:
for (size_t i = 0; i < actors.size(); ++i)
{
- NvBlastActor* newActor = NvBlastFamilyDeserializeActor(newFamily, &streams[order[i]][0], logFn);
+ NvBlastActor* newActor = NvBlastFamilyDeserializeActor(newFamily, streams[order[i]].data(), logFn);
EXPECT_TRUE(newActor != nullptr);
}
@@ -632,7 +682,7 @@ public:
const NvBlastFamily* oldFamily = NvBlastActorGetFamily(&a, logFn);
const uint32_t size = NvBlastFamilyGetSize(oldFamily, logFn);
std::vector<char> buffer((char*)oldFamily, (char*)oldFamily + size);
- NvBlastFamily* familyCopy = reinterpret_cast<NvBlastFamily*>(&buffer[0]);
+ NvBlastFamily* familyCopy = reinterpret_cast<NvBlastFamily*>(buffer.data());
const uint32_t serCount = 1 + (rand() % actors.size() - 1);
@@ -661,7 +711,7 @@ public:
for (uint32_t i = 0; i < serCount; ++i)
{
- NvBlastActor* newActor = NvBlastFamilyDeserializeActor(familyCopy, &streams[i][0], logFn);
+ NvBlastActor* newActor = NvBlastFamilyDeserializeActor(familyCopy, streams[i].data(), logFn);
EXPECT_TRUE(newActor != nullptr);
}
@@ -676,7 +726,7 @@ public:
bool simple,
void (*actorTest)(const Nv::Blast::Actor&, NvBlastLog),
void (*postDamageTest)(std::vector<NvBlastActor*>&, NvBlastLog),
- CubeAssetGenerator::BondFlags bondFlags = CubeAssetGenerator::BondFlags::ALL_BONDS
+ CubeAssetGenerator::BondFlags bondFlags = CubeAssetGenerator::BondFlags::ALL_INTERNAL_BONDS
)
{
const float relativeDamageRadius = simple ? 0.75f : 0.2f;
@@ -729,7 +779,6 @@ public:
desc.chunkCount = (uint32_t)testAsset.solverChunks.size();
desc.bondDescs = testAsset.solverBonds.data();
desc.bondCount = (uint32_t)testAsset.solverBonds.size();
-
NvBlastAsset* asset = buildAsset(desc);
NvBlastID assetID = NvBlastAssetGetID(asset, messageLog);
@@ -784,7 +833,7 @@ public:
const uint32_t actorsWritten = NvBlastFamilyGetActors(&buffer1[0], actorCount, family, messageLog);
EXPECT_EQ(actorsWritten, actorCount);
std::vector<NvBlastActor*> buffer2(actors.begin(), actors.end());
- EXPECT_EQ(0, memcmp(&buffer1[0], &buffer2[0], actorCount*sizeof(NvBlastActor*)));
+ EXPECT_EQ(0, memcmp(&buffer1[0], buffer2.data(), actorCount*sizeof(NvBlastActor*)));
}
}
// Test individual actors
@@ -925,7 +974,7 @@ TEST_F(ActorTestAllowWarnings, ActorHealthInitialization)
void* fmem = alloc(NvBlastAssetGetFamilyMemorySize(asset, messageLog));
NvBlastFamily* family = NvBlastAssetCreateFamily(fmem, asset, nullptr);
std::vector<char> scratch((size_t)NvBlastFamilyGetRequiredScratchForCreateFirstActor(family, messageLog));
- NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, &scratch[0], messageLog);
+ NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, scratch.data(), messageLog);
EXPECT_TRUE(actor != nullptr);
Nv::Blast::Actor& actorInt = static_cast<Nv::Blast::Actor&>(*actor);
@@ -1053,7 +1102,20 @@ TEST_F(ActorTestStrict, DamageLeafSupportActorTestActorSerializationPartialBlock
TEST_F(ActorTestStrict, DamageMultipleIslandLeafSupportActorsTestVisibility)
{
- damageLeafSupportActors(4, 4, 5, false, testActorVisibleChunks, nullptr, CubeAssetGenerator::BondFlags::Y_BONDS | CubeAssetGenerator::BondFlags::Z_BONDS); // Only connect y-z plane islands
- damageLeafSupportActors(4, 4, 5, false, testActorVisibleChunks, nullptr, CubeAssetGenerator::BondFlags::Z_BONDS); // Only connect z-direction islands
- damageLeafSupportActors(4, 4, 5, false, testActorVisibleChunks, nullptr, CubeAssetGenerator::BondFlags::NO_BONDS); // All support chunks disconnected (single-chunk islands)
+ typedef CubeAssetGenerator::BondFlags BF;
+ damageLeafSupportActors(4, 4, 5, false, testActorVisibleChunks, nullptr, BF::Y_BONDS | BF::Z_BONDS); // Only connect y-z plane islands
+ damageLeafSupportActors(4, 4, 5, false, testActorVisibleChunks, nullptr, BF::Z_BONDS); // Only connect z-direction islands
+ damageLeafSupportActors(4, 4, 5, false, testActorVisibleChunks, nullptr, BF::NO_BONDS); // All support chunks disconnected (single-chunk islands)
+}
+
+TEST_F(ActorTestStrict, DamageBoundToWorldLeafSupportActorsTestVisibility)
+{
+ typedef CubeAssetGenerator::BondFlags BF;
+ damageLeafSupportActors(4, 4, 5, false, testActorVisibleChunks, nullptr, BF::ALL_INTERNAL_BONDS | BF::X_MINUS_WORLD_BONDS);
+ damageLeafSupportActors(4, 4, 5, false, testActorVisibleChunks, nullptr, BF::ALL_INTERNAL_BONDS | BF::Y_PLUS_WORLD_BONDS);
+ damageLeafSupportActors(4, 4, 5, false, testActorVisibleChunks, nullptr, BF::ALL_INTERNAL_BONDS | BF::Z_MINUS_WORLD_BONDS);
+ damageLeafSupportActors(4, 4, 5, false, testActorVisibleChunks, nullptr, BF::ALL_INTERNAL_BONDS | BF::X_PLUS_WORLD_BONDS | BF::Y_MINUS_WORLD_BONDS);
+ damageLeafSupportActors(4, 4, 5, false, testActorVisibleChunks, nullptr, BF::ALL_INTERNAL_BONDS | BF::X_PLUS_WORLD_BONDS | BF::X_MINUS_WORLD_BONDS
+ | BF::Y_PLUS_WORLD_BONDS | BF::Y_MINUS_WORLD_BONDS
+ | BF::Z_PLUS_WORLD_BONDS | BF::Z_MINUS_WORLD_BONDS);
}
diff --git a/test/src/unit/AssetTests.cpp b/test/src/unit/AssetTests.cpp
index 24e5f77..3b1ca7b 100644
--- a/test/src/unit/AssetTests.cpp
+++ b/test/src/unit/AssetTests.cpp
@@ -1,4 +1,33 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2017 NVIDIA Corporation. All rights reserved.
+
+
#include "NvBlastAsset.h"
+#include "NvBlastMath.h"
#include "BlastBaseTest.h"
@@ -7,20 +36,18 @@
#include <algorithm>
-#if defined(_MSC_VER) && _MSC_VER < 1900 || defined(_XBOX_ONE) || defined(PS4) || PX_LINUX
-#define ENABLE_SERIALIZATION_TESTS 0
-#else
+// all supported platform now provide serialization
+// keep the define for future platforms that won't
#define ENABLE_SERIALIZATION_TESTS 1
-#endif
#pragma warning( push )
#pragma warning( disable : 4267 )
// NOTE: Instead of excluding serialization and the tests when on VC12, should break the tests out into a separate C++ file.
#if ENABLE_SERIALIZATION_TESTS
-#include "NvBlastExtSerializationInterface.h"
-
-#include "generated/NvBlastExtSerialization.capn.h"
+#include "NvBlastExtSerialization.h"
+#include "NvBlastExtLlSerialization.h"
+#include "NvBlastExtSerializationInternal.h"
#endif
#pragma warning( pop )
@@ -39,10 +66,7 @@ public:
AssetTest()
{
- Nv::Blast::TkFrameworkDesc desc;
- desc.allocatorCallback = this;
- desc.errorCallback = this;
- NvBlastTkFrameworkCreate(desc);
+ NvBlastTkFrameworkCreate();
}
~AssetTest()
@@ -57,12 +81,12 @@ public:
static void* alloc(size_t size)
{
- return BlastBaseTest<FailLevel, Verbosity>::alloc(size);
+ return BlastBaseTest<FailLevel, Verbosity>::alignedZeroedAlloc(size);
}
static void free(void* mem)
{
- BlastBaseTest<FailLevel, Verbosity>::free(mem);
+ BlastBaseTest<FailLevel, Verbosity>::alignedFree(mem);
}
void testSubtreeLeafChunkCounts(const Nv::Blast::Asset& a)
@@ -112,7 +136,7 @@ public:
std::vector<char> scratch;
scratch.resize((size_t)NvBlastGetRequiredScratchForCreateAsset(desc, messageLog));
void* mem = alloc(NvBlastGetAssetMemorySize(desc, messageLog));
- NvBlastAsset* asset = NvBlastCreateAsset(mem, desc, &scratch[0], messageLog);
+ NvBlastAsset* asset = NvBlastCreateAsset(mem, desc, scratch.data(), messageLog);
EXPECT_TRUE(asset != nullptr);
if (asset == nullptr)
{
@@ -141,13 +165,103 @@ public:
testChunkToNodeMap(asset);
}
+ // expects that the bond normal points from the lower indexed chunk to higher index chunk
+ // uses chunk.centroid
+ // convention, requirement from findClosestNode
+ void checkNormalDir(NvBlastChunkDesc* chunkDescs, size_t chunkDescCount, NvBlastBondDesc* bondDescs, size_t bondDescCount)
+ {
+ for (size_t bondIndex = 0; bondIndex < bondDescCount; ++bondIndex)
+ {
+ NvBlastBondDesc& bond = bondDescs[bondIndex];
+ uint32_t chunkIndex0 = bond.chunkIndices[0];
+ uint32_t chunkIndex1 = bond.chunkIndices[1];
+
+ bool swap = chunkIndex0 > chunkIndex1;
+ uint32_t testIndex0 = swap ? chunkIndex1 : chunkIndex0;
+ uint32_t testIndex1 = swap ? chunkIndex0 : chunkIndex1;
+
+ EXPECT_TRUE(testIndex0 < testIndex1);
+
+ // no convention for world chunks
+ if (!Nv::Blast::isInvalidIndex(testIndex0) && !Nv::Blast::isInvalidIndex(testIndex1))
+ {
+ NvBlastChunkDesc& chunk0 = chunkDescs[testIndex0];
+ NvBlastChunkDesc& chunk1 = chunkDescs[testIndex1];
+
+ float dir[3];
+ Nv::Blast::VecMath::sub(chunk1.centroid, chunk0.centroid, dir);
+ bool meetsConvention = Nv::Blast::VecMath::dot(bond.bond.normal, dir) > 0;
+ EXPECT_TRUE(meetsConvention);
+ if (!meetsConvention)
+ {
+ printf("bond %zd chunks(%d,%d): %.2f %.2f %.2f %.2f %.2f %.2f %d\n",
+ bondIndex, chunkIndex0, chunkIndex1,
+ bond.bond.normal[0], bond.bond.normal[1], bond.bond.normal[2],
+ dir[0], dir[1], dir[2],
+ Nv::Blast::VecMath::dot(bond.bond.normal, dir) > 0);
+ }
+ }
+ }
+ }
+
+ // expects that the bond normal points from the lower indexed node to higher index node
+ // uses chunk.centroid
+ // convention, requirement from findClosestNode
+ void checkNormalDir(const NvBlastSupportGraph graph, const NvBlastChunk* assetChunks, const NvBlastBond* assetBonds)
+ {
+ for (uint32_t nodeIndex = 0; nodeIndex < graph.nodeCount; nodeIndex++)
+ {
+ uint32_t adjStart = graph.adjacencyPartition[nodeIndex];
+ uint32_t adjStop = graph.adjacencyPartition[nodeIndex + 1];
+ for (uint32_t adj = adjStart; adj < adjStop; ++adj)
+ {
+ uint32_t adjNodeIndex = graph.adjacentNodeIndices[adj];
+
+ bool swap = nodeIndex > adjNodeIndex;
+ uint32_t testIndex0 = swap ? adjNodeIndex : nodeIndex;
+ uint32_t testIndex1 = swap ? nodeIndex : adjNodeIndex;
+
+ // no convention for world chunks
+ if (!Nv::Blast::isInvalidIndex(graph.chunkIndices[testIndex0]) && !Nv::Blast::isInvalidIndex(graph.chunkIndices[testIndex1]))
+ {
+ const NvBlastChunk& chunk0 = assetChunks[graph.chunkIndices[testIndex0]];
+ const NvBlastChunk& chunk1 = assetChunks[graph.chunkIndices[testIndex1]];
+
+ uint32_t bondIndex = graph.adjacentBondIndices[adj];
+ const NvBlastBond& bond = assetBonds[bondIndex];
+
+ float dir[3];
+ Nv::Blast::VecMath::sub(chunk1.centroid, chunk0.centroid, dir);
+ bool meetsConvention = Nv::Blast::VecMath::dot(bond.normal, dir) > 0;
+ EXPECT_TRUE(meetsConvention);
+ if (!meetsConvention)
+ {
+ printf("bond %d nodes(%d,%d): %.2f %.2f %.2f %.2f %.2f %.2f %d\n",
+ bondIndex, nodeIndex, adjNodeIndex,
+ bond.normal[0], bond.normal[1], bond.normal[2],
+ dir[0], dir[1], dir[2],
+ Nv::Blast::VecMath::dot(bond.normal, dir) > 0);
+ }
+ }
+ }
+ }
+ }
+
+ void checkNormalDir(const NvBlastAsset* asset)
+ {
+ const NvBlastChunk* assetChunks = NvBlastAssetGetChunks(asset, nullptr);
+ const NvBlastBond* assetBonds = NvBlastAssetGetBonds(asset, nullptr);
+ const NvBlastSupportGraph graph = NvBlastAssetGetSupportGraph(asset, nullptr);
+ checkNormalDir(graph, assetChunks, assetBonds);
+ }
+
void buildAssetShufflingDescriptors(const NvBlastAssetDesc* desc, const ExpectedAssetValues& expected, uint32_t shuffleCount, bool useTk)
{
NvBlastAssetDesc shuffledDesc = *desc;
std::vector<NvBlastChunkDesc> chunkDescs(desc->chunkDescs, desc->chunkDescs + desc->chunkCount);
- shuffledDesc.chunkDescs = &chunkDescs[0];
+ shuffledDesc.chunkDescs = chunkDescs.data();
std::vector<NvBlastBondDesc> bondDescs(desc->bondDescs, desc->bondDescs + desc->bondCount);
- shuffledDesc.bondDescs = &bondDescs[0];
+ shuffledDesc.bondDescs = bondDescs.data();
if (!useTk)
{
std::vector<char> scratch(desc->chunkCount);
@@ -159,9 +273,13 @@ public:
}
for (uint32_t i = 0; i < shuffleCount; ++i)
{
- shuffleAndFixChunkDescs(&chunkDescs[0], desc->chunkCount, &bondDescs[0], desc->bondCount, useTk);
+ checkNormalDir(chunkDescs.data(), chunkDescs.size(), bondDescs.data(), bondDescs.size());
+ shuffleAndFixChunkDescs(chunkDescs.data(), desc->chunkCount, bondDescs.data(), desc->bondCount, useTk);
+ checkNormalDir(chunkDescs.data(), chunkDescs.size(), bondDescs.data(), bondDescs.size());
+
NvBlastAsset* asset = buildAsset(expected, &shuffledDesc);
EXPECT_TRUE(asset != nullptr);
+ checkNormalDir(asset);
if (asset)
{
free(asset);
@@ -193,7 +311,11 @@ public:
std::vector<NvBlastBondDesc> savedBondDescs(bondDescs, bondDescs + bondDescCount);
// Shuffle chunks and bonds
- NvBlastApplyAssetDescChunkReorderMap(shuffledChunkDescs.data(), chunkDescs, chunkDescCount, bondDescs, bondDescCount, shuffledOrder.data(), nullptr);
+ NvBlastApplyAssetDescChunkReorderMap(shuffledChunkDescs.data(), chunkDescs, chunkDescCount, bondDescs, bondDescCount, shuffledOrder.data(), true, nullptr);
+
+ // All the normals are pointing in the expected direction (they have been swapped)
+ checkNormalDir(shuffledChunkDescs.data(), chunkDescCount, bondDescs, bondDescCount);
+ checkNormalDir(chunkDescs, chunkDescCount, savedBondDescs.data(), bondDescCount);
// Check the results
for (uint32_t i = 0; i < chunkDescCount; ++i)
@@ -205,7 +327,10 @@ public:
{
for (uint32_t k = 0; k < 2; ++k)
{
- EXPECT_EQ(shuffledOrder[savedBondDescs[i].chunkIndices[k]], bondDescs[i].chunkIndices[k]);
+ if (!Nv::Blast::isInvalidIndex(savedBondDescs[i].chunkIndices[k]))
+ {
+ EXPECT_EQ(shuffledOrder[savedBondDescs[i].chunkIndices[k]], bondDescs[i].chunkIndices[k]);
+ }
}
}
@@ -239,12 +364,12 @@ public:
std::vector<char> scratch2(2 * chunkDescCount * sizeof(uint32_t));
const bool isIdentity = NvBlastBuildAssetDescChunkReorderMap(chunkReorderMap.data(), shuffledChunkDescs.data(), chunkDescCount, scratch2.data(), messageLog);
EXPECT_FALSE(isIdentity);
- NvBlastApplyAssetDescChunkReorderMap(chunkDescs, shuffledChunkDescs.data(), chunkDescCount, bondDescs, bondDescCount, chunkReorderMap.data(), messageLog);
+ NvBlastApplyAssetDescChunkReorderMap(chunkDescs, shuffledChunkDescs.data(), chunkDescCount, bondDescs, bondDescCount, chunkReorderMap.data(), true, messageLog);
}
else
{
memcpy(chunkDescs, shuffledChunkDescs.data(), chunkDescCount * sizeof(NvBlastChunkDesc));
- const bool isIdentity = NvBlastTkFrameworkGet()->reorderAssetDescChunks(chunkDescs, chunkDescCount, bondDescs, bondDescCount);
+ const bool isIdentity = NvBlastTkFrameworkGet()->reorderAssetDescChunks(chunkDescs, chunkDescCount, bondDescs, bondDescCount, nullptr, true);
EXPECT_FALSE(isIdentity);
}
}
@@ -278,55 +403,14 @@ TEST_F(AssetTestStrict, BuildAssets)
}
#if ENABLE_SERIALIZATION_TESTS
-// Restricting this test to windows since we don't have a handy cross platform temp file.
-#if defined(WIN32) || defined(WIN64)
-TEST_F(AssetTestStrict, SerializeAssetIntoFile)
+TEST_F(AssetTestStrict, SerializeAssets)
{
- const uint32_t assetDescCount = sizeof(g_assetDescs) / sizeof(g_assetDescs[0]);
-
- std::vector<Nv::Blast::Asset *> assets(assetDescCount);
-
- // Build
- for (uint32_t i = 0; i < assetDescCount; ++i)
- {
- assets[i] = reinterpret_cast<Nv::Blast::Asset*>(buildAsset(g_assetExpectedValues[i], &g_assetDescs[i]));
- }
-
- char tempPath[1024];
- GetTempPathA(1024, tempPath);
-
- char tempFilename[1024];
-
- GetTempFileNameA(tempPath, nullptr, 0, tempFilename);
-
- std::ofstream myFile(tempFilename, std::ios::out | std::ios::binary);
-
- EXPECT_TRUE(serializeAssetIntoStream(assets[0], myFile));
+ Nv::Blast::ExtSerialization* ser = NvBlastExtSerializationCreate();
+ EXPECT_TRUE(ser != nullptr);
- myFile.flush();
-
- // Load it back
-
- std::ifstream myFileReader(tempFilename, std::ios::binary);
-
- Nv::Blast::Asset* rtAsset = reinterpret_cast<Nv::Blast::Asset *>(deserializeAssetFromStream(myFileReader));
- EXPECT_TRUE(rtAsset != nullptr);
-
- checkAssetsExpected(*rtAsset, g_assetExpectedValues[0]);
-
- for (uint32_t i = 0; i < assetDescCount; ++i)
- {
- free(assets[i]);
- }
- free(rtAsset);
-}
-#endif
-
-TEST_F(AssetTestStrict, SerializeAssetsNewBuffer)
-{
const uint32_t assetDescCount = sizeof(g_assetDescs) / sizeof(g_assetDescs[0]);
- std::vector<Nv::Blast::Asset *> assets(assetDescCount);
+ std::vector<Nv::Blast::Asset*> assets(assetDescCount);
// Build
for (uint32_t i = 0; i < assetDescCount; ++i)
@@ -337,14 +421,17 @@ TEST_F(AssetTestStrict, SerializeAssetsNewBuffer)
// Serialize them
for (Nv::Blast::Asset* asset : assets)
{
- uint32_t size = 0;
- unsigned char* buffer = nullptr;
-
-
-// auto result = Nv::Blast::BlastSerialization<Nv::Blast::Asset, Nv::Blast::Serialization::Asset::Reader, Nv::Blast::Serialization::Asset::Builder>::serializeIntoNewBuffer(asset, &buffer, size);
- EXPECT_TRUE(serializeAssetIntoNewBuffer(asset, &buffer, size));
-
- free(static_cast<void*>(buffer));
+ void* buffer;
+ const uint64_t size = NvBlastExtSerializationSerializeAssetIntoBuffer(buffer, *ser, asset);
+ EXPECT_TRUE(size != 0);
+
+ uint32_t objectTypeID;
+ uint32_t encodingID;
+ uint64_t dataSize = 0;
+ EXPECT_TRUE(ser->peekHeader(&objectTypeID, &encodingID, &dataSize, buffer, size));
+ EXPECT_EQ(objectTypeID, Nv::Blast::LlObjectTypeID::Asset);
+ EXPECT_EQ(encodingID, ser->getSerializationEncoding());
+ EXPECT_EQ(dataSize + Nv::Blast::ExtSerializationInternal::HeaderSize, size);
}
// Destroy
@@ -356,13 +443,17 @@ TEST_F(AssetTestStrict, SerializeAssetsNewBuffer)
}
}
+ ser->release();
}
-TEST_F(AssetTestStrict, SerializeAssetsExistingBuffer)
+TEST_F(AssetTestStrict, SerializeAssetsRoundTrip)
{
+ Nv::Blast::ExtSerialization* ser = NvBlastExtSerializationCreate();
+ EXPECT_TRUE(ser != nullptr);
+
const uint32_t assetDescCount = sizeof(g_assetDescs) / sizeof(g_assetDescs[0]);
- std::vector<Nv::Blast::Asset *> assets(assetDescCount);
+ std::vector<Nv::Blast::Asset*> assets(assetDescCount);
// Build
for (uint32_t i = 0; i < assetDescCount; ++i)
@@ -370,20 +461,33 @@ TEST_F(AssetTestStrict, SerializeAssetsExistingBuffer)
assets[i] = reinterpret_cast<Nv::Blast::Asset*>(buildAsset(g_assetExpectedValues[i], &g_assetDescs[i]));
}
- // How big does our buffer need to be? Guess.
-
- uint32_t maxSize = 1024 * 1024;
- void* buffer = alloc(maxSize);
+ const uint32_t encodings[] =
+ {
+ Nv::Blast::ExtSerialization::EncodingID::CapnProtoBinary,
+ Nv::Blast::ExtSerialization::EncodingID::RawBinary
+ };
- // Serialize them
- for (Nv::Blast::Asset* asset : assets)
+ for (auto encoding : encodings)
{
- uint32_t usedSize = 0;
+ ser->setSerializationEncoding(encoding);
- EXPECT_TRUE(serializeAssetIntoExistingBuffer(asset, (unsigned char *)buffer, maxSize, usedSize));
- }
+ // Serialize them
+ for (uint32_t i = 0; i < assetDescCount; ++i)
+ {
+ Nv::Blast::Asset* asset = assets[i];
- free(static_cast<void*>(buffer));
+ void* buffer;
+ const uint64_t size = NvBlastExtSerializationSerializeAssetIntoBuffer(buffer, *ser, asset);
+ EXPECT_TRUE(size != 0);
+
+ Nv::Blast::Asset* rtAsset = reinterpret_cast<Nv::Blast::Asset*>(ser->deserializeFromBuffer(buffer, size));
+
+ //TODO: Compare assets
+ checkAssetsExpected(*rtAsset, g_assetExpectedValues[i]);
+
+ free(static_cast<void*>(rtAsset));
+ }
+ }
// Destroy
for (uint32_t i = 0; i < assetDescCount; ++i)
@@ -394,13 +498,39 @@ TEST_F(AssetTestStrict, SerializeAssetsExistingBuffer)
}
}
+ ser->release();
}
-TEST_F(AssetTestStrict, SerializeAssetsRoundTrip)
+TEST_F(AssetTestStrict, SerializeAssetsRoundTripWithSkipping)
{
+ Nv::Blast::ExtSerialization* ser = NvBlastExtSerializationCreate();
+ EXPECT_TRUE(ser != nullptr);
+
+ std::vector<char> stream;
+
+ class StreamBufferProvider : public Nv::Blast::ExtSerialization::BufferProvider
+ {
+ public:
+ StreamBufferProvider(std::vector<char>& stream) : m_stream(stream), m_cursor(0) {}
+
+ virtual void* requestBuffer(size_t size) override
+ {
+ m_stream.resize(m_cursor + size);
+ void* data = m_stream.data() + m_cursor;
+ m_cursor += size;
+ return data;
+ }
+
+ private:
+ std::vector<char>& m_stream;
+ size_t m_cursor;
+ } myStreamProvider(stream);
+
+ ser->setBufferProvider(&myStreamProvider);
+
const uint32_t assetDescCount = sizeof(g_assetDescs) / sizeof(g_assetDescs[0]);
- std::vector<Nv::Blast::Asset *> assets(assetDescCount);
+ std::vector<Nv::Blast::Asset*> assets(assetDescCount);
// Build
for (uint32_t i = 0; i < assetDescCount; ++i)
@@ -408,66 +538,82 @@ TEST_F(AssetTestStrict, SerializeAssetsRoundTrip)
assets[i] = reinterpret_cast<Nv::Blast::Asset*>(buildAsset(g_assetExpectedValues[i], &g_assetDescs[i]));
}
- // Serialize them
- for (uint32_t i = 0; i < assetDescCount; ++i)
+ const uint32_t encodings[] =
{
- Nv::Blast::Asset* asset = assets[i];
- uint32_t size = 0;
- unsigned char* buffer = nullptr;
-
- EXPECT_TRUE(serializeAssetIntoNewBuffer(asset, &buffer, size));
+ Nv::Blast::ExtSerialization::EncodingID::CapnProtoBinary,
+ Nv::Blast::ExtSerialization::EncodingID::RawBinary
+ };
- // No release needed for this asset since it's never put into that system
- Nv::Blast::Asset* rtAsset = reinterpret_cast<Nv::Blast::Asset*>(deserializeAsset(buffer, size));
-
- //TODO: Compare assets
- checkAssetsExpected(*rtAsset, g_assetExpectedValues[i]);
+ for (auto encoding : encodings)
+ {
+ ser->setSerializationEncoding(encoding);
- free(static_cast<void*>(buffer));
- free(static_cast<void*>(rtAsset));
+ // Serialize them
+ for (uint32_t i = 0; i < assetDescCount; ++i)
+ {
+ void* buffer;
+ const uint64_t size = NvBlastExtSerializationSerializeAssetIntoBuffer(buffer, *ser, assets[i]);
+ EXPECT_TRUE(size != 0);
+ }
}
- // Destroy
- for (uint32_t i = 0; i < assetDescCount; ++i)
+ // Deserialize from stream
+ const void* buffer = stream.data();
+ uint64_t bufferSize = stream.size();
+ for (uint32_t assetCount = 0; bufferSize; ++assetCount)
{
- if (assets[i])
+ uint32_t objectTypeID;
+ uint32_t encodingID;
+ const bool peekSuccess = ser->peekHeader(&objectTypeID, &encodingID, nullptr, buffer, bufferSize);
+ EXPECT_TRUE(peekSuccess);
+ if (!peekSuccess)
{
- free(assets[i]);
+ break;
}
- }
-}
-#endif
+ EXPECT_EQ(Nv::Blast::LlObjectTypeID::Asset, objectTypeID);
+ if (assetCount < assetDescCount)
+ {
+ EXPECT_EQ(Nv::Blast::ExtSerialization::EncodingID::CapnProtoBinary, encodingID);
+ }
+ else
+ {
+ EXPECT_EQ(Nv::Blast::ExtSerialization::EncodingID::RawBinary, encodingID);
+ }
-#if 0
-TEST_F(AssetTestStrict, AssociateAsset)
-{
- const uint32_t assetDescCount = sizeof(g_assetDescs) / sizeof(g_assetDescs[0]);
+ const bool skip = (assetCount & 1) != 0;
- for (uint32_t i = 0; i < assetDescCount; ++i)
- {
- // Build
- NvBlastAsset asset;
- if (!buildAsset(&asset, g_assetExpectedValues[i], &g_assetDescs[i]))
+ if (!skip)
{
- continue;
+ const uint32_t assetnum = assetCount % assetDescCount;
+ Nv::Blast::Asset* rtAsset = reinterpret_cast<Nv::Blast::Asset*>(ser->deserializeFromBuffer(buffer, bufferSize));
+ EXPECT_TRUE(rtAsset != nullptr);
+ if (rtAsset == nullptr)
+ {
+ break;
+ }
+
+ //TODO: Compare assets
+ checkAssetsExpected(*rtAsset, g_assetExpectedValues[assetnum]);
+
+ free(static_cast<void*>(rtAsset));
}
- // Copy
- const char* data = (const char*)NvBlastAssetGetData(&asset, messageLog);
- const size_t dataSize = NvBlastAssetDataGetSize(data, messageLog);
- NvBlastAsset duplicate;
- char* duplicateData = (char*)alloc(dataSize);
- memcpy(duplicateData, data, dataSize);
- const bool assetAssociateResult = NvBlastAssetAssociateData(&duplicate, duplicateData, messageLog);
- EXPECT_TRUE(assetAssociateResult);
+ buffer = ser->skipObject(bufferSize, buffer);
+ }
- // Destroy
- NvBlastAssetFreeData(&asset, free, messageLog);
- NvBlastAssetFreeData(&duplicate, free, messageLog);
+ // Destroy
+ for (uint32_t i = 0; i < assetDescCount; ++i)
+ {
+ if (assets[i])
+ {
+ free(assets[i]);
+ }
}
+
+ ser->release();
}
-#endif
+#endif // ENABLE_SERIALIZATION_TESTS
TEST_F(AssetTestAllowWarnings, BuildAssetsMissingCoverage)
{
@@ -486,7 +632,7 @@ TEST_F(AssetTestAllowWarnings, BuildAssetsMissingCoverage)
std::vector<char> scratch(desc->chunkCount * sizeof(NvBlastChunkDesc));
const bool changedCoverage = !NvBlastEnsureAssetExactSupportCoverage(chunkDescs.data(), fixedDesc.chunkCount, scratch.data(), messageLog);
EXPECT_TRUE(changedCoverage);
- NvBlastReorderAssetDescChunks(chunkDescs.data(), fixedDesc.chunkCount, bondDescs.data(), fixedDesc.bondCount, chunkReorderMap.data(), scratch.data(), messageLog);
+ NvBlastReorderAssetDescChunks(chunkDescs.data(), fixedDesc.chunkCount, bondDescs.data(), fixedDesc.bondCount, chunkReorderMap.data(), true, scratch.data(), messageLog);
fixedDesc.chunkDescs = chunkDescs.data();
fixedDesc.bondDescs = bondDescs.data();
assets[i] = buildAsset(g_assetsFromMissingCoverageExpectedValues[i], &fixedDesc);
diff --git a/test/src/unit/CoreTests.cpp b/test/src/unit/CoreTests.cpp
index 4aff4ae..f4f0de1 100644
--- a/test/src/unit/CoreTests.cpp
+++ b/test/src/unit/CoreTests.cpp
@@ -1,3 +1,31 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2017 NVIDIA Corporation. All rights reserved.
+
+
#include <algorithm>
#include "gtest/gtest.h"
@@ -5,7 +33,7 @@
#include "NvBlastActor.h"
#include "NvBlastIndexFns.h"
-#include "AlignedAllocator.h"
+#include "NvBlastGlobals.h"
#include "TestAssets.h"
#include "NvBlastActor.h"
@@ -41,13 +69,50 @@ TEST(CoreTests, IndexStartLookup)
#include "NvBlastGeometry.h"
+int findClosestNodeByBonds(const float point[4], const NvBlastActor* actor)
+{
+ const Nv::Blast::Actor* a = static_cast<const Nv::Blast::Actor*>(actor);
+ const NvBlastFamily* family = NvBlastActorGetFamily(actor, messageLog);
+ const NvBlastAsset* asset = NvBlastFamilyGetAsset(family, messageLog);
+ const NvBlastSupportGraph graph = NvBlastAssetGetSupportGraph(asset, messageLog);
+ return Nv::Blast::findClosestNode(
+ point,
+ a->getFirstGraphNodeIndex(),
+ a->getFamilyHeader()->getGraphNodeIndexLinks(),
+ graph.adjacencyPartition,
+ graph.adjacentNodeIndices,
+ graph.adjacentBondIndices,
+ NvBlastAssetGetBonds(asset, messageLog),
+ NvBlastActorGetBondHealths(actor, messageLog),
+ graph.chunkIndices
+ );
+}
+
+int findClosestNodeByChunks(const float point[4], const NvBlastActor* actor)
+{
+ const Nv::Blast::Actor* a = static_cast<const Nv::Blast::Actor*>(actor);
+ return Nv::Blast::findClosestNode(
+ point,
+ a->getFirstGraphNodeIndex(),
+ a->getFamilyHeader()->getGraphNodeIndexLinks(),
+ a->getAsset()->m_graph.getAdjacencyPartition(),
+ a->getAsset()->m_graph.getAdjacentNodeIndices(),
+ a->getAsset()->m_graph.getAdjacentBondIndices(),
+ a->getAsset()->getBonds(),
+ a->getFamilyHeader()->getBondHealths(),
+ a->getAsset()->getChunks(),
+ a->getFamilyHeader()->getLowerSupportChunkHealths(),
+ a->getAsset()->m_graph.getChunkIndices()
+ );
+}
+
TEST(CoreTests, FindChunkByPosition)
{
std::vector<char> scratch;
const NvBlastAssetDesc& desc = g_assetDescs[0]; // 1-cube
scratch.resize((size_t)NvBlastGetRequiredScratchForCreateAsset(&desc, nullptr));
- void* amem = alignedAlloc<malloc>(NvBlastGetAssetMemorySize(&desc, nullptr));
- NvBlastAsset* asset = NvBlastCreateAsset(amem, &desc, &scratch[0], nullptr);
+ void* amem = NVBLAST_ALLOC(NvBlastGetAssetMemorySize(&desc, nullptr));
+ NvBlastAsset* asset = NvBlastCreateAsset(amem, &desc, scratch.data(), nullptr);
ASSERT_TRUE(asset != nullptr);
uint32_t expectedNode[] = { 0, 1, 2, 3, 4, 5, 6, 7 };
@@ -66,28 +131,21 @@ TEST(CoreTests, FindChunkByPosition)
NvBlastActorDesc actorDesc;
actorDesc.initialBondHealths = actorDesc.initialSupportChunkHealths = nullptr;
actorDesc.uniformInitialBondHealth = actorDesc.uniformInitialLowerSupportChunkHealth = 1.0f;
- void* fmem = alignedAlloc<malloc>(NvBlastAssetGetFamilyMemorySize(asset, nullptr));
+ void* fmem = NVBLAST_ALLOC(NvBlastAssetGetFamilyMemorySize(asset, nullptr));
NvBlastFamily* family = NvBlastAssetCreateFamily(fmem, asset, nullptr);
scratch.resize((size_t)NvBlastFamilyGetRequiredScratchForCreateFirstActor(family, nullptr));
- NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, &scratch[0], nullptr);
+ NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, scratch.data(), nullptr);
ASSERT_TRUE(actor != nullptr);
- std::vector<uint32_t> graphNodeIndices;
- graphNodeIndices.resize(NvBlastActorGetGraphNodeCount(actor, nullptr));
- const float* bondHealths = NvBlastActorGetBondHealths(actor, messageLog);
- uint32_t graphNodesCount = NvBlastActorGetGraphNodeIndices(graphNodeIndices.data(), (uint32_t)graphNodeIndices.size(), actor, nullptr);
-
- const NvBlastBond* bonds = NvBlastAssetGetBonds(asset, nullptr);
- NvBlastSupportGraph graph = NvBlastAssetGetSupportGraph(asset, nullptr);
for (int i = 0; i < 8; ++i, pos += 3)
{
- EXPECT_EQ(expectedNode[i], Nv::Blast::findNodeByPosition(pos, graphNodesCount, graphNodeIndices.data(), graph, bonds, bondHealths));
- EXPECT_EQ(expectedNode[i] + 1, NvBlastActorClosestChunk(pos, actor, nullptr)); // Works because (chunk index) = (node index) + 1 in these cases
+ EXPECT_EQ(expectedNode[i], findClosestNodeByBonds(pos, actor));
+ EXPECT_EQ(expectedNode[i], findClosestNodeByChunks(pos, actor));
}
EXPECT_TRUE(NvBlastActorDeactivate(actor, nullptr));
- alignedFree<free>(family);
- alignedFree<free>(asset);
+ NVBLAST_FREE(family);
+ NVBLAST_FREE(asset);
}
TEST(CoreTests, FindChunkByPositionUShape)
@@ -105,48 +163,41 @@ TEST(CoreTests, FindChunkByPositionUShape)
const NvBlastChunkDesc uchunks[7] =
{
// centroid volume parent idx flags ID
- { {0.0f, 0.0f, 0.0f}, 0.0f, UINT32_MAX, NvBlastChunkDesc::NoFlags, 0 },
- { {0.0f, 0.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 1 },
- { {0.0f, 0.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 2 },
- { {0.0f, 0.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 3 },
- { {0.0f, 0.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 4 },
- { {0.0f, 0.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 5 },
- { {0.0f, 0.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 6 }
+ { {3.0f, 2.0f, 0.0f}, 0.0f, UINT32_MAX, NvBlastChunkDesc::NoFlags, 0 },
+ { {1.0f, 1.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 1 },
+ { {3.0f, 1.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 2 },
+ { {5.0f, 1.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 3 },
+ { {1.0f, 3.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 4 },
+ { {3.0f, 3.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 5 },
+ { {5.0f, 3.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 6 }
};
const NvBlastBondDesc ubonds[5] =
{
- // chunks normal area centroid userData
- { { 2, 1 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 2.0f, 1.0f, 0.0f }, 0 } }, // index swap should not matter
- { { 2, 3 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 4.0f, 1.0f, 0.0f }, 0 } },
- { { 1, 4 }, { { 0.0f, 1.0f, 0.0f }, 1.0f, { 1.0f, 2.0f, 0.0f }, 0 } },
- { { 4, 5 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 2.0f, 3.0f, 0.0f }, 0 } },
- { { 5, 6 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 4.0f, 3.0f, 0.0f }, 0 } },
+// normal area centroid userData chunks
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 2.0f, 1.0f, 0.0f }, 0 }, { 2, 1 } }, // index swap should not matter
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 4.0f, 1.0f, 0.0f }, 0 }, { 2, 3 } },
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f, { 1.0f, 2.0f, 0.0f }, 0 }, { 1, 4 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 2.0f, 3.0f, 0.0f }, 0 }, { 4, 5 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 4.0f, 3.0f, 0.0f }, 0 }, { 5, 6 } },
};
const NvBlastAssetDesc desc = { 7, uchunks, 5, ubonds };
std::vector<char> scratch;
scratch.resize((size_t)NvBlastGetRequiredScratchForCreateAsset(&desc, messageLog));
- void* amem = alignedAlloc<malloc>(NvBlastGetAssetMemorySize(&desc, messageLog));
- NvBlastAsset* asset = NvBlastCreateAsset(amem, &desc, &scratch[0], messageLog);
+ void* amem = NVBLAST_ALLOC(NvBlastGetAssetMemorySize(&desc, messageLog));
+ NvBlastAsset* asset = NvBlastCreateAsset(amem, &desc, scratch.data(), messageLog);
ASSERT_TRUE(asset != nullptr);
NvBlastActorDesc actorDesc;
actorDesc.initialBondHealths = actorDesc.initialSupportChunkHealths = nullptr;
actorDesc.uniformInitialBondHealth = actorDesc.uniformInitialLowerSupportChunkHealth = 1.0f;
- void* fmem = alignedAlloc<malloc>(NvBlastAssetGetFamilyMemorySize(asset, messageLog));
+ void* fmem = NVBLAST_ALLOC(NvBlastAssetGetFamilyMemorySize(asset, messageLog));
NvBlastFamily* family = NvBlastAssetCreateFamily(fmem, asset, nullptr);
scratch.resize((size_t)NvBlastFamilyGetRequiredScratchForCreateFirstActor(family, messageLog));
- NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, &scratch[0], nullptr);
+ NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, scratch.data(), nullptr);
ASSERT_TRUE(actor != nullptr);
- std::vector<uint32_t> graphNodeIndices;
- graphNodeIndices.resize(NvBlastActorGetGraphNodeCount(actor, nullptr));
- uint32_t graphNodesCount = NvBlastActorGetGraphNodeIndices(graphNodeIndices.data(), (uint32_t)graphNodeIndices.size(), actor, nullptr);
-
- const NvBlastBond* bonds = NvBlastAssetGetBonds(asset, nullptr);
- NvBlastSupportGraph graph = NvBlastAssetGetSupportGraph(asset, nullptr);
-
srand(100);
for (uint32_t i = 0; i < 100000; i++)
{
@@ -162,90 +213,88 @@ TEST(CoreTests, FindChunkByPositionUShape)
//printf("iteration %i: %.1f %.1f %.1f expected: %d\n", i, rpos[0], rpos[1], rpos[2], expectedNode);
{
- uint32_t returnedNode = Nv::Blast::findNodeByPosition(rpos, graphNodesCount, graphNodeIndices.data(), graph, bonds, NvBlastActorGetBondHealths(actor, messageLog));
+ uint32_t returnedNode = findClosestNodeByBonds(rpos, actor);
if (expectedNode != returnedNode)
- Nv::Blast::findNodeByPosition(rpos, graphNodesCount, graphNodeIndices.data(), graph, bonds, NvBlastActorGetBondHealths(actor, messageLog));
+ findClosestNodeByBonds(rpos, actor);
EXPECT_EQ(expectedNode, returnedNode);
}
{
- // +1 to account for graph vs. asset indices
- uint32_t expectedChunk = expectedNode + 1;
- uint32_t returnedChunk = NvBlastActorClosestChunk(rpos, actor, nullptr);
- if (expectedChunk != returnedChunk)
- NvBlastActorClosestChunk(rpos, actor, nullptr);
- EXPECT_EQ(expectedChunk, returnedChunk);
+ uint32_t returnedNode = findClosestNodeByChunks(rpos, actor);
+ if (expectedNode != returnedNode)
+ findClosestNodeByChunks(rpos, actor);
+ EXPECT_EQ(expectedNode, returnedNode);
}
}
EXPECT_TRUE(NvBlastActorDeactivate(actor, messageLog));
- alignedFree<free>(family);
- alignedFree<free>(asset);
+ NVBLAST_FREE(family);
+ NVBLAST_FREE(asset);
}
TEST(CoreTests, FindChunkByPositionLandlocked)
{
+ // 7 > 8 > 9
+ // ^ ^ ^
+ // 4 > 5 > 6
+ // ^ ^ ^
+ // 1 > 2 > 3
+
+ // chunk 5 (node 4) is broken out (landlocked)
+ // find closest chunk/node on the two new actors
+
const NvBlastChunkDesc chunks[10] =
{
// centroid volume parent idx flags ID
{ {0.0f, 0.0f, 0.0f}, 0.0f, UINT32_MAX, NvBlastChunkDesc::NoFlags, 0 },
- { {0.0f, 0.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 1 },
- { {0.0f, 0.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 2 },
- { {0.0f, 0.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 3 },
- { {0.0f, 0.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 4 },
- { {0.0f, 0.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 5 },
- { {0.0f, 0.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 6 },
- { {0.0f, 0.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 7 },
- { {0.0f, 0.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 8 },
- { {0.0f, 0.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 9 },
+ { {1.0f, 1.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 1 },
+ { {3.0f, 1.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 2 },
+ { {5.0f, 1.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 3 },
+ { {1.0f, 3.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 4 },
+ { {3.0f, 3.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 5 },
+ { {5.0f, 3.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 6 },
+ { {1.0f, 5.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 7 },
+ { {3.0f, 5.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 8 },
+ { {5.0f, 5.0f, 0.0f}, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 9 },
};
const NvBlastBondDesc bonds[12] =
{
- // chunks normal area centroid userData
- { { 1, 2 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 2.0f, 1.0f, 0.0f }, 0 } },
- { { 2, 3 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 4.0f, 1.0f, 0.0f }, 0 } },
- { { 4, 5 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 2.0f, 3.0f, 0.0f }, 0 } },
- { { 5, 6 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 4.0f, 3.0f, 0.0f }, 0 } },
- { { 7, 8 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 2.0f, 5.0f, 0.0f }, 0 } },
- { { 8, 9 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 4.0f, 5.0f, 0.0f }, 0 } },
- { { 1, 4 }, { { 0.0f, 1.0f, 0.0f }, 1.0f, { 1.0f, 2.0f, 0.0f }, 0 } },
- { { 2, 5 }, { { 0.0f, 1.0f, 0.0f }, 1.0f, { 3.0f, 2.0f, 0.0f }, 0 } },
- { { 3, 6 }, { { 0.0f, 1.0f, 0.0f }, 1.0f, { 5.0f, 2.0f, 0.0f }, 0 } },
- { { 4, 7 }, { { 0.0f, 1.0f, 0.0f }, 1.0f, { 1.0f, 4.0f, 0.0f }, 0 } },
- { { 5, 8 }, { { 0.0f, 1.0f, 0.0f }, 1.0f, { 3.0f, 4.0f, 0.0f }, 0 } },
- { { 6, 9 }, { { 0.0f, 1.0f, 0.0f }, 1.0f, { 5.0f, 4.0f, 0.0f }, 0 } },
+// normal area centroid userData chunks
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 2.0f, 1.0f, 0.0f }, 0 }, { 1, 2 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 4.0f, 1.0f, 0.0f }, 0 }, { 2, 3 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 2.0f, 3.0f, 0.0f }, 0 }, { 4, 5 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 4.0f, 3.0f, 0.0f }, 0 }, { 5, 6 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 2.0f, 5.0f, 0.0f }, 0 }, { 7, 8 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 4.0f, 5.0f, 0.0f }, 0 }, { 8, 9 } },
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f, { 1.0f, 2.0f, 0.0f }, 0 }, { 1, 4 } },
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f, { 3.0f, 2.0f, 0.0f }, 0 }, { 2, 5 } },
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f, { 5.0f, 2.0f, 0.0f }, 0 }, { 3, 6 } },
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f, { 1.0f, 4.0f, 0.0f }, 0 }, { 4, 7 } },
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f, { 3.0f, 4.0f, 0.0f }, 0 }, { 5, 8 } },
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f, { 5.0f, 4.0f, 0.0f }, 0 }, { 6, 9 } },
};
const NvBlastAssetDesc desc = { 10, chunks, 12, bonds };
std::vector<char> scratch;
scratch.resize((size_t)NvBlastGetRequiredScratchForCreateAsset(&desc, messageLog));
- void* amem = alignedAlloc<malloc>(NvBlastGetAssetMemorySize(&desc, messageLog));
- NvBlastAsset* asset = NvBlastCreateAsset(amem, &desc, &scratch[0], messageLog);
+ void* amem = NVBLAST_ALLOC(NvBlastGetAssetMemorySize(&desc, messageLog));
+ NvBlastAsset* asset = NvBlastCreateAsset(amem, &desc, scratch.data(), messageLog);
ASSERT_TRUE(asset != nullptr);
NvBlastActorDesc actorDesc;
actorDesc.initialBondHealths = actorDesc.initialSupportChunkHealths = nullptr;
actorDesc.uniformInitialBondHealth = actorDesc.uniformInitialLowerSupportChunkHealth = 1.0f;
- void* fmem = alignedAlloc<malloc>(NvBlastAssetGetFamilyMemorySize(asset, nullptr));
+ void* fmem = NVBLAST_ALLOC(NvBlastAssetGetFamilyMemorySize(asset, nullptr));
NvBlastFamily* family = NvBlastAssetCreateFamily(fmem, asset, nullptr);
scratch.resize((size_t)NvBlastFamilyGetRequiredScratchForCreateFirstActor(family, nullptr));
- NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, &scratch[0], nullptr);
+ NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, scratch.data(), nullptr);
ASSERT_TRUE(actor != nullptr);
- const NvBlastBond* assetBonds = NvBlastAssetGetBonds(asset, nullptr);
- NvBlastSupportGraph graph = NvBlastAssetGetSupportGraph(asset, nullptr);
-
float point[4] = { 3.0f, 3.0f, 0.0f };
- EXPECT_EQ(5, NvBlastActorClosestChunk(point, actor, nullptr));
- {
- std::vector<uint32_t> graphNodeIndices;
- graphNodeIndices.resize(NvBlastActorGetGraphNodeCount(actor, nullptr));
- uint32_t graphNodesCount = NvBlastActorGetGraphNodeIndices(graphNodeIndices.data(), (uint32_t)graphNodeIndices.size(), actor, nullptr);
-
- EXPECT_EQ(4, Nv::Blast::findNodeByPosition(point, graphNodesCount, graphNodeIndices.data(), graph, assetBonds, NvBlastActorGetBondHealths(actor, messageLog)));
- }
+ EXPECT_EQ(4, findClosestNodeByChunks(point, actor));
+ EXPECT_EQ(4, findClosestNodeByBonds(point, actor));
NvBlastChunkFractureData chunkBuffer[1];
NvBlastFractureBuffers events = { 0, 1, nullptr, chunkBuffer };
@@ -263,31 +312,122 @@ TEST(CoreTests, FindChunkByPositionLandlocked)
ASSERT_EQ(actor, newActors[1]);
- EXPECT_NE(5, NvBlastActorClosestChunk(point, actor, nullptr));
+ EXPECT_NE(4, findClosestNodeByChunks(point, actor));
+ EXPECT_NE(4, findClosestNodeByBonds(point, actor));
float point2[4] = { 80.0f, 80.0f, 80.0f };
- EXPECT_EQ(5, NvBlastActorClosestChunk(point2, newActors[0], nullptr));
+ EXPECT_EQ(4, findClosestNodeByChunks(point2, newActors[0]));
+ EXPECT_EQ(4, findClosestNodeByBonds(point, newActors[0]));
+ for (uint32_t i = 0; i < newActorsCount; ++i)
{
- const float* bondHealths = NvBlastActorGetBondHealths(actor, messageLog);
- std::vector<uint32_t> graphNodeIndices;
- graphNodeIndices.resize(NvBlastActorGetGraphNodeCount(actor, nullptr));
- uint32_t graphNodesCount = NvBlastActorGetGraphNodeIndices(graphNodeIndices.data(), (uint32_t)graphNodeIndices.size(), actor, nullptr);
+ EXPECT_TRUE(NvBlastActorDeactivate(newActors[i], nullptr));
+ }
+
+ NVBLAST_FREE(family);
+ NVBLAST_FREE(asset);
+}
- EXPECT_NE(4, Nv::Blast::findNodeByPosition(point, graphNodesCount, graphNodeIndices.data(), graph, assetBonds, bondHealths));
+TEST(CoreTests, FindClosestByChunkAccuracy)
+{
+ // (0,0) +---+-------+
+ // | | 1 |
+ // | 2 +---+---+
+ // | | 5 | |
+ // +---+---+ 4 |
+ // | 3 | |
+ // +-------+---+ (6,6)
+
+ // random point lookup over the actor's space
+ // tests would fail if findClosestNodeByChunks didn't improve accuracy with the help of bonds
+
+ const NvBlastChunkDesc chunks[6] =
+ {
+ // centroid volume parent idx flags ID
+ { { 0.0f, 0.0f, 0.0f }, 0.0f, UINT32_MAX, NvBlastChunkDesc::NoFlags, 0 },
+ { { 4.0f, 1.0f, 0.0f }, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 1 },
+ { { 1.0f, 2.0f, 0.0f }, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 2 },
+ { { 2.0f, 5.0f, 0.0f }, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 3 },
+ { { 5.0f, 4.0f, 0.0f }, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 4 },
+ { { 3.0f, 3.0f, 0.0f }, 0.0f, 0, NvBlastChunkDesc::SupportFlag, 5 },
+ };
- graphNodeIndices.resize(NvBlastActorGetGraphNodeCount(newActors[0], nullptr));
- graphNodesCount = NvBlastActorGetGraphNodeIndices(graphNodeIndices.data(), (uint32_t)graphNodeIndices.size(), newActors[0], nullptr);
+ const NvBlastBondDesc bonds[8] =
+ {
+ // normal area centroid userData chunks
+ { { { -1.0f, 0.0f, 0.0f }, 1.0f,{ 2.0f, 1.0f, 0.0f }, 0 },{ 1, 2 } },
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f,{ 5.0f, 2.0f, 0.0f }, 0 },{ 1, 4 } },
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f,{ 3.0f, 2.0f, 0.0f }, 0 },{ 5, 1 } },
- EXPECT_EQ(4, Nv::Blast::findNodeByPosition(point, graphNodesCount, graphNodeIndices.data(), graph, assetBonds, bondHealths));
- }
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f,{ 1.0f, 4.0f, 0.0f }, 0 },{ 2, 3 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 2.0f, 3.0f, 0.0f }, 0 },{ 2, 5 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 4.0f, 5.0f, 0.0f }, 0 },{ 3, 4 } },
+ { { { 0.0f, -1.0f, 0.0f }, 1.0f,{ 3.0f, 4.0f, 0.0f }, 0 },{ 3, 5 } },
- for (uint32_t i = 0; i < newActorsCount; ++i)
+ { { { -1.0f, 0.0f, 0.0f }, 1.0f,{ 4.0f, 3.0f, 0.0f }, 0 },{ 4, 5 } },
+ };
+
+ const NvBlastAssetDesc desc = { 6, chunks, 8, bonds };
+ std::vector<char> scratch;
+ scratch.resize((size_t)NvBlastGetRequiredScratchForCreateAsset(&desc, messageLog));
+ void* amem = NVBLAST_ALLOC(NvBlastGetAssetMemorySize(&desc, messageLog));
+ NvBlastAsset* asset = NvBlastCreateAsset(amem, &desc, scratch.data(), messageLog);
+ ASSERT_TRUE(asset != nullptr);
+
+ NvBlastActorDesc actorDesc;
+ actorDesc.initialBondHealths = actorDesc.initialSupportChunkHealths = nullptr;
+ actorDesc.uniformInitialBondHealth = actorDesc.uniformInitialLowerSupportChunkHealth = 1.0f;
+ void* fmem = NVBLAST_ALLOC(NvBlastAssetGetFamilyMemorySize(asset, nullptr));
+ NvBlastFamily* family = NvBlastAssetCreateFamily(fmem, asset, nullptr);
+ scratch.resize((size_t)NvBlastFamilyGetRequiredScratchForCreateFirstActor(family, nullptr));
+ NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, scratch.data(), nullptr);
+ ASSERT_TRUE(actor != nullptr);
+
+ srand(0xb007);
+ for (uint32_t i = 0; i < 100000; i++)
{
- EXPECT_TRUE(NvBlastActorDeactivate(newActors[i], nullptr));
+ float rx = 8 * (float)(rand()) / RAND_MAX - 1;
+ float ry = 8 * (float)(rand()) / RAND_MAX - 1;
+ float rz = 0.0f;
+ float rpos[] = { rx, ry, rz };
+
+ EXPECT_LE(-1.0f, rx); EXPECT_GE(7.0f, rx);
+ EXPECT_LE(-1.0f, ry); EXPECT_GE(7.0f, ry);
+
+ uint32_t expectedNode = 0xdefec7;
+
+ if (rx < 2.0f) {
+ if (ry < 4.0f) { expectedNode = 1; }
+ else { expectedNode = 2; }
+ }
+ else if (rx < 4.0f) {
+ if (ry < 2.0f) { expectedNode = 0; }
+ else if (ry < 4.0f) { expectedNode = 4; }
+ else { expectedNode = 2; }
+ }
+ else {
+ if (ry < 2.0f) { expectedNode = 0; }
+ else { expectedNode = 3; }
+ }
+
+ uint32_t nodeByBonds = findClosestNodeByBonds(rpos, actor);
+ if (nodeByBonds != expectedNode)
+ {
+ printf("%.1f %.1f %.1f\n", rx, ry, rz);
+ }
+ EXPECT_EQ(expectedNode, nodeByBonds);
+
+ uint32_t nodeByChunks = findClosestNodeByChunks(rpos, actor);
+ if (nodeByChunks != expectedNode)
+ {
+ printf("%.1f %.1f %.1f\n", rx, ry, rz);
+ }
+ EXPECT_EQ(expectedNode, nodeByChunks);
}
- alignedFree<free>(family);
- alignedFree<free>(asset);
+ EXPECT_TRUE(NvBlastActorDeactivate(actor, messageLog));
+
+ NVBLAST_FREE(family);
+ NVBLAST_FREE(asset);
}
diff --git a/test/src/unit/FamilyGraphTests.cpp b/test/src/unit/FamilyGraphTests.cpp
index fdb9738..3468c9e 100644
--- a/test/src/unit/FamilyGraphTests.cpp
+++ b/test/src/unit/FamilyGraphTests.cpp
@@ -1,3 +1,31 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2017 NVIDIA Corporation. All rights reserved.
+
+
#include "BlastBaseTest.h"
#include "NvBlastSupportGraph.h"
@@ -108,7 +136,7 @@ protected:
uint32_t familyGraphMemorySize = (uint32_t)FamilyGraph::requiredMemorySize(m_graph->m_nodeCount, bondIndex);
m_memoryBlock.resize(familyGraphMemorySize);
// placement new family graph
- FamilyGraph* familyGraph = new(&m_memoryBlock[0]) FamilyGraph(m_graph);
+ FamilyGraph* familyGraph = new(m_memoryBlock.data()) FamilyGraph(m_graph);
return familyGraph;
}
@@ -220,10 +248,10 @@ TEST_F(FamilyGraphTestStrict, Graph0FindIslands0)
EXPECT_EQ(9, graph->getEdgesCount(m_graph));
graph->notifyEdgeRemoved(DEFAULT_ACTOR_INDEX, 0, 4, m_graph);
EXPECT_EQ(8, graph->getEdgesCount(m_graph));
- EXPECT_EQ(1, graph->findIslands(DEFAULT_ACTOR_INDEX, &scratch[0], m_graph));
+ EXPECT_EQ(1, graph->findIslands(DEFAULT_ACTOR_INDEX, scratch.data(), m_graph));
graph->notifyEdgeRemoved(DEFAULT_ACTOR_INDEX, 1, 2, m_graph);
- EXPECT_EQ(1, graph->findIslands(DEFAULT_ACTOR_INDEX, &scratch[0], m_graph));
+ EXPECT_EQ(1, graph->findIslands(DEFAULT_ACTOR_INDEX, scratch.data(), m_graph));
std::vector<IslandInfo> info;
getIslandsInfo(*graph, info);
@@ -244,7 +272,7 @@ TEST_F(FamilyGraphTestStrict, Graph0FindIslands1)
graph->notifyEdgeRemoved(DEFAULT_ACTOR_INDEX, 4, 5, m_graph);
graph->notifyEdgeRemoved(DEFAULT_ACTOR_INDEX, 1, 2, m_graph);
EXPECT_EQ(6, graph->getEdgesCount(m_graph));
- EXPECT_EQ(3, graph->findIslands(DEFAULT_ACTOR_INDEX, &scratch[0], m_graph));
+ EXPECT_EQ(3, graph->findIslands(DEFAULT_ACTOR_INDEX, scratch.data(), m_graph));
std::vector<IslandInfo> info;
getIslandsInfo(*graph, info);
@@ -265,21 +293,21 @@ TEST_F(FamilyGraphTestStrict, Graph0FindIslandsDifferentActors)
std::vector<char> scratch;
scratch.resize((size_t)FamilyGraph::findIslandsRequiredScratch(chunkCount0));
- EXPECT_EQ(0, graph->findIslands(ACTOR_1_INDEX, &scratch[0], m_graph));
- EXPECT_EQ(1, graph->findIslands(ACTOR_0_INDEX, &scratch[0], m_graph));
+ EXPECT_EQ(0, graph->findIslands(ACTOR_1_INDEX, scratch.data(), m_graph));
+ EXPECT_EQ(1, graph->findIslands(ACTOR_0_INDEX, scratch.data(), m_graph));
graph->notifyEdgeRemoved(ACTOR_0_INDEX, 2, 1, m_graph);
EXPECT_EQ(8, graph->getEdgesCount(m_graph));
- EXPECT_EQ(1, graph->findIslands(ACTOR_0_INDEX, &scratch[0], m_graph));
+ EXPECT_EQ(1, graph->findIslands(ACTOR_0_INDEX, scratch.data(), m_graph));
graph->notifyEdgeRemoved(ACTOR_1_INDEX, 2, 6, m_graph);
graph->notifyEdgeRemoved(ACTOR_1_INDEX, 7, 3, m_graph);
- EXPECT_EQ(1, graph->findIslands(ACTOR_1_INDEX, &scratch[0], m_graph));
+ EXPECT_EQ(1, graph->findIslands(ACTOR_1_INDEX, scratch.data(), m_graph));
graph->notifyEdgeRemoved(ACTOR_0_INDEX, 0, 1, m_graph);
graph->notifyEdgeRemoved(ACTOR_0_INDEX, 4, 5, m_graph);
- EXPECT_EQ(1, graph->findIslands(ACTOR_0_INDEX, &scratch[0], m_graph));
+ EXPECT_EQ(1, graph->findIslands(ACTOR_0_INDEX, scratch.data(), m_graph));
std::vector<IslandInfo> info;
@@ -306,7 +334,7 @@ TEST_F(FamilyGraphTestStrict, Graph1FindIslands0)
graph->notifyEdgeRemoved(DEFAULT_ACTOR_INDEX, 5, 6, m_graph);
graph->notifyEdgeRemoved(DEFAULT_ACTOR_INDEX, 9, 10, m_graph);
EXPECT_EQ(11, graph->getEdgesCount(m_graph));
- EXPECT_EQ(3, graph->findIslands(DEFAULT_ACTOR_INDEX, &scratch[0], m_graph));
+ EXPECT_EQ(3, graph->findIslands(DEFAULT_ACTOR_INDEX, scratch.data(), m_graph));
std::vector<IslandInfo> info;
getIslandsInfo(*graph, info);
@@ -326,17 +354,17 @@ TEST_F(FamilyGraphTestStrict, Graph1FindIslands1)
scratch.resize((size_t)FamilyGraph::findIslandsRequiredScratch(chunkCount1));
graph->notifyEdgeRemoved(DEFAULT_ACTOR_INDEX, 0, 4, m_graph);
- EXPECT_EQ(1, graph->findIslands(DEFAULT_ACTOR_INDEX, &scratch[0], m_graph));
+ EXPECT_EQ(1, graph->findIslands(DEFAULT_ACTOR_INDEX, scratch.data(), m_graph));
graph->notifyEdgeRemoved(DEFAULT_ACTOR_INDEX, 1, 5, m_graph);
- EXPECT_EQ(0, graph->findIslands(DEFAULT_ACTOR_INDEX, &scratch[0], m_graph));
+ EXPECT_EQ(0, graph->findIslands(DEFAULT_ACTOR_INDEX, scratch.data(), m_graph));
graph->notifyEdgeRemoved(DEFAULT_ACTOR_INDEX, 2, 6, m_graph);
- EXPECT_EQ(0, graph->findIslands(DEFAULT_ACTOR_INDEX, &scratch[0], m_graph));
+ EXPECT_EQ(0, graph->findIslands(DEFAULT_ACTOR_INDEX, scratch.data(), m_graph));
graph->notifyEdgeRemoved(DEFAULT_ACTOR_INDEX, 3, 7, m_graph);
- EXPECT_EQ(1, graph->findIslands(DEFAULT_ACTOR_INDEX, &scratch[0], m_graph));
+ EXPECT_EQ(1, graph->findIslands(DEFAULT_ACTOR_INDEX, scratch.data(), m_graph));
graph->notifyEdgeRemoved(DEFAULT_ACTOR_INDEX, 5, 6, m_graph);
- EXPECT_EQ(0, graph->findIslands(DEFAULT_ACTOR_INDEX, &scratch[0], m_graph));
+ EXPECT_EQ(0, graph->findIslands(DEFAULT_ACTOR_INDEX, scratch.data(), m_graph));
graph->notifyEdgeRemoved(DEFAULT_ACTOR_INDEX, 9, 10, m_graph);
- EXPECT_EQ(1, graph->findIslands(DEFAULT_ACTOR_INDEX, &scratch[0], m_graph));
+ EXPECT_EQ(1, graph->findIslands(DEFAULT_ACTOR_INDEX, scratch.data(), m_graph));
std::vector<IslandInfo> info;
getIslandsInfo(*graph, info);
@@ -368,7 +396,7 @@ TEST_F(FamilyGraphTestStrict, Graph1FindIslandsRemoveAllEdges)
}
EXPECT_EQ(0, graph->getEdgesCount(m_graph));
- EXPECT_EQ(12, graph->findIslands(DEFAULT_ACTOR_INDEX, &scratch[0], m_graph));
+ EXPECT_EQ(12, graph->findIslands(DEFAULT_ACTOR_INDEX, scratch.data(), m_graph));
for (uint32_t node0 = 0; node0 < chunkCount1; node0++)
{
diff --git a/test/src/unit/MultithreadingTests.cpp b/test/src/unit/MultithreadingTests.cpp
index f1ae176..708f153 100644
--- a/test/src/unit/MultithreadingTests.cpp
+++ b/test/src/unit/MultithreadingTests.cpp
@@ -1,3 +1,31 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2017 NVIDIA Corporation. All rights reserved.
+
+
#include "BlastBaseTest.h"
#include "AssetGenerator.h"
@@ -107,12 +135,12 @@ public:
static void* alloc(size_t size)
{
- return BlastBaseTest<FailLevel, Verbosity>::alloc(size);
+ return BlastBaseTest<FailLevel, Verbosity>::alignedZeroedAlloc(size);
}
static void free(void* mem)
{
- BlastBaseTest<FailLevel, Verbosity>::free(mem);
+ BlastBaseTest<FailLevel, Verbosity>::alignedFree(mem);
}
static void testActorVisibleChunks(const Nv::Blast::Actor& actor, NvBlastLog)
@@ -297,13 +325,13 @@ public:
NvBlastAssetDesc desc;
desc.chunkDescs = &testAsset.solverChunks[0];
desc.chunkCount = (uint32_t)testAsset.solverChunks.size();
- desc.bondDescs = &testAsset.solverBonds[0];
+ desc.bondDescs = testAsset.solverBonds.data();
desc.bondCount = (uint32_t)testAsset.solverBonds.size();
std::vector<char> scratch;
scratch.resize((size_t)NvBlastGetRequiredScratchForCreateAsset(&desc, messageLog));
void* mem = alloc(NvBlastGetAssetMemorySize(&desc, messageLog));
- NvBlastAsset* asset = NvBlastCreateAsset(mem, &desc, &scratch[0], messageLog);
+ NvBlastAsset* asset = NvBlastCreateAsset(mem, &desc, scratch.data(), messageLog);
EXPECT_TRUE(asset != nullptr);
NvBlastActorDesc actorDesc;
@@ -312,7 +340,7 @@ public:
void* fmem = alloc(NvBlastAssetGetFamilyMemorySize(asset, messageLog));
NvBlastFamily* family = NvBlastAssetCreateFamily(fmem, asset, nullptr); // Using zeroingAlloc in case actorTest compares memory blocks
scratch.resize((size_t)NvBlastFamilyGetRequiredScratchForCreateFirstActor(family, messageLog));
- NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, &scratch[0], messageLog);
+ NvBlastActor* actor = NvBlastFamilyCreateFirstActor(family, &actorDesc, scratch.data(), messageLog);
EXPECT_TRUE(actor != nullptr);
// Run parallelized damage through TaskDispatcher
diff --git a/test/src/unit/SyncTests.cpp b/test/src/unit/SyncTests.cpp
index 425210d..4ac79ac 100644
--- a/test/src/unit/SyncTests.cpp
+++ b/test/src/unit/SyncTests.cpp
@@ -1,3 +1,31 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2017 NVIDIA Corporation. All rights reserved.
+
+
#include "TkBaseTest.h"
#include "NvBlastExtSync.h"
@@ -26,7 +54,7 @@ public:
TkFramework* fwk = NvBlastTkFrameworkGet();
TkGroupDesc gdesc;
- gdesc.pxTaskManager = m_test->m_taskman;
+ gdesc.workerCount = m_test->m_taskman->getCpuDispatcher()->getWorkerCount();
m_group = fwk->createGroup(gdesc);
EXPECT_TRUE(m_group != nullptr);
@@ -48,6 +76,7 @@ public:
families[1]->setID(id);
m_group->addActor(*actor1);
+ m_test->m_groupTM->setGroup(m_group);
//////// server/client specific impl ////////
@@ -121,8 +150,8 @@ protected:
}
// process
- m_group->process();
- m_group->sync();
+ m_test->m_groupTM->process();
+ m_test->m_groupTM->wait();
EXPECT_EQ(families[0]->getActorCount(), 2);
// sync family #0
@@ -149,8 +178,8 @@ protected:
}
// process
- m_group->process();
- m_group->sync();
+ m_test->m_groupTM->process();
+ m_test->m_groupTM->wait();
EXPECT_EQ(families[0]->getActorCount(), 5);
EXPECT_EQ(families[1]->getActorCount(), 1);
@@ -229,8 +258,8 @@ protected:
family->removeListener(*this);
}
- m_group->process();
- m_group->sync();
+ m_test->m_groupTM->process();
+ m_test->m_groupTM->wait();
sync->release();
}
diff --git a/test/src/unit/TkCompositeTests.cpp b/test/src/unit/TkCompositeTests.cpp
index 60fbe49..37dad1b 100644
--- a/test/src/unit/TkCompositeTests.cpp
+++ b/test/src/unit/TkCompositeTests.cpp
@@ -1,3 +1,31 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2017 NVIDIA Corporation. All rights reserved.
+
+
#include "TkBaseTest.h"
#include <map>
@@ -6,8 +34,6 @@
#include "PsMemoryBuffer.h"
-#include "NvBlastTkSerializable.h"
-
#include "NvBlastTime.h"
@@ -40,17 +66,6 @@ template<int FailLevel, int Verbosity>
class TkCompositeTest : public TkBaseTest<FailLevel, Verbosity>
{
public:
- virtual void* allocate(size_t size, const char* typeName, const char* filename, int line) override
- {
- void* ptr = TkBaseTest<FailLevel, Verbosity>::allocate(size, typeName, filename, line);
- return ptr;
- }
-
- virtual void deallocate(void* ptr) override
- {
- return TkBaseTest<FailLevel, Verbosity>::deallocate(ptr);
- }
-
// Composite/joint tests
void createAssembly(std::vector<TkActor*>& actors, std::vector<TkJoint*>& joints, bool createNRFJoints)
@@ -125,6 +140,10 @@ public:
void familySerialization(std::vector<TkFamily*>& families, TestFamilyTracker& tracker)
{
+#if 1
+ NV_UNUSED(families);
+ NV_UNUSED(tracker);
+#else
TkFramework* fw = NvBlastTkFrameworkGet();
PsMemoryBuffer* membuf = PX_NEW(PsMemoryBuffer);
@@ -138,7 +157,8 @@ public:
for (size_t familyNum = 0; familyNum < families.size(); ++familyNum)
{
- families[familyNum]->serialize(*membuf);
+ GTEST_FATAL_FAILURE_("Serialization of families needs to be put into extensions.");
+// families[familyNum]->serialize(*membuf);
}
for (size_t familyNum = 0; familyNum < families.size(); ++familyNum)
@@ -158,9 +178,10 @@ public:
for (size_t familyNum = 0; familyNum < families.size(); ++familyNum)
{
- TkFamily* f = reinterpret_cast<TkFamily*>(fw->deserialize(*membuf));
- f->addListener(tracker);
- families[familyNum] = f;
+ GTEST_FATAL_FAILURE_("Deserialization of families needs to be put into extensions.");
+// TkFamily* f = reinterpret_cast<TkFamily*>(fw->deserialize(*membuf));
+// f->addListener(tracker);
+// families[familyNum] = f;
}
for (size_t familyNum = 0; familyNum < families.size(); ++familyNum)
@@ -188,6 +209,7 @@ public:
}
membuf->release();
+#endif
}
void recollectActors(std::vector<TkFamily*>& families, std::vector<TkActor*>& actors)
@@ -287,10 +309,12 @@ public:
TestFamilyTracker tracker;
TkGroupDesc gdesc;
- gdesc.pxTaskManager = m_taskman;
+ gdesc.workerCount = m_taskman->getCpuDispatcher()->getWorkerCount();
TkGroup* group = fw->createGroup(gdesc);
EXPECT_TRUE(group != nullptr);
+ m_groupTM->setGroup(group);
+
TkActorDesc adesc(testAssets[0]);
TkActor* actor1 = fw->createActor(adesc);
@@ -308,8 +332,8 @@ public:
EXPECT_EQ((size_t)0, tracker.joints.size());
- group->process();
- group->sync();
+ m_groupTM->process();
+ m_groupTM->wait();
if (testAssemblySerialization)
{
@@ -344,8 +368,8 @@ public:
actor->damage(getFalloffProgram(), &radialDamage, sizeof(radialDamage), getDefaultMaterial());
}
- group->process();
- group->sync();
+ m_groupTM->process();
+ m_groupTM->wait();
if (testAssemblySerialization)
{
@@ -409,10 +433,12 @@ public:
tracker.joints.insert(joints.begin(), joints.end());
TkGroupDesc gdesc;
- gdesc.pxTaskManager = m_taskman;
+ gdesc.workerCount = m_taskman->getCpuDispatcher()->getWorkerCount();
TkGroup* group = fw->createGroup(gdesc);
EXPECT_TRUE(group != nullptr);
+ m_groupTM->setGroup(group);
+
for (size_t i = 0; i < actors.size(); ++i)
{
TkFamily& family = actors[i]->getFamily();
@@ -444,8 +470,8 @@ public:
CSParams p(2, 0.0f);
actors[i]->damage(getCubeSlicerProgram(), &p, sizeof(p), getDefaultMaterial());
- group->process();
- group->sync();
+ m_groupTM->process();
+ m_groupTM->wait();
if (serializationTest)
{
@@ -494,8 +520,8 @@ public:
actor->damage(getFalloffProgram(), &radialDamage, sizeof(radialDamage), getDefaultMaterial());
}
- group->process();
- group->sync();
+ m_groupTM->process();
+ m_groupTM->wait();
totalActorCount = 0;
for (int i = 0; i < 4; ++i)
@@ -547,8 +573,8 @@ public:
};
const NvBlastBondDesc bondDesc =
-// chunks normal area centroid userData
- { { 1, 2 },{ { 0.0f, 1.0f, 0.0f }, 1.0f,{ 0.0f, 0.0f, 0.0f }, 0 } };
+// normal area centroid userData chunks
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f, { 0.0f, 0.0f, 0.0f }, 0 }, { 1, 2 } };
TkFramework* framework = NvBlastTkFrameworkGet();
@@ -564,10 +590,12 @@ public:
EXPECT_TRUE(asset != nullptr);
TkGroupDesc gdesc;
- gdesc.pxTaskManager = m_taskman;
+ gdesc.workerCount = m_taskman->getCpuDispatcher()->getWorkerCount();
TkGroup* group = framework->createGroup(gdesc);
EXPECT_TRUE(group != nullptr);
+ m_groupTM->setGroup(group);
+
TkActorDesc adesc(asset);
TkActor* actor1 = framework->createActor(adesc);
EXPECT_TRUE(actor1 != nullptr);
@@ -601,8 +629,8 @@ public:
NvBlastExtRadialDamageDesc radialDamage2 = getRadialDamageDesc(0, -1, 0, 2, 2);
actor2->damage(getFalloffProgram(), &radialDamage2, sizeof(radialDamage2), getDefaultMaterial());
- group->process();
- group->sync();
+ m_groupTM->process();
+ m_groupTM->wait();
TkActor* actors1[2];
TkActor* actors2[2];
@@ -640,6 +668,7 @@ protected:
using TkBaseTest<FailLevel, Verbosity>::testAssets;
using TkBaseTest<FailLevel, Verbosity>::m_taskman;
+ using TkBaseTest<FailLevel, Verbosity>::m_groupTM;
using TkBaseTest<FailLevel, Verbosity>::createFramework;
using TkBaseTest<FailLevel, Verbosity>::releaseFramework;
using TkBaseTest<FailLevel, Verbosity>::createTestAssets;
@@ -664,7 +693,7 @@ TEST_F(TkCompositeTestStrict, AssemblyCreateAndRelease_NoNRFJoints_NoSerializati
assemblyCreateAndRelease(false, false);
}
-TEST_F(TkCompositeTestStrict, AssemblyCreateAndRelease_NoNRFJoints_AssemblySerialization)
+TEST_F(TkCompositeTestStrict, DISABLED_AssemblyCreateAndRelease_NoNRFJoints_AssemblySerialization)
{
assemblyCreateAndRelease(false, true);
}
@@ -674,7 +703,7 @@ TEST_F(TkCompositeTestStrict, AssemblyCreateAndRelease_WithNRFJoints_NoSerializa
assemblyCreateAndRelease(true, false);
}
-TEST_F(TkCompositeTestStrict, AssemblyCreateAndRelease_WithNRFJoints_AssemblySerialization)
+TEST_F(TkCompositeTestStrict, DISABLED_AssemblyCreateAndRelease_WithNRFJoints_AssemblySerialization)
{
assemblyCreateAndRelease(true, true);
}
@@ -693,7 +722,7 @@ TEST_F(TkCompositeTestStrict, AssemblyInternalJoints_NoSerialization)
assemblyInternalJoints(false);
}
-TEST_F(TkCompositeTestStrict, AssemblyInternalJoints_AssemblySerialization)
+TEST_F(TkCompositeTestStrict, DISABLED_AssemblyInternalJoints_AssemblySerialization)
{
assemblyInternalJoints(true);
}
@@ -708,7 +737,7 @@ TEST_F(TkCompositeTestStrict, AssemblyCompositeWithInternalJoints_NoNRFJoints_No
assemblyCompositeWithInternalJoints(false, false);
}
-TEST_F(TkCompositeTestStrict, AssemblyCompositeWithInternalJoints_NoNRFJoints_AssemblySerialization)
+TEST_F(TkCompositeTestStrict, DISABLED_AssemblyCompositeWithInternalJoints_NoNRFJoints_AssemblySerialization)
{
assemblyCompositeWithInternalJoints(false, true);
}
@@ -718,7 +747,7 @@ TEST_F(TkCompositeTestStrict, AssemblyCompositeWithInternalJoints_WithNRFJoints_
assemblyCompositeWithInternalJoints(true, false);
}
-TEST_F(TkCompositeTestStrict, AssemblyCompositeWithInternalJoints_WithNRFJoints_AssemblySerialization)
+TEST_F(TkCompositeTestStrict, DISABLED_AssemblyCompositeWithInternalJoints_WithNRFJoints_AssemblySerialization)
{
assemblyCompositeWithInternalJoints(true, true);
}
diff --git a/test/src/unit/TkTests.cpp b/test/src/unit/TkTests.cpp
index 045b0c9..19f582a 100644
--- a/test/src/unit/TkTests.cpp
+++ b/test/src/unit/TkTests.cpp
@@ -1,3 +1,31 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2017 NVIDIA Corporation. All rights reserved.
+
+
#include "TkBaseTest.h"
#include <map>
@@ -6,10 +34,9 @@
#include "PsMemoryBuffer.h"
-#include "NvBlastTkSerializable.h"
-
#include "NvBlastTime.h"
+#include "NvBlastExtPxTask.h"
struct ExpectedVisibleChunks
{
@@ -67,11 +94,11 @@ TEST_F(TkTestStrict, CreateAsset)
#if USE_PHYSX_DISPATCHER
TEST_F(TkTestStrict, DISABLED_MemLeak)
{
- PxFoundation* pxFoundation = PxCreateFoundation(PX_FOUNDATION_VERSION, *this, *this);
+ PxFoundation* pxFoundation = PxCreateFoundation(PX_FOUNDATION_VERSION, NvBlastGetPxAllocatorCallback(), NvBlastGetPxErrorCallback());
PxU32 affinity[] = { 1, 2, 4, 8 };
PxDefaultCpuDispatcher* cpuDispatcher = PxDefaultCpuDispatcherCreate(4, affinity);
cpuDispatcher->setRunProfiled(false);
- PxTaskManager* taskman = PxTaskManager::createTaskManager(*this, cpuDispatcher, nullptr);
+ PxTaskManager* taskman = PxTaskManager::createTaskManager(NvBlastGetPxErrorCallback(), cpuDispatcher, nullptr);
cpuDispatcher->release();
taskman->release();
@@ -79,7 +106,7 @@ TEST_F(TkTestStrict, DISABLED_MemLeak)
}
#endif
-TEST_F(TkTestAllowWarnings, ActorDamageNoGroup)
+TEST_F(TkTestStrict, ActorDamageNoGroup)
{
createFramework();
createTestAssets();
@@ -111,14 +138,16 @@ TEST_F(TkTestAllowWarnings, ActorDamageNoGroup)
EXPECT_TRUE(actor->isPending());
TkGroupDesc gdesc;
- gdesc.pxTaskManager = m_taskman;
+ gdesc.workerCount = m_taskman->getCpuDispatcher()->getWorkerCount();
TkGroup* group = fwk->createGroup(gdesc);
EXPECT_TRUE(group != nullptr);
+ m_groupTM->setGroup(group);
+
group->addActor(*actor);
- group->process();
- group->sync(true);
+ m_groupTM->process();
+ m_groupTM->wait();
EXPECT_FALSE(actor->isPending());
EXPECT_EQ(2, family.getActorCount());
@@ -126,7 +155,7 @@ TEST_F(TkTestAllowWarnings, ActorDamageNoGroup)
releaseFramework();
}
-TEST_F(TkTestAllowWarnings, ActorDamageGroup)
+TEST_F(TkTestStrict, ActorDamageGroup)
{
TEST_ZONE_BEGIN("ActorDamageGroup");
@@ -138,10 +167,12 @@ TEST_F(TkTestAllowWarnings, ActorDamageGroup)
TestFamilyTracker ftrack1, ftrack2;
TkGroupDesc gdesc;
- gdesc.pxTaskManager = m_taskman;
+ gdesc.workerCount = m_taskman->getCpuDispatcher()->getWorkerCount();
TkGroup* group = fwk->createGroup(gdesc);
EXPECT_TRUE(group != nullptr);
+ m_groupTM->setGroup(group);
+
NvBlastExtRadialDamageDesc radialDamage = getRadialDamageDesc(0, 0, 0);
NvBlastExtShearDamageDesc shearDamage = getShearDamageDesc(0, 0, 0);
@@ -163,12 +194,8 @@ TEST_F(TkTestAllowWarnings, ActorDamageGroup)
expectedVisibleChunks[&actor2->getFamily()] = ExpectedVisibleChunks(1, 1); // not split
GeneratorAsset cube;
- generateCube(cube, 5, 2);
TkAssetDesc assetDesc;
- assetDesc.bondCount = (uint32_t)cube.solverBonds.size();
- assetDesc.bondDescs = cube.solverBonds.data();
- assetDesc.chunkCount = (uint32_t)cube.chunks.size();
- assetDesc.chunkDescs = cube.solverChunks.data();
+ generateCube(cube, assetDesc, 5, 2);
assetDesc.bondFlags = nullptr;
TkAsset* cubeAsset = fwk->createAsset(assetDesc);
@@ -211,11 +238,10 @@ TEST_F(TkTestAllowWarnings, ActorDamageGroup)
actor1->damage(getFalloffProgram(), &radialDamage, sizeof(radialDamage), getDefaultMaterial());
}
- EXPECT_FALSE(group->sync(true));
- EXPECT_FALSE(group->sync(false));
+ EXPECT_FALSE(group->endProcess());
- group->process();
- group->sync();
+ m_groupTM->process();
+ m_groupTM->wait();
testResults(families, expectedVisibleChunks);
@@ -231,8 +257,8 @@ TEST_F(TkTestAllowWarnings, ActorDamageGroup)
}
expectedVisibleChunks[trackedFamily] = ExpectedVisibleChunks(4, 2);
- group->process();
- group->sync();
+ m_groupTM->process();
+ m_groupTM->wait();
testResults(families, expectedVisibleChunks);
@@ -249,8 +275,8 @@ TEST_F(TkTestAllowWarnings, ActorDamageGroup)
expectedVisibleChunks[trackedFamily] = ExpectedVisibleChunks(8, 1);
- group->process();
- group->sync();
+ m_groupTM->process();
+ m_groupTM->wait();
testResults(families, expectedVisibleChunks);
@@ -267,8 +293,8 @@ TEST_F(TkTestAllowWarnings, ActorDamageGroup)
}
expectedVisibleChunks[trackedFamily] = ExpectedVisibleChunks(4096, 1);
- group->process();
- while (!group->sync(true));
+ m_groupTM->process();
+ m_groupTM->wait();
testResults(families, expectedVisibleChunks);
@@ -285,9 +311,8 @@ TEST_F(TkTestAllowWarnings, ActorDamageGroup)
TEST_ZONE_END("damage");
}
- group->process();
- while (!group->sync(true))
- ;
+ m_groupTM->process();
+ m_groupTM->wait();
@@ -302,8 +327,8 @@ TEST_F(TkTestAllowWarnings, ActorDamageGroup)
TEST_ZONE_END("damage");
}
- group->process();
- while (!group->sync(true));
+ m_groupTM->process();
+ m_groupTM->wait();
group->release();
@@ -318,7 +343,7 @@ TEST_F(TkTestAllowWarnings, ActorDamageGroup)
}
-TEST_F(TkTestAllowWarnings, ActorDamageMultiGroup)
+TEST_F(TkTestStrict, ActorDamageMultiGroup)
{
createFramework();
createTestAssets();
@@ -328,24 +353,23 @@ TEST_F(TkTestAllowWarnings, ActorDamageMultiGroup)
TestFamilyTracker ftrack1, ftrack2;
TkGroupDesc gdesc;
- gdesc.pxTaskManager = m_taskman;
+ gdesc.workerCount = m_taskman->getCpuDispatcher()->getWorkerCount();
TkGroup* group0 = fwk->createGroup(gdesc);
EXPECT_TRUE(group0 != nullptr);
TkGroup* group1 = fwk->createGroup(gdesc);
EXPECT_TRUE(group1 != nullptr);
+ ExtGroupTaskManager& gtm1 = *ExtGroupTaskManager::create(*m_taskman, *group1);
+ ExtGroupTaskManager& gtm0 = *ExtGroupTaskManager::create(*m_taskman, *group0);
+
std::vector<TkFamily*> families(2);
std::map<TkFamily*, ExpectedVisibleChunks> expectedVisibleChunks;
// prepare 2 equal actors/families and damage
{
GeneratorAsset cube;
- generateCube(cube, 6, 2, 5);
TkAssetDesc assetDesc;
- assetDesc.bondCount = (uint32_t)cube.solverBonds.size();
- assetDesc.bondDescs = cube.solverBonds.data();
- assetDesc.chunkCount = (uint32_t)cube.chunks.size();
- assetDesc.chunkDescs = cube.solverChunks.data();
+ generateCube(cube, assetDesc, 6, 2, 5);
assetDesc.bondFlags = nullptr;
TkAsset* cubeAsset = fwk->createAsset(assetDesc);
@@ -385,14 +409,14 @@ TEST_F(TkTestAllowWarnings, ActorDamageMultiGroup)
// async process 2 groups
{
- EXPECT_TRUE(group0->process());
- EXPECT_TRUE(group1->process());
+ EXPECT_GT(gtm0.process(2), (uint32_t)0);
+ EXPECT_GT(gtm1.process(2), (uint32_t)0);
uint32_t completed = 0;
while (completed < 2)
{
- if (group0->sync(false))
+ if (gtm0.wait(false))
completed++;
- if (group1->sync(false))
+ if (gtm1.wait(false))
completed++;
}
}
@@ -456,14 +480,14 @@ TEST_F(TkTestAllowWarnings, ActorDamageMultiGroup)
// async process 2 groups
{
- EXPECT_TRUE(group1->process());
- EXPECT_TRUE(group0->process());
+ EXPECT_GT(gtm1.process(2), (uint32_t)0);
+ EXPECT_GT(gtm0.process(2), (uint32_t)0);
uint32_t completed = 0;
while (completed < 2)
{
- if (group0->sync(false))
+ if (gtm1.wait(false))
completed++;
- if (group1->sync(false))
+ if (gtm0.wait(false))
completed++;
}
}
@@ -520,24 +544,24 @@ TEST_F(TkTestAllowWarnings, ActorDamageMultiGroup)
newGroup->addActor(*actor);
}
}
+ TEST_ZONE_END("damage loop");
if (!workTBD)
break;
// async process 2 groups
{
- EXPECT_TRUE(group1->process());
- EXPECT_TRUE(group0->process());
+ EXPECT_GT(gtm1.process(2), (uint32_t)0);
+ EXPECT_GT(gtm0.process(2), (uint32_t)0);
uint32_t completed = 0;
while (completed < 2)
{
- if (group0->sync(false))
+ if (gtm1.wait(false))
completed++;
- if (group1->sync(false))
+ if (gtm0.wait(false))
completed++;
}
}
- TEST_ZONE_END("damage loop");
}
}
@@ -547,6 +571,9 @@ TEST_F(TkTestAllowWarnings, ActorDamageMultiGroup)
EXPECT_EQ(65536, families[0]->getActorCount() + families[1]->getActorCount());
EXPECT_EQ(65536, group0->getActorCount() + group1->getActorCount());
+ gtm0.release();
+ gtm1.release();
+
group0->release();
group1->release();
@@ -557,28 +584,26 @@ TEST_F(TkTestAllowWarnings, ActorDamageMultiGroup)
releaseFramework();
}
-TEST_F(TkTestAllowWarnings, ActorDamageBufferedDamage)
+TEST_F(TkTestStrict, ActorDamageBufferedDamage)
{
createFramework();
TkFramework* fwk = NvBlastTkFrameworkGet();
// group
TkGroupDesc gdesc;
- gdesc.pxTaskManager = m_taskman;
+ gdesc.workerCount = m_taskman->getCpuDispatcher()->getWorkerCount();
TkGroup* group = fwk->createGroup(gdesc);
EXPECT_TRUE(group != nullptr);
-
+
+ m_groupTM->setGroup(group);
+
// random engine
std::default_random_engine re;
// cube asset
GeneratorAsset cube;
- generateCube(cube, 4, 2, 3);
TkAssetDesc assetDesc;
- assetDesc.bondCount = (uint32_t)cube.solverBonds.size();
- assetDesc.bondDescs = cube.solverBonds.data();
- assetDesc.chunkCount = (uint32_t)cube.chunks.size();
- assetDesc.chunkDescs = cube.solverChunks.data();
+ generateCube(cube, assetDesc, 4, 2, 3);
assetDesc.bondFlags = nullptr;
TkAsset* cubeAsset = fwk->createAsset(assetDesc);
testAssets.push_back(cubeAsset);
@@ -650,8 +675,8 @@ TEST_F(TkTestAllowWarnings, ActorDamageBufferedDamage)
}
// sync
- EXPECT_TRUE(group->process());
- group->sync(true);
+ EXPECT_GT(m_groupTM->process(), (uint32_t)0);
+ m_groupTM->wait();
const auto ac = family->getActorCount();
@@ -756,6 +781,7 @@ TEST_F(TkTestStrict, CreateActor)
template<int FailMask, int Verbosity>
TkFamily* TkBaseTest<FailMask, Verbosity>::familySerialization(TkFamily* family)
{
+#if 0
TkFramework* fw = NvBlastTkFrameworkGet();
const TkType* familyType = fw->getType(TkTypeIndex::Family);
@@ -785,19 +811,23 @@ TkFamily* TkBaseTest<FailMask, Verbosity>::familySerialization(TkFamily* family)
}
return family;
+#endif
+ return nullptr;
}
-TEST_F(TkTestAllowWarnings, FamilySerialization)
+TEST_F(TkTestAllowWarnings, DISABLED_FamilySerialization)
{
createFramework();
TkFramework* fwk = NvBlastTkFrameworkGet();
// group
TkGroupDesc gdesc;
- gdesc.pxTaskManager = m_taskman;
+ gdesc.workerCount = m_taskman->getCpuDispatcher()->getWorkerCount();
TkGroup* group = fwk->createGroup(gdesc);
EXPECT_TRUE(group != nullptr);
+ m_groupTM->setGroup(group);
+
// random engine
std::default_random_engine re;
@@ -865,8 +895,8 @@ TEST_F(TkTestAllowWarnings, FamilySerialization)
}
// sync
- EXPECT_TRUE(group->process());
- group->sync(true);
+ EXPECT_GT(m_groupTM->process(), (uint32_t)0);
+ m_groupTM->wait();
family = familySerialization(family);
}
@@ -889,10 +919,12 @@ TEST_F(TkTestStrict, GroupStats)
// group
TkGroupDesc gdesc;
- gdesc.pxTaskManager = m_taskman;
+ gdesc.workerCount = m_taskman->getCpuDispatcher()->getWorkerCount();
TkGroup* group = fwk->createGroup(gdesc);
EXPECT_TRUE(group != nullptr);
+ m_groupTM->setGroup(group);
+
TkAsset* cubeAsset = createCubeAsset(4, 2);
TkActorDesc cubeDesc(cubeAsset);
@@ -913,8 +945,8 @@ TEST_F(TkTestStrict, GroupStats)
cubeActor4->damage(getFalloffProgram(), &r0, sizeof(r0));
Nv::Blast::Time time;
- group->process();
- group->sync(true);
+ m_groupTM->process();
+ m_groupTM->wait();
int64_t groupTime = time.getElapsedTicks();
TkGroupStats gstats;
@@ -1036,17 +1068,19 @@ TEST_F(TkTestStrict, FractureReportSupport)
EXPECT_EQ((void*)'root', actor->userData);
EXPECT_EQ(0, actor->getIndex());
- TkGroupDesc groupDesc = { m_taskman };
+ TkGroupDesc groupDesc = { m_taskman->getCpuDispatcher()->getWorkerCount() };
TkGroup* group = fwk->createGroup(groupDesc);
+ m_groupTM->setGroup(group);
+
group->addActor(*actor);
// this will trigger hierarchical chunk fracture
NvBlastExtRadialDamageDesc radialDamage = getRadialDamageDesc(0, 0, 0);
actor->damage(getFalloffProgram(), &radialDamage, sizeof(NvBlastExtRadialDamageDesc), getDefaultMaterial());
- group->process();
- group->sync();
+ m_groupTM->process();
+ m_groupTM->wait();
releaseFramework();
}
@@ -1057,20 +1091,20 @@ TEST_F(TkTestStrict, FractureReportGraph)
TkFramework* fwk = NvBlastTkFrameworkGet();
- NvBlastBond bondToBreak = { { 1,0,0 }, 1,{ 0, 0, 0 }, 0 };
- NvBlastBond bondToKeep = { { 1,0,0 }, 1,{ 10, 10, 10 }, 0 };
+ NvBlastBond bondToBreak = { { 1, 0, 0 }, 1, { 0, 0, 0 }, 0 };
+ NvBlastBond bondToKeep = { { 1, 0, 0 }, 1, { 10, 10, 10 }, 0 };
NvBlastBondDesc bondDescs[] =
{
- { { 1,2 }, bondToKeep },
- { { 2,3 }, bondToBreak },
+ { bondToKeep, { 1, 2 } },
+ { bondToBreak, { 2, 3 } },
};
NvBlastChunkDesc chunkDescs[] =
{
- { { 0,0,0 }, 2, UINT32_MAX, NvBlastChunkDesc::NoFlags, 'root' },
- { { -1,0,0 }, 1, 0, NvBlastChunkDesc::SupportFlag, 'A' },
- { { +1,0,0 }, 1, 0, NvBlastChunkDesc::SupportFlag, 'B' },
- { { +1,0,0 }, 1, 0, NvBlastChunkDesc::SupportFlag, 'C' },
+ { { 0, 0, 0 }, 2, UINT32_MAX, NvBlastChunkDesc::NoFlags, 'root' },
+ { { -1, 0, 0 }, 1, 0, NvBlastChunkDesc::SupportFlag, 'A' },
+ { { +1, 0, 0 }, 1, 0, NvBlastChunkDesc::SupportFlag, 'B' },
+ { { +1, 0, 0 }, 1, 0, NvBlastChunkDesc::SupportFlag, 'C' },
};
TkAssetDesc assetDesc;
@@ -1102,7 +1136,7 @@ TEST_F(TkTestStrict, FractureReportGraph)
case TkFractureCommands::EVENT_TYPE:
{
const TkActorData& actor = event.getPayload<TkFractureCommands>()->tkActorData;
-
+
// Group::sync still needed the family for SharedMemory management.
EXPECT_TRUE(nullptr != actor.family);
@@ -1154,7 +1188,7 @@ TEST_F(TkTestStrict, FractureReportGraph)
{
TkActor* a = split->children[0];
- EXPECT_EQ(1, a->getVisibleChunkCount());
+ EXPECT_EQ(1, a->getVisibleChunkCount());
a->getVisibleChunkIndices(visibleChunkIndex, 1);
uint32_t actorIndex = a->getIndex();
EXPECT_EQ(2, actorIndex);
@@ -1176,17 +1210,19 @@ TEST_F(TkTestStrict, FractureReportGraph)
EXPECT_EQ(0, rootActor->getIndex());
EXPECT_EQ(1, rootActor->getVisibleChunkCount());
- TkGroupDesc groupDesc = { m_taskman };
+ TkGroupDesc groupDesc = { m_taskman->getCpuDispatcher()->getWorkerCount() };
TkGroup* group = fwk->createGroup(groupDesc);
+ m_groupTM->setGroup(group);
+
group->addActor(*rootActor);
// this will trigger one bond to break
NvBlastExtRadialDamageDesc radialDamage = getRadialDamageDesc(0, 0, 0, 0.5f, 0.5f);
rootActor->damage(getFalloffProgram(), &radialDamage, sizeof(NvBlastExtRadialDamageDesc), getDefaultMaterial());
- group->process();
- group->sync();
+ m_groupTM->process();
+ m_groupTM->wait();
releaseFramework();
}
@@ -1222,16 +1258,18 @@ TEST_F(TkTestStrict, SplitWarning) // GWD-167
actorDesc.asset = asset;
TkActor* actor = fwk->createActor(actorDesc);
- TkGroupDesc groupDesc = { m_taskman };
+ TkGroupDesc groupDesc = { m_taskman->getCpuDispatcher()->getWorkerCount() };
TkGroup* group = fwk->createGroup(groupDesc);
+ m_groupTM->setGroup(group);
+
group->addActor(*actor);
NvBlastExtRadialDamageDesc radialDamage = getRadialDamageDesc(0, 0, 0);
actor->damage(getFalloffProgram(), &radialDamage, sizeof(NvBlastExtRadialDamageDesc), getDefaultMaterial());
- group->process();
- group->sync();
+ m_groupTM->process();
+ m_groupTM->wait();
releaseFramework();
}
@@ -1309,14 +1347,17 @@ TEST_F(TkTestAllowWarnings, ChangeThreadCountToZero)
TestCpuDispatcher* disp4 = new TestCpuDispatcher(4);
#endif
- PxTaskManager* taskman = PxTaskManager::createTaskManager(*this, disp4);
+ m_taskman->setCpuDispatcher(*disp4);
- TkGroupDesc groupDesc = { taskman };
+ TkGroupDesc groupDesc = { m_taskman->getCpuDispatcher()->getWorkerCount() };
TkGroup* group = fwk->createGroup(groupDesc);
+ m_groupTM->setGroup(group);
+
group->addActor(*actor1);
group->addActor(*actor2);
- taskman->setCpuDispatcher(*disp0);
+ m_taskman->setCpuDispatcher(*disp0);
+ //group->setWorkerCount(m_taskman->getCpuDispatcher()->getWorkerCount());
group->addActor(*actor3);
group->addActor(*actor4);
@@ -1326,8 +1367,8 @@ TEST_F(TkTestAllowWarnings, ChangeThreadCountToZero)
actor3->damage(getFalloffProgram(), &radialDamage, sizeof(NvBlastExtRadialDamageDesc), getDefaultMaterial());
actor4->damage(getFalloffProgram(), &radialDamage, sizeof(NvBlastExtRadialDamageDesc), getDefaultMaterial());
- group->process();
- group->sync();
+ m_groupTM->process();
+ m_groupTM->wait();
EXPECT_EQ(4, listener.fracCommands);
EXPECT_EQ(4, listener.fracEvents);
@@ -1336,10 +1377,9 @@ TEST_F(TkTestAllowWarnings, ChangeThreadCountToZero)
disp0->release();
disp4->release();
- taskman->release();
}
-TEST_F(TkTestAllowWarnings, ChangeThreadCountUp)
+TEST_F(TkTestStrict, ChangeThreadCountUp)
{
// tests that group allocates more memory for additional workers
// by replacing to a higher thread count cpu dispatcher (warns)
@@ -1411,11 +1451,12 @@ TEST_F(TkTestAllowWarnings, ChangeThreadCountUp)
TestCpuDispatcher* disp4 = new TestCpuDispatcher(4);
#endif
- PxTaskManager* taskman = PxTaskManager::createTaskManager(*this, disp2);
-
- TkGroupDesc groupDesc = { taskman };
+ m_taskman->setCpuDispatcher(*disp2);
+ TkGroupDesc groupDesc = { m_taskman->getCpuDispatcher()->getWorkerCount() };
TkGroup* group = fwk->createGroup(groupDesc);
+ m_groupTM->setGroup(group);
+
group->addActor(*actor1);
group->addActor(*actor2);
group->addActor(*actor3);
@@ -1427,10 +1468,11 @@ TEST_F(TkTestAllowWarnings, ChangeThreadCountUp)
actor3->damage(getFalloffProgram(), &radialDamage, sizeof(NvBlastExtRadialDamageDesc), getDefaultMaterial());
actor4->damage(getFalloffProgram(), &radialDamage, sizeof(NvBlastExtRadialDamageDesc), getDefaultMaterial());
- taskman->setCpuDispatcher(*disp4);
+ m_taskman->setCpuDispatcher(*disp4);
+ //group->setWorkerCount(m_taskman->getCpuDispatcher()->getWorkerCount());
- group->process();
- group->sync();
+ m_groupTM->process();
+ m_groupTM->wait();
EXPECT_EQ(4, listener.fracCommands);
EXPECT_EQ(4, listener.fracEvents);
@@ -1439,7 +1481,6 @@ TEST_F(TkTestAllowWarnings, ChangeThreadCountUp)
disp2->release();
disp4->release();
- taskman->release();
}
TEST_F(TkTestAllowWarnings, GroupNoWorkers)
@@ -1503,9 +1544,18 @@ TEST_F(TkTestAllowWarnings, GroupNoWorkers)
actor3->getFamily().addListener(listener);
actor4->getFamily().addListener(listener);
- TkGroupDesc groupDesc = { nullptr };
+#if USE_PHYSX_DISPATCHER
+ PxDefaultCpuDispatcher* disp = PxDefaultCpuDispatcherCreate(0);
+#else
+ TestCpuDispatcher* disp = new TestCpuDispatcher(0);
+#endif
+ m_taskman->setCpuDispatcher(*disp);
+
+ TkGroupDesc groupDesc = { m_taskman->getCpuDispatcher()->getWorkerCount() };
TkGroup* group = fwk->createGroup(groupDesc);
+ m_groupTM->setGroup(group);
+
group->addActor(*actor1);
group->addActor(*actor2);
group->addActor(*actor3);
@@ -1517,12 +1567,14 @@ TEST_F(TkTestAllowWarnings, GroupNoWorkers)
actor3->damage(getFalloffProgram(), &radialDamage, sizeof(NvBlastExtRadialDamageDesc), getDefaultMaterial());
actor4->damage(getFalloffProgram(), &radialDamage, sizeof(NvBlastExtRadialDamageDesc), getDefaultMaterial());
- group->process();
- group->sync();
+ m_groupTM->process();
+ m_groupTM->wait();
EXPECT_EQ(4, listener.fracCommands);
EXPECT_EQ(4, listener.fracEvents);
+ disp->release();
+
releaseFramework();
}
diff --git a/test/src/utils/TaskDispatcher.h b/test/src/utils/TaskDispatcher.h
index bd8bfc8..4038c60 100644
--- a/test/src/utils/TaskDispatcher.h
+++ b/test/src/utils/TaskDispatcher.h
@@ -1,3 +1,31 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2017 NVIDIA Corporation. All rights reserved.
+
+
#pragma once
#include <thread>
diff --git a/test/src/utils/TestAssets.cpp b/test/src/utils/TestAssets.cpp
index f2a1396..34dd5b5 100644
--- a/test/src/utils/TestAssets.cpp
+++ b/test/src/utils/TestAssets.cpp
@@ -1,3 +1,31 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2017 NVIDIA Corporation. All rights reserved.
+
+
#include "TestAssets.h"
#include "AssetGenerator.h"
@@ -17,21 +45,45 @@ const NvBlastChunkDesc g_cube1ChunkDescs[9] =
const NvBlastBondDesc g_cube1BondDescs[12] =
{
-// chunks normal area centroid userData
- { { 1, 2 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 0.0f,-0.5f,-0.5f }, 0 } },
- { { 3, 4 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 0.0f, 0.5f,-0.5f }, 0 } },
- { { 5, 6 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 0.0f,-0.5f, 0.5f }, 0 } },
- { { 7, 8 }, { { 1.0f, 0.0f, 0.0f }, 1.0f, { 0.0f, 0.5f, 0.5f }, 0 } },
-
- { { 1, 3 }, { { 0.0f, 1.0f, 0.0f }, 1.0f, {-0.5f, 0.0f,-0.5f }, 0 } },
- { { 2, 4 }, { { 0.0f, 1.0f, 0.0f }, 1.0f, { 0.5f, 0.0f,-0.5f }, 0 } },
- { { 5, 7 }, { { 0.0f, 1.0f, 0.0f }, 1.0f, {-0.5f, 0.0f, 0.5f }, 0 } },
- { { 6, 8 }, { { 0.0f, 1.0f, 0.0f }, 1.0f, { 0.5f, 0.0f, 0.5f }, 0 } },
-
- { { 1, 5 }, { { 0.0f, 0.0f, 1.0f }, 1.0f, {-0.5f,-0.5f, 0.0f }, 0 } },
- { { 2, 6 }, { { 0.0f, 0.0f, 1.0f }, 1.0f, { 0.5f,-0.5f, 0.0f }, 0 } },
- { { 3, 7 }, { { 0.0f, 0.0f, 1.0f }, 1.0f, {-0.5f, 0.5f, 0.0f }, 0 } },
- { { 4, 8 }, { { 0.0f, 0.0f, 1.0f }, 1.0f, { 0.5f, 0.5f, 0.0f }, 0 } },
+// normal area centroid userData chunks
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 0.0f,-0.5f,-0.5f }, 0 }, { 1, 2 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 0.0f, 0.5f,-0.5f }, 0 }, { 3, 4 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 0.0f,-0.5f, 0.5f }, 0 }, { 5, 6 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 0.0f, 0.5f, 0.5f }, 0 }, { 7, 8 } },
+
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f, {-0.5f, 0.0f,-0.5f }, 0 }, { 1, 3 } },
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f, { 0.5f, 0.0f,-0.5f }, 0 }, { 2, 4 } },
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f, {-0.5f, 0.0f, 0.5f }, 0 }, { 5, 7 } },
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f, { 0.5f, 0.0f, 0.5f }, 0 }, { 6, 8 } },
+
+ { { { 0.0f, 0.0f, 1.0f }, 1.0f, {-0.5f,-0.5f, 0.0f }, 0 }, { 1, 5 } },
+ { { { 0.0f, 0.0f, 1.0f }, 1.0f, { 0.5f,-0.5f, 0.0f }, 0 }, { 2, 6 } },
+ { { { 0.0f, 0.0f, 1.0f }, 1.0f, {-0.5f, 0.5f, 0.0f }, 0 }, { 3, 7 } },
+ { { { 0.0f, 0.0f, 1.0f }, 1.0f, { 0.5f, 0.5f, 0.0f }, 0 }, { 4, 8 } },
+};
+
+const NvBlastBondDesc g_cube1BondDescs_wb[16] =
+{
+// normal area centroid userData chunks
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 0.0f,-0.5f,-0.5f }, 0 }, { 1, 2 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 0.0f, 0.5f,-0.5f }, 0 }, { 3, 4 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 0.0f,-0.5f, 0.5f }, 0 }, { 5, 6 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f, { 0.0f, 0.5f, 0.5f }, 0 }, { 7, 8 } },
+
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f, {-0.5f, 0.0f,-0.5f }, 0 }, { 1, 3 } },
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f, { 0.5f, 0.0f,-0.5f }, 0 }, { 2, 4 } },
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f, {-0.5f, 0.0f, 0.5f }, 0 }, { 5, 7 } },
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f, { 0.5f, 0.0f, 0.5f }, 0 }, { 6, 8 } },
+
+ { { { 0.0f, 0.0f, 1.0f }, 1.0f, {-0.5f,-0.5f, 0.0f }, 0 }, { 1, 5 } },
+ { { { 0.0f, 0.0f, 1.0f }, 1.0f, { 0.5f,-0.5f, 0.0f }, 0 }, { 2, 6 } },
+ { { { 0.0f, 0.0f, 1.0f }, 1.0f, {-0.5f, 0.5f, 0.0f }, 0 }, { 3, 7 } },
+ { { { 0.0f, 0.0f, 1.0f }, 1.0f, { 0.5f, 0.5f, 0.0f }, 0 }, { 4, 8 } },
+
+ { { { 0.0f, 0.0f,-1.0f }, 1.0f, {-0.5f,-0.5f,-1.0f }, 0 }, { 1, UINT32_MAX } },
+ { { { 0.0f, 0.0f,-1.0f }, 1.0f, { 0.5f,-0.5f,-1.0f }, 0 }, { 2, UINT32_MAX } },
+ { { { 0.0f, 0.0f,-1.0f }, 1.0f, {-0.5f, 0.5f,-1.0f }, 0 }, { 3, UINT32_MAX } },
+ { { { 0.0f, 0.0f,-1.0f }, 1.0f, { 0.5f, 0.5f,-1.0f }, 0 }, { 4, UINT32_MAX } },
};
const NvBlastChunkDesc g_cube2ChunkDescs[73] =
@@ -125,29 +177,53 @@ const NvBlastChunkDesc g_cube3ChunkDescs[11] =
{ {-0.5f,-0.5f, 0.5f }, 1.0f, 1, NvBlastChunkDesc::SupportFlag, 7 },
{ { 0.5f,-0.5f, 0.5f }, 1.0f, 1, NvBlastChunkDesc::SupportFlag, 8 },
{ {-0.5f, 0.5f, 0.5f }, 1.0f, 2, NvBlastChunkDesc::SupportFlag, 9 },
- { { 0.5f, 0.5f, 0.5f }, 1.0f, 2, NvBlastChunkDesc::SupportFlag, 10 },
+ { { 0.5f, 0.5f, 0.5f }, 1.0f, 2, NvBlastChunkDesc::SupportFlag, 10 },
};
const NvBlastBondDesc g_cube3BondDescs[12] =
{
- // chunks normal area centroid userData
- { { 3, 4 },{ { 1.0f, 0.0f, 0.0f }, 1.0f,{ 0.0f,-0.5f,-0.5f }, 0 } },
- { { 5, 6 },{ { 1.0f, 0.0f, 0.0f }, 1.0f,{ 0.0f, 0.5f,-0.5f }, 0 } },
- { { 7, 8 },{ { 1.0f, 0.0f, 0.0f }, 1.0f,{ 0.0f,-0.5f, 0.5f }, 0 } },
- { { 9, 10},{ { 1.0f, 0.0f, 0.0f }, 1.0f,{ 0.0f, 0.5f, 0.5f }, 0 } },
-
- { { 3, 5 },{ { 0.0f, 1.0f, 0.0f }, 1.0f,{-0.5f, 0.0f,-0.5f }, 0 } },
- { { 4, 6 },{ { 0.0f, 1.0f, 0.0f }, 1.0f,{ 0.5f, 0.0f,-0.5f }, 0 } },
- { { 7, 9 },{ { 0.0f, 1.0f, 0.0f }, 1.0f,{-0.5f, 0.0f, 0.5f }, 0 } },
- { { 8, 10},{ { 0.0f, 1.0f, 0.0f }, 1.0f,{ 0.5f, 0.0f, 0.5f }, 0 } },
-
- { { 3, 7 },{ { 0.0f, 0.0f, 1.0f }, 1.0f,{-0.5f,-0.5f, 0.0f }, 0 } },
- { { 4, 8 },{ { 0.0f, 0.0f, 1.0f }, 1.0f,{ 0.5f,-0.5f, 0.0f }, 0 } },
- { { 5, 9 },{ { 0.0f, 0.0f, 1.0f }, 1.0f,{-0.5f, 0.5f, 0.0f }, 0 } },
- { { 6, 10},{ { 0.0f, 0.0f, 1.0f }, 1.0f,{ 0.5f, 0.5f, 0.0f }, 0 } },
+// normal area centroid userData chunks
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 0.0f,-0.5f,-0.5f }, 0 }, { 3, 4 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 0.0f, 0.5f,-0.5f }, 0 }, { 5, 6 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 0.0f,-0.5f, 0.5f }, 0 }, { 7, 8 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 0.0f, 0.5f, 0.5f }, 0 }, { 9, 10} },
+
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f,{-0.5f, 0.0f,-0.5f }, 0 }, { 3, 5 } },
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f,{ 0.5f, 0.0f,-0.5f }, 0 }, { 4, 6 } },
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f,{-0.5f, 0.0f, 0.5f }, 0 }, { 7, 9 } },
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f,{ 0.5f, 0.0f, 0.5f }, 0 }, { 8, 10} },
+
+ { { { 0.0f, 0.0f, 1.0f }, 1.0f,{-0.5f,-0.5f, 0.0f }, 0 }, { 3, 7 } },
+ { { { 0.0f, 0.0f, 1.0f }, 1.0f,{ 0.5f,-0.5f, 0.0f }, 0 }, { 4, 8 } },
+ { { { 0.0f, 0.0f, 1.0f }, 1.0f,{-0.5f, 0.5f, 0.0f }, 0 }, { 5, 9 } },
+ { { { 0.0f, 0.0f, 1.0f }, 1.0f,{ 0.5f, 0.5f, 0.0f }, 0 }, { 6, 10} },
+};
+
+const NvBlastBondDesc g_cube3BondDescs_wb[16] =
+{
+// normal area centroid userData chunks
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 0.0f,-0.5f,-0.5f }, 0 }, { 3, 4 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 0.0f, 0.5f,-0.5f }, 0 }, { 5, 6 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 0.0f,-0.5f, 0.5f }, 0 }, { 7, 8 } },
+ { { { 1.0f, 0.0f, 0.0f }, 1.0f,{ 0.0f, 0.5f, 0.5f }, 0 }, { 9, 10} },
+
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f,{-0.5f, 0.0f,-0.5f }, 0 }, { 3, 5 } },
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f,{ 0.5f, 0.0f,-0.5f }, 0 }, { 4, 6 } },
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f,{-0.5f, 0.0f, 0.5f }, 0 }, { 7, 9 } },
+ { { { 0.0f, 1.0f, 0.0f }, 1.0f,{ 0.5f, 0.0f, 0.5f }, 0 }, { 8, 10} },
+
+ { { { 0.0f, 0.0f, 1.0f }, 1.0f,{-0.5f,-0.5f, 0.0f }, 0 }, { 3, 7 } },
+ { { { 0.0f, 0.0f, 1.0f }, 1.0f,{ 0.5f,-0.5f, 0.0f }, 0 }, { 4, 8 } },
+ { { { 0.0f, 0.0f, 1.0f }, 1.0f,{-0.5f, 0.5f, 0.0f }, 0 }, { 5, 9 } },
+ { { { 0.0f, 0.0f, 1.0f }, 1.0f,{ 0.5f, 0.5f, 0.0f }, 0 }, { 6, 10} },
+
+ { { { 0.0f, 0.0f, 1.0f }, 1.0f,{-0.5f,-0.5f,-1.0f }, 0 }, { 3, UINT32_MAX} },
+ { { { 0.0f, 0.0f, 1.0f }, 1.0f,{ 0.5f,-0.5f,-1.0f }, 0 }, { 4, UINT32_MAX} },
+ { { { 0.0f, 0.0f, 1.0f }, 1.0f,{-0.5f, 0.5f,-1.0f }, 0 }, { 5, UINT32_MAX} },
+ { { { 0.0f, 0.0f, 1.0f }, 1.0f,{ 0.5f, 0.5f,-1.0f }, 0 }, { 6, UINT32_MAX} },
};
-const NvBlastAssetDesc g_assetDescs[3] =
+const NvBlastAssetDesc g_assetDescs[6] =
{
// 2x2x2 axis-aligned cube centered at the origin, split into 8 depth-1 1x1x1 child chunks
{ sizeof(g_cube1ChunkDescs) / sizeof(g_cube1ChunkDescs[0]), g_cube1ChunkDescs, sizeof(g_cube1BondDescs) / sizeof(g_cube1BondDescs[0]), g_cube1BondDescs },
@@ -158,6 +234,16 @@ const NvBlastAssetDesc g_assetDescs[3] =
// 2x2x2 axis-aligned cube centered at the origin, split into 8 depth-1 1x1x1 child chunks with multiple roots
{ sizeof(g_cube3ChunkDescs) / sizeof(g_cube3ChunkDescs[0]), g_cube3ChunkDescs, sizeof(g_cube3BondDescs) / sizeof(g_cube3BondDescs[0]), g_cube3BondDescs },
+
+ // 2x2x2 axis-aligned cube centered at the origin, split into 8 depth-1 1x1x1 child chunks - contains world-bound chunks
+ { sizeof(g_cube1ChunkDescs) / sizeof(g_cube1ChunkDescs[0]), g_cube1ChunkDescs, sizeof(g_cube1BondDescs_wb) / sizeof(g_cube1BondDescs_wb[0]), g_cube1BondDescs_wb },
+
+ // 2x2x2 axis-aligned cube centered at the origin, split into 8 depth-1 1x1x1 child chunks which are then split into 8 depth-2 (1/2)x(1/2)x(1/2) child chunks each - contains world-bound chunks
+ // Support is at depth-1, so the g_cube1BondDescs_wb are used
+ { sizeof(g_cube2ChunkDescs) / sizeof(g_cube2ChunkDescs[0]), g_cube2ChunkDescs, sizeof(g_cube1BondDescs_wb) / sizeof(g_cube1BondDescs_wb[0]), g_cube1BondDescs_wb },
+
+ // 2x2x2 axis-aligned cube centered at the origin, split into 8 depth-1 1x1x1 child chunks with multiple roots - contains world-bound chunks
+ { sizeof(g_cube3ChunkDescs) / sizeof(g_cube3ChunkDescs[0]), g_cube3ChunkDescs, sizeof(g_cube3BondDescs_wb) / sizeof(g_cube3BondDescs_wb[0]), g_cube3BondDescs_wb },
};
@@ -171,12 +257,15 @@ struct ExpectedValues
uint32_t subsupportChunkCount;
};
-const ExpectedAssetValues g_assetExpectedValues[3] =
+const ExpectedAssetValues g_assetExpectedValues[6] =
{
// total graph leaves bonds sub
{ 9, 8, 8, 12, 0 },
{ 73, 8, 64, 12, 64 },
- { 11, 8, 8, 12, 0 }
+ { 11, 8, 8, 12, 0 },
+ { 9, 9, 8, 16, 0 },
+ { 73, 9, 64, 16, 64 },
+ { 11, 9, 8, 16, 0 },
};
@@ -243,23 +332,29 @@ const NvBlastChunkDesc g_cube2ChunkDescsMissingCoverage2[17] =
};
-const NvBlastAssetDesc g_assetDescsMissingCoverage[3] =
+const NvBlastAssetDesc g_assetDescsMissingCoverage[6] =
{
{ sizeof(g_cube1ChunkDescsMissingCoverage) / sizeof(g_cube1ChunkDescsMissingCoverage[0]), g_cube1ChunkDescsMissingCoverage, sizeof(g_cube1BondDescs) / sizeof(g_cube1BondDescs[0]), g_cube1BondDescs },
{ sizeof(g_cube2ChunkDescsMissingCoverage1) / sizeof(g_cube2ChunkDescsMissingCoverage1[0]), g_cube2ChunkDescsMissingCoverage1, sizeof(g_cube1BondDescs) / sizeof(g_cube1BondDescs[0]), g_cube1BondDescs },
{ sizeof(g_cube2ChunkDescsMissingCoverage2) / sizeof(g_cube2ChunkDescsMissingCoverage2[0]), g_cube2ChunkDescsMissingCoverage2, sizeof(g_cube1BondDescs) / sizeof(g_cube1BondDescs[0]), g_cube1BondDescs },
+ { sizeof(g_cube1ChunkDescsMissingCoverage) / sizeof(g_cube1ChunkDescsMissingCoverage[0]), g_cube1ChunkDescsMissingCoverage, sizeof(g_cube1BondDescs_wb) / sizeof(g_cube1BondDescs_wb[0]), g_cube1BondDescs_wb },
+ { sizeof(g_cube2ChunkDescsMissingCoverage1) / sizeof(g_cube2ChunkDescsMissingCoverage1[0]), g_cube2ChunkDescsMissingCoverage1, sizeof(g_cube1BondDescs_wb) / sizeof(g_cube1BondDescs_wb[0]), g_cube1BondDescs_wb },
+ { sizeof(g_cube2ChunkDescsMissingCoverage2) / sizeof(g_cube2ChunkDescsMissingCoverage2[0]), g_cube2ChunkDescsMissingCoverage2, sizeof(g_cube1BondDescs_wb) / sizeof(g_cube1BondDescs_wb[0]), g_cube1BondDescs_wb },
};
-extern const ExpectedAssetValues g_assetsFromMissingCoverageExpectedValues[3] =
+extern const ExpectedAssetValues g_assetsFromMissingCoverageExpectedValues[6] =
{
// total graph leaves bonds sub
{ 9, 8, 8, 12, 0 },
{ 17, 8, 15, 12, 8 },
{ 17, 15, 15, 9, 0 },
+ { 9, 9, 8, 16, 0 },
+ { 17, 9, 15, 16, 8 },
+ { 17, 16, 15, 12, 0 },
};
-void generateCube(GeneratorAsset& cubeAsset, size_t maxDepth, size_t width, int32_t supportDepth)
+void generateCube(GeneratorAsset& cubeAsset, NvBlastAssetDesc& assetDesc, size_t maxDepth, size_t width, int32_t supportDepth, CubeAssetGenerator::BondFlags bondFlags)
{
CubeAssetGenerator::Settings settings;
settings.extents = GeneratorAsset::Vec3(1, 1, 1);
@@ -267,6 +362,7 @@ void generateCube(GeneratorAsset& cubeAsset, size_t maxDepth, size_t width, int3
depthInfo.slicesPerAxis = GeneratorAsset::Vec3(1, 1, 1);
depthInfo.flag = NvBlastChunkDesc::Flags::NoFlags;
settings.depths.push_back(depthInfo);
+ settings.bondFlags = bondFlags;
for (uint32_t depth = 1; depth < maxDepth; ++depth)
{
@@ -276,13 +372,9 @@ void generateCube(GeneratorAsset& cubeAsset, size_t maxDepth, size_t width, int3
settings.depths[(supportDepth > 0 ? supportDepth : maxDepth) - 1].flag = NvBlastChunkDesc::SupportFlag; // Leaves are support
CubeAssetGenerator::generate(cubeAsset, settings);
-}
-void generateCube(GeneratorAsset& cubeAsset, NvBlastAssetDesc& assetDesc, size_t maxDepth, size_t width, int32_t supportDepth)
-{
- generateCube(cubeAsset, maxDepth, width, supportDepth);
assetDesc.bondCount = (uint32_t)cubeAsset.solverBonds.size();
assetDesc.bondDescs = cubeAsset.solverBonds.data();
assetDesc.chunkCount = (uint32_t)cubeAsset.chunks.size();
assetDesc.chunkDescs = cubeAsset.solverChunks.data();
-} \ No newline at end of file
+}
diff --git a/test/src/utils/TestAssets.h b/test/src/utils/TestAssets.h
index e4a9c77..5fd7741 100644
--- a/test/src/utils/TestAssets.h
+++ b/test/src/utils/TestAssets.h
@@ -1,3 +1,31 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2017 NVIDIA Corporation. All rights reserved.
+
+
#ifndef TESTASSETS_H
#define TESTASSETS_H
@@ -15,12 +43,12 @@ struct ExpectedAssetValues
// Indexable asset descriptors and expected values
-extern const NvBlastAssetDesc g_assetDescs[3];
-extern const ExpectedAssetValues g_assetExpectedValues[3];
+extern const NvBlastAssetDesc g_assetDescs[6];
+extern const ExpectedAssetValues g_assetExpectedValues[6];
// Indexable asset descriptors for assets missing coverage and expected values
-extern const NvBlastAssetDesc g_assetDescsMissingCoverage[3];
-extern const ExpectedAssetValues g_assetsFromMissingCoverageExpectedValues[3];
+extern const NvBlastAssetDesc g_assetDescsMissingCoverage[6];
+extern const ExpectedAssetValues g_assetsFromMissingCoverageExpectedValues[6];
inline uint32_t getAssetDescCount()
@@ -34,7 +62,7 @@ inline uint32_t getAssetDescMissingCoverageCount()
}
-void generateCube(GeneratorAsset& cubeAsset, size_t maxDepth, size_t width, int32_t supportDepth = -1);
-void generateCube(GeneratorAsset& cubeAsset, NvBlastAssetDesc& assetDesc, size_t maxDepth, size_t width, int32_t supportDepth = -1);
+void generateCube(GeneratorAsset& cubeAsset, NvBlastAssetDesc& assetDesc, size_t maxDepth, size_t width,
+ int32_t supportDepth = -1, CubeAssetGenerator::BondFlags bondFlags = CubeAssetGenerator::ALL_INTERNAL_BONDS);
#endif // #ifdef TESTASSETS_H
diff --git a/test/src/utils/TestProfiler.h b/test/src/utils/TestProfiler.h
index 318e6e6..39dbc26 100644
--- a/test/src/utils/TestProfiler.h
+++ b/test/src/utils/TestProfiler.h
@@ -1,27 +1,35 @@
-#ifndef TESTPROFILER_H
-#define TESTPROFILER_H
-
-#include "NvBlastPreprocessor.h"
-
-#if NV_NVTX
-#include "nvToolsExt.h"
-NV_INLINE void platformZoneStart(const char* name) { nvtxRangePush(name); }
-NV_INLINE void platformZoneEnd(const char*) { nvtxRangePop(); }
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2016-2017 NVIDIA Corporation. All rights reserved.
-#elif NV_XBOXONE
-#define NOMINMAX
-#include "xboxone/NvBlastProfilerXB1.h"
-#elif NV_PS4
-#include "ps4/NvBlastProfilerPS4.h"
-
-#else
-NV_INLINE void platformZoneStart(const char*) { }
-NV_INLINE void platformZoneEnd(const char*) { }
-
-#endif
+#ifndef TESTPROFILER_H
+#define TESTPROFILER_H
-#define TEST_ZONE_BEGIN(name) platformZoneStart(name)
-#define TEST_ZONE_END(name) platformZoneEnd(name)
+#define TEST_ZONE_BEGIN(name) platformZoneStart(name)
+#define TEST_ZONE_END(name) platformZoneEnd()
#endif // TESTPROFILER_H