Skip to content

Commit

Permalink
alpha of vulkan backend for Radeon Rays, some tidy up to come (build …
Browse files Browse the repository at this point in the history
…system in particular), also new unittests and sample
  • Loading branch information
DeanoC committed Jul 29, 2016
1 parent 9c9edc3 commit 9cb51b1
Show file tree
Hide file tree
Showing 15 changed files with 157 additions and 25 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "Anvil"]
path = Anvil
url = https://github.com/GPUOpen-LibrariesAndSDKs/Anvil.git
1 change: 1 addition & 0 deletions Anvil
Submodule Anvil added at 84d228
64 changes: 64 additions & 0 deletions Anvil_premake/anvil.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
project "Anvil"
location "../Anvil"
kind "StaticLib"
local vulkanPath = ""

if _OPTIONS["use_vulkan"] then
local vulkanSDKPath = os.getenv( "VK_SDK_PATH" );
if vulkanSDKPath ~= nil then
vulkanPath = os.getenv( "VK_SDK_PATH" ) .. "/Include"
end
end

includedirs { "../Anvil",
"../Anvil/deps",
"../Anvil/include",
".",
vulkanPath }

if os.is("macosx") then
buildoptions "-std=c++11 -stdlib=libc++ -fpermissive"
glslang_os_files = "../Anvil/deps/glslang/glslang/OSDependent/Unix/*.*"
elseif os.is("linux") then
buildoptions "-std=c++11 -fPIC -fpermissive"
glslang_os_files = "../Anvil/deps/glslang/glslang/OSDependent/Unix/*.*"
elseif os.is("window") then
glslang_os_files = "../Anvil/deps/glslang/glslang/OSDependent/Windows/*.*"
end

files { "./config.h",
"../Anvil/include/misc/*.*",
"../Anvil/include/wrappers/*.*",
"../Anvil/src/misc/*.h",
"../Anvil/src/wrappers/*.*",
"../Anvil/deps/glslang/OGLCompilersDLL/*.*",
"../Anvil/deps/glslang/hlsl/*.*",
"../Anvil/deps/glslang/glslang/MachineIndependent/preprocessor/*.*",
"../Anvil/deps/glslang/glslang/MachineIndependent/*.*",
"../Anvil/deps/glslang/glslang/GenericCodeGen/*.*",
"../Anvil/deps/glslang/SPIRV/*.*",
glslang_os_files,
}
if os.is("linux") then
excludes {"../Anvil/include/misc/window_win3264.h" }
elseif os.is("window") then
excludes {
"../Anvil/include/misc/window_xcb.h",
"../Anvil/include/misc/xcb_loader_for_anvil.h",
"../Anvil/src/misc/window_xcb.cpp",
"../Anvil/src/misc/xcb_loader_for_anvil.cpp"
}
end

defines {"ANVIL_LINK_WITH_GLSLANG" }


configuration {"x32", "Debug"}
targetdir "../Bin/Debug/x86"
configuration {"x64", "Debug"}
targetdir "../Bin/Debug/x64"
configuration {"x32", "Release"}
targetdir "../Bin/Release/x86"
configuration {"x64", "Release"}
targetdir "../Bin/Release/x64"
configuration {}
2 changes: 2 additions & 0 deletions Anvil_premake/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* Defined if glslangvalidator is statically linked with Anvil */
#define ANVIL_LINK_WITH_GLSLANG 1
12 changes: 9 additions & 3 deletions Calc/src/calc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,32 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
********************************************************************/
#include "calc.h"
#if USE_OPENCL
#include "calc_clw.h"
#endif
#if USE_VULKAN
#include "calc_vk.h"
#include "calc_vkw.h"
#endif

