diff options
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/gfx-unit-test/buffer-barrier-test.cpp | 1 | ||||
| -rw-r--r-- | tools/gfx-unit-test/existing-device-handle-test.cpp | 1 | ||||
| -rw-r--r-- | tools/gfx-unit-test/get-buffer-resource-handle-test.cpp | 1 | ||||
| -rw-r--r-- | tools/gfx-unit-test/get-cmd-buffer-handle-test.cpp | 1 | ||||
| -rw-r--r-- | tools/gfx-unit-test/get-cmd-queue-handle-test.cpp | 1 | ||||
| -rw-r--r-- | tools/gfx-unit-test/get-texture-resource-handle-test.cpp | 1 | ||||
| -rw-r--r-- | tools/gfx-unit-test/gfx-test-util.cpp | 8 | ||||
| -rw-r--r-- | tools/gfx/d3d12/d3d12-device.cpp | 13 | ||||
| -rw-r--r-- | tools/gfx/d3d12/d3d12-helper-functions.cpp | 7 | ||||
| -rw-r--r-- | tools/gfx/render.cpp | 12 | ||||
| -rw-r--r-- | tools/gfx/vulkan/vk-device.cpp | 5 | ||||
| -rw-r--r-- | tools/gfx/vulkan/vk-helper-functions.cpp | 3 | ||||
| -rw-r--r-- | tools/gfx/vulkan/vk-helper-functions.h | 7 | ||||
| -rw-r--r-- | tools/slang-test/options.cpp | 12 | ||||
| -rw-r--r-- | tools/slang-test/options.h | 9 | ||||
| -rw-r--r-- | tools/slang-test/slang-test-main.cpp | 28 | ||||
| -rw-r--r-- | tools/slang-test/test-context.h | 2 | ||||
| -rw-r--r-- | tools/slang-test/test-reporter.cpp | 2 | ||||
| -rw-r--r-- | tools/unit-test/slang-unit-test.h | 1 |
19 files changed, 64 insertions, 51 deletions
diff --git a/tools/gfx-unit-test/buffer-barrier-test.cpp b/tools/gfx-unit-test/buffer-barrier-test.cpp index 2d53ac13f..b128448d2 100644 --- a/tools/gfx-unit-test/buffer-barrier-test.cpp +++ b/tools/gfx-unit-test/buffer-barrier-test.cpp @@ -146,6 +146,7 @@ void barrierTestImpl(IDevice* device, UnitTestContext* context) void barrierTestAPI(UnitTestContext* context, Slang::RenderApiFlag::Enum api) { + gfxEnableDebugLayer(context->enableDebugLayers); if ((api & context->enabledApis) == 0) { SLANG_IGNORE_TEST diff --git a/tools/gfx-unit-test/existing-device-handle-test.cpp b/tools/gfx-unit-test/existing-device-handle-test.cpp index 8b7a84ec2..5605bf8a5 100644 --- a/tools/gfx-unit-test/existing-device-handle-test.cpp +++ b/tools/gfx-unit-test/existing-device-handle-test.cpp @@ -83,6 +83,7 @@ void existingDeviceHandleTestImpl(IDevice* device, UnitTestContext* context) void existingDeviceHandleTestAPI(UnitTestContext* context, Slang::RenderApiFlag::Enum api) { + gfxEnableDebugLayer(context->enableDebugLayers); if ((api & context->enabledApis) == 0) { SLANG_IGNORE_TEST; diff --git a/tools/gfx-unit-test/get-buffer-resource-handle-test.cpp b/tools/gfx-unit-test/get-buffer-resource-handle-test.cpp index 97bb413fd..102986616 100644 --- a/tools/gfx-unit-test/get-buffer-resource-handle-test.cpp +++ b/tools/gfx-unit-test/get-buffer-resource-handle-test.cpp @@ -53,6 +53,7 @@ void getBufferResourceHandleTestImpl(IDevice* device, UnitTestContext* context) void getBufferResourceHandleTestAPI(UnitTestContext* context, Slang::RenderApiFlag::Enum api) { + gfxEnableDebugLayer(context->enableDebugLayers); if ((api & context->enabledApis) == 0) { SLANG_IGNORE_TEST; diff --git a/tools/gfx-unit-test/get-cmd-buffer-handle-test.cpp b/tools/gfx-unit-test/get-cmd-buffer-handle-test.cpp index b1e7ebc04..5c734f966 100644 --- a/tools/gfx-unit-test/get-cmd-buffer-handle-test.cpp +++ b/tools/gfx-unit-test/get-cmd-buffer-handle-test.cpp @@ -49,6 +49,7 @@ void getBufferHandleTestImpl(IDevice* device, UnitTestContext* context) void getBufferHandleTestAPI(UnitTestContext* context, Slang::RenderApiFlag::Enum api) { + gfxEnableDebugLayer(context->enableDebugLayers); if ((api & context->enabledApis) == 0) { SLANG_IGNORE_TEST; diff --git a/tools/gfx-unit-test/get-cmd-queue-handle-test.cpp b/tools/gfx-unit-test/get-cmd-queue-handle-test.cpp index 5e72c41d9..82561f4a2 100644 --- a/tools/gfx-unit-test/get-cmd-queue-handle-test.cpp +++ b/tools/gfx-unit-test/get-cmd-queue-handle-test.cpp @@ -38,6 +38,7 @@ void getQueueHandleTestImpl(IDevice* device, UnitTestContext* context) void getQueueHandleTestAPI(UnitTestContext* context, Slang::RenderApiFlag::Enum api) { + gfxEnableDebugLayer(context->enableDebugLayers); if ((api & context->enabledApis) == 0) { SLANG_IGNORE_TEST; diff --git a/tools/gfx-unit-test/get-texture-resource-handle-test.cpp b/tools/gfx-unit-test/get-texture-resource-handle-test.cpp index 4a7412ddc..1900b482e 100644 --- a/tools/gfx-unit-test/get-texture-resource-handle-test.cpp +++ b/tools/gfx-unit-test/get-texture-resource-handle-test.cpp @@ -50,6 +50,7 @@ void getTextureResourceHandleTestImpl(IDevice* device, UnitTestContext* context) void getTextureResourceHandleTestAPI(UnitTestContext* context, Slang::RenderApiFlag::Enum api) { + gfxEnableDebugLayer(context->enableDebugLayers); if ((api & context->enabledApis) == 0) { SLANG_IGNORE_TEST; diff --git a/tools/gfx-unit-test/gfx-test-util.cpp b/tools/gfx-unit-test/gfx-test-util.cpp index d7cfa0f65..bd1b2a891 100644 --- a/tools/gfx-unit-test/gfx-test-util.cpp +++ b/tools/gfx-unit-test/gfx-test-util.cpp @@ -323,13 +323,7 @@ Slang::ComPtr<gfx::IDevice> createTestingDevice( void* extDescPtrs[2] = {&extDesc, &slangExtDesc}; deviceDesc.extendedDescs = extDescPtrs; - // TODO: We should also set the debug callback - // (And in general reduce the differences (and duplication) between - // here and render-test-main.cpp) -#ifdef _DEBUG - gfx::gfxEnableDebugLayer(); -#endif - + gfx::gfxEnableDebugLayer(context->enableDebugLayers); auto createDeviceResult = gfxCreateDevice(&deviceDesc, device.writeRef()); if (SLANG_FAILED(createDeviceResult)) { 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> diff --git a/tools/slang-test/options.cpp b/tools/slang-test/options.cpp index 6be590ef2..da4f9cffe 100644 --- a/tools/slang-test/options.cpp +++ b/tools/slang-test/options.cpp @@ -1,4 +1,4 @@ -// test-context.cpp +// options.cpp #include "options.h" #include "../../source/core/slang-io.h" @@ -88,6 +88,10 @@ static bool _isSubCommand(const char* arg) " -use-test-server Run tests using test server\n" " -use-fully-isolated-test-server Run each test in isolated server\n" " -capability <name> Compile with the given capability\n" +#if _DEBUG + " -disable-debug-layers Disable the debug layers (default enabled in debug " + "build)\n" +#endif "\n" "Output modes:\n" " -appveyor Use AppVeyor output format\n" @@ -406,6 +410,12 @@ static bool _isSubCommand(const char* arg) { optionsOut->skipReferenceImageGeneration = true; } +#if _DEBUG + else if (strcmp(arg, "-disable-debug-layers") == 0) + { + optionsOut->debugLayerEnabled = false; + } +#endif else { stdError.print("unknown option '%s'\n", arg); diff --git a/tools/slang-test/options.h b/tools/slang-test/options.h index 7fda33198..6e408374e 100644 --- a/tools/slang-test/options.h +++ b/tools/slang-test/options.h @@ -83,6 +83,15 @@ struct Options // integration builds. bool dumpOutputOnFailure = false; + // When true it will run with debug layer (e.g. vulkan validation layer) +#if _DEBUG + // Default is true for debug build + bool debugLayerEnabled = true; +#else + // Default is false for release build + bool debugLayerEnabled = false; +#endif + // Set the default spawn type to use // Having tests isolated, slows down testing considerably, so using UseSharedLibrary is the most // desirable default usually. diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp index 92e50737e..02d305a46 100644 --- a/tools/slang-test/slang-test-main.cpp +++ b/tools/slang-test/slang-test-main.cpp @@ -3607,8 +3607,10 @@ TestResult runComputeComparisonImpl( // gets misinterpreted as the result from the test. // This is due to the limitation that Slang RPC implementation expects only // one time communication. - if (input.spawnType != SpawnType::UseTestServer) + if (context->options.debugLayerEnabled && input.spawnType != SpawnType::UseTestServer) + { cmdLine.addArg("-enable-debug-layers"); + } #endif if (context->isExecuting()) @@ -4344,7 +4346,7 @@ static SlangResult _runTestsOnFile(TestContext* context, String filePath) context->setTestRequirements(&requirements); runTest(context, filePath, filePath, filePath, testDetails.options); - // + apiUsedFlags |= requirements.usedRenderApiFlags; explictUsedApiFlags |= (requirements.explicitRenderApi != RenderApiType::Unknown) ? (RenderApiFlags(1) << int(requirements.explicitRenderApi)) @@ -4703,6 +4705,7 @@ static SlangResult runUnitTestModule( unitTestContext.slangGlobalSession = context->getSession(); unitTestContext.workDirectory = ""; unitTestContext.enabledApis = context->options.enabledApis; + unitTestContext.enableDebugLayers = context->options.debugLayerEnabled; unitTestContext.executableDirectory = context->exeDirectoryPath.getBuffer(); auto testCount = testModule->getTestCount(); @@ -5054,21 +5057,20 @@ SlangResult innerMain(int argc, char** argv) TestReporter::SuiteScope suiteScope(&reporter, "unit tests"); TestReporter::set(&reporter); - for (bool isRetry : {false, true}) + // Try the unit tests up to 3 times + for (bool isRetry : {false, true, true}) { - auto spawnType = context.getFinalSpawnType(); - - context.isRetry = false; + // Use default spawn type for unit tests as the test server one is unstable + auto spawnType = SpawnType::Default; + context.isRetry = isRetry; if (isRetry) { if (context.failedUnitTests.getCount() == 0) break; - printf("Retrying unit tests...\n"); - context.isRetry = true; + printf("Retrying unit tests with default spawn type...\n"); context.options.testPrefixes = context.failedUnitTests; context.failedUnitTests.clear(); - spawnType = SpawnType::Default; } // Run the unit tests @@ -5090,14 +5092,20 @@ SlangResult innerMain(int argc, char** argv) } // If we have a couple failed tests, they maybe intermittent failures due to parallel - // excution or driver instability. We can try running them again. + // excution or driver instability. We can try running them again. Debug build has more + // instability at this moment, so we allow more retries. +#if _DEBUG + static constexpr int kFailedTestLimitForRetry = 32; +#else static constexpr int kFailedTestLimitForRetry = 16; +#endif if (context.failedFileTests.getCount() <= kFailedTestLimitForRetry) { if (context.failedFileTests.getCount() > 0) printf("Retrying %d failed tests...\n", (int)context.failedFileTests.getCount()); for (auto& test : context.failedFileTests) { + context.isRetry = true; FileTestInfoImpl* fileTestInfo = static_cast<FileTestInfoImpl*>(test.Ptr()); TestReporter::SuiteScope suiteScope(&reporter, "tests"); TestReporter::TestScope scope(&reporter, fileTestInfo->testName); diff --git a/tools/slang-test/test-context.h b/tools/slang-test/test-context.h index 97562da99..6720cd648 100644 --- a/tools/slang-test/test-context.h +++ b/tools/slang-test/test-context.h @@ -181,6 +181,8 @@ public: Slang::RefPtr<Slang::JSONRPCConnection> m_languageServerConnection; bool isRetry; + bool enableDebugLayers; + std::mutex mutexFailedTests; Slang::List<Slang::RefPtr<FileTestInfo>> failedFileTests; Slang::List<Slang::String> failedUnitTests; diff --git a/tools/slang-test/test-reporter.cpp b/tools/slang-test/test-reporter.cpp index 1f6c00637..352245028 100644 --- a/tools/slang-test/test-reporter.cpp +++ b/tools/slang-test/test-reporter.cpp @@ -693,7 +693,7 @@ void TestReporter::outputSummary() printf("\n===\n\n"); if (m_failedTestCount) { - printf("failing tests:\n"); + printf("%d failing tests:\n", m_failedTestCount); printf("---\n"); for (const auto& testInfo : m_testInfos) { diff --git a/tools/unit-test/slang-unit-test.h b/tools/unit-test/slang-unit-test.h index 8f0f0a445..49cb5d8d7 100644 --- a/tools/unit-test/slang-unit-test.h +++ b/tools/unit-test/slang-unit-test.h @@ -43,6 +43,7 @@ struct UnitTestContext const char* workDirectory; const char* executableDirectory; Slang::RenderApiFlags enabledApis; + bool enableDebugLayers; }; typedef void (*UnitTestFunc)(UnitTestContext*); |
