]> git.tdb.fi Git - libs/gl.git/commitdiff
Adjustments due to changes in Variant
authorMikko Rasa <tdb@tdb.fi>
Wed, 4 Jan 2023 22:10:19 +0000 (00:10 +0200)
committerMikko Rasa <tdb@tdb.fi>
Thu, 5 Jan 2023 09:34:20 +0000 (11:34 +0200)
Retrieving an object from a collection now requires its type to be fully
defined.

19 files changed:
demos/desertpillars/source/desertpillars.cpp
demos/forestpond/source/forestpond.cpp
demos/forestpond/source/water.cpp
source/builders/sequencetemplate.h
source/effects/ambientocclusion.cpp
source/effects/bloom.cpp
source/effects/colorcurve.cpp
source/effects/environmentmap.cpp
source/effects/shadowmap.cpp
source/effects/sky.cpp
source/glsl/generate.cpp
source/glsl/optimize.cpp
source/glsl/reflect.cpp
source/glsl/resolve.cpp
source/glsl/spirv.cpp
source/materials/material.cpp
source/materials/pbrmaterial.cpp
source/materials/rendermethod.cpp
source/materials/splatmaterial.cpp

index bfb25f30c6b5c3564dee3746955ace47ddf8bf51..7c285185649aaeeed4e49c3a3b64dee3b1fc00e2 100644 (file)
@@ -2,6 +2,7 @@
 #include <msp/gl/directionallight.h>
 #include <msp/gl/lighting.h>
 #include <msp/gl/sequencebuilder.h>
+#include <msp/gl/sequencetemplate.h>
 #include <msp/gl/pointlight.h>
 #include <msp/gl/renderer.h>
 #include <msp/input/keys.h>
index bbe1f7b062c4b6ea07908698cff9114bf9bbb082..613189e07c0c484dbf52d6a300752e5f2bc05929 100644 (file)
@@ -1,5 +1,6 @@
 #include <msp/fs/dir.h>
 #include <msp/gl/sequencebuilder.h>
+#include <msp/gl/sequencetemplate.h>
 #include "forestpond.h"
 
 using namespace std;
index 85ee4fd7fe7187ed99bd1ba3a3e38ffcb664371f..816b33a3739dbc6fc34670ec9e8edcad628da5f2 100644 (file)
@@ -1,7 +1,9 @@
 #include <msp/gl/camera.h>
 #include <msp/gl/framebuffer.h>
 #include <msp/gl/mesh.h>
+#include <msp/gl/program.h>
 #include <msp/gl/renderer.h>
+#include <msp/gl/sampler.h>
 #include <msp/strings/format.h>
 #include "water.h"
 
index 34e4924befc521902d5f5827af46b88b2c032946..5c45a9005c5c661d2edf367725a31166818f6234 100644 (file)
@@ -6,6 +6,7 @@
 #include <msp/core/typeregistry.h>
 #include <msp/datafile/dynamicobjectloader.h>
 #include <msp/datafile/objectloader.h>
+#include "color.h"
 #include "depthtest.h"
 #include "effect.h"
 #include "postprocessor.h"
index 287dacf13f8dbb65e99e7ee14766887d08458f81..780f0515bfd9c0df961c9451b7fcd2f838b31a4e 100644 (file)
@@ -3,8 +3,10 @@
 #include "blend.h"
 #include "camera.h"
 #include "mesh.h"
+#include "program.h"
 #include "renderer.h"
 #include "resources.h"
+#include "sampler.h"
 #include "texture2d.h"
 
 using namespace std;
index fba608e7f7c20f2f870cafb3853867b04d2d94a2..2aec1838fcd3d1391a0f56baae8295b803459655 100644 (file)
@@ -2,8 +2,10 @@
 #include <msp/strings/format.h>
 #include "bloom.h"
 #include "mesh.h"
+#include "program.h"
 #include "renderer.h"
 #include "resources.h"
+#include "sampler.h"
 #include "texture2d.h"
 
 using namespace std;
index ffc5497a2f4ad52a2f0f2edd77ca879b4cc60652..2865743b4bb4d404c4d7181456eb95bc73407e6e 100644 (file)
@@ -2,8 +2,10 @@
 #include "color.h"
 #include "colorcurve.h"
 #include "mesh.h"
