-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
custom iterator for SOA, sortable SOA queues, and fixes (#53)
* minor fixes destroy cuda surface when swapchain is recreated fix window resize validation warn * implement morton encoding (TMP) * implement custom iterator for SoA * implement sortable work queue
- Loading branch information
Showing
13 changed files
with
259 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
[submodule "src/ext/assimp"] | ||
path = src/ext/assimp | ||
url = git@github.com:assimp/assimp.git | ||
url = https://github.com/assimp/assimp.git | ||
[submodule "src/ext/glfw"] | ||
path = src/ext/glfw | ||
url = git@github.com:glfw/glfw.git | ||
url = https://github.com/glfw/glfw.git | ||
[submodule "src/ext/pybind11"] | ||
path = src/ext/pybind11 | ||
url = git@github.com:pybind/pybind11.git | ||
url = https://github.com/pybind/pybind11.git | ||
branch = stable | ||
[submodule "src/ext/pbrtparser"] | ||
path = src/ext/pbrtparser | ||
url = git@github.com:cuteday/pbrt-parser.git | ||
url = https://github.com/cuteday/pbrt-parser.git | ||
branch = cute | ||
[submodule "src/core/math/3rdparty/eigen"] | ||
path = src/core/math/3rdparty/eigen | ||
url = git@github.com:cuteday/Eigen.git | ||
url = https://github.com/cuteday/Eigen.git | ||
[submodule "src/ext/nvrhi"] | ||
path = src/ext/nvrhi | ||
url = git@github.com:cuteday/nvrhi.git | ||
url = https://github.com/cuteday/nvrhi.git | ||
[submodule "src/ext/openvdb"] | ||
path = src/ext/openvdb | ||
url = git@github.com:cuteday/openvdb_win.git | ||
url = https://github.com/cuteday/openvdb_win.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#pragma once | ||
#include "common.h" | ||
#include <type_traits> | ||
|
||
NAMESPACE_BEGIN(krr) | ||
|
||
// specifications for SOA::GetSetIndirector | ||
template <typename T> | ||
class SOA { | ||
public: | ||
struct GetSetIndirector { | ||
GetSetIndirector() = default; | ||
KRR_CALLABLE operator T() const; | ||
KRR_CALLABLE void operator=(const T &val); | ||
KRR_CALLABLE void operator=(const GetSetIndirector &other); | ||
SOA<T> *soa; int i; | ||
}; | ||
}; | ||
|
||
// https://en.cppreference.com/w/cpp/named_req/RandomAccessIterator | ||
template <typename T> | ||
class SOAIterator { | ||
public: | ||
using difference_type = int; | ||
using value_type = T; | ||
using reference = typename SOA<T>::GetSetIndirector; | ||
using pointer = void; | ||
using iterator_category = std::random_access_iterator_tag; | ||
|
||
KRR_CALLABLE SOAIterator() : m_soa(nullptr), m_index(0) {} | ||
KRR_CALLABLE SOAIterator(SOA<T> *soa, int index) : m_soa(soa), m_index(index) {} | ||
KRR_CALLABLE SOAIterator(const SOA<T> *soa, int index) : m_soa(const_cast<SOA<T>*>(soa)), m_index(index) {} | ||
|
||
KRR_CALLABLE SOAIterator& operator +=(int n) { m_index += n; return *this; } | ||
KRR_CALLABLE SOAIterator& operator -=(int n) { m_index -= n; return *this; } | ||
KRR_CALLABLE SOAIterator& operator ++() { ++m_index; return *this; } | ||
KRR_CALLABLE SOAIterator& operator --() { --m_index; return *this; } | ||
KRR_CALLABLE SOAIterator operator ++(int) { SOAIterator it = *this; ++m_index; return it; } | ||
KRR_CALLABLE SOAIterator operator --(int) { SOAIterator it = *this; --m_index; return it; } | ||
KRR_CALLABLE SOAIterator operator+(difference_type n) const { return SOAIterator(m_soa, m_index + n); } | ||
KRR_CALLABLE SOAIterator operator-(difference_type n) const { return SOAIterator(m_soa, m_index - n); } | ||
KRR_CALLABLE difference_type operator-(const SOAIterator& it) const { return m_index - it.m_index; } | ||
KRR_CALLABLE friend SOAIterator operator+(difference_type n, const SOAIterator& it) { return it + n; } | ||
KRR_CALLABLE friend SOAIterator operator-(difference_type n, const SOAIterator &it) { return it - n; } | ||
|
||
KRR_CALLABLE bool operator==(const SOAIterator& it) const { return m_index == it.m_index; } | ||
KRR_CALLABLE bool operator!=(const SOAIterator &it) const { return m_index != it.m_index; } | ||
KRR_CALLABLE bool operator<(const SOAIterator &it) const { return m_index < it.m_index; } | ||
KRR_CALLABLE bool operator<=(const SOAIterator &it) const { return m_index <= it.m_index; } | ||
KRR_CALLABLE bool operator>(const SOAIterator &it) const { return m_index > it.m_index; } | ||
KRR_CALLABLE bool operator>=(const SOAIterator &it) const { return m_index >= it.m_index; } | ||
|
||
KRR_CALLABLE reference operator*() { return {m_soa, m_index}; } | ||
KRR_CALLABLE reference operator[](difference_type n) { return {m_soa, m_index + n}; } | ||
|
||
private: | ||
std::conditional_t<std::is_const_v<T>, const SOA<T>*, SOA<T>*> m_soa; | ||
difference_type m_index; | ||
}; | ||
|
||
NAMESPACE_END(krr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,6 @@ | |
|
||
NAMESPACE_BEGIN(krr) | ||
|
||
using namespace utils; | ||
using namespace rt; | ||
|
||
struct HitInfo { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.