diff --git a/Source/Engine/Content/Assets/Shader.cpp b/Source/Engine/Content/Assets/Shader.cpp index 9228ef635..d79132fb7 100644 --- a/Source/Engine/Content/Assets/Shader.cpp +++ b/Source/Engine/Content/Assets/Shader.cpp @@ -18,11 +18,7 @@ Shader::Shader(const SpawnParams& params, const AssetInfo* info) : ShaderAssetTypeBase(params, info) { ASSERT(GPUDevice::Instance); - StringView name = info->Path; -#if GPU_ENABLE_RESOURCE_NAMING && !USE_EDITOR - name = Content::GetRegistry()->GetEditorAssetPath(info->ID); -#endif - _shader = GPUDevice::Instance->CreateShader(name); + _shader = GPUDevice::Instance->CreateShader(GPU_GET_RESOURCE_NAME_FROM_ASSET(info)); ASSERT(_shader); GPU = _shader; } diff --git a/Source/Engine/Graphics/GPUDevice.h b/Source/Engine/Graphics/GPUDevice.h index 6e7cd6612..b9f681b5c 100644 --- a/Source/Engine/Graphics/GPUDevice.h +++ b/Source/Engine/Graphics/GPUDevice.h @@ -512,3 +512,10 @@ struct FLAXENGINE_API GPUDeviceLock : NonCopyable Device->Locker.Unlock(); } }; + +// Utility to get GPU resource name (StringView) from the AssetInfo. Supports cooked builds with enabled debug resource naming that resolves original file path from the project to boost debugging experience. +#if GPU_ENABLE_RESOURCE_NAMING && !USE_EDITOR +#define GPU_GET_RESOURCE_NAME_FROM_ASSET(assetInfo) Content::GetRegistry()->GetEditorAssetPath(info->ID) +#else +#define GPU_GET_RESOURCE_NAME_FROM_ASSET(assetInfo) info->Path +#endif diff --git a/Source/Engine/Graphics/Textures/TextureBase.cpp b/Source/Engine/Graphics/Textures/TextureBase.cpp index eb838fa07..b5f020611 100644 --- a/Source/Engine/Graphics/Textures/TextureBase.cpp +++ b/Source/Engine/Graphics/Textures/TextureBase.cpp @@ -15,6 +15,10 @@ #include "Engine/Scripting/Enums.h" #include "Engine/Tools/TextureTool/TextureTool.h" #include "Engine/Threading/Threading.h" +#if GPU_ENABLE_RESOURCE_NAMING && !USE_EDITOR +#include "Engine/Content/Content.h" +#include "Engine/Content/Cache/AssetsCache.h" +#endif TextureMipData::TextureMipData() : RowPitch(0) @@ -243,7 +247,7 @@ REGISTER_BINARY_ASSET_ABSTRACT(TextureBase, "FlaxEngine.TextureBase"); TextureBase::TextureBase(const SpawnParams& params, const AssetInfo* info) : BinaryAsset(params, info) - , _texture(this, info->Path) + , _texture(this, GPU_GET_RESOURCE_NAME_FROM_ASSET(info)) , _customData(nullptr) , _parent(this) {