Skip to content

Commit

Permalink
Add support for extension GL_ARB_vertex_attrib_64bit
Browse files Browse the repository at this point in the history
  • Loading branch information
pmistryNV committed Apr 24, 2020
1 parent 7d65f09 commit 1cb1c5f
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 6 deletions.
16 changes: 16 additions & 0 deletions Test/150.vert
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,21 @@ uniform foob {
};
int a[5]; // ERROR, resizing user-block member

in double dvarerr; // Error since extension GL_ARB_vertex_attrib_64bit is not enabled
#extension GL_ARB_vertex_attrib_64bit: enable
in double dvar;
in dvec2 dv2var;
in dvec3 dv3var;
in dvec4 dv4var;
in dmat2 dmat2var;
in dmat3 dmat3var;
in dmat4 dmat4var;
in dmat2x3 dmat23var;
in dmat2x4 dmat24var;
in dmat3x2 dmat32var;
in dmat3x4 dmat34var;
in dmat4x2 dmat42var;
in dmat4x3 dmat43var;

#line 3000
#error line of this error should be 3001
35 changes: 34 additions & 1 deletion Test/baseResults/150.vert.out
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
150.vert
ERROR: 0:26: 'a' : cannot redeclare a user-block member array
ERROR: 0:28: 'double' : Reserved word.
ERROR: 0:28: 'double' : not supported for this version or the enabled extensions
ERROR: 0:28: 'vertex-shader `double` type input' : not supported for this version or the enabled extensions
ERROR: 0:3001: '#error' : line of this error should be 3001
ERROR: 2 compilation errors. No code generated.
ERROR: 5 compilation errors. No code generated.


Shader version: 150
Requested GL_ARB_vertex_attrib_64bit
ERROR: node is still EOpNull!
0:13 Function Definition: main( ( global void)
0:13 Function Parameters:
Expand Down Expand Up @@ -43,6 +47,20 @@ ERROR: node is still EOpNull!
0:? 'iv4' ( in 4-component vector of float)
0:? 'ps' ( uniform float)
0:? 'anon@1' (layout( column_major shared) uniform block{layout( column_major shared) uniform unsized 1-element array of int a})
0:? 'dvarerr' ( in double)
0:? 'dvar' ( in double)
0:? 'dv2var' ( in 2-component vector of double)
0:? 'dv3var' ( in 3-component vector of double)
0:? 'dv4var' ( in 4-component vector of double)
0:? 'dmat2var' ( in 2X2 matrix of double)
0:? 'dmat3var' ( in 3X3 matrix of double)
0:? 'dmat4var' ( in 4X4 matrix of double)
0:? 'dmat23var' ( in 2X3 matrix of double)
0:? 'dmat24var' ( in 2X4 matrix of double)
0:? 'dmat32var' ( in 3X2 matrix of double)
0:? 'dmat34var' ( in 3X4 matrix of double)
0:? 'dmat42var' ( in 4X2 matrix of double)
0:? 'dmat43var' ( in 4X3 matrix of double)
0:? 'gl_VertexID' ( gl_VertexId int VertexId)
0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId)

Expand All @@ -52,6 +70,7 @@ Linked vertex stage:
ERROR: Linking vertex stage: Can only use one of gl_ClipDistance or gl_ClipVertex (gl_ClipDistance is preferred)

Shader version: 150
Requested GL_ARB_vertex_attrib_64bit
ERROR: node is still EOpNull!
0:13 Function Definition: main( ( global void)
0:13 Function Parameters:
Expand Down Expand Up @@ -90,6 +109,20 @@ ERROR: node is still EOpNull!
0:? 'iv4' ( in 4-component vector of float)
0:? 'ps' ( uniform float)
0:? 'anon@1' (layout( column_major shared) uniform block{layout( column_major shared) uniform 1-element array of int a})
0:? 'dvarerr' ( in double)
0:? 'dvar' ( in double)
0:? 'dv2var' ( in 2-component vector of double)
0:? 'dv3var' ( in 3-component vector of double)
0:? 'dv4var' ( in 4-component vector of double)
0:? 'dmat2var' ( in 2X2 matrix of double)
0:? 'dmat3var' ( in 3X3 matrix of double)
0:? 'dmat4var' ( in 4X4 matrix of double)
0:? 'dmat23var' ( in 2X3 matrix of double)
0:? 'dmat24var' ( in 2X4 matrix of double)
0:? 'dmat32var' ( in 3X2 matrix of double)
0:? 'dmat34var' ( in 3X4 matrix of double)
0:? 'dmat42var' ( in 4X2 matrix of double)
0:? 'dmat43var' ( in 4X3 matrix of double)
0:? 'gl_VertexID' ( gl_VertexId int VertexId)
0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId)

7 changes: 6 additions & 1 deletion glslang/MachineIndependent/ParseHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3354,6 +3354,11 @@ void TParseContext::globalQualifierTypeCheck(const TSourceLoc& loc, const TQuali
!qualifier.hasBufferReference())
error(loc, "buffers can be declared only as blocks", "buffer", "");