+#include "program.h"
 #include "renderer.h"
 #include "resources.h"
+#include "sampler.h"
 #include "texture2d.h"
 
 using namespace std;
index c0bfc8a22c271a8901aae43d0bc70c2843bae3c5..c9bfb0d0bf772451d43dd320b41b014d510e0deb 100644 (file)
@@ -5,8 +5,10 @@
 #include "environmentmap.h"
 #include "error.h"
 #include "mesh.h"
+#include "program.h"
 #include "renderer.h"
 #include "resources.h"
+#include "sampler.h"
 
 using namespace std;
 
index d3bd358ebb75ace528f9d6bd4e871ff10c71de0b..0c345d4e5497ab98d53c63c344d09efc168490ea 100644 (file)
@@ -5,6 +5,7 @@
 #include "pointlight.h"
 #include "renderer.h"
 #include "resources.h"
+#include "sampler.h"
 #include "shadowmap.h"
 
 using namespace std;
index 42c22686905044385ea5cfe090c4e8e5377b3873..94ca90fe006aa16c04982f0aa96b8a82fdcf3554 100644 (file)
@@ -3,8 +3,10 @@
 #include "directionallight.h"
 #include "error.h"
 #include "mesh.h"
+#include "program.h"
 #include "renderer.h"
 #include "resources.h"
+#include "sampler.h"
 #include "texture2d.h"
 #include "sky.h"
 
