Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate slang-rhi #4970

Merged
merged 9 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
submodules: 'recursive'
fetch-depth: '0'
- name: Common setup
uses: ./.github/actions/common-setup
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
submodules: 'recursive'
fetch-depth: '0'
- name: Setup
uses: ./.github/actions/common-setup
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/compile-regression-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
submodules: 'recursive'
fetch-depth: '0'
- name: Setup
uses: ./.github/actions/common-setup
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/falcor-compiler-perf-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
submodules: 'recursive'
fetch-depth: '0'

- name: Setup
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/falcor-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
submodules: 'recursive'
fetch-depth: '0'
- name: Setup
uses: ./.github/actions/common-setup
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-linux-glibc-2-17.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
submodules: 'recursive'
fetch-depth: '0'

# build the binary in docker image
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
steps:
- uses: actions/checkout@v3
with:
submodules: 'true'
submodules: 'recursive'
fetch-depth: '0'
- name: Setup
uses: ./.github/actions/common-setup
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@
[submodule "external/metal-cpp"]
path = external/metal-cpp
url = https://github.com/bkaradzic/metal-cpp
[submodule "external/slang-rhi"]
path = external/slang-rhi
url = https://github.com/shader-slang/slang-rhi.git
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -637,8 +637,7 @@ if(SLANG_ENABLE_TESTS)
core
compiler-core
slang
gfx
gfx-util
slang-rhi
platform
$<$<BOOL:${SLANG_ENABLE_CUDA}>:CUDA::cuda_driver>
EXTRA_COMPILE_DEFINITIONS_PRIVATE
Expand Down
6 changes: 6 additions & 0 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ endif()
add_library(imgui INTERFACE)
target_include_directories(imgui INTERFACE "${CMAKE_CURRENT_LIST_DIR}/imgui")

