From a93a69e53263005709fa172845b01f81cd1c074c Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 15 Feb 2021 13:25:37 +0200 Subject: [PATCH] Refactor handling of texture sampling functions in LegacyConverter This structure allows to check support for sampler types which don't have legacy variants for the texture function. --- source/glsl/compatibility.cpp | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/source/glsl/compatibility.cpp b/source/glsl/compatibility.cpp index 4e43ae9d..a3b2882d 100644 --- a/source/glsl/compatibility.cpp +++ b/source/glsl/compatibility.cpp @@ -145,47 +145,54 @@ bool LegacyConverter::supports_unified_sampling_functions() const void LegacyConverter::visit(FunctionCall &call) { - if(call.name=="texture" && !call.declaration && !supports_unified_sampling_functions()) + if(call.name=="texture") { + string sampler_type; + type = string(); NodeArray::iterator i = call.arguments.begin(); if(i!=call.arguments.end()) { (*i)->visit(*this); - if(type=="sampler1D") + sampler_type = type; + + for(; i!=call.arguments.end(); ++i) + (*i)->visit(*this); + } + + if(!supports_unified_sampling_functions()) + { + if(sampler_type=="sampler1D") call.name = "texture1D"; - else if(type=="sampler2D") + else if(sampler_type=="sampler2D") call.name = "texture2D"; - else if(type=="sampler3D") + else if(sampler_type=="sampler3D") call.name = "texture3D"; - else if(type=="samplerCube") + else if(sampler_type=="samplerCube") call.name = "textureCube"; - else if(type=="sampler1DShadow") + else if(sampler_type=="sampler1DShadow") call.name = "shadow1D"; - else if(type=="sampler2DShadow") + else if(sampler_type=="sampler2DShadow") call.name = "shadow2D"; - else if(type=="sampler1DArray") + else if(sampler_type=="sampler1DArray") { check_extension(EXT_texture_array); call.name = "texture1DArray"; } - else if(type=="sampler2DArray") + else if(sampler_type=="sampler2DArray") { check_extension(EXT_texture_array); call.name = "texture2DArray"; } - else if(type=="sampler1DArrayShadow") + else if(sampler_type=="sampler1DArrayShadow") { check_extension(EXT_texture_array); call.name = "shadow1DArray"; } - else if(type=="sampler2DArrayShadow") + else if(sampler_type=="sampler2DArrayShadow") { check_extension(EXT_texture_array); call.name = "shadow2DArray"; } - - for(; i!=call.arguments.end(); ++i) - (*i)->visit(*this); } } else -- 2.45.2