ShaderModuleBase::ShaderModuleBase(DevicePtr dptr, const SpirVData& data) : DeviceLinked(dptr), _module(create_shader_module(dptr, data)) { spirv_cross::Compiler compiler(std::vector<u32>(data.data(), data.data() + data.size() / 4)); _type = module_type(compiler); auto resources = compiler.get_shader_resources(); merge(_bindings, create_bindings(compiler, resources.uniform_buffers, _type, vk::DescriptorType::eUniformBuffer)); merge(_bindings, create_bindings(compiler, resources.storage_buffers, _type, vk::DescriptorType::eStorageBuffer)); merge(_bindings, create_bindings(compiler, resources.sampled_images, _type, vk::DescriptorType::eCombinedImageSampler)); merge(_bindings, create_bindings(compiler, resources.storage_images, _type, vk::DescriptorType::eStorageImage)); _push_constants = create_push_constants(compiler, resources.push_constant_buffers, _type); _attribs = create_attribs(compiler, resources.stage_inputs); // these are attribs & other stages stuff fail_not_empty(resources.atomic_counters); fail_not_empty(resources.separate_images); fail_not_empty(resources.separate_samplers); u32 spec_offset = 0; for(const auto& cst : compiler.get_specialization_constants()) { const auto& type = compiler.get_type(compiler.get_constant(cst.id).constant_type); u32 size = type.width / 8; _spec_constants << vk::SpecializationMapEntry(cst.constant_id, spec_offset, size); spec_offset += size; } for(usize i = 0; i != 3; ++i) { _local_size[i] = compiler.get_execution_mode_argument(spv::ExecutionMode::ExecutionModeLocalSize, i); } }
/* * Update current bindings with a new value */ void shortcuts_update_bindings(guint shortcut_idx, guint key, GdkModifierType mask) { // first remove all existing bindings remove_bindings(); // update data update_bindings_data(shortcut_idx, key, mask); // recreate all bindings create_bindings(); // update configuration dbus_set_shortcuts(shortcutsMap); }
/* * Initialize a specific binding */ static void initialize_binding(const gchar* action, guint key, GdkModifierType mask) { guint i; for (i = 0; accelerators_list[i].action != NULL && g_strcmp0(action, accelerators_list[i].action) != 0; ++i) /* noop */; if (accelerators_list[i].action == NULL) { g_warning("Shortcut: Error: Cannot find corresponding action"); return; } // update config value accelerators_list[i].key = key; accelerators_list[i].mask = mask; // update bindings create_bindings(); }