First tests for SPIR-V v1.1.
Add test for named-barrier instructions and capability.
Add spv_target_env as an optional argument to CompileSuccessfully() and
CompileFailure(). Currently defaults to UNIVERSAL_1_0, though that
could change in the future.
Make spv_context a local variable in test methods instead of a
TextToBinaryTestBase member. Introduce ScopedContext to make temp
contexts easier.
diff --git a/include/spirv-tools/libspirv.h b/include/spirv-tools/libspirv.h
index a43e446..d594f43 100644
--- a/include/spirv-tools/libspirv.h
+++ b/include/spirv-tools/libspirv.h
@@ -335,7 +335,7 @@
typedef enum {
SPV_ENV_UNIVERSAL_1_0, // SPIR-V 1.0 latest revision, no other restrictions.
SPV_ENV_VULKAN_1_0, // Vulkan 1.0 latest revision.
- SPV_ENV_UNIVERSAL_1_1, // SPIR-V 1.1 any revision, no other restrictions.
+ SPV_ENV_UNIVERSAL_1_1, // SPIR-V 1.1 latest revision, no other restrictions.
} spv_target_env;
// Returns a string describing the given SPIR-V target environment.
@@ -349,7 +349,8 @@
// Encodes the given SPIR-V assembly text to its binary representation. The
// length parameter specifies the number of bytes for text. Encoded binary will
-// be stored into *binary. Any error will be written into *diagnostic.
+// be stored into *binary. Any error will be written into *diagnostic. The
+// generated binary is independent of the context and may outlive it.
spv_result_t spvTextToBinary(const spv_const_context context, const char* text,
const size_t length, spv_binary* binary,
spv_diagnostic* diagnostic);
diff --git a/test/AssemblyFormat.cpp b/test/AssemblyFormat.cpp
index 94df1fe..9da22af 100644
--- a/test/AssemblyFormat.cpp
+++ b/test/AssemblyFormat.cpp
@@ -32,9 +32,9 @@
TEST_F(TextToBinaryTest, NotPlacingResultIDAtTheBeginning) {
SetText("OpTypeMatrix %1 %2 1000");
- EXPECT_EQ(
- SPV_ERROR_INVALID_TEXT,
- spvTextToBinary(context, text.str, text.length, &binary, &diagnostic));
+ EXPECT_EQ(SPV_ERROR_INVALID_TEXT,
+ spvTextToBinary(ScopedContext().context, text.str, text.length,
+ &binary, &diagnostic));
ASSERT_NE(nullptr, diagnostic);
EXPECT_STREQ(
"Expected <result-id> at the beginning of an instruction, found "
diff --git a/test/BinaryDestroy.cpp b/test/BinaryDestroy.cpp
index a5cb19c..b618ced 100644
--- a/test/BinaryDestroy.cpp
+++ b/test/BinaryDestroy.cpp
@@ -43,8 +43,8 @@
// Use a binary object constructed by the API instead of rolling our own.
SetText("OpSource OpenCL_C 120");
spv_binary my_binary = nullptr;
- ASSERT_EQ(SPV_SUCCESS, spvTextToBinary(context, text.str, text.length,
- &my_binary, &diagnostic));
+ ASSERT_EQ(SPV_SUCCESS, spvTextToBinary(ScopedContext().context, text.str,
+ text.length, &my_binary, &diagnostic));
ASSERT_NE(nullptr, my_binary);
spvBinaryDestroy(my_binary);
}
diff --git a/test/BinaryParse.cpp b/test/BinaryParse.cpp
index 1fdfedc..659453b 100644
--- a/test/BinaryParse.cpp
+++ b/test/BinaryParse.cpp
@@ -218,9 +218,9 @@
});
}
EXPECT_EQ(expected_result,
- spvBinaryParse(context, &client_, flipped_words.data(),
- flipped_words.size(), invoke_header,
- invoke_instruction, &diagnostic_));
+ spvBinaryParse(ScopedContext().context, &client_,
+ flipped_words.data(), flipped_words.size(),
+ invoke_header, invoke_instruction, &diagnostic_));
}
spv_diagnostic diagnostic_ = nullptr;
@@ -229,12 +229,12 @@
// Adds an EXPECT_CALL to client_->Header() with appropriate parameters,
// including bound. Returns the EXPECT_CALL result.
-#define EXPECT_HEADER(bound) \
- EXPECT_CALL(client_, \
- Header(AnyOf(SPV_ENDIANNESS_LITTLE, SPV_ENDIANNESS_BIG), \
- SpvMagicNumber, 0x10000, \
- SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS_ASSEMBLER, 0), \
- bound, 0 /*reserved*/))
+#define EXPECT_HEADER(bound) \
+ EXPECT_CALL( \
+ client_, \
+ Header(AnyOf(SPV_ENDIANNESS_LITTLE, SPV_ENDIANNESS_BIG), SpvMagicNumber, \
+ 0x10000, SPV_GENERATOR_WORD(SPV_GENERATOR_KHRONOS_ASSEMBLER, 0), \
+ bound, 0 /*reserved*/))
static const bool kSwapEndians[] = {false, true};
@@ -267,9 +267,9 @@
.Times(0); // No header callback.
EXPECT_CALL(client_, Instruction(MakeParsedVoidTypeInstruction(1)))
.WillOnce(Return(SPV_SUCCESS));
- EXPECT_EQ(SPV_SUCCESS,
- spvBinaryParse(context, &client_, words.data(), words.size(),
- nullptr, invoke_instruction, &diagnostic_));
+ EXPECT_EQ(SPV_SUCCESS, spvBinaryParse(ScopedContext().context, &client_,
+ words.data(), words.size(), nullptr,
+ invoke_instruction, &diagnostic_));
EXPECT_EQ(nullptr, diagnostic_);
}
@@ -278,8 +278,8 @@
EXPECT_HEADER((2)).WillOnce(Return(SPV_SUCCESS));
EXPECT_CALL(client_, Instruction(_)).Times(0); // No instruction callback.
EXPECT_EQ(SPV_SUCCESS,
- spvBinaryParse(context, &client_, words.data(), words.size(),
- invoke_header, nullptr, &diagnostic_));
+ spvBinaryParse(ScopedContext().context, &client_, words.data(),
+ words.size(), invoke_header, nullptr, &diagnostic_));
EXPECT_EQ(nullptr, diagnostic_);
}
@@ -443,8 +443,8 @@
TEST_P(BinaryParseWordsAndCountDiagnosticTest, WordAndCountCases) {
EXPECT_EQ(
SPV_ERROR_INVALID_BINARY,
- spvBinaryParse(context, nullptr, GetParam().words, GetParam().num_words,
- nullptr, nullptr, &diagnostic));
+ spvBinaryParse(ScopedContext().context, nullptr, GetParam().words,
+ GetParam().num_words, nullptr, nullptr, &diagnostic));
ASSERT_NE(nullptr, diagnostic);
EXPECT_THAT(diagnostic->error, Eq(GetParam().expected_diagnostic));
}
@@ -479,8 +479,8 @@
TEST_P(BinaryParseWordVectorDiagnosticTest, WordVectorCases) {
const auto& words = GetParam().words;
- EXPECT_THAT(spvBinaryParse(context, nullptr, words.data(), words.size(),
- nullptr, nullptr, &diagnostic),
+ EXPECT_THAT(spvBinaryParse(ScopedContext().context, nullptr, words.data(),
+ words.size(), nullptr, nullptr, &diagnostic),
AnyOf(SPV_ERROR_INVALID_BINARY, SPV_ERROR_INVALID_ID));
ASSERT_NE(nullptr, diagnostic);
EXPECT_THAT(diagnostic->error, Eq(GetParam().expected_diagnostic));
@@ -709,8 +709,8 @@
TEST_P(BinaryParseAssemblyDiagnosticTest, AssemblyCases) {
auto words = CompileSuccessfully(GetParam().assembly);
- EXPECT_THAT(spvBinaryParse(context, nullptr, words.data(), words.size(),
- nullptr, nullptr, &diagnostic),
+ EXPECT_THAT(spvBinaryParse(ScopedContext().context, nullptr, words.data(),
+ words.size(), nullptr, nullptr, &diagnostic),
AnyOf(SPV_ERROR_INVALID_BINARY, SPV_ERROR_INVALID_ID));
ASSERT_NE(nullptr, diagnostic);
EXPECT_THAT(diagnostic->error, Eq(GetParam().expected_diagnostic));
diff --git a/test/BinaryToText.cpp b/test/BinaryToText.cpp
index bfb8887..897e8d1 100644
--- a/test/BinaryToText.cpp
+++ b/test/BinaryToText.cpp
@@ -415,9 +415,9 @@
TEST_F(TextToBinaryTest, VersionString) {
auto words = CompileSuccessfully("");
spv_text decoded_text = nullptr;
- EXPECT_THAT(spvBinaryToText(context, words.data(), words.size(),
- SPV_BINARY_TO_TEXT_OPTION_NONE, &decoded_text,
- &diagnostic),
+ EXPECT_THAT(spvBinaryToText(ScopedContext().context, words.data(),
+ words.size(), SPV_BINARY_TO_TEXT_OPTION_NONE,
+ &decoded_text, &diagnostic),
Eq(SPV_SUCCESS));
EXPECT_EQ(nullptr, diagnostic);
@@ -446,9 +446,9 @@
SPV_GENERATOR_WORD(GetParam().generator, GetParam().misc);
spv_text decoded_text = nullptr;
- EXPECT_THAT(spvBinaryToText(context, words.data(), words.size(),
- SPV_BINARY_TO_TEXT_OPTION_NONE, &decoded_text,
- &diagnostic),
+ EXPECT_THAT(spvBinaryToText(ScopedContext().context, words.data(),
+ words.size(), SPV_BINARY_TO_TEXT_OPTION_NONE,
+ &decoded_text, &diagnostic),
Eq(SPV_SUCCESS));
EXPECT_THAT(diagnostic, Eq(nullptr));
EXPECT_THAT(std::string(decoded_text->str), HasSubstr(GetParam().expected));
diff --git a/test/ImmediateInt.cpp b/test/ImmediateInt.cpp
index bdfdd87..1233a16 100644
--- a/test/ImmediateInt.cpp
+++ b/test/ImmediateInt.cpp
@@ -30,8 +30,8 @@
#include <gmock/gmock.h>
-#include "source/util/bitutils.h"
#include "TestFixture.h"
+#include "source/util/bitutils.h"
namespace {
@@ -46,8 +46,8 @@
TEST_F(TextToBinaryTest, ImmediateIntOpCode) {
SetText("!0x00FF00FF");
- ASSERT_EQ(SPV_SUCCESS, spvTextToBinary(context, text.str, text.length,
- &binary, &diagnostic));
+ ASSERT_EQ(SPV_SUCCESS, spvTextToBinary(ScopedContext().context, text.str,
+ text.length, &binary, &diagnostic));
EXPECT_EQ(0x00FF00FFu, binary->code[5]);
if (diagnostic) {
spvDiagnosticPrint(diagnostic);
@@ -56,8 +56,8 @@
TEST_F(TextToBinaryTest, ImmediateIntOperand) {
SetText("OpCapability !0x00FF00FF");
- EXPECT_EQ(SPV_SUCCESS, spvTextToBinary(context, text.str, text.length,
- &binary, &diagnostic));
+ EXPECT_EQ(SPV_SUCCESS, spvTextToBinary(ScopedContext().context, text.str,
+ text.length, &binary, &diagnostic));
EXPECT_EQ(0x00FF00FFu, binary->code[6]);
if (diagnostic) {
spvDiagnosticPrint(diagnostic);
diff --git a/test/OpcodeRequiresCapabilities.cpp b/test/OpcodeRequiresCapabilities.cpp
index c89ad69..eea16ea 100644
--- a/test/OpcodeRequiresCapabilities.cpp
+++ b/test/OpcodeRequiresCapabilities.cpp
@@ -46,7 +46,7 @@
spv_opcode_desc_t entry;
};
-TEST_P(Requires, Capabilityabilities) {
+TEST_P(Requires, Capabilities) {
ASSERT_NE(0, spvOpcodeRequiresCapabilities(&entry));
}
@@ -94,7 +94,7 @@
TEST_P(OpcodeTableCapabilitiesTest, TableEntryMatchesExpectedCapabilities) {
spv_opcode_table opcodeTable;
ASSERT_EQ(SPV_SUCCESS,
- spvOpcodeTableGet(&opcodeTable, SPV_ENV_UNIVERSAL_1_0));
+ spvOpcodeTableGet(&opcodeTable, SPV_ENV_UNIVERSAL_1_1));
spv_opcode_desc entry;
ASSERT_EQ(SPV_SUCCESS,
spvOpcodeTableValueLookup(opcodeTable, GetParam().opcode, &entry));
@@ -133,6 +133,8 @@
ExpectedOpCodeCapabilities{SpvOpFunction, 0},
ExpectedOpCodeCapabilities{SpvOpConvertFToS, 0},
ExpectedOpCodeCapabilities{SpvOpEmitStreamVertex,
- mask(SpvCapabilityGeometryStreams)}), );
+ mask(SpvCapabilityGeometryStreams)},
+ ExpectedOpCodeCapabilities{SpvOpTypeNamedBarrier,
+ mask(SpvCapabilityNamedBarrier)}), );
} // anonymous namespace
diff --git a/test/TestFixture.h b/test/TestFixture.h
index c3edd32..9a57f13 100644
--- a/test/TestFixture.h
+++ b/test/TestFixture.h
@@ -40,13 +40,17 @@
using SpirvVector = std::vector<uint32_t>;
// Offset into a SpirvVector at which the first instruction starts.
- const SpirvVector::size_type kFirstInstruction = 5;
+ static const SpirvVector::size_type kFirstInstruction = 5;
- TextToBinaryTestBase()
- : context(spvContextCreate(SPV_ENV_UNIVERSAL_1_0)),
- diagnostic(nullptr),
- text(),
- binary(nullptr) {
+ // RAII for spv_context.
+ struct ScopedContext {
+ ScopedContext(spv_target_env env = SPV_ENV_UNIVERSAL_1_0)
+ : context(spvContextCreate(env)) {}
+ ~ScopedContext() { spvContextDestroy(context); }
+ spv_context context;
+ };
+
+ TextToBinaryTestBase() : diagnostic(nullptr), text(), binary(nullptr) {
char textStr[] = "substitute the text member variable with your test";
text = {textStr, strlen(textStr)};
}
@@ -54,7 +58,6 @@
virtual ~TextToBinaryTestBase() {
DestroyBinary();
if (diagnostic) spvDiagnosticDestroy(diagnostic);
- spvContextDestroy(context);
}
// Returns subvector v[from:end).
@@ -65,9 +68,11 @@
// Compiles SPIR-V text in the given assembly syntax format, asserting
// compilation success. Returns the compiled code.
- SpirvVector CompileSuccessfully(const std::string& txt) {
+ SpirvVector CompileSuccessfully(const std::string& txt,
+ spv_target_env env = SPV_ENV_UNIVERSAL_1_0) {
spv_result_t status =
- spvTextToBinary(context, txt.c_str(), txt.size(), &binary, &diagnostic);
+ spvTextToBinary(ScopedContext(env).context, txt.c_str(), txt.size(),
+ &binary, &diagnostic);
EXPECT_EQ(SPV_SUCCESS, status) << txt;
SpirvVector code_copy;
if (status == SPV_SUCCESS) {
@@ -81,9 +86,11 @@
// Compiles SPIR-V text with the given format, asserting compilation failure.
// Returns the error message(s).
- std::string CompileFailure(const std::string& txt) {
- EXPECT_NE(SPV_SUCCESS, spvTextToBinary(context, txt.c_str(), txt.size(),
- &binary, &diagnostic))
+ std::string CompileFailure(const std::string& txt,
+ spv_target_env env = SPV_ENV_UNIVERSAL_1_0) {
+ EXPECT_NE(SPV_SUCCESS,
+ spvTextToBinary(ScopedContext(env).context, txt.c_str(),
+ txt.size(), &binary, &diagnostic))
<< txt;
DestroyBinary();
return diagnostic->error;
@@ -100,8 +107,9 @@
std::string EncodeAndDecodeSuccessfully(const std::string& txt,
uint32_t disassemble_options) {
DestroyBinary();
- spv_result_t error =
- spvTextToBinary(context, txt.c_str(), txt.size(), &binary, &diagnostic);
+ ScopedContext context;
+ spv_result_t error = spvTextToBinary(context.context, txt.c_str(),
+ txt.size(), &binary, &diagnostic);
if (error) {
spvDiagnosticPrint(diagnostic);
spvDiagnosticDestroy(diagnostic);
@@ -110,7 +118,7 @@
if (!binary) return "";
spv_text decoded_text;
- error = spvBinaryToText(context, binary->code, binary->wordCount,
+ error = spvBinaryToText(context.context, binary->code, binary->wordCount,
disassemble_options, &decoded_text, &diagnostic);
if (error) {
spvDiagnosticPrint(diagnostic);
@@ -137,9 +145,10 @@
spvtest::Concatenate({CompileSuccessfully(txt), words_to_append});
spv_text decoded_text;
- EXPECT_NE(SPV_SUCCESS, spvBinaryToText(context, code.data(), code.size(),
- SPV_BINARY_TO_TEXT_OPTION_NONE,
- &decoded_text, &diagnostic));
+ EXPECT_NE(SPV_SUCCESS,
+ spvBinaryToText(ScopedContext().context, code.data(), code.size(),
+ SPV_BINARY_TO_TEXT_OPTION_NONE, &decoded_text,
+ &diagnostic));
if (diagnostic) {
std::string error_message = diagnostic->error;
spvDiagnosticDestroy(diagnostic);
@@ -151,8 +160,9 @@
// Compiles SPIR-V text, asserts success, and returns the words representing
// the instructions. In particular, skip the words in the SPIR-V header.
- SpirvVector CompiledInstructions(const std::string& txt) {
- const SpirvVector code = CompileSuccessfully(txt);
+ SpirvVector CompiledInstructions(const std::string& txt,
+ spv_target_env env = SPV_ENV_UNIVERSAL_1_0) {
+ const SpirvVector code = CompileSuccessfully(txt, env);
SpirvVector result;
// Extract just the instructions.
// If the code fails to compile, then return the empty vector.
@@ -174,7 +184,6 @@
binary = nullptr;
}
- spv_context context;
spv_diagnostic diagnostic;
std::string textString;
diff --git a/test/TextToBinary.Barrier.cpp b/test/TextToBinary.Barrier.cpp
index b3452e7..9f833d7 100644
--- a/test/TextToBinary.Barrier.cpp
+++ b/test/TextToBinary.Barrier.cpp
@@ -29,14 +29,16 @@
#include "UnitSPIRV.h"
-#include "gmock/gmock.h"
#include "TestFixture.h"
+#include "gmock/gmock.h"
namespace {
+using ::testing::ElementsAre;
+using ::testing::Eq;
+using ::testing::_;
using spvtest::MakeInstruction;
using spvtest::TextToBinaryTest;
-using ::testing::Eq;
// Test OpMemoryBarrier
@@ -86,4 +88,86 @@
// TODO(dneto): OpGroupUMax
// TODO(dneto): OpGroupSMax
+using NamedMemoryBarrierTest = spvtest::TextToBinaryTest;
+
+TEST_F(NamedMemoryBarrierTest, OpcodeUnrecognizedInV10) {
+ EXPECT_THAT(CompileFailure("OpMemoryNamedBarrier %bar %scope %semantics",
+ SPV_ENV_UNIVERSAL_1_0),
+ Eq("Invalid Opcode name 'OpMemoryNamedBarrier'"));
+}
+
+TEST_F(NamedMemoryBarrierTest, ArgumentCount) {
+ EXPECT_THAT(CompileFailure("OpMemoryNamedBarrier", SPV_ENV_UNIVERSAL_1_1),
+ Eq("Expected operand, found end of stream."));
+ EXPECT_THAT(
+ CompileFailure("OpMemoryNamedBarrier %bar", SPV_ENV_UNIVERSAL_1_1),
+ Eq("Expected operand, found end of stream."));
+ EXPECT_THAT(
+ CompileFailure("OpMemoryNamedBarrier %bar %scope", SPV_ENV_UNIVERSAL_1_1),
+ Eq("Expected operand, found end of stream."));
+ EXPECT_THAT(
+ CompiledInstructions("OpMemoryNamedBarrier %bar %scope %semantics",
+ SPV_ENV_UNIVERSAL_1_1),
+ ElementsAre(spvOpcodeMake(4, SpvOpMemoryNamedBarrier), _, _, _));
+ EXPECT_THAT(
+ CompileFailure("OpMemoryNamedBarrier %bar %scope %semantics %extra",
+ SPV_ENV_UNIVERSAL_1_1),
+ Eq("Expected '=', found end of stream."));
+}
+
+TEST_F(NamedMemoryBarrierTest, ArgumentTypes) {
+ EXPECT_THAT(CompileFailure("OpMemoryNamedBarrier 123 %scope %semantics",
+ SPV_ENV_UNIVERSAL_1_1),
+ Eq("Expected id to start with %."));
+ EXPECT_THAT(CompileFailure("OpMemoryNamedBarrier %bar %scope \"semantics\"",
+ SPV_ENV_UNIVERSAL_1_1),
+ Eq("Expected id to start with %."));
+}
+
+using TypeNamedBarrierTest = spvtest::TextToBinaryTest;
+
+TEST_F(TypeNamedBarrierTest, OpcodeUnrecognizedInV10) {
+ EXPECT_THAT(CompileFailure("%t = OpTypeNamedBarrier", SPV_ENV_UNIVERSAL_1_0),
+ Eq("Invalid Opcode name 'OpTypeNamedBarrier'"));
+}
+
+TEST_F(TypeNamedBarrierTest, ArgumentCount) {
+ EXPECT_THAT(CompileFailure("OpTypeNamedBarrier", SPV_ENV_UNIVERSAL_1_1),
+ Eq("Expected <result-id> at the beginning of an instruction, "
+ "found 'OpTypeNamedBarrier'."));
+ EXPECT_THAT(
+ CompiledInstructions("%t = OpTypeNamedBarrier", SPV_ENV_UNIVERSAL_1_1),
+ ElementsAre(spvOpcodeMake(2, SpvOpTypeNamedBarrier), _));
+ EXPECT_THAT(
+ CompileFailure("%t = OpTypeNamedBarrier 1 2 3", SPV_ENV_UNIVERSAL_1_1),
+ Eq("Expected <opcode> or <result-id> at the beginning of an instruction, "
+ "found '1'."));
+}
+
+using NamedBarrierInitializeTest = spvtest::TextToBinaryTest;
+
+TEST_F(NamedBarrierInitializeTest, OpcodeUnrecognizedInV10) {
+ EXPECT_THAT(CompileFailure("%bar = OpNamedBarrierInitialize %type %count",
+ SPV_ENV_UNIVERSAL_1_0),
+ Eq("Invalid Opcode name 'OpNamedBarrierInitialize'"));
+}
+
+TEST_F(NamedBarrierInitializeTest, ArgumentCount) {
+ EXPECT_THAT(
+ CompileFailure("%bar = OpNamedBarrierInitialize", SPV_ENV_UNIVERSAL_1_1),
+ Eq("Expected operand, found end of stream."));
+ EXPECT_THAT(CompileFailure("%bar = OpNamedBarrierInitialize %ype",
+ SPV_ENV_UNIVERSAL_1_1),
+ Eq("Expected operand, found end of stream."));
+ EXPECT_THAT(
+ CompiledInstructions("%bar = OpNamedBarrierInitialize %type %count",
+ SPV_ENV_UNIVERSAL_1_1),
+ ElementsAre(spvOpcodeMake(4, SpvOpNamedBarrierInitialize), _, _, _));
+ EXPECT_THAT(
+ CompileFailure("%bar = OpNamedBarrierInitialize %type %count \"extra\"",
+ SPV_ENV_UNIVERSAL_1_1),
+ Eq("Expected <opcode> or <result-id> at the beginning of an instruction, "
+ "found '\"extra\"'."));
+}
+
} // anonymous namespace
diff --git a/test/TextToBinary.cpp b/test/TextToBinary.cpp
index 812da40..a1a58e3 100644
--- a/test/TextToBinary.cpp
+++ b/test/TextToBinary.cpp
@@ -123,7 +123,8 @@
TEST_F(TextToBinaryTest, InvalidText) {
ASSERT_EQ(SPV_ERROR_INVALID_TEXT,
- spvTextToBinary(context, nullptr, 0, &binary, &diagnostic));
+ spvTextToBinary(ScopedContext().context, nullptr, 0, &binary,
+ &diagnostic));
EXPECT_NE(nullptr, diagnostic);
EXPECT_THAT(diagnostic->error, Eq(std::string("Missing assembly text.")));
}
@@ -131,16 +132,17 @@
TEST_F(TextToBinaryTest, InvalidPointer) {
SetText(
"OpEntryPoint Kernel 0 \"\"\nOpExecutionMode 0 LocalSizeHint 1 1 1\n");
- ASSERT_EQ(
- SPV_ERROR_INVALID_POINTER,
- spvTextToBinary(context, text.str, text.length, nullptr, &diagnostic));
+ ASSERT_EQ(SPV_ERROR_INVALID_POINTER,
+ spvTextToBinary(ScopedContext().context, text.str, text.length,
+ nullptr, &diagnostic));
}
TEST_F(TextToBinaryTest, InvalidDiagnostic) {
SetText(
"OpEntryPoint Kernel 0 \"\"\nOpExecutionMode 0 LocalSizeHint 1 1 1\n");
ASSERT_EQ(SPV_ERROR_INVALID_DIAGNOSTIC,
- spvTextToBinary(context, text.str, text.length, &binary, nullptr));
+ spvTextToBinary(ScopedContext().context, text.str, text.length,
+ &binary, nullptr));
}
TEST_F(TextToBinaryTest, InvalidPrefix) {
diff --git a/test/ValidateID.cpp b/test/ValidateID.cpp
index 808a90b..c125a74 100644
--- a/test/ValidateID.cpp
+++ b/test/ValidateID.cpp
@@ -414,7 +414,8 @@
// Runs spvValidate() on v, printing any errors via spvDiagnosticPrint().
spv_result_t Val(const SpirvVector& v) {
spv_const_binary_t cbinary{v.data(), v.size()};
- const auto status = spvValidate(context, &cbinary, &diagnostic_);
+ const auto status =
+ spvValidate(ScopedContext().context, &cbinary, &diagnostic_);
if (status != SPV_SUCCESS) {
spvDiagnosticPrint(diagnostic_);
}
diff --git a/tools/val/val.cpp b/tools/val/val.cpp
index 8ec92db..d5b88d5 100644
--- a/tools/val/val.cpp
+++ b/tools/val/val.cpp
@@ -63,10 +63,9 @@
if ('-' == cur_arg[0]) {
if (0 == strcmp(cur_arg, "--version")) {
printf("%s\n", kBuildVersion);
- printf("Targets:\n %s\n %s\n %s\n",
- spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_0),
- spvTargetEnvDescription(SPV_ENV_VULKAN_1_0),
- spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_1));
+ printf("Targets:\n %s\n %s\n",
+ spvTargetEnvDescription(SPV_ENV_UNIVERSAL_1_1),
+ spvTargetEnvDescription(SPV_ENV_VULKAN_1_0));
return 0;
} else if (0 == strcmp(cur_arg, "--help") || 0 == strcmp(cur_arg, "-h")) {
print_usage(argv[0]);