Merge pull request #1291 from ben-clayton/add-nv-nopersp

Add support for GL_NV_shader_noperspective_interpolation
This commit is contained in:
John Kessenich 2018-03-16 15:50:38 -06:00 committed by GitHub
commit cd23a47566
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 1196 additions and 1074 deletions

View File

@ -1,7 +1,7 @@
300.frag
ERROR: 0:2: 'float' : type requires declaration of default precision qualifier
ERROR: 0:30: 'noperspective' : Reserved word.
ERROR: 0:30: 'noperspective' : not supported with this profile: es
ERROR: 0:30: 'noperspective' : not supported for this version or the enabled extensions
ERROR: 0:31: 'sampler2D' : sampler/image types can only be used in uniform variables or function parameters: bads
ERROR: 0:32: 'uint' : cannot apply precision statement to this type; use 'float', 'int' or a sampler type
ERROR: 0:39: 'structure' : must be qualified as flat in

View File

@ -105,7 +105,7 @@ ERROR: 0:346: 'centroid/sample/patch' : can't use auxiliary qualifier on a fragm
ERROR: 0:347: 'flat/smooth/noperspective' : can't use interpolation qualifier on a fragment output
ERROR: 0:348: 'flat/smooth/noperspective' : can't use interpolation qualifier on a fragment output
ERROR: 0:349: 'noperspective' : Reserved word.
ERROR: 0:349: 'noperspective' : not supported with this profile: es
ERROR: 0:349: 'noperspective' : not supported for this version or the enabled extensions
ERROR: 0:349: 'flat/smooth/noperspective' : can't use interpolation qualifier on a fragment output
ERROR: 0:355: 'interpolateAtCentroid' : required extension not requested: GL_OES_shader_multisample_interpolation
ERROR: 0:356: 'interpolateAtSample' : required extension not requested: GL_OES_shader_multisample_interpolation

View File

