mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-04 12:16:10 +00:00
writer/hlsl: Emit more helpers for intrinsic calls
And call these helpers instead of inlining complex statements. Cleans up output, and helps prevent for-loops decaying to while loops. Change-Id: I6ac31b18ce6c5fac0e54e982f7db3bb298f7edb2 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58060 Auto-Submit: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@chromium.org> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
f242fb9f7e
commit
e54e26d7e8
@ -1275,219 +1275,200 @@ bool GeneratorImpl::EmitFrexpCall(std::ostream& out,
|
|||||||
const sem::Intrinsic* intrinsic) {
|
const sem::Intrinsic* intrinsic) {
|
||||||
// Exponent is an integer in WGSL, but HLSL wants a float.
|
// Exponent is an integer in WGSL, but HLSL wants a float.
|
||||||
// We need to make the call with a temporary float, and then cast.
|
// We need to make the call with a temporary float, and then cast.
|
||||||
|
return CallIntrinsicHelper(
|
||||||
|
out, expr, intrinsic,
|
||||||
|
[&](TextBuffer* b, const std::vector<std::string>& params) {
|
||||||
|
auto* significand_ty = intrinsic->Parameters()[0].type;
|
||||||
|
auto significand = params[0];
|
||||||
|
auto* exponent_ty = intrinsic->Parameters()[1].type;
|
||||||
|
auto exponent = params[1];
|
||||||
|
|
||||||
auto signficand = intrinsic->Parameters()[0];
|
std::string width;
|
||||||
auto exponent = intrinsic->Parameters()[1];
|
if (auto* vec = significand_ty->As<sem::Vector>()) {
|
||||||
|
width = std::to_string(vec->size());
|
||||||
|
}
|
||||||
|
|
||||||
std::string width;
|
// Exponent is an integer, which HLSL does not have an overload for.
|
||||||
if (auto* vec = signficand.type->As<sem::Vector>()) {
|
// We need to cast from a float.
|
||||||
width = std::to_string(vec->size());
|
line(b) << "float" << width << " float_exp;";
|
||||||
}
|
line(b) << "float" << width << " significand = frexp(" << significand
|
||||||
|
<< ", float_exp);";
|
||||||
// Exponent is an integer, which HLSL does not have an overload for.
|
{
|
||||||
// We need to cast from a float.
|
auto l = line(b);
|
||||||
auto float_exp = UniqueIdentifier(kTempNamePrefix);
|
l << exponent << " = ";
|
||||||
auto significand = UniqueIdentifier(kTempNamePrefix);
|
if (!EmitType(l, exponent_ty->UnwrapPtr(), ast::StorageClass::kNone,
|
||||||
line() << "float" << width << " " << float_exp << ";";
|
ast::Access::kUndefined, "")) {
|
||||||
{
|
return false;
|
||||||
auto pre = line();
|
}
|
||||||
pre << "float" << width << " " << significand << " = frexp(";
|
l << "(float_exp);";
|
||||||
if (!EmitExpression(pre, expr->params()[0])) {
|
}
|
||||||
return false;
|
line(b) << "return significand;";
|
||||||
}
|
return true;
|
||||||
pre << ", " << float_exp << ");";
|
});
|
||||||
}
|
|
||||||
{
|
|
||||||
auto pre = line();
|
|
||||||
if (!EmitExpression(pre, expr->params()[1])) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
pre << " = ";
|
|
||||||
if (!EmitType(pre, exponent.type->UnwrapPtr(), ast::StorageClass::kNone,
|
|
||||||
ast::Access::kUndefined, "")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
pre << "(" << float_exp << ");";
|
|
||||||
}
|
|
||||||
|
|
||||||
out << significand;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GeneratorImpl::EmitIsNormalCall(std::ostream& out,
|
bool GeneratorImpl::EmitIsNormalCall(std::ostream& out,
|
||||||
ast::CallExpression* expr,
|
ast::CallExpression* expr,
|
||||||
const sem::Intrinsic* intrinsic) {
|
const sem::Intrinsic* intrinsic) {
|
||||||
// HLSL doesn't have a isNormal intrinsic, we need to emulate
|
// HLSL doesn't have a isNormal intrinsic, we need to emulate
|
||||||
auto input = intrinsic->Parameters()[0];
|
return CallIntrinsicHelper(
|
||||||
|
out, expr, intrinsic,
|
||||||
|
[&](TextBuffer* b, const std::vector<std::string>& params) {
|
||||||
|
auto* input_ty = intrinsic->Parameters()[0].type;
|
||||||
|
|
||||||
std::string width;
|
std::string width;
|
||||||
if (auto* vec = input.type->As<sem::Vector>()) {
|
if (auto* vec = input_ty->As<sem::Vector>()) {
|
||||||
width = std::to_string(vec->size());
|
width = std::to_string(vec->size());
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr auto* kExponentMask = "0x7f80000";
|
constexpr auto* kExponentMask = "0x7f80000";
|
||||||
constexpr auto* kMinNormalExponent = "0x0080000";
|
constexpr auto* kMinNormalExponent = "0x0080000";
|
||||||
constexpr auto* kMaxNormalExponent = "0x7f00000";
|
constexpr auto* kMaxNormalExponent = "0x7f00000";
|
||||||
|
|
||||||
auto exponent = UniqueIdentifier("tint_isnormal_exponent");
|
line(b) << "uint" << width << " exponent = asuint(" << params[0]
|
||||||
auto clamped = UniqueIdentifier("tint_isnormal_clamped");
|
<< ") & " << kExponentMask << ";";
|
||||||
|
line(b) << "uint" << width << " clamped = "
|
||||||
{
|
<< "clamp(exponent, " << kMinNormalExponent << ", "
|
||||||
auto pre = line();
|
<< kMaxNormalExponent << ");";
|
||||||
pre << "uint" << width << " " << exponent << " = asuint(";
|
line(b) << "return clamped == exponent;";
|
||||||
if (!EmitExpression(pre, expr->params()[0])) {
|
return true;
|
||||||
return false;
|
});
|
||||||
}
|
|
||||||
pre << ") & " << kExponentMask << ";";
|
|
||||||
}
|
|
||||||
line() << "uint" << width << " " << clamped << " = "
|
|
||||||
<< "clamp(" << exponent << ", " << kMinNormalExponent << ", "
|
|
||||||
<< kMaxNormalExponent << ");";
|
|
||||||
|
|
||||||
out << "(" << clamped << " == " << exponent << ")";
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GeneratorImpl::EmitDataPackingCall(std::ostream& out,
|
bool GeneratorImpl::EmitDataPackingCall(std::ostream& out,
|
||||||
ast::CallExpression* expr,
|
ast::CallExpression* expr,
|
||||||
const sem::Intrinsic* intrinsic) {
|
const sem::Intrinsic* intrinsic) {
|
||||||
auto* param = expr->params()[0];
|
return CallIntrinsicHelper(
|
||||||
auto tmp_name = UniqueIdentifier(kTempNamePrefix);
|
out, expr, intrinsic,
|
||||||
std::ostringstream expr_out;
|
[&](TextBuffer* b, const std::vector<std::string>& params) {
|
||||||
if (!EmitExpression(expr_out, param)) {
|
uint32_t dims = 2;
|
||||||
return false;
|
bool is_signed = false;
|
||||||
}
|
uint32_t scale = 65535;
|
||||||
uint32_t dims = 2;
|
if (intrinsic->Type() == sem::IntrinsicType::kPack4x8snorm ||
|
||||||
bool is_signed = false;
|
intrinsic->Type() == sem::IntrinsicType::kPack4x8unorm) {
|
||||||
uint32_t scale = 65535;
|
dims = 4;
|
||||||
if (intrinsic->Type() == sem::IntrinsicType::kPack4x8snorm ||
|
scale = 255;
|
||||||
intrinsic->Type() == sem::IntrinsicType::kPack4x8unorm) {
|
}
|
||||||
dims = 4;
|
if (intrinsic->Type() == sem::IntrinsicType::kPack4x8snorm ||
|
||||||
scale = 255;
|
intrinsic->Type() == sem::IntrinsicType::kPack2x16snorm) {
|
||||||
}
|
is_signed = true;
|
||||||
if (intrinsic->Type() == sem::IntrinsicType::kPack4x8snorm ||
|
scale = (scale - 1) / 2;
|
||||||
intrinsic->Type() == sem::IntrinsicType::kPack2x16snorm) {
|
}
|
||||||
is_signed = true;
|
switch (intrinsic->Type()) {
|
||||||
scale = (scale - 1) / 2;
|
case sem::IntrinsicType::kPack4x8snorm:
|
||||||
}
|
case sem::IntrinsicType::kPack4x8unorm:
|
||||||
switch (intrinsic->Type()) {
|
case sem::IntrinsicType::kPack2x16snorm:
|
||||||
case sem::IntrinsicType::kPack4x8snorm:
|
case sem::IntrinsicType::kPack2x16unorm: {
|
||||||
case sem::IntrinsicType::kPack4x8unorm:
|
{
|
||||||
case sem::IntrinsicType::kPack2x16snorm:
|
auto l = line(b);
|
||||||
case sem::IntrinsicType::kPack2x16unorm: {
|
l << (is_signed ? "" : "u") << "int" << dims
|
||||||
{
|
<< " i = " << (is_signed ? "" : "u") << "int" << dims
|
||||||
auto pre = line();
|
<< "(round(clamp(" << params[0] << ", "
|
||||||
pre << (is_signed ? "" : "u") << "int" << dims << " " << tmp_name
|
<< (is_signed ? "-1.0" : "0.0") << ", 1.0) * " << scale
|
||||||
<< " = " << (is_signed ? "" : "u") << "int" << dims
|
<< ".0))";
|
||||||
<< "(round(clamp(" << expr_out.str() << ", "
|
if (is_signed) {
|
||||||
<< (is_signed ? "-1.0" : "0.0") << ", 1.0) * " << scale << ".0))";
|
l << " & " << (dims == 4 ? "0xff" : "0xffff");
|
||||||
if (is_signed) {
|
}
|
||||||
pre << " & " << (dims == 4 ? "0xff" : "0xffff");
|
l << ";";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
auto l = line(b);
|
||||||
|
l << "return ";
|
||||||
|
if (is_signed) {
|
||||||
|
l << "asuint";
|
||||||
|
}
|
||||||
|
l << "(i.x | i.y << " << (32 / dims);
|
||||||
|
if (dims == 4) {
|
||||||
|
l << " | i.z << 16 | i.w << 24";
|
||||||
|
}
|
||||||
|
l << ");";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case sem::IntrinsicType::kPack2x16float: {
|
||||||
|
line(b) << "uint2 i = f32tof16(" << params[0] << ");";
|
||||||
|
line(b) << "return i.x | (i.y << 16);";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
diagnostics_.add_error(
|
||||||
|
diag::System::Writer,
|
||||||
|
"Internal error: unhandled data packing intrinsic");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
pre << ";";
|
|
||||||
}
|
|
||||||
if (is_signed) {
|
|
||||||
out << "asuint";
|
|
||||||
}
|
|
||||||
out << "(";
|
|
||||||
out << tmp_name << ".x | " << tmp_name << ".y << " << (32 / dims);
|
|
||||||
if (dims == 4) {
|
|
||||||
out << " | " << tmp_name << ".z << 16 | " << tmp_name << ".w << 24";
|
|
||||||
}
|
|
||||||
out << ")";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case sem::IntrinsicType::kPack2x16float: {
|
|
||||||
line() << "uint2 " << tmp_name << " = f32tof16(" << expr_out.str()
|
|
||||||
<< ");";
|
|
||||||
out << "(" << tmp_name << ".x | " << tmp_name << ".y << 16)";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
diagnostics_.add_error(
|
|
||||||
diag::System::Writer,
|
|
||||||
"Internal error: unhandled data packing intrinsic");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GeneratorImpl::EmitDataUnpackingCall(std::ostream& out,
|
bool GeneratorImpl::EmitDataUnpackingCall(std::ostream& out,
|
||||||
ast::CallExpression* expr,
|
ast::CallExpression* expr,
|
||||||
const sem::Intrinsic* intrinsic) {
|
const sem::Intrinsic* intrinsic) {
|
||||||
auto* param = expr->params()[0];
|
return CallIntrinsicHelper(
|
||||||
auto tmp_name = UniqueIdentifier(kTempNamePrefix);
|
out, expr, intrinsic,
|
||||||
std::ostringstream expr_out;
|
[&](TextBuffer* b, const std::vector<std::string>& params) {
|
||||||
if (!EmitExpression(expr_out, param)) {
|
uint32_t dims = 2;
|
||||||
return false;
|
bool is_signed = false;
|
||||||
}
|
uint32_t scale = 65535;
|
||||||
uint32_t dims = 2;
|
if (intrinsic->Type() == sem::IntrinsicType::kUnpack4x8snorm ||
|
||||||
bool is_signed = false;
|
intrinsic->Type() == sem::IntrinsicType::kUnpack4x8unorm) {
|
||||||
uint32_t scale = 65535;
|
dims = 4;
|
||||||
if (intrinsic->Type() == sem::IntrinsicType::kUnpack4x8snorm ||
|
scale = 255;
|
||||||
intrinsic->Type() == sem::IntrinsicType::kUnpack4x8unorm) {
|
|
||||||
dims = 4;
|
|
||||||
scale = 255;
|
|
||||||
}
|
|
||||||
if (intrinsic->Type() == sem::IntrinsicType::kUnpack4x8snorm ||
|
|
||||||
intrinsic->Type() == sem::IntrinsicType::kUnpack2x16snorm) {
|
|
||||||
is_signed = true;
|
|
||||||
scale = (scale - 1) / 2;
|
|
||||||
}
|
|
||||||
switch (intrinsic->Type()) {
|
|
||||||
case sem::IntrinsicType::kUnpack4x8snorm:
|
|
||||||
case sem::IntrinsicType::kUnpack2x16snorm: {
|
|
||||||
auto tmp_name2 = UniqueIdentifier(kTempNamePrefix);
|
|
||||||
line() << "int " << tmp_name2 << " = int(" << expr_out.str() << ");";
|
|
||||||
{ // Perform sign extension on the converted values.
|
|
||||||
auto pre = line();
|
|
||||||
pre << "int" << dims << " " << tmp_name << " = int" << dims << "(";
|
|
||||||
if (dims == 2) {
|
|
||||||
pre << tmp_name2 << " << 16, " << tmp_name2 << ") >> 16";
|
|
||||||
} else {
|
|
||||||
pre << tmp_name2 << " << 24, " << tmp_name2 << " << 16, " << tmp_name2
|
|
||||||
<< " << 8, " << tmp_name2 << ") >> 24";
|
|
||||||
}
|
}
|
||||||
pre << ";";
|
if (intrinsic->Type() == sem::IntrinsicType::kUnpack4x8snorm ||
|
||||||
}
|
intrinsic->Type() == sem::IntrinsicType::kUnpack2x16snorm) {
|
||||||
|
is_signed = true;
|
||||||
out << "clamp(float" << dims << "(" << tmp_name << ") / " << scale
|
scale = (scale - 1) / 2;
|
||||||
<< ".0, " << (is_signed ? "-1.0" : "0.0") << ", 1.0)";
|
}
|
||||||
break;
|
switch (intrinsic->Type()) {
|
||||||
}
|
case sem::IntrinsicType::kUnpack4x8snorm:
|
||||||
case sem::IntrinsicType::kUnpack4x8unorm:
|
case sem::IntrinsicType::kUnpack2x16snorm: {
|
||||||
case sem::IntrinsicType::kUnpack2x16unorm: {
|
line(b) << "int j = int(" << params[0] << ");";
|
||||||
auto tmp_name2 = UniqueIdentifier(kTempNamePrefix);
|
{ // Perform sign extension on the converted values.
|
||||||
line() << "uint " << tmp_name2 << " = " << expr_out.str() << ";";
|
auto l = line(b);
|
||||||
{
|
l << "int" << dims << " i = int" << dims << "(";
|
||||||
auto pre = line();
|
if (dims == 2) {
|
||||||
pre << "uint" << dims << " " << tmp_name << " = uint" << dims << "(";
|
l << "j << 16, j) >> 16";
|
||||||
pre << tmp_name2 << " & " << (dims == 2 ? "0xffff" : "0xff") << ", ";
|
} else {
|
||||||
if (dims == 4) {
|
l << "j << 24, j << 16, j << 8, j) >> 24";
|
||||||
pre << "(" << tmp_name2 << " >> " << (32 / dims) << ") & 0xff, ("
|
}
|
||||||
<< tmp_name2 << " >> 16) & 0xff, " << tmp_name2 << " >> 24";
|
l << ";";
|
||||||
} else {
|
}
|
||||||
pre << tmp_name2 << " >> " << (32 / dims);
|
line(b) << "return clamp(float" << dims << "(i) / " << scale
|
||||||
|
<< ".0, " << (is_signed ? "-1.0" : "0.0") << ", 1.0);";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case sem::IntrinsicType::kUnpack4x8unorm:
|
||||||
|
case sem::IntrinsicType::kUnpack2x16unorm: {
|
||||||
|
line(b) << "uint j = " << params[0] << ";";
|
||||||
|
{
|
||||||
|
auto l = line(b);
|
||||||
|
l << "uint" << dims << " i = uint" << dims << "(";
|
||||||
|
l << "j & " << (dims == 2 ? "0xffff" : "0xff") << ", ";
|
||||||
|
if (dims == 4) {
|
||||||
|
l << "(j >> " << (32 / dims)
|
||||||
|
<< ") & 0xff, (j >> 16) & 0xff, j >> 24";
|
||||||
|
} else {
|
||||||
|
l << "j >> " << (32 / dims);
|
||||||
|
}
|
||||||
|
l << ");";
|
||||||
|
}
|
||||||
|
line(b) << "return float" << dims << "(i) / " << scale << ".0;";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case sem::IntrinsicType::kUnpack2x16float:
|
||||||
|
line(b) << "uint i = " << params[0] << ";";
|
||||||
|
line(b) << "return f16tof32(uint2(i & 0xffff, i >> 16));";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
diagnostics_.add_error(
|
||||||
|
diag::System::Writer,
|
||||||
|
"Internal error: unhandled data packing intrinsic");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
pre << ");";
|
|
||||||
}
|
|
||||||
out << "float" << dims << "(" << tmp_name << ") / " << scale << ".0";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case sem::IntrinsicType::kUnpack2x16float:
|
|
||||||
line() << "uint " << tmp_name << " = " << expr_out.str() << ";";
|
|
||||||
out << "f16tof32(uint2(" << tmp_name << " & 0xffff, " << tmp_name
|
|
||||||
<< " >> 16))";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
diagnostics_.add_error(
|
|
||||||
diag::System::Writer,
|
|
||||||
"Internal error: unhandled data packing intrinsic");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GeneratorImpl::EmitBarrierCall(std::ostream& out,
|
bool GeneratorImpl::EmitBarrierCall(std::ostream& out,
|
||||||
@ -3247,19 +3228,75 @@ bool GeneratorImpl::EmitProgramConstVariable(const ast::Variable* var) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string GeneratorImpl::get_buffer_name(ast::Expression* expr) {
|
template <typename F>
|
||||||
for (;;) {
|
bool GeneratorImpl::CallIntrinsicHelper(std::ostream& out,
|
||||||
if (auto* ident = expr->As<ast::IdentifierExpression>()) {
|
ast::CallExpression* call,
|
||||||
return builder_.Symbols().NameFor(ident->symbol());
|
const sem::Intrinsic* intrinsic,
|
||||||
} else if (auto* member = expr->As<ast::MemberAccessorExpression>()) {
|
F&& build) {
|
||||||
expr = member->structure();
|
// Generate the helper function if it hasn't been created already
|
||||||
} else if (auto* array = expr->As<ast::ArrayAccessorExpression>()) {
|
auto fn = utils::GetOrCreate(intrinsics_, intrinsic, [&]() -> std::string {
|
||||||
expr = array->array();
|
auto fn_name =
|
||||||
} else {
|
UniqueIdentifier(std::string("tint_") + sem::str(intrinsic->Type()));
|
||||||
break;
|
std::vector<std::string> parameter_names;
|
||||||
|
{
|
||||||
|
auto decl = line(&helpers_);
|
||||||
|
if (!EmitTypeAndName(decl, intrinsic->ReturnType(),
|
||||||
|
ast::StorageClass::kNone, ast::Access::kUndefined,
|
||||||
|
fn_name)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
ScopedParen sp(decl);
|
||||||
|
for (auto param : intrinsic->Parameters()) {
|
||||||
|
if (!parameter_names.empty()) {
|
||||||
|
decl << ", ";
|
||||||
|
}
|
||||||
|
auto param_name = "param_" + std::to_string(parameter_names.size());
|
||||||
|
const auto* ty = param.type;
|
||||||
|
if (auto* ptr = ty->As<sem::Pointer>()) {
|
||||||
|
decl << "inout ";
|
||||||
|
ty = ptr->StoreType();
|
||||||
|
}
|
||||||
|
if (!EmitTypeAndName(decl, ty, ast::StorageClass::kNone,
|
||||||
|
ast::Access::kUndefined, param_name)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
parameter_names.emplace_back(std::move(param_name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
decl << " {";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
ScopedIndent si(&helpers_);
|
||||||
|
if (!build(&helpers_, parameter_names)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
line(&helpers_) << "}";
|
||||||
|
line(&helpers_);
|
||||||
|
return fn_name;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (fn.empty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call the helper
|
||||||
|
out << fn;
|
||||||
|
{
|
||||||
|
ScopedParen sp(out);
|
||||||
|
bool first = true;
|
||||||
|
for (auto* arg : call->params()) {
|
||||||
|
if (!first) {
|
||||||
|
out << ", ";
|
||||||
|
}
|
||||||
|
first = false;
|
||||||
|
if (!EmitExpression(out, arg)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace hlsl
|
} // namespace hlsl
|
||||||
|
@ -400,12 +400,31 @@ class GeneratorImpl : public TextGenerator {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string get_buffer_name(ast::Expression* expr);
|
/// CallIntrinsicHelper will call the intrinsic helper function, creating it
|
||||||
|
/// if it hasn't been built already. If the intrinsic needs to be built then
|
||||||
|
/// CallIntrinsicHelper will generate the function signature and will call
|
||||||
|
/// `build` to emit the body of the function.
|
||||||
|
/// @param out the output of the expression stream
|
||||||
|
/// @param call the call expression
|
||||||
|
/// @param intrinsic the semantic information for the intrinsic
|
||||||
|
/// @param build a function with the signature:
|
||||||
|
/// `bool(TextBuffer* buffer, const std::vector<std::string>& params)`
|
||||||
|
/// Where:
|
||||||
|
/// `buffer` is the body of the generated function
|
||||||
|
/// `params` is the name of all the generated function parameters
|
||||||
|
/// @returns true if the call expression is emitted
|
||||||
|
|
||||||
|
template <typename F>
|
||||||
|
bool CallIntrinsicHelper(std::ostream& out,
|
||||||
|
ast::CallExpression* call,
|
||||||
|
const sem::Intrinsic* intrinsic,
|
||||||
|
F&& build);
|
||||||
|
|
||||||
TextBuffer helpers_; // Helper functions emitted at the top of the output
|
TextBuffer helpers_; // Helper functions emitted at the top of the output
|
||||||
std::function<bool()> emit_continuing_;
|
std::function<bool()> emit_continuing_;
|
||||||
std::unordered_map<DMAIntrinsic, std::string, DMAIntrinsic::Hasher>
|
std::unordered_map<DMAIntrinsic, std::string, DMAIntrinsic::Hasher>
|
||||||
dma_intrinsics_;
|
dma_intrinsics_;
|
||||||
|
std::unordered_map<const sem::Intrinsic*, std::string> intrinsics_;
|
||||||
std::unordered_map<const sem::Struct*, std::string> structure_builders_;
|
std::unordered_map<const sem::Struct*, std::string> structure_builders_;
|
||||||
std::unordered_map<const sem::Vector*, std::string> dynamic_vector_write_;
|
std::unordered_map<const sem::Vector*, std::string> dynamic_vector_write_;
|
||||||
};
|
};
|
||||||
|
@ -326,12 +326,21 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Frexp_Scalar_i32) {
|
|||||||
GeneratorImpl& gen = SanitizeAndBuild();
|
GeneratorImpl& gen = SanitizeAndBuild();
|
||||||
|
|
||||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||||
EXPECT_THAT(gen.result(), HasSubstr(R"(
|
EXPECT_EQ(gen.result(),
|
||||||
float tint_tmp;
|
R"(float tint_frexp(float param_0, inout int param_1) {
|
||||||
float tint_tmp_1 = frexp(1.0f, tint_tmp);
|
float float_exp;
|
||||||
exp = int(tint_tmp);
|
float significand = frexp(param_0, float_exp);
|
||||||
tint_tmp_1;
|
param_1 = int(float_exp);
|
||||||
)"));
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void test_function() {
|
||||||
|
int exp = 0;
|
||||||
|
tint_frexp(1.0f, exp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Intrinsic, Frexp_Vector_i32) {
|
TEST_F(HlslGeneratorImplTest_Intrinsic, Frexp_Vector_i32) {
|
||||||
@ -342,12 +351,21 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Frexp_Vector_i32) {
|
|||||||
GeneratorImpl& gen = SanitizeAndBuild();
|
GeneratorImpl& gen = SanitizeAndBuild();
|
||||||
|
|
||||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||||
EXPECT_THAT(gen.result(), HasSubstr(R"(
|
EXPECT_EQ(gen.result(),
|
||||||
float3 tint_tmp;
|
R"(float3 tint_frexp(float3 param_0, inout int3 param_1) {
|
||||||
float3 tint_tmp_1 = frexp(float3(0.0f, 0.0f, 0.0f), tint_tmp);
|
float3 float_exp;
|
||||||
res = int3(tint_tmp);
|
float3 significand = frexp(param_0, float_exp);
|
||||||
tint_tmp_1;
|
param_1 = int3(float_exp);
|
||||||
)"));
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void test_function() {
|
||||||
|
int3 res = int3(0, 0, 0);
|
||||||
|
tint_frexp(float3(0.0f, 0.0f, 0.0f), res);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Intrinsic, IsNormal_Scalar) {
|
TEST_F(HlslGeneratorImplTest_Intrinsic, IsNormal_Scalar) {
|
||||||
@ -358,11 +376,19 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, IsNormal_Scalar) {
|
|||||||
GeneratorImpl& gen = SanitizeAndBuild();
|
GeneratorImpl& gen = SanitizeAndBuild();
|
||||||
|
|
||||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||||
EXPECT_THAT(gen.result(), HasSubstr(R"(
|
EXPECT_EQ(gen.result(), R"(bool tint_isNormal(float param_0) {
|
||||||
uint tint_isnormal_exponent = asuint(val) & 0x7f80000;
|
uint exponent = asuint(param_0) & 0x7f80000;
|
||||||
uint tint_isnormal_clamped = clamp(tint_isnormal_exponent, 0x0080000, 0x7f00000);
|
uint clamped = clamp(exponent, 0x0080000, 0x7f00000);
|
||||||
(tint_isnormal_clamped == tint_isnormal_exponent);
|
return clamped == exponent;
|
||||||
)"));
|
}
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void test_function() {
|
||||||
|
float val = 0.0f;
|
||||||
|
tint_isNormal(val);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Intrinsic, IsNormal_Vector) {
|
TEST_F(HlslGeneratorImplTest_Intrinsic, IsNormal_Vector) {
|
||||||
@ -373,11 +399,19 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, IsNormal_Vector) {
|
|||||||
GeneratorImpl& gen = SanitizeAndBuild();
|
GeneratorImpl& gen = SanitizeAndBuild();
|
||||||
|
|
||||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||||
EXPECT_THAT(gen.result(), HasSubstr(R"(
|
EXPECT_EQ(gen.result(), R"(bool3 tint_isNormal(float3 param_0) {
|
||||||
uint3 tint_isnormal_exponent = asuint(val) & 0x7f80000;
|
uint3 exponent = asuint(param_0) & 0x7f80000;
|
||||||
uint3 tint_isnormal_clamped = clamp(tint_isnormal_exponent, 0x0080000, 0x7f00000);
|
uint3 clamped = clamp(exponent, 0x0080000, 0x7f00000);
|
||||||
(tint_isnormal_clamped == tint_isnormal_exponent);
|
return clamped == exponent;
|
||||||
)"));
|
}
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void test_function() {
|
||||||
|
float3 val = float3(0.0f, 0.0f, 0.0f);
|
||||||
|
tint_isNormal(val);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Intrinsic, Pack4x8Snorm) {
|
TEST_F(HlslGeneratorImplTest_Intrinsic, Pack4x8Snorm) {
|
||||||
@ -386,13 +420,20 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Pack4x8Snorm) {
|
|||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
gen.increment_indent();
|
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||||
std::stringstream out;
|
EXPECT_EQ(gen.result(), R"(uint tint_pack4x8snorm(float4 param_0) {
|
||||||
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
|
int4 i = int4(round(clamp(param_0, -1.0, 1.0) * 127.0)) & 0xff;
|
||||||
EXPECT_THAT(gen.result(), HasSubstr("int4 tint_tmp = int4(round(clamp(p1, "
|
return asuint(i.x | i.y << 8 | i.z << 16 | i.w << 24);
|
||||||
"-1.0, 1.0) * 127.0)) & 0xff;"));
|
}
|
||||||
EXPECT_THAT(out.str(), HasSubstr("asuint(tint_tmp.x | tint_tmp.y << 8 | "
|
|
||||||
"tint_tmp.z << 16 | tint_tmp.w << 24)"));
|
static float4 p1 = float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void test_function() {
|
||||||
|
tint_pack4x8snorm(p1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Intrinsic, Pack4x8Unorm) {
|
TEST_F(HlslGeneratorImplTest_Intrinsic, Pack4x8Unorm) {
|
||||||
@ -401,13 +442,20 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Pack4x8Unorm) {
|
|||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
gen.increment_indent();
|
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||||
std::stringstream out;
|
EXPECT_EQ(gen.result(), R"(uint tint_pack4x8unorm(float4 param_0) {
|
||||||
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
|
uint4 i = uint4(round(clamp(param_0, 0.0, 1.0) * 255.0));
|
||||||
EXPECT_THAT(gen.result(), HasSubstr("uint4 tint_tmp = uint4(round(clamp(p1, "
|
return (i.x | i.y << 8 | i.z << 16 | i.w << 24);
|
||||||
"0.0, 1.0) * 255.0));"));
|
}
|
||||||
EXPECT_THAT(out.str(), HasSubstr("(tint_tmp.x | tint_tmp.y << 8 | "
|
|
||||||
"tint_tmp.z << 16 | tint_tmp.w << 24)"));
|
static float4 p1 = float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void test_function() {
|
||||||
|
tint_pack4x8unorm(p1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Intrinsic, Pack2x16Snorm) {
|
TEST_F(HlslGeneratorImplTest_Intrinsic, Pack2x16Snorm) {
|
||||||
@ -416,12 +464,20 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Pack2x16Snorm) {
|
|||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
gen.increment_indent();
|
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||||
std::stringstream out;
|
EXPECT_EQ(gen.result(), R"(uint tint_pack2x16snorm(float2 param_0) {
|
||||||
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
|
int2 i = int2(round(clamp(param_0, -1.0, 1.0) * 32767.0)) & 0xffff;
|
||||||
EXPECT_THAT(gen.result(), HasSubstr("int2 tint_tmp = int2(round(clamp(p1, "
|
return asuint(i.x | i.y << 16);
|
||||||
"-1.0, 1.0) * 32767.0)) & 0xffff;"));
|
}
|
||||||
EXPECT_THAT(out.str(), HasSubstr("asuint(tint_tmp.x | tint_tmp.y << 16)"));
|
|
||||||
|
static float2 p1 = float2(0.0f, 0.0f);
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void test_function() {
|
||||||
|
tint_pack2x16snorm(p1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Intrinsic, Pack2x16Unorm) {
|
TEST_F(HlslGeneratorImplTest_Intrinsic, Pack2x16Unorm) {
|
||||||
@ -430,12 +486,20 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Pack2x16Unorm) {
|
|||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
gen.increment_indent();
|
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||||
std::stringstream out;
|
EXPECT_EQ(gen.result(), R"(uint tint_pack2x16unorm(float2 param_0) {
|
||||||
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
|
uint2 i = uint2(round(clamp(param_0, 0.0, 1.0) * 65535.0));
|
||||||
EXPECT_THAT(gen.result(), HasSubstr("uint2 tint_tmp = uint2(round(clamp(p1, "
|
return (i.x | i.y << 16);
|
||||||
"0.0, 1.0) * 65535.0));"));
|
}
|
||||||
EXPECT_THAT(out.str(), HasSubstr("(tint_tmp.x | tint_tmp.y << 16)"));
|
|
||||||
|
static float2 p1 = float2(0.0f, 0.0f);
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void test_function() {
|
||||||
|
tint_pack2x16unorm(p1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Intrinsic, Pack2x16Float) {
|
TEST_F(HlslGeneratorImplTest_Intrinsic, Pack2x16Float) {
|
||||||
@ -444,11 +508,20 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Pack2x16Float) {
|
|||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
gen.increment_indent();
|
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||||
std::stringstream out;
|
EXPECT_EQ(gen.result(), R"(uint tint_pack2x16float(float2 param_0) {
|
||||||
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
|
uint2 i = f32tof16(param_0);
|
||||||
EXPECT_THAT(gen.result(), HasSubstr("uint2 tint_tmp = f32tof16(p1);"));
|
return i.x | (i.y << 16);
|
||||||
EXPECT_THAT(out.str(), HasSubstr("(tint_tmp.x | tint_tmp.y << 16)"));
|
}
|
||||||
|
|
||||||
|
static float2 p1 = float2(0.0f, 0.0f);
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void test_function() {
|
||||||
|
tint_pack2x16float(p1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Intrinsic, Unpack4x8Snorm) {
|
TEST_F(HlslGeneratorImplTest_Intrinsic, Unpack4x8Snorm) {
|
||||||
@ -457,15 +530,21 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Unpack4x8Snorm) {
|
|||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
gen.increment_indent();
|
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||||
std::stringstream out;
|
EXPECT_EQ(gen.result(), R"(float4 tint_unpack4x8snorm(uint param_0) {
|
||||||
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
|
int j = int(param_0);
|
||||||
EXPECT_THAT(gen.result(), HasSubstr("int tint_tmp_1 = int(p1);"));
|
int4 i = int4(j << 24, j << 16, j << 8, j) >> 24;
|
||||||
EXPECT_THAT(gen.result(),
|
return clamp(float4(i) / 127.0, -1.0, 1.0);
|
||||||
HasSubstr("int4 tint_tmp = int4(tint_tmp_1 << 24, tint_tmp_1 "
|
}
|
||||||
"<< 16, tint_tmp_1 << 8, tint_tmp_1) >> 24;"));
|
|
||||||
EXPECT_THAT(out.str(),
|
static uint p1 = 0u;
|
||||||
HasSubstr("clamp(float4(tint_tmp) / 127.0, -1.0, 1.0)"));
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void test_function() {
|
||||||
|
tint_unpack4x8snorm(p1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Intrinsic, Unpack4x8Unorm) {
|
TEST_F(HlslGeneratorImplTest_Intrinsic, Unpack4x8Unorm) {
|
||||||
@ -474,15 +553,21 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Unpack4x8Unorm) {
|
|||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
gen.increment_indent();
|
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||||
std::stringstream out;
|
EXPECT_EQ(gen.result(), R"(float4 tint_unpack4x8unorm(uint param_0) {
|
||||||
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
|
uint j = param_0;
|
||||||
EXPECT_THAT(gen.result(), HasSubstr("uint tint_tmp_1 = p1;"));
|
uint4 i = uint4(j & 0xff, (j >> 8) & 0xff, (j >> 16) & 0xff, j >> 24);
|
||||||
EXPECT_THAT(
|
return float4(i) / 255.0;
|
||||||
gen.result(),
|
}
|
||||||
HasSubstr("uint4 tint_tmp = uint4(tint_tmp_1 & 0xff, (tint_tmp_1 >> "
|
|
||||||
"8) & 0xff, (tint_tmp_1 >> 16) & 0xff, tint_tmp_1 >> 24);"));
|
static uint p1 = 0u;
|
||||||
EXPECT_THAT(out.str(), HasSubstr("float4(tint_tmp) / 255.0"));
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void test_function() {
|
||||||
|
tint_unpack4x8unorm(p1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Intrinsic, Unpack2x16Snorm) {
|
TEST_F(HlslGeneratorImplTest_Intrinsic, Unpack2x16Snorm) {
|
||||||
@ -491,15 +576,21 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Unpack2x16Snorm) {
|
|||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
gen.increment_indent();
|
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||||
std::stringstream out;
|
EXPECT_EQ(gen.result(), R"(float2 tint_unpack2x16snorm(uint param_0) {
|
||||||
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
|
int j = int(param_0);
|
||||||
EXPECT_THAT(gen.result(), HasSubstr("int tint_tmp_1 = int(p1);"));
|
int2 i = int2(j << 16, j) >> 16;
|
||||||
EXPECT_THAT(
|
return clamp(float2(i) / 32767.0, -1.0, 1.0);
|
||||||
gen.result(),
|
}
|
||||||
HasSubstr("int2 tint_tmp = int2(tint_tmp_1 << 16, tint_tmp_1) >> 16;"));
|
|
||||||
EXPECT_THAT(out.str(),
|
static uint p1 = 0u;
|
||||||
HasSubstr("clamp(float2(tint_tmp) / 32767.0, -1.0, 1.0)"));
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void test_function() {
|
||||||
|
tint_unpack2x16snorm(p1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Intrinsic, Unpack2x16Unorm) {
|
TEST_F(HlslGeneratorImplTest_Intrinsic, Unpack2x16Unorm) {
|
||||||
@ -508,14 +599,21 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Unpack2x16Unorm) {
|
|||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
gen.increment_indent();
|
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||||
std::stringstream out;
|
EXPECT_EQ(gen.result(), R"(float2 tint_unpack2x16unorm(uint param_0) {
|
||||||
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
|
uint j = param_0;
|
||||||
EXPECT_THAT(gen.result(), HasSubstr("uint tint_tmp_1 = p1;"));
|
uint2 i = uint2(j & 0xffff, j >> 16);
|
||||||
EXPECT_THAT(gen.result(),
|
return float2(i) / 65535.0;
|
||||||
HasSubstr("uint2 tint_tmp = uint2(tint_tmp_1 & 0xffff, "
|
}
|
||||||
"tint_tmp_1 >> 16);"));
|
|
||||||
EXPECT_THAT(out.str(), HasSubstr("float2(tint_tmp) / 65535.0"));
|
static uint p1 = 0u;
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void test_function() {
|
||||||
|
tint_unpack2x16unorm(p1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Intrinsic, Unpack2x16Float) {
|
TEST_F(HlslGeneratorImplTest_Intrinsic, Unpack2x16Float) {
|
||||||
@ -524,12 +622,20 @@ TEST_F(HlslGeneratorImplTest_Intrinsic, Unpack2x16Float) {
|
|||||||
WrapInFunction(call);
|
WrapInFunction(call);
|
||||||
GeneratorImpl& gen = Build();
|
GeneratorImpl& gen = Build();
|
||||||
|
|
||||||
gen.increment_indent();
|
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||||
std::stringstream out;
|
EXPECT_EQ(gen.result(), R"(float2 tint_unpack2x16float(uint param_0) {
|
||||||
ASSERT_TRUE(gen.EmitExpression(out, call)) << gen.error();
|
uint i = param_0;
|
||||||
EXPECT_THAT(gen.result(), HasSubstr("uint tint_tmp = p1;"));
|
return f16tof32(uint2(i & 0xffff, i >> 16));
|
||||||
EXPECT_THAT(out.str(),
|
}
|
||||||
HasSubstr("f16tof32(uint2(tint_tmp & 0xffff, tint_tmp >> 16))"));
|
|
||||||
|
static uint p1 = 0u;
|
||||||
|
|
||||||
|
[numthreads(1, 1, 1)]
|
||||||
|
void test_function() {
|
||||||
|
tint_unpack2x16float(p1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
)");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(HlslGeneratorImplTest_Intrinsic, StorageBarrier) {
|
TEST_F(HlslGeneratorImplTest_Intrinsic, StorageBarrier) {
|
||||||
|
@ -209,7 +209,7 @@ class TextGenerator {
|
|||||||
/// @param buffer the TextBuffer to write the line to
|
/// @param buffer the TextBuffer to write the line to
|
||||||
/// @returns a new LineWriter, used for buffering and writing a line to
|
/// @returns a new LineWriter, used for buffering and writing a line to
|
||||||
/// the end of `buffer`.
|
/// the end of `buffer`.
|
||||||
LineWriter line(TextBuffer* buffer) { return LineWriter(buffer); }
|
static LineWriter line(TextBuffer* buffer) { return LineWriter(buffer); }
|
||||||
|
|
||||||
/// The program
|
/// The program
|
||||||
Program const* const program_;
|
Program const* const program_;
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
|
float tint_frexp(float param_0, inout int param_1) {
|
||||||
|
float float_exp;
|
||||||
|
float significand = frexp(param_0, float_exp);
|
||||||
|
param_1 = int(float_exp);
|
||||||
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
[numthreads(1, 1, 1)]
|
[numthreads(1, 1, 1)]
|
||||||
void main() {
|
void main() {
|
||||||
int exponent = 0;
|
int exponent = 0;
|
||||||
float tint_tmp;
|
const float significand = tint_frexp(1.230000019f, exponent);
|
||||||
float tint_tmp_1 = frexp(1.230000019f, tint_tmp);
|
|
||||||
exponent = int(tint_tmp);
|
|
||||||
const float significand = tint_tmp_1;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
|
float4 tint_frexp(float4 param_0, inout int4 param_1) {
|
||||||
|
float4 float_exp;
|
||||||
|
float4 significand = frexp(param_0, float_exp);
|
||||||
|
param_1 = int4(float_exp);
|
||||||
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
void frexp_013caa() {
|
void frexp_013caa() {
|
||||||
int4 arg_1 = int4(0, 0, 0, 0);
|
int4 arg_1 = int4(0, 0, 0, 0);
|
||||||
float4 tint_tmp;
|
float4 res = tint_frexp(float4(0.0f, 0.0f, 0.0f, 0.0f), arg_1);
|
||||||
float4 tint_tmp_1 = frexp(float4(0.0f, 0.0f, 0.0f, 0.0f), tint_tmp);
|
|
||||||
arg_1 = int4(tint_tmp);
|
|
||||||
float4 res = tint_tmp_1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
|
float tint_frexp(float param_0, inout int param_1) {
|
||||||
|
float float_exp;
|
||||||
|
float significand = frexp(param_0, float_exp);
|
||||||
|
param_1 = int(float_exp);
|
||||||
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
groupshared int arg_1;
|
groupshared int arg_1;
|
||||||
|
|
||||||
void frexp_0da285() {
|
void frexp_0da285() {
|
||||||
float tint_tmp;
|
float res = tint_frexp(1.0f, arg_1);
|
||||||
float tint_tmp_1 = frexp(1.0f, tint_tmp);
|
|
||||||
arg_1 = int(tint_tmp);
|
|
||||||
float res = tint_tmp_1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol_1 {
|
struct tint_symbol_1 {
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
|
float2 tint_frexp(float2 param_0, inout int2 param_1) {
|
||||||
|
float2 float_exp;
|
||||||
|
float2 significand = frexp(param_0, float_exp);
|
||||||
|
param_1 = int2(float_exp);
|
||||||
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
void frexp_15edf3() {
|
void frexp_15edf3() {
|
||||||
int2 arg_1 = int2(0, 0);
|
int2 arg_1 = int2(0, 0);
|
||||||
float2 tint_tmp;
|
float2 res = tint_frexp(float2(0.0f, 0.0f), arg_1);
|
||||||
float2 tint_tmp_1 = frexp(float2(0.0f, 0.0f), tint_tmp);
|
|
||||||
arg_1 = int2(tint_tmp);
|
|
||||||
float2 res = tint_tmp_1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
|
float4 tint_frexp(float4 param_0, inout int4 param_1) {
|
||||||
|
float4 float_exp;
|
||||||
|
float4 significand = frexp(param_0, float_exp);
|
||||||
|
param_1 = int4(float_exp);
|
||||||
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
void frexp_19ab15() {
|
void frexp_19ab15() {
|
||||||
int4 arg_1 = int4(0, 0, 0, 0);
|
int4 arg_1 = int4(0, 0, 0, 0);
|
||||||
float4 tint_tmp;
|
float4 res = tint_frexp(float4(0.0f, 0.0f, 0.0f, 0.0f), arg_1);
|
||||||
float4 tint_tmp_1 = frexp(float4(0.0f, 0.0f, 0.0f, 0.0f), tint_tmp);
|
|
||||||
arg_1 = int4(tint_tmp);
|
|
||||||
float4 res = tint_tmp_1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
|
float4 tint_frexp(float4 param_0, inout int4 param_1) {
|
||||||
|
float4 float_exp;
|
||||||
|
float4 significand = frexp(param_0, float_exp);
|
||||||
|
param_1 = int4(float_exp);
|
||||||
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
void frexp_2052e9() {
|
void frexp_2052e9() {
|
||||||
int4 arg_1 = int4(0, 0, 0, 0);
|
int4 arg_1 = int4(0, 0, 0, 0);
|
||||||
float4 tint_tmp;
|
float4 res = tint_frexp(float4(0.0f, 0.0f, 0.0f, 0.0f), arg_1);
|
||||||
float4 tint_tmp_1 = frexp(float4(0.0f, 0.0f, 0.0f, 0.0f), tint_tmp);
|
|
||||||
arg_1 = int4(tint_tmp);
|
|
||||||
float4 res = tint_tmp_1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
|
float3 tint_frexp(float3 param_0, inout int3 param_1) {
|
||||||
|
float3 float_exp;
|
||||||
|
float3 significand = frexp(param_0, float_exp);
|
||||||
|
param_1 = int3(float_exp);
|
||||||
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
groupshared int3 arg_1;
|
groupshared int3 arg_1;
|
||||||
|
|
||||||
void frexp_40fc9b() {
|
void frexp_40fc9b() {
|
||||||
float3 tint_tmp;
|
float3 res = tint_frexp(float3(0.0f, 0.0f, 0.0f), arg_1);
|
||||||
float3 tint_tmp_1 = frexp(float3(0.0f, 0.0f, 0.0f), tint_tmp);
|
|
||||||
arg_1 = int3(tint_tmp);
|
|
||||||
float3 res = tint_tmp_1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol_1 {
|
struct tint_symbol_1 {
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
|
float tint_frexp(float param_0, inout int param_1) {
|
||||||
|
float float_exp;
|
||||||
|
float significand = frexp(param_0, float_exp);
|
||||||
|
param_1 = int(float_exp);
|
||||||
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
void frexp_41e931() {
|
void frexp_41e931() {
|
||||||
int arg_1 = 0;
|
int arg_1 = 0;
|
||||||
float tint_tmp;
|
float res = tint_frexp(1.0f, arg_1);
|
||||||
float tint_tmp_1 = frexp(1.0f, tint_tmp);
|
|
||||||
arg_1 = int(tint_tmp);
|
|
||||||
float res = tint_tmp_1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
|
float tint_frexp(float param_0, inout int param_1) {
|
||||||
|
float float_exp;
|
||||||
|
float significand = frexp(param_0, float_exp);
|
||||||
|
param_1 = int(float_exp);
|
||||||
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
void frexp_481e59() {
|
void frexp_481e59() {
|
||||||
int arg_1 = 0;
|
int arg_1 = 0;
|
||||||
float tint_tmp;
|
float res = tint_frexp(1.0f, arg_1);
|
||||||
float tint_tmp_1 = frexp(1.0f, tint_tmp);
|
|
||||||
arg_1 = int(tint_tmp);
|
|
||||||
float res = tint_tmp_1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
|
float3 tint_frexp(float3 param_0, inout int3 param_1) {
|
||||||
|
float3 float_exp;
|
||||||
|
float3 significand = frexp(param_0, float_exp);
|
||||||
|
param_1 = int3(float_exp);
|
||||||
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
void frexp_5a141e() {
|
void frexp_5a141e() {
|
||||||
int3 arg_1 = int3(0, 0, 0);
|
int3 arg_1 = int3(0, 0, 0);
|
||||||
float3 tint_tmp;
|
float3 res = tint_frexp(float3(0.0f, 0.0f, 0.0f), arg_1);
|
||||||
float3 tint_tmp_1 = frexp(float3(0.0f, 0.0f, 0.0f), tint_tmp);
|
|
||||||
arg_1 = int3(tint_tmp);
|
|
||||||
float3 res = tint_tmp_1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
|
float3 tint_frexp(float3 param_0, inout int3 param_1) {
|
||||||
|
float3 float_exp;
|
||||||
|
float3 significand = frexp(param_0, float_exp);
|
||||||
|
param_1 = int3(float_exp);
|
||||||
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
void frexp_6d0058() {
|
void frexp_6d0058() {
|
||||||
int3 arg_1 = int3(0, 0, 0);
|
int3 arg_1 = int3(0, 0, 0);
|
||||||
float3 tint_tmp;
|
float3 res = tint_frexp(float3(0.0f, 0.0f, 0.0f), arg_1);
|
||||||
float3 tint_tmp_1 = frexp(float3(0.0f, 0.0f, 0.0f), tint_tmp);
|
|
||||||
arg_1 = int3(tint_tmp);
|
|
||||||
float3 res = tint_tmp_1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
|
float3 tint_frexp(float3 param_0, inout int3 param_1) {
|
||||||
|
float3 float_exp;
|
||||||
|
float3 significand = frexp(param_0, float_exp);
|
||||||
|
param_1 = int3(float_exp);
|
||||||
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
static int3 arg_1 = int3(0, 0, 0);
|
static int3 arg_1 = int3(0, 0, 0);
|
||||||
|
|
||||||
void frexp_6efa09() {
|
void frexp_6efa09() {
|
||||||
float3 tint_tmp;
|
float3 res = tint_frexp(float3(0.0f, 0.0f, 0.0f), arg_1);
|
||||||
float3 tint_tmp_1 = frexp(float3(0.0f, 0.0f, 0.0f), tint_tmp);
|
|
||||||
arg_1 = int3(tint_tmp);
|
|
||||||
float3 res = tint_tmp_1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
|
float tint_frexp(float param_0, inout int param_1) {
|
||||||
|
float float_exp;
|
||||||
|
float significand = frexp(param_0, float_exp);
|
||||||
|
param_1 = int(float_exp);
|
||||||
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
static int arg_1 = 0;
|
static int arg_1 = 0;
|
||||||
|
|
||||||
void frexp_a2a617() {
|
void frexp_a2a617() {
|
||||||
float tint_tmp;
|
float res = tint_frexp(1.0f, arg_1);
|
||||||
float tint_tmp_1 = frexp(1.0f, tint_tmp);
|
|
||||||
arg_1 = int(tint_tmp);
|
|
||||||
float res = tint_tmp_1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
|
float2 tint_frexp(float2 param_0, inout int2 param_1) {
|
||||||
|
float2 float_exp;
|
||||||
|
float2 significand = frexp(param_0, float_exp);
|
||||||
|
param_1 = int2(float_exp);
|
||||||
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
groupshared int2 arg_1;
|
groupshared int2 arg_1;
|
||||||
|
|
||||||
void frexp_a3f940() {
|
void frexp_a3f940() {
|
||||||
float2 tint_tmp;
|
float2 res = tint_frexp(float2(0.0f, 0.0f), arg_1);
|
||||||
float2 tint_tmp_1 = frexp(float2(0.0f, 0.0f), tint_tmp);
|
|
||||||
arg_1 = int2(tint_tmp);
|
|
||||||
float2 res = tint_tmp_1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol_1 {
|
struct tint_symbol_1 {
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
|
float2 tint_frexp(float2 param_0, inout int2 param_1) {
|
||||||
|
float2 float_exp;
|
||||||
|
float2 significand = frexp(param_0, float_exp);
|
||||||
|
param_1 = int2(float_exp);
|
||||||
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
void frexp_a951b5() {
|
void frexp_a951b5() {
|
||||||
int2 arg_1 = int2(0, 0);
|
int2 arg_1 = int2(0, 0);
|
||||||
float2 tint_tmp;
|
float2 res = tint_frexp(float2(0.0f, 0.0f), arg_1);
|
||||||
float2 tint_tmp_1 = frexp(float2(0.0f, 0.0f), tint_tmp);
|
|
||||||
arg_1 = int2(tint_tmp);
|
|
||||||
float2 res = tint_tmp_1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
|
float4 tint_frexp(float4 param_0, inout int4 param_1) {
|
||||||
|
float4 float_exp;
|
||||||
|
float4 significand = frexp(param_0, float_exp);
|
||||||
|
param_1 = int4(float_exp);
|
||||||
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
static int4 arg_1 = int4(0, 0, 0, 0);
|
static int4 arg_1 = int4(0, 0, 0, 0);
|
||||||
|
|
||||||
void frexp_b45525() {
|
void frexp_b45525() {
|
||||||
float4 tint_tmp;
|
float4 res = tint_frexp(float4(0.0f, 0.0f, 0.0f, 0.0f), arg_1);
|
||||||
float4 tint_tmp_1 = frexp(float4(0.0f, 0.0f, 0.0f, 0.0f), tint_tmp);
|
|
||||||
arg_1 = int4(tint_tmp);
|
|
||||||
float4 res = tint_tmp_1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
|
float4 tint_frexp(float4 param_0, inout int4 param_1) {
|
||||||
|
float4 float_exp;
|
||||||
|
float4 significand = frexp(param_0, float_exp);
|
||||||
|
param_1 = int4(float_exp);
|
||||||
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
groupshared int4 arg_1;
|
groupshared int4 arg_1;
|
||||||
|
|
||||||
void frexp_b87f4e() {
|
void frexp_b87f4e() {
|
||||||
float4 tint_tmp;
|
float4 res = tint_frexp(float4(0.0f, 0.0f, 0.0f, 0.0f), arg_1);
|
||||||
float4 tint_tmp_1 = frexp(float4(0.0f, 0.0f, 0.0f, 0.0f), tint_tmp);
|
|
||||||
arg_1 = int4(tint_tmp);
|
|
||||||
float4 res = tint_tmp_1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol_1 {
|
struct tint_symbol_1 {
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
|
float3 tint_frexp(float3 param_0, inout int3 param_1) {
|
||||||
|
float3 float_exp;
|
||||||
|
float3 significand = frexp(param_0, float_exp);
|
||||||
|
param_1 = int3(float_exp);
|
||||||
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
void frexp_b9e4de() {
|
void frexp_b9e4de() {
|
||||||
int3 arg_1 = int3(0, 0, 0);
|
int3 arg_1 = int3(0, 0, 0);
|
||||||
float3 tint_tmp;
|
float3 res = tint_frexp(float3(0.0f, 0.0f, 0.0f), arg_1);
|
||||||
float3 tint_tmp_1 = frexp(float3(0.0f, 0.0f, 0.0f), tint_tmp);
|
|
||||||
arg_1 = int3(tint_tmp);
|
|
||||||
float3 res = tint_tmp_1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
|
float2 tint_frexp(float2 param_0, inout int2 param_1) {
|
||||||
|
float2 float_exp;
|
||||||
|
float2 significand = frexp(param_0, float_exp);
|
||||||
|
param_1 = int2(float_exp);
|
||||||
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
static int2 arg_1 = int2(0, 0);
|
static int2 arg_1 = int2(0, 0);
|
||||||
|
|
||||||
void frexp_c084e3() {
|
void frexp_c084e3() {
|
||||||
float2 tint_tmp;
|
float2 res = tint_frexp(float2(0.0f, 0.0f), arg_1);
|
||||||
float2 tint_tmp_1 = frexp(float2(0.0f, 0.0f), tint_tmp);
|
|
||||||
arg_1 = int2(tint_tmp);
|
|
||||||
float2 res = tint_tmp_1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
|
float2 tint_frexp(float2 param_0, inout int2 param_1) {
|
||||||
|
float2 float_exp;
|
||||||
|
float2 significand = frexp(param_0, float_exp);
|
||||||
|
param_1 = int2(float_exp);
|
||||||
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
void frexp_d06c2c() {
|
void frexp_d06c2c() {
|
||||||
int2 arg_1 = int2(0, 0);
|
int2 arg_1 = int2(0, 0);
|
||||||
float2 tint_tmp;
|
float2 res = tint_frexp(float2(0.0f, 0.0f), arg_1);
|
||||||
float2 tint_tmp_1 = frexp(float2(0.0f, 0.0f), tint_tmp);
|
|
||||||
arg_1 = int2(tint_tmp);
|
|
||||||
float2 res = tint_tmp_1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
|
float tint_frexp(float param_0, inout int param_1) {
|
||||||
|
float float_exp;
|
||||||
|
float significand = frexp(param_0, float_exp);
|
||||||
|
param_1 = int(float_exp);
|
||||||
|
return significand;
|
||||||
|
}
|
||||||
|
|
||||||
void frexp_e061dd() {
|
void frexp_e061dd() {
|
||||||
int arg_1 = 0;
|
int arg_1 = 0;
|
||||||
float tint_tmp;
|
float res = tint_frexp(1.0f, arg_1);
|
||||||
float tint_tmp_1 = frexp(1.0f, tint_tmp);
|
|
||||||
arg_1 = int(tint_tmp);
|
|
||||||
float res = tint_tmp_1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
|
bool4 tint_isNormal(float4 param_0) {
|
||||||
|
uint4 exponent = asuint(param_0) & 0x7f80000;
|
||||||
|
uint4 clamped = clamp(exponent, 0x0080000, 0x7f00000);
|
||||||
|
return clamped == exponent;
|
||||||
|
}
|
||||||
|
|
||||||
void isNormal_863dcd() {
|
void isNormal_863dcd() {
|
||||||
uint4 tint_isnormal_exponent = asuint(float4(0.0f, 0.0f, 0.0f, 0.0f)) & 0x7f80000;
|
bool4 res = tint_isNormal(float4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||||
uint4 tint_isnormal_clamped = clamp(tint_isnormal_exponent, 0x0080000, 0x7f00000);
|
|
||||||
bool4 res = (tint_isnormal_clamped == tint_isnormal_exponent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
|
bool2 tint_isNormal(float2 param_0) {
|
||||||
|
uint2 exponent = asuint(param_0) & 0x7f80000;
|
||||||
|
uint2 clamped = clamp(exponent, 0x0080000, 0x7f00000);
|
||||||
|
return clamped == exponent;
|
||||||
|
}
|
||||||
|
|
||||||
void isNormal_b00ab1() {
|
void isNormal_b00ab1() {
|
||||||
uint2 tint_isnormal_exponent = asuint(float2(0.0f, 0.0f)) & 0x7f80000;
|
bool2 res = tint_isNormal(float2(0.0f, 0.0f));
|
||||||
uint2 tint_isnormal_clamped = clamp(tint_isnormal_exponent, 0x0080000, 0x7f00000);
|
|
||||||
bool2 res = (tint_isnormal_clamped == tint_isnormal_exponent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
|
bool3 tint_isNormal(float3 param_0) {
|
||||||
|
uint3 exponent = asuint(param_0) & 0x7f80000;
|
||||||
|
uint3 clamped = clamp(exponent, 0x0080000, 0x7f00000);
|
||||||
|
return clamped == exponent;
|
||||||
|
}
|
||||||
|
|
||||||
void isNormal_c286b7() {
|
void isNormal_c286b7() {
|
||||||
uint3 tint_isnormal_exponent = asuint(float3(0.0f, 0.0f, 0.0f)) & 0x7f80000;
|
bool3 res = tint_isNormal(float3(0.0f, 0.0f, 0.0f));
|
||||||
uint3 tint_isnormal_clamped = clamp(tint_isnormal_exponent, 0x0080000, 0x7f00000);
|
|
||||||
bool3 res = (tint_isnormal_clamped == tint_isnormal_exponent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
|
bool tint_isNormal(float param_0) {
|
||||||
|
uint exponent = asuint(param_0) & 0x7f80000;
|
||||||
|
uint clamped = clamp(exponent, 0x0080000, 0x7f00000);
|
||||||
|
return clamped == exponent;
|
||||||
|
}
|
||||||
|
|
||||||
void isNormal_c6e880() {
|
void isNormal_c6e880() {
|
||||||
uint tint_isnormal_exponent = asuint(1.0f) & 0x7f80000;
|
bool res = tint_isNormal(1.0f);
|
||||||
uint tint_isnormal_clamped = clamp(tint_isnormal_exponent, 0x0080000, 0x7f00000);
|
|
||||||
bool res = (tint_isnormal_clamped == tint_isnormal_exponent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
|
uint tint_pack2x16float(float2 param_0) {
|
||||||
|
uint2 i = f32tof16(param_0);
|
||||||
|
return i.x | (i.y << 16);
|
||||||
|
}
|
||||||
|
|
||||||
void pack2x16float_0e97b3() {
|
void pack2x16float_0e97b3() {
|
||||||
uint2 tint_tmp = f32tof16(float2(0.0f, 0.0f));
|
uint res = tint_pack2x16float(float2(0.0f, 0.0f));
|
||||||
uint res = (tint_tmp.x | tint_tmp.y << 16);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
|
uint tint_pack2x16snorm(float2 param_0) {
|
||||||
|
int2 i = int2(round(clamp(param_0, -1.0, 1.0) * 32767.0)) & 0xffff;
|
||||||
|
return asuint(i.x | i.y << 16);
|
||||||
|
}
|
||||||
|
|
||||||
void pack2x16snorm_6c169b() {
|
void pack2x16snorm_6c169b() {
|
||||||
int2 tint_tmp = int2(round(clamp(float2(0.0f, 0.0f), -1.0, 1.0) * 32767.0)) & 0xffff;
|
uint res = tint_pack2x16snorm(float2(0.0f, 0.0f));
|
||||||
uint res = asuint(tint_tmp.x | tint_tmp.y << 16);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
|
uint tint_pack2x16unorm(float2 param_0) {
|
||||||
|
uint2 i = uint2(round(clamp(param_0, 0.0, 1.0) * 65535.0));
|
||||||
|
return (i.x | i.y << 16);
|
||||||
|
}
|
||||||
|
|
||||||
void pack2x16unorm_0f08e4() {
|
void pack2x16unorm_0f08e4() {
|
||||||
uint2 tint_tmp = uint2(round(clamp(float2(0.0f, 0.0f), 0.0, 1.0) * 65535.0));
|
uint res = tint_pack2x16unorm(float2(0.0f, 0.0f));
|
||||||
uint res = (tint_tmp.x | tint_tmp.y << 16);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
|
uint tint_pack4x8snorm(float4 param_0) {
|
||||||
|
int4 i = int4(round(clamp(param_0, -1.0, 1.0) * 127.0)) & 0xff;
|
||||||
|
return asuint(i.x | i.y << 8 | i.z << 16 | i.w << 24);
|
||||||
|
}
|
||||||
|
|
||||||
void pack4x8snorm_4d22e7() {
|
void pack4x8snorm_4d22e7() {
|
||||||
int4 tint_tmp = int4(round(clamp(float4(0.0f, 0.0f, 0.0f, 0.0f), -1.0, 1.0) * 127.0)) & 0xff;
|
uint res = tint_pack4x8snorm(float4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||||
uint res = asuint(tint_tmp.x | tint_tmp.y << 8 | tint_tmp.z << 16 | tint_tmp.w << 24);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
|
uint tint_pack4x8unorm(float4 param_0) {
|
||||||
|
uint4 i = uint4(round(clamp(param_0, 0.0, 1.0) * 255.0));
|
||||||
|
return (i.x | i.y << 8 | i.z << 16 | i.w << 24);
|
||||||
|
}
|
||||||
|
|
||||||
void pack4x8unorm_95c456() {
|
void pack4x8unorm_95c456() {
|
||||||
uint4 tint_tmp = uint4(round(clamp(float4(0.0f, 0.0f, 0.0f, 0.0f), 0.0, 1.0) * 255.0));
|
uint res = tint_pack4x8unorm(float4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||||
uint res = (tint_tmp.x | tint_tmp.y << 8 | tint_tmp.z << 16 | tint_tmp.w << 24);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
|
float2 tint_unpack2x16float(uint param_0) {
|
||||||
|
uint i = param_0;
|
||||||
|
return f16tof32(uint2(i & 0xffff, i >> 16));
|
||||||
|
}
|
||||||
|
|
||||||
void unpack2x16float_32a5cf() {
|
void unpack2x16float_32a5cf() {
|
||||||
uint tint_tmp = 1u;
|
float2 res = tint_unpack2x16float(1u);
|
||||||
float2 res = f16tof32(uint2(tint_tmp & 0xffff, tint_tmp >> 16));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
|
float2 tint_unpack2x16snorm(uint param_0) {
|
||||||
|
int j = int(param_0);
|
||||||
|
int2 i = int2(j << 16, j) >> 16;
|
||||||
|
return clamp(float2(i) / 32767.0, -1.0, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
void unpack2x16snorm_b4aea6() {
|
void unpack2x16snorm_b4aea6() {
|
||||||
int tint_tmp_1 = int(1u);
|
float2 res = tint_unpack2x16snorm(1u);
|
||||||
int2 tint_tmp = int2(tint_tmp_1 << 16, tint_tmp_1) >> 16;
|
|
||||||
float2 res = clamp(float2(tint_tmp) / 32767.0, -1.0, 1.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
|
float2 tint_unpack2x16unorm(uint param_0) {
|
||||||
|
uint j = param_0;
|
||||||
|
uint2 i = uint2(j & 0xffff, j >> 16);
|
||||||
|
return float2(i) / 65535.0;
|
||||||
|
}
|
||||||
|
|
||||||
void unpack2x16unorm_7699c0() {
|
void unpack2x16unorm_7699c0() {
|
||||||
uint tint_tmp_1 = 1u;
|
float2 res = tint_unpack2x16unorm(1u);
|
||||||
uint2 tint_tmp = uint2(tint_tmp_1 & 0xffff, tint_tmp_1 >> 16);
|
|
||||||
float2 res = float2(tint_tmp) / 65535.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
|
float4 tint_unpack4x8snorm(uint param_0) {
|
||||||
|
int j = int(param_0);
|
||||||
|
int4 i = int4(j << 24, j << 16, j << 8, j) >> 24;
|
||||||
|
return clamp(float4(i) / 127.0, -1.0, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
void unpack4x8snorm_523fb3() {
|
void unpack4x8snorm_523fb3() {
|
||||||
int tint_tmp_1 = int(1u);
|
float4 res = tint_unpack4x8snorm(1u);
|
||||||
int4 tint_tmp = int4(tint_tmp_1 << 24, tint_tmp_1 << 16, tint_tmp_1 << 8, tint_tmp_1) >> 24;
|
|
||||||
float4 res = clamp(float4(tint_tmp) / 127.0, -1.0, 1.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
|
float4 tint_unpack4x8unorm(uint param_0) {
|
||||||
|
uint j = param_0;
|
||||||
|
uint4 i = uint4(j & 0xff, (j >> 8) & 0xff, (j >> 16) & 0xff, j >> 24);
|
||||||
|
return float4(i) / 255.0;
|
||||||
|
}
|
||||||
|
|
||||||
void unpack4x8unorm_750c74() {
|
void unpack4x8unorm_750c74() {
|
||||||
uint tint_tmp_1 = 1u;
|
float4 res = tint_unpack4x8unorm(1u);
|
||||||
uint4 tint_tmp = uint4(tint_tmp_1 & 0xff, (tint_tmp_1 >> 8) & 0xff, (tint_tmp_1 >> 16) & 0xff, tint_tmp_1 >> 24);
|
|
||||||
float4 res = float4(tint_tmp) / 255.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tint_symbol {
|
struct tint_symbol {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user