summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-03-15 12:59:58 -0700
committerGitHub <noreply@github.com>2021-03-15 12:59:58 -0700
commit10b39e0cb545f98f1a417da8e8e52258134a3e87 (patch)
treef57192ca5b79365a40e02d64879591ed70c9975a /tools
parente428f6e6cb868e7ca487dba09f3ca5530fd85ca6 (diff)
Enable `gfx::CUDADevice` on linux. (#1756)
Diffstat (limited to 'tools')
-rw-r--r--tools/gfx/cuda/render-cuda.cpp41
-rw-r--r--tools/gfx/render.cpp14
-rw-r--r--tools/render-test/bind-location.h8
-rw-r--r--tools/render-test/cuda/cuda-compute-util.cpp8
-rw-r--r--tools/render-test/cuda/cuda-compute-util.h2
-rw-r--r--tools/render-test/shader-input-layout.h6
6 files changed, 41 insertions, 38 deletions
diff --git a/tools/gfx/cuda/render-cuda.cpp b/tools/gfx/cuda/render-cuda.cpp
index 89aaa33aa..3e94f5571 100644
--- a/tools/gfx/cuda/render-cuda.cpp
+++ b/tools/gfx/cuda/render-cuda.cpp
@@ -1,20 +1,19 @@
#include "render-cuda.h"
-#include "slang.h"
-#include "slang-com-ptr.h"
-#include "slang-com-helper.h"
+
+#ifdef GFX_ENABLE_CUDA
+#include <cuda.h>
+#include <cuda_runtime_api.h>
#include "core/slang-basic.h"
#include "core/slang-blob.h"
+#include "core/slang-std-writers.h"
+#include "slang.h"
+#include "slang-com-ptr.h"
+#include "slang-com-helper.h"
#include "../command-writer.h"
#include "../renderer-shared.h"
#include "../render-graphics-common.h"
#include "../slang-context.h"
-
-#ifdef GFX_ENABLE_CUDA
-#include <cuda.h>
-#include <cuda_runtime_api.h>
-#include "core/slang-std-writers.h"
-
#endif
namespace gfx
@@ -466,7 +465,7 @@ public:
return SLANG_OK;
}
virtual SLANG_NO_THROW Result SLANG_MCALL
- setData(ShaderOffset const& offset, void const* data, size_t size)
+ setData(ShaderOffset const& offset, void const* data, size_t size) override
{
size = Math::Min(size, bufferResource->getDesc()->sizeInBytes - offset.uniformOffset);
SLANG_CUDA_RETURN_ON_FAIL(cudaMemcpy(
@@ -488,7 +487,7 @@ public:
return SLANG_OK;
}
virtual SLANG_NO_THROW Result SLANG_MCALL
- getObject(ShaderOffset const& offset, IShaderObject** object)
+ getObject(ShaderOffset const& offset, IShaderObject** object) override
{
auto subObjectIndex =
getLayout()->m_bindingRanges[offset.bindingRangeIndex].baseIndex + offset.bindingArrayIndex;
@@ -507,7 +506,7 @@ public:
return SLANG_OK;
}
virtual SLANG_NO_THROW Result SLANG_MCALL
- setObject(ShaderOffset const& offset, IShaderObject* object)
+ setObject(ShaderOffset const& offset, IShaderObject* object) override
{
auto layout = getLayout();
@@ -625,7 +624,7 @@ public:
return SLANG_OK;
}
virtual SLANG_NO_THROW Result SLANG_MCALL
- setResource(ShaderOffset const& offset, IResourceView* resourceView)
+ setResource(ShaderOffset const& offset, IResourceView* resourceView) override
{
auto layout = getLayout();
@@ -669,14 +668,14 @@ public:
return SLANG_OK;
}
virtual SLANG_NO_THROW Result SLANG_MCALL
- setSampler(ShaderOffset const& offset, ISamplerState* sampler)
+ setSampler(ShaderOffset const& offset, ISamplerState* sampler) override
{
SLANG_UNUSED(sampler);
SLANG_UNUSED(offset);
return SLANG_OK;
}
virtual SLANG_NO_THROW Result SLANG_MCALL setCombinedTextureSampler(
- ShaderOffset const& offset, IResourceView* textureView, ISamplerState* sampler)
+ ShaderOffset const& offset, IResourceView* textureView, ISamplerState* sampler) override
{
SLANG_UNUSED(sampler);
setResource(offset, textureView);
@@ -758,7 +757,7 @@ public:
}
virtual SLANG_NO_THROW Result SLANG_MCALL
- setDeviceData(size_t offset, void* data, size_t size)
+ setDeviceData(size_t offset, void* data, size_t size) override
{
size = Math::Min(size, uniformBufferSize - offset);
SLANG_CUDA_RETURN_ON_FAIL(cudaMemcpy(
@@ -1004,8 +1003,8 @@ public:
*outObject = nullptr;
return SLANG_E_NO_INTERFACE;
}
- virtual SLANG_NO_THROW uint32_t SLANG_MCALL addRef() { return 1; }
- virtual SLANG_NO_THROW uint32_t SLANG_MCALL release() { return 1; }
+ virtual SLANG_NO_THROW uint32_t SLANG_MCALL addRef() override { return 1; }
+ virtual SLANG_NO_THROW uint32_t SLANG_MCALL release() override { return 1; }
public:
CommandWriter* m_writer;
@@ -1064,8 +1063,8 @@ public:
*outObject = nullptr;
return SLANG_E_NO_INTERFACE;
}
- virtual SLANG_NO_THROW uint32_t SLANG_MCALL addRef() { return 1; }
- virtual SLANG_NO_THROW uint32_t SLANG_MCALL release() { return 1; }
+ virtual SLANG_NO_THROW uint32_t SLANG_MCALL addRef() override { return 1; }
+ virtual SLANG_NO_THROW uint32_t SLANG_MCALL release() override { return 1; }
public:
CommandWriter* m_writer;
@@ -1087,7 +1086,7 @@ public:
}
virtual SLANG_NO_THROW void SLANG_MCALL
- uploadBufferData(IBufferResource* dst, size_t offset, size_t size, void* data)
+ uploadBufferData(IBufferResource* dst, size_t offset, size_t size, void* data) override
{
m_writer->uploadBufferData(dst, offset, size, data);
}
diff --git a/tools/gfx/render.cpp b/tools/gfx/render.cpp
index e7d30b728..183afaffd 100644
--- a/tools/gfx/render.cpp
+++ b/tools/gfx/render.cpp
@@ -92,11 +92,15 @@ extern "C"
}
break;
#elif SLANG_LINUX_FAMILY
- case DeviceType::Default:
- case DeviceType::Vulkan:
- {
- return createVKDevice(desc, outDevice);
- }
+ case DeviceType::Default:
+ case DeviceType::Vulkan:
+ {
+ return createVKDevice(desc, outDevice);
+ }
+ case DeviceType::CUDA:
+ {
+ return createCUDADevice(desc, outDevice);
+ }
#endif
case DeviceType::CPU:
{
diff --git a/tools/render-test/bind-location.h b/tools/render-test/bind-location.h
index cfa88cce0..33670bf4b 100644
--- a/tools/render-test/bind-location.h
+++ b/tools/render-test/bind-location.h
@@ -1,10 +1,10 @@
#ifndef BIND_LOCATION_H
#define BIND_LOCATION_H
-#include "core/slang-basic.h"
-#include "core/slang-free-list.h"
-#include "core/slang-memory-arena.h"
-#include "core/slang-writer.h"
+#include "source/core/slang-basic.h"
+#include "source/core/slang-free-list.h"
+#include "source/core/slang-memory-arena.h"
+#include "source/core/slang-writer.h"
#include "slang.h"
diff --git a/tools/render-test/cuda/cuda-compute-util.cpp b/tools/render-test/cuda/cuda-compute-util.cpp
index ea7dab163..bd77919a2 100644
--- a/tools/render-test/cuda/cuda-compute-util.cpp
+++ b/tools/render-test/cuda/cuda-compute-util.cpp
@@ -1,11 +1,11 @@
#include "cuda-compute-util.h"
-#include "../../slang-com-helper.h"
+#include "slang-com-helper.h"
-#include "../../source/core/slang-std-writers.h"
-#include "../../source/core/slang-token-reader.h"
-#include "../../source/core/slang-semantic-version.h"
+#include "source/core/slang-std-writers.h"
+#include "source/core/slang-token-reader.h"
+#include "source/core/slang-semantic-version.h"
#include "../bind-location.h"
diff --git a/tools/render-test/cuda/cuda-compute-util.h b/tools/render-test/cuda/cuda-compute-util.h
index ac0c6bba3..9c6c8b9b4 100644
--- a/tools/render-test/cuda/cuda-compute-util.h
+++ b/tools/render-test/cuda/cuda-compute-util.h
@@ -4,7 +4,7 @@
#include "../slang-support.h"
#include "../options.h"
-#include "../../source/core/slang-smart-pointer.h"
+#include "source/core/slang-smart-pointer.h"
namespace renderer_test {
diff --git a/tools/render-test/shader-input-layout.h b/tools/render-test/shader-input-layout.h
index 2c8dbe821..253f065f6 100644
--- a/tools/render-test/shader-input-layout.h
+++ b/tools/render-test/shader-input-layout.h
@@ -1,10 +1,10 @@
#ifndef SLANG_TEST_SHADER_INPUT_LAYOUT_H
#define SLANG_TEST_SHADER_INPUT_LAYOUT_H
-#include "core/slang-basic.h"
-#include "core/slang-random-generator.h"
+#include "source/core/slang-basic.h"
+#include "source/core/slang-random-generator.h"
-#include "core/slang-writer.h"
+#include "source/core/slang-writer.h"
#include "bind-location.h"