Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .teamcity/MacOS/Project.kt
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class CarbonBuildMacOS(buildName: String, configType: String, preset: String, ag
name = "Run Tests"
workingDir = "%env.CMAKE_BUILD_FOLDER%"
path = "ctest"
arguments = "-C %env.CMAKE_CONFIG_TYPE% -V --output-on-failure --output-junit %env.CTEST_JUNIT_OUTPUT_FILE%"
arguments = "-C %env.CMAKE_CONFIG_TYPE% -V --output-on-failure --timeout 30 --output-junit %env.CTEST_JUNIT_OUTPUT_FILE%"
}
exec {
name = "Package artifact"
Expand Down
2 changes: 1 addition & 1 deletion .teamcity/Windows/Project.kt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class CarbonBuildWindows(buildName: String, configType: String, preset: String)
name = "Run Tests"
workingDir = "%env.CMAKE_BUILD_FOLDER%"
path = "ctest"
arguments = "-C %env.CMAKE_CONFIG_TYPE% -V --output-on-failure --output-junit %env.CTEST_JUNIT_OUTPUT_FILE%"
arguments = "-C %env.CMAKE_CONFIG_TYPE% -V --output-on-failure --timeout 30 --output-junit %env.CTEST_JUNIT_OUTPUT_FILE%"
}
exec {
name = "Package artifact"
Expand Down
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ if(BUILD_FOR_PYTHON_2)
set(BUILD_METAL ON)
set(BUILD_SHADER_COMPILER ON)
set(INSTALL_TO_MONOLITH ON)
set(BUILD_TESTING OFF)

else()
# Feature options
Expand Down Expand Up @@ -50,6 +51,14 @@ endif()

project(carbon-trinity VERSION 1.0.0)

if(PROJECT_IS_TOP_LEVEL)
option(BUILD_TESTING "Build tests. Enabled by default." ON)
endif()

if(BUILD_TESTING)
enable_testing()
endif()

if (BUILD_FOR_PYTHON_2)
if(NOT DEFINED ENV{CCP_EVE_PERFORCE_BRANCH_PATH})
message(FATAL_ERROR "Missing required environment variable CCP_EVE_PERFORCE_BRANCH_PATH")
Expand Down
7 changes: 3 additions & 4 deletions shadercompiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -306,18 +306,17 @@ else() # VCPKG install mode

endif()

option(BUILD_TESTING "Build and run tests. Enabled by default." ON)
message(STATUS " BUILD_TESTING VALUE IS ${BUILD_TESTING}")
if(BUILD_TESTING)

find_package(GTest REQUIRED)

add_executable(ShaderCompilerTest)
target_compile_definitions(ShaderCompilerTest PRIVATE SHADER_COMPILER_TEST=1)
target_link_libraries(ShaderCompilerTest PRIVATE GTest::GTest GTest::Main)
target_link_libraries(ShaderCompilerTest PRIVATE GTest::GTest)
target_sources(ShaderCompilerTest PRIVATE ${_TEST_SOURCES})
source_group(Tests FILES ${_TEST_SOURCES})
configure_shader_compiler(ShaderCompilerTest)
set_target_properties(ShaderCompilerTest PROPERTIES FOLDER "Tests")
add_dependencies(ShaderCompilerTest ShaderCompiler)

gtest_discover_tests(ShaderCompilerTest DISCOVERY_MODE PRE_TEST TEST_PREFIX ShaderCompiler.)
endif()
2 changes: 1 addition & 1 deletion shadercompiler/EffectCompilerMetal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4254,7 +4254,7 @@ std::string MetalTool( const char* name )
size_t programFilesSize;
getenv_s( &programFilesSize, programFiles, "PROGRAMFILES" );

cmd << "\"" << programFiles << "\\Metal Developer Tools\\metal\\macos\\bin\\" << name << ".exe\"";
cmd << "\"" << std::string( programFiles ) << "\\Metal Developer Tools\\metal\\macos\\bin\\" << name << ".exe\"";
}
#else
cmd << "xcrun -sdk macosx " << name;
Expand Down
73 changes: 73 additions & 0 deletions shadercompiler/tests/MetalConversionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

