|
|
@ -2,14 +2,21 @@
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <memory>
|
|
|
|
#include <variant>
|
|
|
|
#include <variant>
|
|
|
|
|
|
|
|
|
|
|
|
#include "video_core/shader/expr.h"
|
|
|
|
#include "video_core/shader/expr.h"
|
|
|
|
|
|
|
|
|
|
|
|
namespace VideoCommon::Shader {
|
|
|
|
namespace VideoCommon::Shader {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
bool ExprIsBoolean(const Expr& expr) {
|
|
|
|
|
|
|
|
return std::holds_alternative<ExprBoolean>(*expr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ExprBooleanGet(const Expr& expr) {
|
|
|
|
|
|
|
|
return std::get_if<ExprBoolean>(expr.get())->value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} // Anonymous namespace
|
|
|
|
|
|
|
|
|
|
|
|
bool ExprAnd::operator==(const ExprAnd& b) const {
|
|
|
|
bool ExprAnd::operator==(const ExprAnd& b) const {
|
|
|
|
return (*operand1 == *b.operand1) && (*operand2 == *b.operand2);
|
|
|
|
return (*operand1 == *b.operand1) && (*operand2 == *b.operand2);
|
|
|
@ -23,19 +30,11 @@ bool ExprNot::operator==(const ExprNot& b) const {
|
|
|
|
return (*operand1 == *b.operand1);
|
|
|
|
return (*operand1 == *b.operand1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool ExprIsBoolean(Expr expr) {
|
|
|
|
|
|
|
|
return std::holds_alternative<ExprBoolean>(*expr);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ExprBooleanGet(Expr expr) {
|
|
|
|
|
|
|
|
return std::get_if<ExprBoolean>(expr.get())->value;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Expr MakeExprNot(Expr first) {
|
|
|
|
Expr MakeExprNot(Expr first) {
|
|
|
|
if (std::holds_alternative<ExprNot>(*first)) {
|
|
|
|
if (std::holds_alternative<ExprNot>(*first)) {
|
|
|
|
return std::get_if<ExprNot>(first.get())->operand1;
|
|
|
|
return std::get_if<ExprNot>(first.get())->operand1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return MakeExpr<ExprNot>(first);
|
|
|
|
return MakeExpr<ExprNot>(std::move(first));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Expr MakeExprAnd(Expr first, Expr second) {
|
|
|
|
Expr MakeExprAnd(Expr first, Expr second) {
|
|
|
@ -45,7 +44,7 @@ Expr MakeExprAnd(Expr first, Expr second) {
|
|
|
|
if (ExprIsBoolean(second)) {
|
|
|
|
if (ExprIsBoolean(second)) {
|
|
|
|
return ExprBooleanGet(second) ? first : second;
|
|
|
|
return ExprBooleanGet(second) ? first : second;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return MakeExpr<ExprAnd>(first, second);
|
|
|
|
return MakeExpr<ExprAnd>(std::move(first), std::move(second));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Expr MakeExprOr(Expr first, Expr second) {
|
|
|
|
Expr MakeExprOr(Expr first, Expr second) {
|
|
|
@ -55,14 +54,14 @@ Expr MakeExprOr(Expr first, Expr second) {
|
|
|
|
if (ExprIsBoolean(second)) {
|
|
|
|
if (ExprIsBoolean(second)) {
|
|
|
|
return ExprBooleanGet(second) ? second : first;
|
|
|
|
return ExprBooleanGet(second) ? second : first;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return MakeExpr<ExprOr>(first, second);
|
|
|
|
return MakeExpr<ExprOr>(std::move(first), std::move(second));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool ExprAreEqual(Expr first, Expr second) {
|
|
|
|
bool ExprAreEqual(const Expr& first, const Expr& second) {
|
|
|
|
return (*first) == (*second);
|
|
|
|
return (*first) == (*second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool ExprAreOpposite(Expr first, Expr second) {
|
|
|
|
bool ExprAreOpposite(const Expr& first, const Expr& second) {
|
|
|
|
if (std::holds_alternative<ExprNot>(*first)) {
|
|
|
|
if (std::holds_alternative<ExprNot>(*first)) {
|
|
|
|
return ExprAreEqual(std::get_if<ExprNot>(first.get())->operand1, second);
|
|
|
|
return ExprAreEqual(std::get_if<ExprNot>(first.get())->operand1, second);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -72,7 +71,7 @@ bool ExprAreOpposite(Expr first, Expr second) {
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool ExprIsTrue(Expr first) {
|
|
|
|
bool ExprIsTrue(const Expr& first) {
|
|
|
|
if (ExprIsBoolean(first)) {
|
|
|
|
if (ExprIsBoolean(first)) {
|
|
|
|
return ExprBooleanGet(first);
|
|
|
|
return ExprBooleanGet(first);
|
|
|
|
}
|
|
|
|
}
|
|
|
|