Fix texture GPU resource debug name in non-Release game builds to match the path in project

This commit is contained in:
Wojtek Figat
2026-02-20 23:43:29 +01:00
parent 1982694ef0
commit 5b3079acde
3 changed files with 13 additions and 6 deletions

View File

@@ -18,11 +18,7 @@ Shader::Shader(const SpawnParams& params, const AssetInfo* info)
: ShaderAssetTypeBase<BinaryAsset>(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;
}

View File

@@ -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

View File

@@ -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)
{