Externals: Update glslang.

This updates glslang to commit 9bb8cfffb0eed010e07132282c41d73064a7a609
which is the current version listed in the known_good.json file for the
version 1.3.212 of the Vulkan-ValidationLayers repo.
This commit is contained in:
iwubcode
2022-04-30 00:37:59 -05:00
parent 260d3faba8
commit 6d528a72eb
142 changed files with 26417 additions and 10676 deletions
+25 -2
View File
@@ -59,7 +59,7 @@ TEST_P(CompileToAstTestNV, FromFile)
}
// clang-format off
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Glsl, CompileToAstTest,
::testing::ValuesIn(std::vector<std::string>({
"sample.frag",
@@ -233,7 +233,12 @@ INSTANTIATE_TEST_CASE_P(
"precise_struct_block.vert",
"maxClipDistances.vert",
"findFunction.frag",
"noMatchingFunction.frag",
"constantUnaryConversion.comp",
"xfbUnsizedArray.error.vert",
"xfbUnsizedArray.error.tese",
"glsl.140.layoutOffset.error.vert",
"glsl.430.layoutOffset.error.vert",
"glsl.450.subgroup.frag",
"glsl.450.subgroup.geom",
"glsl.450.subgroup.tesc",
@@ -258,6 +263,7 @@ INSTANTIATE_TEST_CASE_P(
"glsl.460.subgroup.rgen",
"glsl.460.subgroup.rint",
"glsl.460.subgroup.rmiss",
"glsl.es300.layoutOffset.error.vert",
"glsl.es320.subgroup.frag",
"glsl.es320.subgroup.geom",
"glsl.es320.subgroup.tesc",
@@ -274,17 +280,34 @@ INSTANTIATE_TEST_CASE_P(
"glsl.es320.subgroupShuffleRelative.comp",
"glsl.es320.subgroupQuad.comp",
"glsl.es320.subgroupVote.comp",
"terminate.frag",
"terminate.vert",
"negativeWorkGroupSize.comp",
"textureoffset_sampler2darrayshadow.vert",
"atomicAdd.comp",
"GL_ARB_gpu_shader5.u2i.vert",
"textureQueryLOD.frag",
"atomicCounterARBOps.vert",
"GL_EXT_shader_integer_mix.vert",
"GL_ARB_draw_instanced.vert",
"GL_ARB_fragment_coord_conventions.vert",
"BestMatchFunction.vert",
"EndStreamPrimitive.geom",
"floatBitsToInt.vert",
"coord_conventions.frag",
"gl_FragCoord.frag"
})),
FileNameAsCustomTestSuffix
);
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Glsl, CompileToAstTestNV,
::testing::ValuesIn(std::vector<std::string>({
"nvShaderNoperspectiveInterpolation.frag",
})),
FileNameAsCustomTestSuffix
);
// clang-format on
} // anonymous namespace
+46 -4
View File
@@ -1,3 +1,36 @@
# Copyright (C) 2020 The Khronos Group Inc.
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
#
# Neither the name of The Khronos Group Inc. nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
if(BUILD_TESTING)
if(TARGET gmock)
message(STATUS "Google Mock found - building tests")
@@ -14,29 +47,32 @@ if(BUILD_TESTING)
# Test related source files
${CMAKE_CURRENT_SOURCE_DIR}/AST.FromFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/BuiltInResource.FromFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Common.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Config.FromFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/HexFloat.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Hlsl.FromFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Link.FromFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Link.FromFile.Vk.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Pp.FromFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Spv.FromFile.cpp)
${CMAKE_CURRENT_SOURCE_DIR}/Spv.FromFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/VkRelaxed.FromFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/GlslMapIO.FromFile.cpp)
if(ENABLE_SPVREMAPPER)
set(TEST_SOURCES ${TEST_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/Remap.FromFile.cpp)
endif()
glslang_pch(TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/pch.cpp)
add_executable(glslangtests ${TEST_SOURCES})
glslang_pch(glslangtests ${CMAKE_CURRENT_SOURCE_DIR}/pch.h)
set_property(TARGET glslangtests PROPERTY FOLDER tests)
glslang_set_link_args(glslangtests)
if(ENABLE_GLSLANG_INSTALL)
install(TARGETS glslangtests EXPORT glslangtestsTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(EXPORT glslangtestsTargets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
endif(ENABLE_GLSLANG_INSTALL)
endif()
set(GLSLANG_TEST_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../Test")
# Supply a default test root directory, so that manual testing
@@ -50,6 +86,12 @@ if(BUILD_TESTING)
${gmock_SOURCE_DIR}/include
${gtest_SOURCE_DIR}/include)
if(ENABLE_OPT)
target_include_directories(glslangtests
PRIVATE ${spirv-tools_SOURCE_DIR}/include
)
endif()
set(LIBRARIES
glslang OSDependent OGLCompiler glslang
SPIRV glslang-default-resource-limits)
@@ -60,7 +102,7 @@ if(BUILD_TESTING)
if(ENABLE_HLSL)
set(LIBRARIES ${LIBRARIES} HLSL)
endif(ENABLE_HLSL)
endif()
target_link_libraries(glslangtests PRIVATE ${LIBRARIES} gmock)
add_test(NAME glslang-gtests
+165
View File
@@ -0,0 +1,165 @@
// Copyright (c) 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <cstdint>
#include <gmock/gmock.h>
#include "glslang/Include/Common.h"
namespace {
TEST(IsPow2, Int_Negative) {
EXPECT_EQ(false, glslang::IsPow2(-5));
EXPECT_EQ(false, glslang::IsPow2(-1));
EXPECT_EQ(false, glslang::IsPow2(INT_MIN));
EXPECT_EQ(false, glslang::IsPow2(int64_t(-10)));
}
TEST(IsPow2, Zero) {
EXPECT_EQ(false, glslang::IsPow2(0));
EXPECT_EQ(false, glslang::IsPow2(0u));
EXPECT_EQ(false, glslang::IsPow2(0));
EXPECT_EQ(false, glslang::IsPow2(uint64_t(0)));
EXPECT_EQ(false, glslang::IsPow2(int64_t(0)));
}
TEST(IsPow2, Int_Positive_PowersOf2) {
EXPECT_EQ(true, glslang::IsPow2(1));
EXPECT_EQ(true, glslang::IsPow2(2));
EXPECT_EQ(true, glslang::IsPow2(4));
EXPECT_EQ(true, glslang::IsPow2(8));
EXPECT_EQ(true, glslang::IsPow2(16));
EXPECT_EQ(true, glslang::IsPow2(32768));
EXPECT_EQ(true, glslang::IsPow2(65536));
EXPECT_EQ(true, glslang::IsPow2(2147483648));
}
TEST(IsPow2, Int_Positive_NonPowersOf2) {
EXPECT_EQ(false, glslang::IsPow2(3));
EXPECT_EQ(false, glslang::IsPow2(5));
EXPECT_EQ(false, glslang::IsPow2(2147483647));
}
TEST(IsPow2, Uint_Positive_PowersOf2) {
EXPECT_EQ(true, glslang::IsPow2(1u));
EXPECT_EQ(true, glslang::IsPow2(2u));
EXPECT_EQ(true, glslang::IsPow2(4u));
EXPECT_EQ(true, glslang::IsPow2(8u));
EXPECT_EQ(true, glslang::IsPow2(16u));
EXPECT_EQ(true, glslang::IsPow2(32768u));
EXPECT_EQ(true, glslang::IsPow2(65536u));
EXPECT_EQ(true, glslang::IsPow2(2147483648u));
}
TEST(IsPow2, Uint_Positive_NonPowersOf2) {
EXPECT_EQ(false, glslang::IsPow2(3u));
EXPECT_EQ(false, glslang::IsPow2(5u));
EXPECT_EQ(false, glslang::IsPow2(2147483647u));
}
TEST(IntLog2, Int) {
EXPECT_EQ(0, glslang::IntLog2(1));
EXPECT_EQ(1, glslang::IntLog2(2));
EXPECT_EQ(2, glslang::IntLog2(4));
EXPECT_EQ(3, glslang::IntLog2(8));
EXPECT_EQ(4, glslang::IntLog2(16));
EXPECT_EQ(5, glslang::IntLog2(32));
EXPECT_EQ(6, glslang::IntLog2(64));
EXPECT_EQ(7, glslang::IntLog2(128));
EXPECT_EQ(8, glslang::IntLog2(256));
EXPECT_EQ(9, glslang::IntLog2(512));
EXPECT_EQ(10, glslang::IntLog2(1024));
EXPECT_EQ(11, glslang::IntLog2(2048));
EXPECT_EQ(12, glslang::IntLog2(0x1000));
EXPECT_EQ(13, glslang::IntLog2(0x2000));
EXPECT_EQ(14, glslang::IntLog2(0x4000));
EXPECT_EQ(15, glslang::IntLog2(0x8000));
EXPECT_EQ(16, glslang::IntLog2(0x10000));
EXPECT_EQ(17, glslang::IntLog2(0x20000));
EXPECT_EQ(18, glslang::IntLog2(0x40000));
EXPECT_EQ(19, glslang::IntLog2(0x80000));
EXPECT_EQ(20, glslang::IntLog2(0x100000));
EXPECT_EQ(21, glslang::IntLog2(0x200000));
EXPECT_EQ(22, glslang::IntLog2(0x400000));
EXPECT_EQ(23, glslang::IntLog2(0x800000));
EXPECT_EQ(24, glslang::IntLog2(0x1000000));
EXPECT_EQ(25, glslang::IntLog2(0x2000000));
EXPECT_EQ(26, glslang::IntLog2(0x4000000));
EXPECT_EQ(27, glslang::IntLog2(0x8000000));
EXPECT_EQ(28, glslang::IntLog2(0x10000000));
EXPECT_EQ(29, glslang::IntLog2(0x20000000));
EXPECT_EQ(30, glslang::IntLog2(0x40000000));
}
TEST(IntLog2, Uint) {
EXPECT_EQ(0, glslang::IntLog2(1u));
EXPECT_EQ(1, glslang::IntLog2(2u));
EXPECT_EQ(2, glslang::IntLog2(4u));
EXPECT_EQ(3, glslang::IntLog2(8u));
EXPECT_EQ(4, glslang::IntLog2(16u));
EXPECT_EQ(5, glslang::IntLog2(32u));
EXPECT_EQ(6, glslang::IntLog2(64u));
EXPECT_EQ(7, glslang::IntLog2(128u));
EXPECT_EQ(8, glslang::IntLog2(256u));
EXPECT_EQ(9, glslang::IntLog2(512u));
EXPECT_EQ(10, glslang::IntLog2(1024u));
EXPECT_EQ(11, glslang::IntLog2(2048u));
EXPECT_EQ(12, glslang::IntLog2(0x1000u));
EXPECT_EQ(13, glslang::IntLog2(0x2000u));
EXPECT_EQ(14, glslang::IntLog2(0x4000u));
EXPECT_EQ(15, glslang::IntLog2(0x8000u));
EXPECT_EQ(16, glslang::IntLog2(0x10000u));
EXPECT_EQ(17, glslang::IntLog2(0x20000u));
EXPECT_EQ(18, glslang::IntLog2(0x40000u));
EXPECT_EQ(19, glslang::IntLog2(0x80000u));
EXPECT_EQ(20, glslang::IntLog2(0x100000u));
EXPECT_EQ(21, glslang::IntLog2(0x200000u));
EXPECT_EQ(22, glslang::IntLog2(0x400000u));
EXPECT_EQ(23, glslang::IntLog2(0x800000u));
EXPECT_EQ(24, glslang::IntLog2(0x1000000u));
EXPECT_EQ(25, glslang::IntLog2(0x2000000u));
EXPECT_EQ(26, glslang::IntLog2(0x4000000u));
EXPECT_EQ(27, glslang::IntLog2(0x8000000u));
EXPECT_EQ(28, glslang::IntLog2(0x10000000u));
EXPECT_EQ(29, glslang::IntLog2(0x20000000u));
EXPECT_EQ(30, glslang::IntLog2(0x40000000u));
EXPECT_EQ(31, glslang::IntLog2(0x80000000u));
}
TEST(IntLog2, Int64) {
EXPECT_EQ(0, glslang::IntLog2(int64_t(1)));
EXPECT_EQ(1, glslang::IntLog2(int64_t(2)));
EXPECT_EQ(2, glslang::IntLog2(int64_t(4)));
EXPECT_EQ(3, glslang::IntLog2(int64_t(8)));
EXPECT_EQ(30, glslang::IntLog2(int64_t(0x40000000u)));
EXPECT_EQ(31, glslang::IntLog2(int64_t(0x80000000u)));
EXPECT_EQ(32, glslang::IntLog2(int64_t(0x10000) * int64_t(0x10000)));
EXPECT_EQ(48, glslang::IntLog2(int64_t(0x10000) * int64_t(0x10000) * int64_t(0x10000)));
EXPECT_EQ(62, glslang::IntLog2(int64_t(0x10000) * int64_t(0x10000) * int64_t(0x10000) * int64_t(0x4000)));
}
TEST(IntLog2, Uint64) {
EXPECT_EQ(0, glslang::IntLog2(uint64_t(1)));
EXPECT_EQ(1, glslang::IntLog2(uint64_t(2)));
EXPECT_EQ(2, glslang::IntLog2(uint64_t(4)));
EXPECT_EQ(3, glslang::IntLog2(uint64_t(8)));
EXPECT_EQ(30, glslang::IntLog2(uint64_t(0x40000000u)));
EXPECT_EQ(31, glslang::IntLog2(uint64_t(0x80000000u)));
EXPECT_EQ(32, glslang::IntLog2(uint64_t(0x10000) * uint64_t(0x10000)));
EXPECT_EQ(48, glslang::IntLog2(uint64_t(0x10000) * uint64_t(0x10000) * uint64_t(0x10000)));
EXPECT_EQ(62, glslang::IntLog2(uint64_t(0x10000) * uint64_t(0x10000) * uint64_t(0x10000) * uint64_t(0x4000)));
EXPECT_EQ(63, glslang::IntLog2(uint64_t(0x10000) * uint64_t(0x10000) * uint64_t(0x10000) * uint64_t(0x8000)));
}
} // anonymous namespace
+1 -1
View File
@@ -95,7 +95,7 @@ TEST_P(ConfigTest, FromFile)
}
// clang-format off
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Glsl, ConfigTest,
::testing::ValuesIn(std::vector<TestCaseSpec>({
{"specExamples.vert", "baseResults/test.conf", "specExamplesConf.vert.out", (EShMessages)(EShMsgAST | EShMsgCascadingErrors)},
+355
View File
@@ -0,0 +1,355 @@
//
// Copyright (C) 2016-2017 Google, Inc.
// Copyright (C) 2020 The Khronos Group Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#include <algorithm>
#include <gtest/gtest.h>
#include "TestFixture.h"
#include "glslang/MachineIndependent/iomapper.h"
#include "glslang/MachineIndependent/reflection.h"
#ifndef GLSLANG_WEB
namespace glslangtest {
namespace {
struct IoMapData {
std::vector<std::string> fileNames;
Semantics semantics;
};
using GlslMapIOTest = GlslangTest <::testing::TestWithParam<IoMapData>>;
template<class T>
std::string interfaceName(T symbol) {
return symbol.getType()->getBasicType() == glslang::EbtBlock ? std::string(symbol.getType()->getTypeName().c_str()) : symbol.name;
}
bool verifyIOMapping(std::string& linkingError, glslang::TProgram& program) {
bool success = true;
// Verify IO Mapping by generating reflection for each stage individually
// and comparing layout qualifiers on the results
int reflectionOptions = EShReflectionDefault;
//reflectionOptions |= EShReflectionStrictArraySuffix;
//reflectionOptions |= EShReflectionBasicArraySuffix;
reflectionOptions |= EShReflectionIntermediateIO;
reflectionOptions |= EShReflectionSeparateBuffers;
reflectionOptions |= EShReflectionAllBlockVariables;
//reflectionOptions |= EShReflectionUnwrapIOBlocks;
success &= program.buildReflection(reflectionOptions);
// check that the reflection output from the individual stages all makes sense..
std::vector<glslang::TReflection> stageReflections;
for (int s = 0; s < EShLangCount; ++s) {
if (program.getIntermediate((EShLanguage)s)) {
stageReflections.emplace_back((EShReflectionOptions)reflectionOptions, (EShLanguage)s, (EShLanguage)s);
success &= stageReflections.back().addStage((EShLanguage)s, *program.getIntermediate((EShLanguage)s));
}
}
// check that input/output locations match between stages
auto it = stageReflections.begin();
auto nextIt = it + 1;
for (; nextIt != stageReflections.end(); it++, nextIt++) {
int numOut = it->getNumPipeOutputs();
std::map<std::string, const glslang::TObjectReflection*> pipeOut;
for (int i = 0; i < numOut; i++) {
const glslang::TObjectReflection& out = it->getPipeOutput(i);
std::string name = interfaceName(out);
pipeOut[name] = &out;
}
int numIn = nextIt->getNumPipeInputs();
for (int i = 0; i < numIn; i++) {
auto in = nextIt->getPipeInput(i);
std::string name = interfaceName(in);
auto out = pipeOut.find(name);
if (out != pipeOut.end()) {
auto inQualifier = in.getType()->getQualifier();
auto outQualifier = out->second->getType()->getQualifier();
success &= outQualifier.layoutLocation == inQualifier.layoutLocation;
}
else {
if (!in.getType()->isStruct()) {
bool found = false;
for (auto outIt : pipeOut) {
if (outIt.second->getType()->isStruct()) {
unsigned int baseLoc = outIt.second->getType()->getQualifier().hasLocation() ?
outIt.second->getType()->getQualifier().layoutLocation :
std::numeric_limits<unsigned int>::max();
for (size_t j = 0; j < outIt.second->getType()->getStruct()->size(); j++) {
baseLoc = (*outIt.second->getType()->getStruct())[j].type->getQualifier().hasLocation() ?
(*outIt.second->getType()->getStruct())[j].type->getQualifier().layoutLocation : baseLoc;
if (baseLoc != std::numeric_limits<unsigned int>::max()) {
if (baseLoc == in.getType()->getQualifier().layoutLocation) {
found = true;
break;
}
baseLoc += glslang::TIntermediate::computeTypeLocationSize(*(*outIt.second->getType()->getStruct())[j].type, EShLangVertex);
}
}
if (found) {
break;
}
}
}
success &= found;
}
else {
unsigned int baseLoc = in.getType()->getQualifier().hasLocation() ? in.getType()->getQualifier().layoutLocation : -1;
for (size_t j = 0; j < in.getType()->getStruct()->size(); j++) {
baseLoc = (*in.getType()->getStruct())[j].type->getQualifier().hasLocation() ?
(*in.getType()->getStruct())[j].type->getQualifier().layoutLocation : baseLoc;
if (baseLoc != std::numeric_limits<unsigned int>::max()) {
bool isMemberFound = false;
for (auto outIt : pipeOut) {
if (baseLoc == outIt.second->getType()->getQualifier().layoutLocation) {
isMemberFound = true;
break;
}
}
if (!isMemberFound) {
success &= false;
break;
}
baseLoc += glslang::TIntermediate::computeTypeLocationSize(*(*in.getType()->getStruct())[j].type, EShLangVertex);
}
}
}
}
}
}
// compare uniforms in each stage to the program
{
int totalUniforms = program.getNumUniformVariables();
std::map<std::string, const glslang::TObjectReflection*> programUniforms;
for (int i = 0; i < totalUniforms; i++) {
const glslang::TObjectReflection& uniform = program.getUniform(i);
std::string name = interfaceName(uniform);
programUniforms[name] = &uniform;
}
it = stageReflections.begin();
for (; it != stageReflections.end(); it++) {
int numUniform = it->getNumUniforms();
std::map<std::string, glslang::TObjectReflection> uniforms;
for (int i = 0; i < numUniform; i++) {
glslang::TObjectReflection uniform = it->getUniform(i);
std::string name = interfaceName(uniform);
auto programUniform = programUniforms.find(name);
if (programUniform != programUniforms.end()) {
auto stageQualifier = uniform.getType()->getQualifier();
auto programQualifier = programUniform->second->getType()->getQualifier();
success &= stageQualifier.layoutLocation == programQualifier.layoutLocation;
success &= stageQualifier.layoutBinding == programQualifier.layoutBinding;
success &= stageQualifier.layoutSet == programQualifier.layoutSet;
}
else {
success &= false;
}
}
}
}
// compare uniform blocks in each stage to the program table
{
int totalUniforms = program.getNumUniformBlocks();
std::map<std::string, const glslang::TObjectReflection*> programUniforms;
for (int i = 0; i < totalUniforms; i++) {
const glslang::TObjectReflection& uniform = program.getUniformBlock(i);
std::string name = interfaceName(uniform);
programUniforms[name] = &uniform;
}
it = stageReflections.begin();
for (; it != stageReflections.end(); it++) {
int numUniform = it->getNumUniformBlocks();
std::map<std::string, glslang::TObjectReflection> uniforms;
for (int i = 0; i < numUniform; i++) {
glslang::TObjectReflection uniform = it->getUniformBlock(i);
std::string name = interfaceName(uniform);
auto programUniform = programUniforms.find(name);
if (programUniform != programUniforms.end()) {
auto stageQualifier = uniform.getType()->getQualifier();
auto programQualifier = programUniform->second->getType()->getQualifier();
success &= stageQualifier.layoutLocation == programQualifier.layoutLocation;
success &= stageQualifier.layoutBinding == programQualifier.layoutBinding;
success &= stageQualifier.layoutSet == programQualifier.layoutSet;
}
else {
success &= false;
}
}
}
}
if (!success) {
linkingError += "Mismatched cross-stage IO\n";
}
return success;
}
TEST_P(GlslMapIOTest, FromFile)
{
const auto& fileNames = GetParam().fileNames;
Semantics semantics = GetParam().semantics;
const size_t fileCount = fileNames.size();
const EShMessages controls = DeriveOptions(Source::GLSL, semantics, Target::BothASTAndSpv);
GlslangResult result;
// Compile each input shader file.
bool success = true;
std::vector<std::unique_ptr<glslang::TShader>> shaders;
for (size_t i = 0; i < fileCount; ++i) {
std::string contents;
tryLoadFile(GlobalTestSettings.testRoot + "/" + fileNames[i],
"input", &contents);
shaders.emplace_back(
new glslang::TShader(GetShaderStage(GetSuffix(fileNames[i]))));
auto* shader = shaders.back().get();
shader->setAutoMapLocations(true);
shader->setAutoMapBindings(true);
if (controls & EShMsgSpvRules) {
if (controls & EShMsgVulkanRules) {
shader->setEnvInput((controls & EShMsgReadHlsl) ? glslang::EShSourceHlsl
: glslang::EShSourceGlsl,
shader->getStage(), glslang::EShClientVulkan, 100);
shader->setEnvClient(glslang::EShClientVulkan, glslang::EShTargetVulkan_1_1);
shader->setEnvTarget(glslang::EShTargetSpv, glslang::EShTargetSpv_1_0);
} else {
shader->setEnvInput((controls & EShMsgReadHlsl) ? glslang::EShSourceHlsl
: glslang::EShSourceGlsl,
shader->getStage(), glslang::EShClientOpenGL, 100);
shader->setEnvClient(glslang::EShClientOpenGL, glslang::EShTargetOpenGL_450);
shader->setEnvTarget(glslang::EshTargetSpv, glslang::EShTargetSpv_1_0);
}
}
success &= compile(shader, contents, "", controls);
result.shaderResults.push_back(
{ fileNames[i], shader->getInfoLog(), shader->getInfoDebugLog() });
}
// Link all of them.
glslang::TProgram program;
for (const auto& shader : shaders) program.addShader(shader.get());
success &= program.link(controls);
result.linkingOutput = program.getInfoLog();
result.linkingError = program.getInfoDebugLog();
unsigned int stage = 0;
glslang::TIntermediate* firstIntermediate = nullptr;
while (!program.getIntermediate((EShLanguage)stage) && stage < EShLangCount) { stage++; }
firstIntermediate = program.getIntermediate((EShLanguage)stage);
glslang::TDefaultGlslIoResolver resolver(*firstIntermediate);
glslang::TGlslIoMapper ioMapper;
if (success) {
success &= program.mapIO(&resolver, &ioMapper);
result.linkingOutput = program.getInfoLog();
result.linkingError = program.getInfoDebugLog();
}
success &= verifyIOMapping(result.linkingError, program);
result.validationResult = success;
if (success && (controls & EShMsgSpvRules)) {
for (int stage = 0; stage < EShLangCount; ++stage) {
if (program.getIntermediate((EShLanguage)stage)) {
spv::SpvBuildLogger logger;
std::vector<uint32_t> spirv_binary;
options().disableOptimizer = false;
glslang::GlslangToSpv(*program.getIntermediate((EShLanguage)stage),
spirv_binary, &logger, &options());
std::ostringstream disassembly_stream;
spv::Parameterize();
spv::Disassemble(disassembly_stream, spirv_binary);
result.spirvWarningsErrors += logger.getAllMessages();
result.spirv += disassembly_stream.str();
result.validationResult &= !options().validate || logger.getAllMessages().empty();
}
}
}
std::ostringstream stream;
outputResultToStream(&stream, result, controls);
// Check with expected results.
const std::string expectedOutputFname =
GlobalTestSettings.testRoot + "/baseResults/" + fileNames.front() + ".out";
std::string expectedOutput;
tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
checkEqAndUpdateIfRequested(expectedOutput, stream.str(), expectedOutputFname,
result.spirvWarningsErrors);
}
// clang-format off
INSTANTIATE_TEST_SUITE_P(
Glsl, GlslMapIOTest,
::testing::ValuesIn(std::vector<IoMapData>({
{{"iomap.crossStage.vert", "iomap.crossStage.frag" }, Semantics::OpenGL},
{{"iomap.crossStage.2.vert", "iomap.crossStage.2.geom", "iomap.crossStage.2.frag" }, Semantics::OpenGL},
{{"iomap.blockOutVariableIn.vert", "iomap.blockOutVariableIn.frag"}, Semantics::OpenGL},
{{"iomap.variableOutBlockIn.vert", "iomap.variableOutBlockIn.frag"}, Semantics::OpenGL},
{{"iomap.blockOutVariableIn.2.vert", "iomap.blockOutVariableIn.geom"}, Semantics::OpenGL},
{{"iomap.variableOutBlockIn.2.vert", "iomap.variableOutBlockIn.geom"}, Semantics::OpenGL},
// vulkan semantics
{{"iomap.crossStage.vk.vert", "iomap.crossStage.vk.geom", "iomap.crossStage.vk.frag" }, Semantics::Vulkan},
}))
);
// clang-format on
} // anonymous namespace
} // namespace glslangtest
#endif
+19 -19
View File
@@ -77,7 +77,7 @@ TEST_P(HexDoubleTest, DecodeCorrectly) {
EXPECT_THAT(Decode<double>(GetParam().second), Eq(GetParam().first));
}
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Float32Tests, HexFloatTest,
::testing::ValuesIn(std::vector<std::pair<FloatProxy<float>, std::string>>({
{0.f, "0x0p+0"},
@@ -129,7 +129,7 @@ INSTANTIATE_TEST_CASE_P(
})));
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Float32NanTests, HexFloatTest,
::testing::ValuesIn(std::vector<std::pair<FloatProxy<float>, std::string>>({
// Various NAN and INF cases
@@ -147,7 +147,7 @@ INSTANTIATE_TEST_CASE_P(
{uint32_t(0x7FFFFFFF), "0x1.fffffep+128"}, // +nan
})));
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Float64Tests, HexDoubleTest,
::testing::ValuesIn(
std::vector<std::pair<FloatProxy<double>, std::string>>({
@@ -220,7 +220,7 @@ INSTANTIATE_TEST_CASE_P(
})));
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Float64NanTests, HexDoubleTest,
::testing::ValuesIn(std::vector<
std::pair<FloatProxy<double>, std::string>>({
@@ -262,7 +262,7 @@ TEST_P(DecodeHexDoubleTest, DecodeCorrectly) {
EXPECT_THAT(Decode<double>(GetParam().first), Eq(GetParam().second));
}
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Float32DecodeTests, DecodeHexFloatTest,
::testing::ValuesIn(std::vector<std::pair<std::string, FloatProxy<float>>>({
{"0x0p+000", 0.f},
@@ -284,7 +284,7 @@ INSTANTIATE_TEST_CASE_P(
{"0x0.4p+0", 0.25f},
})));
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Float32DecodeInfTests, DecodeHexFloatTest,
::testing::ValuesIn(std::vector<std::pair<std::string, FloatProxy<float>>>({
// inf cases
@@ -294,7 +294,7 @@ INSTANTIATE_TEST_CASE_P(
{"-0x32p+127", uint32_t(0xFF800000)}, // -inf
})));
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Float64DecodeTests, DecodeHexDoubleTest,
::testing::ValuesIn(
std::vector<std::pair<std::string, FloatProxy<double>>>({
@@ -317,7 +317,7 @@ INSTANTIATE_TEST_CASE_P(
{"0x0.4p+0", 0.25},
})));
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Float64DecodeInfTests, DecodeHexDoubleTest,
::testing::ValuesIn(
std::vector<std::pair<std::string, FloatProxy<double>>>({
@@ -465,7 +465,7 @@ TEST_P(FloatProxyDoubleTest, EncodeCorrectly) {
Eq(GetParam().second));
}
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Float32Tests, FloatProxyFloatTest,
::testing::ValuesIn(std::vector<std::pair<FloatProxy<float>, std::string>>({
// Zero
@@ -497,7 +497,7 @@ INSTANTIATE_TEST_CASE_P(
{-std::numeric_limits<float>::infinity(), "-0x1p+128"},
})));
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Float64Tests, FloatProxyDoubleTest,
::testing::ValuesIn(
std::vector<std::pair<FloatProxy<double>, std::string>>({
@@ -747,7 +747,7 @@ TEST_P(HexFloatRoundTest, RoundDownToFP16) {
}
// clang-format off
INSTANTIATE_TEST_CASE_P(F32ToF16, HexFloatRoundTest,
INSTANTIATE_TEST_SUITE_P(F32ToF16, HexFloatRoundTest,
::testing::ValuesIn(std::vector<RoundSignificandCase>(
{
{float_fractions({0}), std::make_pair(half_bits_set({}), false), spvutils::kRoundToZero},
@@ -828,7 +828,7 @@ TEST_P(HexFloatRoundUpSignificandTest, Widening) {
}
}
INSTANTIATE_TEST_CASE_P(F16toF32, HexFloatRoundUpSignificandTest,
INSTANTIATE_TEST_SUITE_P(F16toF32, HexFloatRoundUpSignificandTest,
// 0xFC00 of the source 16-bit hex value cover the sign and the exponent.
// They are ignored for this test.
::testing::ValuesIn(std::vector<UpCastSignificandCase>(
@@ -879,7 +879,7 @@ TEST_P(HexFloatFP32To16Tests, NarrowingCasts) {
const uint16_t positive_infinity = 0x7C00;
const uint16_t negative_infinity = 0xFC00;
INSTANTIATE_TEST_CASE_P(F32ToF16, HexFloatFP32To16Tests,
INSTANTIATE_TEST_SUITE_P(F32ToF16, HexFloatFP32To16Tests,
::testing::ValuesIn(std::vector<DownCastTest>(
{
// Exactly representable as half.
@@ -944,7 +944,7 @@ TEST_P(HexFloatFP16To32Tests, WideningCasts) {
}
}
INSTANTIATE_TEST_CASE_P(F16ToF32, HexFloatFP16To32Tests,
INSTANTIATE_TEST_SUITE_P(F16ToF32, HexFloatFP16To32Tests,
::testing::ValuesIn(std::vector<UpCastCase>(
{
{0x0000, 0.f},
@@ -1039,7 +1039,7 @@ FloatParseCase<T> GoodFloatParseCase(std::string literal, bool negate_value,
return FloatParseCase<T>{literal, negate_value, true, proxy_expected_value};
}
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
FloatParse, ParseNormalFloatTest,
::testing::ValuesIn(std::vector<FloatParseCase<float>>{
// Failing cases due to trivially incorrect syntax.
@@ -1090,7 +1090,7 @@ TEST_P(ParseNormalFloat16Test, Samples) {
}
}
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Float16Parse, ParseNormalFloat16Test,
::testing::ValuesIn(std::vector<FloatParseCase<Float16>>{
// Failing cases due to trivially incorrect syntax.
@@ -1137,7 +1137,7 @@ TEST_P(FloatProxyParseOverflowFloatTest, Sample) {
}
}
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
FloatOverflow, FloatProxyParseOverflowFloatTest,
::testing::ValuesIn(std::vector<OverflowParseCase<float>>({
{"0", true, 0.0f},
@@ -1164,7 +1164,7 @@ TEST_P(FloatProxyParseOverflowDoubleTest, Sample) {
}
}
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
DoubleOverflow, FloatProxyParseOverflowDoubleTest,
::testing::ValuesIn(std::vector<OverflowParseCase<double>>({
{"0", true, 0.0},
@@ -1193,7 +1193,7 @@ TEST_P(FloatProxyParseOverflowFloat16Test, Sample) {
}
}
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Float16Overflow, FloatProxyParseOverflowFloat16Test,
::testing::ValuesIn(std::vector<OverflowParseCase<uint16_t>>({
{"0", true, uint16_t{0}},
Vendored Executable → Regular
+35 -8
View File
@@ -59,6 +59,7 @@ std::string FileNameAsCustomTestSuffix(
using HlslCompileTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
using HlslVulkan1_1CompileTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
using HlslSpv1_6CompileTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
using HlslCompileAndFlattenTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
using HlslLegalizeTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
using HlslDebugTest = GlslangTest<::testing::TestWithParam<FileNameEntryPointPair>>;
@@ -81,6 +82,13 @@ TEST_P(HlslVulkan1_1CompileTest, FromFile)
Target::BothASTAndSpv, true, GetParam().entryPoint);
}
TEST_P(HlslSpv1_6CompileTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
Source::HLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_3, glslang::EShTargetSpv_1_6,
Target::BothASTAndSpv, true, GetParam().entryPoint);
}
TEST_P(HlslCompileAndFlattenTest, FromFile)
{
loadFileCompileFlattenUniformsAndCheck(GlobalTestSettings.testRoot, GetParam().fileName,
@@ -129,7 +137,7 @@ TEST_P(HlslLegalDebugTest, FromFile)
}
// clang-format off
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
ToSpirv, HlslCompileTest,
::testing::ValuesIn(std::vector<FileNameEntryPointPair>{
{"hlsl.amend.frag", "f1"},
@@ -227,6 +235,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.hull.3.tesc", "main"},
{"hlsl.hull.4.tesc", "main"},
{"hlsl.hull.5.tesc", "main"},
{"hlsl.hull.6.tesc", "main"},
{"hlsl.hull.void.tesc", "main"},
{"hlsl.hull.ctrlpt-1.tesc", "main"},
{"hlsl.hull.ctrlpt-2.tesc", "main"},
@@ -234,16 +243,17 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.groupid.comp", "main"},
{"hlsl.identifier.sample.frag", "main"},
{"hlsl.if.frag", "PixelShaderFunction"},
{"hlsl.imageload-subvec4.comp", "main"},
{"hlsl.imagefetch-subvec4.comp", "main"},
{"hlsl.implicitBool.frag", "main"},
{"hlsl.inf.vert", "main"},
{"hlsl.inoutquals.frag", "main"},
{"hlsl.inoutquals.negative.frag", "main"},
{"hlsl.init.frag", "ShaderFunction"},
{"hlsl.init2.frag", "main"},
{"hlsl.isfinite.frag", "main"},
{"hlsl.intrinsics.barriers.comp", "ComputeShaderFunction"},
{"hlsl.intrinsics.comp", "ComputeShaderFunction"},
{"hlsl.intrinsics.evalfns.frag", "main"},
{"hlsl.intrinsics.d3dcolortoubyte4.frag", "main"},
{"hlsl.intrinsics.double.frag", "PixelShaderFunction"},
{"hlsl.intrinsics.f1632.frag", "main"},
@@ -277,6 +287,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.logical.unary.frag", "main"},
{"hlsl.loopattr.frag", "main"},
{"hlsl.matpack-pragma.frag", "main"},
{"hlsl.matpack-pragma-global.frag", "main"},
{"hlsl.mip.operator.frag", "main"},
{"hlsl.mip.negative.frag", "main"},
{"hlsl.mip.negative2.frag", "main"},
@@ -305,10 +316,12 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.pp.vert", "main"},
{"hlsl.pp.line.frag", "main"},
{"hlsl.precise.frag", "main"},
{"hlsl.printf.comp", "main"},
{"hlsl.promote.atomic.frag", "main"},
{"hlsl.promote.binary.frag", "main"},
{"hlsl.promote.vec1.frag", "main"},
{"hlsl.promotions.frag", "main"},
{"hlsl.round.dx10.frag", "main"},
{"hlsl.rw.atomics.frag", "main"},
{"hlsl.rw.bracket.frag", "main"},
{"hlsl.rw.register.frag", "main"},
@@ -350,6 +363,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.semicolons.frag", "main"},
{"hlsl.shapeConv.frag", "main"},
{"hlsl.shapeConvRet.frag", "main"},
{"hlsl.singleArgIntPromo.vert", "main"},
{"hlsl.self_cast.frag", "main"},
{"hlsl.snorm.uav.comp", "main"},
{"hlsl.specConstant.frag", "main"},
@@ -379,6 +393,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.structbuffer.fn2.comp", "main"},
{"hlsl.structbuffer.rw.frag", "main"},
{"hlsl.structbuffer.rwbyte.frag", "main"},
{"hlsl.structbuffer.rwbyte2.comp", "main"},
{"hlsl.structin.vert", "main"},
{"hlsl.structIoFourWay.frag", "main"},
{"hlsl.structStructName.frag", "main"},
@@ -426,7 +441,7 @@ INSTANTIATE_TEST_CASE_P(
// clang-format on
// clang-format off
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
ToSpirv, HlslVulkan1_1CompileTest,
::testing::ValuesIn(std::vector<FileNameEntryPointPair>{
{"hlsl.wavebroadcast.comp", "CSMain"},
@@ -444,7 +459,17 @@ INSTANTIATE_TEST_CASE_P(
// clang-format on
// clang-format off
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
ToSpirv, HlslSpv1_6CompileTest,
::testing::ValuesIn(std::vector<FileNameEntryPointPair>{
{"hlsl.spv.1.6.discard.frag", "PixelShaderFunction"}
}),
FileNameAsCustomTestSuffix
);
// clang-format on
// clang-format off
INSTANTIATE_TEST_SUITE_P(
ToSpirv, HlslCompileAndFlattenTest,
::testing::ValuesIn(std::vector<FileNameEntryPointPair>{
{"hlsl.array.flatten.frag", "main"},
@@ -456,7 +481,7 @@ INSTANTIATE_TEST_CASE_P(
#if ENABLE_OPT
// clang-format off
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
ToSpirv, HlslLegalizeTest,
::testing::ValuesIn(std::vector<FileNameEntryPointPair>{
{"hlsl.aliasOpaque.frag", "main"},
@@ -465,6 +490,7 @@ INSTANTIATE_TEST_CASE_P(
{"hlsl.flattenOpaqueInitMix.vert", "main"},
{"hlsl.flattenSubset.frag", "main"},
{"hlsl.flattenSubset2.frag", "main"},
{"hlsl.intrinsics.evalfns.frag", "main"},
{"hlsl.partialFlattenLocal.vert", "main"},
{"hlsl.partialFlattenMixed.vert", "main"}
}),
@@ -474,7 +500,7 @@ INSTANTIATE_TEST_CASE_P(
#endif
// clang-format off
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
ToSpirv, HlslDebugTest,
::testing::ValuesIn(std::vector<FileNameEntryPointPair>{
{"hlsl.pp.line2.frag", "MainPs"}
@@ -482,9 +508,10 @@ INSTANTIATE_TEST_CASE_P(
FileNameAsCustomTestSuffix
);
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
ToSpirv, HlslDX9CompatibleTest,
::testing::ValuesIn(std::vector<FileNameEntryPointPair>{
{"hlsl.round.dx9.frag", "main"},
{"hlsl.sample.dx9.frag", "main"},
{"hlsl.sample.dx9.vert", "main"},
}),
@@ -492,7 +519,7 @@ INSTANTIATE_TEST_CASE_P(
);
// clang-format off
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
ToSpirv, HlslLegalDebugTest,
::testing::ValuesIn(std::vector<FileNameEntryPointPair>{
{"hlsl.pp.line4.frag", "MainPs"}
+18 -1
View File
@@ -50,6 +50,7 @@ TEST_P(LinkTestVulkan, FromFile)
const size_t fileCount = fileNames.size();
const EShMessages controls = DeriveOptions(Source::GLSL, Semantics::Vulkan, Target::AST);
GlslangResult result;
result.validationResult = false;
// Compile each input shader file.
bool success = true;
@@ -74,6 +75,11 @@ TEST_P(LinkTestVulkan, FromFile)
result.linkingOutput = program.getInfoLog();
result.linkingError = program.getInfoDebugLog();
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
if (success)
program.mapIO();
#endif
if (success && (controls & EShMsgSpvRules)) {
spv::SpvBuildLogger logger;
std::vector<uint32_t> spirv_binary;
@@ -103,11 +109,22 @@ TEST_P(LinkTestVulkan, FromFile)
}
// clang-format off
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Glsl, LinkTestVulkan,
::testing::ValuesIn(std::vector<std::vector<std::string>>({
{"link1.vk.frag", "link2.vk.frag"},
{"spv.unit1.frag", "spv.unit2.frag", "spv.unit3.frag"},
{"link.vk.matchingPC.0.0.frag", "link.vk.matchingPC.0.1.frag",
"link.vk.matchingPC.0.2.frag"},
{"link.vk.differentPC.0.0.frag", "link.vk.differentPC.0.1.frag",
"link.vk.differentPC.0.2.frag"},
{"link.vk.differentPC.1.0.frag", "link.vk.differentPC.1.1.frag",
"link.vk.differentPC.1.2.frag"},
{"link.vk.pcNamingValid.0.0.vert", "link.vk.pcNamingValid.0.1.vert"},
{"link.vk.pcNamingInvalid.0.0.vert", "link.vk.pcNamingInvalid.0.1.vert"},
{"link.vk.multiBlocksValid.0.0.vert", "link.vk.multiBlocksValid.0.1.vert"},
{"link.vk.multiBlocksValid.1.0.geom", "link.vk.multiBlocksValid.1.1.geom"},
{"link.vk.inconsistentGLPerVertex.0.vert", "link.vk.inconsistentGLPerVertex.0.geom"},
}))
);
// clang-format on
+10 -2
View File
@@ -86,7 +86,7 @@ TEST_P(LinkTest, FromFile)
}
// clang-format off
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Glsl, LinkTest,
::testing::ValuesIn(std::vector<std::vector<std::string>>({
{"mains1.frag", "mains2.frag", "noMain1.geom", "noMain2.geom"},
@@ -99,8 +99,16 @@ INSTANTIATE_TEST_CASE_P(
{"empty.frag", "empty2.frag", "empty3.frag"},
{"150.tesc", "150.tese", "400.tesc", "400.tese", "410.tesc", "420.tesc", "420.tese"},
{"max_vertices_0.geom"},
{"contradict_0.geom", "contradict_1.geom"},
{"es-link1.frag", "es-link2.frag"},
{"missingBodies.vert"}
{"missingBodies.vert"},
{"link.multiAnonBlocksInvalid.0.0.vert", "link.multiAnonBlocksInvalid.0.1.vert"},
{"link.multiAnonBlocksValid.0.0.vert", "link.multiAnonBlocksValid.0.1.vert"},
{"link.multiBlocksInvalid.0.0.vert", "link.multiBlocksInvalid.0.1.vert"},
{"link.multiBlocksValid.1.0.vert", "link.multiBlocksValid.1.1.vert"},
{"link.tesselation.vert", "link.tesselation.frag"},
{"link.tesselation.tese", "link.tesselation.tesc"},
{"link.redeclareBuiltin.vert", "link.redeclareBuiltin.geom"},
}))
);
// clang-format on
+1 -1
View File
@@ -47,7 +47,7 @@ TEST_P(PreprocessingTest, FromFile)
}
// clang-format off
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Glsl, PreprocessingTest,
::testing::ValuesIn(std::vector<std::string>({
"preprocessor.bad_arg.vert",
+1 -1
View File
@@ -80,7 +80,7 @@ TEST_P(RemapTest, FromFile)
}
// clang-format off
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
ToSpirv, RemapTest,
::testing::ValuesIn(std::vector<RemapTestArgs>{
// GLSL remapper tests
+146 -14
View File
@@ -1,6 +1,7 @@
//
// Copyright (C) 2016 Google, Inc.
// Copyright (C) 2019 ARM Limited.
// Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
//
// All rights reserved.
//
@@ -68,6 +69,7 @@ using CompileVulkanToSpirvDeadCodeElimTest = GlslangTest<::testing::TestWithPara
using CompileVulkanToDebugSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
using CompileVulkan1_1ToSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
using CompileToSpirv14Test = GlslangTest<::testing::TestWithParam<std::string>>;
using CompileToSpirv16Test = GlslangTest<::testing::TestWithParam<std::string>>;
using CompileOpenGLToSpirvTest = GlslangTest<::testing::TestWithParam<std::string>>;
using VulkanSemantics = GlslangTest<::testing::TestWithParam<std::string>>;
using OpenGLSemantics = GlslangTest<::testing::TestWithParam<std::string>>;
@@ -76,6 +78,7 @@ using HlslIoMap = GlslangTest<::testing::TestWithParam<IoMapData>>;
using GlslIoMap = GlslangTest<::testing::TestWithParam<IoMapData>>;
using CompileVulkanToSpirvTestAMD = GlslangTest<::testing::TestWithParam<std::string>>;
using CompileVulkanToSpirvTestNV = GlslangTest<::testing::TestWithParam<std::string>>;
using CompileVulkanToSpirv14TestNV = GlslangTest<::testing::TestWithParam<std::string>>;
using CompileUpgradeTextureToSampledTextureAndDropSamplersTest = GlslangTest<::testing::TestWithParam<std::string>>;
// Compiling GLSL to SPIR-V under Vulkan semantics. Expected to successfully
@@ -105,6 +108,7 @@ TEST_P(CompileVulkanToDebugSpirvTest, FromFile)
"/baseResults/", false, true);
}
TEST_P(CompileVulkan1_1ToSpirvTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
@@ -119,6 +123,13 @@ TEST_P(CompileToSpirv14Test, FromFile)
Target::Spv);
}
TEST_P(CompileToSpirv16Test, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_3, glslang::EShTargetSpv_1_6,
Target::Spv);
}
// Compiling GLSL to SPIR-V under OpenGL semantics. Expected to successfully
// generate SPIR-V.
TEST_P(CompileOpenGLToSpirvTest, FromFile)
@@ -202,6 +213,13 @@ TEST_P(CompileVulkanToSpirvTestNV, FromFile)
Target::Spv);
}
TEST_P(CompileVulkanToSpirv14TestNV, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::Vulkan, glslang::EShTargetVulkan_1_1, glslang::EShTargetSpv_1_4,
Target::Spv);
}
TEST_P(CompileUpgradeTextureToSampledTextureAndDropSamplersTest, FromFile)
{
loadCompileUpgradeTextureToSampledTextureAndDropSamplersAndCheck(GlobalTestSettings.testRoot,
@@ -212,7 +230,7 @@ TEST_P(CompileUpgradeTextureToSampledTextureAndDropSamplersTest, FromFile)
}
// clang-format off
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Glsl, CompileVulkanToSpirvTest,
::testing::ValuesIn(std::vector<std::string>({
// Test looping constructs.
@@ -229,6 +247,17 @@ INSTANTIATE_TEST_CASE_P(
"spv.while-continue-break.vert",
"spv.while-simple.vert",
// vulkan-specific tests
"rayQuery.rgen",
"rayQuery-no-cse.rgen",
"rayQuery-initialize.rgen",
"rayQuery-allOps.rgen",
"rayQuery-allOps.Error.rgen",
"rayQuery-committed.Error.rgen",
"rayQuery-allOps.comp",
"rayQuery-allOps.frag",
"rayQuery-initialization.Error.comp",
"rayQuery-global.rgen",
"rayQuery-types.comp",
"spv.set.vert",
"spv.double.comp",
"spv.100ops.frag",
@@ -271,6 +300,7 @@ INSTANTIATE_TEST_CASE_P(
"spv.always-discard2.frag",
"spv.arbPostDepthCoverage.frag",
"spv.arbPostDepthCoverage_Error.frag",
"spv.atomicCounter.comp",
"spv.bitCast.frag",
"spv.bool.vert",
"spv.boolInBlock.frag",
@@ -309,9 +339,12 @@ INSTANTIATE_TEST_CASE_P(
"spv.dataOut.frag",
"spv.dataOutIndirect.frag",
"spv.dataOutIndirect.vert",
"spv.debugPrintf.frag",
"spv.debugPrintf_Error.frag",
"spv.demoteDisabled.frag",
"spv.deepRvalue.frag",
"spv.depthOut.frag",
"spv.depthUnchanged.frag",
"spv.discard-dce.frag",
"spv.doWhileLoop.frag",
"spv.earlyReturnDiscard.frag",
@@ -334,10 +367,22 @@ INSTANTIATE_TEST_CASE_P(
"spv.functionSemantics.frag",
"spv.functionParameterTypes.frag",
"spv.GeometryShaderPassthrough.geom",
"spv.funcall.array.frag",
"spv.load.bool.array.interface.block.frag",
"spv.interpOps.frag",
"spv.int64.frag",
"spv.intcoopmat.comp",
"spv.intOps.vert",
"spv.intrinsicsSpirvByReference.vert",
"spv.intrinsicsSpirvDecorate.frag",
"spv.intrinsicsSpirvExecutionMode.frag",
"spv.intrinsicsSpirvInstruction.vert",
"spv.intrinsicsSpirvLiteral.vert",
"spv.intrinsicsSpirvStorageClass.rchit",
"spv.intrinsicsSpirvType.rgen",
"spv.intrinsicsSpirvTypeLocalVar.vert",
"spv.invariantAll.vert",
"spv.layer.tese",
"spv.layoutNested.vert",
"spv.length.frag",
"spv.localAggregates.frag",
@@ -355,12 +400,19 @@ INSTANTIATE_TEST_CASE_P(
"spv.nonSquare.vert",
"spv.nonuniform.frag",
"spv.nonuniform2.frag",
"spv.nonuniform3.frag",
"spv.nonuniform4.frag",
"spv.nonuniform5.frag",
"spv.noWorkgroup.comp",
"spv.nullInit.comp",
"spv.offsets.frag",
"spv.Operations.frag",
"spv.paramMemory.frag",
"spv.paramMemory.420.frag",
"spv.precision.frag",
"spv.precisionArgs.frag",
"spv.precisionNonESSamp.frag",
"spv.precisionTexture.frag",
"spv.prepost.frag",
"spv.privateVariableTypes.frag",
"spv.qualifiers.vert",
@@ -391,6 +443,7 @@ INSTANTIATE_TEST_CASE_P(
"spv.texture.vert",
"spv.textureBuffer.vert",
"spv.image.frag",
"spv.imageAtomic64.frag",
"spv.types.frag",
"spv.uint.frag",
"spv.uniformArray.frag",
@@ -411,9 +464,15 @@ INSTANTIATE_TEST_CASE_P(
"spv.specConstant.comp",
"spv.specConstantComposite.vert",
"spv.specConstantOperations.vert",
"spv.specConstant.float16.comp",
"spv.specConstant.int16.comp",
"spv.specConstant.int8.comp",
"spv.storageBuffer.vert",
"spv.terminate.frag",
"spv.subgroupUniformControlFlow.vert",
"spv.precise.tese",
"spv.precise.tesc",
"spv.viewportindex.tese",
"spv.volatileAtomic.comp",
"spv.vulkan100.subgroupArithmetic.comp",
"spv.vulkan100.subgroupPartitioned.comp",
@@ -423,6 +482,9 @@ INSTANTIATE_TEST_CASE_P(
"spv.samplerlessTextureFunctions.frag",
"spv.smBuiltins.vert",
"spv.smBuiltins.frag",
"spv.builtin.PrimitiveShadingRateEXT.vert",
"spv.builtin.ShadingRateEXT.frag",
"spv.atomicAdd.bufferReference.comp"
})),
FileNameAsCustomTestSuffix
);
@@ -430,7 +492,7 @@ INSTANTIATE_TEST_CASE_P(
// Cases with deliberately unreachable code.
// By default the compiler will aggressively eliminate
// unreachable merges and continues.
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
GlslWithDeadCode, CompileVulkanToSpirvDeadCodeElimTest,
::testing::ValuesIn(std::vector<std::string>({
"spv.dead-after-continue.vert",
@@ -445,7 +507,7 @@ INSTANTIATE_TEST_CASE_P(
);
// clang-format off
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Glsl, CompileVulkanToDebugSpirvTest,
::testing::ValuesIn(std::vector<std::string>({
"spv.pp.line.frag",
@@ -454,7 +516,7 @@ INSTANTIATE_TEST_CASE_P(
);
// clang-format off
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Glsl, CompileVulkan1_1ToSpirvTest,
::testing::ValuesIn(std::vector<std::string>({
"spv.1.3.8bitstorage-ubo.vert",
@@ -466,11 +528,13 @@ INSTANTIATE_TEST_CASE_P(
"spv.vulkan110.int16.frag",
"spv.int32.frag",
"spv.explicittypes.frag",
"spv.float16NoRelaxed.vert",
"spv.float32.frag",
"spv.float64.frag",
"spv.memoryScopeSemantics.comp",
"spv.memoryScopeSemantics_Error.comp",
"spv.multiView.frag",
"spv.queueFamilyScope.comp",
"spv.RayGenShader11.rgen",
"spv.subgroup.frag",
"spv.subgroup.geom",
@@ -510,26 +574,76 @@ INSTANTIATE_TEST_CASE_P(
);
// clang-format off
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Glsl, CompileToSpirv14Test,
::testing::ValuesIn(std::vector<std::string>({
"spv.1.4.LoopControl.frag",
"spv.1.4.NonWritable.frag",
"spv.1.4.OpEntryPoint.frag",
"spv.1.4.OpEntryPoint.opaqueParams.vert",
"spv.1.4.OpSelect.frag",
"spv.1.4.OpCopyLogical.comp",
"spv.1.4.OpCopyLogicalBool.comp",
"spv.1.4.OpCopyLogical.funcall.frag",
"spv.1.4.funcall.array.frag",
"spv.1.4.load.bool.array.interface.block.frag",
"spv.1.4.image.frag",
"spv.1.4.sparseTexture.frag",
"spv.1.4.texture.frag",
"spv.1.4.constructComposite.comp",
"spv.ext.AnyHitShader.rahit",
"spv.ext.AnyHitShader_Errors.rahit",
"spv.ext.ClosestHitShader.rchit",
"spv.ext.ClosestHitShader_Subgroup.rchit",
"spv.ext.ClosestHitShader_Errors.rchit",
"spv.ext.IntersectShader.rint",
"spv.ext.IntersectShader_Errors.rint",
"spv.ext.MissShader.rmiss",
"spv.ext.MissShader_Errors.rmiss",
"spv.ext.RayPrimCull_Errors.rgen",
"spv.ext.RayCallable.rcall",
"spv.ext.RayCallable_Errors.rcall",
"spv.ext.RayConstants.rgen",
"spv.ext.RayGenShader.rgen",
"spv.ext.RayGenShader_Errors.rgen",
"spv.ext.RayGenShader11.rgen",
"spv.ext.RayGenShaderArray.rgen",
"spv.ext.RayGenSBTlayout.rgen",
"spv.ext.RayGenSBTlayout140.rgen",
"spv.ext.RayGenSBTlayout430.rgen",
"spv.ext.RayGenSBTlayoutscalar.rgen",
"spv.ext.World3x4.rahit",
"spv.ext.AccelDecl.frag",
"spv.ext.RayQueryDecl.frag",
// SPV_KHR_workgroup_memory_explicit_layout depends on SPIR-V 1.4.
"spv.WorkgroupMemoryExplicitLayout.SingleBlock.comp",
"spv.WorkgroupMemoryExplicitLayout.MultiBlock.comp",
"spv.WorkgroupMemoryExplicitLayout.8BitAccess.comp",
"spv.WorkgroupMemoryExplicitLayout.16BitAccess.comp",
"spv.WorkgroupMemoryExplicitLayout.NonBlock.comp",
"spv.WorkgroupMemoryExplicitLayout.MixBlockNonBlock_Errors.comp",
"spv.WorkgroupMemoryExplicitLayout.std140.comp",
"spv.WorkgroupMemoryExplicitLayout.std430.comp",
"spv.WorkgroupMemoryExplicitLayout.scalar.comp",
})),
FileNameAsCustomTestSuffix
);
// clang-format off
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Glsl, CompileToSpirv16Test,
::testing::ValuesIn(std::vector<std::string>({
"spv.1.6.conditionalDiscard.frag",
"spv.1.6.helperInvocation.frag",
"spv.1.6.specConstant.comp",
})),
FileNameAsCustomTestSuffix
);
// clang-format off
INSTANTIATE_TEST_SUITE_P(
Hlsl, HlslIoMap,
::testing::ValuesIn(std::vector<IoMapData>{
{ "spv.register.autoassign.frag", "main_ep", 5, 10, 0, 20, 30, true, false },
@@ -549,7 +663,7 @@ INSTANTIATE_TEST_CASE_P(
);
// clang-format off
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Hlsl, GlslIoMap,
::testing::ValuesIn(std::vector<IoMapData>{
{ "spv.glsl.register.autoassign.frag", "main", 5, 10, 0, 20, 30, true, false },
@@ -559,17 +673,23 @@ INSTANTIATE_TEST_CASE_P(
);
// clang-format off
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Glsl, CompileOpenGLToSpirvTest,
::testing::ValuesIn(std::vector<std::string>({
"spv.460.frag",
"spv.460.vert",
"spv.460.comp",
"spv.atomic.comp",
"spv.atomicFloat.comp",
"spv.atomicFloat_Error.comp",
"spv.glFragColor.frag",
"spv.rankShift.comp",
"spv.specConst.vert",
"spv.specTexture.frag",
"spv.OVR_multiview.vert",
"spv.uniformInitializer.frag",
"spv.uniformInitializerSpecConstant.frag",
"spv.uniformInitializerStruct.frag",
"spv.xfbOffsetOnBlockMembersAssignment.vert",
"spv.xfbOffsetOnStructMembersAssignment.vert",
"spv.xfbOverlapOffsetCheckWithBlockAndMember.vert",
@@ -578,7 +698,7 @@ INSTANTIATE_TEST_CASE_P(
FileNameAsCustomTestSuffix
);
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Glsl, VulkanSemantics,
::testing::ValuesIn(std::vector<std::string>({
"vulkan.frag",
@@ -590,7 +710,7 @@ INSTANTIATE_TEST_CASE_P(
FileNameAsCustomTestSuffix
);
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Glsl, OpenGLSemantics,
::testing::ValuesIn(std::vector<std::string>({
"glspv.esversion.vert",
@@ -602,7 +722,7 @@ INSTANTIATE_TEST_CASE_P(
FileNameAsCustomTestSuffix
);
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Glsl, VulkanAstSemantics,
::testing::ValuesIn(std::vector<std::string>({
"vulkan.ast.vert",
@@ -610,7 +730,7 @@ INSTANTIATE_TEST_CASE_P(
FileNameAsCustomTestSuffix
);
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Glsl, CompileVulkanToSpirvTestAMD,
::testing::ValuesIn(std::vector<std::string>({
"spv.16bitxfb.vert",
@@ -626,7 +746,7 @@ INSTANTIATE_TEST_CASE_P(
FileNameAsCustomTestSuffix
);
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Glsl, CompileVulkanToSpirvTestNV,
::testing::ValuesIn(std::vector<std::string>({
"spv.sampleMaskOverrideCoverage.frag",
@@ -638,6 +758,7 @@ INSTANTIATE_TEST_CASE_P(
"spv.multiviewPerViewAttributes.vert",
"spv.multiviewPerViewAttributes.tesc",
"spv.atomicInt64.comp",
"spv.atomicStoreInt64.comp",
"spv.shadingRate.frag",
"spv.RayGenShader.rgen",
"spv.RayGenShaderArray.rgen",
@@ -674,7 +795,18 @@ INSTANTIATE_TEST_CASE_P(
FileNameAsCustomTestSuffix
);
INSTANTIATE_TEST_CASE_P(
INSTANTIATE_TEST_SUITE_P(
Glsl, CompileVulkanToSpirv14TestNV,
::testing::ValuesIn(std::vector<std::string>({
"spv.RayGenShaderMotion.rgen",
"spv.IntersectShaderMotion.rint",
"spv.AnyHitShaderMotion.rahit",
"spv.ClosestHitShaderMotion.rchit",
"spv.MissShaderMotion.rmiss",
})),
FileNameAsCustomTestSuffix
);
INSTANTIATE_TEST_SUITE_P(
Glsl, CompileUpgradeTextureToSampledTextureAndDropSamplersTest,
::testing::ValuesIn(std::vector<std::string>({
"spv.texture.sampler.transform.frag",
+6 -6
View File
@@ -61,17 +61,17 @@ EShLanguage GetShaderStage(const std::string& stage)
} else if (stage == "comp") {
return EShLangCompute;
} else if (stage == "rgen") {
return EShLangRayGenNV;
return EShLangRayGen;
} else if (stage == "rint") {
return EShLangIntersectNV;
return EShLangIntersect;
} else if (stage == "rahit") {
return EShLangAnyHitNV;
return EShLangAnyHit;
} else if (stage == "rchit") {
return EShLangClosestHitNV;
return EShLangClosestHit;
} else if (stage == "rmiss") {
return EShLangMissNV;
return EShLangMiss;
} else if (stage == "rcall") {
return EShLangCallableNV;
return EShLangCallable;
} else if (stage == "task") {
return EShLangTaskNV;
} else if (stage == "mesh") {
Vendored Executable → Regular
+13 -6
View File
@@ -253,10 +253,13 @@ public:
glslang::TProgram program;
program.addShader(&shader);
success &= program.link(controls);
spv::SpvBuildLogger logger;
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
if (success)
program.mapIO();
#endif
if (success && (controls & EShMsgSpvRules)) {
spv::SpvBuildLogger logger;
std::vector<uint32_t> spirv_binary;
options().disableOptimizer = !enableOptimizer;
options().generateDebugInfo = enableDebug;
@@ -312,8 +315,9 @@ public:
program.addShader(&shader);
success &= program.link(controls);
#ifndef GLSLANG_WEB
success &= program.mapIO();
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
if (success)
program.mapIO();
#endif
spv::SpvBuildLogger logger;
@@ -356,10 +360,13 @@ public:
glslang::TProgram program;
program.addShader(&shader);
success &= program.link(controls);
spv::SpvBuildLogger logger;
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
if (success)
program.mapIO();
#endif
if (success && (controls & EShMsgSpvRules)) {
spv::SpvBuildLogger logger;
std::vector<uint32_t> spirv_binary;
glslang::GlslangToSpv(*program.getIntermediate(stage),
spirv_binary, &logger, &options());
+306
View File
@@ -0,0 +1,306 @@
//
// Copyright (C) 2016-2017 Google, Inc.
// Copyright (C) 2020 The Khronos Group Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#include <algorithm>
#include <gtest/gtest.h>
#include "TestFixture.h"
#include "glslang/MachineIndependent/iomapper.h"
#include "glslang/MachineIndependent/reflection.h"
#ifndef GLSLANG_WEB
namespace glslangtest {
namespace {
struct vkRelaxedData {
std::vector<std::string> fileNames;
std::vector<std::vector<std::string>> resourceSetBindings;
};
using VulkanRelaxedTest = GlslangTest <::testing::TestWithParam<vkRelaxedData>>;
template<class T>
std::string interfaceName(T symbol) {
return symbol.getType()->getBasicType() == glslang::EbtBlock ? std::string(symbol.getType()->getTypeName().c_str()) : symbol.name;
}
bool verifyIOMapping(std::string& linkingError, glslang::TProgram& program) {
bool success = true;
// Verify IO Mapping by generating reflection for each stage individually
// and comparing layout qualifiers on the results
int reflectionOptions = EShReflectionDefault;
//reflectionOptions |= EShReflectionStrictArraySuffix;
//reflectionOptions |= EShReflectionBasicArraySuffix;
reflectionOptions |= EShReflectionIntermediateIO;
reflectionOptions |= EShReflectionSeparateBuffers;
reflectionOptions |= EShReflectionAllBlockVariables;
//reflectionOptions |= EShReflectionUnwrapIOBlocks;
success &= program.buildReflection(reflectionOptions);
// check that the reflection output from the individual stages all makes sense..
std::vector<glslang::TReflection> stageReflections;
for (int s = 0; s < EShLangCount; ++s) {
if (program.getIntermediate((EShLanguage)s)) {
stageReflections.emplace_back((EShReflectionOptions)reflectionOptions, (EShLanguage)s, (EShLanguage)s);
success &= stageReflections.back().addStage((EShLanguage)s, *program.getIntermediate((EShLanguage)s));
}
}
// check that input/output locations match between stages
auto it = stageReflections.begin();
auto nextIt = it + 1;
for (; nextIt != stageReflections.end(); it++, nextIt++) {
int numOut = it->getNumPipeOutputs();
std::map<std::string, const glslang::TObjectReflection*> pipeOut;
for (int i = 0; i < numOut; i++) {
const glslang::TObjectReflection& out = it->getPipeOutput(i);
std::string name = interfaceName(out);
pipeOut[name] = &out;
}
int numIn = nextIt->getNumPipeInputs();
for (int i = 0; i < numIn; i++) {
auto in = nextIt->getPipeInput(i);
std::string name = interfaceName(in);
auto out = pipeOut.find(name);
if (out != pipeOut.end()) {
auto inQualifier = in.getType()->getQualifier();
auto outQualifier = out->second->getType()->getQualifier();
success &= outQualifier.layoutLocation == inQualifier.layoutLocation;
// These are not part of a matched interface. Other cases still need to be added.
} else if (name != "gl_FrontFacing" && name != "gl_FragCoord") {
success &= false;
}
}
}
// compare uniforms in each stage to the program
{
int totalUniforms = program.getNumUniformVariables();
std::map<std::string, const glslang::TObjectReflection*> programUniforms;
for (int i = 0; i < totalUniforms; i++) {
const glslang::TObjectReflection& uniform = program.getUniform(i);
std::string name = interfaceName(uniform);
programUniforms[name] = &uniform;
}
it = stageReflections.begin();
for (; it != stageReflections.end(); it++) {
int numUniform = it->getNumUniforms();
std::map<std::string, glslang::TObjectReflection> uniforms;
for (int i = 0; i < numUniform; i++) {
glslang::TObjectReflection uniform = it->getUniform(i);
std::string name = interfaceName(uniform);
auto programUniform = programUniforms.find(name);
if (programUniform != programUniforms.end()) {
auto stageQualifier = uniform.getType()->getQualifier();
auto programQualifier = programUniform->second->getType()->getQualifier();
success &= stageQualifier.layoutLocation == programQualifier.layoutLocation;
success &= stageQualifier.layoutBinding == programQualifier.layoutBinding;
success &= stageQualifier.layoutSet == programQualifier.layoutSet;
}
else {
success &= false;
}
}
}
}
// compare uniform blocks in each stage to the program table
{
int totalUniforms = program.getNumUniformBlocks();
std::map<std::string, const glslang::TObjectReflection*> programUniforms;
for (int i = 0; i < totalUniforms; i++) {
const glslang::TObjectReflection& uniform = program.getUniformBlock(i);
std::string name = interfaceName(uniform);
programUniforms[name] = &uniform;
}
it = stageReflections.begin();
for (; it != stageReflections.end(); it++) {
int numUniform = it->getNumUniformBlocks();
std::map<std::string, glslang::TObjectReflection> uniforms;
for (int i = 0; i < numUniform; i++) {
glslang::TObjectReflection uniform = it->getUniformBlock(i);
std::string name = interfaceName(uniform);
auto programUniform = programUniforms.find(name);
if (programUniform != programUniforms.end()) {
auto stageQualifier = uniform.getType()->getQualifier();
auto programQualifier = programUniform->second->getType()->getQualifier();
success &= stageQualifier.layoutLocation == programQualifier.layoutLocation;
success &= stageQualifier.layoutBinding == programQualifier.layoutBinding;
success &= stageQualifier.layoutSet == programQualifier.layoutSet;
}
else {
success &= false;
}
}
}
}
if (!success) {
linkingError += "Mismatched cross-stage IO\n";
}
return success;
}
TEST_P(VulkanRelaxedTest, FromFile)
{
const auto& fileNames = GetParam().fileNames;
const auto& resourceSetBindings = GetParam().resourceSetBindings;
Semantics semantics = Semantics::Vulkan;
const size_t fileCount = fileNames.size();
const EShMessages controls = DeriveOptions(Source::GLSL, semantics, Target::BothASTAndSpv);
GlslangResult result;
// Compile each input shader file.
bool success = true;
std::vector<std::unique_ptr<glslang::TShader>> shaders;
for (size_t i = 0; i < fileCount; ++i) {
std::string contents;
tryLoadFile(GlobalTestSettings.testRoot + "/" + fileNames[i],
"input", &contents);
shaders.emplace_back(
new glslang::TShader(GetShaderStage(GetSuffix(fileNames[i]))));
auto* shader = shaders.back().get();
shader->setAutoMapLocations(true);
shader->setAutoMapBindings(true);
shader->setEnvInput(glslang::EShSourceGlsl, shader->getStage(), glslang::EShClientVulkan, 100);
shader->setEnvClient(glslang::EShClientVulkan, glslang::EShTargetVulkan_1_1);
shader->setEnvTarget(glslang::EShTargetSpv, glslang::EShTargetSpv_1_0);
// Use vulkan relaxed option
shader->setEnvInputVulkanRulesRelaxed();
success &= compile(shader, contents, "", controls);
result.shaderResults.push_back(
{ fileNames[i], shader->getInfoLog(), shader->getInfoDebugLog() });
}
// Link all of them.
glslang::TProgram program;
for (const auto& shader : shaders) program.addShader(shader.get());
success &= program.link(controls);
result.linkingOutput = program.getInfoLog();
result.linkingError = program.getInfoDebugLog();
if (!resourceSetBindings.empty()) {
assert(resourceSetBindings.size() == fileNames.size());
for (size_t i = 0; i < shaders.size(); i++)
shaders[i]->setResourceSetBinding(resourceSetBindings[i]);
}
unsigned int stage = 0;
glslang::TIntermediate* firstIntermediate = nullptr;
while (!program.getIntermediate((EShLanguage)stage) && stage < EShLangCount) { stage++; }
firstIntermediate = program.getIntermediate((EShLanguage)stage);
glslang::TDefaultGlslIoResolver resolver(*firstIntermediate);
glslang::TGlslIoMapper ioMapper;
if (success) {
success &= program.mapIO(&resolver, &ioMapper);
result.linkingOutput = program.getInfoLog();
result.linkingError = program.getInfoDebugLog();
}
success &= verifyIOMapping(result.linkingError, program);
result.validationResult = success;
if (success && (controls & EShMsgSpvRules)) {
for (int stage = 0; stage < EShLangCount; ++stage) {
if (program.getIntermediate((EShLanguage)stage)) {
spv::SpvBuildLogger logger;
std::vector<uint32_t> spirv_binary;
options().disableOptimizer = false;
glslang::GlslangToSpv(*program.getIntermediate((EShLanguage)stage),
spirv_binary, &logger, &options());
std::ostringstream disassembly_stream;
spv::Parameterize();
spv::Disassemble(disassembly_stream, spirv_binary);
result.spirvWarningsErrors += logger.getAllMessages();
result.spirv += disassembly_stream.str();
result.validationResult &= !options().validate || logger.getAllMessages().empty();
}
}
}
std::ostringstream stream;
outputResultToStream(&stream, result, controls);
// Check with expected results.
const std::string expectedOutputFname =
GlobalTestSettings.testRoot + "/baseResults/" + fileNames.front() + ".out";
std::string expectedOutput;
tryLoadFile(expectedOutputFname, "expected output", &expectedOutput);
checkEqAndUpdateIfRequested(expectedOutput, stream.str(), expectedOutputFname,
result.spirvWarningsErrors);
}
// clang-format off
INSTANTIATE_TEST_SUITE_P(
Glsl, VulkanRelaxedTest,
::testing::ValuesIn(std::vector<vkRelaxedData>({
{{"vk.relaxed.frag"}},
{{"vk.relaxed.link1.frag", "vk.relaxed.link2.frag"}},
{{"vk.relaxed.stagelink.0.0.vert", "vk.relaxed.stagelink.0.1.vert", "vk.relaxed.stagelink.0.2.vert", "vk.relaxed.stagelink.0.0.frag", "vk.relaxed.stagelink.0.1.frag", "vk.relaxed.stagelink.0.2.frag"}},
{{"vk.relaxed.stagelink.vert", "vk.relaxed.stagelink.frag"}},
{{"vk.relaxed.errorcheck.vert", "vk.relaxed.errorcheck.frag"}},
{{"vk.relaxed.changeSet.vert", "vk.relaxed.changeSet.frag" }, { {"0"}, {"1"} } },
}))
);
// clang-format on
} // anonymous namespace
} // namespace glslangtest
#endif
-35
View File
@@ -1,35 +0,0 @@
//
// Copyright (C) 2018 The Khronos Group Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
//
// Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
//
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
// contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
//
#include "pch.h"