diff --git a/CHANGELOG b/CHANGELOG index a05f3010..3f1b067c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,4 @@ +- remove IResource::setDebugName/getDebugName, add label to BufferDesc and TextureDesc instead - rename IPipelineState -> IPipeline - rename IDevice::createRayTracingPipelineState -> IDevice::createRayTracingPipeline - rename IDevice::createComputePipelineState -> IDevice::createComputePipeline diff --git a/include/slang-rhi.h b/include/slang-rhi.h index 5eefb02a..5d273de3 100644 --- a/include/slang-rhi.h +++ b/include/slang-rhi.h @@ -561,9 +561,6 @@ class IResource : public ISlangUnknown public: virtual SLANG_NO_THROW Result SLANG_MCALL getNativeResourceHandle(InteropHandle* outHandle) = 0; virtual SLANG_NO_THROW Result SLANG_MCALL getSharedHandle(InteropHandle* outHandle) = 0; - - virtual SLANG_NO_THROW Result SLANG_MCALL setDebugName(const char* name) = 0; - virtual SLANG_NO_THROW const char* SLANG_MCALL getDebugName() = 0; }; struct MemoryRange @@ -589,6 +586,9 @@ struct BufferDesc InteropHandle existingHandle = {}; bool isShared = false; + + /// The name of the buffer for debugging purposes. + const char* label = nullptr; }; class IBuffer : public IResource @@ -748,6 +748,9 @@ struct TextureDesc int sampleQuality = 0; ClearValue* optimalClearValue = nullptr; + + /// The name of the texture for debugging purposes. + const char* label = nullptr; }; class ITexture : public IResource diff --git a/src/d3d12/d3d12-buffer.cpp b/src/d3d12/d3d12-buffer.cpp index 67c3ad3b..1009864e 100644 --- a/src/d3d12/d3d12-buffer.cpp +++ b/src/d3d12/d3d12-buffer.cpp @@ -77,11 +77,4 @@ Result BufferImpl::unmap(MemoryRange* writtenRange) return SLANG_OK; } -Result BufferImpl::setDebugName(const char* name) -{ - Parent::setDebugName(name); - m_resource.setDebugName(name); - return SLANG_OK; -} - } // namespace rhi::d3d12 diff --git a/src/d3d12/d3d12-buffer.h b/src/d3d12/d3d12-buffer.h index 579a4a3b..6fddd061 100644 --- a/src/d3d12/d3d12-buffer.h +++ b/src/d3d12/d3d12-buffer.h @@ -27,8 +27,6 @@ class BufferImpl : public Buffer virtual SLANG_NO_THROW Result SLANG_MCALL map(MemoryRange* rangeToRead, void** outPointer) override; virtual SLANG_NO_THROW Result SLANG_MCALL unmap(MemoryRange* writtenRange) override; - - virtual SLANG_NO_THROW Result SLANG_MCALL setDebugName(const char* name) override; }; } // namespace rhi::d3d12 diff --git a/src/d3d12/d3d12-device.cpp b/src/d3d12/d3d12-device.cpp index 3b688baa..979734ce 100644 --- a/src/d3d12/d3d12-device.cpp +++ b/src/d3d12/d3d12-device.cpp @@ -1057,7 +1057,10 @@ Result DeviceImpl::createTexture(const TextureDesc& descIn, const SubresourceDat .initCommitted(m_device, heapProps, flags, resourceDesc, D3D12_RESOURCE_STATE_COPY_DEST, clearValuePtr) ); - texture->m_resource.setDebugName(L"Texture"); + if (srcDesc.label) + { + texture->m_resource.setDebugName(srcDesc.label); + } } // Calculate the layout @@ -1265,6 +1268,11 @@ Result DeviceImpl::createBuffer(const BufferDesc& descIn, const void* initData, descIn.memoryType )); + if (srcDesc.label) + { + buffer->m_resource.setDebugName(srcDesc.label); + } + returnComPtr(outBuffer, buffer); return SLANG_OK; } diff --git a/src/d3d12/d3d12-texture.cpp b/src/d3d12/d3d12-texture.cpp index 9b50074a..c0f0b739 100644 --- a/src/d3d12/d3d12-texture.cpp +++ b/src/d3d12/d3d12-texture.cpp @@ -47,11 +47,4 @@ Result TextureImpl::getSharedHandle(InteropHandle* outHandle) #endif } -Result TextureImpl::setDebugName(const char* name) -{ - Parent::setDebugName(name); - m_resource.setDebugName(name); - return SLANG_OK; -} - } // namespace rhi::d3d12 diff --git a/src/d3d12/d3d12-texture.h b/src/d3d12/d3d12-texture.h index a67c0eb8..6ef5f166 100644 --- a/src/d3d12/d3d12-texture.h +++ b/src/d3d12/d3d12-texture.h @@ -19,8 +19,6 @@ class TextureImpl : public Texture virtual SLANG_NO_THROW Result SLANG_MCALL getNativeResourceHandle(InteropHandle* outHandle) override; virtual SLANG_NO_THROW Result SLANG_MCALL getSharedHandle(InteropHandle* outHandle) override; - - virtual SLANG_NO_THROW Result SLANG_MCALL setDebugName(const char* name) override; }; } // namespace rhi::d3d12 diff --git a/src/debug-layer/debug-buffer.cpp b/src/debug-layer/debug-buffer.cpp index 454c6086..6129768a 100644 --- a/src/debug-layer/debug-buffer.cpp +++ b/src/debug-layer/debug-buffer.cpp @@ -27,18 +27,6 @@ Result DebugBuffer::getSharedHandle(InteropHandle* outHandle) return baseObject->getSharedHandle(outHandle); } -Result DebugBuffer::setDebugName(const char* name) -{ - SLANG_RHI_API_FUNC; - return baseObject->setDebugName(name); -} - -const char* DebugBuffer::getDebugName() -{ - SLANG_RHI_API_FUNC; - return baseObject->getDebugName(); -} - Result DebugBuffer::map(MemoryRange* rangeToRead, void** outPointer) { SLANG_RHI_API_FUNC; diff --git a/src/debug-layer/debug-buffer.h b/src/debug-layer/debug-buffer.h index 4859c2f8..d28b09cb 100644 --- a/src/debug-layer/debug-buffer.h +++ b/src/debug-layer/debug-buffer.h @@ -16,9 +16,6 @@ class DebugBuffer : public DebugObject virtual SLANG_NO_THROW Result SLANG_MCALL getNativeResourceHandle(InteropHandle* outHandle) override; virtual SLANG_NO_THROW Result SLANG_MCALL getSharedHandle(InteropHandle* outHandle) override; - virtual SLANG_NO_THROW Result SLANG_MCALL setDebugName(const char* name) override; - virtual SLANG_NO_THROW const char* SLANG_MCALL getDebugName() 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/src/debug-layer/debug-texture.cpp b/src/debug-layer/debug-texture.cpp index 5caa3c9e..457a4075 100644 --- a/src/debug-layer/debug-texture.cpp +++ b/src/debug-layer/debug-texture.cpp @@ -21,14 +21,4 @@ Result DebugTexture::getSharedHandle(InteropHandle* outHandle) return baseObject->getSharedHandle(outHandle); } -Result DebugTexture::setDebugName(const char* name) -{ - return baseObject->setDebugName(name); -} - -const char* DebugTexture::getDebugName() -{ - return baseObject->getDebugName(); -} - } // namespace rhi::debug diff --git a/src/debug-layer/debug-texture.h b/src/debug-layer/debug-texture.h index 08bf9e72..a829ddcb 100644 --- a/src/debug-layer/debug-texture.h +++ b/src/debug-layer/debug-texture.h @@ -14,9 +14,6 @@ class DebugTexture : public DebugObject virtual SLANG_NO_THROW TextureDesc* SLANG_MCALL getDesc() override; virtual SLANG_NO_THROW Result SLANG_MCALL getNativeResourceHandle(InteropHandle* outHandle) override; virtual SLANG_NO_THROW Result SLANG_MCALL getSharedHandle(InteropHandle* outHandle) override; - - virtual SLANG_NO_THROW Result SLANG_MCALL setDebugName(const char* name) override; - virtual SLANG_NO_THROW const char* SLANG_MCALL getDebugName() override; }; } // namespace rhi::debug diff --git a/src/metal/metal-buffer.cpp b/src/metal/metal-buffer.cpp index 4155bf15..444cd3ec 100644 --- a/src/metal/metal-buffer.cpp +++ b/src/metal/metal-buffer.cpp @@ -39,11 +39,4 @@ Result BufferImpl::unmap(MemoryRange* writtenRange) return SLANG_OK; } -Result BufferImpl::setDebugName(const char* name) -{ - Parent::setDebugName(name); - m_buffer->addDebugMarker(MetalUtil::createString(name).get(), NS::Range(0, m_desc.size)); - return SLANG_OK; -} - } // namespace rhi::metal diff --git a/src/metal/metal-buffer.h b/src/metal/metal-buffer.h index 96c9320b..83b63591 100644 --- a/src/metal/metal-buffer.h +++ b/src/metal/metal-buffer.h @@ -25,8 +25,6 @@ class BufferImpl : public Buffer virtual SLANG_NO_THROW Result SLANG_MCALL map(MemoryRange* rangeToRead, void** outPointer) override; virtual SLANG_NO_THROW Result SLANG_MCALL unmap(MemoryRange* writtenRange) override; - - virtual SLANG_NO_THROW Result SLANG_MCALL setDebugName(const char* name) override; }; } // namespace rhi::metal diff --git a/src/metal/metal-device.cpp b/src/metal/metal-device.cpp index 397425f8..8a028ddf 100644 --- a/src/metal/metal-device.cpp +++ b/src/metal/metal-device.cpp @@ -443,6 +443,8 @@ Result DeviceImpl::createTexture(const TextureDesc& descIn, const SubresourceDat textureImpl->m_textureType = textureDesc->textureType(); textureImpl->m_pixelFormat = textureDesc->pixelFormat(); + textureImpl->m_texture->setLabel(MetalUtil::createString(desc.label).get()); + // TODO: handle initData if (initData) { @@ -529,6 +531,8 @@ Result DeviceImpl::createBuffer(const BufferDesc& descIn, const void* initData, return SLANG_FAIL; } + buffer->m_buffer->addDebugMarker(MetalUtil::createString(desc.label).get(), NS::Range(0, desc.size)); + if (initData) { NS::SharedPtr stagingBuffer = NS::TransferPtr( diff --git a/src/metal/metal-texture.cpp b/src/metal/metal-texture.cpp index 4bfe4bc7..2677aa47 100644 --- a/src/metal/metal-texture.cpp +++ b/src/metal/metal-texture.cpp @@ -23,11 +23,4 @@ Result TextureImpl::getSharedHandle(InteropHandle* outHandle) return SLANG_E_NOT_AVAILABLE; } -Result TextureImpl::setDebugName(const char* name) -{ - Parent::setDebugName(name); - m_texture->setLabel(MetalUtil::createString(name).get()); - return SLANG_OK; -} - } // namespace rhi::metal diff --git a/src/metal/metal-texture.h b/src/metal/metal-texture.h index 245c68ff..420fa3e0 100644 --- a/src/metal/metal-texture.h +++ b/src/metal/metal-texture.h @@ -21,8 +21,6 @@ class TextureImpl : public Texture virtual SLANG_NO_THROW Result SLANG_MCALL getNativeResourceHandle(InteropHandle* outHandle) override; virtual SLANG_NO_THROW Result SLANG_MCALL getSharedHandle(InteropHandle* outHandle) override; - - virtual SLANG_NO_THROW Result SLANG_MCALL setDebugName(const char* name) override; }; } // namespace rhi::metal diff --git a/src/renderer-shared.h b/src/renderer-shared.h index 440e2eee..ec5922a6 100644 --- a/src/renderer-shared.h +++ b/src/renderer-shared.h @@ -204,7 +204,6 @@ class Resource : public ComObject { protected: InteropHandle sharedHandle = {}; - std::string m_debugName; }; class Buffer : public IBuffer, public Resource @@ -226,13 +225,6 @@ class Buffer : public IBuffer, public Resource virtual SLANG_NO_THROW Result SLANG_MCALL getNativeResourceHandle(InteropHandle* outHandle) SLANG_OVERRIDE; virtual SLANG_NO_THROW Result SLANG_MCALL getSharedHandle(InteropHandle* outHandle) SLANG_OVERRIDE; - virtual SLANG_NO_THROW Result SLANG_MCALL setDebugName(const char* name) override - { - m_debugName = name; - return SLANG_OK; - } - virtual SLANG_NO_THROW const char* SLANG_MCALL getDebugName() override { return m_debugName.data(); } - protected: BufferDesc m_desc; }; @@ -256,13 +248,6 @@ class Texture : public ITexture, public Resource virtual SLANG_NO_THROW Result SLANG_MCALL getNativeResourceHandle(InteropHandle* outHandle) SLANG_OVERRIDE; virtual SLANG_NO_THROW Result SLANG_MCALL getSharedHandle(InteropHandle* outHandle) SLANG_OVERRIDE; - virtual SLANG_NO_THROW Result SLANG_MCALL setDebugName(const char* name) override - { - m_debugName = name; - return SLANG_OK; - } - virtual SLANG_NO_THROW const char* SLANG_MCALL getDebugName() override { return m_debugName.data(); } - protected: TextureDesc m_desc; }; diff --git a/src/vulkan/vk-buffer.cpp b/src/vulkan/vk-buffer.cpp index bbcc3891..f9aebaf7 100644 --- a/src/vulkan/vk-buffer.cpp +++ b/src/vulkan/vk-buffer.cpp @@ -181,20 +181,4 @@ Result BufferImpl::unmap(MemoryRange* writtenRange) return SLANG_OK; } -Result BufferImpl::setDebugName(const char* name) -{ - Parent::setDebugName(name); - auto api = m_buffer.m_api; - if (api->vkDebugMarkerSetObjectNameEXT) - { - VkDebugMarkerObjectNameInfoEXT nameDesc = {}; - nameDesc.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT; - nameDesc.object = (uint64_t)m_buffer.m_buffer; - nameDesc.objectType = VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT; - nameDesc.pObjectName = name; - api->vkDebugMarkerSetObjectNameEXT(api->m_device, &nameDesc); - } - return SLANG_OK; -} - } // namespace rhi::vk diff --git a/src/vulkan/vk-buffer.h b/src/vulkan/vk-buffer.h index ff3cb86f..6c314478 100644 --- a/src/vulkan/vk-buffer.h +++ b/src/vulkan/vk-buffer.h @@ -62,8 +62,6 @@ class BufferImpl : public Buffer virtual SLANG_NO_THROW Result SLANG_MCALL map(MemoryRange* rangeToRead, void** outPointer) override; virtual SLANG_NO_THROW Result SLANG_MCALL unmap(MemoryRange* writtenRange) override; - - virtual SLANG_NO_THROW Result SLANG_MCALL setDebugName(const char* name) override; }; } // namespace rhi::vk diff --git a/src/vulkan/vk-device.cpp b/src/vulkan/vk-device.cpp index b677c0f8..a84841e6 100644 --- a/src/vulkan/vk-device.cpp +++ b/src/vulkan/vk-device.cpp @@ -1592,6 +1592,16 @@ Result DeviceImpl::createTexture(const TextureDesc& descIn, const SubresourceDat // Bind the memory to the image m_api.vkBindImageMemory(m_device, texture->m_image, texture->m_imageMemory, 0); + if (desc.label && m_api.vkDebugMarkerSetObjectNameEXT) + { + VkDebugMarkerObjectNameInfoEXT nameDesc = {}; + nameDesc.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT; + nameDesc.object = (uint64_t)texture->m_image; + nameDesc.objectType = VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT; + nameDesc.pObjectName = desc.label; + m_api.vkDebugMarkerSetObjectNameEXT(m_api.m_device, &nameDesc); + } + VKBufferHandleRAII uploadBuffer; if (initData) { @@ -1917,6 +1927,16 @@ Result DeviceImpl::createBufferImpl( SLANG_RETURN_ON_FAIL(buffer->m_buffer.init(m_api, desc.size, usage, reqMemoryProperties)); } + if (desc.label && m_api.vkDebugMarkerSetObjectNameEXT) + { + VkDebugMarkerObjectNameInfoEXT nameDesc = {}; + nameDesc.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT; + nameDesc.object = (uint64_t)buffer->m_buffer.m_buffer; + nameDesc.objectType = VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT; + nameDesc.pObjectName = desc.label; + m_api.vkDebugMarkerSetObjectNameEXT(m_api.m_device, &nameDesc); + } + if (initData) { if (desc.memoryType == MemoryType::DeviceLocal) diff --git a/src/vulkan/vk-texture.cpp b/src/vulkan/vk-texture.cpp index 151d5489..0dfbafa5 100644 --- a/src/vulkan/vk-texture.cpp +++ b/src/vulkan/vk-texture.cpp @@ -77,20 +77,5 @@ Result TextureImpl::getSharedHandle(InteropHandle* outHandle) outHandle->api = InteropHandleAPI::Vulkan; return SLANG_OK; } -Result TextureImpl::setDebugName(const char* name) -{ - Parent::setDebugName(name); - auto& api = m_device->m_api; - if (api.vkDebugMarkerSetObjectNameEXT) - { - VkDebugMarkerObjectNameInfoEXT nameDesc = {}; - nameDesc.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT; - nameDesc.object = (uint64_t)m_image; - nameDesc.objectType = VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT; - nameDesc.pObjectName = name; - api.vkDebugMarkerSetObjectNameEXT(api.m_device, &nameDesc); - } - return SLANG_OK; -} } // namespace rhi::vk diff --git a/src/vulkan/vk-texture.h b/src/vulkan/vk-texture.h index 46c2d536..b585635a 100644 --- a/src/vulkan/vk-texture.h +++ b/src/vulkan/vk-texture.h @@ -21,8 +21,6 @@ class TextureImpl : public Texture virtual SLANG_NO_THROW Result SLANG_MCALL getNativeResourceHandle(InteropHandle* outHandle) override; virtual SLANG_NO_THROW Result SLANG_MCALL getSharedHandle(InteropHandle* outHandle) override; - - virtual SLANG_NO_THROW Result SLANG_MCALL setDebugName(const char* name) override; }; } // namespace rhi::vk