index 635d9f15dcec1b6720a13df6285d83a6e329c3aa..a6758fbd9cd58a5c3f0c72e596a1bc7d835a91ef 100644 (file)
@@ -444,7 +444,7 @@ void ArraySizer::visit(BinaryExpression &binary)
 {
        if(binary.oper->token[0]=='[')
                if(const Literal *literal_index = dynamic_cast<const Literal *>(binary.right.get()))
-                       if(literal_index->value.check_type<int>())
+                       if(literal_index->value.has_type<int>())
                        {
                                r_declaration = 0;
                                binary.left->visit(*this);
index a35e2cd244941cb125b5e3450734ba2e88254b37..bb5ba6ce8a025ea09c8c059d87236a4d336b186d 100644 (file)
@@ -649,7 +649,7 @@ void AggregateDismantler::visit(BinaryExpression &binary)
 
                unsigned index = 0x3F;
                if(Literal *literal_subscript = dynamic_cast<Literal *>(binary.right.get()))
-                       if(literal_subscript->value.check_type<int>())
+                       if(literal_subscript->value.has_type<int>())
                                index = literal_subscript->value.value<int>();
                add_to_chain(r_reference, Assignment::Target::ARRAY, index);
 
@@ -703,7 +703,7 @@ void AggregateDismantler::visit(VariableDeclaration &var)
                }
                else if(const Literal *literal_size = dynamic_cast<const Literal *>(var.array_size.get()))
                {
-                       if(literal_size->value.check_type<int>())
+                       if(literal_size->value.has_type<int>())
                        {
                                Aggregate &aggre = aggregates[&var];
                                aggre.declaration = &var;
@@ -782,13 +782,13 @@ T ConstantFolder::evaluate_int_special_op(char oper, T left, T right)
 template<typename T>
 void ConstantFolder::convert_to_result(const Variant &value)
 {
-       if(value.check_type<bool>())
+       if(value.has_type<bool>())
                set_result(static_cast<T>(value.value<bool>()));
-       else if(value.check_type<int>())
+       else if(value.has_type<int>())
                set_result(static_cast<T>(value.value<int>()));
-       else if(value.check_type<unsigned>())
+       else if(value.has_type<unsigned>())
                set_result(static_cast<T>(value.value<unsigned>()));
-       else if(value.check_type<float>())
+       else if(value.has_type<float>())
                set_result(static_cast<T>(value.value<float>()));
 }
 
@@ -813,13 +813,13 @@ void ConstantFolder::visit(RefPtr<Expression> &expr)
                return;
 
        RefPtr<Literal> literal = new Literal;
-       if(r_constant_value.check_type<bool>())
+       if(r_constant_value.has_type<bool>())
                literal->token = (r_constant_value.value<bool>() ? "true" : "false");
-       else if(r_constant_value.check_type<int>())
+       else if(r_constant_value.has_type<int>())
                literal->token = lexical_cast<string>(r_constant_value.value<int>());
-       else if(r_constant_value.check_type<unsigned>())
+       else if(r_constant_value.has_type<unsigned>())
                literal->token = lexical_cast<string>(r_constant_value.value<unsigned>())+"u";
-       else if(r_constant_value.check_type<float>())
+       else if(r_constant_value.has_type<float>())
        {
                literal->token = lexical_cast<string>(r_constant_value.value<float>(), Fmt().precision(8));
                if(literal->token.find('.')==string::npos && literal->token.find('e')==string::npos)
@@ -876,23 +876,23 @@ void ConstantFolder::visit(UnaryExpression &unary)
        char oper2 = unary.oper->token[1];
        if(oper=='!')
        {
-               if(r_constant_value.check_type<bool>())
+               if(r_constant_value.has_type<bool>())
                        set_result(!r_constant_value.value<bool>());
        }
        else if(oper=='~')
        {
-               if(r_constant_value.check_type<int>())
+               if(r_constant_value.has_type<int>())
                        set_result(~r_constant_value.value<int>());
-               else if(r_constant_value.check_type<unsigned>())
+               else if(r_constant_value.has_type<unsigned>())
                        set_result(~r_constant_value.value<unsigned>());
        }
        else if(oper=='-' && !oper2)
        {
-               if(r_constant_value.check_type<int>())
+               if(r_constant_value.has_type<int>())
                        set_result(-r_constant_value.value<int>());
-               else if(r_constant_value.check_type<unsigned>())
+               else if(r_constant_value.has_type<unsigned>())
                        set_result(-r_constant_value.value<unsigned>());
-               else if(r_constant_value.check_type<float>())
+               else if(r_constant_value.has_type<float>())
                        set_result(-r_constant_value.value<float>());
        }
 }
@@ -913,52 +913,52 @@ void ConstantFolder::visit(BinaryExpression &binary)
                return;
 
        // Currently only expressions with both sides of equal types are handled.
-       if(!left_value.check_same_type(r_constant_value))
+       if(!left_value.has_same_type(r_constant_value))
                return;
 
        char oper = binary.oper->token[0];
        char oper2 = binary.oper->token[1];
        if(oper=='&' || oper=='|' || oper=='^')
        {
-               if(oper2==oper && left_value.check_type<bool>())
+               if(oper2==oper && left_value.has_type<bool>())
                        set_result(evaluate_logical(oper, left_value.value<bool>(), r_constant_value.value<bool>()));
-               else if(!oper2 && left_value.check_type<int>())
+               else if(!oper2 && left_value.has_type<int>())
                        set_result(evaluate_logical(oper, left_value.value<int>(), r_constant_value.value<int>()));
-               else if(!oper2 && left_value.check_type<unsigned>())
+               else if(!oper2 && left_value.has_type<unsigned>())
                        set_result(evaluate_logical(oper, left_value.value<unsigned>(), r_constant_value.value<unsigned>()));
        }
        else if((oper=='<' || oper=='>') && oper2!=oper)
        {
-               if(left_value.check_type<int>())
+               if(left_value.has_type<int>())
                        set_result(evaluate_relation(binary.oper->token, left_value.value<int>(), r_constant_value.value<int>()));
-               else if(left_value.check_type<unsigned>())
+               else if(left_value.has_type<unsigned>())
                        set_result(evaluate_relation(binary.oper->token, left_value.value<unsigned>(), r_constant_value.value<unsigned>()));
-               else if(left_value.check_type<float>())
+               else if(left_value.has_type<float>())
                        set_result(evaluate_relation(binary.oper->token, left_value.value<float>(), r_constant_value.value<float>()));
        }
        else if((oper=='=' || oper=='!') && oper2=='=')
        {
-               if(left_value.check_type<int>())
+               if(left_value.has_type<int>())
                        set_result((left_value.value<int>()==r_constant_value.value<int>()) == (oper=='='));
-               else if(left_value.check_type<unsigned>())
+               else if(left_value.has_type<unsigned>())
                        set_result((left_value.value<unsigned>()==r_constant_value.value<unsigned>()) == (oper=='='));
-               else if(left_value.check_type<float>())
+               else if(left_value.has_type<float>())
                        set_result((left_value.value<float>()==r_constant_value.value<float>()) == (oper=='='));
        }
        else if(oper=='+' || oper=='-' || oper=='*' || oper=='/')
        {
-               if(left_value.check_type<int>())
+               if(left_value.has_type<int>())
                        set_result(evaluate_arithmetic(oper, left_value.value<int>(), r_constant_value.value<int>()));
-               else if(left_value.check_type<unsigned>())
+               else if(left_value.has_type<unsigned>())
                        set_result(evaluate_arithmetic(oper, left_value.value<unsigned>(), r_constant_value.value<unsigned>()));
-               else if(left_value.check_type<float>())
+               else if(left_value.has_type<float>())
                        set_result(evaluate_arithmetic(oper, left_value.value<float>(), r_constant_value.value<float>()));
        }
        else if(oper=='%' || ((oper=='<' || oper=='>') && oper2==oper))
        {
-               if(left_value.check_type<int>())
+               if(left_value.has_type<int>())
                        set_result(evaluate_int_special_op(oper, left_value.value<int>(), r_constant_value.value<int>()));
-               else if(left_value.check_type<unsigned>())
+               else if(left_value.has_type<unsigned>())
                        set_result(evaluate_int_special_op(oper, left_value.value<unsigned>(), r_constant_value.value<unsigned>()));
        }
 }
@@ -1039,7 +1039,7 @@ void ConstantFolder::visit(Iteration &iter)
        if(iter.condition)
        {
                visit(iter.condition);
-               if(r_constant && r_constant_value.check_type<bool>() && !r_constant_value.value<bool>())
+               if(r_constant && r_constant_value.has_type<bool>() && !r_constant_value.value<bool>())
                {
                        RefPtr<Literal> literal = new Literal;
                        literal->token = "false";
@@ -1065,7 +1065,7 @@ bool ConstantConditionEliminator::apply(Stage &stage)
 ConstantConditionEliminator::ConstantStatus ConstantConditionEliminator::check_constant_condition(const Expression &expr)
 {
        if(const Literal *literal = dynamic_cast<const Literal *>(&expr))
-               if(literal->value.check_type<bool>())
+               if(literal->value.has_type<bool>())
                        return (literal->value.value<bool>() ? CONSTANT_TRUE : CONSTANT_FALSE);
        return NOT_CONSTANT;
 }
index becc833e28ef7da9c9bbcd5fc5ad6e6fe7d81ce6..818ccc97c316fd1743a521a6ec6a8f6fbb74bace 100644 (file)
@@ -96,7 +96,7 @@ void TypeComparer::visit(Literal &literal)
                {
                        compare(*lit1->type, *literal.type);
                        if(r_result)
-                               r_result = (literal.value.check_type<int>() && lit1->value.value<int>()==literal.value.value<int>());
+                               r_result = (literal.value.has_type<int>() && lit1->value.value<int>()==literal.value.value<int>());
                }
        }
 }
@@ -280,7 +280,7 @@ void LocationCounter::visit(VariableDeclaration &var)
                var.type_declaration->visit(*this);
        if(var.array)
                if(const Literal *literal = dynamic_cast<const Literal *>(var.array_size.get()))
-                       if(literal->value.check_type<int>())
+                       if(literal->value.has_type<int>())
                                r_count *= literal->value.value<int>();
 }
 
@@ -345,7 +345,7 @@ void MemoryRequirementsCalculator::visit(VariableDeclaration &var)
                var.type_declaration->visit(*this);
        if(var.array)
                if(const Literal *literal = dynamic_cast<const Literal *>(var.array_size.get()))
-                       if(literal->value.check_type<int>())
+                       if(literal->value.has_type<int>())
                        {
                                unsigned aligned_size = r_size+r_alignment-1;
                                aligned_size -= aligned_size%r_alignment;
index 1d165b7e119178a46ea5011ec4e426b21a7c64f5..ffcec7b9fad5e44a08ce6ab33801096f8b255101 100644 (file)
@@ -364,7 +364,7 @@ void VariableResolver::visit(BinaryExpression &binary)
                {
                        unsigned index = 0x3F;
                        if(Literal *literal_subscript = dynamic_cast<Literal *>(binary.right.get()))
-                               if(literal_subscript->value.check_type<int>())
+                               if(literal_subscript->value.has_type<int>())
                                        index = literal_subscript->value.value<int>();
                        add_to_chain(r_assignment_target, Assignment::Target::ARRAY, index);
                }
@@ -612,13 +612,13 @@ void ExpressionResolver::visit(Block &block)
 
 void ExpressionResolver::visit(Literal &literal)
 {
-       if(literal.value.check_type<bool>())
+       if(literal.value.has_type<bool>())
                resolve(literal, find_type(BasicTypeDeclaration::BOOL, 1), false);
-       else if(literal.value.check_type<int>())
+       else if(literal.value.has_type<int>())
                resolve(literal, find_type(BasicTypeDeclaration::INT, 32, true), false);
-       else if(literal.value.check_type<unsigned>())
+       else if(literal.value.has_type<unsigned>())
                resolve(literal, find_type(BasicTypeDeclaration::INT, 32, false), false);
-       else if(literal.value.check_type<float>())
+       else if(literal.value.has_type<float>())
                resolve(literal, find_type(BasicTypeDeclaration::FLOAT, 32), false);
 }
 
index 4dceb9719a638c8ba6048b1a3509eb5b8555046c..b0855feb63ac121123422987b91b47dd57d64af9 100644 (file)
@@ -341,13 +341,13 @@ SpirVGenerator::Id SpirVGenerator::write_constant(Id type_id, Word value, bool s
 
 SpirVGenerator::ConstantKey SpirVGenerator::get_constant_key(Id type_id, const Variant &value)
 {
-       if(value.check_type<bool>())
+       if(value.has_type<bool>())
                return ConstantKey(type_id, value.value<bool>());
-       else if(value.check_type<int>())
+       else if(value.has_type<int>())
                return ConstantKey(type_id, value.value<int>());
-       else if(value.check_type<unsigned>())
+       else if(value.has_type<unsigned>())
                return ConstantKey(type_id, value.value<unsigned>());
-       else if(value.check_type<float>())
+       else if(value.has_type<float>())
                return ConstantKey(type_id, value.value<float>());
        else
                throw invalid_argument("SpirVGenerator::get_constant_key");
index 62d3b3ba7e76cd08ff22ff9a691267cd94ac6d12..8e565c53698784e39fa96da71ed7854740c19ef4 100644 (file)
@@ -4,6 +4,7 @@
 #include "pbrmaterial.h"
 #include "program.h"
 #include "resources.h"
+#include "sampler.h"
 #include "splatmaterial.h"
 #include "unlitmaterial.h"
 
index 4a5f0a419d370ef1bc935bdf15fc3ff0cd0929d5..41da18b5992c87845d0e31236d85d6e7842db745 100644 (file)
@@ -1,8 +1,10 @@
 #include "framebuffer.h"
 #include "mesh.h"
 #include "pbrmaterial.h"
+#include "program.h"
 #include "renderer.h"
 #include "resources.h"
+#include "sampler.h"
 #include "texture2d.h"
 
 using namespace std;
index 86136fb5561ddb4c0d25f0baf330103498f00fce..9e9a477eb91e2ee82a22a44a314538afb27c398a 100644 (file)
@@ -6,6 +6,7 @@
 #include "program.h"
 #include "programdata.h"
 #include "renderer.h"
+#include "sampler.h"
 #include "texture.h"
 #include "texture2d.h"
 
index a7050e64df3df8d7eb1965db5e1a1da694111349..3a051147e74bfd354302e0ac9efb286cb88673b6 100644 (file)
@@ -2,6 +2,7 @@
 #include <msp/strings/format.h>
 #include "pbrmaterial.h"
 #include "resources.h"
+#include "sampler.h"
 #include "splatmaterial.h"
 #include "texture2d.h"
 #include "texture2darray.h"