Skip to content

Commit

Permalink
rename native handle types
Browse files Browse the repository at this point in the history
  • Loading branch information
skallweitNV committed Sep 1, 2024
1 parent 5dce4c1 commit 63ee51f
Show file tree
Hide file tree
Showing 31 changed files with 91 additions and 119 deletions.
94 changes: 35 additions & 59 deletions include/slang-rhi.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,65 +527,41 @@ enum class NativeHandleType
Win32 = 0x00000001,
FileDescriptor = 0x00000002,

D3D11_Device = 0x00010001,
D3D11_DeviceContext = 0x00010002,
D3D11_Resource = 0x00010003,
D3D11_Buffer = 0x00010004,
D3D11_RenderTargetView = 0x00010005,
D3D11_DepthStencilView = 0x00010006,
D3D11_ShaderResourceView = 0x00010007,
D3D11_UnorderedAccessView = 0x00010008,

D3D12_Device = 0x00020001,
D3D12_CommandQueue = 0x00020002,
D3D12_GraphicsCommandList = 0x00020003,
D3D12_Resource = 0x00020004,
D3D12_RenderTargetViewDescriptor = 0x00020005,
D3D12_DepthStencilViewDescriptor = 0x00020006,
D3D12_ShaderResourceViewGpuDescripror = 0x00020007,
D3D12_UnorderedAccessViewGpuDescripror = 0x00020008,
D3D12_RootSignature = 0x00020009,
D3D12_PipelineState = 0x0002000a,
D3D12_CommandAllocator = 0x0002000b,
D3D12_CpuDescriptorHandle = 0x0002000c,
D3D12_Fence = 0x0002000d,
D3D12_DeviceAddress = 0x0002000e,

VK_Device = 0x00030001,
VK_PhysicalDevice = 0x00030002,
VK_Instance = 0x00030003,
VK_Queue = 0x00030004,
VK_CommandBuffer = 0x00030005,
VK_DeviceMemory = 0x00030006,
VK_Buffer = 0x00030007,
VK_Image = 0x00030008,
VK_ImageView = 0x00030009,
VK_AccelerationStructureKHR = 0x0003000a,
VK_Sampler = 0x0003000b,
VK_ShaderModule = 0x0003000c,
VK_RenderPass = 0x0003000d,
VK_Framebuffer = 0x0003000e,
VK_DescriptorPool = 0x0003000f,
VK_DescriptorSetLayout = 0x00030010,
VK_DescriptorSet = 0x00030011,
VK_PipelineLayout = 0x00030012,
VK_Pipeline = 0x00030013,
VK_Micromap = 0x00030014,
VK_Semaphore = 0x00030015,
VK_CommandQueue = 0x00030016,

MTL_Device = 0x00040001,
MTL_CommandQueue = 0x00040002,
MTL_CommandBuffer = 0x00040003,
MTL_Texture = 0x00040004,
MTL_Buffer = 0x00040005,
MTL_ComputePipelineState = 0x00040006,
MTL_RenderPipelineState = 0x00040007,
MTL_SharedEvent = 0x00040008,

CU_Device = 0x00050001,
CU_DevicePtr = 0x00050002,
CU_TexObject = 0x00050003,
D3D12Device = 0x00020001,
D3D12CommandQueue = 0x00020002,
D3D12GraphicsCommandList = 0x00020003,
D3D12Resource = 0x00020004,
D3D12PipelineState = 0x00020005,
D3D12StateObject = 0x00020006,
D3D12CpuDescriptorHandle = 0x00020007,
D3D12Fence = 0x00020008,
D3D12DeviceAddress = 0x00020009,

VkDevice = 0x00030001,
VkPhysicalDevice = 0x00030002,
VkInstance = 0x00030003,
VkQueue = 0x00030004,
VkCommandBuffer = 0x00030005,
VkBuffer = 0x00030006,
VkImage = 0x00030007,
VkImageView = 0x00030008,
VkAccelerationStructureKHR = 0x00030009,
VkSampler = 0x0003000a,
VkPipeline = 0x0003000b,
VkSemaphore = 0x0003000c,

MTLDevice = 0x00040001,
MTLCommandQueue = 0x00040002,
MTLCommandBuffer = 0x00040003,
MTLTexture = 0x00040004,
MTLBuffer = 0x00040005,
MTLComputePipelineState = 0x00040006,
MTLRenderPipelineState = 0x00040007,
MTLSharedEvent = 0x00040008,

CUdevice = 0x00050001,
CUdeviceptr = 0x00050002,
CUtexObject = 0x00050003,
};

struct NativeHandle
Expand Down
2 changes: 1 addition & 1 deletion src/cuda/cuda-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ DeviceAddress BufferImpl::getDeviceAddress()