if (qualifier.storage != EvqVaryingIn && publicType.basicType == EbtDouble &&
extensionTurnedOn(E_GL_ARB_vertex_attrib_64bit) && language == EShLangVertex &&
version < 400) {
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 410, E_GL_ARB_gpu_shader_fp64, "vertex-shader `double` type");
}
if (qualifier.storage != EvqVaryingIn && qualifier.storage != EvqVaryingOut)
return;

Expand Down Expand Up @@ -3404,7 +3409,7 @@ void TParseContext::globalQualifierTypeCheck(const TSourceLoc& loc, const TQuali
profileRequires(loc, ENoProfile, 150, nullptr, "vertex input arrays");
}
if (publicType.basicType == EbtDouble)
profileRequires(loc, ~EEsProfile, 410, nullptr, "vertex-shader `double` type input");
profileRequires(loc, ~EEsProfile, 410, E_GL_ARB_vertex_attrib_64bit, "vertex-shader `double` type input");
if (qualifier.isAuxiliary() || qualifier.isInterpolation() || qualifier.isMemory() || qualifier.invariant)
error(loc, "vertex input cannot be further qualified", "", "");
break;
Expand Down
8 changes: 5 additions & 3 deletions glslang/MachineIndependent/Scan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1196,8 +1196,8 @@ int TScanContext::tokenizeIdentifier()
afterType = true;
if (parseContext.isEsProfile() || parseContext.version < 150 ||
(!parseContext.symbolTable.atBuiltInLevel() &&
parseContext.version < 400 &&
!parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_fp64)))
(parseContext.version < 400 && !parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_fp64) &&
(parseContext.version < 410 && !parseContext.extensionTurnedOn(E_GL_ARB_vertex_attrib_64bit)))))
reservedWord();
return keyword;

Expand Down Expand Up @@ -1774,7 +1774,9 @@ int TScanContext::dMat()

if (!parseContext.isEsProfile() && (parseContext.version >= 400 ||
parseContext.symbolTable.atBuiltInLevel() ||
(parseContext.version >= 150 && parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_fp64))))
(parseContext.version >= 150 && parseContext.extensionTurnedOn(E_GL_ARB_gpu_shader_fp64)) ||
(parseContext.version >= 150 && parseContext.extensionTurnedOn(E_GL_ARB_vertex_attrib_64bit)
&& parseContext.language == EShLangVertex)))
return keyword;

if (parseContext.isForwardCompatible())
Expand Down
9 changes: 8 additions & 1 deletion glslang/MachineIndependent/Versions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_ARB_shader_bit_encoding] = EBhDisable;
extensionBehavior[E_GL_ARB_shader_image_size] = EBhDisable;
extensionBehavior[E_GL_ARB_shader_storage_buffer_object] = EBhDisable;
extensionBehavior[E_GL_ARB_vertex_attrib_64bit] = EBhDisable;

extensionBehavior[E_GL_KHR_shader_subgroup_basic] = EBhDisable;
extensionBehavior[E_GL_KHR_shader_subgroup_vote] = EBhDisable;
Expand Down Expand Up @@ -415,6 +416,7 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_ARB_uniform_buffer_object 1\n"
"#define GL_ARB_shader_bit_encoding 1\n"
"#define GL_ARB_shader_storage_buffer_object 1\n"
"#define GL_ARB_vertex_attrib_64bit 1\n"
"#define GL_EXT_shader_non_constant_global_initializers 1\n"
"#define GL_EXT_shader_image_load_formatted 1\n"
"#define GL_EXT_post_depth_coverage 1\n"
Expand Down Expand Up @@ -942,8 +944,13 @@ void TParseVersions::fullIntegerCheck(const TSourceLoc& loc, const char* op)
// Call for any operation needing GLSL double data-type support.
void TParseVersions::doubleCheck(const TSourceLoc& loc, const char* op)
{

//requireProfile(loc, ECoreProfile | ECompatibilityProfile, op);
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 400, E_GL_ARB_gpu_shader_fp64, op);
if (language == EShLangVertex) {
const char* const f64_Extensions[] = {E_GL_ARB_gpu_shader_fp64, E_GL_ARB_vertex_attrib_64bit};
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 400, 2, f64_Extensions, op);
} else
profileRequires(loc, ECoreProfile | ECompatibilityProfile, 400, E_GL_ARB_gpu_shader_fp64, op);
}

// Call for any operation needing GLSL float16 data-type support.
Expand Down
1 change: 1 addition & 0 deletions glslang/MachineIndependent/Versions.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ const char* const E_GL_ARB_sample_shading = "GL_ARB_sample_shading
const char* const E_GL_ARB_shader_bit_encoding = "GL_ARB_shader_bit_encoding";
const char* const E_GL_ARB_shader_image_size = "GL_ARB_shader_image_size";
const char* const E_GL_ARB_shader_storage_buffer_object = "GL_ARB_shader_storage_buffer_object";
const char* const E_GL_ARB_vertex_attrib_64bit = "GL_ARB_vertex_attrib_64bit";

const char* const E_GL_KHR_shader_subgroup_basic = "GL_KHR_shader_subgroup_basic";
const char* const E_GL_KHR_shader_subgroup_vote = "GL_KHR_shader_subgroup_vote";
Expand Down

0 comments on commit 1cb1c5f

Please sign in to comment.