12 const spirv_cross::ParsedIR* ir,
13 const spirv_cross::Compiler*
compiler,
14 std::optional<spirv_cross::SPIRType::BaseType> type_filter,
17 std::vector<spirv_cross::ID> uniforms;
18 ir->for_each_typed_id<spirv_cross::SPIRVariable>(
19 [&](uint32_t,
const spirv_cross::SPIRVariable& var) {
20 if (var.storage != spv::StorageClassUniformConstant) {
24 if (!type_filter.has_value() ||
25 (include && type_filter.value() ==
type.basetype) ||
26 (!include && type_filter.value() !=
type.basetype)) {
27 uniforms.push_back(var.self);
31 auto compare_locations = [&ir](spirv_cross::ID id1, spirv_cross::ID id2) {
32 auto& flags1 = ir->get_decoration_bitset(id1);
33 auto& flags2 = ir->get_decoration_bitset(id2);
35 if (!flags1.get(spv::Decoration::DecorationLocation)) {
38 if (!flags2.get(spv::Decoration::DecorationLocation)) {
42 return ir->get_decoration(id1, spv::Decoration::DecorationLocation) <
43 ir->get_decoration(id2, spv::Decoration::DecorationLocation);
45 std::sort(uniforms.begin(), uniforms.end(), compare_locations);
static std::vector< SkPDFIndirectReference > sort(const THashSet< SkPDFIndirectReference > &src)
std::vector< spirv_cross::ID > SortUniforms(const spirv_cross::ParsedIR *ir, const spirv_cross::Compiler *compiler, std::optional< spirv_cross::SPIRType::BaseType > type_filter, bool include)
Sorts uniform declarations in an IR according to decoration order.