Result BufferImpl::getNativeHandle(NativeHandle* outHandle)
{
outHandle->type = NativeHandleType::CU_DevicePtr;
outHandle->type = NativeHandleType::CUdeviceptr;
outHandle->value = getBindlessHandle();
return SLANG_OK;
}
Expand Down
6 changes: 3 additions & 3 deletions src/cuda/cuda-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Result DeviceImpl::_initCuda(CUDAReportStyle reportType)

SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::getNativeDeviceHandles(NativeHandles* outHandles)
{
outHandles->handles[0].type = NativeHandleType::CU_Device;
outHandles->handles[0].type = NativeHandleType::CUdevice;
outHandles->handles[0].value = (uint64_t)m_device;
outHandles->handles[1] = {};
outHandles->handles[2] = {};
Expand Down Expand Up @@ -760,7 +760,7 @@ DeviceImpl::createBufferFromSharedHandle(NativeHandle handle, const BufferDesc&
memset(&externalMemoryHandleDesc, 0, sizeof(externalMemoryHandleDesc));
switch (handle.type)
{
case NativeHandleType::D3D12_Resource:
case NativeHandleType::D3D12Resource:
externalMemoryHandleDesc.type = CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE;
break;
case NativeHandleType::Win32:
Expand Down Expand Up @@ -825,7 +825,7 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createTextureFromSharedHandle(
memset(&externalMemoryHandleDesc, 0, sizeof(externalMemoryHandleDesc));
switch (handle.type)
{
case NativeHandleType::D3D12_Resource:
case NativeHandleType::D3D12Resource:
externalMemoryHandleDesc.type = CU_EXTERNAL_MEMORY_HANDLE_TYPE_D3D12_RESOURCE;
break;
case NativeHandleType::Win32:
Expand Down
2 changes: 1 addition & 1 deletion src/cuda/cuda-texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ uint64_t TextureImpl::getBindlessHandle()

Result TextureImpl::getNativeHandle(NativeHandle* outHandle)
{
outHandle->type = NativeHandleType::CU_TexObject;
outHandle->type = NativeHandleType::CUtexObject;
outHandle->value = getBindlessHandle();
return SLANG_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion src/d3d12/d3d12-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ DeviceAddress BufferImpl::getDeviceAddress()

Result BufferImpl::getNativeHandle(NativeHandle* outHandle)
{
outHandle->type = NativeHandleType::D3D12_Resource;
outHandle->type = NativeHandleType::D3D12Resource;
outHandle->value = (uint64_t)m_resource.getResource();
return SLANG_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion src/d3d12/d3d12-command-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ICommandBufferD3D12* CommandBufferImpl::getInterface(const Guid& guid)

Result CommandBufferImpl::getNativeHandle(NativeHandle* handle)
{
handle->type = NativeHandleType::D3D12_GraphicsCommandList;
handle->type = NativeHandleType::D3D12GraphicsCommandList;
handle->value = (uint64_t)m_cmdList.get();
return SLANG_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion src/d3d12/d3d12-command-queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ ICommandQueue* CommandQueueImpl::getInterface(const Guid& guid)

Result CommandQueueImpl::getNativeHandle(NativeHandle* outHandle)
{
outHandle->type = NativeHandleType::D3D12_CommandQueue;
outHandle->type = NativeHandleType::D3D12CommandQueue;
outHandle->value = (uint64_t)m_d3dQueue.get();
return SLANG_OK;
}
Expand Down
8 changes: 4 additions & 4 deletions src/d3d12/d3d12-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ Result DeviceImpl::captureTextureToSurface(

Result DeviceImpl::getNativeDeviceHandles(NativeHandles* outHandles)
{
outHandles->handles[0].type = NativeHandleType::D3D12_Device;
outHandles->handles[0].type = NativeHandleType::D3D12Device;
outHandles->handles[0].value = (uint64_t)m_device;
outHandles->handles[1] = {};
outHandles->handles[2] = {};
Expand Down Expand Up @@ -581,7 +581,7 @@ Result DeviceImpl::initialize(const Desc& desc)
}
else
{
if (desc.existingDeviceHandles.handles[0].type != NativeHandleType::D3D12_Device)
if (desc.existingDeviceHandles.handles[0].type != NativeHandleType::D3D12Device)
{
return SLANG_FAIL;
}
Expand Down Expand Up @@ -1235,7 +1235,7 @@ Result DeviceImpl::createTextureFromNativeHandle(NativeHandle handle, const Text
{
RefPtr<TextureImpl> texture(new TextureImpl(srcDesc));

if (handle.type == NativeHandleType::D3D12_Resource)
if (handle.type == NativeHandleType::D3D12Resource)
{
texture->m_resource.setResource((ID3D12Resource*)handle.value);
}
Expand Down Expand Up @@ -1283,7 +1283,7 @@ Result DeviceImpl::createBufferFromNativeHandle(NativeHandle handle, const Buffe
{
RefPtr<BufferImpl> buffer(new BufferImpl(srcDesc));

if (handle.type == NativeHandleType::D3D12_Resource)
if (handle.type == NativeHandleType::D3D12Resource)
{
buffer->m_resource.setResource((ID3D12Resource*)handle.value);
}
Expand Down
2 changes: 1 addition & 1 deletion src/d3d12/d3d12-fence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Result FenceImpl::setCurrentValue(uint64_t value)

Result FenceImpl::getNativeHandle(NativeHandle* outHandle)
{
outHandle->type = NativeHandleType::D3D12_Fence;
outHandle->type = NativeHandleType::D3D12Fence;
outHandle->value = (uint64_t)m_fence.get();
return SLANG_OK;
}
Expand Down
4 changes: 2 additions & 2 deletions src/d3d12/d3d12-pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void PipelineImpl::init(const ComputePipelineDesc& inDesc)
Result PipelineImpl::getNativeHandle(NativeHandle* outHandle)
{
SLANG_RETURN_ON_FAIL(ensureAPIPipelineCreated());
outHandle->type = NativeHandleType::D3D12_PipelineState;
outHandle->type = NativeHandleType::D3D12PipelineState;
outHandle->value = (uint64_t)(m_pipelineState.get());
return SLANG_OK;
}
Expand Down Expand Up @@ -361,7 +361,7 @@ void RayTracingPipelineImpl::init(const RayTracingPipelineDesc& inDesc)
Result RayTracingPipelineImpl::getNativeHandle(NativeHandle* outHandle)
{
SLANG_RETURN_ON_FAIL(ensureAPIPipelineCreated());
outHandle->type = NativeHandleType::D3D12_PipelineState;
outHandle->type = NativeHandleType::D3D12StateObject;
outHandle->value = (uint64_t)(m_stateObject.get());
return SLANG_OK;
}
Expand Down
4 changes: 2 additions & 2 deletions src/d3d12/d3d12-resource-views.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ Result ResourceViewInternalImpl::getBufferDescriptorForBinding(

Result ResourceViewImpl::getNativeHandle(NativeHandle* outHandle)
{
outHandle->type = NativeHandleType::D3D12_CpuDescriptorHandle;
outHandle->type = NativeHandleType::D3D12CpuDescriptorHandle;
outHandle->value = m_descriptor.cpuHandle.ptr;
return SLANG_OK;
}
Expand All @@ -180,7 +180,7 @@ DeviceAddress AccelerationStructureImpl::getDeviceAddress()

Result AccelerationStructureImpl::getNativeHandle(NativeHandle* outHandle)
{
outHandle->type = NativeHandleType::D3D12_DeviceAddress;
outHandle->type = NativeHandleType::D3D12DeviceAddress;
outHandle->value = getDeviceAddress();
return SLANG_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion src/d3d12/d3d12-sampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SamplerImpl::~SamplerImpl()

Result SamplerImpl::getNativeHandle(NativeHandle* outHandle)
{
outHandle->type = NativeHandleType::D3D12_CpuDescriptorHandle;
outHandle->type = NativeHandleType::D3D12CpuDescriptorHandle;
outHandle->value = m_descriptor.cpuHandle.ptr;
return SLANG_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion src/d3d12/d3d12-texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ TextureImpl::~TextureImpl()

Result TextureImpl::getNativeHandle(NativeHandle* outHandle)
{
outHandle->type = NativeHandleType::D3D12_Resource;
outHandle->type = NativeHandleType::D3D12Resource;
outHandle->value = (uint64_t)m_resource.getResource();
return SLANG_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion src/metal/metal-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ DeviceAddress BufferImpl::getDeviceAddress()

Result BufferImpl::getNativeHandle(NativeHandle* outHandle)
{
outHandle->type = NativeHandleType::MTL_Buffer;
outHandle->type = NativeHandleType::MTLBuffer;
outHandle->value = (uint64_t)m_buffer.get();
return SLANG_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion src/metal/metal-command-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void CommandBufferImpl::close()

Result CommandBufferImpl::getNativeHandle(NativeHandle* outHandle)
{
outHandle->type = NativeHandleType::MTL_CommandBuffer;
outHandle->type = NativeHandleType::MTLCommandBuffer;
outHandle->value = (uint64_t)m_commandBuffer.get();
return SLANG_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion src/metal/metal-command-queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void CommandQueueImpl::waitOnHost()

Result CommandQueueImpl::getNativeHandle(NativeHandle* outHandle)
{
outHandle->type = NativeHandleType::MTL_CommandQueue;
outHandle->type = NativeHandleType::MTLCommandQueue;
outHandle->value = (uint64_t)m_commandQueue.get();
return SLANG_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion src/metal/metal-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ DeviceImpl::~DeviceImpl() {}

Result DeviceImpl::getNativeDeviceHandles(NativeHandles* outHandles)
{
outHandles->handles[0].type = NativeHandleType::MTL_Device;
outHandles->handles[0].type = NativeHandleType::MTLDevice;
outHandles->handles[0].value = (uint64_t)m_device.get();
outHandles->handles[1] = {};
outHandles->handles[2] = {};
Expand Down
2 changes: 1 addition & 1 deletion src/metal/metal-fence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Result FenceImpl::setCurrentValue(uint64_t value)

Result FenceImpl::getNativeHandle(NativeHandle* outHandle)
{
outHandle->type = NativeHandleType::MTL_SharedEvent;
outHandle->type = NativeHandleType::MTLSharedEvent;
outHandle->value = (uint64_t)m_event.get();
return SLANG_OK;
}
Expand Down
4 changes: 2 additions & 2 deletions src/metal/metal-pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@ SLANG_NO_THROW Result SLANG_MCALL PipelineImpl::getNativeHandle(NativeHandle* ou
switch (desc.type)
{
case PipelineType::Compute:
outHandle->type = NativeHandleType::MTL_ComputePipelineState;
outHandle->type = NativeHandleType::MTLComputePipelineState;
outHandle->value = (uint64_t)m_computePipelineState.get();
return SLANG_OK;
case PipelineType::Graphics:
outHandle->type = NativeHandleType::MTL_RenderPipelineState;
outHandle->type = NativeHandleType::MTLRenderPipelineState;
outHandle->value = (uint64_t)m_renderPipelineState.get();
return SLANG_OK;
}
Expand Down
6 changes: 2 additions & 4 deletions src/metal/metal-resource-views.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ TextureViewImpl::~TextureViewImpl() {}

Result TextureViewImpl::getNativeHandle(NativeHandle* outHandle)
{
outHandle->type = NativeHandleType::MTL_Texture;
outHandle->type = NativeHandleType::MTLTexture;
outHandle->value = (uint64_t)m_textureView.get();
return SLANG_OK;
}
Expand All @@ -15,9 +15,7 @@ BufferViewImpl::~BufferViewImpl() {}

Result BufferViewImpl::getNativeHandle(NativeHandle* outHandle)
{
outHandle->type = NativeHandleType::MTL_Buffer;
outHandle->value = (uint64_t)m_buffer->m_buffer->m_buffer.get();
return SLANG_OK;
return m_buffer->getNativeHandle(outHandle);
}

TexelBufferViewImpl::TexelBufferViewImpl(DeviceImpl* device)
Expand Down
2 changes: 1 addition & 1 deletion src/metal/metal-texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ TextureImpl::~TextureImpl() {}

Result TextureImpl::getNativeHandle(NativeHandle* outHandle)
{
outHandle->type = NativeHandleType::MTL_Texture;
outHandle->type = NativeHandleType::MTLTexture;
outHandle->value = (uint64_t)m_texture.get();
return SLANG_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion src/vulkan/vk-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ DeviceAddress BufferImpl::getDeviceAddress()

Result BufferImpl::getNativeHandle(NativeHandle* outHandle)
{
outHandle->type = NativeHandleType::VK_Buffer;
outHandle->type = NativeHandleType::VkBuffer;
outHandle->value = (uint64_t)m_buffer.m_buffer;
return SLANG_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion src/vulkan/vk-command-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void CommandBufferImpl::close()

Result CommandBufferImpl::getNativeHandle(NativeHandle* outHandle)
{
outHandle->type = NativeHandleType::VK_CommandBuffer;
outHandle->type = NativeHandleType::VkCommandBuffer;
outHandle->value = (uint64_t)m_commandBuffer;
return SLANG_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion src/vulkan/vk-command-queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void CommandQueueImpl::waitOnHost()

Result CommandQueueImpl::getNativeHandle(NativeHandle* outHandle)
{
outHandle->type = NativeHandleType::VK_CommandQueue;
outHandle->type = NativeHandleType::VkQueue;
outHandle->value = (uint64_t)m_queue;
return SLANG_OK;
}
Expand Down
Loading

0 comments on commit 63ee51f

Please sign in to comment.