tmp
This commit is contained in:
parent
afab59eb21
commit
69a17a609e
71 changed files with 199 additions and 282 deletions
|
|
@ -32,6 +32,7 @@ tp::MemHead* tp::HeapAllocGlobal::mEntry = nullptr;
|
||||||
tp::ualni tp::HeapAllocGlobal::mNumAllocations = 0;
|
tp::ualni tp::HeapAllocGlobal::mNumAllocations = 0;
|
||||||
std::mutex tp::HeapAllocGlobal::mMutex;
|
std::mutex tp::HeapAllocGlobal::mMutex;
|
||||||
bool tp::HeapAllocGlobal::mIgnore = true;
|
bool tp::HeapAllocGlobal::mIgnore = true;
|
||||||
|
bool tp::HeapAllocGlobal::mEnableCallstack = false;
|
||||||
|
|
||||||
#ifdef MEM_STACK_TRACE
|
#ifdef MEM_STACK_TRACE
|
||||||
tp::CallStackCapture tp::HeapAllocGlobal::mCallstack;
|
tp::CallStackCapture tp::HeapAllocGlobal::mCallstack;
|
||||||
|
|
@ -109,7 +110,7 @@ ALLOCATE:
|
||||||
// 3) Trace the stack
|
// 3) Trace the stack
|
||||||
#ifdef MEM_STACK_TRACE
|
#ifdef MEM_STACK_TRACE
|
||||||
// check if somewhat decides to call new within static variable initialization
|
// check if somewhat decides to call new within static variable initialization
|
||||||
head->mCallStack = mCallstack.getSnapshot();
|
head->mCallStack = (mEnableCallstack && mCallstack.initialized) ? mCallstack.getSnapshot() : nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mMutex.unlock();
|
mMutex.unlock();
|
||||||
|
|
@ -144,20 +145,19 @@ void HeapAllocGlobal::deallocate(void* aPtr) {
|
||||||
if (head == mEntry) {
|
if (head == mEntry) {
|
||||||
mEntry = head->mPrev;
|
mEntry = head->mPrev;
|
||||||
}
|
}
|
||||||
mMutex.unlock();
|
|
||||||
|
|
||||||
if (!head->mIgnored) {
|
if (!head->mIgnored) {
|
||||||
// 3) Check the wrap
|
// 3) Check the wrap
|
||||||
if (memCompareVal(wrap_top, WRAP_SIZE, WRAP_VAL)) {
|
if (memCompareVal(wrap_top, WRAP_SIZE, WRAP_VAL)) {
|
||||||
#ifdef MEM_STACK_TRACE
|
#ifdef MEM_STACK_TRACE
|
||||||
mCallstack.printSnapshot(head->mCallStack);
|
if (head->mCallStack) mCallstack.printSnapshot(head->mCallStack);
|
||||||
#endif
|
#endif
|
||||||
ASSERT(!"Allocated Block Wrap Corrupted!")
|
ASSERT(!"Allocated Block Wrap Corrupted!")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memCompareVal(wrap_bottom, WRAP_SIZE, WRAP_VAL)) {
|
if (memCompareVal(wrap_bottom, WRAP_SIZE, WRAP_VAL)) {
|
||||||
#ifdef MEM_STACK_TRACE
|
#ifdef MEM_STACK_TRACE
|
||||||
mCallstack.printSnapshot(head->mCallStack);
|
if (head->mCallStack) mCallstack.printSnapshot(head->mCallStack);
|
||||||
#endif
|
#endif
|
||||||
ASSERT(!"Allocated Block Wrap Corrupted!")
|
ASSERT(!"Allocated Block Wrap Corrupted!")
|
||||||
}
|
}
|
||||||
|
|
@ -168,6 +168,8 @@ void HeapAllocGlobal::deallocate(void* aPtr) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mMutex.unlock();
|
||||||
|
|
||||||
// 5) free the block
|
// 5) free the block
|
||||||
free(head);
|
free(head);
|
||||||
}
|
}
|
||||||
|
|
@ -183,7 +185,7 @@ bool HeapAllocGlobal::checkLeaks() {
|
||||||
|
|
||||||
#ifdef MEM_STACK_TRACE
|
#ifdef MEM_STACK_TRACE
|
||||||
for (auto iter = mEntry; iter; iter = iter->mPrev) {
|
for (auto iter = mEntry; iter; iter = iter->mPrev) {
|
||||||
if (!iter->mIgnored) mCallstack.printSnapshot(iter->mCallStack);
|
if (!iter->mIgnored && iter->mCallStack) mCallstack.printSnapshot(iter->mCallStack);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -211,6 +213,18 @@ ualni HeapAllocGlobal::getNAllocations() {
|
||||||
return mNumAllocations;
|
return mNumAllocations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void HeapAllocGlobal::enableCallstack() {
|
||||||
|
mMutex.lock();
|
||||||
|
mEnableCallstack = true;
|
||||||
|
mMutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
void HeapAllocGlobal::disableCallstack() {
|
||||||
|
mMutex.lock();
|
||||||
|
mEnableCallstack = false;
|
||||||
|
mMutex.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
HeapAllocGlobal::~HeapAllocGlobal() = default;
|
HeapAllocGlobal::~HeapAllocGlobal() = default;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ namespace tp {
|
||||||
static struct MemHead* mEntry;
|
static struct MemHead* mEntry;
|
||||||
static std::mutex mMutex;
|
static std::mutex mMutex;
|
||||||
static bool mIgnore;
|
static bool mIgnore;
|
||||||
|
static bool mEnableCallstack;
|
||||||
#ifdef MEM_STACK_TRACE // Save stack on allocation call
|
#ifdef MEM_STACK_TRACE // Save stack on allocation call
|
||||||
static CallStackCapture mCallstack;
|
static CallStackCapture mCallstack;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -30,6 +31,9 @@ namespace tp {
|
||||||
static void stopIgnore();
|
static void stopIgnore();
|
||||||
static ualni getNAllocations();
|
static ualni getNAllocations();
|
||||||
|
|
||||||
|
static void enableCallstack();
|
||||||
|
static void disableCallstack();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] bool checkWrap() const { return false; }
|
[[nodiscard]] bool checkWrap() const { return false; }
|
||||||
void checkValid() {}
|
void checkValid() {}
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,9 @@ add_subdirectory(Modules)
|
||||||
add_subdirectory(Callstack)
|
add_subdirectory(Callstack)
|
||||||
add_subdirectory(Containers)
|
add_subdirectory(Containers)
|
||||||
add_subdirectory(Math)
|
add_subdirectory(Math)
|
||||||
add_subdirectory(Allocators)
|
|
||||||
add_subdirectory(Strings)
|
add_subdirectory(Strings)
|
||||||
add_subdirectory(Language)
|
add_subdirectory(Allocators)
|
||||||
|
# add_subdirectory(Language)
|
||||||
add_subdirectory(Externals)
|
add_subdirectory(Externals)
|
||||||
add_subdirectory(Connection)
|
add_subdirectory(Connection)
|
||||||
add_subdirectory(Graphics)
|
add_subdirectory(Graphics)
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,8 @@ CallStackCapture::CallStackCapture() {
|
||||||
|
|
||||||
|
|
||||||
platformInit();
|
platformInit();
|
||||||
|
|
||||||
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const CallStackCapture::CallStack* CallStackCapture::getSnapshot() {
|
const CallStackCapture::CallStack* CallStackCapture::getSnapshot() {
|
||||||
|
|
@ -101,7 +103,10 @@ void CallStackCapture::clear() {
|
||||||
mSymbols.removeAll();
|
mSymbols.removeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
CallStackCapture::~CallStackCapture() { free(mBuff); }
|
CallStackCapture::~CallStackCapture() {
|
||||||
|
free(mBuff);
|
||||||
|
initialized = false;
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------- Platform Depended ---------------------------------- //
|
// ---------------------------------- Platform Depended ---------------------------------- //
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ namespace tp {
|
||||||
public:
|
public:
|
||||||
typedef tp::alni FramePointer;
|
typedef tp::alni FramePointer;
|
||||||
|
|
||||||
|
bool initialized = false;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
MAX_CALL_DEPTH_CAPTURE = 16,
|
MAX_CALL_DEPTH_CAPTURE = 16,
|
||||||
MAX_CALL_CAPTURES_MEM_SIZE_MB = 32,
|
MAX_CALL_CAPTURES_MEM_SIZE_MB = 32,
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,11 @@ file(GLOB HEADERS "./public/*.hpp")
|
||||||
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
|
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC ./public/)
|
target_include_directories(${PROJECT_NAME} PUBLIC ./public/)
|
||||||
target_include_directories(${PROJECT_NAME} PRIVATE ${BINDINGS_INCLUDE})
|
target_include_directories(${PROJECT_NAME} PRIVATE ${BINDINGS_INCLUDE})
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC Strings)
|
target_link_libraries(${PROJECT_NAME} PUBLIC Modules)
|
||||||
|
|
||||||
### -------------------------- Tests -------------------------- ###
|
### -------------------------- Tests -------------------------- ###
|
||||||
enable_testing()
|
enable_testing()
|
||||||
file(GLOB TEST_SOURCES "./tests/*.cpp")
|
file(GLOB TEST_SOURCES "./tests/*.cpp")
|
||||||
add_executable(${PROJECT_NAME}Tests ${TEST_SOURCES})
|
add_executable(Test${PROJECT_NAME} ${TEST_SOURCES})
|
||||||
target_link_libraries(${PROJECT_NAME}Tests ${PROJECT_NAME} UnitTest++)
|
target_link_libraries(Test${PROJECT_NAME} ${PROJECT_NAME} UnitTest++)
|
||||||
add_test(NAME ${PROJECT_NAME}Tests COMMAND ${PROJECT_NAME}Tests)
|
add_test(NAME Test${PROJECT_NAME} COMMAND Test${PROJECT_NAME})
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
|
|
||||||
#include "ConnectionCommon.hpp"
|
|
||||||
|
|
||||||
static tp::ModuleManifest* sModuleDependencies[] = { &tp::gModuleStrings, nullptr };
|
|
||||||
|
|
||||||
tp::ModuleManifest tp::gModuleConnection = ModuleManifest("Storage", nullptr, nullptr, sModuleDependencies);
|
|
||||||
|
|
@ -7,7 +7,8 @@
|
||||||
using namespace tp;
|
using namespace tp;
|
||||||
|
|
||||||
bool LocalConnection::Location::exists() const {
|
bool LocalConnection::Location::exists() const {
|
||||||
FILE* file = fopen(mLocation.read(), "r");
|
// TODO : fixme
|
||||||
|
FILE* file = fopen(mLocation.c_str(), "r");
|
||||||
if (file) {
|
if (file) {
|
||||||
// File exists, close it and return 1
|
// File exists, close it and return 1
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
@ -23,10 +24,8 @@ bool LocalConnection::connect(const Location& location, const Type& connectionIn
|
||||||
auto handle = new LocalConnectionContext();
|
auto handle = new LocalConnectionContext();
|
||||||
|
|
||||||
switch (connectionInfo.getType()) {
|
switch (connectionInfo.getType()) {
|
||||||
case Type::READ: handle->open(location.getLocation().read(), true); break;
|
case Type::READ: handle->open(location.getLocation().c_str(), true); break;
|
||||||
|
case Type::WRITE: handle->open(location.getLocation().c_str(), false); break;
|
||||||
case Type::WRITE: handle->open(location.getLocation().read(), false); break;
|
|
||||||
|
|
||||||
default: break;
|
default: break;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,9 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Strings.hpp"
|
#include "Module.hpp"
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace tp {
|
namespace tp {
|
||||||
extern ModuleManifest gModuleConnection;
|
|
||||||
|
|
||||||
class Connection {
|
class Connection {
|
||||||
public:
|
public:
|
||||||
typedef ualni SizeBytes;
|
typedef ualni SizeBytes;
|
||||||
|
|
|
||||||
|
|
@ -9,20 +9,20 @@ namespace tp {
|
||||||
class LocalConnection : public Connection {
|
class LocalConnection : public Connection {
|
||||||
public:
|
public:
|
||||||
class Location {
|
class Location {
|
||||||
String mLocation;
|
std::string mLocation;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Location() :
|
Location() :
|
||||||
mLocation("tmp"){};
|
mLocation("tmp"){};
|
||||||
explicit Location(const String& location) :
|
explicit Location(const std::string& location) :
|
||||||
mLocation(location) {}
|
mLocation(location) {}
|
||||||
void setLocation(const String& location) { mLocation = location; }
|
void setLocation(const std::string& location) { mLocation = location; }
|
||||||
[[nodiscard]] const String& getLocation() const { return mLocation; }
|
[[nodiscard]] const std::string& getLocation() const { return mLocation; }
|
||||||
[[nodiscard]] bool exists() const;
|
[[nodiscard]] bool exists() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LocalConnection(){ MODULE_SANITY_CHECK(gModuleConnection) };
|
LocalConnection() = default;
|
||||||
|
|
||||||
virtual ~LocalConnection() {
|
virtual ~LocalConnection() {
|
||||||
if (mStatus.isOpened()) LocalConnection::disconnect();
|
if (mStatus.isOpened()) LocalConnection::disconnect();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Common.hpp"
|
#include "Module.hpp"
|
||||||
|
|
||||||
namespace tp {
|
namespace tp {
|
||||||
class ServerContext;
|
class ServerContext;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ConnectionCommon.hpp"
|
#include "ConnectionCommon.hpp"
|
||||||
#include "List.hpp"
|
|
||||||
|
|
||||||
namespace tp {
|
namespace tp {
|
||||||
|
|
||||||
|
|
@ -17,7 +16,7 @@ namespace tp {
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RemoteConnection(){ MODULE_SANITY_CHECK(gModuleConnection) };
|
RemoteConnection() = default;
|
||||||
|
|
||||||
virtual ~RemoteConnection() {
|
virtual ~RemoteConnection() {
|
||||||
if (mStatus.isOpened()) RemoteConnection::disconnect();
|
if (mStatus.isOpened()) RemoteConnection::disconnect();
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,14 @@ SUITE(Connection) {
|
||||||
|
|
||||||
{
|
{
|
||||||
LocalConnection file;
|
LocalConnection file;
|
||||||
file.connect(LocalConnection::Location(String("tmp2.txt")), LocalConnection::Type(false));
|
file.connect(LocalConnection::Location(std::string("tmp2.txt")), LocalConnection::Type(false));
|
||||||
file.writeBytes(data, 6);
|
file.writeBytes(data, 6);
|
||||||
file.disconnect();
|
file.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
LocalConnection file;
|
LocalConnection file;
|
||||||
file.connect(LocalConnection::Location(String("tmp2.txt")), LocalConnection::Type(true));
|
file.connect(LocalConnection::Location(std::string("tmp2.txt")), LocalConnection::Type(true));
|
||||||
file.readBytes(dataRead, 6);
|
file.readBytes(dataRead, 6);
|
||||||
file.disconnect();
|
file.disconnect();
|
||||||
}
|
}
|
||||||
|
|
@ -35,17 +35,5 @@ SUITE(Connection) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
return UnitTest::RunAllTests();
|
||||||
tp::ModuleManifest* deps[] = { &tp::gModuleConnection, nullptr };
|
|
||||||
tp::ModuleManifest testModule("ConnectionTest", nullptr, nullptr, deps);
|
|
||||||
|
|
||||||
if (!testModule.initialize()) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool res = UnitTest::RunAllTests();
|
|
||||||
|
|
||||||
testModule.deinitialize();
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
@ -9,15 +9,16 @@ namespace tp {
|
||||||
template <typename tType, ualni tSizeX, ualni tSizeY>
|
template <typename tType, ualni tSizeX, ualni tSizeY>
|
||||||
using ConstSizeBuffer2D = ConstSizeBuffer<ConstSizeBuffer<tType, tSizeX>, tSizeY>;
|
using ConstSizeBuffer2D = ConstSizeBuffer<ConstSizeBuffer<tType, tSizeX>, tSizeY>;
|
||||||
|
|
||||||
|
typedef ualni Index;
|
||||||
|
|
||||||
|
struct Index2D {
|
||||||
|
Index x = 0;
|
||||||
|
Index y = 0;
|
||||||
|
};
|
||||||
|
|
||||||
template <typename tType, class tAllocator = DefaultAllocator>
|
template <typename tType, class tAllocator = DefaultAllocator>
|
||||||
class Buffer2D {
|
class Buffer2D {
|
||||||
public:
|
public:
|
||||||
typedef ualni Index;
|
|
||||||
|
|
||||||
struct Index2D {
|
|
||||||
Index x = 0;
|
|
||||||
Index y = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef SelectValueOrReference<tType> tTypeArg;
|
typedef SelectValueOrReference<tType> tTypeArg;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,8 @@ add_executable(NumRecApp applications/NumRecApp.cpp)
|
||||||
target_link_libraries(NumRecApp ${PROJECT_NAME} Connection ImageIO)
|
target_link_libraries(NumRecApp ${PROJECT_NAME} Connection ImageIO)
|
||||||
|
|
||||||
### -------------------------- Tests -------------------------- ###
|
### -------------------------- Tests -------------------------- ###
|
||||||
enable_testing()
|
|
||||||
file(GLOB TEST_SOURCES "./tests/*.cpp" "./tests/*/*.cpp")
|
file(GLOB TEST_SOURCES "./tests/*.cpp" "./tests/*/*.cpp")
|
||||||
add_executable(${PROJECT_NAME}Tests ${TEST_SOURCES})
|
add_executable(Test${PROJECT_NAME} ${TEST_SOURCES})
|
||||||
|
target_include_directories(Test${PROJECT_NAME} PUBLIC ./applications/)
|
||||||
target_include_directories(${PROJECT_NAME}Tests PUBLIC ./applications/)
|
target_link_libraries(Test${PROJECT_NAME} ${PROJECT_NAME} UnitTest++)
|
||||||
|
add_test(NAME Test${PROJECT_NAME} COMMAND Test${PROJECT_NAME})
|
||||||
target_link_libraries(${PROJECT_NAME}Tests ${PROJECT_NAME} UnitTest++)
|
|
||||||
add_test(NAME ${PROJECT_NAME}Tests COMMAND ${PROJECT_NAME}Tests)
|
|
||||||
|
|
|
||||||
|
|
@ -62,16 +62,7 @@ int main(int argc, char** argv) {
|
||||||
imageName = argv[1];
|
imageName = argv[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
ModuleManifest* deps[] = { &gModuleDataAnalysis, &gModuleConnection, nullptr };
|
|
||||||
ModuleManifest module = ModuleManifest("NumRec", nullptr, nullptr, deps);
|
|
||||||
|
|
||||||
if (!module.initialize()) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
executeCmd(imageName);
|
executeCmd(imageName);
|
||||||
|
|
||||||
module.deinitialize();
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -24,12 +24,12 @@ void writeImage(const Buffer<halnf>& image, const char* name) {
|
||||||
|
|
||||||
struct Dataset {
|
struct Dataset {
|
||||||
ualni length = 0;
|
ualni length = 0;
|
||||||
Pair<ualni, ualni> imageSize = { 0, 0 };
|
std::pair<ualni, ualni> imageSize = { 0, 0 };
|
||||||
Buffer<uint1> labels;
|
Buffer<uint1> labels;
|
||||||
Buffer<Buffer<uint1>> images;
|
Buffer<Buffer<uint1>> images;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool loadDataset(Dataset& out, const String& location) {
|
bool loadDataset(Dataset& out, const std::string& location) {
|
||||||
LocalConnection dataset;
|
LocalConnection dataset;
|
||||||
dataset.connect(LocalConnection::Location(location), LocalConnection::Type(true));
|
dataset.connect(LocalConnection::Location(location), LocalConnection::Type(true));
|
||||||
|
|
||||||
|
|
@ -207,51 +207,38 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
ModuleManifest* deps[] = { &gModuleDataAnalysis, &gModuleConnection, nullptr };
|
NumberRec app;
|
||||||
ModuleManifest module = ModuleManifest("NumRec", nullptr, nullptr, deps);
|
|
||||||
|
|
||||||
if (!module.initialize()) {
|
auto numBatches = 10;
|
||||||
return 1;
|
auto trainRange = Range(0, 50000);
|
||||||
}
|
auto testRange = Range(50000, 70000);
|
||||||
|
|
||||||
{
|
auto batchSize = trainRange.idxDiff() / numBatches;
|
||||||
NumberRec app;
|
|
||||||
|
|
||||||
auto numBatches = 10;
|
for (auto epoch : Range(1)) {
|
||||||
auto trainRange = Range(0, 50000);
|
printf("Epoch %i\n", epoch.index());
|
||||||
auto testRange = Range(50000, 70000);
|
|
||||||
|
|
||||||
auto batchSize = trainRange.idxDiff() / numBatches;
|
for (auto batchIdx : Range(trainRange.idxDiff() / batchSize)) {
|
||||||
|
printf(" - Batch :%i \n", batchIdx.index());
|
||||||
|
|
||||||
for (auto epoch : Range(1)) {
|
auto batchRange = Range(trainRange.idxBegin() + batchSize * batchIdx, trainRange.idxBegin() + batchSize * (batchIdx + 1));
|
||||||
printf("Epoch %i\n", epoch.index());
|
|
||||||
|
|
||||||
for (auto batchIdx : Range(trainRange.idxDiff() / batchSize)) {
|
app.trainStep(batchRange);
|
||||||
printf(" - Batch :%i \n", batchIdx.index());
|
|
||||||
|
|
||||||
auto batchRange = Range(trainRange.idxBegin() + batchSize * batchIdx, trainRange.idxBegin() + batchSize * (batchIdx + 1));
|
printf("Cost on batch data : %f\n", app.test(batchRange));
|
||||||
|
|
||||||
app.trainStep(batchRange);
|
|
||||||
|
|
||||||
printf("Cost on batch data : %f\n", app.test(batchRange));
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Cost on test data : %f\n\n", app.test(testRange));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto errors = 0;
|
printf("Cost on test data : %f\n\n", app.test(testRange));
|
||||||
for (auto i : testRange) {
|
|
||||||
if (app.testIncorrect(i)) {
|
|
||||||
errors++;
|
|
||||||
}
|
|
||||||
// app.debLog(i);
|
|
||||||
// app.displayImage(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("\n\nIncorrect - %i out of %i (%f)\n\n", errors, testRange.idxDiff(), (halnf) errors / (halnf) testRange.idxDiff());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.deinitialize();
|
auto errors = 0;
|
||||||
|
for (auto i : testRange) {
|
||||||
|
if (app.testIncorrect(i)) {
|
||||||
|
errors++;
|
||||||
|
}
|
||||||
|
// app.debLog(i);
|
||||||
|
// app.displayImage(i);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
printf("\n\nIncorrect - %i out of %i (%f)\n\n", errors, testRange.idxDiff(), (halnf) errors / (halnf) testRange.idxDiff());
|
||||||
}
|
}
|
||||||
|
|
@ -4,6 +4,6 @@
|
||||||
#include "MathCommon.hpp"
|
#include "MathCommon.hpp"
|
||||||
|
|
||||||
namespace tp {
|
namespace tp {
|
||||||
static ModuleManifest* deps[] = { &gModuleMath, &gModuleContainers, &gModuleAllocators, nullptr };
|
static ModuleManifest* deps[] = { &gModuleAllocators, nullptr };
|
||||||
ModuleManifest gModuleDataAnalysis = ModuleManifest("DataAnalysis", nullptr, nullptr, deps);
|
ModuleManifest gModuleDataAnalysis = ModuleManifest("DataAnalysis", nullptr, nullptr, deps);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,22 +24,27 @@ SUITE(FCNN) {
|
||||||
}
|
}
|
||||||
|
|
||||||
FCNN nn(layers);
|
FCNN nn(layers);
|
||||||
halnf steppingValue = 100;
|
halnf steppingValue = 0.01;
|
||||||
|
|
||||||
for (auto i : Range(50)) {
|
halnf cost = 0;
|
||||||
|
|
||||||
|
for (auto i : Range(150)) {
|
||||||
|
|
||||||
nn.evaluate(input, output);
|
nn.evaluate(input, output);
|
||||||
|
|
||||||
nn.calcGrad(outputExpected);
|
nn.calcGrad(outputExpected);
|
||||||
nn.applyGrad(steppingValue);
|
nn.applyGrad(steppingValue);
|
||||||
|
|
||||||
|
cost = nn.calcCost(outputExpected);
|
||||||
printf("Loss %f \n", nn.calcCost(outputExpected));
|
printf("Loss %f \n", nn.calcCost(outputExpected));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CHECK(cost < 0.1f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
tp::ModuleManifest* deps[] = { &tp::gModuleDataAnalysis, &tp::gModuleUtils, nullptr };
|
tp::ModuleManifest* deps[] = { &tp::gModuleDataAnalysis, nullptr };
|
||||||
tp::ModuleManifest testModule("DataAnalysisTest", nullptr, nullptr, deps);
|
tp::ModuleManifest testModule("DataAnalysisTest", nullptr, nullptr, deps);
|
||||||
|
|
||||||
if (!testModule.initialize()) {
|
if (!testModule.initialize()) {
|
||||||
|
|
|
||||||
1
Externals/CMakeLists.txt
vendored
1
Externals/CMakeLists.txt
vendored
|
|
@ -32,7 +32,6 @@ endif()
|
||||||
#add_subdirectory(unittest-cpp)
|
#add_subdirectory(unittest-cpp)
|
||||||
|
|
||||||
add_subdirectory(lalr)
|
add_subdirectory(lalr)
|
||||||
|
|
||||||
add_subdirectory(glfw)
|
add_subdirectory(glfw)
|
||||||
|
|
||||||
project(Imgui)
|
project(Imgui)
|
||||||
|
|
|
||||||
2
Externals/asio
vendored
2
Externals/asio
vendored
|
|
@ -1 +1 @@
|
||||||
Subproject commit 3a7078a2002c670d98ee3044802a5086f3e49634
|
Subproject commit ed5db1b50136bace796062c1a6eab0df9a74f8fa
|
||||||
|
|
@ -10,11 +10,14 @@ file(GLOB HEADERS "./public/*.hpp")
|
||||||
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
|
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC ./public/)
|
target_include_directories(${PROJECT_NAME} PUBLIC ./public/)
|
||||||
target_include_directories(${PROJECT_NAME} PRIVATE ${BINDINGS_INCLUDE})
|
target_include_directories(${PROJECT_NAME} PRIVATE ${BINDINGS_INCLUDE})
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC Strings Math Utils)
|
target_link_libraries(${PROJECT_NAME} PUBLIC Strings Math Allocators)
|
||||||
target_link_libraries(${PROJECT_NAME} PRIVATE ${BINDINGS_LIBS})
|
target_link_libraries(${PROJECT_NAME} PRIVATE ${BINDINGS_LIBS})
|
||||||
|
|
||||||
### -------------------------- Examples -------------------------- ###
|
### -------------------------- Examples -------------------------- ###
|
||||||
add_executable(${PROJECT_NAME}Example ./examples/Example.cpp)
|
add_executable(Example${PROJECT_NAME} ./examples/Example.cpp)
|
||||||
target_link_libraries(${PROJECT_NAME}Example ${PROJECT_NAME} ${BINDINGS_LIBS})
|
target_link_libraries(Example${PROJECT_NAME} ${PROJECT_NAME} ${BINDINGS_LIBS})
|
||||||
target_include_directories(${PROJECT_NAME}Example PRIVATE ${BINDINGS_INCLUDE})
|
target_include_directories(Example${PROJECT_NAME} PRIVATE ${BINDINGS_INCLUDE})
|
||||||
|
|
||||||
|
|
||||||
|
file(COPY "examples/Font.ttf" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/")
|
||||||
|
|
||||||
|
|
|
||||||
BIN
Graphics/examples/Font.ttf
Normal file
BIN
Graphics/examples/Font.ttf
Normal file
Binary file not shown.
|
|
@ -1,6 +1,7 @@
|
||||||
#include "GraphicsCommon.hpp"
|
#include "GraphicsCommon.hpp"
|
||||||
|
#include "MathCommon.hpp"
|
||||||
|
|
||||||
namespace tp {
|
namespace tp {
|
||||||
static ModuleManifest* deps[] = { &gModuleStrings, &gModuleMath, nullptr };
|
static ModuleManifest* deps[] = { &gModuleAllocators, nullptr };
|
||||||
ModuleManifest gModuleGraphics = ModuleManifest("Graphics", nullptr, nullptr, deps);
|
ModuleManifest gModuleGraphics = ModuleManifest("Graphics", nullptr, nullptr, deps);
|
||||||
}
|
}
|
||||||
|
|
@ -71,7 +71,7 @@ void Graphics::Canvas::popClamp() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::Canvas::text(
|
void Graphics::Canvas::text(
|
||||||
const String& string, const RectF& aRec, halnf size, Align align, halnf marging, const RGBA& col
|
const char* string, const RectF& aRec, halnf size, Align align, halnf marging, const RGBA& col
|
||||||
) {
|
) {
|
||||||
RectF rec = { aRec.x + marging, aRec.y + marging, aRec.z - marging * 2, aRec.w - marging * 2 };
|
RectF rec = { aRec.x + marging, aRec.y + marging, aRec.z - marging * 2, aRec.w - marging * 2 };
|
||||||
|
|
||||||
|
|
@ -107,7 +107,7 @@ void Graphics::Canvas::text(
|
||||||
|
|
||||||
nvgTextAlign(mContext->vg, alignNVG);
|
nvgTextAlign(mContext->vg, alignNVG);
|
||||||
|
|
||||||
nvgText(mContext->vg, centerX, centerY, string.read(), nullptr);
|
nvgText(mContext->vg, centerX, centerY, string, nullptr);
|
||||||
|
|
||||||
popClamp();
|
popClamp();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "GraphicsCommon.hpp"
|
#include "GraphicsCommon.hpp"
|
||||||
|
|
||||||
// TODO : fix this ugly shit
|
// TODO : ugly
|
||||||
|
|
||||||
namespace tp {
|
namespace tp {
|
||||||
class Window;
|
class Window;
|
||||||
|
|
@ -85,7 +85,7 @@ namespace tp {
|
||||||
void pushClamp(const RectF& rec);
|
void pushClamp(const RectF& rec);
|
||||||
void popClamp();
|
void popClamp();
|
||||||
void rect(const RectF& rec, const RGBA& col, halnf round = 0);
|
void rect(const RectF& rec, const RGBA& col, halnf round = 0);
|
||||||
void text(const String&, const RectF&, halnf size, Align, halnf marging, const RGBA&);
|
void text(const char*, const RectF&, halnf size, Align, halnf marging, const RGBA&);
|
||||||
|
|
||||||
// TODO : API
|
// TODO : API
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,10 @@
|
||||||
|
|
||||||
#include "Color.hpp"
|
#include "Color.hpp"
|
||||||
#include "Rect.hpp"
|
#include "Rect.hpp"
|
||||||
#include "Strings.hpp"
|
|
||||||
#include "Timing.hpp"
|
#include "Timing.hpp"
|
||||||
|
|
||||||
|
#include "Allocators.hpp"
|
||||||
|
|
||||||
namespace tp {
|
namespace tp {
|
||||||
extern ModuleManifest gModuleGraphics;
|
extern ModuleManifest gModuleGraphics;
|
||||||
}
|
}
|
||||||
|
|
@ -11,7 +11,7 @@ file(GLOB HEADERS "./public/*.hpp" "./public/*/*.hpp" "./applications/*.hpp")
|
||||||
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
|
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
|
||||||
|
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC ./public/ ${BINDINGS_INCLUDE} ./ext/)
|
target_include_directories(${PROJECT_NAME} PUBLIC ./public/ ${BINDINGS_INCLUDE} ./ext/)
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC Graphics Connection Widgets)
|
target_link_libraries(${PROJECT_NAME} PUBLIC Graphics Connection Widgets Strings)
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC ${BINDINGS_LIBS})
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${BINDINGS_LIBS})
|
||||||
|
|
||||||
file(COPY "library" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}")
|
file(COPY "library" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}")
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ void runApp() {
|
||||||
|
|
||||||
auto area = window->getCanvas().getAvaliableArea();
|
auto area = window->getCanvas().getAvaliableArea();
|
||||||
|
|
||||||
gui.proc(window->getEvents(), {}, { area.x, area.y, area.z, area.w });
|
gui.proc(window->getEvents(), { area.x, area.y, area.z, area.w }, { area.x, area.y, area.z, area.w });
|
||||||
gui.draw(window->getCanvas());
|
gui.draw(window->getCanvas());
|
||||||
|
|
||||||
// tp::sleep(100);
|
// tp::sleep(100);
|
||||||
|
|
@ -54,6 +54,8 @@ int main() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tp::HeapAllocGlobal::disableCallstack();
|
||||||
|
|
||||||
runApp();
|
runApp();
|
||||||
|
|
||||||
binModule.deinitialize();
|
binModule.deinitialize();
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
|
|
||||||
namespace tp {
|
namespace tp {
|
||||||
static ModuleManifest* deps[] = { &gModuleGraphics, &gModuleConnection, &gModuleWidgets, nullptr };
|
static ModuleManifest* deps[] = { &gModuleGraphics, &gModuleStrings, &gModuleAllocators, nullptr };
|
||||||
ModuleManifest gModuleLibraryViewer = ModuleManifest("LibraryViewer", nullptr, nullptr, deps);
|
ModuleManifest gModuleLibraryViewer = ModuleManifest("LibraryViewer", nullptr, nullptr, deps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -51,7 +51,7 @@ bool Library::loadJson(const String& path) {
|
||||||
LocalConnection libraryFile;
|
LocalConnection libraryFile;
|
||||||
Buffer<int1> libraryFileMem;
|
Buffer<int1> libraryFileMem;
|
||||||
|
|
||||||
if (!libraryFile.connect(LocalConnection::Location(path), LocalConnection::Type(true))) return false;
|
if (!libraryFile.connect(LocalConnection::Location(path.read()), LocalConnection::Type(true))) return false;
|
||||||
|
|
||||||
libraryFileMem.reserve(libraryFile.size());
|
libraryFileMem.reserve(libraryFile.size());
|
||||||
libraryFile.readBytes(libraryFileMem.getBuff(), libraryFile.size());
|
libraryFile.readBytes(libraryFileMem.getBuff(), libraryFile.size());
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Window.hpp"
|
#include "Window.hpp"
|
||||||
|
#include "Strings.hpp"
|
||||||
|
|
||||||
typedef tp::ualni SongId;
|
typedef tp::ualni SongId;
|
||||||
enum class SONG_FORMAT { WAV, FLAC, NONE };
|
enum class SONG_FORMAT { WAV, FLAC, NONE };
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,10 @@ file(GLOB SOURCES "./private/*.cpp")
|
||||||
file(GLOB HEADERS "./public/*.hpp")
|
file(GLOB HEADERS "./public/*.hpp")
|
||||||
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
|
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC ./public/)
|
target_include_directories(${PROJECT_NAME} PUBLIC ./public/)
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC Allocators)
|
target_link_libraries(${PROJECT_NAME} PUBLIC Containers)
|
||||||
|
|
||||||
### -------------------------- Tests -------------------------- ###
|
### -------------------------- Tests -------------------------- ###
|
||||||
enable_testing()
|
|
||||||
file(GLOB TEST_SOURCES "./tests/*.cpp")
|
file(GLOB TEST_SOURCES "./tests/*.cpp")
|
||||||
add_executable(${PROJECT_NAME}Tests ${TEST_SOURCES})
|
add_executable(Test${PROJECT_NAME} ${TEST_SOURCES})
|
||||||
target_link_libraries(${PROJECT_NAME}Tests ${PROJECT_NAME} UnitTest++)
|
target_link_libraries(Test${PROJECT_NAME} ${PROJECT_NAME} UnitTest++)
|
||||||
add_test(NAME ${PROJECT_NAME}Tests COMMAND ${PROJECT_NAME}Tests)
|
add_test(NAME Test${PROJECT_NAME} COMMAND Test${PROJECT_NAME})
|
||||||
|
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
||||||
|
|
||||||
/// whoaoao wtf
|
|
||||||
|
|
||||||
#include "MathCommon.hpp"
|
|
||||||
#include "Allocators.hpp"
|
|
||||||
|
|
||||||
static tp::ModuleManifest* sModuleDependencies[] = { &tp::gModuleAllocators, nullptr };
|
|
||||||
|
|
||||||
tp::ModuleManifest tp::gModuleMath = ModuleManifest("Math", nullptr, nullptr, sModuleDependencies);
|
|
||||||
|
|
||||||
tp::alnf std_sin(tp::alnf radians);
|
|
||||||
tp::alnf std_tan(tp::alnf radians);
|
|
||||||
tp::alnf std_cos(tp::alnf radians);
|
|
||||||
tp::alnf std_acos(tp::alnf val);
|
|
||||||
tp::alnf std_sqrt(tp::alnf val);
|
|
||||||
tp::alnf std_rad(tp::alnf val);
|
|
||||||
tp::alnf std_deg(tp::alnf val);
|
|
||||||
tp::alnf std_atan2(tp::alnf X, tp::alnf Y);
|
|
||||||
tp::alnf std_atan(tp::alnf val);
|
|
||||||
tp::alnf std_log2(tp::alnf val);
|
|
||||||
|
|
||||||
tp::alnf tp::sin(const tp::alnf radians) { return std_sin((halnf) radians); }
|
|
||||||
tp::alnf tp::tan(const tp::alnf radians) { return std_tan((halnf) radians); }
|
|
||||||
tp::alnf tp::cos(const tp::alnf radians) { return std_cos((halnf) radians); }
|
|
||||||
tp::alnf tp::acos(const tp::alnf val) { return std_acos((halnf) val); }
|
|
||||||
tp::alnf tp::sqrt(const tp::alnf val) { return std_sqrt((halnf) val); }
|
|
||||||
tp::alnf tp::rad(const tp::alnf val) { return val * (PI / 180.f); }
|
|
||||||
tp::alnf tp::deg(const tp::alnf val) { return val * (180.f / PI); }
|
|
||||||
tp::alnf tp::atan2(const tp::alnf X, const tp::alnf Y) { return std_atan2((halnf) X, (halnf) Y); }
|
|
||||||
tp::alnf tp::atan(const tp::alnf val) { return std_atan((halnf) val); }
|
|
||||||
tp::alnf tp::log2(alnf val) { return std_log2(val); }
|
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
|
|
||||||
tp::alnf std_sin(const tp::alnf radians) { return sinf((tp::halnf) radians); }
|
|
||||||
tp::alnf std_tan(const tp::alnf radians) { return tanf((tp::halnf) radians); }
|
|
||||||
tp::alnf std_cos(const tp::alnf radians) { return cosf((tp::halnf) radians); }
|
|
||||||
tp::alnf std_acos(const tp::alnf val) { return acos((tp::halnf) val); }
|
|
||||||
tp::alnf std_sqrt(const tp::alnf val) { return sqrt((tp::halnf) val); }
|
|
||||||
tp::alnf std_rad(const tp::alnf val) { return val * (PI / 180.f); }
|
|
||||||
tp::alnf std_deg(const tp::alnf val) { return val * (180.f / PI); }
|
|
||||||
tp::alnf std_atan2(const tp::alnf X, const tp::alnf Y) { return atan2((tp::halnf) X, (tp::halnf) Y); }
|
|
||||||
tp::alnf std_atan(const tp::alnf val) { return atan((tp::halnf) val); }
|
|
||||||
tp::alnf std_log2(const tp::alnf val) { return log2((tp::halnf) val); }
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
|
|
||||||
#include "Topology.hpp"
|
#include "Topology.hpp"
|
||||||
|
|
||||||
#include "NewPlacement.hpp"
|
|
||||||
|
|
||||||
using namespace tp;
|
using namespace tp;
|
||||||
|
|
||||||
Vec3F TrigCache::gHitPos;
|
Vec3F TrigCache::gHitPos;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@
|
||||||
using namespace tp;
|
using namespace tp;
|
||||||
|
|
||||||
Trig::Trig() {
|
Trig::Trig() {
|
||||||
MODULE_SANITY_CHECK(gModuleMath)
|
|
||||||
p1.assign(0.f, 0.f, 0.f);
|
p1.assign(0.f, 0.f, 0.f);
|
||||||
p2.assign(0.f, 0.f, 0.f);
|
p2.assign(0.f, 0.f, 0.f);
|
||||||
p3.assign(0.f, 0.f, 0.f);
|
p3.assign(0.f, 0.f, 0.f);
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace tp {
|
||||||
|
|
||||||
[[nodiscard]] ComplexCart operator-(const ComplexCart& in) const { return { in.r - r, in.i - i }; }
|
[[nodiscard]] ComplexCart operator-(const ComplexCart& in) const { return { in.r - r, in.i - i }; }
|
||||||
|
|
||||||
[[nodiscard]] Number mod() const { return tp::sqrt(i * i + r * r); }
|
[[nodiscard]] Number mod() const { return sqrt(i * i + r * r); }
|
||||||
|
|
||||||
[[nodiscard]] Number arg() const { return atan2(r, i); }
|
[[nodiscard]] Number arg() const { return atan2(r, i); }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,17 +13,7 @@
|
||||||
#define SQRT2 1.4142135623730950488016887242
|
#define SQRT2 1.4142135623730950488016887242
|
||||||
#define EXP 2.7182818284590452353602874714
|
#define EXP 2.7182818284590452353602874714
|
||||||
|
|
||||||
namespace tp {
|
#include <cmath>
|
||||||
extern ModuleManifest gModuleMath;
|
|
||||||
|
|
||||||
alnf sin(alnf radians);
|
#define RAD(val) (val * (PI / 180.f))
|
||||||
alnf tan(alnf radians);
|
#define DEG(val) (val * (180.f / PI))
|
||||||
alnf atan2(alnf X, alnf Y);
|
|
||||||
alnf atan(alnf val);
|
|
||||||
alnf cos(alnf radians);
|
|
||||||
alnf acos(alnf val);
|
|
||||||
alnf sqrt(alnf val);
|
|
||||||
alnf rad(alnf val);
|
|
||||||
alnf deg(alnf val);
|
|
||||||
alnf log2(alnf val);
|
|
||||||
}
|
|
||||||
|
|
@ -16,7 +16,7 @@ namespace tp {
|
||||||
inline Type& set(ualni i, TypeArg arg) { return mBuff[i] = arg; }
|
inline Type& set(ualni i, TypeArg arg) { return mBuff[i] = arg; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Vec() { MODULE_SANITY_CHECK(gModuleMath) }
|
Vec() = default;
|
||||||
|
|
||||||
explicit Vec(TypeArg val) { assign(val); }
|
explicit Vec(TypeArg val) { assign(val); }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,16 +44,5 @@ SUITE(Math) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
tp::ModuleManifest* deps[] = { &tp::gModuleMath, &tp::gModuleUtils, nullptr };
|
return UnitTest::RunAllTests();
|
||||||
tp::ModuleManifest testModule("MathTest", nullptr, nullptr, deps);
|
|
||||||
|
|
||||||
if (!testModule.initialize()) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool res = UnitTest::RunAllTests();
|
|
||||||
|
|
||||||
testModule.deinitialize();
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ void deinitializeCallStackCapture();
|
||||||
|
|
||||||
static bool initialize(const tp::ModuleManifest*) {
|
static bool initialize(const tp::ModuleManifest*) {
|
||||||
initializeCallStackCapture();
|
initializeCallStackCapture();
|
||||||
std::srand(std::time(nullptr));
|
// std::srand(std::time(nullptr));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
#include "Common.hpp"
|
#include "Common.hpp"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace tp {
|
namespace tp {
|
||||||
|
|
||||||
// Used to transfer data to or from some sort of archive
|
// Used to transfer data to or from some sort of archive
|
||||||
|
|
@ -130,4 +132,29 @@ namespace tp {
|
||||||
ualni mAddress = 0;
|
ualni mAddress = 0;
|
||||||
ualni mFirstNotWritten = 0;
|
ualni mFirstNotWritten = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct StringArchiver {
|
||||||
|
std::string* val;
|
||||||
|
|
||||||
|
StringArchiver(std::string& val) { this->val = &val; }
|
||||||
|
|
||||||
|
template <typename tArchiver>
|
||||||
|
void archiveRead(tArchiver& ar) {
|
||||||
|
ualni len;
|
||||||
|
ar >> len;
|
||||||
|
val->resize(len);
|
||||||
|
for (ualni i = 0; i < len; i++) {
|
||||||
|
ar >> (*val)[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename tArchiver>
|
||||||
|
void archiveWrite(tArchiver& ar) const {
|
||||||
|
ualni len = val->size();
|
||||||
|
ar << len;
|
||||||
|
for (ualni i = 0; i < len; i++) {
|
||||||
|
ar << (*val)[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Assert.hpp"
|
#include "Assert.hpp"
|
||||||
|
#include "Utils.hpp"
|
||||||
#include "Common.hpp"
|
#include "Common.hpp"
|
||||||
|
|
||||||
#define MODULE_SANITY_CHECK(name) DEBUG_ASSERT(name.isInitialized() && "Modules Is Not Initialized" && #name)
|
#define MODULE_SANITY_CHECK(name) DEBUG_ASSERT(name.isInitialized() && "Modules Is Not Initialized" && #name)
|
||||||
|
|
|
||||||
|
|
@ -216,7 +216,7 @@ struct HasArchive<T, A, VoidType<decltype(DeclareValue<T>()().archive(DeclareVal
|
||||||
|
|
||||||
SUITE(BaseModule) {
|
SUITE(BaseModule) {
|
||||||
TEST(Basic) {
|
TEST(Basic) {
|
||||||
tp::ModuleManifest* ModuleDependencies[] = { &tp::gModuleBase, nullptr };
|
tp::ModuleManifest* ModuleDependencies[] = { nullptr };
|
||||||
tp::ModuleManifest TestModule("Test", nullptr, nullptr, ModuleDependencies);
|
tp::ModuleManifest TestModule("Test", nullptr, nullptr, ModuleDependencies);
|
||||||
|
|
||||||
REQUIRE CHECK(TestModule.initialize());
|
REQUIRE CHECK(TestModule.initialize());
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ file(GLOB HEADERS "./public/*.hpp" "./public/*/*.hpp" "./applications/*.hpp")
|
||||||
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
|
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
|
||||||
|
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC ./public/ ${BINDINGS_INCLUDE})
|
target_include_directories(${PROJECT_NAME} PUBLIC ./public/ ${BINDINGS_INCLUDE})
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC Strings Math Connection LALR)
|
target_link_libraries(${PROJECT_NAME} PUBLIC Strings Math Connection LALR Strings)
|
||||||
target_compile_definitions(${PROJECT_NAME} PUBLIC USERDATA_DESTROY_FAILED_TREE_ROOTS)
|
target_compile_definitions(${PROJECT_NAME} PUBLIC USERDATA_DESTROY_FAILED_TREE_ROOTS)
|
||||||
|
|
||||||
### -------------------------- Applications -------------------------- ###
|
### -------------------------- Applications -------------------------- ###
|
||||||
|
|
@ -23,6 +23,6 @@ file(COPY "rsc/Font.ttf" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/")
|
||||||
|
|
||||||
### -------------------------- Tests -------------------------- ###
|
### -------------------------- Tests -------------------------- ###
|
||||||
file(GLOB TEST_SOURCES "./tests/*.cpp" "./tests/*/*.cpp")
|
file(GLOB TEST_SOURCES "./tests/*.cpp" "./tests/*/*.cpp")
|
||||||
add_executable(${PROJECT_NAME}Tests ${TEST_SOURCES})
|
add_executable(Test${PROJECT_NAME} ${TEST_SOURCES})
|
||||||
target_link_libraries(${PROJECT_NAME}Tests ${PROJECT_NAME} UnitTest++)
|
target_link_libraries(Test${PROJECT_NAME} ${PROJECT_NAME} UnitTest++)
|
||||||
add_test(NAME ${PROJECT_NAME}Tests COMMAND ${PROJECT_NAME}Tests)
|
add_test(NAME Test${PROJECT_NAME} COMMAND Test${PROJECT_NAME})
|
||||||
|
|
@ -77,9 +77,7 @@ static void deinit(const tp::ModuleManifest*) {
|
||||||
|
|
||||||
static tp::ModuleManifest* sModuleDependencies[] = {
|
static tp::ModuleManifest* sModuleDependencies[] = {
|
||||||
// &tp::gModuleCompressor,
|
// &tp::gModuleCompressor,
|
||||||
&tp::gModuleMath,
|
|
||||||
&tp::gModuleStrings,
|
&tp::gModuleStrings,
|
||||||
&tp::gModuleConnection,
|
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,26 +3,18 @@ project(RayTracer)
|
||||||
### ---------------------- Static Library --------------------- ###
|
### ---------------------- Static Library --------------------- ###
|
||||||
file(GLOB SOURCES "./private/*.cpp" "./private/*/*.cpp")
|
file(GLOB SOURCES "./private/*.cpp" "./private/*/*.cpp")
|
||||||
file(GLOB HEADERS "./public/*.hpp" "./public/*/*.hpp" "./applications/*.hpp")
|
file(GLOB HEADERS "./public/*.hpp" "./public/*/*.hpp" "./applications/*.hpp")
|
||||||
|
|
||||||
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
|
add_library(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})
|
||||||
|
|
||||||
target_include_directories(${PROJECT_NAME} PUBLIC ./public/)
|
target_include_directories(${PROJECT_NAME} PUBLIC ./public/)
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC Math Connection)
|
target_link_libraries(${PROJECT_NAME} PUBLIC Math Connection)
|
||||||
|
|
||||||
### -------------------------- Applications -------------------------- ###
|
### -------------------------- Applications -------------------------- ###
|
||||||
add_executable(rayt ./applications/Rayt.cpp applications/SceneLoad.cpp
|
add_executable(rayt ./applications/Rayt.cpp applications/SceneLoad.cpp applications/Rayt.hpp)
|
||||||
applications/Rayt.hpp)
|
|
||||||
|
|
||||||
target_link_libraries(rayt ${PROJECT_NAME} Lua ImageIO)
|
target_link_libraries(rayt ${PROJECT_NAME} Lua ImageIO)
|
||||||
|
|
||||||
file(COPY "applications/rsc" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/")
|
file(COPY "applications/rsc" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/")
|
||||||
|
|
||||||
### -------------------------- Tests -------------------------- ###
|
### -------------------------- Tests -------------------------- ###
|
||||||
enable_testing()
|
|
||||||
file(GLOB TEST_SOURCES "./tests/*.cpp" "./tests/*/*.cpp")
|
file(GLOB TEST_SOURCES "./tests/*.cpp" "./tests/*/*.cpp")
|
||||||
add_executable(${PROJECT_NAME}Tests ${TEST_SOURCES})
|
add_executable(Test${PROJECT_NAME} ${TEST_SOURCES})
|
||||||
|
target_include_directories(Test${PROJECT_NAME} PUBLIC ./applications/)
|
||||||
target_include_directories(${PROJECT_NAME}Tests PUBLIC ./applications/)
|
target_link_libraries(Test${PROJECT_NAME} ${PROJECT_NAME} UnitTest++ ImageIO)
|
||||||
|
add_test(NAME Test${PROJECT_NAME} COMMAND Test${PROJECT_NAME})
|
||||||
target_link_libraries(${PROJECT_NAME}Tests ${PROJECT_NAME} UnitTest++ ImageIO)
|
|
||||||
add_test(NAME ${PROJECT_NAME}Tests COMMAND ${PROJECT_NAME}Tests)
|
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ void writeImage(const RayTracer::RenderBuffer& output, const char* name) {
|
||||||
Buffer2D<urgb> converted;
|
Buffer2D<urgb> converted;
|
||||||
converted.reserve(output.size());
|
converted.reserve(output.size());
|
||||||
|
|
||||||
for (RayTracer::RenderBuffer::Index i = 0; i < output.size().x; i++) {
|
for (Index i = 0; i < output.size().x; i++) {
|
||||||
for (RayTracer::RenderBuffer::Index j = 0; j < output.size().y; j++) {
|
for (Index j = 0; j < output.size().y; j++) {
|
||||||
converted.get({ i, j }).r = uint1(output.get({ i, j }).r * 255);
|
converted.get({ i, j }).r = uint1(output.get({ i, j }).r * 255);
|
||||||
converted.get({ i, j }).g = uint1(output.get({ i, j }).g * 255);
|
converted.get({ i, j }).g = uint1(output.get({ i, j }).g * 255);
|
||||||
converted.get({ i, j }).b = uint1(output.get({ i, j }).b * 255);
|
converted.get({ i, j }).b = uint1(output.get({ i, j }).b * 255);
|
||||||
|
|
@ -51,7 +51,7 @@ void printStatus(const halnf* percentage) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderCommand(const String& scenePath) {
|
void renderCommand(const std::string& scenePath) {
|
||||||
Scene scene;
|
Scene scene;
|
||||||
RayTracer::RenderSettings settings;
|
RayTracer::RenderSettings settings;
|
||||||
|
|
||||||
|
|
@ -80,14 +80,6 @@ void renderCommand(const String& scenePath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char** argv) {
|
int main(int argc, const char** argv) {
|
||||||
tp::ModuleManifest* deps[] = { &gModuleRayTracer, nullptr };
|
renderCommand("scene.lua");
|
||||||
tp::ModuleManifest module("Rayt", nullptr, nullptr, deps);
|
|
||||||
|
|
||||||
if (module.initialize()) {
|
|
||||||
renderCommand("scene.lua");
|
|
||||||
|
|
||||||
module.deinitialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "RayTracer.hpp"
|
#include "RayTracer.hpp"
|
||||||
#include "Strings.hpp"
|
|
||||||
|
|
||||||
void loadScene(tp::Scene& scene, const tp::String& scenePath, tp::RayTracer::RenderSettings& settings);
|
#include <string>
|
||||||
|
|
||||||
|
void loadScene(tp::Scene& scene, const std::string& scenePath, tp::RayTracer::RenderSettings& settings);
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,12 @@ extern "C" {
|
||||||
|
|
||||||
#include "OBJ_Loader.h"
|
#include "OBJ_Loader.h"
|
||||||
|
|
||||||
bool loadMeshes(tp::Scene& scene, const tp::String& objetsPath) {
|
bool loadMeshes(tp::Scene& scene, const std::string& objetsPath) {
|
||||||
using namespace tp;
|
using namespace tp;
|
||||||
|
|
||||||
objl::Loader Loader;
|
objl::Loader Loader;
|
||||||
|
|
||||||
if (!Loader.LoadFile(objetsPath.read())) {
|
if (!Loader.LoadFile(objetsPath.c_str())) {
|
||||||
std::cout << "Failed to Load File. May have failed to find it or it was not an .obj file.\n";
|
std::cout << "Failed to Load File. May have failed to find it or it was not an .obj file.\n";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -123,7 +123,7 @@ int readLight(lua_State* L, tp::PointLight* light) {
|
||||||
return 1; // Success
|
return 1; // Success
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadScene(tp::Scene& scene, const tp::String& scenePath, tp::RayTracer::RenderSettings& settings) {
|
void loadScene(tp::Scene& scene, const std::string& scenePath, tp::RayTracer::RenderSettings& settings) {
|
||||||
lua_State* L = luaL_newstate();
|
lua_State* L = luaL_newstate();
|
||||||
luaL_openlibs(L);
|
luaL_openlibs(L);
|
||||||
|
|
||||||
|
|
@ -136,7 +136,7 @@ void loadScene(tp::Scene& scene, const tp::String& scenePath, tp::RayTracer::Ren
|
||||||
lua_getglobal(L, "Meshes");
|
lua_getglobal(L, "Meshes");
|
||||||
|
|
||||||
if (lua_isstring(L, -1)) {
|
if (lua_isstring(L, -1)) {
|
||||||
tp::String meshesPath = lua_tostring(L, -1);
|
std::string meshesPath = lua_tostring(L, -1);
|
||||||
|
|
||||||
if (!loadMeshes(scene, meshesPath)) {
|
if (!loadMeshes(scene, meshesPath)) {
|
||||||
printf("No 'meshes' loaded - check ur .obj path and validate content of .obj .\n");
|
printf("No 'meshes' loaded - check ur .obj path and validate content of .obj .\n");
|
||||||
|
|
|
||||||
|
|
@ -43,10 +43,6 @@ normal = n1 * barycentric.x + n2 * barycentric.y + n3 * barycentric.z;
|
||||||
|
|
||||||
using namespace tp;
|
using namespace tp;
|
||||||
|
|
||||||
ModuleManifest* sDependencies[] = { &gModuleMath, &gModuleConnection, nullptr };
|
|
||||||
|
|
||||||
ModuleManifest tp::gModuleRayTracer = ModuleManifest("RayTracer", nullptr, nullptr, sDependencies);
|
|
||||||
|
|
||||||
void RayTracer::castRay(const Ray& ray, RayCastData& out, alnf farVal) {
|
void RayTracer::castRay(const Ray& ray, RayCastData& out, alnf farVal) {
|
||||||
out.hit = false;
|
out.hit = false;
|
||||||
|
|
||||||
|
|
@ -167,8 +163,8 @@ void RayTracer::render(const Scene& scene, OutputBuffers& out, const RenderSetti
|
||||||
col.b /= num;
|
col.b /= num;
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto i = 0; i < mSettings.size.x; i++) {
|
for (ualni i = 0; i < mSettings.size.x; i++) {
|
||||||
for (auto j = 0; j < mSettings.size.y; j++) {
|
for (ualni j = 0; j < mSettings.size.y; j++) {
|
||||||
for (auto sample = 0; sample < mSettings.multisampling; sample++) {
|
for (auto sample = 0; sample < mSettings.multisampling; sample++) {
|
||||||
auto randX = randomFloat();
|
auto randX = randomFloat();
|
||||||
auto randY = randomFloat();
|
auto randY = randomFloat();
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ namespace tp {
|
||||||
uhalni depth = 2;
|
uhalni depth = 2;
|
||||||
uhalni spray = 1;
|
uhalni spray = 1;
|
||||||
ualni multisampling = 1;
|
ualni multisampling = 1;
|
||||||
Vec2I size;
|
Vec2<ualni> size;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct OutputBuffers {
|
struct OutputBuffers {
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ void writeImage(const RayTracer::RenderBuffer& output) {
|
||||||
Buffer2D<urgb> converted;
|
Buffer2D<urgb> converted;
|
||||||
converted.reserve(output.size());
|
converted.reserve(output.size());
|
||||||
|
|
||||||
for (RayTracer::RenderBuffer::Index i = 0; i < output.size().x; i++) {
|
for (Index i = 0; i < output.size().x; i++) {
|
||||||
for (RayTracer::RenderBuffer::Index j = 0; j < output.size().y; j++) {
|
for (Index j = 0; j < output.size().y; j++) {
|
||||||
converted.get({ i, j }).r = uint1(output.get({ i, j }).r * 255);
|
converted.get({ i, j }).r = uint1(output.get({ i, j }).r * 255);
|
||||||
converted.get({ i, j }).g = uint1(output.get({ i, j }).g * 255);
|
converted.get({ i, j }).g = uint1(output.get({ i, j }).g * 255);
|
||||||
converted.get({ i, j }).b = uint1(output.get({ i, j }).b * 255);
|
converted.get({ i, j }).b = uint1(output.get({ i, j }).b * 255);
|
||||||
|
|
@ -101,8 +101,8 @@ SUITE(RayTracer) {
|
||||||
|
|
||||||
if (0) {
|
if (0) {
|
||||||
writeImage(output.color);
|
writeImage(output.color);
|
||||||
for (auto i = 0; i < output.color.size().x; i++) {
|
for (Index i = 0; i < output.color.size().x; i++) {
|
||||||
for (auto j = 0; j < output.color.size().y; j++) {
|
for (Index j = 0; j < output.color.size().y; j++) {
|
||||||
auto tmp = output.color.get({ i, j });
|
auto tmp = output.color.get({ i, j });
|
||||||
printf(
|
printf(
|
||||||
"TEST(compareCols(output.get({%i, %i}), RGBA{ %ff, %ff, %ff, %ff }));\n", i, j, tmp.r, tmp.g, tmp.b, tmp.a
|
"TEST(compareCols(output.get({%i, %i}), RGBA{ %ff, %ff, %ff, %ff }));\n", i, j, tmp.r, tmp.g, tmp.b, tmp.a
|
||||||
|
|
@ -114,16 +114,5 @@ SUITE(RayTracer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
tp::ModuleManifest* ModuleDependencies[] = { &tp::gModuleRayTracer, nullptr };
|
return UnitTest::RunAllTests();
|
||||||
tp::ModuleManifest TestModule("TokenizerTest", nullptr, nullptr, ModuleDependencies);
|
|
||||||
|
|
||||||
if (!TestModule.initialize()) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool res = UnitTest::RunAllTests();
|
|
||||||
|
|
||||||
TestModule.deinitialize();
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,6 @@ target_link_libraries(${PROJECT_NAME} PUBLIC Allocators Containers)
|
||||||
### -------------------------- Tests -------------------------- ###
|
### -------------------------- Tests -------------------------- ###
|
||||||
enable_testing()
|
enable_testing()
|
||||||
file(GLOB TEST_SOURCES "./tests/*.cpp")
|
file(GLOB TEST_SOURCES "./tests/*.cpp")
|
||||||
add_executable(${PROJECT_NAME}Tests ${TEST_SOURCES})
|
add_executable(Test${PROJECT_NAME} ${TEST_SOURCES})
|
||||||
target_link_libraries(${PROJECT_NAME}Tests ${PROJECT_NAME} UnitTest++)
|
target_link_libraries(Test${PROJECT_NAME} ${PROJECT_NAME} UnitTest++)
|
||||||
add_test(NAME ${PROJECT_NAME}Tests COMMAND ${PROJECT_NAME}Tests)
|
add_test(NAME Test${PROJECT_NAME} COMMAND Test${PROJECT_NAME})
|
||||||
|
|
@ -12,6 +12,6 @@ bool initialize(const ModuleManifest*) {
|
||||||
|
|
||||||
void deinitialize(const ModuleManifest*) { Logger::deinitializeGlobal(); }
|
void deinitialize(const ModuleManifest*) { Logger::deinitializeGlobal(); }
|
||||||
|
|
||||||
static tp::ModuleManifest* sModuleDependencies[] = { &tp::gModuleContainers, &tp::gModuleAllocators, nullptr };
|
static tp::ModuleManifest* sModuleDependencies[] = { &tp::gModuleAllocators, nullptr };
|
||||||
|
|
||||||
ModuleManifest tp::gModuleStrings = ModuleManifest("Strings", initialize, deinitialize, sModuleDependencies);
|
ModuleManifest tp::gModuleStrings = ModuleManifest("Strings", initialize, deinitialize, sModuleDependencies);
|
||||||
|
|
@ -229,7 +229,7 @@ SUITE(Strings) {
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
tp::ModuleManifest* deps[] = { &tp::gModuleStrings, &tp::gModuleUtils, nullptr };
|
tp::ModuleManifest* deps[] = { &tp::gModuleStrings, nullptr };
|
||||||
tp::ModuleManifest testModule("StringsTest", nullptr, nullptr, deps);
|
tp::ModuleManifest testModule("StringsTest", nullptr, nullptr, deps);
|
||||||
|
|
||||||
if (!testModule.initialize()) {
|
if (!testModule.initialize()) {
|
||||||
|
|
|
||||||
|
|
@ -11,15 +11,13 @@ target_link_libraries(${PROJECT_NAME} PUBLIC Math Strings)
|
||||||
### -------------------------- Tests -------------------------- ###
|
### -------------------------- Tests -------------------------- ###
|
||||||
enable_testing()
|
enable_testing()
|
||||||
file(GLOB TEST_SOURCES "./tests/*.cpp")
|
file(GLOB TEST_SOURCES "./tests/*.cpp")
|
||||||
add_executable(${PROJECT_NAME}Tests ${TEST_SOURCES})
|
add_executable(Test${PROJECT_NAME} ${TEST_SOURCES})
|
||||||
target_link_libraries(${PROJECT_NAME}Tests ${PROJECT_NAME} UnitTest++)
|
target_link_libraries(Test${PROJECT_NAME} ${PROJECT_NAME} UnitTest++)
|
||||||
add_test(NAME ${PROJECT_NAME}Tests COMMAND ${PROJECT_NAME}Tests)
|
add_test(NAME Test${PROJECT_NAME} COMMAND Test${PROJECT_NAME})
|
||||||
|
|
||||||
### -------------------------- Applications -------------------------- ###
|
### -------------------------- Applications -------------------------- ###
|
||||||
|
|
||||||
add_executable(ExampleGui examples/Entry.cpp)
|
add_executable(ExampleGui examples/Entry.cpp)
|
||||||
|
|
||||||
target_link_libraries(ExampleGui ${PROJECT_NAME} Graphics Imgui Nanovg glfw ${GLEW_LIB})
|
target_link_libraries(ExampleGui ${PROJECT_NAME} Graphics Imgui Nanovg glfw ${GLEW_LIB})
|
||||||
target_include_directories(ExampleGui PUBLIC ../Externals/glfw/include ${GLEW_INCLUDE_DIR})
|
target_include_directories(ExampleGui PUBLIC ../Externals/glfw/include ${GLEW_INCLUDE_DIR})
|
||||||
|
|
||||||
file(COPY "examples/Font.ttf" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/")
|
file(COPY "examples/Font.ttf" DESTINATION "${CMAKE_BINARY_DIR}/${PROJECT_NAME}/")
|
||||||
|
|
@ -4,6 +4,6 @@
|
||||||
namespace tp {
|
namespace tp {
|
||||||
GlobalGUIConfig* gGlobalGUIConfig = nullptr;
|
GlobalGUIConfig* gGlobalGUIConfig = nullptr;
|
||||||
|
|
||||||
ModuleManifest* deps[] = { &gModuleMath, &gModuleStrings, nullptr };
|
ModuleManifest* deps[] = { &gModuleStrings, nullptr };
|
||||||
ModuleManifest gModuleWidgets = ModuleManifest("Widgets", nullptr, nullptr, deps);
|
ModuleManifest gModuleWidgets = ModuleManifest("Widgets", nullptr, nullptr, deps);
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue