Skip to content

Commit

Permalink
remove IResource::setDebugName/getDebugName
Browse files Browse the repository at this point in the history
  • Loading branch information
skallweitNV committed Aug 31, 2024
1 parent c9fa70f commit 2eb84dd
Show file tree
Hide file tree
Showing 22 changed files with 40 additions and 118 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 6 additions & 3 deletions include/slang-rhi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions src/d3d12/d3d12-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions src/d3d12/d3d12-buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 9 additions & 1 deletion src/d3d12/d3d12-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 0 additions & 7 deletions src/d3d12/d3d12-texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions src/d3d12/d3d12-texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 0 additions & 12 deletions src/debug-layer/debug-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions src/debug-layer/debug-buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ class DebugBuffer : public DebugObject<IBuffer>
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;
};
Expand Down
10 changes: 0 additions & 10 deletions src/debug-layer/debug-texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions src/debug-layer/debug-texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ class DebugTexture : public DebugObject<ITexture>
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
7 changes: 0 additions & 7 deletions src/metal/metal-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions src/metal/metal-buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions src/metal/metal-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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<MTL::Buffer> stagingBuffer = NS::TransferPtr(
Expand Down
7 changes: 0 additions & 7 deletions src/metal/metal-texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions src/metal/metal-texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 0 additions & 15 deletions src/renderer-shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ class Resource : public ComObject
{
protected:
InteropHandle sharedHandle = {};
std::string m_debugName;
};

class Buffer : public IBuffer, public Resource
Expand All @@ -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;
};
Expand All @@ -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;
};
Expand Down
16 changes: 0 additions & 16 deletions src/vulkan/vk-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions src/vulkan/vk-buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 20 additions & 0 deletions src/vulkan/vk-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down
15 changes: 0 additions & 15 deletions src/vulkan/vk-texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions src/vulkan/vk-texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2eb84dd

Please sign in to comment.