namespace Calc
{
// Create corresponding calc
Calc* CreateCalc( Platform inPlatform, int reserved )
{
#if USE_OPENCL
if ( inPlatform & Platform::kOpenCL )
{
return new CalcClw();
}
#if defined(USE_VULKAN)
else if ( inPlatform & Platform::kVulkan )
else
#elif USE_VULKAN
if ( inPlatform & Platform::kVulkan )
{
return new CalcVulkanw();
}
#endif // USE_VULKAN
else
#endif // USE_VULKAN
{
return nullptr;
}
Expand Down
6 changes: 5 additions & 1 deletion Calc/src/calc_clw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
********************************************************************/

#if USE_OPENCL
#include "calc_clw.h"
#include "device_clw.h"
#include "except_clw.h"
Expand Down Expand Up @@ -127,4 +129,6 @@ namespace Calc
delete device;
}

}
}

#endif //use_opencl
5 changes: 4 additions & 1 deletion Calc/src/device_clw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
********************************************************************/
#if USE_OPENCL
#include "calc.h"
#include "primitives.h"
#include "device_clw.h"
Expand Down Expand Up @@ -558,4 +559,6 @@ namespace Calc
{
delete prims;
}
}
}

#endif
4 changes: 3 additions & 1 deletion RadeonRays/src/intersection/radeon_rays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ namespace RadeonRays
{
// if CL allowed see if we have any devices if not
// try Vulkan if allowed, if neither try embree if allowed
#if USE_OPENCL
if( s_calc_platform & DeviceInfo::Platform::kOpenCL )
{
auto* calc = GetCalcOpenCL();
if (calc != nullptr) { return calc; }
}
#ifdef USE_VULKAN
#endif
#if USE_VULKAN
if ( s_calc_platform & DeviceInfo::Platform::kVulkan )
{
auto* calc = GetCalcVulkan();
Expand Down
6 changes: 3 additions & 3 deletions RadeonRays/src/intersection/radeon_rays_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ THE SOFTWARE.
#include "../primitive/mesh.h"
#include "../primitive/instance.h"
#include "../except/except.h"

#ifdef USE_OPENCL
#include "../device/intersection_device.h"

#if USE_OPENCL
#include "../device/calc_intersection_device_cl.h"
#endif

#ifdef USE_VULKAN
#if USE_VULKAN
#include "../device/calc_intersection_device_vk.h"
#include <wrappers/buffer.h>
#endif
Expand Down
27 changes: 25 additions & 2 deletions UnitTest/UnitTest.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
project "UnitTest"
location "../UnitTest"
kind "ConsoleApp"
includedirs { "../RadeonRays/include", "../Gtest/include", "../CLW", "../Calc/inc", "." }
links {"Gtest", "RadeonRays", "CLW", "Calc"}
includedirs { "../RadeonRays/include", "../Gtest/include", "../Calc/inc", "." }
links {"Gtest", "RadeonRays", "Calc"}
files { "**.cpp", "**.h" }

if os.is("macosx") then
Expand All @@ -17,6 +17,29 @@ project "UnitTest"
defines{ "GTEST_HAS_TR1_TUPLE=0" }
end

if _OPTIONS["use_opencl"] then
includedirs { "../CLW" }
links {"CLW"}
end

if _OPTIONS["use_vulkan"] then
local vulkanSDKPath = os.getenv( "VK_SDK_PATH" );
if vulkanSDKPath ~= nil then
configuration {"x32"}
libdirs { vulkanSDKPath .. "/Bin32" }
configuration {"x64"}
libdirs { vulkanSDKPath .. "/Bin" }
configuration {}
end
if os.is("macosx") then
--no Vulkan on macOs need to error out TODO
elseif os.is("linux") then
links {"Anvil", "vulkan"}
elseif os.is("windows") then
links {"Anvil", "vulkan-1"}
end
end

configuration {"x32", "Debug"}
targetdir "../Bin/Debug/x86"
configuration {"x64", "Debug"}
Expand Down
1 change: 1 addition & 0 deletions UnitTest/calc_test_cl.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class CalcTest : public ::testing::Test
virtual void SetUp()
{
m_calc = Calc::CreateCalc(Calc::kOpenCL, 0);
ASSERT_TRUE(m_calc != nullptr);
}

virtual void TearDown()
Expand Down
3 changes: 3 additions & 0 deletions UnitTest/clw_cl_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ THE SOFTWARE.
#ifndef CLW_CL_TEST_H
#define CLW_CL_TEST_H


#if USE_OPENCL
/// This test suite is testing CLW library interop with pure OpenCL
///

Expand Down Expand Up @@ -140,5 +142,6 @@ TEST_F(CLWCL, BufferWrite)
ASSERT_EQ(mismatch.first, initdata.cend());
}

#endif // use opengl

#endif // CLW_CL_TEST
4 changes: 4 additions & 0 deletions UnitTest/clw_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ THE SOFTWARE.
#ifndef CLW_TEST_H
#define CLW_TEST_H

#if USE_OPENCL
/// This test suite is testing CLW library functionality
///

Expand All @@ -32,6 +33,7 @@ THE SOFTWARE.
#include <ctime>

#include "gtest/gtest.h"

#include "CLW.h"

// Api creation fixture, prepares api_ for further tests
Expand Down Expand Up @@ -362,3 +364,5 @@ TEST_F(CLW, RadixSortLarge)
}

