Skip to content

Commit 05eb55e

Browse files
committed
open source release
1 parent cb6bb9a commit 05eb55e

File tree

235 files changed

+90535
-4598
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+90535
-4598
lines changed

.clang-format

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BasedOnStyle: Google
2+
ColumnLimit: 120
3+
IndentWidth: 4
4+
AlignAfterOpenBracket: Align
5+
BreakBeforeBraces: Custom
6+
BraceWrapping:
7+
AfterUnion: true
8+
AfterEnum: true
9+
AfterStruct: true
10+
SplitEmptyFunction: true
11+
AfterNamespace: true
12+
AfterClass: true
13+
AfterFunction: true
14+
AfterControlStatement: true
15+
AllowShortIfStatementsOnASingleLine: false
16+
IndentCaseLabels: false
17+
DerivePointerAlignment: false
18+
PointerAlignment: Left
19+
AlignTrailingComments: true
20+
AllowShortBlocksOnASingleLine: false
21+
AlignConsecutiveDeclarations: true
22+
AlignConsecutiveAssignments: true
23+
AllowAllParametersOfDeclarationOnNextLine: false
24+
BinPackArguments: false
25+
BinPackParameters: false
26+
AccessModifierOffset: -4
27+
TabWidth: 4
28+
UseTab: Never

