diff options
| author | Gangzheng Tong <tonggangzheng@gmail.com> | 2025-07-08 23:44:56 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-09 06:44:56 +0000 |
| commit | 43d0c2100ef1a5df4b54525e50eb29fe7c39ec16 (patch) | |
| tree | 25ec4fb9c726115f90bdaa9878f2f4ca372ad0a6 /examples/reflection-parameter-blocks/main.cpp | |
| parent | 00746bf09047cdf01c19dac513a532bcf3ed3ea3 (diff) | |
Convert gfx unit tests and examples to use slang-rhi (#7577)
* Port first gfx unit test to slang-rhi
* port triangle example to use slang-rhi
* port platform-test to slang-rhi
* Update platform-test to throttle mouse move events
* port gpu-printing example to use slang-rhi
* port model-viewer example to use slang-rhi
* port ray-tracing example to use slang-rhi
* port ray-tracing pipeline example to use slang-rhi
* port reflection parameter blocks example to use slang-rhi
* port shader-object example to use slang-rhi
* port shader-toy example to use slang-rhi
* Port most of tests to slang-rhi
* port link-time-constant-array-size to use slang-rhi
* Fix tests and find matching tests in slang-rhi
* port autodiff-texture
* remove gfx target; port nv-aftermath-example
* update include path for shader-cursor.h
* Disabled 2 more ported tests
* fix build error
* remove gfx test
* put slang-rhi (static-lib) before slang (shared)
* format code (#7621)
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* add debug callback
* format code (#7649)
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
* Address review comments; revert back to use SLANG_CHECK_MSG
---------
Co-authored-by: slangbot <ellieh+slangbot@nvidia.com>
Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'examples/reflection-parameter-blocks/main.cpp')
| -rw-r--r-- | examples/reflection-parameter-blocks/main.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/examples/reflection-parameter-blocks/main.cpp b/examples/reflection-parameter-blocks/main.cpp index 873e785d0..04e2b19c0 100644 --- a/examples/reflection-parameter-blocks/main.cpp +++ b/examples/reflection-parameter-blocks/main.cpp @@ -21,15 +21,17 @@ // with a certain amount of boilerplate that isn't especially // interesting to discuss. +#include "core/slang-basic.h" +#include "examples/example-base/example-base.h" #include "slang-com-ptr.h" +#include "slang-rhi.h" #include "slang.h" -typedef SlangResult Result; -#include "core/slang-basic.h" -#include "examples/example-base/example-base.h" +typedef SlangResult Result; using Slang::ComPtr; using Slang::String; using Slang::List; +using namespace rhi; // The example code currently only supports Vulkan, but the // code is factored with the intention that it could be extended @@ -47,7 +49,7 @@ static const char* kSourceFileName = "shader.slang"; struct PipelineLayoutReflectionContext { - gfx::IDevice* _gfxDevice = nullptr; + IDevice* _rhiDevice = nullptr; slang::ISession* _slangSession = nullptr; slang::ProgramLayout* _slangProgramLayout = nullptr; slang::IBlob* _slangCompiledProgramBlob = nullptr; @@ -529,16 +531,16 @@ struct PipelineLayoutReflectionContext_Vulkan : PipelineLayoutReflectionContext Result createAndValidatePipelineLayout() { // Here we do a little bit of complicated interaction with - // the `gfx` library to allow us to call raw Vulkan API - // functions on the same device that `gfx` kindly set up + // the `slang-rhi` library to allow us to call raw Vulkan API + // functions on the same device that `slang-rhi` kindly set up // for us. // - gfx::IDevice::InteropHandles handles; - SLANG_RETURN_ON_FAIL(_gfxDevice->getNativeDeviceHandles(&handles)); + DeviceNativeHandles handle; + SLANG_RETURN_ON_FAIL(_rhiDevice->getNativeDeviceHandles(&handle)); - vkAPI.instance = (VkInstance)handles.handles[0].handleValue; - vkAPI.physicalDevice = (VkPhysicalDevice)handles.handles[1].handleValue; - vkAPI.device = (VkDevice)handles.handles[2].handleValue; + vkAPI.instance = (VkInstance)handle.handles[0].value; + vkAPI.physicalDevice = (VkPhysicalDevice)handle.handles[1].value; + vkAPI.device = (VkDevice)handle.handles[2].value; vkAPI.initGlobalProcs(); vkAPI.initInstanceProcs(); @@ -575,25 +577,23 @@ struct ReflectionParameterBlocksExampleApp : public TestBase { parseOption(argc, argv); - // We start by initializing the `gfx` system, so that + // We start by initializing the `slang-rhi` system, so that // it can handle most of the details of getting a // Vulkan device up and running. -#ifdef _DEBUG - gfx::gfxEnableDebugLayer(true); -#endif - gfx::IDevice::Desc deviceDesc = {}; - deviceDesc.deviceType = gfx::DeviceType::Vulkan; + DeviceDesc deviceDesc = {}; + deviceDesc.deviceType = DeviceType::Vulkan; - ComPtr<gfx::IDevice> gfxDevice; - SLANG_RETURN_ON_FAIL(gfxCreateDevice(&deviceDesc, gfxDevice.writeRef())); + ComPtr<IDevice> rhiDevice = getRHI()->createDevice(deviceDesc); + if (!rhiDevice) + return SLANG_FAIL; - // The `gfx` library also creates a Slang session as + // The `slang-rhi` library also creates a Slang session as // part of its startup, so we will use the session // it already created for the compilation in // this example. // - auto slangSession = gfxDevice->getSlangSession(); + auto slangSession = rhiDevice->getSlangSession(); // Next we go through the fairly routine steps needed to // compile a Slang program from source. @@ -672,7 +672,7 @@ struct ReflectionParameterBlocksExampleApp : public TestBase // PipelineLayoutReflectionContext_Vulkan context; - context._gfxDevice = gfxDevice; + context._rhiDevice = rhiDevice; context._slangSession = slangSession; context._slangProgramLayout = programLayout; context._slangCompiledProgramBlob = programBinary; |
