From 891ec09c62bb570c5c4d125221dd437d13940f9d Mon Sep 17 00:00:00 2001 From: Chow Date: Wed, 25 Dec 2019 17:08:48 +0800 Subject: [PATCH] Modify atomic_uint binding check Modify atomic_uint binding check. Currently, when not declared with offset, default atomic_unint won't check whether its binding is valid or not more than its limit value. --- Test/450.comp | 3 +++ Test/baseResults/450.comp.out | 13 +++++++------ glslang/MachineIndependent/ParseHelper.cpp | 8 +++++--- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Test/450.comp b/Test/450.comp index fb2b56a7..316674dd 100644 --- a/Test/450.comp +++ b/Test/450.comp @@ -1,5 +1,8 @@ #version 450 core layout(local_size_x = 0) in; // ERROR, 0 not allowed + +layout(binding=10000) uniform atomic_uint; // ERROR + void main() { shared float f; // ERROR shared must be global diff --git a/Test/baseResults/450.comp.out b/Test/baseResults/450.comp.out index 4ae77cca..ce95f8db 100644 --- a/Test/baseResults/450.comp.out +++ b/Test/baseResults/450.comp.out @@ -1,14 +1,15 @@ 450.comp ERROR: 0:2: 'local_size_x' : must be at least 1 -ERROR: 0:5: 'shared' : not allowed in nested scope -ERROR: 2 compilation errors. No code generated. +ERROR: 0:4: 'binding' : atomic_uint binding is too large +ERROR: 0:8: 'shared' : not allowed in nested scope +ERROR: 3 compilation errors. No code generated. Shader version: 450 local_size = (1, 1, 1) ERROR: node is still EOpNull! -0:3 Function Definition: main( ( global void) -0:3 Function Parameters: +0:6 Function Definition: main( ( global void) +0:6 Function Parameters: 0:? Linker Objects @@ -18,7 +19,7 @@ Linked compute stage: Shader version: 450 local_size = (1, 1, 1) ERROR: node is still EOpNull! -0:3 Function Definition: main( ( global void) -0:3 Function Parameters: +0:6 Function Definition: main( ( global void) +0:6 Function Parameters: 0:? Linker Objects diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index 9c46d57c..d7a85100 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -6380,13 +6380,15 @@ const TFunction* TParseContext::findFunctionExplicitTypes(const TSourceLoc& loc, void TParseContext::declareTypeDefaults(const TSourceLoc& loc, const TPublicType& publicType) { #ifndef GLSLANG_WEB - if (publicType.basicType == EbtAtomicUint && publicType.qualifier.hasBinding() && - publicType.qualifier.hasOffset()) { + if (publicType.basicType == EbtAtomicUint && publicType.qualifier.hasBinding()) { if (publicType.qualifier.layoutBinding >= (unsigned int)resources.maxAtomicCounterBindings) { error(loc, "atomic_uint binding is too large", "binding", ""); return; } - atomicUintOffsets[publicType.qualifier.layoutBinding] = publicType.qualifier.layoutOffset; + + if(publicType.qualifier.hasOffset()) { + atomicUintOffsets[publicType.qualifier.layoutBinding] = publicType.qualifier.layoutOffset; + } return; }