@ -21,7 +21,7 @@ ERROR: 0:48: 'assign' : l-value required (can't modify a const)
ERROR: 0:51: 'patch' : cannot use interpolation qualifiers with patch
ERROR: 0:52: 'patch' : cannot use interpolation qualifiers with patch
ERROR: 0:53: 'noperspective' : Reserved word.
ERROR: 0:53: 'noperspective' : not supported with this profile: es
ERROR: 0:53: 'noperspective' : not supported for this version or the enabled extensions
ERROR: 0:53: 'patch' : cannot use interpolation qualifiers with patch
ERROR: 0:54: 'sample' : Reserved word.
ERROR: 0:54: '' : can only have one auxiliary qualifier (centroid, patch, and sample)

View File

@ -23,7 +23,7 @@ ERROR: 0:157: 'centroid/sample/patch' : can't use auxiliary qualifier on a fragm
ERROR: 0:158: 'flat/smooth/noperspective' : can't use interpolation qualifier on a fragment output
ERROR: 0:159: 'flat/smooth/noperspective' : can't use interpolation qualifier on a fragment output
ERROR: 0:160: 'noperspective' : Reserved word.
ERROR: 0:160: 'noperspective' : not supported with this profile: es
ERROR: 0:160: 'noperspective' : not supported for this version or the enabled extensions
ERROR: 0:160: 'flat/smooth/noperspective' : can't use interpolation qualifier on a fragment output
ERROR: 0:165: 'centroid/sample/patch' : can't use auxiliary qualifier on a fragment output
ERROR: 0:180: 'interpolateAtCentroid' : no matching overloaded function found

View File

@ -21,7 +21,7 @@ ERROR: 0:44: 'assign' : l-value required (can't modify a const)
ERROR: 0:47: 'patch' : cannot use interpolation qualifiers with patch
ERROR: 0:48: 'patch' : cannot use interpolation qualifiers with patch
ERROR: 0:49: 'noperspective' : Reserved word.
ERROR: 0:49: 'noperspective' : not supported with this profile: es
ERROR: 0:49: 'noperspective' : not supported for this version or the enabled extensions
ERROR: 0:49: 'patch' : cannot use interpolation qualifiers with patch
ERROR: 0:50: '' : can only have one auxiliary qualifier (centroid, patch, and sample)
ERROR: 0:54: 'gl_PerVertex' : block already declared with size, can't redeclare as implicitly-sized

View File

@ -0,0 +1,38 @@
nvShaderNoperspectiveInterpolation.frag
ERROR: 0:5: 'noperspective' : Reserved word.
ERROR: 0:5: 'noperspective' : not supported for this version or the enabled extensions
ERROR: 2 compilation errors. No code generated.
Shader version: 300
Requested GL_NV_shader_noperspective_interpolation
ERROR: node is still EOpNull!
0:13 Function Definition: main( ( global void)
0:13 Function Parameters:
0:14 Sequence
0:14 move second child to first child ( temp mediump 4-component vector of float)
0:14 'fragColor' ( out mediump 4-component vector of float)
0:14 'color' ( noperspective in mediump 4-component vector of float)
0:? Linker Objects
0:? 'bad' ( noperspective in mediump 4-component vector of float)
0:? 'color' ( noperspective in mediump 4-component vector of float)
0:? 'fragColor' ( out mediump 4-component vector of float)
Linked fragment stage:
Shader version: 300
Requested GL_NV_shader_noperspective_interpolation
ERROR: node is still EOpNull!
0:13 Function Definition: main( ( global void)
0:13 Function Parameters:
0:14 Sequence
0:14 move second child to first child ( temp mediump 4-component vector of float)
0:14 'fragColor' ( out mediump 4-component vector of float)
0:14 'color' ( noperspective in mediump 4-component vector of float)
0:? Linker Objects
0:? 'bad' ( noperspective in mediump 4-component vector of float)
0:? 'color' ( noperspective in mediump 4-component vector of float)
0:? 'fragColor' ( out mediump 4-component vector of float)

View File

@ -0,0 +1,15 @@
#version 300 es
precision mediump float;
noperspective in vec4 bad; // ERROR
#extension GL_NV_shader_noperspective_interpolation : enable
noperspective in vec4 color;
out vec4 fragColor;
void main() {
fragColor = color;
}

View File

@ -962,7 +962,7 @@ int TScanContext::tokenizeIdentifier()
case PATCH:
if (parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.profile == EEsProfile &&
(parseContext.version >= 320 ||
(parseContext.version >= 320 ||
parseContext.extensionsTurnedOn(Num_AEP_tessellation_shader, AEP_tessellation_shader))) ||
(parseContext.profile != EEsProfile && parseContext.extensionTurnedOn(E_GL_ARB_tessellation_shader)))
return keyword;
@ -1450,6 +1450,11 @@ int TScanContext::tokenizeIdentifier()
#endif
case NOPERSPECTIVE:
#ifdef NV_EXTENSIONS
if (parseContext.profile == EEsProfile && parseContext.version >= 300 &&
parseContext.extensionTurnedOn(E_GL_NV_shader_noperspective_interpolation))
return keyword;
#endif
return es30ReservedFromGLSL(130);
case SMOOTH:

View File

@ -225,6 +225,7 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_NVX_multiview_per_view_attributes] = EBhDisable;
extensionBehavior[E_GL_NV_shader_atomic_int64] = EBhDisable;
extensionBehavior[E_GL_NV_conservative_raster_underestimation] = EBhDisable;
extensionBehavior[E_GL_NV_shader_noperspective_interpolation] = EBhDisable;
#endif
// AEP
@ -319,6 +320,13 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_OES_texture_cube_map_array 1\n"
"#define GL_EXT_shader_non_constant_global_initializers 1\n"
;
#ifdef NV_EXTENSIONS
if (profile == EEsProfile && version >= 300) {
preamble += "#define GL_NV_shader_noperspective_interpolation 1\n";
}
#endif
} else {
preamble =
"#define GL_FRAGMENT_PRECISION_HIGH 1\n"

View File

@ -196,6 +196,7 @@ const char* const E_GL_NV_stereo_view_rendering = "GL_NV_stereo_
const char* const E_GL_NVX_multiview_per_view_attributes = "GL_NVX_multiview_per_view_attributes";
const char* const E_GL_NV_shader_atomic_int64 = "GL_NV_shader_atomic_int64";
const char* const E_GL_NV_conservative_raster_underestimation = "GL_NV_conservative_raster_underestimation";
const char* const E_GL_NV_shader_noperspective_interpolation = "GL_NV_shader_noperspective_interpolation";
// Arrays of extensions for the above viewportEXTs duplications

View File

@ -1117,7 +1117,11 @@ interpolation_qualifier
}
| NOPERSPECTIVE {
parseContext.globalCheck($1.loc, "noperspective");
#ifdef NV_EXTENSIONS
parseContext.profileRequires($1.loc, EEsProfile, 0, E_GL_NV_shader_noperspective_interpolation, "noperspective");
#else
parseContext.requireProfile($1.loc, ~EEsProfile, "noperspective");
#endif
parseContext.profileRequires($1.loc, ENoProfile, 130, 0, "noperspective");
$$.init($1.loc);
$$.qualifier.nopersp = true;

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
/* A Bison parser, made by GNU Bison 3.0. */
/* A Bison parser, made by GNU Bison 3.0.4. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -437,7 +437,7 @@ extern int yydebug;
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE YYSTYPE;
union YYSTYPE
{
#line 70 "MachineIndependent/glslang.y" /* yacc.c:1909 */
@ -477,6 +477,8 @@ union YYSTYPE
#line 479 "MachineIndependent/glslang_tab.cpp.h" /* yacc.c:1909 */
};
typedef union YYSTYPE YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define YYSTYPE_IS_DECLARED 1
#endif

View File

@ -41,6 +41,10 @@ namespace {
using CompileToAstTest = GlslangTest<::testing::TestWithParam<std::string>>;
#ifdef NV_EXTENSIONS
using CompileToAstTestNV = GlslangTest<::testing::TestWithParam<std::string>>;
#endif
TEST_P(CompileToAstTest, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
@ -48,6 +52,16 @@ TEST_P(CompileToAstTest, FromFile)
Target::AST);
}
#ifdef NV_EXTENSIONS
// Compiling GLSL to SPIR-V under OpenGL semantics (NV extensions enabled).
TEST_P(CompileToAstTestNV, FromFile)
{
loadFileCompileAndCheck(GlobalTestSettings.testRoot, GetParam(),
Source::GLSL, Semantics::OpenGL, glslang::EShTargetVulkan_1_0,
Target::AST);
}
#endif
// clang-format off
INSTANTIATE_TEST_CASE_P(
Glsl, CompileToAstTest,
@ -214,6 +228,16 @@ INSTANTIATE_TEST_CASE_P(
})),
FileNameAsCustomTestSuffix
);
#ifdef NV_EXTENSIONS
INSTANTIATE_TEST_CASE_P(
Glsl, CompileToAstTestNV,
::testing::ValuesIn(std::vector<std::string>({
"nvShaderNoperspectiveInterpolation.frag",
})),
FileNameAsCustomTestSuffix
);
#endif
// clang-format on
} // anonymous namespace

View File

@ -171,7 +171,7 @@ TEST_P(CompileVulkanToSpirvTestAMD, FromFile)
#endif
#ifdef NV_EXTENSIONS
// Compiling GLSL to SPIR-V under Vulkan semantics (AMD extensions enabled).
// Compiling GLSL to SPIR-V under Vulkan semantics (NV extensions enabled).
// Expected to successfully generate SPIR-V.
TEST_P(CompileVulkanToSpirvTestNV, FromFile)
{