Commit 2d0cc786 by John Kessenich

SPV: Turn on atomic-storage functionality for SPIR-V.

This is used by OpenGL, but not Vulkan. Includes: - atomicCounter, atomicIncrement, atomicCounterDecrement - atomic_uint layout-offset checking - AtomicStorage capability
parent 5e69ec68
...@@ -1832,7 +1832,7 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty ...@@ -1832,7 +1832,7 @@ spv::Id TGlslangToSpvTraverser::convertGlslangToSpvType(const glslang::TType& ty
spvType = builder.makeUintType(64); spvType = builder.makeUintType(64);
break; break;
case glslang::EbtAtomicUint: case glslang::EbtAtomicUint:
logger->tbdFunctionality("Is atomic_uint an opaque handle in the uniform storage class, or an addresses in the atomic storage class?"); builder.addCapability(spv::CapabilityAtomicStorage);
spvType = builder.makeUintType(32); spvType = builder.makeUintType(32);
break; break;
case glslang::EbtSampler: case glslang::EbtSampler:
......
#version 310 es #version 450
...@@ -22,6 +22,7 @@ void main() ...@@ -22,6 +22,7 @@ void main()
func(counter); func(counter);
uint val = atomicCounter(countArr[2]); uint val = atomicCounter(countArr[2]);
atomicCounterDecrement(counter); atomicCounterDecrement(counter);
atomicCounterIncrement(counter);
} }
shared int atomi; shared int atomi;
......
...@@ -1259,7 +1259,6 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV ...@@ -1259,7 +1259,6 @@ void TBuiltIns::initialize(int version, EProfile profile, const SpvVersion& spvV
} }
if (spvVersion.vulkan == 0) { if (spvVersion.vulkan == 0) {
// gl_spirv TODO
// //
// Atomic counter functions. // Atomic counter functions.
// //
......
...@@ -186,7 +186,6 @@ INSTANTIATE_TEST_CASE_P( ...@@ -186,7 +186,6 @@ INSTANTIATE_TEST_CASE_P(
"whileLoop.frag", "whileLoop.frag",
"nonVulkan.frag", "nonVulkan.frag",
"negativeArraySize.comp", "negativeArraySize.comp",
"spv.atomic.comp",
"precise.tesc", "precise.tesc",
"precise_struct_block.vert", "precise_struct_block.vert",
"maxClipDistances.vert", "maxClipDistances.vert",
......
...@@ -41,19 +41,29 @@ ...@@ -41,19 +41,29 @@
namespace glslangtest { namespace glslangtest {
namespace { namespace {
using CompileToSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>; using CompileVulkanToSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
using CompileOpenGLToSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
using VulkanSemantics = GlslangTest<::testing::TestWithParam<std::string>>; using VulkanSemantics = GlslangTest<::testing::TestWithParam<std::string>>;
using VulkanAstSemantics = GlslangTest<::testing::TestWithParam<std::string>>; using VulkanAstSemantics = GlslangTest<::testing::TestWithParam<std::string>>;
// Compiling GLSL to SPIR-V under Vulkan semantics. Expected to successfully // Compiling GLSL to SPIR-V under Vulkan semantics. Expected to successfully
// generate SPIR-V. // generate SPIR-V.
TEST_P(CompileToSpirvTest, FromFile) TEST_P(CompileVulkanToSpirvTest, FromFile)
{ {
loadFileCompileAndCheck(GLSLANG_TEST_DIRECTORY, GetParam(), loadFileCompileAndCheck(GLSLANG_TEST_DIRECTORY, GetParam(),
Source::GLSL, Semantics::Vulkan, Source::GLSL, Semantics::Vulkan,
Target::Spv); Target::Spv);
} }
// Compiling GLSL to SPIR-V under OpenGL semantics. Expected to successfully
// generate SPIR-V.
TEST_P(CompileOpenGLToSpirvTest, FromFile)
{
loadFileCompileAndCheck(GLSLANG_TEST_DIRECTORY, GetParam(),
Source::GLSL, Semantics::OpenGL,
Target::Spv);
}
// GLSL-level Vulkan semantics test. Expected to error out before generating // GLSL-level Vulkan semantics test. Expected to error out before generating
// SPIR-V. // SPIR-V.
TEST_P(VulkanSemantics, FromFile) TEST_P(VulkanSemantics, FromFile)
...@@ -73,7 +83,7 @@ TEST_P(VulkanAstSemantics, FromFile) ...@@ -73,7 +83,7 @@ TEST_P(VulkanAstSemantics, FromFile)
// clang-format off // clang-format off
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
Glsl, CompileToSpirvTest, Glsl, CompileVulkanToSpirvTest,
::testing::ValuesIn(std::vector<std::string>({ ::testing::ValuesIn(std::vector<std::string>({
// Test looping constructs. // Test looping constructs.
// No tests yet for making sure break and continue from a nested loop // No tests yet for making sure break and continue from a nested loop
...@@ -192,6 +202,18 @@ INSTANTIATE_TEST_CASE_P( ...@@ -192,6 +202,18 @@ INSTANTIATE_TEST_CASE_P(
FileNameAsCustomTestSuffix FileNameAsCustomTestSuffix
); );
// clang-format off
INSTANTIATE_TEST_CASE_P(
Glsl, CompileOpenGLToSpirvTest,
::testing::ValuesIn(std::vector<std::string>({
// Test looping constructs.
// No tests yet for making sure break and continue from a nested loop
// goes to the innermost target.
"spv.atomic.comp",
})),
FileNameAsCustomTestSuffix
);
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(
Glsl, VulkanSemantics, Glsl, VulkanSemantics,
::testing::ValuesIn(std::vector<std::string>({ ::testing::ValuesIn(std::vector<std::string>({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment