Support Uint to Int implicit conversions at #extension GL_ARB_gpu_shader5.

Signed-off-by: ZhiqianXia <xzq0528@outlook.com>
This commit is contained in:
ZhiqianXia 2021-07-19 17:24:28 +08:00
parent 9158061398
commit 8cd85272ad
5 changed files with 75 additions and 1 deletions

View File

@ -0,0 +1,11 @@
#version 150
#extension GL_ARB_gpu_shader5 : require
uniform int u1;
uniform int u2;
out vec4 result;
void main()
{
uint v = 0;
v = uint(u2) - u1; // implicit conversions
}

View File

@ -0,0 +1,57 @@
GL_ARB_gpu_shader5.u2i.vert
WARNING: 0:2: '#extension' : extension is only partially supported: GL_ARB_gpu_shader5
Shader version: 150
Requested GL_ARB_gpu_shader5
0:? Sequence
0:7 Function Definition: main( ( global void)
0:7 Function Parameters:
0:9 Sequence
0:9 Sequence
0:9 move second child to first child ( temp uint)
0:9 'v' ( temp uint)
0:9 Constant:
0:9 0 (const uint)
0:10 move second child to first child ( temp uint)
0:10 'v' ( temp uint)
0:10 subtract ( temp uint)
0:10 Convert int to uint ( temp uint)
0:10 'u2' ( uniform int)
0:10 Convert int to uint ( temp uint)
0:10 'u1' ( uniform int)
0:? Linker Objects
0:? 'u1' ( uniform int)
0:? 'u2' ( uniform int)
0:? 'result' ( smooth out 4-component vector of float)
0:? 'gl_VertexID' ( gl_VertexId int VertexId)
0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId)
Linked vertex stage:
Shader version: 150
Requested GL_ARB_gpu_shader5
0:? Sequence
0:7 Function Definition: main( ( global void)
0:7 Function Parameters:
0:9 Sequence
0:9 Sequence
0:9 move second child to first child ( temp uint)
0:9 'v' ( temp uint)
0:9 Constant:
0:9 0 (const uint)
0:10 move second child to first child ( temp uint)
0:10 'v' ( temp uint)
0:10 subtract ( temp uint)
0:10 Convert int to uint ( temp uint)
0:10 'u2' ( uniform int)
0:10 Convert int to uint ( temp uint)
0:10 'u1' ( uniform int)
0:? Linker Objects
0:? 'u1' ( uniform int)
0:? 'u2' ( uniform int)
0:? 'result' ( smooth out 4-component vector of float)
0:? 'gl_VertexID' ( gl_VertexId int VertexId)
0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId)

View File

@ -1739,7 +1739,7 @@ bool TIntermediate::canImplicitlyPromote(TBasicType from, TBasicType to, TOperat
case EbtUint:
switch (from) {
case EbtInt:
return version >= 400 || getSource() == EShSourceHlsl;
return version >= 400 || getSource() == EShSourceHlsl || IsRequestedExtension(E_GL_ARB_gpu_shader5);
case EbtBool:
return getSource() == EShSourceHlsl;
case EbtInt16:

View File

@ -926,6 +926,11 @@ public:
return false;
}
bool IsRequestedExtension(const char* extension) const
{
return (requestedExtensions.find(extension) != requestedExtensions.end());
}
void addToCallGraph(TInfoSink&, const TString& caller, const TString& callee);
void merge(TInfoSink&, TIntermediate&);
void finalCheck(TInfoSink&, bool keepUncalled);

View File

@ -282,6 +282,7 @@ INSTANTIATE_TEST_SUITE_P(
"terminate.vert",
"negativeWorkGroupSize.comp",
"textureoffset_sampler2darrayshadow.vert",
"GL_ARB_gpu_shader5.u2i.vert",
})),
FileNameAsCustomTestSuffix
);