mirror of
https://github.com/RPCS3/rsx_program_decompiler.git
synced 2026-01-31 01:25:19 +01:00
Fixed clang compilation errors
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "rsx_decompiler.h"
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
#include <iterator>
|
||||
|
||||
namespace rsx
|
||||
{
|
||||
@@ -50,7 +51,7 @@ namespace rsx
|
||||
switch (program.type)
|
||||
{
|
||||
case program_type::fragment:
|
||||
for (std::size_t index = 0; index < std::size(rsx::fragment_program::input_attrib_map); ++index)
|
||||
for (std::size_t index = 0; index < 16; ++index)
|
||||
{
|
||||
if (program.input_attributes & (1 << index))
|
||||
{
|
||||
@@ -60,7 +61,7 @@ namespace rsx
|
||||
break;
|
||||
|
||||
case program_type::vertex:
|
||||
for (std::size_t index = 0; index < std::size(rsx::vertex_program::input_registers_table); ++index)
|
||||
for (std::size_t index = 0; index < 16; ++index)
|
||||
{
|
||||
if (program.input_attributes & (1 << index))
|
||||
{
|
||||
|
||||
@@ -25,8 +25,8 @@ namespace rsx
|
||||
};
|
||||
|
||||
template<clike_language::type_class_t Type, int Count>
|
||||
static typename base::boolean_expr<Count> single_compare_function(compare_function function,
|
||||
typename base::expression_t<Type, Count> a, typename base::expression_t<Type, Count> b)
|
||||
static typename base::template boolean_expr<Count> single_compare_function(compare_function function,
|
||||
typename base::template expression_t<Type, Count> a, typename base::template expression_t<Type, Count> b)
|
||||
{
|
||||
std::string operator_string;
|
||||
|
||||
@@ -47,8 +47,8 @@ namespace rsx
|
||||
}
|
||||
|
||||
template<clike_language::type_class_t Type, int Count>
|
||||
static typename base::boolean_expr<Count> vector_compare_function(compare_function function,
|
||||
typename base::expression_t<Type, Count> a, typename base::expression_t<Type, Count> b)
|
||||
static typename base::template boolean_expr<Count> vector_compare_function(compare_function function,
|
||||
typename base::template expression_t<Type, Count> a, typename base::template expression_t<Type, Count> b)
|
||||
{
|
||||
switch (function)
|
||||
{
|
||||
@@ -64,8 +64,8 @@ namespace rsx
|
||||
}
|
||||
|
||||
template<clike_language::type_class_t Type, int Count>
|
||||
static typename base::boolean_expr<Count> custom_compare(compare_function function, int channel_count,
|
||||
typename base::expression_t<Type, Count> a, typename base::expression_t<Type, Count> b)
|
||||
static typename base::template boolean_expr<Count> custom_compare(compare_function function, int channel_count,
|
||||
typename base::template expression_t<Type, Count> a, typename base::template expression_t<Type, Count> b)
|
||||
{
|
||||
if (channel_count == 1)
|
||||
{
|
||||
|
||||
@@ -13,16 +13,16 @@ namespace rsx
|
||||
using base = decompiler_base<Language>;
|
||||
|
||||
template<int Count>
|
||||
using boolean_expr = typename base::boolean_expr<Count>;
|
||||
using boolean_expr = typename base::template boolean_expr<Count>;
|
||||
|
||||
template<int Count>
|
||||
using float_point_expr = typename base::float_point_expr<Count>;
|
||||
using float_point_expr = typename base::template float_point_expr<Count>;
|
||||
|
||||
template<int Count>
|
||||
using float_point_t = typename base::float_point_t<Count>;
|
||||
using float_point_t = typename base::template float_point_t<Count>;
|
||||
|
||||
template<int Count>
|
||||
using boolean_t = typename base::boolean_t<Count>;
|
||||
using boolean_t = typename base::template boolean_t<Count>;
|
||||
|
||||
struct context_t
|
||||
{
|
||||
@@ -30,7 +30,7 @@ namespace rsx
|
||||
bool is_next_is_constant;
|
||||
u32 offset;
|
||||
|
||||
typename base::float_point_expr<4> constant()
|
||||
float_point_expr<4> constant()
|
||||
{
|
||||
constant_info info;
|
||||
info.id = offset + sizeof(instruction_t);
|
||||
@@ -41,7 +41,7 @@ namespace rsx
|
||||
return info.name;
|
||||
}
|
||||
|
||||
typename base::float_point_expr<4> temporary(bool is_fp16, int index)
|
||||
float_point_expr<4> temporary(bool is_fp16, int index)
|
||||
{
|
||||
register_info info;
|
||||
info.id = index;
|
||||
@@ -51,7 +51,7 @@ namespace rsx
|
||||
return info.name;
|
||||
}
|
||||
|
||||
typename base::float_point_expr<4> condition(int index)
|
||||
float_point_expr<4> condition(int index)
|
||||
{
|
||||
register_info info;
|
||||
info.id = index;
|
||||
@@ -62,7 +62,7 @@ namespace rsx
|
||||
return info.name;
|
||||
}
|
||||
|
||||
typename base::float_point_expr<4> input(int index)
|
||||
float_point_expr<4> input(int index)
|
||||
{
|
||||
program.input_attributes |= (1 << index);
|
||||
return input_attrib_map[index];
|
||||
@@ -121,7 +121,7 @@ namespace rsx
|
||||
return result;
|
||||
}
|
||||
|
||||
typename base::float_point_expr<4> swizzle_as_dst(typename base::float_point_expr<4> arg) const
|
||||
float_point_expr<4> swizzle_as_dst(float_point_expr<4> arg) const
|
||||
{
|
||||
std::string arg_mask;
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace rsx
|
||||
return float_point_expr<4>(arg.text, arg_mask, arg.is_single, arg.base_count);
|
||||
}
|
||||
|
||||
typename base::float_point_expr<4> src(context_t& context, int index, bool is_swizzle_as_dst = false) const
|
||||
float_point_expr<4> src(context_t& context, int index, bool is_swizzle_as_dst = false) const
|
||||
{
|
||||
src_t src;
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace rsx
|
||||
throw;
|
||||
};
|
||||
|
||||
typename base::float_point_expr<4> result = get_variable(src);
|
||||
float_point_expr<4> result = get_variable(src);
|
||||
|
||||
result.assign(result.swizzle(src.swizzle_x, src.swizzle_y, src.swizzle_z, src.swizzle_w));
|
||||
|
||||
@@ -190,7 +190,7 @@ namespace rsx
|
||||
return swizzle;
|
||||
}
|
||||
|
||||
typename base::float_point_expr<4> destination(context_t& context) const
|
||||
float_point_expr<4> destination(context_t& context) const
|
||||
{
|
||||
if (data.dst.no_dest)
|
||||
{
|
||||
@@ -206,22 +206,22 @@ namespace rsx
|
||||
instruction_t instruction;
|
||||
context_t context;
|
||||
|
||||
typename base::float_point_expr<4> src(int index, bool is_swizzle_as_dst = false)
|
||||
float_point_expr<4> src(int index, bool is_swizzle_as_dst = false)
|
||||
{
|
||||
return instruction.src(context, index, is_swizzle_as_dst);
|
||||
}
|
||||
|
||||
typename base::float_point_expr<4> src_swizzled_as_dst(int index)
|
||||
float_point_expr<4> src_swizzled_as_dst(int index)
|
||||
{
|
||||
return src(index, instruction.data.dst.set_cond || !instruction.data.dst.no_dest);
|
||||
}
|
||||
|
||||
typename base::float_point_expr<4> modify_condition_register()
|
||||
float_point_expr<4> modify_condition_register()
|
||||
{
|
||||
return context.condition(instruction.data.src0.cond_mod_reg_index);
|
||||
}
|
||||
|
||||
typename base::float_point_expr<4> execution_condition_register()
|
||||
float_point_expr<4> execution_condition_register()
|
||||
{
|
||||
std::string swizzle;
|
||||
|
||||
@@ -270,7 +270,7 @@ namespace rsx
|
||||
throw;
|
||||
}
|
||||
|
||||
typename base::boolean_expr<1> execution_condition(condition_operation operation)
|
||||
boolean_expr<1> execution_condition(condition_operation operation)
|
||||
{
|
||||
if (instruction.data.src0.exec_if_gr && instruction.data.src0.exec_if_eq && instruction.data.src0.exec_if_gr)
|
||||
{
|
||||
@@ -302,12 +302,12 @@ namespace rsx
|
||||
throw;
|
||||
}
|
||||
|
||||
typename boolean_expr<4> compare(typename base::compare_function function, float_point_expr<4> a, float_point_expr<4> b)
|
||||
boolean_expr<4> compare(typename base::compare_function function, float_point_expr<4> a, float_point_expr<4> b)
|
||||
{
|
||||
return base::custom_compare(function, (int)instruction.destination_swizzle().size(), a, b);
|
||||
}
|
||||
|
||||
typename base::expression_from<typename base::sampler2D_t> tex()
|
||||
typename base::template expression_from<typename base::sampler2D_t> tex()
|
||||
{
|
||||
return{ "unk_tex" };
|
||||
}
|
||||
@@ -381,7 +381,7 @@ namespace rsx
|
||||
return arg;
|
||||
}
|
||||
|
||||
builder::writer_t set_dst(const typename base::float_point_expr<4>& arg, u32 flags = none)
|
||||
builder::writer_t set_dst(const float_point_expr<4>& arg, u32 flags = none)
|
||||
{
|
||||
builder::writer_t result;
|
||||
|
||||
@@ -427,7 +427,7 @@ namespace rsx
|
||||
}
|
||||
else
|
||||
{
|
||||
static const typename base::float_point_expr<1> zero(0.0f);
|
||||
static const float_point_expr<1> zero(0.0f);
|
||||
|
||||
std::map<char, std::vector<std::pair<int, int>>> condition_map;
|
||||
|
||||
@@ -458,7 +458,7 @@ namespace rsx
|
||||
dst_swizzle += dest.swizzle(channels.second).mask[0];
|
||||
}
|
||||
|
||||
typename base::float_point_expr<4> expression{ src.with_mask(src_swizzle) };
|
||||
float_point_expr<4> expression{ src.with_mask(src_swizzle) };
|
||||
|
||||
if (!instruction.data.dst.no_dest)
|
||||
{
|
||||
@@ -470,7 +470,7 @@ namespace rsx
|
||||
expression.assign(cond.with_mask(dst_swizzle) = expression);
|
||||
}
|
||||
|
||||
result += base::if_(cond.swizzle(channel_to_index.at(entry.first)).call_operator<typename base::boolean_t<1>>(operation, zero), expression);
|
||||
result += base::if_(cond.swizzle(channel_to_index.at(entry.first)).template call_operator<boolean_t<1>>(operation, zero), expression);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -504,7 +504,7 @@ namespace rsx
|
||||
return result;
|
||||
}
|
||||
|
||||
builder::writer_t set_dst(const typename base::float_point_expr<1>& arg, u32 flags = none)
|
||||
builder::writer_t set_dst(const float_point_expr<1>& arg, u32 flags = none)
|
||||
{
|
||||
if (instruction.destination_swizzle().size() != 1)
|
||||
{
|
||||
|
||||
@@ -13,22 +13,22 @@ namespace rsx
|
||||
using base = decompiler_base<Language>;
|
||||
|
||||
template<int Count>
|
||||
using boolean_expr = typename base::boolean_expr<Count>;
|
||||
using boolean_expr = typename base::template boolean_expr<Count>;
|
||||
|
||||
template<int Count>
|
||||
using float_point_expr = typename base::float_point_expr<Count>;
|
||||
using float_point_expr = typename base::template float_point_expr<Count>;
|
||||
|
||||
template<int Count>
|
||||
using integer_expr = typename base::integer_expr<Count>;
|
||||
using integer_expr = typename base::template integer_expr<Count>;
|
||||
|
||||
template<int Count>
|
||||
using float_point_t = typename base::float_point_t<Count>;
|
||||
using float_point_t = typename base::template float_point_t<Count>;
|
||||
|
||||
template<int Count>
|
||||
using boolean_t = typename base::boolean_t<Count>;
|
||||
using boolean_t = typename base::template boolean_t<Count>;
|
||||
|
||||
template<int Count>
|
||||
using integer_t = typename base::integer_t<Count>;
|
||||
using integer_t = typename base::template integer_t<Count>;
|
||||
|
||||
struct context_t
|
||||
{
|
||||
@@ -402,7 +402,7 @@ namespace rsx
|
||||
expression.assign(cond.with_mask(dst_swizzle) = expression);
|
||||
}
|
||||
|
||||
result += base::if_(cond.swizzle(channel_to_index.at(entry.first)).call_operator<boolean_t<1>>(operation, zero), expression);
|
||||
result += base::if_(cond.swizzle(channel_to_index.at(entry.first)).template call_operator<boolean_t<1>>(operation, zero), expression);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -462,7 +462,7 @@ namespace rsx
|
||||
any
|
||||
};
|
||||
|
||||
typename base::compare_function execution_condition_function(u32 condition = instruction.data.d0.cond) const
|
||||
typename base::compare_function execution_condition_function(u32 condition) const
|
||||
{
|
||||
switch (condition)
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace shader_code
|
||||
return invoke();
|
||||
}
|
||||
|
||||
static expression_t<> ctor(typename native_type_t<Type>::type value)
|
||||
static expression_t<> ctor(typename clike_language::native_type_t<Type>::type value)
|
||||
{
|
||||
return invoke(expression_t<Type, 1>(native_type_t<Type>::to_string(value)));
|
||||
}
|
||||
@@ -37,7 +37,7 @@ namespace shader_code
|
||||
|
||||
static constexpr const char* name()
|
||||
{
|
||||
using type_name_t = typename language::type_name_t<Type, Count>;
|
||||
using type_name_t = typename language::template type_name_t<Type, Count>;
|
||||
return type_name_t::name;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace shader_code
|
||||
template<typename... T>
|
||||
static expression_t<> invoke(T... exprs)
|
||||
{
|
||||
return function_t<clike_language::type_t<Type, Count>, typename language::type_name_t<Type, Count>>::invoke(exprs...);
|
||||
return function_t<clike_language::type_t<Type, Count>, typename language::template type_name_t<Type, Count>>::invoke(exprs...);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -65,14 +65,14 @@ namespace shader_code
|
||||
using base::ctor;
|
||||
|
||||
template<clike_language::type_class_t FromType>
|
||||
static typename base::expression_t<> ctor(typename base::expression_t<FromType, 1> expr)
|
||||
static typename base::template expression_t<> ctor(typename base::template expression_t<FromType, 1> expr)
|
||||
{
|
||||
return this->invoke(expr);
|
||||
return base::invoke(expr);
|
||||
}
|
||||
|
||||
static typename base::expression_t<> ctor(typename base::expression_t<Type, 1> a, typename base::expression_t<Type, 1> b)
|
||||
static typename base::template expression_t<> ctor(typename base::template expression_t<Type, 1> a, typename base::template expression_t<Type, 1> b)
|
||||
{
|
||||
return this->invoke(a, b);
|
||||
return base::invoke(a, b);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -83,25 +83,25 @@ namespace shader_code
|
||||
using base::ctor;
|
||||
|
||||
template<clike_language::type_class_t FromType>
|
||||
static typename base::expression_t<> ctor(typename base::expression_t<FromType, 1> expr)
|
||||
static typename base::template expression_t<> ctor(typename base::template expression_t<FromType, 1> expr)
|
||||
{
|
||||
return this->invoke(expr);
|
||||
return base::invoke(expr);
|
||||
}
|
||||
|
||||
static typename base::expression_t<Type, 3> ctor(typename base::expression_t<Type, 1> a, typename base::expression_t<Type, 2> b)
|
||||
static typename base::template expression_t<Type, 3> ctor(typename base::template expression_t<Type, 1> a, typename base::template expression_t<Type, 2> b)
|
||||
{
|
||||
return this->invoke(a, b);
|
||||
return base::invoke(a, b);
|
||||
}
|
||||
|
||||
static typename base::expression_t<Type, 3> ctor(typename base::expression_t<Type, 2> a, typename base::expression_t<Type, 1> b)
|
||||
static typename base::template expression_t<Type, 3> ctor(typename base::template expression_t<Type, 2> a, typename base::template expression_t<Type, 1> b)
|
||||
{
|
||||
return this->invoke(a, b);
|
||||
return base::invoke(a, b);
|
||||
}
|
||||
|
||||
static typename base::expression_t<Type, 3> ctor(typename base::expression_t<Type, 1> a, typename base::expression_t<Type, 1> b,
|
||||
typename base::expression_t<Type, 1> c)
|
||||
static typename base::template expression_t<Type, 3> ctor(typename base::template expression_t<Type, 1> a, typename base::template expression_t<Type, 1> b,
|
||||
typename base::template expression_t<Type, 1> c)
|
||||
{
|
||||
return this->invoke(a, b, c);
|
||||
return base::invoke(a, b, c);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -112,57 +112,57 @@ namespace shader_code
|
||||
using base::ctor;
|
||||
|
||||
template<clike_language::type_class_t FromType>
|
||||
static typename base::expression_t<Type, 4> ctor(typename base::expression_t<FromType, 1> expr)
|
||||
static typename base::template expression_t<Type, 4> ctor(typename base::template expression_t<FromType, 1> expr)
|
||||
{
|
||||
return base::invoke(expr);
|
||||
return base::template invoke(expr);
|
||||
}
|
||||
|
||||
static typename base::expression_t<Type, 4> ctor(typename base::expression_t<Type, 1> a, typename base::expression_t<Type, 3> b)
|
||||
static typename base::template expression_t<Type, 4> ctor(typename base::template expression_t<Type, 1> a, typename base::template expression_t<Type, 3> b)
|
||||
{
|
||||
return base::invoke(a, b);
|
||||
return base::template invoke(a, b);
|
||||
}
|
||||
static typename base::expression_t<Type, 4> ctor(typename base::expression_t<Type, 3> a, typename base::expression_t<Type, 1> b)
|
||||
static typename base::template expression_t<Type, 4> ctor(typename base::template expression_t<Type, 3> a, typename base::template expression_t<Type, 1> b)
|
||||
{
|
||||
return base::invoke(a, b);
|
||||
return base::template invoke(a, b);
|
||||
}
|
||||
static typename base::expression_t<Type, 4> ctor(typename base::expression_t<Type, 2> a, typename base::expression_t<Type, 2> b)
|
||||
static typename base::template expression_t<Type, 4> ctor(typename base::template expression_t<Type, 2> a, typename base::template expression_t<Type, 2> b)
|
||||
{
|
||||
return base::invoke(a, b);
|
||||
return base::template invoke(a, b);
|
||||
}
|
||||
static typename base::expression_t<Type, 4> ctor(typename base::expression_t<Type, 1> a, typename base::expression_t<Type, 1> b,
|
||||
typename base::expression_t<Type, 1> c, typename base::expression_t<Type, 1> d)
|
||||
static typename base::template expression_t<Type, 4> ctor(typename base::template expression_t<Type, 1> a, typename base::template expression_t<Type, 1> b,
|
||||
typename base::template expression_t<Type, 1> c, typename base::template expression_t<Type, 1> d)
|
||||
{
|
||||
return base::invoke(a, b, c, d);
|
||||
return base::template invoke(a, b, c, d);
|
||||
}
|
||||
static typename base::expression_t<Type, 4> ctor(typename base::expression_t<Type, 2> a, typename base::expression_t<Type, 1> b,
|
||||
typename base::expression_t<Type, 1> c)
|
||||
static typename base::template expression_t<Type, 4> ctor(typename base::template expression_t<Type, 2> a, typename base::template expression_t<Type, 1> b,
|
||||
typename base::template expression_t<Type, 1> c)
|
||||
{
|
||||
return base::invoke(a, b, c);
|
||||
return base::template invoke(a, b, c);
|
||||
}
|
||||
static typename base::expression_t<Type, 4> ctor(typename base::expression_t<Type, 1> a, typename base::expression_t<Type, 2> b,
|
||||
typename base::expression_t<Type, 1> c)
|
||||
static typename base::template expression_t<Type, 4> ctor(typename base::template expression_t<Type, 1> a, typename base::template expression_t<Type, 2> b,
|
||||
typename base::template expression_t<Type, 1> c)
|
||||
{
|
||||
return base::invoke(a, b, c);
|
||||
return base::template invoke(a, b, c);
|
||||
}
|
||||
static typename base::expression_t<Type, 4> ctor(typename base::expression_t<Type, 1> a, typename base::expression_t<Type, 1> b,
|
||||
typename base::expression_t<Type, 2> c)
|
||||
static typename base::template expression_t<Type, 4> ctor(typename base::template expression_t<Type, 1> a, typename base::template expression_t<Type, 1> b,
|
||||
typename base::template expression_t<Type, 2> c)
|
||||
{
|
||||
return base::invoke(a, b, c);
|
||||
return base::template invoke(a, b, c);
|
||||
}
|
||||
};
|
||||
|
||||
using sampler1D_t = typename type_t<clike_language::type_class_t::type_sampler1D, 1>;
|
||||
using sampler2D_t = typename type_t<clike_language::type_class_t::type_sampler2D, 1>;
|
||||
using sampler3D_t = typename type_t<clike_language::type_class_t::type_sampler3D, 1>;
|
||||
using sampler1D_t = type_t<clike_language::type_class_t::type_sampler1D, 1>;
|
||||
using sampler2D_t = type_t<clike_language::type_class_t::type_sampler2D, 1>;
|
||||
using sampler3D_t = type_t<clike_language::type_class_t::type_sampler3D, 1>;
|
||||
|
||||
template<size_t Count>
|
||||
using boolean_t = typename type_t<clike_language::type_class_t::type_bool, Count>;
|
||||
using boolean_t = type_t<clike_language::type_class_t::type_bool, Count>;
|
||||
|
||||
template<size_t Count>
|
||||
using integer_t = typename type_t<clike_language::type_class_t::type_int, Count>;
|
||||
using integer_t = type_t<clike_language::type_class_t::type_int, Count>;
|
||||
|
||||
template<size_t Count>
|
||||
using float_point_t = typename type_t<clike_language::type_class_t::type_float, Count>;
|
||||
using float_point_t = type_t<clike_language::type_class_t::type_float, Count>;
|
||||
|
||||
using void_expr = expression_from<void_t>;
|
||||
template<int Count> using float_point_expr = expression_from<float_point_t<Count>>;
|
||||
@@ -171,187 +171,187 @@ namespace shader_code
|
||||
|
||||
static expression_from<float_point_t<4>> texture(const expression_from<sampler1D_t>& texture, const expression_from<float_point_t<1>>& coord)
|
||||
{
|
||||
return function_t<float_point_t<4>, typename language::function_name_t<function_class_t::function_texture>>::invoke(texture, coord);
|
||||
return function_t<float_point_t<4>, typename language::template function_name_t<function_class_t::function_texture>>::invoke(texture, coord);
|
||||
}
|
||||
|
||||
static expression_from<float_point_t<4>> texture(const expression_from<sampler2D_t>& texture, const expression_from<float_point_t<2>>& coord)
|
||||
{
|
||||
return function_t<float_point_t<4>, typename language::function_name_t<function_class_t::function_texture>>::invoke(texture, coord);
|
||||
return function_t<float_point_t<4>, typename language::template function_name_t<function_class_t::function_texture>>::invoke(texture, coord);
|
||||
}
|
||||
|
||||
static expression_from<float_point_t<4>> texture_lod(const expression_from<sampler2D_t>& texture, const expression_from<float_point_t<2>>& coord, const expression_from<float_point_t<1>>& lod)
|
||||
{
|
||||
return function_t<float_point_t<4>, typename language::function_name_t<function_class_t::function_texture_lod>>::invoke(texture, coord, lod);
|
||||
return function_t<float_point_t<4>, typename language::template function_name_t<function_class_t::function_texture_lod>>::invoke(texture, coord, lod);
|
||||
}
|
||||
|
||||
static expression_from<float_point_t<4>> texture_bias(const expression_from<sampler2D_t>& texture, const expression_from<float_point_t<2>>& coord, const expression_from<float_point_t<1>>& bias)
|
||||
{
|
||||
return function_t<float_point_t<4>, typename language::function_name_t<function_class_t::function_texture_bias>>::invoke(texture, coord, bias);
|
||||
return function_t<float_point_t<4>, typename language::template function_name_t<function_class_t::function_texture_bias>>::invoke(texture, coord, bias);
|
||||
}
|
||||
|
||||
static expression_from<float_point_t<4>> texture_grad(const expression_from<sampler2D_t>& texture, const expression_from<float_point_t<2>>& coord, const expression_from<float_point_t<2>>& ddx, const expression_from<float_point_t<2>>& ddy)
|
||||
{
|
||||
return function_t<float_point_t<4>, typename language::function_name_t<function_class_t::function_texture_grad>>::invoke(texture, coord, ddx, ddy);
|
||||
return function_t<float_point_t<4>, typename language::template function_name_t<function_class_t::function_texture_grad>>::invoke(texture, coord, ddx, ddy);
|
||||
}
|
||||
|
||||
static expression_from<float_point_t<4>> texture(const expression_from<sampler3D_t>& texture, const expression_from<float_point_t<3>>& coord)
|
||||
{
|
||||
return function_t<float_point_t<4>, typename language::function_name_t<function_class_t::function_texture>>::invoke(texture, coord);
|
||||
return function_t<float_point_t<4>, typename language::template function_name_t<function_class_t::function_texture>>::invoke(texture, coord);
|
||||
}
|
||||
|
||||
template<int Count>
|
||||
static expression_from<float_point_t<Count>> normalize(const expression_t<clike_language::type_class_t::type_float, Count>& arg)
|
||||
{
|
||||
return function_t<float_point_t<Count>, typename language::function_name_t<function_class_t::function_normalize>>::invoke(arg);
|
||||
return function_t<float_point_t<Count>, typename language::template function_name_t<function_class_t::function_normalize>>::invoke(arg);
|
||||
}
|
||||
|
||||
template<int Count>
|
||||
static expression_from<float_point_t<Count>> abs(const expression_t<clike_language::type_class_t::type_float, Count>& arg)
|
||||
{
|
||||
return function_t<float_point_t<Count>, typename language::function_name_t<function_class_t::function_abs>>::invoke(arg);
|
||||
return function_t<float_point_t<Count>, typename language::template function_name_t<function_class_t::function_abs>>::invoke(arg);
|
||||
}
|
||||
|
||||
template<int Count>
|
||||
static expression_from<integer_t<Count>> abs(const expression_t<clike_language::type_class_t::type_int, Count>& arg)
|
||||
{
|
||||
return function_t<integer_t<Count>, typename language::function_name_t<function_class_t::function_abs>>::invoke(arg);
|
||||
return function_t<integer_t<Count>, typename language::template function_name_t<function_class_t::function_abs>>::invoke(arg);
|
||||
}
|
||||
|
||||
template<int Count>
|
||||
static expression_from<boolean_t<1>> any(const expression_t<clike_language::type_class_t::type_bool, Count>& arg)
|
||||
{
|
||||
return function_t<boolean_t<1>, typename language::function_name_t<function_class_t::function_any>>::invoke(arg);
|
||||
return function_t<boolean_t<1>, typename language::template function_name_t<function_class_t::function_any>>::invoke(arg);
|
||||
}
|
||||
|
||||
template<int Count, typename = std::enable_if_t<(Count > 1)>>
|
||||
static expression_from<boolean_t<1>> all(const expression_t<clike_language::type_class_t::type_bool, Count>& arg)
|
||||
{
|
||||
return function_t<boolean_t<1>, typename language::function_name_t<function_class_t::function_all>>::invoke(arg);
|
||||
return function_t<boolean_t<1>, typename language::template function_name_t<function_class_t::function_all>>::invoke(arg);
|
||||
}
|
||||
|
||||
template<int Count, typename = std::enable_if_t<(Count > 1)>>
|
||||
static expression_from<float_point_t<1>> dot(const expression_t<clike_language::type_class_t::type_float, Count>& a, const expression_t<clike_language::type_class_t::type_float, Count>& b)
|
||||
{
|
||||
return function_t<float_point_t<1>, typename language::function_name_t<function_class_t::function_dot>>::invoke(a, b);
|
||||
return function_t<float_point_t<1>, typename language::template function_name_t<function_class_t::function_dot>>::invoke(a, b);
|
||||
}
|
||||
|
||||
template<clike_language::type_class_t Type, int Count>
|
||||
static expression_t<Type, Count> min(const expression_t<Type, Count>& a, const expression_t<Type, Count>& b)
|
||||
{
|
||||
return function_t<type_t<Type, Count>, typename language::function_name_t<function_class_t::function_min>>::invoke(a, b);
|
||||
return function_t<type_t<Type, Count>, typename language::template function_name_t<function_class_t::function_min>>::invoke(a, b);
|
||||
}
|
||||
|
||||
template<clike_language::type_class_t Type, int Count>
|
||||
static expression_t<Type, Count> max(const expression_t<Type, Count>& a, const expression_t<Type, Count>& b)
|
||||
{
|
||||
return function_t<type_t<Type, Count>, typename language::function_name_t<function_class_t::function_max>>::invoke(a, b);
|
||||
return function_t<type_t<Type, Count>, typename language::template function_name_t<function_class_t::function_max>>::invoke(a, b);
|
||||
}
|
||||
|
||||
template<clike_language::type_class_t Type, int Count>
|
||||
static expression_from<boolean_t<Count>> greater(const expression_t<Type, Count>& a, const expression_t<Type, Count>& b)
|
||||
{
|
||||
return function_t<boolean_t<Count>, typename language::function_name_t<function_class_t::function_greater>>::invoke(a, b);
|
||||
return function_t<boolean_t<Count>, typename language::template function_name_t<function_class_t::function_greater>>::invoke(a, b);
|
||||
}
|
||||
|
||||
template<clike_language::type_class_t Type, int Count>
|
||||
static expression_from<boolean_t<Count>> less(const expression_t<Type, Count>& a, const expression_t<Type, Count>& b)
|
||||
{
|
||||
return function_t<boolean_t<Count>, typename language::function_name_t<function_class_t::function_less>>::invoke(a, b);
|
||||
return function_t<boolean_t<Count>, typename language::template function_name_t<function_class_t::function_less>>::invoke(a, b);
|
||||
}
|
||||
|
||||
template<clike_language::type_class_t Type, int Count>
|
||||
static expression_from<boolean_t<Count>> equal(const expression_t<Type, Count>& a, const expression_t<Type, Count>& b)
|
||||
{
|
||||
return function_t<boolean_t<Count>, typename language::function_name_t<function_class_t::function_equal>>::invoke(a, b);
|
||||
return function_t<boolean_t<Count>, typename language::template function_name_t<function_class_t::function_equal>>::invoke(a, b);
|
||||
}
|
||||
|
||||
template<clike_language::type_class_t Type, int Count>
|
||||
static expression_from<boolean_t<Count>> greater_equal(const expression_t<Type, Count>& a, const expression_t<Type, Count>& b)
|
||||
{
|
||||
return function_t<boolean_t<Count>, typename language::function_name_t<function_class_t::function_greater_equal>>::invoke(a, b);
|
||||
return function_t<boolean_t<Count>, typename language::template function_name_t<function_class_t::function_greater_equal>>::invoke(a, b);
|
||||
}
|
||||
|
||||
template<clike_language::type_class_t Type, int Count>
|
||||
static expression_from<boolean_t<Count>> less_equal(const expression_t<Type, Count>& a, const expression_t<Type, Count>& b)
|
||||
{
|
||||
return function_t<boolean_t<Count>, typename language::function_name_t<function_class_t::function_less_equal>>::invoke(a, b);
|
||||
return function_t<boolean_t<Count>, typename language::template function_name_t<function_class_t::function_less_equal>>::invoke(a, b);
|
||||
}
|
||||
|
||||
template<clike_language::type_class_t Type, int Count>
|
||||
static expression_from<boolean_t<Count>> not_equal(const expression_t<Type, Count>& a, const expression_t<Type, Count>& b)
|
||||
{
|
||||
return function_t<boolean_t<Count>, typename language::function_name_t<function_class_t::function_not_equal>>::invoke(a, b);
|
||||
return function_t<boolean_t<Count>, typename language::template function_name_t<function_class_t::function_not_equal>>::invoke(a, b);
|
||||
}
|
||||
|
||||
template<int Count>
|
||||
static expression_from<float_point_t<Count>> fract(const expression_t<clike_language::type_class_t::type_float, Count>& arg)
|
||||
{
|
||||
return function_t<float_point_t<Count>, typename language::function_name_t<function_class_t::function_fract>>::invoke(arg);
|
||||
return function_t<float_point_t<Count>, typename language::template function_name_t<function_class_t::function_fract>>::invoke(arg);
|
||||
}
|
||||
template<int Count>
|
||||
static expression_from<float_point_t<Count>> floor(const expression_t<clike_language::type_class_t::type_float, Count>& arg)
|
||||
{
|
||||
return function_t<float_point_t<Count>, typename language::function_name_t<function_class_t::function_floor>>::invoke(arg);
|
||||
return function_t<float_point_t<Count>, typename language::template function_name_t<function_class_t::function_floor>>::invoke(arg);
|
||||
}
|
||||
template<int Count>
|
||||
static expression_from<float_point_t<Count>> sin(const expression_t<clike_language::type_class_t::type_float, Count>& arg)
|
||||
{
|
||||
return function_t<float_point_t<Count>, typename language::function_name_t<function_class_t::function_sin>>::invoke(arg);
|
||||
return function_t<float_point_t<Count>, typename language::template function_name_t<function_class_t::function_sin>>::invoke(arg);
|
||||
}
|
||||
template<int Count>
|
||||
static expression_from<float_point_t<Count>> cos(const expression_t<clike_language::type_class_t::type_float, Count>& arg)
|
||||
{
|
||||
return function_t<float_point_t<Count>, typename language::function_name_t<function_class_t::function_cos>>::invoke(arg);
|
||||
return function_t<float_point_t<Count>, typename language::template function_name_t<function_class_t::function_cos>>::invoke(arg);
|
||||
}
|
||||
template<int Count>
|
||||
static expression_from<float_point_t<Count>> clamp(const expression_t<clike_language::type_class_t::type_float, Count>& a, const expression_t<clike_language::type_class_t::type_float, 1>& b, const expression_t<clike_language::type_class_t::type_float, 1>& c)
|
||||
{
|
||||
return function_t<float_point_t<Count>, typename language::function_name_t<function_class_t::function_clamp>>::invoke(a, b, c);
|
||||
return function_t<float_point_t<Count>, typename language::template function_name_t<function_class_t::function_clamp>>::invoke(a, b, c);
|
||||
}
|
||||
template<int Count>
|
||||
static expression_from<float_point_t<Count>> sqrt(const expression_t<clike_language::type_class_t::type_float, Count>& arg)
|
||||
{
|
||||
return function_t<float_point_t<Count>, typename language::function_name_t<function_class_t::function_sqrt>>::invoke(arg);
|
||||
return function_t<float_point_t<Count>, typename language::template function_name_t<function_class_t::function_sqrt>>::invoke(arg);
|
||||
}
|
||||
template<int Count>
|
||||
static expression_from<float_point_t<Count>> rsqrt(const expression_t<clike_language::type_class_t::type_float, Count>& arg)
|
||||
{
|
||||
return function_t<float_point_t<Count>, typename language::function_name_t<function_class_t::function_rsqrt>>::invoke(arg);
|
||||
return function_t<float_point_t<Count>, typename language::template function_name_t<function_class_t::function_rsqrt>>::invoke(arg);
|
||||
}
|
||||
template<int Count>
|
||||
static expression_from<float_point_t<Count>> pow(const expression_t<clike_language::type_class_t::type_float, Count>& a, const expression_t<clike_language::type_class_t::type_float, Count>& b)
|
||||
{
|
||||
return function_t<float_point_t<Count>, typename language::function_name_t<function_class_t::function_pow>>::invoke(a, b);
|
||||
return function_t<float_point_t<Count>, typename language::template function_name_t<function_class_t::function_pow>>::invoke(a, b);
|
||||
}
|
||||
template<int Count>
|
||||
static expression_from<float_point_t<Count>> exp(const expression_t<clike_language::type_class_t::type_float, Count>& arg)
|
||||
{
|
||||
return function_t<float_point_t<Count>, typename language::function_name_t<function_class_t::function_exp>>::invoke(arg);
|
||||
return function_t<float_point_t<Count>, typename language::template function_name_t<function_class_t::function_exp>>::invoke(arg);
|
||||
}
|
||||
template<int Count>
|
||||
static expression_from<float_point_t<Count>> log(const expression_t<clike_language::type_class_t::type_float, Count>& arg)
|
||||
{
|
||||
return function_t<float_point_t<Count>, typename language::function_name_t<function_class_t::function_log>>::invoke(arg);
|
||||
return function_t<float_point_t<Count>, typename language::template function_name_t<function_class_t::function_log>>::invoke(arg);
|
||||
}
|
||||
template<int Count>
|
||||
static expression_from<float_point_t<Count>> exp2(const expression_t<clike_language::type_class_t::type_float, Count>& arg)
|
||||
{
|
||||
return function_t<float_point_t<Count>, typename language::function_name_t<function_class_t::function_exp2>>::invoke(arg);
|
||||
return function_t<float_point_t<Count>, typename language::template function_name_t<function_class_t::function_exp2>>::invoke(arg);
|
||||
}
|
||||
template<int Count>
|
||||
static expression_from<float_point_t<Count>> log2(const expression_t<clike_language::type_class_t::type_float, Count>& arg)
|
||||
{
|
||||
return function_t<float_point_t<Count>, typename language::function_name_t<function_class_t::function_log2>>::invoke(arg);
|
||||
return function_t<float_point_t<Count>, typename language::template function_name_t<function_class_t::function_log2>>::invoke(arg);
|
||||
}
|
||||
template<int Count>
|
||||
static expression_from<float_point_t<Count>> ddx(const expression_t<clike_language::type_class_t::type_float, Count>& arg)
|
||||
{
|
||||
return function_t<float_point_t<Count>, typename language::function_name_t<function_class_t::function_ddx>>::invoke(arg);
|
||||
return function_t<float_point_t<Count>, typename language::template function_name_t<function_class_t::function_ddx>>::invoke(arg);
|
||||
}
|
||||
template<int Count>
|
||||
static expression_from<float_point_t<Count>> ddy(const expression_t<clike_language::type_class_t::type_float, Count>& arg)
|
||||
{
|
||||
return function_t<float_point_t<Count>, typename language::function_name_t<function_class_t::function_ddy>>::invoke(arg);
|
||||
return function_t<float_point_t<Count>, typename language::template function_name_t<function_class_t::function_ddy>>::invoke(arg);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
namespace shader_code
|
||||
{
|
||||
struct clike_language
|
||||
namespace clike_language_impl
|
||||
{
|
||||
enum class type_class_t
|
||||
{
|
||||
@@ -17,6 +17,27 @@ namespace shader_code
|
||||
type_sampler3D
|
||||
};
|
||||
|
||||
template<type_class_t Type, int Count>
|
||||
using type_t = builder::type_t<type_class_t, Type, Count>;
|
||||
|
||||
template<size_t Count>
|
||||
using boolean_t = type_t<type_class_t::type_bool, Count>;
|
||||
|
||||
template<size_t Count>
|
||||
using integer_t = type_t<type_class_t::type_int, Count>;
|
||||
|
||||
template<size_t Count>
|
||||
using float_point_t = type_t<type_class_t::type_float, Count>;
|
||||
|
||||
|
||||
using sampler1D_t = type_t<type_class_t::type_sampler1D, 1>;
|
||||
using sampler2D_t = type_t<type_class_t::type_sampler2D, 1>;
|
||||
using sampler3D_t = type_t<type_class_t::type_sampler3D, 1>;
|
||||
using void_t = type_t<type_class_t::type_void, 0>;
|
||||
|
||||
template<type_class_t Type>
|
||||
struct native_type_t;
|
||||
|
||||
template<typename Type>
|
||||
struct native_type_base_t
|
||||
{
|
||||
@@ -28,9 +49,6 @@ namespace shader_code
|
||||
}
|
||||
};
|
||||
|
||||
template<type_class_t Type>
|
||||
struct native_type_t;
|
||||
|
||||
template<>
|
||||
struct native_type_t<type_class_t::type_bool>
|
||||
{
|
||||
@@ -80,64 +98,9 @@ namespace shader_code
|
||||
{
|
||||
};
|
||||
|
||||
template<type_class_t Type, int Count>
|
||||
using type_t = builder::type_t<type_class_t, Type, Count>;
|
||||
|
||||
template<size_t Count>
|
||||
using boolean_t = typename type_t<type_class_t::type_bool, Count>;
|
||||
|
||||
template<size_t Count>
|
||||
using integer_t = typename type_t<type_class_t::type_int, Count>;
|
||||
|
||||
template<size_t Count>
|
||||
using float_point_t = typename type_t<type_class_t::type_float, Count>;
|
||||
|
||||
using sampler1D_t = type_t<type_class_t::type_sampler1D, 1>;
|
||||
using sampler2D_t = type_t<type_class_t::type_sampler2D, 1>;
|
||||
using sampler3D_t = type_t<type_class_t::type_sampler3D, 1>;
|
||||
using void_t = type_t<type_class_t::type_void, 0>;
|
||||
|
||||
enum function_class_t
|
||||
{
|
||||
function_abs,
|
||||
function_fract,
|
||||
function_floor,
|
||||
function_exp,
|
||||
function_log,
|
||||
function_exp2,
|
||||
function_log2,
|
||||
function_pow,
|
||||
function_texture,
|
||||
function_texture_lod,
|
||||
function_texture_bias,
|
||||
function_texture_grad,
|
||||
function_normalize,
|
||||
function_any,
|
||||
function_all,
|
||||
function_dot,
|
||||
function_min,
|
||||
function_max,
|
||||
function_greater,
|
||||
function_less,
|
||||
function_equal,
|
||||
function_greater_equal,
|
||||
function_less_equal,
|
||||
function_not_equal,
|
||||
function_sin,
|
||||
function_cos,
|
||||
function_clamp,
|
||||
function_sqrt,
|
||||
function_rsqrt,
|
||||
function_ddx,
|
||||
function_ddy
|
||||
};
|
||||
|
||||
template<type_class_t Type, int Count>
|
||||
struct expression_t;
|
||||
|
||||
template<typename Type>
|
||||
using expression_from = expression_t<Type::type, Type::count>;
|
||||
|
||||
template<type_class_t Type, int Count>
|
||||
struct expression_helper_t : public builder::expression_base_t
|
||||
{
|
||||
@@ -151,22 +114,22 @@ namespace shader_code
|
||||
|
||||
expression_helper_t(const std::string& text, bool is_single = true, int base_count = Count)
|
||||
: expression_base_t{ text }
|
||||
, is_single(is_single)
|
||||
, mask{ std::string("xyzw").substr(0, base_count) }
|
||||
, is_single(is_single)
|
||||
, base_count(base_count)
|
||||
{
|
||||
}
|
||||
|
||||
expression_helper_t(const std::string& text, const std::string& mask, bool is_single = true, int base_count = Count)
|
||||
: expression_base_t{ text }
|
||||
, is_single(is_single)
|
||||
, mask(mask)
|
||||
, is_single(is_single)
|
||||
, base_count(base_count)
|
||||
{
|
||||
}
|
||||
|
||||
template<size_t N>
|
||||
expression_helper_t(const std::string& text, const char (&mask)[N], bool is_single = true, int base_count = Count)
|
||||
expression_helper_t(const std::string& text, const char(&mask)[N], bool is_single = true, int base_count = Count)
|
||||
: expression_helper_t{ text, std::string(mask), is_single, base_count }
|
||||
{
|
||||
static_assert(N == Count + 1, "Bad swizzle!");
|
||||
@@ -180,8 +143,8 @@ namespace shader_code
|
||||
base_count = rhs.base_count;
|
||||
}
|
||||
|
||||
template<typename Type>
|
||||
expression_t<Type::type, Type::count> as() const
|
||||
template<typename AsType>
|
||||
expression_t<AsType::type, AsType::count> as() const
|
||||
{
|
||||
return{ text, mask, is_single, base_count };
|
||||
}
|
||||
@@ -199,7 +162,7 @@ namespace shader_code
|
||||
std::string new_mask;
|
||||
|
||||
using sw = std::string[]; sw{ (new_mask += mask.substr(channels, 1))... };
|
||||
|
||||
|
||||
return{ !is_single ? "(" + text + ")" : text, new_mask, is_single, base_count };
|
||||
}
|
||||
|
||||
@@ -243,7 +206,7 @@ namespace shader_code
|
||||
return{ text, mask, true, base_count };
|
||||
}
|
||||
|
||||
//protected:
|
||||
//protected:
|
||||
template<typename RetType = type, typename ArgType>
|
||||
expression_t<RetType::type, RetType::count> call_operator(const std::string& opname, const ArgType& rhs) const
|
||||
{
|
||||
@@ -257,6 +220,9 @@ namespace shader_code
|
||||
}
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
using expression_from = expression_t<Type::type, Type::count>;
|
||||
|
||||
template<type_class_t Type, int Count>
|
||||
struct expression_ctors_t : public expression_helper_t<Type, Count>
|
||||
{
|
||||
@@ -459,7 +425,7 @@ namespace shader_code
|
||||
template<type_class_t Type, int Count>
|
||||
struct expression_t : public expression_swizzle_t<Type, Count>
|
||||
{
|
||||
using base = typename expression_swizzle_t<Type, Count>;
|
||||
using base = expression_swizzle_t<Type, Count>;
|
||||
using base::base;
|
||||
|
||||
const expression_t operator -()
|
||||
@@ -513,9 +479,18 @@ namespace shader_code
|
||||
|
||||
expression_t operator=(const expression_t& rhs) { return this->call_operator("=", rhs); }
|
||||
|
||||
const expression_from<boolean_t<1>> operator!() const { return this->call_operator<boolean_t<1>>("!"); }
|
||||
const expression_from<boolean_t<1>> operator==(const expression_t& rhs) const { return this->call_operator<boolean_t<1>>("==", rhs); }
|
||||
const expression_from<boolean_t<1>> operator!=(const expression_t& rhs) const { return this->call_operator<boolean_t<1>>("!=", rhs); }
|
||||
const expression_t<type_class_t::type_bool, 1> operator!() const
|
||||
{
|
||||
return this->call_operator<type_t<type_class_t::type_bool, 1>>("!");
|
||||
}
|
||||
const expression_t<type_class_t::type_bool, 1> operator==(const expression_t& rhs) const
|
||||
{
|
||||
return this->call_operator<type_t<type_class_t::type_bool, 1>>("==", rhs);
|
||||
}
|
||||
const expression_t<type_class_t::type_bool, 1> operator!=(const expression_t& rhs) const
|
||||
{
|
||||
return this->call_operator<type_t<type_class_t::type_bool, 1>>("!=", rhs);
|
||||
}
|
||||
};
|
||||
|
||||
template<int Count>
|
||||
@@ -536,7 +511,7 @@ namespace shader_code
|
||||
const expression_t operator -()
|
||||
{
|
||||
if (this->is_single && this->text[0] == '-')
|
||||
return expression_t{ this->text.substr(1), mask };
|
||||
return expression_t{ this->text.substr(1), base::mask };
|
||||
|
||||
return this->call_operator("-");
|
||||
}
|
||||
@@ -555,8 +530,8 @@ namespace shader_code
|
||||
|
||||
return this->call_operator("+", rhs);
|
||||
}
|
||||
template<int Count> const expression_t<Type, Count> operator/(const expression_t<Type, Count>& rhs) const { return this->call_operator<type_t<Type, Count>>("/", rhs); }
|
||||
template<int Count> const expression_t<Type, Count> operator*(const expression_t<Type, Count>& rhs) const { return this->call_operator<type_t<Type, Count>>("*", rhs); }
|
||||
template<int Count> const expression_t<Type, Count> operator/(const expression_t<Type, Count>& rhs) const { return this->template call_operator<type_t<Type, Count>>("/", rhs); }
|
||||
template<int Count> const expression_t<Type, Count> operator*(const expression_t<Type, Count>& rhs) const { return this->template call_operator<type_t<Type, Count>>("*", rhs); }
|
||||
|
||||
expression_t operator=(const expression_t& rhs) { return this->call_operator("=", rhs); }
|
||||
|
||||
@@ -565,20 +540,14 @@ namespace shader_code
|
||||
expression_t operator/=(const expression_t& rhs) { return this->call_operator("/=", rhs); }
|
||||
expression_t operator*=(const expression_t& rhs) { return this->call_operator("*=", rhs); }
|
||||
|
||||
const expression_from<boolean_t<1>> operator >(const expression_t& rhs) const { return this->call_operator<boolean_t<1>>(">", rhs); }
|
||||
const expression_from<boolean_t<1>> operator >=(const expression_t& rhs) const { return this->call_operator<boolean_t<1>>(">=", rhs); }
|
||||
const expression_from<boolean_t<1>> operator <(const expression_t& rhs) const { return this->call_operator<boolean_t<1>>("<", rhs); }
|
||||
const expression_from<boolean_t<1>> operator <=(const expression_t& rhs) const { return this->call_operator<boolean_t<1>>("<=", rhs); }
|
||||
const expression_from<boolean_t<1>> operator==(const expression_t& rhs) const { return this->call_operator<boolean_t<1>>("==", rhs); }
|
||||
const expression_from<boolean_t<1>> operator!=(const expression_t& rhs) const { return this->call_operator<boolean_t<1>>("!=", rhs); }
|
||||
const expression_from<boolean_t<1>> operator >(const expression_t& rhs) const { return this->template call_operator<boolean_t<1>>(">", rhs); }
|
||||
const expression_from<boolean_t<1>> operator >=(const expression_t& rhs) const { return this->template call_operator<boolean_t<1>>(">=", rhs); }
|
||||
const expression_from<boolean_t<1>> operator <(const expression_t& rhs) const { return this->template call_operator<boolean_t<1>>("<", rhs); }
|
||||
const expression_from<boolean_t<1>> operator <=(const expression_t& rhs) const { return this->template call_operator<boolean_t<1>>("<=", rhs); }
|
||||
const expression_from<boolean_t<1>> operator==(const expression_t& rhs) const { return this->template call_operator<boolean_t<1>>("==", rhs); }
|
||||
const expression_from<boolean_t<1>> operator!=(const expression_t& rhs) const { return this->template call_operator<boolean_t<1>>("!=", rhs); }
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
static expression_t<(type_class_t)Type::type, Type::count> expression(const std::string& text, bool is_single = true)
|
||||
{
|
||||
return{ text, is_single };
|
||||
}
|
||||
|
||||
template<typename Type, typename NameType>
|
||||
struct function_t
|
||||
{
|
||||
@@ -609,6 +578,81 @@ namespace shader_code
|
||||
return{ result + ")" };
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
struct clike_language
|
||||
{
|
||||
using type_class_t = clike_language_impl::type_class_t;
|
||||
|
||||
template<type_class_t Type, int Count>
|
||||
using type_t = clike_language_impl::type_t<Type, Count>;
|
||||
|
||||
template<type_class_t Type, int Count>
|
||||
using expression_t = clike_language_impl::expression_t<Type, Count>;
|
||||
|
||||
template<size_t Count>
|
||||
using boolean_t = clike_language_impl::boolean_t<Count>;
|
||||
|
||||
template<size_t Count>
|
||||
using integer_t = clike_language_impl::integer_t<Count>;
|
||||
|
||||
template<size_t Count>
|
||||
using float_point_t = clike_language_impl::float_point_t<Count>;
|
||||
|
||||
using sampler1D_t = type_t<type_class_t::type_sampler1D, 1>;
|
||||
using sampler2D_t = type_t<type_class_t::type_sampler2D, 1>;
|
||||
using sampler3D_t = type_t<type_class_t::type_sampler3D, 1>;
|
||||
using void_t = type_t<type_class_t::type_void, 0>;
|
||||
|
||||
template<typename Type>
|
||||
using expression_from = expression_t<Type::type, Type::count>;
|
||||
|
||||
template<typename Type, typename NameType>
|
||||
using function_t = clike_language_impl::function_t<Type, NameType>;
|
||||
|
||||
template<type_class_t Type>
|
||||
using native_type_t = clike_language_impl::native_type_t<Type>;
|
||||
|
||||
enum function_class_t
|
||||
{
|
||||
function_abs,
|
||||
function_fract,
|
||||
function_floor,
|
||||
function_exp,
|
||||
function_log,
|
||||
function_exp2,
|
||||
function_log2,
|
||||
function_pow,
|
||||
function_texture,
|
||||
function_texture_lod,
|
||||
function_texture_bias,
|
||||
function_texture_grad,
|
||||
function_normalize,
|
||||
function_any,
|
||||
function_all,
|
||||
function_dot,
|
||||
function_min,
|
||||
function_max,
|
||||
function_greater,
|
||||
function_less,
|
||||
function_equal,
|
||||
function_greater_equal,
|
||||
function_less_equal,
|
||||
function_not_equal,
|
||||
function_sin,
|
||||
function_cos,
|
||||
function_clamp,
|
||||
function_sqrt,
|
||||
function_rsqrt,
|
||||
function_ddx,
|
||||
function_ddy
|
||||
};
|
||||
|
||||
template<typename Type>
|
||||
static expression_t<(type_class_t)Type::type, Type::count> expression(const std::string& text, bool is_single = true)
|
||||
{
|
||||
return{ text, is_single };
|
||||
}
|
||||
|
||||
template<type_class_t Type, int Count>
|
||||
static expression_from<void_t> if_(expression_from<boolean_t<1>> condition, expression_t<Type, Count> then)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
namespace shader_code
|
||||
{
|
||||
struct glsl_language
|
||||
namespace glsl_language_impl
|
||||
{
|
||||
template<clike_language::type_class_t Type, int Count>
|
||||
struct type_name_t;
|
||||
@@ -288,5 +288,14 @@ namespace shader_code
|
||||
{
|
||||
static constexpr char *name = "dFdy";
|
||||
};
|
||||
}
|
||||
|
||||
struct glsl_language
|
||||
{
|
||||
template<clike_language::type_class_t Type, int Count>
|
||||
using type_name_t = glsl_language_impl::type_name_t<Type, Count>;
|
||||
|
||||
template<clike_language::function_class_t Function>
|
||||
using function_name_t = glsl_language_impl::function_name_t<Function>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user