From 37a3d0771d015bfc64bd9bd6ef87e294cf5a3a59 Mon Sep 17 00:00:00 2001 From: assiduous Date: Sun, 8 Nov 2020 12:19:20 -0800 Subject: Broken shader test: added broken MSL; added SHADER_SOURCE_LANGUAGE_MSL --- Graphics/GraphicsEngine/interface/Shader.h | 3 +++ Tests/DiligentCoreAPITest/src/BrokenShaderTest.cpp | 30 ++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/Graphics/GraphicsEngine/interface/Shader.h b/Graphics/GraphicsEngine/interface/Shader.h index dce77a82..bb4acc84 100644 --- a/Graphics/GraphicsEngine/interface/Shader.h +++ b/Graphics/GraphicsEngine/interface/Shader.h @@ -71,6 +71,9 @@ DILIGENT_TYPED_ENUM(SHADER_SOURCE_LANGUAGE, Uint32) /// The source language is GLSL SHADER_SOURCE_LANGUAGE_GLSL, + /// The source language is Metal shading language (MSL) + SHADER_SOURCE_LANGUAGE_MSL, + /// The source language is GLSL that should be compiled verbatim /// By default the engine prepends GLSL shader source code with platform-specific diff --git a/Tests/DiligentCoreAPITest/src/BrokenShaderTest.cpp b/Tests/DiligentCoreAPITest/src/BrokenShaderTest.cpp index 2320f1c3..d69eb9c2 100644 --- a/Tests/DiligentCoreAPITest/src/BrokenShaderTest.cpp +++ b/Tests/DiligentCoreAPITest/src/BrokenShaderTest.cpp @@ -49,6 +49,25 @@ void VSMain() } )"; +static const char g_BrokenMSL[] = R"( +#include +#include + +using namespace metal; + +struct VSOut +{ + float4 pos [[position]]; +}; + +vertex VSOut vs_main() +{ + VSOut out = {}; + out.pos = float3(0.0, 0.0, 0.0); + return out; +} +)"; + void TestBrokenShader(const char* Source, const char* Name, SHADER_SOURCE_LANGUAGE SourceLanguage, int ErrorAllowance) { auto* pEnv = TestingEnvironment::GetInstance(); @@ -98,4 +117,15 @@ TEST(Shader, BrokenGLSL) deviceCaps.IsGLDevice() ? 2 : 3); } +TEST(Shader, BrokenMSL) +{ + const auto& deviceCaps = TestingEnvironment::GetInstance()->GetDevice()->GetDeviceCaps(); + if (!deviceCaps.IsMetalDevice()) + { + GTEST_SKIP() << "MSL is only supported in Metal"; + } + + TestBrokenShader(g_BrokenMSL, "Broken MSL test", SHADER_SOURCE_LANGUAGE_MSL, 2); +} + } // namespace -- cgit v1.2.3