TEST( MetalConversion, TextureIndexingWorks )
{
if( !g_metalCompilerAvailable )
{
GTEST_SKIP() << "Skipping test: Metal compiler is not available.";
}

const char* src = R"SRC(
Texture2D<float3> tex;

Expand Down Expand Up @@ -38,6 +43,10 @@ technique t0

TEST( MetalConversion, AppliesPackedModifiersToCBuffers )
{
if( !g_metalCompilerAvailable )
{
GTEST_SKIP() << "Skipping test: Metal compiler is not available.";
}
const char* src = R"SRC(
cbuffer cb0: register( b3 )
{
Expand Down Expand Up @@ -72,6 +81,10 @@ technique t0

TEST( MetalConversion, AddsRowsToMatrixInitializers )
{
if( !g_metalCompilerAvailable )
{
GTEST_SKIP() << "Skipping test: Metal compiler is not available.";
}
const char* src = R"SRC(
float4 vs(): SV_Position
{
Expand Down Expand Up @@ -105,6 +118,12 @@ technique t0

TEST( MetalConversion, AppliesPackedModifiersToRtLocalBuffers )
{
if( !g_metalCompilerAvailable )
{
GTEST_SKIP() << "Skipping test: Metal compiler is not available.";
}


const char* src = R"SRC(
struct HitInfo
{
Expand Down Expand Up @@ -140,6 +159,11 @@ technique t0

TEST( MetalConversion, AllowBindlessResources )
{
if( !g_metalCompilerAvailable )
{
GTEST_SKIP() << "Skipping test: Metal compiler is not available.";
}

const char* src = R"SRC(

Buffer<float4> HeapView_BufferFloat4[]
Expand Down Expand Up @@ -186,6 +210,10 @@ technique t0

TEST( MetalConversion, AllowLocalBufferVars )
{
if( !g_metalCompilerAvailable )
{
GTEST_SKIP() << "Skipping test: Metal compiler is not available.";
}
const char* src = R"SRC(

Buffer<float4> HeapView_BufferFloat4[]
Expand Down Expand Up @@ -229,6 +257,11 @@ technique t0

TEST( MetalConversion, AllowManySrvsUavs )
{
if( !g_metalCompilerAvailable )
{
GTEST_SKIP() << "Skipping test: Metal compiler is not available.";
}

const char* src = R"SRC(

RWTexture2D<float4> Tex0;
Expand Down Expand Up @@ -338,6 +371,11 @@ technique t0

TEST( MetalShaderPatching, CanHaveVertexID )
{
if( !g_metalCompilerAvailable )
{
GTEST_SKIP() << "Skipping test: Metal compiler is not available.";
}

const char* src = R"SRC(

struct VSIn
Expand Down Expand Up @@ -381,6 +419,11 @@ technique t0

TEST( MetalShaderPatching, CanHaveVertexIDWithIAInputs )
{
if( !g_metalCompilerAvailable )
{
GTEST_SKIP() << "Skipping test: Metal compiler is not available.";
}

const char* src = R"SRC(

struct VSIn
Expand Down Expand Up @@ -425,6 +468,11 @@ technique t0

TEST( MetalShaderPatching, CanHaveNestedStructs )
{
if( !g_metalCompilerAvailable )
{
GTEST_SKIP() << "Skipping test: Metal compiler is not available.";
}

const char* src = R"SRC(

struct VSIn
Expand Down Expand Up @@ -472,6 +520,11 @@ technique t0

TEST( MetalShaderPatching, CanHaveNestedStructsWithSystemSemanticsWithIAInputs1 )
{
if( !g_metalCompilerAvailable )
{
GTEST_SKIP() << "Skipping test: Metal compiler is not available.";
}

const char* src = R"SRC(

struct VSIn
Expand Down Expand Up @@ -522,6 +575,11 @@ technique t0

TEST( MetalShaderPatching, CanHaveNestedStructsWithSystemSemanticsWithIAInputs2 )
{
if( !g_metalCompilerAvailable )
{
GTEST_SKIP() << "Skipping test: Metal compiler is not available.";
}

const char* src = R"SRC(

struct VSIn
Expand Down Expand Up @@ -572,6 +630,11 @@ technique t0

TEST( MetalShaderPatching, CanHaveInstanceID )
{
if( !g_metalCompilerAvailable )
{
GTEST_SKIP() << "Skipping test: Metal compiler is not available.";
}

const char* src = R"SRC(

struct VSIn
Expand Down Expand Up @@ -615,6 +678,11 @@ technique t0

TEST( MetalShaderPatching, CanHaveInstanceIDWithIAInputs )
{
if( !g_metalCompilerAvailable )
{
GTEST_SKIP() << "Skipping test: Metal compiler is not available.";
}

const char* src = R"SRC(

struct VSIn
Expand Down Expand Up @@ -659,6 +727,11 @@ technique t0

TEST( MetalShaderPatching, CanHaveSystemSemanticMixedParameterAndIAInputs )
{
if( !g_metalCompilerAvailable )
{
GTEST_SKIP() << "Skipping test: Metal compiler is not available.";
}

const char* src = R"SRC(

struct VSIn
Expand Down
Loading