summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJay Kwak <82421531+jkwak-work@users.noreply.github.com>2025-08-26 14:38:57 -0700
committerGitHub <noreply@github.com>2025-08-26 21:38:57 +0000
commit1681bc67fbae57b54b66c5dcfcbf315d1efa831b (patch)
treee4c1ed8d99000732debc960cec49460fa2c4dbde /tools
parent4e9ee1dc80ce353640c1e2134249a1f93da9229a (diff)
Fail slang-test when VVL printed errors (#8280)
fixes https://github.com/shader-slang/slang/issues/8271 This PR does the following, - Fail slang-test when there are VVL error messages. - VVL error for `gfx-unit-test-tool/` were not captured properly by the debug callback. - Set an environment variable, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, for CI and VisualStudio project setup. - Ignores VVL error about NullHandle is used for the acceleration structure; a fix is at ToT of VVL and not available from release build yet. - Fix VVL error complaining about the varying inputs are not provided for the tests, `gfx-unit-test-tool/linkTimeTypeLayout.internal` and `gfx-unit-test-tool/linkTimeTypeLayoutNested.internal`. --------- Co-authored-by: slangbot <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/gfx-unit-test/gfx-test-util.cpp1
-rw-r--r--tools/gfx-unit-test/link-time-type-layout-nested.cpp23
-rw-r--r--tools/gfx-unit-test/link-time-type-layout.cpp19
-rw-r--r--tools/gfx/vulkan/vk-shader-object.cpp7
-rw-r--r--tools/slang-test/slang-test-main.cpp19
5 files changed, 62 insertions, 7 deletions
diff --git a/tools/gfx-unit-test/gfx-test-util.cpp b/tools/gfx-unit-test/gfx-test-util.cpp
index 2e3efe09f..b407f19cc 100644
--- a/tools/gfx-unit-test/gfx-test-util.cpp
+++ b/tools/gfx-unit-test/gfx-test-util.cpp
@@ -252,6 +252,7 @@ Slang::ComPtr<IDevice> createTestingDevice(
{
deviceDesc.enableValidation = context->enableDebugLayers;
deviceDesc.debugCallback = context->debugCallback;
+ getRHI()->enableDebugLayers();
}
D3D12DeviceExtendedDesc extDesc = {};
diff --git a/tools/gfx-unit-test/link-time-type-layout-nested.cpp b/tools/gfx-unit-test/link-time-type-layout-nested.cpp
index 2c2c83a94..425224aa7 100644
--- a/tools/gfx-unit-test/link-time-type-layout-nested.cpp
+++ b/tools/gfx-unit-test/link-time-type-layout-nested.cpp
@@ -35,9 +35,9 @@ static Slang::Result loadProgram(
// Define a regular struct that contains an Inner field
public struct Outer
{
- float2 position;
+ float2 position : POSITION;
Inner innerData;
- float2 texCoord;
+ float2 texCoord : TEXCOORD;
};
// Vertex shader entry point that takes an Outer parameter
@@ -56,7 +56,7 @@ static Slang::Result loadProgram(
export public struct Inner : IFoo
{
public float4 getFoo() { return this.data; }
- float4 data;
+ float4 data : COLOR;
}
)";
@@ -212,8 +212,25 @@ void linkTimeTypeLayoutNestedImpl(rhi::IDevice* device, UnitTestContext* context
validateNestedExternStructLayout(context, slangReflection);
// Create a graphics pipeline to verify everything works
+ InputElementDesc inputElements[] = {
+ {"POSITION", 0, Format::RG32Float, 0, 0}, // Outer.position (float2)
+ {"COLOR", 0, Format::RGBA32Float, 8, 0}, // Outer.innerData.data (float4)
+ {"TEXCOORD", 0, Format::RG32Float, 24, 0}, // Outer.texCoord (float2)
+ };
+ VertexStreamDesc vertexStreams[] = {
+ {32, InputSlotClass::PerVertex, 0}, // sizeof(Outer) = 2*float2 + float4 = 32 bytes
+ };
+ InputLayoutDesc inputLayoutDesc = {};
+ inputLayoutDesc.inputElementCount = SLANG_COUNT_OF(inputElements);
+ inputLayoutDesc.inputElements = inputElements;
+ inputLayoutDesc.vertexStreamCount = SLANG_COUNT_OF(vertexStreams);
+ inputLayoutDesc.vertexStreams = vertexStreams;
+ auto inputLayout = device->createInputLayout(inputLayoutDesc);
+ SLANG_CHECK(inputLayout != nullptr);
+
RenderPipelineDesc pipelineDesc = {};
pipelineDesc.program = shaderProgram.get();
+ pipelineDesc.inputLayout = inputLayout;
pipelineDesc.primitiveTopology = PrimitiveTopology::TriangleList;
ComPtr<IRenderPipeline> pipelineState;
diff --git a/tools/gfx-unit-test/link-time-type-layout.cpp b/tools/gfx-unit-test/link-time-type-layout.cpp
index c5c044acd..3493ea82d 100644
--- a/tools/gfx-unit-test/link-time-type-layout.cpp
+++ b/tools/gfx-unit-test/link-time-type-layout.cpp
@@ -43,7 +43,7 @@ static Slang::Result loadSpirvProgram(
export public struct S : IFoo
{
public float4 getFoo() { return this.foo; }
- float4 foo;
+ float4 foo : POSITION;
}
)";
@@ -213,10 +213,23 @@ void linkTimeTypeLayoutImpl(rhi::IDevice* device, UnitTestContext* context)
validateStructSLayout(context, slangReflection);
// Create a graphics pipeline to verify SPIRV code generation works
+ InputElementDesc inputElements[] = {
+ {"POSITION", 0, Format::RGBA32Float, 0, 0}, // S struct as POSITION semantic (float4)
+ };
+ VertexStreamDesc vertexStreams[] = {
+ {16, InputSlotClass::PerVertex, 0}, // sizeof(float4)
+ };
+ InputLayoutDesc inputLayoutDesc = {};
+ inputLayoutDesc.inputElementCount = SLANG_COUNT_OF(inputElements);
+ inputLayoutDesc.inputElements = inputElements;
+ inputLayoutDesc.vertexStreamCount = SLANG_COUNT_OF(vertexStreams);
+ inputLayoutDesc.vertexStreams = vertexStreams;
+ auto inputLayout = device->createInputLayout(inputLayoutDesc);
+ SLANG_CHECK(inputLayout != nullptr);
+
RenderPipelineDesc pipelineDesc = {};
pipelineDesc.program = shaderProgram.get();
-
- // We need to set up a minimal pipeline state for a vertex shader
+ pipelineDesc.inputLayout = inputLayout;
pipelineDesc.primitiveTopology = PrimitiveTopology::TriangleList;
ComPtr<IRenderPipeline> pipelineState;
diff --git a/tools/gfx/vulkan/vk-shader-object.cpp b/tools/gfx/vulkan/vk-shader-object.cpp
index eaee69edb..58cb23f22 100644
--- a/tools/gfx/vulkan/vk-shader-object.cpp
+++ b/tools/gfx/vulkan/vk-shader-object.cpp
@@ -504,7 +504,6 @@ void ShaderObjectImpl::writeAccelerationStructureDescriptor(
static_cast<AccelerationStructureImpl*>(resourceViews[i].Ptr());
VkWriteDescriptorSetAccelerationStructureKHR writeAS = {};
writeAS.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR;
- VkAccelerationStructureKHR nullHandle = VK_NULL_HANDLE;
if (accelerationStructure)
{
writeAS.accelerationStructureCount = 1;
@@ -512,6 +511,12 @@ void ShaderObjectImpl::writeAccelerationStructureDescriptor(
}
else
{
+ // The Vulkan spec states: If the nullDescriptor feature is not enabled, each element of
+ // pAccelerationStructures must not be VK_NULL_HANDLE
+ SLANG_ASSERT(
+ context.device->m_api.m_extendedFeatures.robustness2Features.nullDescriptor);
+
+ static const VkAccelerationStructureKHR nullHandle = VK_NULL_HANDLE;
writeAS.accelerationStructureCount = 1;
writeAS.pAccelerationStructures = &nullHandle;
}
diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp
index 97c63c392..3f707b5e5 100644
--- a/tools/slang-test/slang-test-main.cpp
+++ b/tools/slang-test/slang-test-main.cpp
@@ -4848,6 +4848,13 @@ static SlangResult runUnitTestModule(
reporter->message(TestMessageType::RunError, "rpc failed");
}
+ // Check for VVL errors in unit tests
+ if (exeRes.debugLayer.getLength() > 0)
+ {
+ testResult = TestResult::Fail;
+ reporter->message(TestMessageType::TestFailure, exeRes.debugLayer);
+ }
+
// If the test fails, output any output - which might give information about
// individual tests that have failed.
if (testResult == TestResult::Fail)
@@ -4877,9 +4884,21 @@ static SlangResult runUnitTestModule(
// TODO(JS): Problem here could be exception not handled properly across
// shared library boundary.
testModule->setTestReporter(reporter);
+
+ // Clear any previous debug messages
+ coreDebugCallback.clear();
+
try
{
test.testFunc(&unitTestContext);
+
+ // Check for VVL errors after test completion
+ String debugMessages = coreDebugCallback.getString();
+ if (debugMessages.getLength() > 0)
+ {
+ reporter->message(TestMessageType::TestFailure, debugMessages);
+ reporter->addResult(TestResult::Fail);
+ }
}
catch (...)
{