From f514d8ea156e68591c444d1e5642877cce1cb257 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 30 Sep 2016 14:31:37 -0400 Subject: Sort out target environments used in different components. SPIRV-Tools has its own target environment definition, and public shaderc API has its own. A new one is added into Compiler in shaderc_util, for better isolation. Now shaderc_util::Compiler's interface accepts target environment, not glslang messages anymore. All the conversion to glslang messages are done in the implementation now. --- libshaderc/src/shaderc_test.cc | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'libshaderc/src/shaderc_test.cc') diff --git a/libshaderc/src/shaderc_test.cc b/libshaderc/src/shaderc_test.cc index 6de7053..c14b9c3 100644 --- a/libshaderc/src/shaderc_test.cc +++ b/libshaderc/src/shaderc_test.cc @@ -266,11 +266,16 @@ class CompileStringTest : public testing::Test { // checking methods. Subclass tests can access the compiler object to set their // properties. class AssembleStringTest : public testing::Test { + public: + AssembleStringTest() : options_(shaderc_compile_options_initialize()) {} + ~AssembleStringTest() { shaderc_compile_options_release(options_); } + protected: // Assembles the given assembly and returns true on success. bool AssemblingSuccess(const std::string& assembly) { return CompilationResultIsSuccess( - Assembling(compiler_.get_compiler_handle(), assembly).result()); + Assembling(compiler_.get_compiler_handle(), assembly, options_) + .result()); } bool AssemblingValid(const std::string& assembly) { @@ -280,6 +285,7 @@ class AssembleStringTest : public testing::Test { } Compiler compiler_; + shaderc_compile_options_t options_; }; // Name holders so that we have test cases being grouped with only one real @@ -312,6 +318,16 @@ TEST_F(AssembleStringTest, GarbageString) { EXPECT_EQ(0u, shaderc_result_get_num_warnings(assembling.result())); } +// TODO(antiagainst): right now there is no assembling difference for all the +// target environments exposed by shaderc. So the following is just testing the +// target environment is accepted. +TEST_F(AssembleStringTest, AcceptTargetEnv) { + ASSERT_NE(nullptr, compiler_.get_compiler_handle()); + shaderc_compile_options_set_target_env(options_, shaderc_target_env_opengl, + /* version = */ 0); + EXPECT_TRUE(AssemblingSuccess("OpCapability Shader")); +} + TEST_F(CompileStringTest, ReallyLongShader) { ASSERT_NE(nullptr, compiler_.get_compiler_handle()); std::string minimal_shader = ""; -- cgit v1.2.3