#endif

#endif //USE_OPENCL
41 changes: 28 additions & 13 deletions UnitTest/radeon_rays_conformance_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class ApiConformance : public ::testing::Test
public:
virtual void SetUp()
{
apicpu_ = nullptr;
apigpu_ = nullptr;

//Search for native CPU
int cpuidx = -1;
int gpuidx = -1;
Expand All @@ -65,7 +68,10 @@ class ApiConformance : public ::testing::Test
apicpu_ = IntersectionApi::Create(cpuidx);
apigpu_ = IntersectionApi::Create(gpuidx);

// Load obj file
ASSERT_TRUE(apicpu_ != nullptr);
ASSERT_TRUE(apigpu_ != nullptr);

// Load obj file
std::string res = LoadObj(shapes_, materials_, "../Resources/CornellBox/orig.objm");

// Create meshes within IntersectionApi
Expand Down Expand Up @@ -94,19 +100,28 @@ class ApiConformance : public ::testing::Test

virtual void TearDown()
{
// Commit update
ASSERT_NO_THROW(apicpu_->Commit());
ASSERT_NO_THROW(apigpu_->Commit());

// Delete meshes
for (int i=0; i<(int)apishapes_cpu_.size(); ++i)
{
ASSERT_NO_THROW(apicpu_->DeleteShape(apishapes_cpu_[i]));
ASSERT_NO_THROW(apigpu_->DeleteShape(apishapes_gpu_[i]));
}
if(apicpu_ != nullptr )
{
// Commit update
ASSERT_NO_THROW(apicpu_->Commit());
for (int i = 0; i < (int)apishapes_cpu_.size(); ++i)
{
ASSERT_NO_THROW(apicpu_->DeleteShape(apishapes_cpu_[i]));
}
IntersectionApi::Delete(apicpu_);
}

if(apigpu_ != nullptr)
{
ASSERT_NO_THROW(apigpu_->Commit());
// Delete meshes
for (int i = 0; i<(int)apishapes_gpu_.size(); ++i)
{
ASSERT_NO_THROW(apigpu_->DeleteShape(apishapes_gpu_[i]));
}
IntersectionApi::Delete(apigpu_);

IntersectionApi::Delete(apicpu_);
IntersectionApi::Delete(apigpu_);
}
}

void Wait(IntersectionApi* api)
Expand Down
3 changes: 2 additions & 1 deletion UnitTest/radeon_rays_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class Api : public ::testing::Test
public:
virtual void SetUp()
{
api_ = nullptr;
int nativeidx = -1;
for (int idx=0; idx < IntersectionApi::GetDeviceCount(); ++idx)
{
Expand All @@ -57,7 +58,7 @@ class Api : public ::testing::Test

virtual void TearDown()
{
IntersectionApi::Delete(api_);
if(api_ != nullptr) IntersectionApi::Delete(api_);
}

void Wait()
Expand Down

0 comments on commit 9cb51b1

Please sign in to comment.