# slang-rhi
set(SLANG_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
set(SLANG_BINARY_DIR ${CMAKE_BINARY_DIR})
set(SLANG_RHI_BUILD_TESTS OFF)
add_subdirectory(slang-rhi)

# Tidy things up:

# Restore log level if we set it
Expand Down
1 change: 1 addition & 0 deletions external/slang-rhi
Submodule slang-rhi added at 162d0a
3 changes: 0 additions & 3 deletions source/core/slang-render-api-util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ namespace Slang {
// NOTE! Must keep in same order as RenderApiType and have same amount of entries
/* static */const RenderApiUtil::Info RenderApiUtil::s_infos[] =
{
{ RenderApiType::OpenGl, "gl,ogl,opengl", "glsl,glsl-rewrite,glsl-cross"},
{ RenderApiType::Vulkan, "vk,vulkan", ""},
{ RenderApiType::D3D12, "dx12,d3d12", ""},
{ RenderApiType::D3D11, "dx11,d3d11", "hlsl,hlsl-rewrite,slang"},
Expand Down Expand Up @@ -265,13 +264,11 @@ static bool _canLoadSharedLibrary(const char* libName)
switch (type)
{
#if SLANG_WINDOWS_FAMILY
case RenderApiType::OpenGl: return _canLoadSharedLibrary("opengl32");
case RenderApiType::Vulkan: return _canLoadSharedLibrary("vulkan-1") || _canLoadSharedLibrary("vk_swiftshader");
#elif SLANG_APPLE_FAMILY
case RenderApiType::Vulkan: return true;
case RenderApiType::Metal: return true;
#elif SLANG_UNIX_FAMILY
case RenderApiType::OpenGl: return true;
case RenderApiType::Vulkan: return true;
#endif

Expand Down
4 changes: 1 addition & 3 deletions source/core/slang-render-api-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ namespace Slang
enum class RenderApiType
{
Unknown = -1,
OpenGl = 0,
Vulkan,
Vulkan = 0,
D3D12,
D3D11,
Metal,
Expand All @@ -26,7 +25,6 @@ struct RenderApiFlag
{
enum Enum
{
OpenGl = 1 << int(RenderApiType::OpenGl),
Vulkan = 1 << int(RenderApiType::Vulkan),
D3D12 = 1 << int(RenderApiType::D3D12),
D3D11 = 1 << int(RenderApiType::D3D11),
Expand Down
3 changes: 1 addition & 2 deletions tests/bugs/gh-4504.slang
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-slang -dx12 -compute -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -compute -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -glsl -compute -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=CHECK):-mtl -compute -shaderobj

//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer
Expand All @@ -20,4 +19,4 @@ void computeMain(uint3 threadId: SV_DispatchThreadID)
&& size.y == 2
&& size.z == 1
;
}
}
1 change: 0 additions & 1 deletion tests/bugs/gh-4556.slang
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-dx12 -compute -output-using-type -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -compute -output-using-type -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -glsl -compute -output-using-type -shaderobj
//TEST(compute):SIMPLE(filecheck=SPIRV): -target spirv-asm -stage compute
//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-mtl -compute -output-using-type -shaderobj
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK): -cpu -output-using-type -shaderobj
Expand Down
1 change: 0 additions & 1 deletion tests/compute/dynamic-dispatch-14.slang
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile sm_6_0 -use-dxil
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx11 -profile sm_5_0
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -gl -profile glsl_440
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -vk -profile glsl_440
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cpu

Expand Down
1 change: 0 additions & 1 deletion tests/compute/texture-subscript-multisample.slang
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// Due to this, Metal compute test is disabled
//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -slang -output-using-type -shaderobj -mtl
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -slang -output-using-type -shaderobj -vk
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -slang -output-using-type -shaderobj -vk -glsl

//METAL_ERROR: error 41402
//METALLIB: error 41402
Expand Down
3 changes: 1 addition & 2 deletions tests/compute/texture-subscript.slang
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// Due to this, Metal compute test is disabled
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -slang -output-using-type -shaderobj -mtl
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -slang -output-using-type -shaderobj -vk
//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -slang -output-using-type -shaderobj -vk -glsl

//METAL-NOT: error 41402
//METALLIB: @computeMain
Expand Down Expand Up @@ -59,4 +58,4 @@ void computeMain()
);
}

//BUF: 1
//BUF: 1
4 changes: 2 additions & 2 deletions tests/render/cross-compile-entry-point.slang
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//TEST(render):COMPARE_HLSL_CROSS_COMPILE_RENDER:
//TEST(render):COMPARE_HLSL_CROSS_COMPILE_RENDER: -dx12
// //TEST(render):COMPARE_HLSL_CROSS_COMPILE_RENDER:
// //TEST(render):COMPARE_HLSL_CROSS_COMPILE_RENDER: -dx12


// This is a test to ensure that we can cross-compile a complete entry point.
Expand Down
3 changes: 0 additions & 3 deletions tools/gfx-unit-test/gfx-test-util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,6 @@ namespace gfx_test
case Slang::RenderApiFlag::CUDA:
deviceDesc.deviceType = gfx::DeviceType::CUDA;
break;
case Slang::RenderApiFlag::OpenGl:
deviceDesc.deviceType = gfx::DeviceType::OpenGl;
break;
default:
SLANG_IGNORE_TEST
}
Expand Down
19 changes: 9 additions & 10 deletions tools/render-test/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,19 @@
namespace renderer_test {
using namespace Slang;

static gfx::DeviceType _toRenderType(Slang::RenderApiType apiType)
static rhi::DeviceType _toRenderType(Slang::RenderApiType apiType)
{
using namespace Slang;
switch (apiType)
{
case RenderApiType::D3D11: return gfx::DeviceType::DirectX11;
case RenderApiType::D3D12: return gfx::DeviceType::DirectX12;
case RenderApiType::OpenGl: return gfx::DeviceType::OpenGl;
case RenderApiType::Vulkan: return gfx::DeviceType::Vulkan;
case RenderApiType::Metal: return gfx::DeviceType::Metal;
case RenderApiType::CPU: return gfx::DeviceType::CPU;
case RenderApiType::CUDA: return gfx::DeviceType::CUDA;
case RenderApiType::D3D11: return rhi::DeviceType::D3D11;
case RenderApiType::D3D12: return rhi::DeviceType::D3D12;
case RenderApiType::Vulkan: return rhi::DeviceType::Vulkan;
case RenderApiType::Metal: return rhi::DeviceType::Metal;
case RenderApiType::CPU: return rhi::DeviceType::CPU;
case RenderApiType::CUDA: return rhi::DeviceType::CUDA;
default:
return gfx::DeviceType::Unknown;
return rhi::DeviceType::Unknown;
}
}

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

if (targetLanguageDeviceType != DeviceType::Unknown)
if (targetLanguageDeviceType != DeviceType::Unknown || argName == "glsl")
{
outOptions.targetLanguageDeviceType = targetLanguageDeviceType;
outOptions.inputLanguageID = (argName == "hlsl" || argName == "glsl" || argName == "cpp" || argName == "cxx" || argName == "c") ? InputLanguageID::Native : InputLanguageID::Slang;
Expand Down
4 changes: 2 additions & 2 deletions tools/render-test/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

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

#include "slang-gfx.h"
#include <slang-rhi.h>

namespace renderer_test {

using namespace gfx;
using namespace rhi;

struct Options
{
Expand Down
Loading
Loading