.gitignore

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,11 @@
1-
*.vcxproj
2-
*.filters
3-
*.obj
4-
*.tlog
5-
*.pdb
6-
*.lib
7-
*.exp
8-
*.ilk
9-
*.log
10-
*.suo
11-
*.cache
12-
*.idb
13-
*.user
14-
*.dll
15-
*.exe
16-
*.opendb
17-
*.db
18-
*.sln
19-
*.d
20-
*.o
21-
*.a
22-
*.so
1+
build/
2+
*.json
3+
*.xcworkspacedata
4+
*.plist
5+
*.xcuserstate
6+
*.xcuserstate
7+
core/.DS_Store
8+
*.json
9+
resources/
10+
src/core/src/vlk/kernels/*.comp.*
11+
src/core/src/vlk/compiled*spv.h

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "third_party/gtest"]
2+
path = third_party/gtest
3+
url = https://github.com/google/googletest.git

CI_WORKFLOW.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# RadeonRays
2+
3+
https://github.com/Radeon-Pro/RadeonRays
4+
5+
## Build
6+
7+
### Requirements
8+
9+
* Cmake 3.12+
10+
* VS 2019
11+
* Windows 10 + latest updates
12+
* MacOS 10.15 (10.14 - build ok)
13+
* Ubuntu latest LTS (18.04)
14+
15+
### Dependencies
16+
17+
* Ubuntu
18+
* fmt
19+
20+
```bash
21+
$ sudo apt install libfmt-dev
22+
```
23+
24+
* spdlog
25+
https://github.com/gabime/spdlog
26+
27+
```bash
28+
$ git clone https://github.com/gabime/spdlog.git
29+
$ cd spdlog && mkdir build && cd build
30+
$ cmake .. && make -j
31+
$ sudo make install
32+
```
33+
34+
* macOS
35+
36+
```bash
37+
brew install fmt
38+
brew install spdlog
39+
```
40+
41+
* Windows
42+
43+
1. Install with `vcpkg` and use `CMAKE_PREFIX_PATH` for build
44+
2. Install form sources
45+
46+
```cmd
47+
git clone https://github.com/gabime/spdlog.git
48+
mkdir build
49+
cd build
50+
cmake ..
51+
cmake --build . --config Release --target INSTALL
52+
```
53+
54+
```cmd
55+
git clone https://github.com/fmtlib/fmt.git
56+
mkdir build
57+
cd build
58+
cmake ..
59+
cmake --build . --config Release --target INSTALL
60+
```
61+
### Build options
62+
63+
```
64+
EMBEDDED_KERNELS=ON
65+
ENABLE_TESTING=ON
66+
CMAKE_BUILD_TYPE=Release
67+
```
68+
69+
* Windows
70+
71+
```cmake
72+
ENABLE_DX12=ON
73+
ENABLE_VULKAN=ON
74+
```
75+
76+
* Lunix
77+
78+
```cmake
79+
ENABLE_VULKAN=ON
80+
CMAKE_CXX_FLAGS="-std=gnu++17"
81+
```
82+
83+
* OSX
84+
85+
```cmake
86+
CMAKE_CXX_FLAGS="-std=c++17"
87+
CMAKE_MACOSX_RPATH=ON
88+
```
89+
90+
## Tests
91+
92+
> :warning: Windows required beta driver with ray-traicing support
93+
94+
[resources](resources) dir is required for tests
95+
96+
### GPUs
97+
98+
* vega56/64
99+
* navi (5700/5700XT)
100+
* nvidia 1080/2070/2080

CMakeLists.txt

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
cmake_minimum_required(VERSION 3.12)
2+
3+
project(radeonrays CXX)
4+
include(cmake/StandardProjectSettings.cmake)
5+
6+
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
7+
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
8+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
9+
10+
# Link this 'library' to set the c++ standard / compile-time options requested
11+
add_library(project_options INTERFACE)
12+
target_compile_features(project_options INTERFACE cxx_std_17)
13+
14+
# Link this 'library' to use the warnings specified in CompilerWarnings.cmake
15+
add_library(project_warnings INTERFACE)
16+
17+
# sanitizer options if supported by compiler
18+
include(cmake/Sanitizers.cmake)
19+
enable_sanitizers(project_options)
20+
21+
# enable doxygen
22+
include(cmake/Doxygen.cmake)
23+
enable_doxygen()
24+
25+
# allow for static analysis options
26+
include(cmake/StaticAnalyzers.cmake)
27+
28+
option(BUILD_SHARED_LIBS "Enable compilation of shared libraries" ON)
29+
option(ENABLE_TESTING "Enable Test Builds" ON)
30+
option(ENABLE_DX12 "Enable DX12 backend" OFF)
31+
option(ENABLE_VULKAN "Enable Vulkan backend" OFF)
32+
option(EMBEDDED_KERNELS "Enable embedding kernels/shaders into library" OFF)
33+
34+
# Very basic PCH example
35+
option(ENABLE_PCH "Enable Precompiled Headers" OFF)
36+
if (ENABLE_PCH)
37+
# This sets a global PCH parameter, each project will build its own PCH, which
38+
# is a good idea if any #define's change
39+
#
40+
#
41+
target_precompile_headers(project_options INTERFACE <vector> <string> <map> <utility>)
42+
endif()
43+
44+
if(ENABLE_VULKAN)
45+
include(cmake/KernelUtils.cmake)
46+
endif(ENABLE_VULKAN)
47+
48+
if(ENABLE_TESTING)
49+
enable_testing()
50+
set(gtest_force_shared_crt ON CACHE BOOL "Use /MD and /MDd" FORCE)
51+
add_subdirectory(third_party/gtest)
52+
53+
set(THIRD_PARTY_TARGETS
54+
gtest
55+
gtest_main
56+
gmock
57+
gmock_main)
58+
59+
foreach(TGT ${THIRD_PARTY_TARGETS})
60+
set_property(TARGET ${TGT} PROPERTY FOLDER "third_party")
61+
endforeach()
62+
63+
add_subdirectory(test)
64+
endif(ENABLE_TESTING)
65+
66+
if(ENABLE_FUZZING)
67+
message(
68+
"Building Fuzz Tests, using fuzzing sanitizer https://www.llvm.org/docs/LibFuzzer.html"
69+
)
70+
add_subdirectory(fuzz_test)
71+
endif(ENABLE_FUZZING)
72+
73+
add_subdirectory(src)
74+
add_subdirectory(bvh_analyzer)

README.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
# RadeonRays 4.0
2-
3-
## Important
4-
5-
RadeonRays 2.0 SDK (OpenCL) has been moved to 'legacy-2.0' branch.
1+
# RadeonRays 4.1
62

73
## Summary
84

9-
RadeonRays is a ray intersection acceleration library for heterogeneous hardware and software systems. AMD developed RadeonRays to help developers make the most of GPU, APUs and CPUs, and to eliminate the need to maintain hardware-dependent code.
5+
RadeonRays is a ray intersection acceleration library. AMD developed RadeonRays to help developers make the most of GPU and to eliminate the need to maintain hardware-dependent code.
106

117
The library offers a well-defined C API for scene building and performing asynchronous ray intersection queries.
128

@@ -16,17 +12,15 @@ RadeonRays is not limited to AMD hardware, a specific operating system or graphi
1612

1713
The library supports the following graphics and GPGPU frameworks as its backends:
1814

19-
- DirectX 12
20-
- Metal
15+
- DirectX12
2116
- Vulkan
2217

2318
## System Requirements
2419

2520
RadeonRays requires a PC with the following software and hardware:
2621

27-
- DirectX12: a 64-bit version of Windows® 10, and a GPU and drivers that supports DirectX12 features
28-
- Metal: a 64-bit version of MacOS® X 10.15 or later, and a discrete GPU that supports the MPS acceleration structure
29-
- Vulkan: a 64-bit version of Windows® 10 or Linux, and a GPU and drivers that support Vulkan version 1.2
22+
- DirectX12: a 64-bit version of Windows&reg; 10, and a GPU and drivers that supports DirectX12 features
23+
- Vulkan: a 64-bit version of Windows&reg; 10 or Linux, and a GPU and drivers that support Vulkan version 1.2
3024

3125
## Documentation
3226

bvh_analyzer/CMakeLists.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
find_package(OpenMP)
2+
3+
file(GLOB HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
4+
file(GLOB SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
5+
6+
add_executable(bvh_analyzer ${HEADER_FILES} ${SOURCE_FILES})
7+
8+
target_link_libraries(bvh_analyzer PRIVATE project_options)
9+
if(OpenMP_CXX_FOUND)
10+
target_link_libraries(bvh_analyzer PRIVATE OpenMP::OpenMP_CXX)
11+
endif()

bvh_analyzer/aabb.h

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/**********************************************************************
2+
Copyright (c) 2020 Advanced Micro Devices, Inc. All rights reserved.
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
The above copyright notice and this permission notice shall be included in
10+
all copies or substantial portions of the Software.
11+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
17+
THE SOFTWARE.
18+
********************************************************************/
19+
#pragma once
20+
#include <cfloat>
21+
#include <ostream>
22+
23+
#include "float2.h"
24+
#include "float3.h"
25+
26+
namespace bvh
27+
{
28+
struct Aabb
29+
{
30+
//<! Create AABB from a single point.
31+
Aabb() : pmin{FLT_MAX, FLT_MAX, FLT_MAX}, pmax{-FLT_MAX, -FLT_MAX, -FLT_MAX} {}
32+
//<! Create AABB from a single point.
33+
Aabb(const float3& p) : pmin(p), pmax(p) {}
34+
//<! Create AABB from min and max points.
35+
Aabb(const float3& mi, const float3& ma) : pmin(mi), pmax(ma) {}
36+
//<! Create AABB from another AABB.
37+
Aabb(const Aabb& rhs) : pmin(rhs.pmin), pmax(rhs.pmax) {}
38+
//<! Grow AABB to enclose itself and another AABB.
39+
Aabb& Grow(const Aabb& rhs)
40+
{
41+
pmin = vmin(pmin, rhs.pmin);
42+
pmax = vmax(pmax, rhs.pmax);
43+
return *this;
44+
}
45+
//<! Grow AABB to enclose itself and another point.
46+
Aabb& Grow(const float3& p)
47+
{
48+
pmin = vmin(pmin, p);
49+
pmax = vmax(pmax, p);
50+
return *this;
51+
}
52+
//<! Box center.
53+
float3 Center() const { return (pmax + pmin) * 0.5; }
54+
55+
//<! Box extens along each axe.
56+
float3 Extents() const { return pmax - pmin; }
57+
//<! Calculate AABB union.
58+
static Aabb Union(const Aabb& rhs, const Aabb& lhs)
59+
{
60+
Aabb result(vmin(lhs.pmin, rhs.pmin), vmax(lhs.pmax, rhs.pmax));
61+
return result;
62+
}
63+
64+
//<! Box extens along each axe.
65+
float Area() const
66+
{
67+
float3 ext = Extents();
68+
return 2 * (ext.x * ext.y + ext.x * ext.z + ext.y * ext.z);
69+
}
70+
71+
//<! Calculate AABB vs ray intersection distances.
72+
float2 Intersect(const float3& invD, const float3& oxInvD, float minT, float maxT) const
73+
{
74+
float3 f = fma(pmax, invD, oxInvD);
75+
float3 n = fma(pmin, invD, oxInvD);
76+
float3 tmax = vmax(f, n);
77+
float3 tmin = vmin(f, n);
78+
float t1 = fminf(fminf(fminf(tmax.x, tmax.y), tmax.z), maxT);
79+
float t0 = fmaxf(fmaxf(fmaxf(tmin.x, tmin.y), tmin.z), minT);
80+
return float2{t0, t1};
81+
}
82+
83+
bool Includes(Aabb const& rhs) const
84+
{
85+
float3 min_diff = rhs.pmin - pmin;
86+
float3 max_diff = pmax - rhs.pmax;
87+
return !(min_diff.x < -1e-8f || min_diff.y < -1e-8f || min_diff.z < -1e-8f || max_diff.x < -1e-8f ||
88+
max_diff.y < -1e-8f || max_diff.z < -1e-8f);
89+
}
90+
91+
//<! Min point of AABB.
92+
float3 pmin;
93+
//<! Max point of AABB.
94+
float3 pmax;
95+
};
96+
97+
inline std::ostream& operator<<(std::ostream& oss, const Aabb& aabb)
98+
{
99+
oss << "{ min: [" << aabb.pmin.x << ", " << aabb.pmin.y << ", " << aabb.pmin.z << "], ";
100+
oss << " max: [" << aabb.pmax.x << ", " << aabb.pmax.y << ", " << aabb.pmax.z << "] }";
101+
return oss;
102+
}
103+
} // namespace bvh

0 commit comments

Comments
 (0)