From: Mikko Rasa Date: Tue, 6 Apr 2021 09:48:44 +0000 (+0300) Subject: Leave no-op constructors as they are X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=fe7996a5985e8e7064004d2f42758d89ebf54b57;p=libs%2Fgl.git Leave no-op constructors as they are In particular, don't break a matrix down into columns and construct it again. These could just be removed from the AST entirely, but the expression resolver currently does not do node replacement and it's easier to just skip this in the backend. --- diff --git a/source/glsl/resolve.cpp b/source/glsl/resolve.cpp index 3201ea1b..2b18c84b 100644 --- a/source/glsl/resolve.cpp +++ b/source/glsl/resolve.cpp @@ -883,6 +883,8 @@ void ExpressionResolver::visit_constructor(FunctionCall &call) map::const_iterator i = stage->types.find(call.name); if(i==stage->types.end()) return; + else if(call.arguments.size()==1 && i->second==call.arguments[0]->type) + ; else if(BasicTypeDeclaration *basic = dynamic_cast(i->second)) { BasicTypeDeclaration *elem = get_element_type(*basic); diff --git a/tests/glsl/no_op_conversion.glsl b/tests/glsl/no_op_conversion.glsl new file mode 100644 index 00000000..2e3ff57b --- /dev/null +++ b/tests/glsl/no_op_conversion.glsl @@ -0,0 +1,17 @@ +uniform mat4 mvp; + +#pragma MSP stage(vertex) +layout(location=0) in vec4 position; +int main() +{ + gl_Position = mat4(mvp)*vec4(position); +} + +/* Expected output: vertex +layout(location=0) uniform mat4 mvp; +layout(location=0) in vec4 position; +int main() +{ + gl_Position = mat4(mvp)*vec4(position); +} +*/