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

Function lib_common_bitCount

src/CommonLibrary.cpp:2565–2592  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2563 return bv_variable_create_int(0);
2564 }
2565 bv_variable lib_common_bitCount(bv_program* prog, u8 count, bv_variable* args)
2566 {
2567 /* bitCount(genIType) */
2568 if (count == 1) {
2569 if (args[0].type == bv_type_object) {
2570 bv_object* vec = bv_variable_get_object(args[0]);
2571 glm::ivec4 vecData = glm::bitCount(sd::AsVector<4, int>(args[0]));
2572
2573 bv_type outType = vec->prop[0].type;
2574
2575 bv_variable ret = Common::create_vec(prog, outType, vec->type->props.name_count);
2576 bv_object* retObj = bv_variable_get_object(ret);
2577
2578 for (u16 i = 0; i < retObj->type->props.name_count; i++)
2579 retObj->prop[i] = bv_variable_cast(outType, bv_variable_create_int(vecData[i]));
2580
2581 return ret;
2582 }
2583 // bitCount(scalar)
2584 else if (args[0].type == bv_type_int)
2585 return bv_variable_create_int(glm::bitCount(bv_variable_get_int(args[0])));
2586 // bitCount(scalar)
2587 else
2588 return bv_variable_create_uint(glm::bitCount(bv_variable_get_uint(bv_variable_cast(bv_type_uint, args[0]))));
2589 }
2590
2591 return bv_variable_create_int(0);
2592 }
2593 bv_variable lib_common_findLSB(bv_program* prog, u8 count, bv_variable* args)
2594 {
2595 /* findLSB(genI/UType) */

Callers

nothing calls this directly

Calls 1

create_vecFunction · 0.85

Tested by

no test coverage detected