diff options
| author | Ellie Hermaszewska <ellieh@nvidia.com> | 2024-10-29 14:49:26 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-29 14:49:26 +0800 |
| commit | f65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (patch) | |
| tree | ea1d61342cd29368e19135000ec2948813096205 /tools/gfx/cuda | |
| parent | a729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff) | |
format
* format
* Minor test fixes
* enable checking cpp format in ci
Diffstat (limited to 'tools/gfx/cuda')
22 files changed, 406 insertions, 359 deletions
diff --git a/tools/gfx/cuda/cuda-base.h b/tools/gfx/cuda/cuda-base.h index 63c280cde..11a798636 100644 --- a/tools/gfx/cuda/cuda-base.h +++ b/tools/gfx/cuda/cuda-base.h @@ -3,32 +3,32 @@ #pragma once #ifdef GFX_ENABLE_CUDA -#include <cuda.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-encoder-com-forward.h" #include "../command-writer.h" -#include "../renderer-shared.h" #include "../mutable-shader-object.h" +#include "../renderer-shared.h" #include "../simple-transient-resource-heap.h" #include "../slang-context.h" -#include "../command-encoder-com-forward.h" +#include "core/slang-basic.h" +#include "core/slang-blob.h" +#include "core/slang-std-writers.h" +#include "slang-com-helper.h" +#include "slang-com-ptr.h" +#include "slang.h" + +#include <cuda.h> -# ifdef RENDER_TEST_OPTIX +#ifdef RENDER_TEST_OPTIX // The `optix_stubs.h` header produces warnings when compiled with MSVC -# ifdef _MSC_VER -# pragma warning(disable: 4996) -# endif +#ifdef _MSC_VER +#pragma warning(disable : 4996) +#endif -# include <optix.h> -# include <optix_function_table_definition.h> -# include <optix_stubs.h> -# endif +#include <optix.h> +#include <optix_function_table_definition.h> +#include <optix_stubs.h> +#endif #endif @@ -36,23 +36,23 @@ namespace gfx { namespace cuda { - class CUDAContext; - class BufferResourceImpl; - class TextureResourceImpl; - class ResourceViewImpl; - class ShaderObjectLayoutImpl; - class RootShaderObjectLayoutImpl; - class ShaderObjectImpl; - class MutableShaderObjectImpl; - class EntryPointShaderObjectImpl; - class RootShaderObjectImpl; - class ShaderProgramImpl; - class PipelineStateImpl; - class QueryPoolImpl; - class DeviceImpl; - class CommandBufferImpl; - class ResourceCommandEncoderImpl; - class ComputeCommandEncoderImpl; - class CommandQueueImpl; -} -} +class CUDAContext; +class BufferResourceImpl; +class TextureResourceImpl; +class ResourceViewImpl; +class ShaderObjectLayoutImpl; +class RootShaderObjectLayoutImpl; +class ShaderObjectImpl; +class MutableShaderObjectImpl; +class EntryPointShaderObjectImpl; +class RootShaderObjectImpl; +class ShaderProgramImpl; +class PipelineStateImpl; +class QueryPoolImpl; +class DeviceImpl; +class CommandBufferImpl; +class ResourceCommandEncoderImpl; +class ComputeCommandEncoderImpl; +class CommandQueueImpl; +} // namespace cuda +} // namespace gfx diff --git a/tools/gfx/cuda/cuda-buffer.cpp b/tools/gfx/cuda/cuda-buffer.cpp index bc4ef32ef..63c94b459 100644 --- a/tools/gfx/cuda/cuda-buffer.cpp +++ b/tools/gfx/cuda/cuda-buffer.cpp @@ -19,7 +19,10 @@ BufferResourceImpl::~BufferResourceImpl() } } -uint64_t BufferResourceImpl::getBindlessHandle() { return (uint64_t)m_cudaMemory; } +uint64_t BufferResourceImpl::getBindlessHandle() +{ + return (uint64_t)m_cudaMemory; +} DeviceAddress BufferResourceImpl::getDeviceAddress() { diff --git a/tools/gfx/cuda/cuda-buffer.h b/tools/gfx/cuda/cuda-buffer.h index 838a06555..c83ab755d 100644 --- a/tools/gfx/cuda/cuda-buffer.h +++ b/tools/gfx/cuda/cuda-buffer.h @@ -16,7 +16,8 @@ class BufferResourceImpl : public BufferResource public: BufferResourceImpl(const Desc& _desc) : BufferResource(_desc) - {} + { + } ~BufferResourceImpl(); @@ -28,9 +29,10 @@ public: RefPtr<CUDAContext> m_cudaContext; virtual SLANG_NO_THROW DeviceAddress SLANG_MCALL getDeviceAddress() override; - virtual SLANG_NO_THROW Result SLANG_MCALL getNativeResourceHandle(InteropHandle* outHandle) override; virtual SLANG_NO_THROW Result SLANG_MCALL - map(MemoryRange* rangeToRead, void** outPointer) override; + getNativeResourceHandle(InteropHandle* outHandle) override; + virtual SLANG_NO_THROW Result SLANG_MCALL + map(MemoryRange* rangeToRead, void** outPointer) override; virtual SLANG_NO_THROW Result SLANG_MCALL unmap(MemoryRange* writtenRange) override; }; diff --git a/tools/gfx/cuda/cuda-command-buffer.cpp b/tools/gfx/cuda/cuda-command-buffer.cpp index efb2486f4..ce95a2196 100644 --- a/tools/gfx/cuda/cuda-command-buffer.cpp +++ b/tools/gfx/cuda/cuda-command-buffer.cpp @@ -33,21 +33,21 @@ SLANG_NO_THROW void SLANG_MCALL CommandBufferImpl::encodeRenderCommands( } SLANG_NO_THROW void SLANG_MCALL - CommandBufferImpl::encodeResourceCommands(IResourceCommandEncoder** outEncoder) +CommandBufferImpl::encodeResourceCommands(IResourceCommandEncoder** outEncoder) { m_resourceCommandEncoder.init(this); *outEncoder = &m_resourceCommandEncoder; } SLANG_NO_THROW void SLANG_MCALL - CommandBufferImpl::encodeComputeCommands(IComputeCommandEncoder** outEncoder) +CommandBufferImpl::encodeComputeCommands(IComputeCommandEncoder** outEncoder) { m_computeCommandEncoder.init(this); *outEncoder = &m_computeCommandEncoder; } SLANG_NO_THROW void SLANG_MCALL - CommandBufferImpl::encodeRayTracingCommands(IRayTracingCommandEncoder** outEncoder) +CommandBufferImpl::encodeRayTracingCommands(IRayTracingCommandEncoder** outEncoder) { *outEncoder = nullptr; } diff --git a/tools/gfx/cuda/cuda-command-buffer.h b/tools/gfx/cuda/cuda-command-buffer.h index 76d9aa01f..05329d67c 100644 --- a/tools/gfx/cuda/cuda-command-buffer.h +++ b/tools/gfx/cuda/cuda-command-buffer.h @@ -11,14 +11,11 @@ using namespace Slang; namespace cuda { -class CommandBufferImpl - : public ICommandBuffer - , public CommandWriter - , public ComObject +class CommandBufferImpl : public ICommandBuffer, public CommandWriter, public ComObject { public: SLANG_COM_OBJECT_IUNKNOWN_ALL - ICommandBuffer* getInterface(const Guid& guid); + ICommandBuffer* getInterface(const Guid& guid); public: DeviceImpl* m_device; @@ -33,11 +30,11 @@ public: IRenderCommandEncoder** outEncoder) override; virtual SLANG_NO_THROW void SLANG_MCALL - encodeResourceCommands(IResourceCommandEncoder** outEncoder) override; + encodeResourceCommands(IResourceCommandEncoder** outEncoder) override; virtual SLANG_NO_THROW void SLANG_MCALL - encodeComputeCommands(IComputeCommandEncoder** outEncoder) override; + encodeComputeCommands(IComputeCommandEncoder** outEncoder) override; virtual SLANG_NO_THROW void SLANG_MCALL - encodeRayTracingCommands(IRayTracingCommandEncoder** outEncoder) override; + encodeRayTracingCommands(IRayTracingCommandEncoder** outEncoder) override; virtual SLANG_NO_THROW void SLANG_MCALL close() override {} diff --git a/tools/gfx/cuda/cuda-command-encoder.cpp b/tools/gfx/cuda/cuda-command-encoder.cpp index d94b40e21..1f4afcc5c 100644 --- a/tools/gfx/cuda/cuda-command-encoder.cpp +++ b/tools/gfx/cuda/cuda-command-encoder.cpp @@ -13,7 +13,7 @@ namespace cuda { void ResourceCommandEncoderImpl::init(CommandBufferImpl* cmdBuffer) -{ +{ m_writer = cmdBuffer; } @@ -28,13 +28,16 @@ SLANG_NO_THROW void SLANG_MCALL ResourceCommandEncoderImpl::copyBuffer( } SLANG_NO_THROW void SLANG_MCALL ResourceCommandEncoderImpl::uploadBufferData( - IBufferResource* dst, Offset offset, Size size, void* data) + IBufferResource* dst, + Offset offset, + Size size, + void* data) { m_writer->uploadBufferData(dst, offset, size, data); } SLANG_NO_THROW void SLANG_MCALL - ResourceCommandEncoderImpl::writeTimestamp(IQueryPool* pool, GfxIndex index) +ResourceCommandEncoderImpl::writeTimestamp(IQueryPool* pool, GfxIndex index) { m_writer->writeTimestamp(pool, index); } @@ -159,7 +162,7 @@ SLANG_NO_THROW void SLANG_MCALL ResourceCommandEncoderImpl::textureSubresourceBa } SLANG_NO_THROW void SLANG_MCALL - ResourceCommandEncoderImpl::beginDebugEvent(const char* name, float rgbColor[3]) +ResourceCommandEncoderImpl::beginDebugEvent(const char* name, float rgbColor[3]) { SLANG_UNUSED(name); SLANG_UNUSED(rgbColor); @@ -172,23 +175,26 @@ void ComputeCommandEncoderImpl::init(CommandBufferImpl* cmdBuffer) } SLANG_NO_THROW Result SLANG_MCALL - ComputeCommandEncoderImpl::bindPipeline(IPipelineState* state, IShaderObject** outRootObject) +ComputeCommandEncoderImpl::bindPipeline(IPipelineState* state, IShaderObject** outRootObject) { m_writer->setPipelineState(state); PipelineStateBase* pipelineImpl = static_cast<PipelineStateBase*>(state); SLANG_RETURN_ON_FAIL(m_commandBuffer->m_device->createRootShaderObject( - pipelineImpl->m_program, m_rootObject.writeRef())); + pipelineImpl->m_program, + m_rootObject.writeRef())); returnComPtr(outRootObject, m_rootObject); return SLANG_OK; } -SLANG_NO_THROW Result SLANG_MCALL - ComputeCommandEncoderImpl::bindPipelineWithRootObject(IPipelineState* state, IShaderObject* rootObject) +SLANG_NO_THROW Result SLANG_MCALL ComputeCommandEncoderImpl::bindPipelineWithRootObject( + IPipelineState* state, + IShaderObject* rootObject) { m_writer->setPipelineState(state); PipelineStateBase* pipelineImpl = static_cast<PipelineStateBase*>(state); SLANG_RETURN_ON_FAIL(m_commandBuffer->m_device->createRootShaderObject( - pipelineImpl->m_program, m_rootObject.writeRef())); + pipelineImpl->m_program, + m_rootObject.writeRef())); m_rootObject->copyFrom(rootObject, m_commandBuffer->m_transientHeap); return SLANG_OK; } @@ -201,7 +207,7 @@ SLANG_NO_THROW Result SLANG_MCALL ComputeCommandEncoderImpl::dispatchCompute(int } SLANG_NO_THROW Result SLANG_MCALL - ComputeCommandEncoderImpl::dispatchComputeIndirect(IBufferResource* argBuffer, Offset offset) +ComputeCommandEncoderImpl::dispatchComputeIndirect(IBufferResource* argBuffer, Offset offset) { SLANG_UNIMPLEMENTED_X("dispatchComputeIndirect"); } diff --git a/tools/gfx/cuda/cuda-command-encoder.h b/tools/gfx/cuda/cuda-command-encoder.h index ab8aa8f8f..e845e1962 100644 --- a/tools/gfx/cuda/cuda-command-encoder.h +++ b/tools/gfx/cuda/cuda-command-encoder.h @@ -22,7 +22,7 @@ public: return nullptr; } virtual SLANG_NO_THROW SlangResult SLANG_MCALL - queryInterface(SlangUUID const& uuid, void** outObject) override + queryInterface(SlangUUID const& uuid, void** outObject) override { if (auto ptr = getInterface(uuid)) { @@ -49,20 +49,22 @@ public: ITextureResource* const* textures, ResourceState src, ResourceState dst) override - {} + { + } virtual SLANG_NO_THROW void SLANG_MCALL bufferBarrier( GfxCount count, IBufferResource* const* buffers, ResourceState src, ResourceState dst) override - {} + { + } - virtual SLANG_NO_THROW void SLANG_MCALL uploadBufferData( - IBufferResource* dst, Offset offset, Size size, void* data) override; + virtual SLANG_NO_THROW void SLANG_MCALL + uploadBufferData(IBufferResource* dst, Offset offset, Size size, void* data) override; virtual SLANG_NO_THROW void SLANG_MCALL - writeTimestamp(IQueryPool* pool, GfxIndex index) override; + writeTimestamp(IQueryPool* pool, GfxIndex index) override; virtual SLANG_NO_THROW void SLANG_MCALL copyTexture( ITextureResource* dst, @@ -120,22 +122,22 @@ public: ResourceState src, ResourceState dst) override; virtual SLANG_NO_THROW void SLANG_MCALL - beginDebugEvent(const char* name, float rgbColor[3]) override; + beginDebugEvent(const char* name, float rgbColor[3]) override; virtual SLANG_NO_THROW void SLANG_MCALL endDebugEvent() override {} }; -class ComputeCommandEncoderImpl - : public IComputeCommandEncoder - , public ResourceCommandEncoderImpl +class ComputeCommandEncoderImpl : public IComputeCommandEncoder, public ResourceCommandEncoderImpl { public: SLANG_GFX_FORWARD_RESOURCE_COMMAND_ENCODER_IMPL(ResourceCommandEncoderImpl) virtual void* getInterface(SlangUUID const& uuid) override { - if (uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == GfxGUID::IID_IComputeCommandEncoder || uuid == ISlangUnknown::getTypeGuid()) + if (uuid == GfxGUID::IID_IResourceCommandEncoder || + uuid == GfxGUID::IID_IComputeCommandEncoder || uuid == ISlangUnknown::getTypeGuid()) return this; return nullptr; } + public: CommandWriter* m_writer; CommandBufferImpl* m_commandBuffer; @@ -144,15 +146,15 @@ public: void init(CommandBufferImpl* cmdBuffer); virtual SLANG_NO_THROW Result SLANG_MCALL - bindPipeline(IPipelineState* state, IShaderObject** outRootObject) override; + bindPipeline(IPipelineState* state, IShaderObject** outRootObject) override; virtual SLANG_NO_THROW Result SLANG_MCALL - bindPipelineWithRootObject(IPipelineState* state, IShaderObject* rootObject) override; + bindPipelineWithRootObject(IPipelineState* state, IShaderObject* rootObject) override; virtual SLANG_NO_THROW Result SLANG_MCALL dispatchCompute(int x, int y, int z) override; virtual SLANG_NO_THROW Result SLANG_MCALL - dispatchComputeIndirect(IBufferResource* argBuffer, Offset offset) override; + dispatchComputeIndirect(IBufferResource* argBuffer, Offset offset) override; }; } // namespace cuda diff --git a/tools/gfx/cuda/cuda-command-queue.cpp b/tools/gfx/cuda/cuda-command-queue.cpp index 5c6f2db26..4cc3e111d 100644 --- a/tools/gfx/cuda/cuda-command-queue.cpp +++ b/tools/gfx/cuda/cuda-command-queue.cpp @@ -36,7 +36,10 @@ CommandQueueImpl::~CommandQueueImpl() } SLANG_NO_THROW void SLANG_MCALL CommandQueueImpl::executeCommandBuffers( - GfxCount count, ICommandBuffer* const* commandBuffers, IFence* fence, uint64_t valueToSignal) + GfxCount count, + ICommandBuffer* const* commandBuffers, + IFence* fence, + uint64_t valueToSignal) { SLANG_UNUSED(valueToSignal); // TODO: implement fence. @@ -55,7 +58,9 @@ SLANG_NO_THROW void SLANG_MCALL CommandQueueImpl::waitOnHost() } SLANG_NO_THROW Result SLANG_MCALL CommandQueueImpl::waitForFenceValuesOnDevice( - GfxCount fenceCount, IFence** fences, uint64_t* waitValues) + GfxCount fenceCount, + IFence** fences, + uint64_t* waitValues) { return SLANG_FAIL; } @@ -115,8 +120,7 @@ void CommandQueueImpl::dispatchCompute(int x, int y, int z) // stored in host memory in a CUDAEntryPointShaderObject, as expected by cuLaunchKernel. // auto entryPointBuffer = currentRootObject->entryPointObjects[kernelId]->getBuffer(); - auto entryPointDataSize = - currentRootObject->entryPointObjects[kernelId]->getBufferSize(); + auto entryPointDataSize = currentRootObject->entryPointObjects[kernelId]->getBufferSize(); void* extraOptions[] = { CU_LAUNCH_PARAM_BUFFER_POINTER, @@ -160,13 +164,14 @@ void CommandQueueImpl::copyBuffer( size); } -void CommandQueueImpl::uploadBufferData(IBufferResource* dst, size_t offset, size_t size, void* data) +void CommandQueueImpl::uploadBufferData( + IBufferResource* dst, + size_t offset, + size_t size, + void* data) { auto dstImpl = static_cast<BufferResourceImpl*>(dst); - cuMemcpy( - (CUdeviceptr)((uint8_t*)dstImpl->m_cudaMemory + offset), - (CUdeviceptr)data, - size); + cuMemcpy((CUdeviceptr)((uint8_t*)dstImpl->m_cudaMemory + offset), (CUdeviceptr)data, size); } void CommandQueueImpl::writeTimestamp(IQueryPool* pool, SlangInt index) @@ -185,12 +190,10 @@ void CommandQueueImpl::execute(CommandBufferImpl* commandBuffer) setPipelineState(commandBuffer->getObject<PipelineStateBase>(cmd.operands[0])); break; case CommandName::BindRootShaderObject: - bindRootShaderObject( - commandBuffer->getObject<ShaderObjectBase>(cmd.operands[0])); + bindRootShaderObject(commandBuffer->getObject<ShaderObjectBase>(cmd.operands[0])); break; case CommandName::DispatchCompute: - dispatchCompute( - int(cmd.operands[0]), int(cmd.operands[1]), int(cmd.operands[2])); + dispatchCompute(int(cmd.operands[0]), int(cmd.operands[1]), int(cmd.operands[2])); break; case CommandName::CopyBuffer: copyBuffer( diff --git a/tools/gfx/cuda/cuda-command-queue.h b/tools/gfx/cuda/cuda-command-queue.h index 10601890e..91d73b184 100644 --- a/tools/gfx/cuda/cuda-command-queue.h +++ b/tools/gfx/cuda/cuda-command-queue.h @@ -1,11 +1,10 @@ // cuda-command-queue.h #pragma once #include "cuda-base.h" - #include "cuda-device.h" +#include "cuda-helper-functions.h" #include "cuda-pipeline-state.h" #include "cuda-shader-object.h" -#include "cuda-helper-functions.h" namespace gfx { @@ -15,13 +14,11 @@ using namespace Slang; namespace cuda { -class CommandQueueImpl - : public ICommandQueue - , public ComObject +class CommandQueueImpl : public ICommandQueue, public ComObject { public: SLANG_COM_OBJECT_IUNKNOWN_ALL - ICommandQueue* getInterface(const Guid& guid); + ICommandQueue* getInterface(const Guid& guid); RefPtr<ComputePipelineStateImpl> currentPipeline; RefPtr<RootShaderObjectImpl> currentRootObject; @@ -35,12 +32,15 @@ public: virtual SLANG_NO_THROW const Desc& SLANG_MCALL getDesc() override { return m_desc; } virtual SLANG_NO_THROW void SLANG_MCALL executeCommandBuffers( - GfxCount count, ICommandBuffer* const* commandBuffers, IFence* fence, uint64_t valueToSignal) override; + GfxCount count, + ICommandBuffer* const* commandBuffers, + IFence* fence, + uint64_t valueToSignal) override; virtual SLANG_NO_THROW void SLANG_MCALL waitOnHost() override; - virtual SLANG_NO_THROW Result SLANG_MCALL waitForFenceValuesOnDevice( - GfxCount fenceCount, IFence** fences, uint64_t* waitValues) override; + virtual SLANG_NO_THROW Result SLANG_MCALL + waitForFenceValuesOnDevice(GfxCount fenceCount, IFence** fences, uint64_t* waitValues) override; virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(InteropHandle* outHandle) override; diff --git a/tools/gfx/cuda/cuda-device.cpp b/tools/gfx/cuda/cuda-device.cpp index b1b582d00..8162a20b8 100644 --- a/tools/gfx/cuda/cuda-device.cpp +++ b/tools/gfx/cuda/cuda-device.cpp @@ -5,10 +5,10 @@ #include "cuda-command-queue.h" #include "cuda-pipeline-state.h" #include "cuda-query.h" -#include "cuda-shader-object.h" +#include "cuda-resource-views.h" #include "cuda-shader-object-layout.h" +#include "cuda-shader-object.h" #include "cuda-shader-program.h" -#include "cuda-resource-views.h" #include "cuda-texture.h" namespace gfx @@ -42,7 +42,7 @@ int DeviceImpl::_calcSMCountPerMultiProcessor(int major, int minor) {0x62, 128}, {0x70, 64}, {0x72, 64}, - {0x75, 64} }; + {0x75, 64}}; const int sm = ((major << 4) + minor); for (Index i = 0; i < SLANG_COUNT_OF(infos); ++i) @@ -78,9 +78,12 @@ SlangResult DeviceImpl::_findMaxFlopsDeviceIndex(int* outDeviceIndex) CUdevice device; SLANG_CUDA_RETURN_ON_FAIL(cuDeviceGet(&device, currentDevice)); int computeMode = -1, major = 0, minor = 0; - SLANG_CUDA_RETURN_ON_FAIL(cuDeviceGetAttribute(&computeMode, CU_DEVICE_ATTRIBUTE_COMPUTE_MODE, device)); - SLANG_CUDA_RETURN_ON_FAIL(cuDeviceGetAttribute(&major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, device)); - SLANG_CUDA_RETURN_ON_FAIL(cuDeviceGetAttribute(&minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, device)); + SLANG_CUDA_RETURN_ON_FAIL( + cuDeviceGetAttribute(&computeMode, CU_DEVICE_ATTRIBUTE_COMPUTE_MODE, device)); + SLANG_CUDA_RETURN_ON_FAIL( + cuDeviceGetAttribute(&major, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, device)); + SLANG_CUDA_RETURN_ON_FAIL( + cuDeviceGetAttribute(&minor, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, device)); // If this GPU is not running on Compute Mode prohibited, // then we can add it to the list @@ -96,8 +99,12 @@ SlangResult DeviceImpl::_findMaxFlopsDeviceIndex(int* outDeviceIndex) } int multiProcessorCount = 0, clockRate = 0; - SLANG_CUDA_RETURN_ON_FAIL(cuDeviceGetAttribute(&multiProcessorCount, CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, device)); - SLANG_CUDA_RETURN_ON_FAIL(cuDeviceGetAttribute(&clockRate, CU_DEVICE_ATTRIBUTE_CLOCK_RATE, device)); + SLANG_CUDA_RETURN_ON_FAIL(cuDeviceGetAttribute( + &multiProcessorCount, + CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, + device)); + SLANG_CUDA_RETURN_ON_FAIL( + cuDeviceGetAttribute(&clockRate, CU_DEVICE_ATTRIBUTE_CLOCK_RATE, device)); uint64_t compute_perf = uint64_t(multiProcessorCount) * smPerMultiproc * clockRate; if (compute_perf > maxComputePerf) @@ -143,7 +150,7 @@ SLANG_NO_THROW SlangResult SLANG_MCALL DeviceImpl::initialize(const Desc& desc) desc.extendedDescs, SLANG_PTX, "sm_5_1", - makeArray(slang::PreprocessorMacroDesc{ "__CUDA_COMPUTE__", "1" }).getView())); + makeArray(slang::PreprocessorMacroDesc{"__CUDA_COMPUTE__", "1"}).getView())); SLANG_RETURN_ON_FAIL(RendererBase::initialize(desc)); @@ -174,12 +181,13 @@ SLANG_NO_THROW SlangResult SLANG_MCALL DeviceImpl::initialize(const Desc& desc) SLANG_CUDA_RETURN_ON_FAIL(cuDeviceGet(&m_device, m_deviceIndex)); SLANG_CUDA_RETURN_WITH_REPORT_ON_FAIL( - cuCtxCreate(&m_context->m_context, 0, m_device), reportType); + cuCtxCreate(&m_context->m_context, 0, m_device), + reportType); { // Not clear how to detect half support on CUDA. For now we'll assume we have it m_features.add("half"); - + // CUDA has support for realtime clock m_features.add("realtime-clock"); @@ -193,7 +201,7 @@ SLANG_NO_THROW SlangResult SLANG_MCALL DeviceImpl::initialize(const Desc& desc) m_info.bindingStyle = BindingStyle::CUDA; m_info.projectionStyle = ProjectionStyle::DirectX; m_info.apiName = "CUDA"; - static const float kIdentity[] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; + static const float kIdentity[] = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1}; ::memcpy(m_info.identityProjectionMatrix, kIdentity, sizeof(kIdentity)); char deviceName[256]; cuDeviceGetName(deviceName, sizeof(deviceName), m_device); @@ -225,7 +233,8 @@ SLANG_NO_THROW SlangResult SLANG_MCALL DeviceImpl::initialize(const Desc& desc) Math::Min( getAttribute(CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_HEIGHT), getAttribute(CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE3D_DEPTH))); - limits.maxTextureDimensionCube = getAttribute(CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_WIDTH); + limits.maxTextureDimensionCube = + getAttribute(CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACECUBEMAP_WIDTH); limits.maxTextureArrayLayers = Math::Min( getAttribute(CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE1D_LAYERED_LAYERS), getAttribute(CU_DEVICE_ATTRIBUTE_MAXIMUM_SURFACE2D_LAYERED_LAYERS)); @@ -266,47 +275,31 @@ Result DeviceImpl::getCUDAFormat(Format format, CUarray_format* outFormat) case Format::R32G32B32_FLOAT: case Format::R32G32_FLOAT: case Format::R32_FLOAT: - case Format::D32_FLOAT: - *outFormat = CU_AD_FORMAT_FLOAT; - return SLANG_OK; + case Format::D32_FLOAT: *outFormat = CU_AD_FORMAT_FLOAT; return SLANG_OK; case Format::R16G16B16A16_FLOAT: case Format::R16G16_FLOAT: - case Format::R16_FLOAT: - *outFormat = CU_AD_FORMAT_HALF; - return SLANG_OK; + case Format::R16_FLOAT: *outFormat = CU_AD_FORMAT_HALF; return SLANG_OK; case Format::R32G32B32A32_UINT: case Format::R32G32B32_UINT: case Format::R32G32_UINT: - case Format::R32_UINT: - *outFormat = CU_AD_FORMAT_UNSIGNED_INT32; - return SLANG_OK; + case Format::R32_UINT: *outFormat = CU_AD_FORMAT_UNSIGNED_INT32; return SLANG_OK; case Format::R16G16B16A16_UINT: case Format::R16G16_UINT: - case Format::R16_UINT: - *outFormat = CU_AD_FORMAT_UNSIGNED_INT16; - return SLANG_OK; + case Format::R16_UINT: *outFormat = CU_AD_FORMAT_UNSIGNED_INT16; return SLANG_OK; case Format::R8G8B8A8_UINT: case Format::R8G8_UINT: case Format::R8_UINT: - case Format::R8G8B8A8_UNORM: - *outFormat = CU_AD_FORMAT_UNSIGNED_INT8; - return SLANG_OK; + case Format::R8G8B8A8_UNORM: *outFormat = CU_AD_FORMAT_UNSIGNED_INT8; return SLANG_OK; case Format::R32G32B32A32_SINT: case Format::R32G32B32_SINT: case Format::R32G32_SINT: - case Format::R32_SINT: - *outFormat = CU_AD_FORMAT_SIGNED_INT32; - return SLANG_OK; + case Format::R32_SINT: *outFormat = CU_AD_FORMAT_SIGNED_INT32; return SLANG_OK; case Format::R16G16B16A16_SINT: case Format::R16G16_SINT: - case Format::R16_SINT: - *outFormat = CU_AD_FORMAT_SIGNED_INT16; - return SLANG_OK; + case Format::R16_SINT: *outFormat = CU_AD_FORMAT_SIGNED_INT16; return SLANG_OK; case Format::R8G8B8A8_SINT: case Format::R8G8_SINT: - case Format::R8_SINT: - *outFormat = CU_AD_FORMAT_SIGNED_INT8; - return SLANG_OK; + case Format::R8_SINT: *outFormat = CU_AD_FORMAT_SIGNED_INT8; return SLANG_OK; default: SLANG_ASSERT(!"Only support R32_FLOAT/R8G8B8A8_UNORM formats for now"); return SLANG_FAIL; @@ -348,16 +341,11 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createTextureResource( depth = 0; break; - case IResource::Type::Texture2D: - depth = 0; - break; + case IResource::Type::Texture2D: depth = 0; break; - case IResource::Type::Texture3D: - break; + case IResource::Type::Texture3D: break; - case IResource::Type::TextureCube: - depth = 1; - break; + case IResource::Type::TextureCube: depth = 1; break; } { @@ -372,25 +360,25 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createTextureResource( switch (format) { case CU_AD_FORMAT_FLOAT: - { - elementSize = sizeof(float) * numChannels; - break; - } + { + elementSize = sizeof(float) * numChannels; + break; + } case CU_AD_FORMAT_HALF: - { - elementSize = sizeof(uint16_t) * numChannels; - break; - } + { + elementSize = sizeof(uint16_t) * numChannels; + break; + } case CU_AD_FORMAT_UNSIGNED_INT8: - { - elementSize = sizeof(uint8_t) * numChannels; - break; - } + { + elementSize = sizeof(uint8_t) * numChannels; + break; + } default: - { - SLANG_ASSERT(!"Only support R32_FLOAT/R8G8B8A8_UNORM formats for now"); - return SLANG_FAIL; - } + { + SLANG_ASSERT(!"Only support R32_FLOAT/R8G8B8A8_UNORM formats for now"); + return SLANG_FAIL; + } } if (desc.numMipLevels > 1) @@ -468,7 +456,8 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createTextureResource( SLANG_CUDA_RETURN_ON_FAIL(cuArray3DCreate(&tex->m_cudaArray, &arrayDesc)); } - else if (desc.type == IResource::Type::Texture3D || + else if ( + desc.type == IResource::Type::Texture3D || desc.type == IResource::Type::TextureCube) { CUDA_ARRAY3D_DESCRIPTOR arrayDesc; @@ -574,8 +563,7 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createTextureResource( { const auto srcData = initData[mipLevel + j * desc.numMipLevels].data; // Copy over to the workspace to make contiguous - ::memcpy( - workspace.begin() + faceSizeInBytes * j, srcData, faceSizeInBytes); + ::memcpy(workspace.begin() + faceSizeInBytes * j, srcData, faceSizeInBytes); } srcDataPtr = workspace.getBuffer(); @@ -590,8 +578,7 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createTextureResource( // Copy the data over to make contiguous for (Index j = 0; j < 6; j++) { - const auto srcData = - initData[mipLevel + j * desc.numMipLevels].data; + const auto srcData = initData[mipLevel + j * desc.numMipLevels].data; ::memcpy( workspace.getBuffer() + faceSizeInBytes * j, srcData, @@ -640,44 +627,44 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createTextureResource( { case IResource::Type::Texture1D: case IResource::Type::Texture2D: - { - CUDA_MEMCPY2D copyParam; - memset(©Param, 0, sizeof(copyParam)); - copyParam.dstMemoryType = CU_MEMORYTYPE_ARRAY; - copyParam.dstArray = dstArray; - copyParam.srcMemoryType = CU_MEMORYTYPE_HOST; - copyParam.srcHost = srcDataPtr; - copyParam.srcPitch = mipWidth * elementSize; - copyParam.WidthInBytes = copyParam.srcPitch; - copyParam.Height = mipHeight; - SLANG_CUDA_RETURN_ON_FAIL(cuMemcpy2D(©Param)); - break; - } + { + CUDA_MEMCPY2D copyParam; + memset(©Param, 0, sizeof(copyParam)); + copyParam.dstMemoryType = CU_MEMORYTYPE_ARRAY; + copyParam.dstArray = dstArray; + copyParam.srcMemoryType = CU_MEMORYTYPE_HOST; + copyParam.srcHost = srcDataPtr; + copyParam.srcPitch = mipWidth * elementSize; + copyParam.WidthInBytes = copyParam.srcPitch; + copyParam.Height = mipHeight; + SLANG_CUDA_RETURN_ON_FAIL(cuMemcpy2D(©Param)); + break; + } case IResource::Type::Texture3D: case IResource::Type::TextureCube: - { - CUDA_MEMCPY3D copyParam; - memset(©Param, 0, sizeof(copyParam)); + { + CUDA_MEMCPY3D copyParam; + memset(©Param, 0, sizeof(copyParam)); - copyParam.dstMemoryType = CU_MEMORYTYPE_ARRAY; - copyParam.dstArray = dstArray; + copyParam.dstMemoryType = CU_MEMORYTYPE_ARRAY; + copyParam.dstArray = dstArray; - copyParam.srcMemoryType = CU_MEMORYTYPE_HOST; - copyParam.srcHost = srcDataPtr; - copyParam.srcPitch = mipWidth * elementSize; - copyParam.WidthInBytes = copyParam.srcPitch; - copyParam.Height = mipHeight; - copyParam.Depth = mipDepth; + copyParam.srcMemoryType = CU_MEMORYTYPE_HOST; + copyParam.srcHost = srcDataPtr; + copyParam.srcPitch = mipWidth * elementSize; + copyParam.WidthInBytes = copyParam.srcPitch; + copyParam.Height = mipHeight; + copyParam.Depth = mipDepth; - SLANG_CUDA_RETURN_ON_FAIL(cuMemcpy3D(©Param)); - break; - } + SLANG_CUDA_RETURN_ON_FAIL(cuMemcpy3D(©Param)); + break; + } default: - { - SLANG_ASSERT(!"Not implemented"); - break; - } + { + SLANG_ASSERT(!"Not implemented"); + break; + } } } } @@ -749,10 +736,8 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createBufferResource( CU_MEM_ATTACH_GLOBAL)); if (initData) { - SLANG_CUDA_RETURN_ON_FAIL(cuMemcpy( - (CUdeviceptr)resource->m_cudaMemory, - (CUdeviceptr)initData, - desc.sizeInBytes)); + SLANG_CUDA_RETURN_ON_FAIL( + cuMemcpy((CUdeviceptr)resource->m_cudaMemory, (CUdeviceptr)initData, desc.sizeInBytes)); } returnComPtr(outResource, resource); return SLANG_OK; @@ -786,8 +771,7 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createBufferFromSharedHandle( case InteropHandleAPI::Vulkan: externalMemoryHandleDesc.type = CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32; break; - default: - return SLANG_FAIL; + default: return SLANG_FAIL; } externalMemoryHandleDesc.handle.win32.handle = (void*)handle.handleValue; externalMemoryHandleDesc.size = desc.sizeInBytes; @@ -813,7 +797,8 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createBufferFromSharedHandle( // Finally, we can "map" the buffer to get a device address. void* deviceAddress; - SLANG_CUDA_RETURN_ON_FAIL(cuExternalMemoryGetMappedBuffer((CUdeviceptr*)&deviceAddress, externalMemory, &bufferDesc)); + SLANG_CUDA_RETURN_ON_FAIL( + cuExternalMemoryGetMappedBuffer((CUdeviceptr*)&deviceAddress, externalMemory, &bufferDesc)); resource->m_cudaMemory = deviceAddress; returnComPtr(outResource, resource); @@ -849,8 +834,7 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createTextureFromSharedHandle( case InteropHandleAPI::Vulkan: externalMemoryHandleDesc.type = CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_WIN32; break; - default: - return SLANG_FAIL; + default: return SLANG_FAIL; } externalMemoryHandleDesc.handle.win32.handle = (void*)handle.handleValue; externalMemoryHandleDesc.size = size; @@ -877,7 +861,8 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createTextureFromSharedHandle( externalMemoryMipDesc.numLevels = desc.numMipLevels; CUmipmappedArray mipArray; - SLANG_CUDA_RETURN_ON_FAIL(cuExternalMemoryGetMappedMipmappedArray(&mipArray, externalMemory, &externalMemoryMipDesc)); + SLANG_CUDA_RETURN_ON_FAIL( + cuExternalMemoryGetMappedMipmappedArray(&mipArray, externalMemory, &externalMemoryMipDesc)); resource->m_cudaMipMappedArray = mipArray; CUarray cuArray; @@ -898,7 +883,9 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createTextureFromSharedHandle( } SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createTextureView( - ITextureResource* texture, IResourceView::Desc const& desc, IResourceView** outView) + ITextureResource* texture, + IResourceView::Desc const& desc, + IResourceView** outView) { RefPtr<ResourceViewImpl> view = new ResourceViewImpl(); view->m_desc = desc; @@ -920,9 +907,8 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createBufferView( return SLANG_OK; } -SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createQueryPool( - const IQueryPool::Desc& desc, - IQueryPool** outPool) +SLANG_NO_THROW Result SLANG_MCALL +DeviceImpl::createQueryPool(const IQueryPool::Desc& desc, IQueryPool** outPool) { RefPtr<QueryPoolImpl> pool = new QueryPoolImpl(); SLANG_RETURN_ON_FAIL(pool->init(desc)); @@ -941,9 +927,7 @@ Result DeviceImpl::createShaderObjectLayout( return SLANG_OK; } -Result DeviceImpl::createShaderObject( - ShaderObjectLayoutBase* layout, - IShaderObject** outObject) +Result DeviceImpl::createShaderObject(ShaderObjectLayoutBase* layout, IShaderObject** outObject) { RefPtr<ShaderObjectImpl> result = new ShaderObjectImpl(); SLANG_RETURN_ON_FAIL(result->init(this, dynamic_cast<ShaderObjectLayoutImpl*>(layout))); @@ -985,15 +969,20 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createProgram( cudaProgram->cudaContext = m_context; if (desc.slangGlobalScope->getSpecializationParamCount() != 0) { - cudaProgram->layout = new RootShaderObjectLayoutImpl(this, desc.slangGlobalScope->getLayout()); + cudaProgram->layout = + new RootShaderObjectLayoutImpl(this, desc.slangGlobalScope->getLayout()); returnComPtr(outProgram, cudaProgram); return SLANG_OK; } ComPtr<ISlangBlob> kernelCode; ComPtr<ISlangBlob> diagnostics; - auto compileResult = getEntryPointCodeFromShaderCache(desc.slangGlobalScope, - (SlangInt)0, 0, kernelCode.writeRef(), diagnostics.writeRef()); + auto compileResult = getEntryPointCodeFromShaderCache( + desc.slangGlobalScope, + (SlangInt)0, + 0, + kernelCode.writeRef(), + diagnostics.writeRef()); if (diagnostics) { getDebugCallback()->handleMessage( @@ -1005,10 +994,14 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createProgram( } SLANG_RETURN_ON_FAIL(compileResult); - SLANG_CUDA_RETURN_ON_FAIL(cuModuleLoadData(&cudaProgram->cudaModule, kernelCode->getBufferPointer())); - cudaProgram->kernelName = desc.slangGlobalScope->getLayout()->getEntryPointByIndex(0)->getName(); + SLANG_CUDA_RETURN_ON_FAIL( + cuModuleLoadData(&cudaProgram->cudaModule, kernelCode->getBufferPointer())); + cudaProgram->kernelName = + desc.slangGlobalScope->getLayout()->getEntryPointByIndex(0)->getName(); SLANG_CUDA_RETURN_ON_FAIL(cuModuleGetFunction( - &cudaProgram->cudaKernel, cudaProgram->cudaModule, cudaProgram->kernelName.getBuffer())); + &cudaProgram->cudaKernel, + cudaProgram->cudaModule, + cudaProgram->kernelName.getBuffer())); auto slangGlobalScope = desc.slangGlobalScope; if (slangGlobalScope) @@ -1030,7 +1023,8 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createProgram( } SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createComputePipelineState( - const ComputePipelineStateDesc& desc, IPipelineState** outState) + const ComputePipelineStateDesc& desc, + IPipelineState** outState) { RefPtr<ComputePipelineStateImpl> state = new ComputePipelineStateImpl(); state->shaderProgram = static_cast<ShaderProgramImpl*>(desc.program); @@ -1065,7 +1059,7 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createTransientResourceHeap( } SLANG_NO_THROW Result SLANG_MCALL - DeviceImpl::createCommandQueue(const ICommandQueue::Desc& desc, ICommandQueue** outQueue) +DeviceImpl::createCommandQueue(const ICommandQueue::Desc& desc, ICommandQueue** outQueue) { RefPtr<CommandQueueImpl> queue = new CommandQueueImpl(); queue->init(this); @@ -1074,7 +1068,9 @@ SLANG_NO_THROW Result SLANG_MCALL } SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createSwapchain( - const ISwapchain::Desc& desc, WindowHandle window, ISwapchain** outSwapchain) + const ISwapchain::Desc& desc, + WindowHandle window, + ISwapchain** outSwapchain) { SLANG_UNUSED(desc); SLANG_UNUSED(window); @@ -1083,7 +1079,8 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createSwapchain( } SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createFramebufferLayout( - const IFramebufferLayout::Desc& desc, IFramebufferLayout** outLayout) + const IFramebufferLayout::Desc& desc, + IFramebufferLayout** outLayout) { SLANG_UNUSED(desc); SLANG_UNUSED(outLayout); @@ -1091,7 +1088,7 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createFramebufferLayout( } SLANG_NO_THROW Result SLANG_MCALL - DeviceImpl::createFramebuffer(const IFramebuffer::Desc& desc, IFramebuffer** outFramebuffer) +DeviceImpl::createFramebuffer(const IFramebuffer::Desc& desc, IFramebuffer** outFramebuffer) { SLANG_UNUSED(desc); SLANG_UNUSED(outFramebuffer); @@ -1108,16 +1105,15 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createRenderPassLayout( } SLANG_NO_THROW Result SLANG_MCALL - DeviceImpl::createSamplerState(ISamplerState::Desc const& desc, ISamplerState** outSampler) +DeviceImpl::createSamplerState(ISamplerState::Desc const& desc, ISamplerState** outSampler) { SLANG_UNUSED(desc); *outSampler = nullptr; return SLANG_OK; } -SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createInputLayout( - IInputLayout::Desc const& desc, - IInputLayout** outLayout) +SLANG_NO_THROW Result SLANG_MCALL +DeviceImpl::createInputLayout(IInputLayout::Desc const& desc, IInputLayout** outLayout) { SLANG_UNUSED(desc); SLANG_UNUSED(outLayout); @@ -1125,7 +1121,8 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createInputLayout( } SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createGraphicsPipelineState( - const GraphicsPipelineStateDesc& desc, IPipelineState** outState) + const GraphicsPipelineStateDesc& desc, + IPipelineState** outState) { SLANG_UNUSED(desc); SLANG_UNUSED(outState); diff --git a/tools/gfx/cuda/cuda-device.h b/tools/gfx/cuda/cuda-device.h index e711dc261..a21333ab6 100644 --- a/tools/gfx/cuda/cuda-device.h +++ b/tools/gfx/cuda/cuda-device.h @@ -1,7 +1,6 @@ // cuda-device.h #pragma once #include "cuda-base.h" - #include "cuda-command-buffer.h" #include "cuda-context.h" #include "cuda-helper-functions.h" @@ -32,7 +31,8 @@ private: String m_adapterName; public: - virtual SLANG_NO_THROW Result SLANG_MCALL getNativeDeviceHandles(InteropHandles* outHandles) override; + virtual SLANG_NO_THROW Result SLANG_MCALL + getNativeDeviceHandles(InteropHandles* outHandles) override; virtual SLANG_NO_THROW SlangResult SLANG_MCALL initialize(const Desc& desc) override; @@ -60,7 +60,9 @@ public: ITextureResource** outResource) override; virtual SLANG_NO_THROW Result SLANG_MCALL createTextureView( - ITextureResource* texture, IResourceView::Desc const& desc, IResourceView** outView) override; + ITextureResource* texture, + IResourceView::Desc const& desc, + IResourceView** outView) override; virtual SLANG_NO_THROW Result SLANG_MCALL createBufferView( IBufferResource* buffer, @@ -68,18 +70,16 @@ public: IResourceView::Desc const& desc, IResourceView** outView) override; - virtual SLANG_NO_THROW Result SLANG_MCALL createQueryPool( - const IQueryPool::Desc& desc, - IQueryPool** outPool) override; + virtual SLANG_NO_THROW Result SLANG_MCALL + createQueryPool(const IQueryPool::Desc& desc, IQueryPool** outPool) override; virtual Result createShaderObjectLayout( slang::ISession* session, slang::TypeLayoutReflection* typeLayout, ShaderObjectLayoutBase** outLayout) override; - virtual Result createShaderObject( - ShaderObjectLayoutBase* layout, - IShaderObject** outObject) override; + virtual Result createShaderObject(ShaderObjectLayoutBase* layout, IShaderObject** outObject) + override; virtual Result createMutableShaderObject( ShaderObjectLayoutBase* layout, @@ -93,7 +93,8 @@ public: ISlangBlob** outDiagnosticBlob) override; virtual SLANG_NO_THROW Result SLANG_MCALL createComputePipelineState( - const ComputePipelineStateDesc& desc, IPipelineState** outState) override; + const ComputePipelineStateDesc& desc, + IPipelineState** outState) override; void* map(IBufferResource* buffer); @@ -109,30 +110,33 @@ public: ITransientResourceHeap** outHeap) override; virtual SLANG_NO_THROW Result SLANG_MCALL - createCommandQueue(const ICommandQueue::Desc& desc, ICommandQueue** outQueue) override; + createCommandQueue(const ICommandQueue::Desc& desc, ICommandQueue** outQueue) override; virtual SLANG_NO_THROW Result SLANG_MCALL createSwapchain( - const ISwapchain::Desc& desc, WindowHandle window, ISwapchain** outSwapchain) override; + const ISwapchain::Desc& desc, + WindowHandle window, + ISwapchain** outSwapchain) override; virtual SLANG_NO_THROW Result SLANG_MCALL createFramebufferLayout( - const IFramebufferLayout::Desc& desc, IFramebufferLayout** outLayout) override; + const IFramebufferLayout::Desc& desc, + IFramebufferLayout** outLayout) override; virtual SLANG_NO_THROW Result SLANG_MCALL - createFramebuffer(const IFramebuffer::Desc& desc, IFramebuffer** outFramebuffer) override; + createFramebuffer(const IFramebuffer::Desc& desc, IFramebuffer** outFramebuffer) override; virtual SLANG_NO_THROW Result SLANG_MCALL createRenderPassLayout( const IRenderPassLayout::Desc& desc, IRenderPassLayout** outRenderPassLayout) override; virtual SLANG_NO_THROW Result SLANG_MCALL - createSamplerState(ISamplerState::Desc const& desc, ISamplerState** outSampler) override; - - virtual SLANG_NO_THROW Result SLANG_MCALL createInputLayout( - IInputLayout::Desc const& desc, - IInputLayout** outLayout) override; + createSamplerState(ISamplerState::Desc const& desc, ISamplerState** outSampler) override; + + virtual SLANG_NO_THROW Result SLANG_MCALL + createInputLayout(IInputLayout::Desc const& desc, IInputLayout** outLayout) override; virtual SLANG_NO_THROW Result SLANG_MCALL createGraphicsPipelineState( - const GraphicsPipelineStateDesc& desc, IPipelineState** outState) override; + const GraphicsPipelineStateDesc& desc, + IPipelineState** outState) override; virtual SLANG_NO_THROW SlangResult SLANG_MCALL readTextureResource( ITextureResource* texture, diff --git a/tools/gfx/cuda/cuda-helper-functions.cpp b/tools/gfx/cuda/cuda-helper-functions.cpp index d478e8815..9fb69d620 100644 --- a/tools/gfx/cuda/cuda-helper-functions.cpp +++ b/tools/gfx/cuda/cuda-helper-functions.cpp @@ -24,7 +24,9 @@ SlangResult CUDAErrorInfo::handle() const builder << m_errorString; } - getDebugCallback()->handleMessage(DebugMessageType::Error, DebugMessageSource::Driver, + getDebugCallback()->handleMessage( + DebugMessageType::Error, + DebugMessageSource::Driver, builder.getUnownedSlice().begin()); // Slang::signalUnexpectedError(builder.getBuffer()); @@ -39,14 +41,14 @@ SlangResult _handleCUDAError(CUresult cuResult, const char* file, int line) return info.handle(); } -# ifdef RENDER_TEST_OPTIX +#ifdef RENDER_TEST_OPTIX static bool _isError(OptixResult result) { return result != OPTIX_SUCCESS; } -# if 1 +#if 1 static SlangResult _handleOptixError(OptixResult result, char const* file, int line) { fprintf( @@ -63,8 +65,8 @@ void _optixLogCallback(unsigned int level, const char* tag, const char* message, { fprintf(stderr, "optix: %s (%s)\n", message, tag); } -# endif -# endif +#endif +#endif AdapterLUID getAdapterLUID(int deviceIndex) { diff --git a/tools/gfx/cuda/cuda-helper-functions.h b/tools/gfx/cuda/cuda-helper-functions.h index 2217c727c..8474e830d 100644 --- a/tools/gfx/cuda/cuda-helper-functions.h +++ b/tools/gfx/cuda/cuda-helper-functions.h @@ -1,9 +1,9 @@ // cuda-helper-functions.h #pragma once -#include "slang-gfx.h" -#include "cuda-base.h" #include "../../../source/core/slang-list.h" +#include "cuda-base.h" +#include "slang-gfx.h" namespace gfx { @@ -12,7 +12,10 @@ using namespace Slang; #ifdef GFX_ENABLE_CUDA namespace cuda { -SLANG_FORCE_INLINE bool _isError(CUresult result) { return result != 0; } +SLANG_FORCE_INLINE bool _isError(CUresult result) +{ + return result != 0; +} // A enum used to control if errors are reported on failure of CUDA call. enum class CUDAReportStyle @@ -28,11 +31,9 @@ struct CUDAErrorInfo int lineNo, const char* errorName = nullptr, const char* errorString = nullptr) - : m_filePath(filePath) - , m_lineNo(lineNo) - , m_errorName(errorName) - , m_errorString(errorString) - {} + : m_filePath(filePath), m_lineNo(lineNo), m_errorName(errorName), m_errorString(errorString) + { + } SlangResult handle() const; const char* m_filePath; @@ -45,57 +46,56 @@ struct CUDAErrorInfo SlangResult _handleCUDAError(CUresult cuResult, const char* file, int line); -# define SLANG_CUDA_HANDLE_ERROR(x) _handleCUDAError(x, __FILE__, __LINE__) - -# define SLANG_CUDA_RETURN_ON_FAIL(x) \ - { \ - auto _res = x; \ - if (_isError(_res)) \ - return SLANG_CUDA_HANDLE_ERROR(_res); \ - } - -# define SLANG_CUDA_RETURN_WITH_REPORT_ON_FAIL(x, r) \ - { \ - auto _res = x; \ - if (_isError(_res)) \ - { \ - return (r == CUDAReportStyle::Normal) ? SLANG_CUDA_HANDLE_ERROR(_res) \ - : SLANG_FAIL; \ - } \ - } - -# define SLANG_CUDA_ASSERT_ON_FAIL(x) \ - { \ - auto _res = x; \ - if (_isError(_res)) \ - { \ - SLANG_ASSERT(!"Failed CUDA call"); \ - }; \ - } - -# ifdef RENDER_TEST_OPTIX +#define SLANG_CUDA_HANDLE_ERROR(x) _handleCUDAError(x, __FILE__, __LINE__) + +#define SLANG_CUDA_RETURN_ON_FAIL(x) \ + { \ + auto _res = x; \ + if (_isError(_res)) \ + return SLANG_CUDA_HANDLE_ERROR(_res); \ + } + +#define SLANG_CUDA_RETURN_WITH_REPORT_ON_FAIL(x, r) \ + { \ + auto _res = x; \ + if (_isError(_res)) \ + { \ + return (r == CUDAReportStyle::Normal) ? SLANG_CUDA_HANDLE_ERROR(_res) : SLANG_FAIL; \ + } \ + } + +#define SLANG_CUDA_ASSERT_ON_FAIL(x) \ + { \ + auto _res = x; \ + if (_isError(_res)) \ + { \ + SLANG_ASSERT(!"Failed CUDA call"); \ + }; \ + } + +#ifdef RENDER_TEST_OPTIX bool _isError(OptixResult result); -# if 1 +#if 1 SlangResult _handleOptixError(OptixResult result, char const* file, int line); -# define SLANG_OPTIX_HANDLE_ERROR(RESULT) _handleOptixError(RESULT, __FILE__, __LINE__) -# else -# define SLANG_OPTIX_HANDLE_ERROR(RESULT) SLANG_FAIL -# endif +#define SLANG_OPTIX_HANDLE_ERROR(RESULT) _handleOptixError(RESULT, __FILE__, __LINE__) +#else +#define SLANG_OPTIX_HANDLE_ERROR(RESULT) SLANG_FAIL +#endif -# define SLANG_OPTIX_RETURN_ON_FAIL(EXPR) \ - do \ - { \ - auto _res = EXPR; \ - if (_isError(_res)) \ - return SLANG_OPTIX_HANDLE_ERROR(_res); \ - } while (0) +#define SLANG_OPTIX_RETURN_ON_FAIL(EXPR) \ + do \ + { \ + auto _res = EXPR; \ + if (_isError(_res)) \ + return SLANG_OPTIX_HANDLE_ERROR(_res); \ + } while (0) void _optixLogCallback(unsigned int level, const char* tag, const char* message, void* userData); -# endif +#endif AdapterLUID getAdapterLUID(int deviceIndex); diff --git a/tools/gfx/cuda/cuda-query.cpp b/tools/gfx/cuda/cuda-query.cpp index 7e97699f8..a671d43fb 100644 --- a/tools/gfx/cuda/cuda-query.cpp +++ b/tools/gfx/cuda/cuda-query.cpp @@ -30,8 +30,8 @@ QueryPoolImpl::~QueryPoolImpl() cuEventDestroy(m_startEvent); } -SLANG_NO_THROW Result SLANG_MCALL QueryPoolImpl::getResult( - GfxIndex queryIndex, GfxCount count, uint64_t* data) +SLANG_NO_THROW Result SLANG_MCALL +QueryPoolImpl::getResult(GfxIndex queryIndex, GfxCount count, uint64_t* data) { for (GfxIndex i = 0; i < count; i++) { diff --git a/tools/gfx/cuda/cuda-query.h b/tools/gfx/cuda/cuda-query.h index db29f488d..04d7edc43 100644 --- a/tools/gfx/cuda/cuda-query.h +++ b/tools/gfx/cuda/cuda-query.h @@ -23,8 +23,8 @@ public: ~QueryPoolImpl(); - virtual SLANG_NO_THROW Result SLANG_MCALL getResult( - GfxIndex queryIndex, GfxCount count, uint64_t* data) override; + virtual SLANG_NO_THROW Result SLANG_MCALL + getResult(GfxIndex queryIndex, GfxCount count, uint64_t* data) override; }; } // namespace cuda diff --git a/tools/gfx/cuda/cuda-resource-views.h b/tools/gfx/cuda/cuda-resource-views.h index 33bf557d7..b2f0441fe 100644 --- a/tools/gfx/cuda/cuda-resource-views.h +++ b/tools/gfx/cuda/cuda-resource-views.h @@ -1,7 +1,6 @@ // cuda-resource-views.h #pragma once #include "cuda-base.h" - #include "cuda-buffer.h" #include "cuda-texture.h" diff --git a/tools/gfx/cuda/cuda-shader-object-layout.cpp b/tools/gfx/cuda/cuda-shader-object-layout.cpp index f527d78de..d00855972 100644 --- a/tools/gfx/cuda/cuda-shader-object-layout.cpp +++ b/tools/gfx/cuda/cuda-shader-object-layout.cpp @@ -9,7 +9,10 @@ using namespace Slang; namespace cuda { -ShaderObjectLayoutImpl::ShaderObjectLayoutImpl(RendererBase* renderer, slang::ISession* session, slang::TypeLayoutReflection* layout) +ShaderObjectLayoutImpl::ShaderObjectLayoutImpl( + RendererBase* renderer, + slang::ISession* session, + slang::TypeLayoutReflection* layout) { m_elementTypeLayout = _unwrapParameterGroups(layout, m_containerType); @@ -41,7 +44,8 @@ ShaderObjectLayoutImpl::ShaderObjectLayoutImpl(RendererBase* renderer, slang::IS // linear search over the descriptor ranges for a specific binding range. // auto uniformOffset = m_elementTypeLayout->getDescriptorSetDescriptorRangeIndexOffset( - descriptorSetIndex, rangeIndexInDescriptorSet); + descriptorSetIndex, + rangeIndexInDescriptorSet); Index baseIndex = 0; Index subObjectIndex = 0; @@ -79,7 +83,7 @@ ShaderObjectLayoutImpl::ShaderObjectLayoutImpl(RendererBase* renderer, slang::IS bindingRangeInfo.uniformOffset = uniformOffset; bindingRangeInfo.subObjectIndex = subObjectIndex; bindingRangeInfo.isSpecializable = m_elementTypeLayout->isBindingRangeSpecializable(r); - m_bindingRanges.add(bindingRangeInfo); + m_bindingRanges.add(bindingRangeInfo); } SlangInt subObjectRangeCount = m_elementTypeLayout->getSubObjectRangeCount(); @@ -100,8 +104,10 @@ ShaderObjectLayoutImpl::ShaderObjectLayoutImpl(RendererBase* renderer, slang::IS RefPtr<ShaderObjectLayoutImpl> subObjectLayout; if (slangBindingType != slang::BindingType::ExistentialValue) { - subObjectLayout = - new ShaderObjectLayoutImpl(renderer, session, slangLeafTypeLayout->getElementTypeLayout()); + subObjectLayout = new ShaderObjectLayoutImpl( + renderer, + session, + slangLeafTypeLayout->getElementTypeLayout()); } SubObjectRangeInfo subObjectRange; @@ -111,14 +117,34 @@ ShaderObjectLayoutImpl::ShaderObjectLayoutImpl(RendererBase* renderer, slang::IS } } -Index ShaderObjectLayoutImpl::getResourceCount() const { return m_resourceCount; } -Index ShaderObjectLayoutImpl::getSubObjectCount() const { return m_subObjectCount; } -List<SubObjectRangeInfo>& ShaderObjectLayoutImpl::getSubObjectRanges() { return subObjectRanges; } -BindingRangeInfo ShaderObjectLayoutImpl::getBindingRange(Index index) { return m_bindingRanges[index]; } -Index ShaderObjectLayoutImpl::getBindingRangeCount() const { return m_bindingRanges.getCount(); } +Index ShaderObjectLayoutImpl::getResourceCount() const +{ + return m_resourceCount; +} +Index ShaderObjectLayoutImpl::getSubObjectCount() const +{ + return m_subObjectCount; +} +List<SubObjectRangeInfo>& ShaderObjectLayoutImpl::getSubObjectRanges() +{ + return subObjectRanges; +} +BindingRangeInfo ShaderObjectLayoutImpl::getBindingRange(Index index) +{ + return m_bindingRanges[index]; +} +Index ShaderObjectLayoutImpl::getBindingRangeCount() const +{ + return m_bindingRanges.getCount(); +} -RootShaderObjectLayoutImpl::RootShaderObjectLayoutImpl(RendererBase* renderer, slang::ProgramLayout* inProgramLayout) - : ShaderObjectLayoutImpl(renderer, inProgramLayout->getSession(), inProgramLayout->getGlobalParamsTypeLayout()) +RootShaderObjectLayoutImpl::RootShaderObjectLayoutImpl( + RendererBase* renderer, + slang::ProgramLayout* inProgramLayout) + : ShaderObjectLayoutImpl( + renderer, + inProgramLayout->getSession(), + inProgramLayout->getGlobalParamsTypeLayout()) , programLayout(inProgramLayout) { for (UInt i = 0; i < programLayout->getEntryPointCount(); i++) @@ -128,7 +154,6 @@ RootShaderObjectLayoutImpl::RootShaderObjectLayoutImpl(RendererBase* renderer, s programLayout->getSession(), programLayout->getEntryPointByIndex(i)->getTypeLayout())); } - } int RootShaderObjectLayoutImpl::getKernelIndex(UnownedStringSlice kernelName) diff --git a/tools/gfx/cuda/cuda-shader-object-layout.h b/tools/gfx/cuda/cuda-shader-object-layout.h index edec0c352..4830fe975 100644 --- a/tools/gfx/cuda/cuda-shader-object-layout.h +++ b/tools/gfx/cuda/cuda-shader-object-layout.h @@ -50,7 +50,10 @@ public: Index m_subObjectCount = 0; Index m_resourceCount = 0; - ShaderObjectLayoutImpl(RendererBase* renderer, slang::ISession* session, slang::TypeLayoutReflection* layout); + ShaderObjectLayoutImpl( + RendererBase* renderer, + slang::ISession* session, + slang::TypeLayoutReflection* layout); Index getResourceCount() const; Index getSubObjectCount() const; diff --git a/tools/gfx/cuda/cuda-shader-object.cpp b/tools/gfx/cuda/cuda-shader-object.cpp index 02b4cf695..e7033e403 100644 --- a/tools/gfx/cuda/cuda-shader-object.cpp +++ b/tools/gfx/cuda/cuda-shader-object.cpp @@ -1,10 +1,9 @@ // cuda-shader-object.cpp #include "cuda-shader-object.h" -#include "cuda-shader-object-layout.h" -#include "cuda-resource-views.h" - #include "cuda-helper-functions.h" +#include "cuda-resource-views.h" +#include "cuda-shader-object-layout.h" namespace gfx { @@ -37,7 +36,8 @@ Result ShaderObjectData::setCount(Index count) m_bufferResource = new BufferResourceImpl(desc); if (count) { - SLANG_CUDA_RETURN_ON_FAIL(cuMemAlloc((CUdeviceptr*)&m_bufferResource->m_cudaMemory, (size_t)count)); + SLANG_CUDA_RETURN_ON_FAIL( + cuMemAlloc((CUdeviceptr*)&m_bufferResource->m_cudaMemory, (size_t)count)); } IResourceView::Desc viewDesc = {}; viewDesc.type = IResourceView::Type::UnorderedAccess; @@ -167,7 +167,7 @@ SLANG_NO_THROW GfxCount SLANG_MCALL ShaderObjectImpl::getEntryPointCount() } SLANG_NO_THROW Result SLANG_MCALL - ShaderObjectImpl::getEntryPoint(GfxIndex index, IShaderObject** outEntryPoint) +ShaderObjectImpl::getEntryPoint(GfxIndex index, IShaderObject** outEntryPoint) { *outEntryPoint = nullptr; return SLANG_OK; @@ -184,7 +184,7 @@ SLANG_NO_THROW Size SLANG_MCALL ShaderObjectImpl::getSize() } SLANG_NO_THROW Result SLANG_MCALL - ShaderObjectImpl::setData(ShaderOffset const& offset, void const* data, Size size) +ShaderObjectImpl::setData(ShaderOffset const& offset, void const* data, Size size) { Size temp = m_data.getCount() - (Size)offset.uniformOffset; size = Math::Min(size, temp); @@ -196,7 +196,7 @@ SLANG_NO_THROW Result SLANG_MCALL } SLANG_NO_THROW Result SLANG_MCALL - ShaderObjectImpl::setResource(ShaderOffset const& offset, IResourceView* resourceView) +ShaderObjectImpl::setResource(ShaderOffset const& offset, IResourceView* resourceView) { if (!resourceView) return SLANG_OK; @@ -255,7 +255,7 @@ SLANG_NO_THROW Result SLANG_MCALL } SLANG_NO_THROW Result SLANG_MCALL - ShaderObjectImpl::setObject(ShaderOffset const& offset, IShaderObject* object) +ShaderObjectImpl::setObject(ShaderOffset const& offset, IShaderObject* object) { SLANG_RETURN_ON_FAIL(Super::setObject(offset, object)); @@ -266,21 +266,20 @@ SLANG_NO_THROW Result SLANG_MCALL switch (bindingRange.bindingType) { default: - { - void* subObjectDataBuffer = subObject->getBuffer(); - SLANG_RETURN_ON_FAIL(setData(offset, &subObjectDataBuffer, sizeof(void*))); - } - break; + { + void* subObjectDataBuffer = subObject->getBuffer(); + SLANG_RETURN_ON_FAIL(setData(offset, &subObjectDataBuffer, sizeof(void*))); + } + break; case slang::BindingType::ExistentialValue: case slang::BindingType::RawBuffer: - case slang::BindingType::MutableRawBuffer: - break; + case slang::BindingType::MutableRawBuffer: break; } return SLANG_OK; } SLANG_NO_THROW Result SLANG_MCALL - ShaderObjectImpl::setSampler(ShaderOffset const& offset, ISamplerState* sampler) +ShaderObjectImpl::setSampler(ShaderOffset const& offset, ISamplerState* sampler) { SLANG_UNUSED(sampler); SLANG_UNUSED(offset); @@ -288,7 +287,9 @@ SLANG_NO_THROW Result SLANG_MCALL } SLANG_NO_THROW Result SLANG_MCALL ShaderObjectImpl::setCombinedTextureSampler( - ShaderOffset const& offset, IResourceView* textureView, ISamplerState* sampler) + ShaderOffset const& offset, + IResourceView* textureView, + ISamplerState* sampler) { SLANG_UNUSED(sampler); setResource(offset, textureView); @@ -329,7 +330,7 @@ SLANG_NO_THROW GfxCount SLANG_MCALL RootShaderObjectImpl::getEntryPointCount() } SLANG_NO_THROW Result SLANG_MCALL - RootShaderObjectImpl::getEntryPoint(GfxIndex index, IShaderObject** outEntryPoint) +RootShaderObjectImpl::getEntryPoint(GfxIndex index, IShaderObject** outEntryPoint) { returnComPtr(outEntryPoint, entryPointObjects[index]); return SLANG_OK; diff --git a/tools/gfx/cuda/cuda-shader-object.h b/tools/gfx/cuda/cuda-shader-object.h index f564f5eb5..c1c00a821 100644 --- a/tools/gfx/cuda/cuda-shader-object.h +++ b/tools/gfx/cuda/cuda-shader-object.h @@ -1,7 +1,6 @@ // cuda-shader-object.h #pragma once #include "cuda-base.h" - #include "cuda-buffer.h" #include "cuda-resource-views.h" @@ -35,37 +34,40 @@ public: class ShaderObjectImpl : public ShaderObjectBaseImpl<ShaderObjectImpl, ShaderObjectLayoutImpl, ShaderObjectData> { - typedef ShaderObjectBaseImpl<ShaderObjectImpl, ShaderObjectLayoutImpl, ShaderObjectData> - Super; + typedef ShaderObjectBaseImpl<ShaderObjectImpl, ShaderObjectLayoutImpl, ShaderObjectData> Super; public: List<RefPtr<ResourceViewImpl>> resources; virtual SLANG_NO_THROW Result SLANG_MCALL - init(IDevice* device, ShaderObjectLayoutImpl* typeLayout); + init(IDevice* device, ShaderObjectLayoutImpl* typeLayout); virtual SLANG_NO_THROW GfxCount SLANG_MCALL getEntryPointCount() override; virtual SLANG_NO_THROW Result SLANG_MCALL - getEntryPoint(GfxIndex index, IShaderObject** outEntryPoint) override; + getEntryPoint(GfxIndex index, IShaderObject** outEntryPoint) override; virtual SLANG_NO_THROW const void* SLANG_MCALL getRawData() override; virtual SLANG_NO_THROW Size SLANG_MCALL getSize() override; virtual SLANG_NO_THROW Result SLANG_MCALL - setData(ShaderOffset const& offset, void const* data, Size size) override; + setData(ShaderOffset const& offset, void const* data, Size size) override; virtual SLANG_NO_THROW Result SLANG_MCALL - setResource(ShaderOffset const& offset, IResourceView* resourceView) override; + setResource(ShaderOffset const& offset, IResourceView* resourceView) override; virtual SLANG_NO_THROW Result SLANG_MCALL - setObject(ShaderOffset const& offset, IShaderObject* object) override; + setObject(ShaderOffset const& offset, IShaderObject* object) override; virtual SLANG_NO_THROW Result SLANG_MCALL - setSampler(ShaderOffset const& offset, ISamplerState* sampler) override; + setSampler(ShaderOffset const& offset, ISamplerState* sampler) override; virtual SLANG_NO_THROW Result SLANG_MCALL setCombinedTextureSampler( - ShaderOffset const& offset, IResourceView* textureView, ISamplerState* sampler) override; + ShaderOffset const& offset, + IResourceView* textureView, + ISamplerState* sampler) override; }; -class MutableShaderObjectImpl : public MutableShaderObject< MutableShaderObjectImpl, ShaderObjectLayoutImpl> -{}; +class MutableShaderObjectImpl + : public MutableShaderObject<MutableShaderObjectImpl, ShaderObjectLayoutImpl> +{ +}; class EntryPointShaderObjectImpl : public ShaderObjectImpl { @@ -78,13 +80,14 @@ class RootShaderObjectImpl : public ShaderObjectImpl public: virtual SLANG_NO_THROW uint32_t SLANG_MCALL addRef() override; virtual SLANG_NO_THROW uint32_t SLANG_MCALL release() override; + public: List<RefPtr<EntryPointShaderObjectImpl>> entryPointObjects; virtual SLANG_NO_THROW Result SLANG_MCALL - init(IDevice* device, ShaderObjectLayoutImpl* typeLayout) override; + init(IDevice* device, ShaderObjectLayoutImpl* typeLayout) override; virtual SLANG_NO_THROW GfxCount SLANG_MCALL getEntryPointCount() override; virtual SLANG_NO_THROW Result SLANG_MCALL - getEntryPoint(GfxIndex index, IShaderObject** outEntryPoint) override; + getEntryPoint(GfxIndex index, IShaderObject** outEntryPoint) override; virtual Result collectSpecializationArgs(ExtendedShaderObjectTypeList& args) override; }; diff --git a/tools/gfx/cuda/cuda-shader-program.h b/tools/gfx/cuda/cuda-shader-program.h index b0961bfc3..3f6117254 100644 --- a/tools/gfx/cuda/cuda-shader-program.h +++ b/tools/gfx/cuda/cuda-shader-program.h @@ -1,7 +1,6 @@ // cuda-shader-program.h #pragma once #include "cuda-base.h" - #include "cuda-context.h" #include "cuda-shader-object-layout.h" diff --git a/tools/gfx/cuda/cuda-texture.h b/tools/gfx/cuda/cuda-texture.h index c9cc8569a..4af2b323b 100644 --- a/tools/gfx/cuda/cuda-texture.h +++ b/tools/gfx/cuda/cuda-texture.h @@ -1,7 +1,6 @@ // cuda-texture.h #pragma once #include "cuda-base.h" - #include "cuda-context.h" namespace gfx @@ -17,7 +16,8 @@ class TextureResourceImpl : public TextureResource public: TextureResourceImpl(const TextureResource::Desc& desc) : TextureResource(desc) - {} + { + } ~TextureResourceImpl(); uint64_t getBindlessHandle(); @@ -36,7 +36,8 @@ public: RefPtr<CUDAContext> m_cudaContext; - virtual SLANG_NO_THROW Result SLANG_MCALL getNativeResourceHandle(InteropHandle* outHandle) override; + virtual SLANG_NO_THROW Result SLANG_MCALL + getNativeResourceHandle(InteropHandle* outHandle) override; }; } // namespace cuda |
