diff --git a/Source/Engine/Engine/CommandLine.cpp b/Source/Engine/Engine/CommandLine.cpp index 57e205a52..694ea9d19 100644 --- a/Source/Engine/Engine/CommandLine.cpp +++ b/Source/Engine/Engine/CommandLine.cpp @@ -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; diff --git a/Source/Engine/Engine/CommandLine.h b/Source/Engine/Engine/CommandLine.h index e60772bc1..2021f95e5 100644 --- a/Source/Engine/Engine/CommandLine.h +++ b/Source/Engine/Engine/CommandLine.h @@ -204,6 +204,11 @@ public: /// -shaderprofile (enables debugging data generation for shaders but leaves shader compiler optimizations active for performance profiling) /// Nullable ShaderProfile; + + /// + /// -gpudebug (activates GPU Debug Layers and additional assertions for rendering validation) + /// + Nullable GPUDebug; #endif }; diff --git a/Source/Engine/Graphics/Config.h b/Source/Engine/Graphics/Config.h index cd734ab98..0d5f53f13 100644 --- a/Source/Engine/Graphics/Config.h +++ b/Source/Engine/Graphics/Config.h @@ -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 diff --git a/Source/Engine/Graphics/GPUDevice.cpp b/Source/Engine/Graphics/GPUDevice.cpp index 1f46c7150..973a0c445 100644 --- a/Source/Engine/Graphics/GPUDevice.cpp +++ b/Source/Engine/Graphics/GPUDevice.cpp @@ -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) diff --git a/Source/Engine/Graphics/GPUDevice.h b/Source/Engine/Graphics/GPUDevice.h index 1f0a1007d..a57ab11bc 100644 --- a/Source/Engine/Graphics/GPUDevice.h +++ b/Source/Engine/Graphics/GPUDevice.h @@ -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; diff --git a/Source/Engine/Graphics/Graphics.Build.cs b/Source/Engine/Graphics/Graphics.Build.cs index 015e2c01d..58944eaa0 100644 --- a/Source/Engine/Graphics/Graphics.Build.cs +++ b/Source/Engine/Graphics/Graphics.Build.cs @@ -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 diff --git a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUDeviceDX11.cpp b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUDeviceDX11.cpp index f581753dc..84168238b 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUDeviceDX11.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUDeviceDX11.cpp @@ -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 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 infoQueue; - VALIDATE_DIRECTX_CALL(_device->QueryInterface(IID_PPV_ARGS(&infoQueue))); + if (_debugLayer) + _device->QueryInterface(IID_PPV_ARGS(&infoQueue)); if (infoQueue) { Array data; diff --git a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUDeviceDX11.h b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUDeviceDX11.h index 51e83345a..08007a0e3 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUDeviceDX11.h +++ b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUDeviceDX11.h @@ -144,7 +144,6 @@ public: GPUBuffer* GetDummyVB(); public: - // [GPUDeviceDX] GPUContext* GetMainContext() override { diff --git a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUSwapChainDX11.cpp b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUSwapChainDX11.cpp index 3856a7cd0..992871b4a 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX11/GPUSwapChainDX11.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX11/GPUSwapChainDX11.cpp @@ -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 diff --git a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUDeviceDX12.cpp b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUDeviceDX12.cpp index aa186ba52..868c865b7 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUDeviceDX12.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUDeviceDX12.cpp @@ -406,36 +406,39 @@ GPUDevice* GPUDeviceDX12::Create() #endif // Debug Layer -#if GPU_ENABLE_DIAGNOSTICS - ComPtr 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 debugLayer; + D3D12GetDebugInterface(IID_PPV_ARGS(&debugLayer)); + if (debugLayer) + { + debugLayer->EnableDebugLayer(); + LOG(Info, "DirectX debugging layer enabled"); + } #if 0 #ifdef __ID3D12Debug1_FWD_DEFINED__ - ComPtr debugLayer1; - D3D12GetDebugInterface(IID_PPV_ARGS(&debugLayer1)); - if (debugLayer1) - { - // GPU-based validation and synchronized validation for debugging only - debugLayer1->SetEnableGPUBasedValidation(true); - debugLayer1->SetEnableSynchronizedCommandQueueValidation(true); - } + ComPtr 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 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 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 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()) { diff --git a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUSwapChainDX12.cpp b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUSwapChainDX12.cpp index 83ecf020d..7c01b9e2d 100644 --- a/Source/Engine/GraphicsDevice/DirectX/DX12/GPUSwapChainDX12.cpp +++ b/Source/Engine/GraphicsDevice/DirectX/DX12/GPUSwapChainDX12.cpp @@ -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) diff --git a/Source/Engine/GraphicsDevice/DirectX/RenderToolsDX.h b/Source/Engine/GraphicsDevice/DirectX/RenderToolsDX.h index f16206c3b..f0a24b9b2 100644 --- a/Source/Engine/GraphicsDevice/DirectX/RenderToolsDX.h +++ b/Source/Engine/GraphicsDevice/DirectX/RenderToolsDX.h @@ -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" diff --git a/Source/Engine/GraphicsDevice/Vulkan/Config.h b/Source/Engine/GraphicsDevice/Vulkan/Config.h index fd5880400..e73e24df9 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/Config.h +++ b/Source/Engine/GraphicsDevice/Vulkan/Config.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 diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.Layers.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.Layers.cpp index 5ac20b613..136524562 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.Layers.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.Layers.cpp @@ -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& list, const char* name) return false; } -void GPUDeviceVulkan::GetInstanceLayersAndExtensions(Array& outInstanceExtensions, Array& outInstanceLayers, bool& outDebugUtils) +void GPUDeviceVulkan::GetInstanceLayersAndExtensions(Array& outInstanceExtensions, Array& outInstanceLayers, bool& outDebugUtils, bool useDebugLayer) { VkResult result; outDebugUtils = false; @@ -281,10 +280,13 @@ void GPUDeviceVulkan::GetInstanceLayersAndExtensions(Array& 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& 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 0 ? static_cast(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 diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h index eec67a18a..a1de50c2d 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUDeviceVulkan.h @@ -395,7 +395,7 @@ public: static OptionalVulkanDeviceExtensions OptionalDeviceExtensions; private: - static void GetInstanceLayersAndExtensions(Array& outInstanceExtensions, Array& outInstanceLayers, bool& outDebugUtils); + static void GetInstanceLayersAndExtensions(Array& outInstanceExtensions, Array& outInstanceLayers, bool& outDebugUtils, bool useDebugLayer = false); void GetDeviceExtensionsAndLayers(VkPhysicalDevice gpu, Array& outDeviceExtensions, Array& outDeviceLayers); static void ParseOptionalDeviceExtensions(const Array& deviceExtensions); diff --git a/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp b/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp index 6014c1c9e..6df6acbde 100644 --- a/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp +++ b/Source/Engine/GraphicsDevice/Vulkan/GPUSwapChainVulkan.cpp @@ -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; diff --git a/Source/Engine/GraphicsDevice/WebGPU/GPUContextWebGPU.cpp b/Source/Engine/GraphicsDevice/WebGPU/GPUContextWebGPU.cpp index 3d007cea0..8b132dde2 100644 --- a/Source/Engine/GraphicsDevice/WebGPU/GPUContextWebGPU.cpp +++ b/Source/Engine/GraphicsDevice/WebGPU/GPUContextWebGPU.cpp @@ -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; diff --git a/Source/Engine/GraphicsDevice/WebGPU/GPUDeviceWebGPU.h b/Source/Engine/GraphicsDevice/WebGPU/GPUDeviceWebGPU.h index f6ca4960b..dcffc8e82 100644 --- a/Source/Engine/GraphicsDevice/WebGPU/GPUDeviceWebGPU.h +++ b/Source/Engine/GraphicsDevice/WebGPU/GPUDeviceWebGPU.h @@ -123,6 +123,7 @@ public: /// class GPUDeviceWebGPU : public GPUDevice { + friend class GPUSwapChainWebGPU; private: GPUContextWebGPU* _mainContext = nullptr; diff --git a/Source/Engine/GraphicsDevice/WebGPU/GPUPipelineStateWebGPU.cpp b/Source/Engine/GraphicsDevice/WebGPU/GPUPipelineStateWebGPU.cpp index 18651d987..bdf54c602 100644 --- a/Source/Engine/GraphicsDevice/WebGPU/GPUPipelineStateWebGPU.cpp +++ b/Source/Engine/GraphicsDevice/WebGPU/GPUPipelineStateWebGPU.cpp @@ -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; diff --git a/Source/Engine/GraphicsDevice/WebGPU/GPUShaderWebGPU.cpp b/Source/Engine/GraphicsDevice/WebGPU/GPUShaderWebGPU.cpp index 402229465..d7e6cb0f8 100644 --- a/Source/Engine/GraphicsDevice/WebGPU/GPUShaderWebGPU.cpp +++ b/Source/Engine/GraphicsDevice/WebGPU/GPUShaderWebGPU.cpp @@ -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; diff --git a/Source/Engine/GraphicsDevice/WebGPU/GPUSwapChainWebGPU.cpp b/Source/Engine/GraphicsDevice/WebGPU/GPUSwapChainWebGPU.cpp index c1ae07c6f..e2cd2a69b 100644 --- a/Source/Engine/GraphicsDevice/WebGPU/GPUSwapChainWebGPU.cpp +++ b/Source/Engine/GraphicsDevice/WebGPU/GPUSwapChainWebGPU.cpp @@ -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; diff --git a/Source/Engine/ShadersCompilation/DirectX/ShaderCompilerD3D.cpp b/Source/Engine/ShadersCompilation/DirectX/ShaderCompilerD3D.cpp index f2b08ea04..9b335bbc3 100644 --- a/Source/Engine/ShadersCompilation/DirectX/ShaderCompilerD3D.cpp +++ b/Source/Engine/ShadersCompilation/DirectX/ShaderCompilerD3D.cpp @@ -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; diff --git a/Source/Engine/ShadersCompilation/DirectX/ShaderCompilerDX.cpp b/Source/Engine/ShadersCompilation/DirectX/ShaderCompilerDX.cpp index 64e486dca..6e92b31a0 100644 --- a/Source/Engine/ShadersCompilation/DirectX/ShaderCompilerDX.cpp +++ b/Source/Engine/ShadersCompilation/DirectX/ShaderCompilerDX.cpp @@ -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 diff --git a/Source/Engine/ShadersCompilation/ShaderDebugDataExporter.h b/Source/Engine/ShadersCompilation/ShaderDebugDataExporter.h index 65247ae6a..215d6dd11 100644 --- a/Source/Engine/ShadersCompilation/ShaderDebugDataExporter.h +++ b/Source/Engine/ShadersCompilation/ShaderDebugDataExporter.h @@ -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" diff --git a/Source/Engine/ShadersCompilation/ShadersCompilation.cpp b/Source/Engine/ShadersCompilation/ShadersCompilation.cpp index f89f38f9f..e1104cca3 100644 --- a/Source/Engine/ShadersCompilation/ShadersCompilation.cpp +++ b/Source/Engine/ShadersCompilation/ShadersCompilation.cpp @@ -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);