Refactor GPU Debug Layers to be manually activated with -gpudebug
Debug builds don't activate it by default. Can be sued in both Debug and Development builds. `GPU_ENABLE_DIAGNOSTICS` renamed to `GPU_ENABLE_DEBUG_LAYER` `GPU_ENABLE_WINDOW_SRV` renamed to `GPU_ENABLE_WINDOW_SRV` `GPU_USE_SHADERS_DEBUG_LAYER` renamed to `GPU_ENABLE_SHADERS_DEBUG_LAYER`
This commit is contained in:
@@ -183,6 +183,7 @@ bool CommandLine::Parse(const Char* cmdLine)
|
||||
#endif
|
||||
#if USE_EDITOR || !BUILD_RELEASE
|
||||
PARSE_BOOL_SWITCH("-shaderprofile ", ShaderProfile);
|
||||
PARSE_BOOL_SWITCH("-gpudebug ", GPUDebug);
|
||||
#endif
|
||||
|
||||
return false;
|
||||
|
||||
@@ -204,6 +204,11 @@ public:
|
||||
/// -shaderprofile (enables debugging data generation for shaders but leaves shader compiler optimizations active for performance profiling)
|
||||
/// </summary>
|
||||
Nullable<bool> ShaderProfile;
|
||||
|
||||
/// <summary>
|
||||
/// -gpudebug (activates GPU Debug Layers and additional assertions for rendering validation)
|
||||
/// </summary>
|
||||
Nullable<bool> GPUDebug;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#define GPU_ENABLE_TEXTURES_STREAMING 1
|
||||
|
||||
// Enable/disable creating Shader Resource View for window backbuffer surface
|
||||
#define GPU_USE_WINDOW_SRV 1
|
||||
#define GPU_ENABLE_WINDOW_SRV 1
|
||||
|
||||
// True if allow graphics profile events and markers
|
||||
#ifndef GPU_ALLOW_PROFILE_EVENTS
|
||||
@@ -85,8 +85,11 @@
|
||||
// Enable/disable gpu resources naming
|
||||
#define GPU_ENABLE_RESOURCE_NAMING (!BUILD_RELEASE)
|
||||
|
||||
// Enable/disable gpu debug layer support (activated via '-gpudebug')
|
||||
#define GPU_ENABLE_DEBUG_LAYER (!BUILD_RELEASE)
|
||||
|
||||
// True if use debug tools and flow for shaders
|
||||
#define GPU_USE_SHADERS_DEBUG_LAYER (BUILD_DEBUG)
|
||||
#define GPU_ENABLE_SHADERS_DEBUG_LAYER (BUILD_DEBUG)
|
||||
|
||||
// Maximum size of the texture that is supported by the engine (specific platforms can have lower limit)
|
||||
#define GPU_MAX_TEXTURE_SIZE 16384
|
||||
|
||||
@@ -369,6 +369,9 @@ GPUDevice::GPUDevice(RendererType type, ShaderProfile profile)
|
||||
, _state(DeviceState::Missing)
|
||||
, _isRendering(false)
|
||||
, _wasVSyncUsed(false)
|
||||
#if GPU_ENABLE_DEBUG_LAYER
|
||||
, _debugLayer(CommandLine::Options.GPUDebug.IsTrue())
|
||||
#endif
|
||||
, _drawGpuEventIndex(0)
|
||||
, _rendererType(type)
|
||||
, _shaderProfile(profile)
|
||||
|
||||
@@ -152,6 +152,9 @@ protected:
|
||||
DeviceState _state;
|
||||
bool _isRendering;
|
||||
bool _wasVSyncUsed;
|
||||
#if GPU_ENABLE_DEBUG_LAYER
|
||||
bool _debugLayer;
|
||||
#endif
|
||||
int32 _drawGpuEventIndex;
|
||||
RendererType _rendererType;
|
||||
ShaderProfile _shaderProfile;
|
||||
|
||||
@@ -15,12 +15,6 @@ public abstract class GraphicsDeviceBaseModule : EngineModule
|
||||
{
|
||||
base.Setup(options);
|
||||
|
||||
if (options.Configuration == TargetConfiguration.Debug && true)
|
||||
{
|
||||
// Enables GPU diagnostic tools (debug layer etc.)
|
||||
options.PublicDefinitions.Add("GPU_ENABLE_DIAGNOSTICS");
|
||||
}
|
||||
|
||||
if (Profiler.Use(options) && tracy.Use(options) && tracy.GPU && true)
|
||||
{
|
||||
// Enables GPU profiling with Tracy
|
||||
|
||||
@@ -124,8 +124,9 @@ static bool TryCreateDevice(IDXGIAdapter* adapter, D3D_FEATURE_LEVEL maxFeatureL
|
||||
ID3D11Device* device = nullptr;
|
||||
ID3D11DeviceContext* context = nullptr;
|
||||
uint32 deviceFlags = D3D11_CREATE_DEVICE_SINGLETHREADED | D3D11_CREATE_DEVICE_BGRA_SUPPORT;
|
||||
#if GPU_ENABLE_DIAGNOSTICS
|
||||
deviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
||||
#if GPU_ENABLE_DEBUG_LAYER
|
||||
if (CommandLine::Options.GPUDebug.IsTrue())
|
||||
deviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
|
||||
#endif
|
||||
|
||||
// Pick the first level
|
||||
@@ -166,7 +167,11 @@ static bool TryCreateDevice(IDXGIAdapter* adapter, D3D_FEATURE_LEVEL maxFeatureL
|
||||
context->Release();
|
||||
return true;
|
||||
}
|
||||
#if GPU_ENABLE_DIAGNOSTICS
|
||||
#if GPU_ENABLE_DEBUG_LAYER
|
||||
if ((deviceFlags & D3D11_CREATE_DEVICE_DEBUG) != D3D11_CREATE_DEVICE_DEBUG)
|
||||
return false;
|
||||
|
||||
// Retry without debug layer
|
||||
deviceFlags &= ~D3D11_CREATE_DEVICE_DEBUG;
|
||||
if (SUCCEEDED(D3D11CreateDevice(
|
||||
adapter,
|
||||
@@ -545,9 +550,12 @@ bool GPUDeviceDX11::Init()
|
||||
|
||||
// Get flags and device type base on current configuration
|
||||
uint32 flags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
|
||||
#if GPU_ENABLE_DIAGNOSTICS
|
||||
flags |= D3D11_CREATE_DEVICE_DEBUG;
|
||||
LOG(Info, "DirectX debugging layer enabled");
|
||||
#if GPU_ENABLE_DEBUG_LAYER
|
||||
if (_debugLayer)
|
||||
{
|
||||
flags |= D3D11_CREATE_DEVICE_DEBUG;
|
||||
LOG(Info, "DirectX debugging layer enabled");
|
||||
}
|
||||
#endif
|
||||
|
||||
// Create DirectX device
|
||||
@@ -712,9 +720,10 @@ bool GPUDeviceDX11::Init()
|
||||
}
|
||||
|
||||
// Init debug layer
|
||||
#if GPU_ENABLE_DIAGNOSTICS
|
||||
#if GPU_ENABLE_DEBUG_LAYER
|
||||
ComPtr<ID3D11InfoQueue> infoQueue;
|
||||
VALIDATE_DIRECTX_CALL(_device->QueryInterface(IID_PPV_ARGS(&infoQueue)));
|
||||
if (_debugLayer)
|
||||
_device->QueryInterface(IID_PPV_ARGS(&infoQueue));
|
||||
if (infoQueue)
|
||||
{
|
||||
D3D11_INFO_QUEUE_FILTER filter;
|
||||
@@ -905,7 +914,7 @@ void GPUDeviceDX11::Dispose()
|
||||
SAFE_DELETE(_mainContext);
|
||||
SAFE_DELETE(_adapter);
|
||||
SAFE_RELEASE(_imContext);
|
||||
#if GPU_ENABLE_DIAGNOSTICS && 0
|
||||
#if GPU_ENABLE_DEBUG_LAYER && 0
|
||||
ID3D11Debug* debugLayer = nullptr;
|
||||
_device->QueryInterface(IID_PPV_ARGS(&debugLayer));
|
||||
if (debugLayer)
|
||||
@@ -934,10 +943,11 @@ void GPUDeviceDX11::DrawEnd()
|
||||
{
|
||||
GPUDeviceDX::DrawEnd();
|
||||
|
||||
#if GPU_ENABLE_DIAGNOSTICS && LOG_ENABLE
|
||||
#if GPU_ENABLE_DEBUG_LAYER && LOG_ENABLE
|
||||
// Flush debug messages queue
|
||||
ComPtr<ID3D11InfoQueue> infoQueue;
|
||||
VALIDATE_DIRECTX_CALL(_device->QueryInterface(IID_PPV_ARGS(&infoQueue)));
|
||||
if (_debugLayer)
|
||||
_device->QueryInterface(IID_PPV_ARGS(&infoQueue));
|
||||
if (infoQueue)
|
||||
{
|
||||
Array<uint8> data;
|
||||
|
||||
@@ -144,7 +144,6 @@ public:
|
||||
GPUBuffer* GetDummyVB();
|
||||
|
||||
public:
|
||||
|
||||
// [GPUDeviceDX]
|
||||
GPUContext* GetMainContext() override
|
||||
{
|
||||
|
||||
@@ -35,7 +35,7 @@ void GPUSwapChainDX11::getBackBuffer()
|
||||
ID3D11RenderTargetView* rtv;
|
||||
ID3D11ShaderResourceView* srv;
|
||||
VALIDATE_DIRECTX_CALL(_device->GetDevice()->CreateRenderTargetView(_backBuffer, nullptr, &rtv));
|
||||
#if GPU_USE_WINDOW_SRV
|
||||
#if GPU_ENABLE_WINDOW_SRV
|
||||
VALIDATE_DIRECTX_CALL(_device->GetDevice()->CreateShaderResourceView(_backBuffer, nullptr, &srv));
|
||||
#else
|
||||
srv = nullptr;
|
||||
@@ -229,7 +229,7 @@ bool GPUSwapChainDX11::Resize(int32 width, int32 height)
|
||||
swapChainDesc.Scaling = DXGI_SCALING_NONE;
|
||||
swapChainDesc.AlphaMode = DXGI_ALPHA_MODE_IGNORE;
|
||||
#endif
|
||||
#if GPU_USE_WINDOW_SRV
|
||||
#if GPU_ENABLE_WINDOW_SRV
|
||||
swapChainDesc.BufferUsage |= DXGI_USAGE_SHADER_INPUT;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -406,36 +406,39 @@ GPUDevice* GPUDeviceDX12::Create()
|
||||
#endif
|
||||
|
||||
// Debug Layer
|
||||
#if GPU_ENABLE_DIAGNOSTICS
|
||||
ComPtr<ID3D12Debug> debugLayer;
|
||||
D3D12GetDebugInterface(IID_PPV_ARGS(&debugLayer));
|
||||
if (debugLayer)
|
||||
#if GPU_ENABLE_DEBUG_LAYER
|
||||
if (CommandLine::Options.GPUDebug.IsTrue())
|
||||
{
|
||||
debugLayer->EnableDebugLayer();
|
||||
LOG(Info, "DirectX debugging layer enabled");
|
||||
}
|
||||
ComPtr<ID3D12Debug> debugLayer;
|
||||
D3D12GetDebugInterface(IID_PPV_ARGS(&debugLayer));
|
||||
if (debugLayer)
|
||||
{
|
||||
debugLayer->EnableDebugLayer();
|
||||
LOG(Info, "DirectX debugging layer enabled");
|
||||
}
|
||||
#if 0
|
||||
#ifdef __ID3D12Debug1_FWD_DEFINED__
|
||||
ComPtr<ID3D12Debug1> debugLayer1;
|
||||
D3D12GetDebugInterface(IID_PPV_ARGS(&debugLayer1));
|
||||
if (debugLayer1)
|
||||
{
|
||||
// GPU-based validation and synchronized validation for debugging only
|
||||
debugLayer1->SetEnableGPUBasedValidation(true);
|
||||
debugLayer1->SetEnableSynchronizedCommandQueueValidation(true);
|
||||
}
|
||||
ComPtr<ID3D12Debug1> debugLayer1;
|
||||
D3D12GetDebugInterface(IID_PPV_ARGS(&debugLayer1));
|
||||
if (debugLayer1)
|
||||
{
|
||||
// GPU-based validation and synchronized validation for debugging only
|
||||
debugLayer1->SetEnableGPUBasedValidation(true);
|
||||
debugLayer1->SetEnableSynchronizedCommandQueueValidation(true);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __ID3D12DeviceRemovedExtendedDataSettings_FWD_DEFINED__
|
||||
ComPtr<ID3D12DeviceRemovedExtendedDataSettings> dredSettings;
|
||||
D3D12GetDebugInterface(IID_PPV_ARGS(&dredSettings));
|
||||
if (dredSettings)
|
||||
{
|
||||
// Turn on AutoBreadcrumbs and Page Fault reporting
|
||||
dredSettings->SetAutoBreadcrumbsEnablement(D3D12_DRED_ENABLEMENT_FORCED_ON);
|
||||
dredSettings->SetPageFaultEnablement(D3D12_DRED_ENABLEMENT_FORCED_ON);
|
||||
}
|
||||
ComPtr<ID3D12DeviceRemovedExtendedDataSettings> dredSettings;
|
||||
D3D12GetDebugInterface(IID_PPV_ARGS(&dredSettings));
|
||||
if (dredSettings)
|
||||
{
|
||||
// Turn on AutoBreadcrumbs and Page Fault reporting
|
||||
dredSettings->SetAutoBreadcrumbsEnablement(D3D12_DRED_ENABLEMENT_FORCED_ON);
|
||||
dredSettings->SetPageFaultEnablement(D3D12_DRED_ENABLEMENT_FORCED_ON);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
// Create DXGI factory (CreateDXGIFactory2 is supported on Windows 8.1 or newer)
|
||||
@@ -612,8 +615,9 @@ bool GPUDeviceDX12::Init()
|
||||
// Create DirectX device
|
||||
D3D12XBOX_CREATE_DEVICE_PARAMETERS params = {};
|
||||
params.Version = D3D12_SDK_VERSION;
|
||||
#if GPU_ENABLE_DIAGNOSTICS
|
||||
params.ProcessDebugFlags = D3D12_PROCESS_DEBUG_FLAG_DEBUG_LAYER_ENABLED;
|
||||
#if GPU_ENABLE_DEBUG_LAYER
|
||||
if (_debugLayer)
|
||||
params.ProcessDebugFlags = D3D12_PROCESS_DEBUG_FLAG_DEBUG_LAYER_ENABLED;
|
||||
#elif !BUILD_RELEASE
|
||||
params.ProcessDebugFlags = D3D12XBOX_PROCESS_DEBUG_FLAG_INSTRUMENTED;
|
||||
#endif
|
||||
@@ -740,10 +744,10 @@ bool GPUDeviceDX12::Init()
|
||||
}
|
||||
|
||||
// Debug Layer
|
||||
#if GPU_ENABLE_DIAGNOSTICS
|
||||
#if GPU_ENABLE_DEBUG_LAYER
|
||||
ComPtr<ID3D12InfoQueue> infoQueue;
|
||||
hr = _device->QueryInterface(IID_PPV_ARGS(&infoQueue));
|
||||
LOG_DIRECTX_RESULT(hr);
|
||||
if (_debugLayer)
|
||||
_device->QueryInterface(IID_PPV_ARGS(&infoQueue));
|
||||
if (infoQueue)
|
||||
{
|
||||
D3D12_INFO_QUEUE_FILTER filter;
|
||||
@@ -794,7 +798,6 @@ bool GPUDeviceDX12::Init()
|
||||
VALIDATE_DIRECTX_CALL(_device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &options, sizeof(options)));
|
||||
LOG(Info, "Tiled Resources Tier: {0}", (int32)options.TiledResourcesTier);
|
||||
LOG(Info, "Resource Binding Tier: {0}", (int32)options.ResourceBindingTier);
|
||||
LOG(Info, "Conservative Rasterization Tier: {0}", (int32)options.ConservativeRasterizationTier);
|
||||
LOG(Info, "Resource Heap Tier: {0}", (int32)options.ResourceHeapTier);
|
||||
|
||||
// Init device limits
|
||||
@@ -841,10 +844,9 @@ bool GPUDeviceDX12::Init()
|
||||
D3D12_FEATURE_DATA_D3D12_OPTIONS2 options2 = {};
|
||||
if (SUCCEEDED(_device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS2, &options2, sizeof(options2))))
|
||||
limits.HasDepthBounds = !!options2.DepthBoundsTestSupported;
|
||||
|
||||
}
|
||||
|
||||
#if !BUILD_RELEASE
|
||||
#if USE_EDITOR || !BUILD_RELEASE
|
||||
// Prevent the GPU from overclocking or under-clocking to get consistent timings
|
||||
if (CommandLine::Options.ShaderProfile.IsTrue())
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@ void BackBufferDX12::Setup(GPUSwapChainDX12* window, ID3D12Resource* backbuffer)
|
||||
Handle.SetRTV(rtDesc);
|
||||
}
|
||||
|
||||
#if GPU_USE_WINDOW_SRV
|
||||
#if GPU_ENABLE_WINDOW_SRV
|
||||
// Create SRV
|
||||
{
|
||||
D3D12_SHADER_RESOURCE_VIEW_DESC srDesc;
|
||||
@@ -198,7 +198,7 @@ bool GPUSwapChainDX12::Resize(int32 width, int32 height)
|
||||
swapChainDesc.Scaling = DXGI_SCALING_STRETCH;
|
||||
swapChainDesc.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED;
|
||||
swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
|
||||
#if GPU_USE_WINDOW_SRV
|
||||
#if GPU_ENABLE_WINDOW_SRV
|
||||
swapChainDesc.BufferUsage |= DXGI_USAGE_SHADER_INPUT;
|
||||
#endif
|
||||
if (_allowTearing)
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace RenderToolsDX
|
||||
#define LOG_DIRECTX_RESULT(result) if (FAILED(result)) RenderToolsDX::LogD3DResult(result, __FILE__, __LINE__)
|
||||
#define LOG_DIRECTX_RESULT_WITH_RETURN(result, returnValue) if (FAILED(result)) { RenderToolsDX::LogD3DResult(result, __FILE__, __LINE__); return returnValue; }
|
||||
|
||||
#if GPU_ENABLE_DIAGNOSTICS || COMPILE_WITH_SHADER_COMPILER || GPU_ENABLE_RESOURCE_NAMING
|
||||
#if GPU_ENABLE_DEBUG_LAYER || COMPILE_WITH_SHADER_COMPILER || GPU_ENABLE_RESOURCE_NAMING
|
||||
|
||||
#include "Engine/Utilities/StringConverter.h"
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
#define VULKAN_ENABLE_API_DUMP 0
|
||||
#define VULKAN_RESET_QUERY_POOLS 1
|
||||
#define VULKAN_HASH_POOLS_WITH_LAYOUT_TYPES 1
|
||||
#define VULKAN_USE_DEBUG_LAYER GPU_ENABLE_DIAGNOSTICS
|
||||
#define VULKAN_USE_DEBUG_DATA (GPU_ENABLE_DIAGNOSTICS && COMPILE_WITH_DEV_ENV)
|
||||
#define VULKAN_USE_DEBUG_LAYER GPU_ENABLE_DEBUG_LAYER
|
||||
#define VULKAN_USE_DEBUG_DATA (GPU_ENABLE_DEBUG_LAYER && COMPILE_WITH_DEV_ENV)
|
||||
|
||||
#ifndef VULKAN_USE_PIPELINE_CACHE
|
||||
#define VULKAN_USE_PIPELINE_CACHE 1
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Core/Collections/ArrayExtensions.h"
|
||||
#include "Engine/Core/Collections/Sorting.h"
|
||||
#include "Engine/Engine/CommandLine.h"
|
||||
|
||||
#if GRAPHICS_API_VULKAN
|
||||
|
||||
// TODO: expose it as a command line or engine parameter to end-user
|
||||
#if GPU_ENABLE_DIAGNOSTICS
|
||||
#if GPU_ENABLE_DEBUG_LAYER
|
||||
VulkanValidationLevel ValidationLevel = VulkanValidationLevel::ErrorsAndWarningsPerf;
|
||||
#else
|
||||
VulkanValidationLevel ValidationLevel = VulkanValidationLevel::Disabled;
|
||||
@@ -18,7 +18,6 @@ VulkanValidationLevel ValidationLevel = VulkanValidationLevel::Disabled;
|
||||
|
||||
#if VULKAN_USE_DEBUG_LAYER
|
||||
|
||||
// TODO: expose it as a command line or engine parameter to end-user
|
||||
#define VULKAN_USE_KHRONOS_STANDARD_VALIDATION 1 // uses VK_LAYER_KHRONOS_validation
|
||||
#define VULKAN_USE_LUNARG_STANDARD_VALIDATION 1 // uses VK_LAYER_LUNARG_standard_validation
|
||||
|
||||
@@ -217,7 +216,7 @@ static bool ListContains(const Array<StringAnsi>& list, const char* name)
|
||||
return false;
|
||||
}
|
||||
|
||||
void GPUDeviceVulkan::GetInstanceLayersAndExtensions(Array<const char*>& outInstanceExtensions, Array<const char*>& outInstanceLayers, bool& outDebugUtils)
|
||||
void GPUDeviceVulkan::GetInstanceLayersAndExtensions(Array<const char*>& outInstanceExtensions, Array<const char*>& outInstanceLayers, bool& outDebugUtils, bool useDebugLayer)
|
||||
{
|
||||
VkResult result;
|
||||
outDebugUtils = false;
|
||||
@@ -281,10 +280,13 @@ void GPUDeviceVulkan::GetInstanceLayersAndExtensions(Array<const char*>& outInst
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: expose as a command line parameter or sth
|
||||
#if VULKAN_USE_DEBUG_LAYER
|
||||
if (!useDebugLayer)
|
||||
ValidationLevel = VulkanValidationLevel::Disabled;
|
||||
const bool useVkTrace = false;
|
||||
|
||||
bool vkTrace = false;
|
||||
if (useVkTrace)
|
||||
if (useVkTrace && useDebugLayer)
|
||||
{
|
||||
const char* VkTraceName = "VK_LAYER_LUNARG_vktrace";
|
||||
if (ContainsLayer(globalLayerExtensions, VkTraceName))
|
||||
@@ -294,9 +296,8 @@ void GPUDeviceVulkan::GetInstanceLayersAndExtensions(Array<const char*>& outInst
|
||||
}
|
||||
}
|
||||
|
||||
#if VULKAN_USE_DEBUG_LAYER
|
||||
#if VULKAN_ENABLE_API_DUMP
|
||||
if (!vkTrace)
|
||||
if (!vkTrace && useDebugLayer)
|
||||
{
|
||||
const char* VkApiDumpName = "VK_LAYER_LUNARG_api_dump";
|
||||
if (FindLayerInList(globalLayerExtensions, VkApiDumpName))
|
||||
@@ -499,13 +500,13 @@ void GPUDeviceVulkan::GetDeviceExtensionsAndLayers(VkPhysicalDevice gpu, Array<c
|
||||
#if VULKAN_USE_KHRONOS_STANDARD_VALIDATION
|
||||
const char* vkLayerKhronosValidation = "VK_LAYER_KHRONOS_validation";
|
||||
hasKhronosStandardValidationLayer = ContainsLayer(deviceLayerExtensions, vkLayerKhronosValidation);
|
||||
if (hasKhronosStandardValidationLayer)
|
||||
if (hasKhronosStandardValidationLayer && _debugLayer)
|
||||
{
|
||||
outDeviceLayers.Add(vkLayerKhronosValidation);
|
||||
}
|
||||
#endif
|
||||
#if VULKAN_USE_LUNARG_STANDARD_VALIDATION
|
||||
if (!hasKhronosStandardValidationLayer)
|
||||
if (!hasKhronosStandardValidationLayer && _debugLayer)
|
||||
{
|
||||
const char* vkLayerLunargStandardValidation = "VK_LAYER_LUNARG_standard_validation";
|
||||
hasLunargStandardValidationLayer = ContainsLayer(deviceLayerExtensions, vkLayerLunargStandardValidation);
|
||||
@@ -515,7 +516,7 @@ void GPUDeviceVulkan::GetDeviceExtensionsAndLayers(VkPhysicalDevice gpu, Array<c
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (!hasKhronosStandardValidationLayer && !hasLunargStandardValidationLayer)
|
||||
if (!hasKhronosStandardValidationLayer && !hasLunargStandardValidationLayer && _debugLayer)
|
||||
{
|
||||
for (uint32 i = 0; GValidationLayers[i] != nullptr; i++)
|
||||
{
|
||||
|
||||
@@ -1036,7 +1036,12 @@ GPUDevice* GPUDeviceVulkan::Create()
|
||||
instInfo.flags |= VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR;
|
||||
#endif
|
||||
instInfo.pApplicationInfo = &appInfo;
|
||||
GetInstanceLayersAndExtensions(InstanceExtensions, InstanceLayers, SupportsDebugUtilsExt);
|
||||
#if VULKAN_USE_DEBUG_LAYER
|
||||
bool useDebugLayer = CommandLine::Options.GPUDebug.IsTrue();
|
||||
#else
|
||||
bool useDebugLayer = false;
|
||||
#endif
|
||||
GetInstanceLayersAndExtensions(InstanceExtensions, InstanceLayers, SupportsDebugUtilsExt, useDebugLayer);
|
||||
instInfo.enabledExtensionCount = InstanceExtensions.Count();
|
||||
instInfo.ppEnabledExtensionNames = instInfo.enabledExtensionCount > 0 ? static_cast<const char* const*>(InstanceExtensions.Get()) : nullptr;
|
||||
instInfo.enabledLayerCount = InstanceLayers.Count();
|
||||
@@ -1134,7 +1139,8 @@ GPUDevice* GPUDeviceVulkan::Create()
|
||||
|
||||
// Setup debug layer
|
||||
#if VULKAN_USE_DEBUG_LAYER
|
||||
SetupDebugLayerCallback();
|
||||
if (useDebugLayer)
|
||||
SetupDebugLayerCallback();
|
||||
#endif
|
||||
|
||||
// Enumerate all GPU devices and pick one
|
||||
|
||||
@@ -395,7 +395,7 @@ public:
|
||||
static OptionalVulkanDeviceExtensions OptionalDeviceExtensions;
|
||||
|
||||
private:
|
||||
static void GetInstanceLayersAndExtensions(Array<const char*>& outInstanceExtensions, Array<const char*>& outInstanceLayers, bool& outDebugUtils);
|
||||
static void GetInstanceLayersAndExtensions(Array<const char*>& outInstanceExtensions, Array<const char*>& outInstanceLayers, bool& outDebugUtils, bool useDebugLayer = false);
|
||||
void GetDeviceExtensionsAndLayers(VkPhysicalDevice gpu, Array<const char*>& outDeviceExtensions, Array<const char*>& outDeviceLayers);
|
||||
static void ParseOptionalDeviceExtensions(const Array<const char*>& deviceExtensions);
|
||||
|
||||
|
||||
@@ -399,7 +399,7 @@ bool GPUSwapChainVulkan::CreateSwapChain(int32 width, int32 height)
|
||||
swapChainInfo.imageExtent.width = width;
|
||||
swapChainInfo.imageExtent.height = height;
|
||||
swapChainInfo.imageUsage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
#if GPU_USE_WINDOW_SRV
|
||||
#if GPU_ENABLE_WINDOW_SRV
|
||||
swapChainInfo.imageUsage |= VK_IMAGE_USAGE_SAMPLED_BIT;
|
||||
#endif
|
||||
swapChainInfo.preTransform = surfProperties.currentTransform;
|
||||
|
||||
@@ -1233,7 +1233,7 @@ void GPUContextWebGPU::BuildBindGroup(uint32 groupIndex, const SpirvShaderDescri
|
||||
break;
|
||||
}
|
||||
default:
|
||||
#if GPU_ENABLE_DIAGNOSTICS
|
||||
#if GPU_ENABLE_DEBUG_LAYER
|
||||
LOG(Fatal, "Unknown descriptor type: {} used as {}", (uint32)descriptor.DescriptorType, (uint32)descriptor.BindingType);
|
||||
#else
|
||||
CRASH;
|
||||
|
||||
@@ -123,6 +123,7 @@ public:
|
||||
/// </summary>
|
||||
class GPUDeviceWebGPU : public GPUDevice
|
||||
{
|
||||
friend class GPUSwapChainWebGPU;
|
||||
private:
|
||||
GPUContextWebGPU* _mainContext = nullptr;
|
||||
|
||||
|
||||
@@ -295,7 +295,7 @@ WGPUBindGroupLayout CreateBindGroupLayout(WGPUDevice device, const GPUContextBin
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
#if GPU_ENABLE_DIAGNOSTICS
|
||||
#if GPU_ENABLE_DEBUG_LAYER
|
||||
LOG(Fatal, "Unknown descriptor type: {} used as {} in '{}'", (uint32)descriptor.DescriptorType, (uint32)descriptor.BindingType, String(debugName));
|
||||
#else
|
||||
CRASH;
|
||||
|
||||
@@ -71,7 +71,7 @@ GPUShaderProgram* GPUShaderWebGPU::CreateGPUShaderProgram(ShaderStage type, cons
|
||||
if (!shaderModule)
|
||||
{
|
||||
LOG(Error, "Failed to create a shader module");
|
||||
#if GPU_ENABLE_DIAGNOSTICS
|
||||
#if GPU_ENABLE_DEBUG_LAYER
|
||||
LOG_STR(Warning, String((char*)wgsl.Get(), wgsl.Length()));
|
||||
#endif
|
||||
return nullptr;
|
||||
|
||||
@@ -114,8 +114,9 @@ bool GPUSwapChainWebGPU::Resize(int32 width, int32 height)
|
||||
return false;
|
||||
_device->WaitForGPU();
|
||||
GPUDeviceLock lock(_device);
|
||||
#if GPU_ENABLE_DIAGNOSTICS
|
||||
LOG(Info, "Resizing WebGPU surface to: {}x{}", width, height);
|
||||
#if GPU_ENABLE_DEBUG_LAYER
|
||||
if (_device->_debugLayer)
|
||||
LOG(Info, "Resizing WebGPU surface to: {}x{}", width, height);
|
||||
#endif
|
||||
|
||||
// Ensure to have a surface
|
||||
@@ -145,7 +146,7 @@ bool GPUSwapChainWebGPU::Resize(int32 width, int32 height)
|
||||
WGPUSurfaceConfiguration configuration = WGPU_SURFACE_CONFIGURATION_INIT;
|
||||
configuration.device = _device->Device;
|
||||
configuration.usage = WGPUTextureUsage_RenderAttachment;
|
||||
#if GPU_USE_WINDOW_SRV
|
||||
#if GPU_ENABLE_WINDOW_SRV
|
||||
configuration.usage |= WGPUTextureUsage_TextureBinding;
|
||||
#endif
|
||||
configuration.width = width;
|
||||
|
||||
@@ -47,7 +47,7 @@ ShaderCompilerD3D::ShaderCompilerD3D(ShaderProfile profile)
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef GPU_USE_SHADERS_DEBUG_LAYER
|
||||
#ifdef GPU_ENABLE_SHADERS_DEBUG_LAYER
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -321,7 +321,7 @@ bool ShaderCompilerD3D::CompileShader(ShaderFunctionMeta& meta, WritePermutation
|
||||
if (ProcessShader(_context, _constantBuffers, reflector.Get(), desc, bindings))
|
||||
return true;
|
||||
|
||||
#ifdef GPU_USE_SHADERS_DEBUG_LAYER
|
||||
#ifdef GPU_ENABLE_SHADERS_DEBUG_LAYER
|
||||
// Generate debug information
|
||||
if (ProcessDebugInfo(_context, meta, permutationIndex, shaderBuffer, shaderBufferSize))
|
||||
return true;
|
||||
|
||||
@@ -263,7 +263,7 @@ bool ShaderCompilerDX::CompileShader(ShaderFunctionMeta& meta, WritePermutationD
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef GPU_USE_SHADERS_DEBUG_LAYER
|
||||
#ifdef GPU_ENABLE_SHADERS_DEBUG_LAYER
|
||||
// Generate debug information
|
||||
{
|
||||
// Disassemble compiled shader
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "ShaderCompilationContext.h"
|
||||
#include "Engine/Graphics/Config.h"
|
||||
|
||||
#if GPU_USE_SHADERS_DEBUG_LAYER && COMPILE_WITH_SHADER_COMPILER
|
||||
#if GPU_ENABLE_SHADERS_DEBUG_LAYER && COMPILE_WITH_SHADER_COMPILER
|
||||
|
||||
#include "Engine/Platform/File.h"
|
||||
#include "Engine/Platform/FileSystem.h"
|
||||
|
||||
@@ -177,7 +177,7 @@ bool ShadersCompilation::Compile(ShaderCompilationOptions& options)
|
||||
result = compiler->Compile(&context);
|
||||
FreeCompiler(compiler);
|
||||
|
||||
#if GPU_USE_SHADERS_DEBUG_LAYER
|
||||
#if GPU_ENABLE_SHADERS_DEBUG_LAYER
|
||||
// Export debug data
|
||||
ShaderDebugDataExporter::Export(&context);
|
||||
#endif
|
||||
@@ -627,7 +627,7 @@ void ShaderCompilationContext::OnError(const char* message)
|
||||
|
||||
void ShaderCompilationContext::OnCollectDebugInfo(ShaderFunctionMeta& meta, int32 permutationIndex, const char* data, const int32 dataLength)
|
||||
{
|
||||
#ifdef GPU_USE_SHADERS_DEBUG_LAYER
|
||||
#ifdef GPU_ENABLE_SHADERS_DEBUG_LAYER
|
||||
|
||||
// Cache data
|
||||
meta.Permutations[permutationIndex].DebugData.Set(data, dataLength);
|
||||
|
||||
Reference in New Issue
Block a user