MCPcopy Create free account
hub / github.com/crosire/reshade / merge

Method merge

source/effect_expression.cpp:12–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10#include <algorithm> // std::max, std::min
11
12reshadefx::type reshadefx::type::merge(const type &lhs, const type &rhs)
13{
14 type result;
15 result.base = std::max(lhs.base, rhs.base);
16
17 // Non-numeric types cannot be vectors or matrices
18 if (!result.is_numeric())
19 {
20 result.rows = 0;
21 result.cols = 0;
22 }
23 // If one side of the expression is scalar, it needs to be promoted to the same dimension as the other side
24 else if ((lhs.rows == 1 && lhs.cols == 1) || (rhs.rows == 1 && rhs.cols == 1))
25 {
26 result.rows = std::max(lhs.rows, rhs.rows);
27 result.cols = std::max(lhs.cols, rhs.cols);
28 }
29 else // Otherwise dimensions match or one side is truncated to match the other one
30 {
31 result.rows = std::min(lhs.rows, rhs.rows);
32 result.cols = std::min(lhs.cols, rhs.cols);
33 }
34
35 // Some qualifiers propagate to the result
36 result.qualifiers = (lhs.qualifiers & type::q_precise) | (rhs.qualifiers & type::q_precise);
37
38 // Cannot merge array types, assume no arrays
39 result.array_length = 0;
40 assert(lhs.array_length == 0 && rhs.array_length == 0);
41
42 // In case this is a structure, assume they are the same
43 result.struct_definition = rhs.struct_definition;
44 assert(lhs.struct_definition == rhs.struct_definition || lhs.struct_definition == 0);
45
46 return result;
47}
48
49std::string reshadefx::type::description() const
50{

Callers 3

on_execute_primaryFunction · 0.80
on_execute_secondaryFunction · 0.80
on_presentFunction · 0.80

Calls 1

is_numericMethod · 0.80

Tested by

no test coverage detected