summaryrefslogtreecommitdiff
path: root/tools/gfx
diff options
context:
space:
mode:
Diffstat (limited to 'tools/gfx')
-rw-r--r--tools/gfx/d3d12/d3d12-device.cpp13
-rw-r--r--tools/gfx/d3d12/d3d12-helper-functions.cpp7
-rw-r--r--tools/gfx/render.cpp12
-rw-r--r--tools/gfx/vulkan/vk-device.cpp5
-rw-r--r--tools/gfx/vulkan/vk-helper-functions.cpp3
-rw-r--r--tools/gfx/vulkan/vk-helper-functions.h7
6 files changed, 15 insertions, 32 deletions
diff --git a/tools/gfx/d3d12/d3d12-device.cpp b/tools/gfx/d3d12/d3d12-device.cpp
index 88051d837..cfb384787 100644
--- a/tools/gfx/d3d12/d3d12-device.cpp
+++ b/tools/gfx/d3d12/d3d12-device.cpp
@@ -17,12 +17,6 @@
#include "d3d12-swap-chain.h"
#include "d3d12-vertex-layout.h"
-#ifdef _DEBUG
-#define ENABLE_DEBUG_LAYER 1
-#else
-#define ENABLE_DEBUG_LAYER 0
-#endif
-
#ifdef GFX_NVAPI
#include "../nvapi/nvapi-include.h"
#endif
@@ -534,7 +528,7 @@ Result DeviceImpl::initialize(const Desc& desc)
// If Aftermath is enabled, we can't enable the D3D12 debug layer as well
- if (ENABLE_DEBUG_LAYER || isGfxDebugLayerEnabled() && !g_isAftermathEnabled)
+ if (isGfxDebugLayerEnabled() && !g_isAftermathEnabled)
{
m_D3D12GetDebugInterface =
(PFN_D3D12_GET_DEBUG_INTERFACE)loadProc(d3dModule, "D3D12GetDebugInterface");
@@ -569,10 +563,7 @@ Result DeviceImpl::initialize(const Desc& desc)
if (desc.existingDeviceHandles.handles[0].handleValue == 0)
{
FlagCombiner combiner;
- // TODO: we should probably provide a command-line option
- // to override UseDebug of default rather than leave it
- // up to each back-end to specify.
- if (ENABLE_DEBUG_LAYER || isGfxDebugLayerEnabled())
+ if (isGfxDebugLayerEnabled())
{
combiner.add(
DeviceCheckFlag::UseDebug,
diff --git a/tools/gfx/d3d12/d3d12-helper-functions.cpp b/tools/gfx/d3d12/d3d12-helper-functions.cpp
index 9d218dae0..7d15a1a2d 100644
--- a/tools/gfx/d3d12/d3d12-helper-functions.cpp
+++ b/tools/gfx/d3d12/d3d12-helper-functions.cpp
@@ -10,15 +10,8 @@
#include "d3d12-query.h"
#include "d3d12-transient-heap.h"
-#ifdef _DEBUG
-#define ENABLE_DEBUG_LAYER 1
-#else
-#define ENABLE_DEBUG_LAYER 0
-#endif
-
namespace gfx
{
-
using namespace Slang;
namespace d3d12
diff --git a/tools/gfx/render.cpp b/tools/gfx/render.cpp
index 1ae7e370c..516369c0e 100644
--- a/tools/gfx/render.cpp
+++ b/tools/gfx/render.cpp
@@ -26,7 +26,13 @@ Result SLANG_MCALL getCUDAAdapters(List<AdapterInfo>& outAdapters);
Result SLANG_MCALL reportD3DLiveObjects();
+// Enable debug layer (validation layer) by default for DEBUG build
+#if _DEBUG
+static bool debugLayerEnabled = true;
+#else
static bool debugLayerEnabled = false;
+#endif
+
bool isGfxDebugLayerEnabled()
{
return debugLayerEnabled;
@@ -276,7 +282,7 @@ extern "C"
return SLANG_E_NOT_IMPLEMENTED;
#endif
#if SLANG_WINDOWS_FAMILY || SLANG_LINUX_FAMILY
- // Assume no Vulkan or CUDA on MacOS or Cygwin
+ // Assume no Vulkan or CUDA on MacOS or Cygwin
case DeviceType::Vulkan:
SLANG_RETURN_ON_FAIL(getVKAdapters(adapters));
break;
@@ -428,9 +434,9 @@ extern "C"
return SLANG_OK;
}
- SLANG_GFX_API void SLANG_MCALL gfxEnableDebugLayer()
+ SLANG_GFX_API void SLANG_MCALL gfxEnableDebugLayer(bool enable)
{
- debugLayerEnabled = true;
+ debugLayerEnabled = enable;
}
const char* SLANG_MCALL gfxGetDeviceTypeName(DeviceType type)
diff --git a/tools/gfx/vulkan/vk-device.cpp b/tools/gfx/vulkan/vk-device.cpp
index b9ca76493..d056e3984 100644
--- a/tools/gfx/vulkan/vk-device.cpp
+++ b/tools/gfx/vulkan/vk-device.cpp
@@ -214,7 +214,8 @@ Result DeviceImpl::initVulkanInstanceAndDevice(
#endif
}
- if (ENABLE_VALIDATION_LAYER || isGfxDebugLayerEnabled())
+ gfxEnableDebugLayer(useValidationLayer);
+ if (isGfxDebugLayerEnabled())
instanceExtensions.add(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
VkInstanceCreateInfo instanceCreateInfo = {VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO};
@@ -1027,7 +1028,7 @@ SlangResult DeviceImpl::initialize(const Desc& desc)
descriptorSetAllocator.m_api = &m_api;
initDeviceResult = initVulkanInstanceAndDevice(
desc.existingDeviceHandles.handles,
- ENABLE_VALIDATION_LAYER != 0 || isGfxDebugLayerEnabled());
+ isGfxDebugLayerEnabled());
if (initDeviceResult == SLANG_OK)
break;
}
diff --git a/tools/gfx/vulkan/vk-helper-functions.cpp b/tools/gfx/vulkan/vk-helper-functions.cpp
index f1f517567..4a1fe85d0 100644
--- a/tools/gfx/vulkan/vk-helper-functions.cpp
+++ b/tools/gfx/vulkan/vk-helper-functions.cpp
@@ -214,8 +214,7 @@ VkAccessFlags translateAccelerationStructureAccessFlag(AccessFlag access)
{
VkAccessFlags result = 0;
if ((uint32_t)access & (uint32_t)AccessFlag::Read)
- result |= VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_KHR | VK_ACCESS_SHADER_READ_BIT |
- VK_ACCESS_TRANSFER_READ_BIT;
+ result |= VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_KHR | VK_ACCESS_SHADER_READ_BIT;
if ((uint32_t)access & (uint32_t)AccessFlag::Write)
result |= VK_ACCESS_ACCELERATION_STRUCTURE_WRITE_BIT_KHR;
return result;
diff --git a/tools/gfx/vulkan/vk-helper-functions.h b/tools/gfx/vulkan/vk-helper-functions.h
index 59dc61230..14fd18f5d 100644
--- a/tools/gfx/vulkan/vk-helper-functions.h
+++ b/tools/gfx/vulkan/vk-helper-functions.h
@@ -7,13 +7,6 @@
// Vulkan has a different coordinate system to ogl
// http://anki3d.org/vulkan-coordinate-system/
-#ifndef ENABLE_VALIDATION_LAYER
-#if _DEBUG
-#define ENABLE_VALIDATION_LAYER 1
-#else
-#define ENABLE_VALIDATION_LAYER 0
-#endif
-#endif
#ifdef _MSC_VER
#include <stddef.h>