summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2023-04-03 11:46:03 +0800
committerGitHub <noreply@github.com>2023-04-02 20:46:03 -0700
commit271ae7165915cf9910e2de0224159ea0fdd8ce72 (patch)
tree9b4db47ec7c4ee59af46ea2ccc1c1caa074d618d
parentd7ba60c993366b4aaf6ef8ee7d8eab940d61eac8 (diff)
Fix several silently failing tests (#2767)
* Add missing expected.txt for test * Diagnostics -> StdWriters in render test * Allow specifying several test prefixes to run `slang-test -- tests/foo tests/bar` * Squash warnings in some tests * Enable gfx debug layer in gfx test util Makes this issue present consistently: https://github.com/shader-slang/slang/issues/2766 * Allow DebugDevice to return interfaces instantiated by the debugged object * Check that we actaully have a shader cache for shader cache tests --------- Co-authored-by: Yong He <yonghe@outlook.com>
-rw-r--r--tests/autodiff/high-order-backward-diff-3.slang.expected.txt5
-rw-r--r--tests/bugs/generic-groupshared.slang2
-rw-r--r--tests/compute/half-rw-texture-simple.slang2
-rw-r--r--tests/compute/half-texture-simple.slang2
-rw-r--r--tools/gfx-unit-test/gfx-test-util.cpp7
-rw-r--r--tools/gfx-unit-test/shader-cache-tests.cpp3
-rw-r--r--tools/gfx/debug-layer/debug-device.cpp14
-rw-r--r--tools/gfx/debug-layer/debug-device.h4
-rw-r--r--tools/render-test/slang-support.cpp3
-rw-r--r--tools/slang-test/options.cpp13
-rw-r--r--tools/slang-test/options.h4
-rw-r--r--tools/slang-test/slang-test-main.cpp15
12 files changed, 49 insertions, 25 deletions
diff --git a/tests/autodiff/high-order-backward-diff-3.slang.expected.txt b/tests/autodiff/high-order-backward-diff-3.slang.expected.txt
index e69de29bb..0f08247f0 100644
--- a/tests/autodiff/high-order-backward-diff-3.slang.expected.txt
+++ b/tests/autodiff/high-order-backward-diff-3.slang.expected.txt
@@ -0,0 +1,5 @@
+type: float
+192.000000
+0.000000
+0.000000
+0.000000
diff --git a/tests/bugs/generic-groupshared.slang b/tests/bugs/generic-groupshared.slang
index c5ed8cf40..b352e7382 100644
--- a/tests/bugs/generic-groupshared.slang
+++ b/tests/bugs/generic-groupshared.slang
@@ -17,7 +17,7 @@ struct S<let n : int>
int doSomething()
{
table<M>(0) = M;
- return table<M>(0);
+ return int(table<M>(0));
}
}
diff --git a/tests/compute/half-rw-texture-simple.slang b/tests/compute/half-rw-texture-simple.slang
index 8077b36a6..739abfab7 100644
--- a/tests/compute/half-rw-texture-simple.slang
+++ b/tests/compute/half-rw-texture-simple.slang
@@ -25,7 +25,7 @@ RWStructuredBuffer<float> outputBuffer;
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
- int idx = dispatchThreadID.x;
+ uint idx = dispatchThreadID.x;
float val = 0.0f;
diff --git a/tests/compute/half-texture-simple.slang b/tests/compute/half-texture-simple.slang
index 124755534..5ddd84d64 100644
--- a/tests/compute/half-texture-simple.slang
+++ b/tests/compute/half-texture-simple.slang
@@ -35,7 +35,7 @@ RWStructuredBuffer<float> outputBuffer;
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
- int idx = dispatchThreadID.x;
+ uint idx = dispatchThreadID.x;
float u = idx * (1.0f / 4);
float val = 0.0f;
diff --git a/tools/gfx-unit-test/gfx-test-util.cpp b/tools/gfx-unit-test/gfx-test-util.cpp
index 5cbb30e71..fcebdda9f 100644
--- a/tools/gfx-unit-test/gfx-test-util.cpp
+++ b/tools/gfx-unit-test/gfx-test-util.cpp
@@ -239,6 +239,13 @@ namespace gfx_test
void* extDescPtr = &extDesc;
deviceDesc.extendedDescs = &extDescPtr;
+ // 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
+
auto createDeviceResult = gfxCreateDevice(&deviceDesc, device.writeRef());
if (SLANG_FAILED(createDeviceResult))
{
diff --git a/tools/gfx-unit-test/shader-cache-tests.cpp b/tools/gfx-unit-test/shader-cache-tests.cpp
index e1607ac59..de699c2d6 100644
--- a/tools/gfx-unit-test/shader-cache-tests.cpp
+++ b/tools/gfx-unit-test/shader-cache-tests.cpp
@@ -141,7 +141,8 @@ namespace gfx_test
[this, func] (IDevice* device, UnitTestContext* ctx)
{
this->device = device;
- device->queryInterface(SLANG_UUID_IShaderCache, (void**)this->shaderCache.writeRef());
+ SLANG_CHECK_ABORT(SLANG_SUCCEEDED(
+ device->queryInterface(SLANG_UUID_IShaderCache, (void**)this->shaderCache.writeRef())));
func();
this->device = nullptr;
this->shaderCache = nullptr;
diff --git a/tools/gfx/debug-layer/debug-device.cpp b/tools/gfx/debug-layer/debug-device.cpp
index 7790149b6..45374b64f 100644
--- a/tools/gfx/debug-layer/debug-device.cpp
+++ b/tools/gfx/debug-layer/debug-device.cpp
@@ -26,6 +26,20 @@ using namespace Slang;
namespace debug
{
+SlangResult DebugDevice::queryInterface(SlangUUID const& uuid, void** outObject) noexcept
+{
+ void* intf = getInterface(uuid);
+ if (intf)
+ {
+ addRef();
+ *outObject = intf;
+ return SLANG_OK;
+ }
+
+ // Fallback to trying to get the interface from the debugged object
+ return baseObject->queryInterface(uuid, outObject);
+}
+
Result DebugDevice::getNativeDeviceHandles(InteropHandles* outHandles)
{
return baseObject->getNativeDeviceHandles(outHandles);
diff --git a/tools/gfx/debug-layer/debug-device.h b/tools/gfx/debug-layer/debug-device.h
index db07cdd1b..5b8424093 100644
--- a/tools/gfx/debug-layer/debug-device.h
+++ b/tools/gfx/debug-layer/debug-device.h
@@ -12,7 +12,9 @@ namespace debug
class DebugDevice : public DebugObject<IDevice>
{
public:
- SLANG_COM_OBJECT_IUNKNOWN_ALL;
+ SlangResult SLANG_MCALL queryInterface(SlangUUID const& uuid, void** outObject) noexcept override;
+ SLANG_COM_OBJECT_IUNKNOWN_ADD_REF;
+ SLANG_COM_OBJECT_IUNKNOWN_RELEASE;
public:
DebugDevice();
diff --git a/tools/render-test/slang-support.cpp b/tools/render-test/slang-support.cpp
index 5b2d69bf4..54f1b94a1 100644
--- a/tools/render-test/slang-support.cpp
+++ b/tools/render-test/slang-support.cpp
@@ -10,6 +10,7 @@
#include <stdio.h>
#include "../../source/core/slang-string-util.h"
+#include "../../source/core/slang-test-tool-util.h"
namespace renderer_test {
using namespace Slang;
@@ -199,7 +200,7 @@ void ShaderCompilerUtil::Output::reset()
if (auto diagnostics = spGetDiagnosticOutput(slangRequest))
{
- fprintf(stderr, "%s", diagnostics);
+ StdWriters::getError().print("%s", diagnostics);
}
SLANG_RETURN_ON_FAIL(res);
diff --git a/tools/slang-test/options.cpp b/tools/slang-test/options.cpp
index 11188d766..ab0d3a01e 100644
--- a/tools/slang-test/options.cpp
+++ b/tools/slang-test/options.cpp
@@ -310,18 +310,7 @@ static bool _isSubCommand(const char* arg)
// first positional argument is source shader path
- if (positionalArgs.getCount())
- {
- optionsOut->testPrefix = positionalArgs[0];
- positionalArgs.removeAt(0);
- }
-
- // any remaining arguments represent an error
- if (positionalArgs.getCount() != 0)
- {
- stdError.print("unexpected arguments\n");
- return SLANG_FAIL;
- }
+ optionsOut->testPrefixes = std::move(positionalArgs);
if (optionsOut->binDir.getLength() == 0)
{
diff --git a/tools/slang-test/options.h b/tools/slang-test/options.h
index 26b8e7500..e786a0a74 100644
--- a/tools/slang-test/options.h
+++ b/tools/slang-test/options.h
@@ -52,8 +52,8 @@ struct Options
// Directory to use when looking for binaries to run. If empty it's not set.
Slang::String binDir;
- // only run test cases with names that have this prefix.
- char const* testPrefix = nullptr;
+ // only run test cases with names have one of these prefixes.
+ Slang::List<const char *> testPrefixes;
// generate extra output (notably: command lines we run)
bool shouldBeVerbose = false;
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp
index 71f5c04bd..51c618187 100644
--- a/tools/slang-test/slang-test-main.cpp
+++ b/tools/slang-test/slang-test-main.cpp
@@ -3900,15 +3900,20 @@ static bool shouldRunTest(
if(!endsWithAllowedExtension(context, filePath))
return false;
- if( context->options.testPrefix )
+ if(!context->options.testPrefixes.getCount())
{
- if( strncmp(context->options.testPrefix, filePath.begin(), strlen(context->options.testPrefix)) != 0 )
+ return true;
+ }
+
+ // If we have prefixes, it has to match one of them
+ for(auto& p : context->options.testPrefixes)
+ {
+ if(filePath.startsWith(p))
{
- return false;
+ return true;
}
}
-
- return true;
+ return false;
}
void getFilesInDirectory(String directoryPath, List<String>& files)