本文整理汇总了C++中Bitset::get方法的典型用法代码示例。如果您正苦于以下问题:C++ Bitset::get方法的具体用法?C++ Bitset::get怎么用?C++ Bitset::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bitset
的用法示例。
在下文中一共展示了Bitset::get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(tinybitset_unittest, test_bitset_boundrytest) {
Bitset bitset;
bool res = bitset.set(-1);
EXPECT_EQ(0,res);
res = bitset.set(128);
EXPECT_EQ(0,res);
res = bitset.set(0);
EXPECT_EQ(1,res);
res = bitset.set(127);
EXPECT_EQ(1,res);
res = bitset.get(-1);
EXPECT_EQ(0,res);
res = bitset.get(128);
EXPECT_EQ(0,res);
res = bitset.get(0);
EXPECT_EQ(1,res);
res = bitset.get(127);
EXPECT_EQ(1,res);
}
示例2: print_resources
static void print_resources(const Compiler &compiler, const char *tag, const SmallVector<Resource> &resources)
{
fprintf(stderr, "%s\n", tag);
fprintf(stderr, "=============\n\n");
bool print_ssbo = !strcmp(tag, "ssbos");
for (auto &res : resources)
{
auto &type = compiler.get_type(res.type_id);
if (print_ssbo && compiler.buffer_is_hlsl_counter_buffer(res.id))
continue;
// If we don't have a name, use the fallback for the type instead of the variable
// for SSBOs and UBOs since those are the only meaningful names to use externally.
// Push constant blocks are still accessed by name and not block name, even though they are technically Blocks.
bool is_push_constant = compiler.get_storage_class(res.id) == StorageClassPushConstant;
bool is_block = compiler.get_decoration_bitset(type.self).get(DecorationBlock) ||
compiler.get_decoration_bitset(type.self).get(DecorationBufferBlock);
bool is_sized_block = is_block && (compiler.get_storage_class(res.id) == StorageClassUniform ||
compiler.get_storage_class(res.id) == StorageClassUniformConstant);
uint32_t fallback_id = !is_push_constant && is_block ? res.base_type_id : res.id;
uint32_t block_size = 0;
uint32_t runtime_array_stride = 0;
if (is_sized_block)
{
auto &base_type = compiler.get_type(res.base_type_id);
block_size = uint32_t(compiler.get_declared_struct_size(base_type));
runtime_array_stride = uint32_t(compiler.get_declared_struct_size_runtime_array(base_type, 1) -
compiler.get_declared_struct_size_runtime_array(base_type, 0));
}
Bitset mask;
if (print_ssbo)
mask = compiler.get_buffer_block_flags(res.id);
else
mask = compiler.get_decoration_bitset(res.id);
string array;
for (auto arr : type.array)
array = join("[", arr ? convert_to_string(arr) : "", "]") + array;
fprintf(stderr, " ID %03u : %s%s", res.id,
!res.name.empty() ? res.name.c_str() : compiler.get_fallback_name(fallback_id).c_str(), array.c_str());
if (mask.get(DecorationLocation))
fprintf(stderr, " (Location : %u)", compiler.get_decoration(res.id, DecorationLocation));
if (mask.get(DecorationDescriptorSet))
fprintf(stderr, " (Set : %u)", compiler.get_decoration(res.id, DecorationDescriptorSet));
if (mask.get(DecorationBinding))
fprintf(stderr, " (Binding : %u)", compiler.get_decoration(res.id, DecorationBinding));
if (mask.get(DecorationInputAttachmentIndex))
fprintf(stderr, " (Attachment : %u)", compiler.get_decoration(res.id, DecorationInputAttachmentIndex));
if (mask.get(DecorationNonReadable))
fprintf(stderr, " writeonly");
if (mask.get(DecorationNonWritable))
fprintf(stderr, " readonly");
if (is_sized_block)
{
fprintf(stderr, " (BlockSize : %u bytes)", block_size);
if (runtime_array_stride)
fprintf(stderr, " (Unsized array stride: %u bytes)", runtime_array_stride);
}
uint32_t counter_id = 0;
if (print_ssbo && compiler.buffer_get_hlsl_counter_buffer(res.id, counter_id))
fprintf(stderr, " (HLSL counter buffer ID: %u)", counter_id);
fprintf(stderr, "\n");
}
fprintf(stderr, "=============\n\n");
}