From: Mikko Rasa Date: Wed, 4 Jan 2023 22:10:19 +0000 (+0200) Subject: Adjustments due to changes in Variant X-Git-Url: https://git.tdb.fi/?a=commitdiff_plain;h=3ab3401371eb4a3135f2e913886395557d4d61c3;p=libs%2Fgl.git Adjustments due to changes in Variant Retrieving an object from a collection now requires its type to be fully defined. --- diff --git a/demos/desertpillars/source/desertpillars.cpp b/demos/desertpillars/source/desertpillars.cpp index bfb25f30..7c285185 100644 --- a/demos/desertpillars/source/desertpillars.cpp +++ b/demos/desertpillars/source/desertpillars.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include diff --git a/demos/forestpond/source/forestpond.cpp b/demos/forestpond/source/forestpond.cpp index bbe1f7b0..613189e0 100644 --- a/demos/forestpond/source/forestpond.cpp +++ b/demos/forestpond/source/forestpond.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "forestpond.h" using namespace std; diff --git a/demos/forestpond/source/water.cpp b/demos/forestpond/source/water.cpp index 85ee4fd7..816b33a3 100644 --- a/demos/forestpond/source/water.cpp +++ b/demos/forestpond/source/water.cpp @@ -1,7 +1,9 @@ #include #include #include +#include #include +#include #include #include "water.h" diff --git a/source/builders/sequencetemplate.h b/source/builders/sequencetemplate.h index 34e4924b..5c45a900 100644 --- a/source/builders/sequencetemplate.h +++ b/source/builders/sequencetemplate.h @@ -6,6 +6,7 @@ #include #include #include +#include "color.h" #include "depthtest.h" #include "effect.h" #include "postprocessor.h" diff --git a/source/effects/ambientocclusion.cpp b/source/effects/ambientocclusion.cpp index 287dacf1..780f0515 100644 --- a/source/effects/ambientocclusion.cpp +++ b/source/effects/ambientocclusion.cpp @@ -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; diff --git a/source/effects/bloom.cpp b/source/effects/bloom.cpp index fba608e7..2aec1838 100644 --- a/source/effects/bloom.cpp +++ b/source/effects/bloom.cpp @@ -2,8 +2,10 @@ #include #include "bloom.h" #include "mesh.h" +#include "program.h" #include "renderer.h" #include "resources.h" +#include "sampler.h" #include "texture2d.h" using namespace std; diff --git a/source/effects/colorcurve.cpp b/source/effects/colorcurve.cpp index ffc5497a..2865743b 100644 --- a/source/effects/colorcurve.cpp +++ b/source/effects/colorcurve.cpp @@ -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; diff --git a/source/effects/environmentmap.cpp b/source/effects/environmentmap.cpp index c0bfc8a2..c9bfb0d0 100644 --- a/source/effects/environmentmap.cpp +++ b/source/effects/environmentmap.cpp @@ -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; diff --git a/source/effects/shadowmap.cpp b/source/effects/shadowmap.cpp index d3bd358e..0c345d4e 100644 --- a/source/effects/shadowmap.cpp +++ b/source/effects/shadowmap.cpp @@ -5,6 +5,7 @@ #include "pointlight.h" #include "renderer.h" #include "resources.h" +#include "sampler.h" #include "shadowmap.h" using namespace std; diff --git a/source/effects/sky.cpp b/source/effects/sky.cpp index 42c22686..94ca90fe 100644 --- a/source/effects/sky.cpp +++ b/source/effects/sky.cpp @@ -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" diff --git a/source/glsl/generate.cpp b/source/glsl/generate.cpp index 635d9f15..a6758fbd 100644 --- a/source/glsl/generate.cpp +++ b/source/glsl/generate.cpp @@ -444,7 +444,7 @@ void ArraySizer::visit(BinaryExpression &binary) { if(binary.oper->token[0]=='[') if(const Literal *literal_index = dynamic_cast(binary.right.get())) - if(literal_index->value.check_type()) + if(literal_index->value.has_type()) { r_declaration = 0; binary.left->visit(*this); diff --git a/source/glsl/optimize.cpp b/source/glsl/optimize.cpp index a35e2cd2..bb5ba6ce 100644 --- a/source/glsl/optimize.cpp +++ b/source/glsl/optimize.cpp @@ -649,7 +649,7 @@ void AggregateDismantler::visit(BinaryExpression &binary) unsigned index = 0x3F; if(Literal *literal_subscript = dynamic_cast(binary.right.get())) - if(literal_subscript->value.check_type()) + if(literal_subscript->value.has_type()) index = literal_subscript->value.value(); 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(var.array_size.get())) { - if(literal_size->value.check_type()) + if(literal_size->value.has_type()) { Aggregate &aggre = aggregates[&var]; aggre.declaration = &var; @@ -782,13 +782,13 @@ T ConstantFolder::evaluate_int_special_op(char oper, T left, T right) template void ConstantFolder::convert_to_result(const Variant &value) { - if(value.check_type()) + if(value.has_type()) set_result(static_cast(value.value())); - else if(value.check_type()) + else if(value.has_type()) set_result(static_cast(value.value())); - else if(value.check_type()) + else if(value.has_type()) set_result(static_cast(value.value())); - else if(value.check_type()) + else if(value.has_type()) set_result(static_cast(value.value())); } @@ -813,13 +813,13 @@ void ConstantFolder::visit(RefPtr &expr) return; RefPtr literal = new Literal; - if(r_constant_value.check_type()) + if(r_constant_value.has_type()) literal->token = (r_constant_value.value() ? "true" : "false"); - else if(r_constant_value.check_type()) + else if(r_constant_value.has_type()) literal->token = lexical_cast(r_constant_value.value()); - else if(r_constant_value.check_type()) + else if(r_constant_value.has_type()) literal->token = lexical_cast(r_constant_value.value())+"u"; - else if(r_constant_value.check_type()) + else if(r_constant_value.has_type()) { literal->token = lexical_cast(r_constant_value.value(), 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()) + if(r_constant_value.has_type()) set_result(!r_constant_value.value()); } else if(oper=='~') { - if(r_constant_value.check_type()) + if(r_constant_value.has_type()) set_result(~r_constant_value.value()); - else if(r_constant_value.check_type()) + else if(r_constant_value.has_type()) set_result(~r_constant_value.value()); } else if(oper=='-' && !oper2) { - if(r_constant_value.check_type()) + if(r_constant_value.has_type()) set_result(-r_constant_value.value()); - else if(r_constant_value.check_type()) + else if(r_constant_value.has_type()) set_result(-r_constant_value.value()); - else if(r_constant_value.check_type()) + else if(r_constant_value.has_type()) set_result(-r_constant_value.value()); } } @@ -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()) + if(oper2==oper && left_value.has_type()) set_result(evaluate_logical(oper, left_value.value(), r_constant_value.value())); - else if(!oper2 && left_value.check_type()) + else if(!oper2 && left_value.has_type()) set_result(evaluate_logical(oper, left_value.value(), r_constant_value.value())); - else if(!oper2 && left_value.check_type()) + else if(!oper2 && left_value.has_type()) set_result(evaluate_logical(oper, left_value.value(), r_constant_value.value())); } else if((oper=='<' || oper=='>') && oper2!=oper) { - if(left_value.check_type()) + if(left_value.has_type()) set_result(evaluate_relation(binary.oper->token, left_value.value(), r_constant_value.value())); - else if(left_value.check_type()) + else if(left_value.has_type()) set_result(evaluate_relation(binary.oper->token, left_value.value(), r_constant_value.value())); - else if(left_value.check_type()) + else if(left_value.has_type()) set_result(evaluate_relation(binary.oper->token, left_value.value(), r_constant_value.value())); } else if((oper=='=' || oper=='!') && oper2=='=') { - if(left_value.check_type()) + if(left_value.has_type()) set_result((left_value.value()==r_constant_value.value()) == (oper=='=')); - else if(left_value.check_type()) + else if(left_value.has_type()) set_result((left_value.value()==r_constant_value.value()) == (oper=='=')); - else if(left_value.check_type()) + else if(left_value.has_type()) set_result((left_value.value()==r_constant_value.value()) == (oper=='=')); } else if(oper=='+' || oper=='-' || oper=='*' || oper=='/') { - if(left_value.check_type()) + if(left_value.has_type()) set_result(evaluate_arithmetic(oper, left_value.value(), r_constant_value.value())); - else if(left_value.check_type()) + else if(left_value.has_type()) set_result(evaluate_arithmetic(oper, left_value.value(), r_constant_value.value())); - else if(left_value.check_type()) + else if(left_value.has_type()) set_result(evaluate_arithmetic(oper, left_value.value(), r_constant_value.value())); } else if(oper=='%' || ((oper=='<' || oper=='>') && oper2==oper)) { - if(left_value.check_type()) + if(left_value.has_type()) set_result(evaluate_int_special_op(oper, left_value.value(), r_constant_value.value())); - else if(left_value.check_type()) + else if(left_value.has_type()) set_result(evaluate_int_special_op(oper, left_value.value(), r_constant_value.value())); } } @@ -1039,7 +1039,7 @@ void ConstantFolder::visit(Iteration &iter) if(iter.condition) { visit(iter.condition); - if(r_constant && r_constant_value.check_type() && !r_constant_value.value()) + if(r_constant && r_constant_value.has_type() && !r_constant_value.value()) { RefPtr 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(&expr)) - if(literal->value.check_type()) + if(literal->value.has_type()) return (literal->value.value() ? CONSTANT_TRUE : CONSTANT_FALSE); return NOT_CONSTANT; } diff --git a/source/glsl/reflect.cpp b/source/glsl/reflect.cpp index becc833e..818ccc97 100644 --- a/source/glsl/reflect.cpp +++ b/source/glsl/reflect.cpp @@ -96,7 +96,7 @@ void TypeComparer::visit(Literal &literal) { compare(*lit1->type, *literal.type); if(r_result) - r_result = (literal.value.check_type() && lit1->value.value()==literal.value.value()); + r_result = (literal.value.has_type() && lit1->value.value()==literal.value.value()); } } } @@ -280,7 +280,7 @@ void LocationCounter::visit(VariableDeclaration &var) var.type_declaration->visit(*this); if(var.array) if(const Literal *literal = dynamic_cast(var.array_size.get())) - if(literal->value.check_type()) + if(literal->value.has_type()) r_count *= literal->value.value(); } @@ -345,7 +345,7 @@ void MemoryRequirementsCalculator::visit(VariableDeclaration &var) var.type_declaration->visit(*this); if(var.array) if(const Literal *literal = dynamic_cast(var.array_size.get())) - if(literal->value.check_type()) + if(literal->value.has_type()) { unsigned aligned_size = r_size+r_alignment-1; aligned_size -= aligned_size%r_alignment; diff --git a/source/glsl/resolve.cpp b/source/glsl/resolve.cpp index 1d165b7e..ffcec7b9 100644 --- a/source/glsl/resolve.cpp +++ b/source/glsl/resolve.cpp @@ -364,7 +364,7 @@ void VariableResolver::visit(BinaryExpression &binary) { unsigned index = 0x3F; if(Literal *literal_subscript = dynamic_cast(binary.right.get())) - if(literal_subscript->value.check_type()) + if(literal_subscript->value.has_type()) index = literal_subscript->value.value(); 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()) + if(literal.value.has_type()) resolve(literal, find_type(BasicTypeDeclaration::BOOL, 1), false); - else if(literal.value.check_type()) + else if(literal.value.has_type()) resolve(literal, find_type(BasicTypeDeclaration::INT, 32, true), false); - else if(literal.value.check_type()) + else if(literal.value.has_type()) resolve(literal, find_type(BasicTypeDeclaration::INT, 32, false), false); - else if(literal.value.check_type()) + else if(literal.value.has_type()) resolve(literal, find_type(BasicTypeDeclaration::FLOAT, 32), false); } diff --git a/source/glsl/spirv.cpp b/source/glsl/spirv.cpp index 4dceb971..b0855feb 100644 --- a/source/glsl/spirv.cpp +++ b/source/glsl/spirv.cpp @@ -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()) + if(value.has_type()) return ConstantKey(type_id, value.value()); - else if(value.check_type()) + else if(value.has_type()) return ConstantKey(type_id, value.value()); - else if(value.check_type()) + else if(value.has_type()) return ConstantKey(type_id, value.value()); - else if(value.check_type()) + else if(value.has_type()) return ConstantKey(type_id, value.value()); else throw invalid_argument("SpirVGenerator::get_constant_key"); diff --git a/source/materials/material.cpp b/source/materials/material.cpp index 62d3b3ba..8e565c53 100644 --- a/source/materials/material.cpp +++ b/source/materials/material.cpp @@ -4,6 +4,7 @@ #include "pbrmaterial.h" #include "program.h" #include "resources.h" +#include "sampler.h" #include "splatmaterial.h" #include "unlitmaterial.h" diff --git a/source/materials/pbrmaterial.cpp b/source/materials/pbrmaterial.cpp index 4a5f0a41..41da18b5 100644 --- a/source/materials/pbrmaterial.cpp +++ b/source/materials/pbrmaterial.cpp @@ -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; diff --git a/source/materials/rendermethod.cpp b/source/materials/rendermethod.cpp index 86136fb5..9e9a477e 100644 --- a/source/materials/rendermethod.cpp +++ b/source/materials/rendermethod.cpp @@ -6,6 +6,7 @@ #include "program.h" #include "programdata.h" #include "renderer.h" +#include "sampler.h" #include "texture.h" #include "texture2d.h" diff --git a/source/materials/splatmaterial.cpp b/source/materials/splatmaterial.cpp index a7050e64..3a051147 100644 --- a/source/materials/splatmaterial.cpp +++ b/source/materials/splatmaterial.cpp @@ -2,6 +2,7 @@ #include #include "pbrmaterial.h" #include "resources.h" +#include "sampler.h" #include "splatmaterial.h" #include "texture2d.h" #include "texture2darray.h"