Skip to content

Commit f428a05

Browse files
Draft: integrate slang-rhi (shader-slang#4970)
* add slang-rhi submodule * refactor render-test to use slang-rhi and remove OpenGL support * remove -vk -glsl tests * remove gl test * disable failing test * allow recursive submodules in github actions * update slang-rhi * update slang-rhi --------- Co-authored-by: Yong He <yonghe@outlook.com>
1 parent 12137e9 commit f428a05

31 files changed

+176
-104
lines changed

.github/workflows/benchmark.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
steps:
2626
- uses: actions/checkout@v3
2727
with:
28-
submodules: 'true'
28+
submodules: 'recursive'
2929
fetch-depth: '0'
3030
- name: Common setup
3131
uses: ./.github/actions/common-setup

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ jobs:
8484
steps:
8585
- uses: actions/checkout@v3
8686
with:
87-
submodules: 'true'
87+
submodules: 'recursive'
8888
fetch-depth: '0'
8989
- name: Setup
9090
uses: ./.github/actions/common-setup

.github/workflows/compile-regression-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
steps:
4343
- uses: actions/checkout@v3
4444
with:
45-
submodules: 'true'
45+
submodules: 'recursive'
4646
fetch-depth: '0'
4747
- name: Setup
4848
uses: ./.github/actions/common-setup

.github/workflows/falcor-compiler-perf-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
steps:
4545
- uses: actions/checkout@v3
4646
with:
47-
submodules: 'true'
47+
submodules: 'recursive'
4848
fetch-depth: '0'
4949

5050
- name: Setup

.github/workflows/falcor-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
steps:
4343
- uses: actions/checkout@v3
4444
with:
45-
submodules: 'true'
45+
submodules: 'recursive'
4646
fetch-depth: '0'
4747
- name: Setup
4848
uses: ./.github/actions/common-setup

.github/workflows/release-linux-glibc-2-17.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v3
1212
with:
13-
submodules: 'true'
13+
submodules: 'recursive'
1414
fetch-depth: '0'
1515

1616
# build the binary in docker image

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
steps:
4343
- uses: actions/checkout@v3
4444
with:
45-
submodules: 'true'
45+
submodules: 'recursive'
4646
fetch-depth: '0'
4747
- name: Setup
4848
uses: ./.github/actions/common-setup

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@
3535
[submodule "external/metal-cpp"]
3636
path = external/metal-cpp
3737
url = https://github.com/bkaradzic/metal-cpp
38+
[submodule "external/slang-rhi"]
39+
path = external/slang-rhi
40+
url = https://github.com/shader-slang/slang-rhi.git

CMakeLists.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,7 @@ if(SLANG_ENABLE_TESTS)
637637
core
638638
compiler-core
639639
slang
640-
gfx
641-
gfx-util
640+
slang-rhi
642641
platform
643642
$<$<BOOL:${SLANG_ENABLE_CUDA}>:CUDA::cuda_driver>
644643
EXTRA_COMPILE_DEFINITIONS_PRIVATE

external/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ endif()
6666
add_library(imgui INTERFACE)
6767
target_include_directories(imgui INTERFACE "${CMAKE_CURRENT_LIST_DIR}/imgui")
6868

69+
# slang-rhi
70+
set(SLANG_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
71+
set(SLANG_BINARY_DIR ${CMAKE_BINARY_DIR})
72+
set(SLANG_RHI_BUILD_TESTS OFF)
73+
add_subdirectory(slang-rhi)
74+
6975
# Tidy things up:
7076

7177
# Restore log level if we set it

external/slang-rhi

Submodule slang-rhi added at 162d0a5

source/core/slang-render-api-util.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ namespace Slang {
1313
// NOTE! Must keep in same order as RenderApiType and have same amount of entries
1414
/* static */const RenderApiUtil::Info RenderApiUtil::s_infos[] =
1515
{
16-
{ RenderApiType::OpenGl, "gl,ogl,opengl", "glsl,glsl-rewrite,glsl-cross"},
1716
{ RenderApiType::Vulkan, "vk,vulkan", ""},
1817
{ RenderApiType::D3D12, "dx12,d3d12", ""},
1918
{ RenderApiType::D3D11, "dx11,d3d11", "hlsl,hlsl-rewrite,slang"},
@@ -265,13 +264,11 @@ static bool _canLoadSharedLibrary(const char* libName)
265264
switch (type)
266265
{
267266
#if SLANG_WINDOWS_FAMILY
268-
case RenderApiType::OpenGl: return _canLoadSharedLibrary("opengl32");
269267
case RenderApiType::Vulkan: return _canLoadSharedLibrary("vulkan-1") || _canLoadSharedLibrary("vk_swiftshader");
270268
#elif SLANG_APPLE_FAMILY
271269
case RenderApiType::Vulkan: return true;
272270
case RenderApiType::Metal: return true;
273271
#elif SLANG_UNIX_FAMILY
274-
case RenderApiType::OpenGl: return true;
275272
case RenderApiType::Vulkan: return true;
276273
#endif
277274

source/core/slang-render-api-util.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ namespace Slang
1111
enum class RenderApiType
1212
{
1313
Unknown = -1,
14-
OpenGl = 0,
15-
Vulkan,
14+
Vulkan = 0,
1615
D3D12,
1716
D3D11,
1817
Metal,
@@ -26,7 +25,6 @@ struct RenderApiFlag
2625
{
2726
enum Enum
2827
{
29-
OpenGl = 1 << int(RenderApiType::OpenGl),
3028
Vulkan = 1 << int(RenderApiType::Vulkan),
3129
D3D12 = 1 << int(RenderApiType::D3D12),
3230
D3D11 = 1 << int(RenderApiType::D3D11),

tests/bugs/gh-4504.slang

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-slang -dx12 -compute -shaderobj
22
//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -compute -shaderobj
3-
//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -glsl -compute -shaderobj
43
//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=CHECK):-mtl -compute -shaderobj
54

65
//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer
@@ -20,4 +19,4 @@ void computeMain(uint3 threadId: SV_DispatchThreadID)
2019
&& size.y == 2
2120
&& size.z == 1
2221
;
23-
}
22+
}

tests/bugs/gh-4556.slang

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -compute -output-using-type -shaderobj
22
//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -compute -output-using-type -shaderobj
3-
//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -glsl -compute -output-using-type -shaderobj
43
//TEST(compute):SIMPLE(filecheck=SPIRV): -target spirv-asm -stage compute
54
//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-mtl -compute -output-using-type -shaderobj
65
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -cpu -output-using-type -shaderobj

tests/compute/dynamic-dispatch-14.slang

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile sm_6_0 -use-dxil
44
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx11 -profile sm_5_0
5-
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -gl -profile glsl_440
65
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -vk -profile glsl_440
76
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cpu
87

tests/compute/texture-subscript-multisample.slang

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// Due to this, Metal compute test is disabled
55
//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -slang -output-using-type -shaderobj -mtl
66
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -slang -output-using-type -shaderobj -vk
7-
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -slang -output-using-type -shaderobj -vk -glsl
87

98
//METAL_ERROR: error 41402
109
//METALLIB: error 41402

tests/compute/texture-subscript.slang

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// Due to this, Metal compute test is disabled
55
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -slang -output-using-type -shaderobj -mtl
66
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -slang -output-using-type -shaderobj -vk
7-
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -slang -output-using-type -shaderobj -vk -glsl
87

98
//METAL-NOT: error 41402
109
//METALLIB: @computeMain
@@ -59,4 +58,4 @@ void computeMain()
5958
);
6059
}
6160

62-
//BUF: 1
61+
//BUF: 1

tests/render/cross-compile-entry-point.slang

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//TEST(render):COMPARE_HLSL_CROSS_COMPILE_RENDER:
2-
//TEST(render):COMPARE_HLSL_CROSS_COMPILE_RENDER: -dx12
1+
// //TEST(render):COMPARE_HLSL_CROSS_COMPILE_RENDER:
2+
// //TEST(render):COMPARE_HLSL_CROSS_COMPILE_RENDER: -dx12
33

44

55
// This is a test to ensure that we can cross-compile a complete entry point.

tools/gfx-unit-test/gfx-test-util.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,6 @@ namespace gfx_test
263263
case Slang::RenderApiFlag::CUDA:
264264
deviceDesc.deviceType = gfx::DeviceType::CUDA;
265265
break;
266-
case Slang::RenderApiFlag::OpenGl:
267-
deviceDesc.deviceType = gfx::DeviceType::OpenGl;
268-
break;
269266
default:
270267
SLANG_IGNORE_TEST
271268
}

tools/render-test/options.cpp

+9-10
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,19 @@
2222
namespace renderer_test {
2323
using namespace Slang;
2424

25-
static gfx::DeviceType _toRenderType(Slang::RenderApiType apiType)
25+
static rhi::DeviceType _toRenderType(Slang::RenderApiType apiType)
2626
{
2727
using namespace Slang;
2828
switch (apiType)
2929
{
30-
case RenderApiType::D3D11: return gfx::DeviceType::DirectX11;
31-
case RenderApiType::D3D12: return gfx::DeviceType::DirectX12;
32-
case RenderApiType::OpenGl: return gfx::DeviceType::OpenGl;
33-
case RenderApiType::Vulkan: return gfx::DeviceType::Vulkan;
34-
case RenderApiType::Metal: return gfx::DeviceType::Metal;
35-
case RenderApiType::CPU: return gfx::DeviceType::CPU;
36-
case RenderApiType::CUDA: return gfx::DeviceType::CUDA;
30+
case RenderApiType::D3D11: return rhi::DeviceType::D3D11;
31+
case RenderApiType::D3D12: return rhi::DeviceType::D3D12;
32+
case RenderApiType::Vulkan: return rhi::DeviceType::Vulkan;
33+
case RenderApiType::Metal: return rhi::DeviceType::Metal;
34+
case RenderApiType::CPU: return rhi::DeviceType::CPU;
35+
case RenderApiType::CUDA: return rhi::DeviceType::CUDA;
3736
default:
38-
return gfx::DeviceType::Unknown;
37+
return rhi::DeviceType::Unknown;
3938
}
4039
}
4140

@@ -254,7 +253,7 @@ static gfx::DeviceType _toRenderType(Slang::RenderApiType apiType)
254253
// Lookup the target language type
255254
DeviceType targetLanguageDeviceType = _toRenderType(RenderApiUtil::findImplicitLanguageRenderApiType(argName));
256255

257-
if (targetLanguageDeviceType != DeviceType::Unknown)
256+
if (targetLanguageDeviceType != DeviceType::Unknown || argName == "glsl")
258257
{
259258
outOptions.targetLanguageDeviceType = targetLanguageDeviceType;
260259
outOptions.inputLanguageID = (argName == "hlsl" || argName == "glsl" || argName == "cpp" || argName == "cxx" || argName == "c") ? InputLanguageID::Native : InputLanguageID::Slang;

tools/render-test/options.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414

1515
#include "../../source/compiler-core/slang-command-line-args.h"
1616

17-
#include "slang-gfx.h"
17+
#include <slang-rhi.h>
1818

1919
namespace renderer_test {
2020

21-
using namespace gfx;
21+
using namespace rhi;
2222

2323
struct Options
2424
{

0 commit comments

Comments
 (0)