MCPcopy Create free account
hub / github.com/dfranx/ShaderDebugger / lib_common_max

Function lib_common_max

src/CommonLibrary.cpp:1634–1737  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1632 return bv_variable_create_float(0.0f);
1633 }
1634 bv_variable lib_common_max(bv_program* prog, u8 count, bv_variable* args)
1635 {
1636 /* max(genType, genType), max(genType, float), also for genIType and genUType */
1637 if (count == 2) {
1638 if (args[0].type == bv_type_object) {
1639 bv_object* vec = bv_variable_get_object(args[0]);
1640
1641 // using: genType, float, genDType, double
1642 if (vec->prop[0].type == bv_type_float)
1643 {
1644 glm::vec4 x = sd::AsVector<4, float>(args[0]);
1645 glm::vec4 y(0.0f);
1646
1647 // get y
1648 if (args[1].type == bv_type_object)
1649 y = sd::AsVector<4, float>(args[1]);
1650 else
1651 y = glm::vec4(bv_variable_get_float(bv_variable_cast(bv_type_float, args[1])));
1652
1653 glm::vec4 vecData = glm::max(x, y);
1654
1655 bv_variable ret = Common::create_vec(prog, bv_type_float, vec->type->props.name_count);
1656 bv_object* retObj = bv_variable_get_object(ret);
1657
1658 for (u16 i = 0; i < retObj->type->props.name_count; i++)
1659 retObj->prop[i] = bv_variable_create_float(vecData[i]);
1660
1661 return ret;
1662 }
1663 // using: genUType, uint
1664 else if (vec->prop[0].type == bv_type_uint)
1665 {
1666 glm::uvec4 x = sd::AsVector<4, unsigned int>(args[0]);
1667 glm::uvec4 y(0u);
1668
1669 // get y
1670 if (args[1].type == bv_type_object)
1671 y = sd::AsVector<4, unsigned int>(args[1]);
1672 else
1673 y = glm::uvec4(bv_variable_get_uint(bv_variable_cast(bv_type_uint, args[1])));
1674
1675 glm::uvec4 vecData = glm::max(x, y);
1676
1677 bv_variable ret = Common::create_vec(prog, bv_type_uint, vec->type->props.name_count);
1678 bv_object* retObj = bv_variable_get_object(ret);
1679
1680 for (u16 i = 0; i < retObj->type->props.name_count; i++)
1681 retObj->prop[i] = bv_variable_create_uint(vecData[i]);
1682
1683 return ret;
1684 }
1685 // using: genIType, int
1686 else if (vec->prop[0].type == bv_type_int)
1687 {
1688 glm::ivec4 x = sd::AsVector<4, int>(args[0]);
1689 glm::ivec4 y(0);
1690
1691 // get y

Callers

nothing calls this directly

Calls 1

create_vecFunction · 0.85

Tested by

no test coverage detected