Beispiel #1
0
static auto create_attribs(const spirv_cross::Compiler& compiler, const std::vector<spirv_cross::Resource>& resources) {
	core::Vector<ShaderModuleBase::Attribute> attribs;
	std::unordered_set<u32> locations;
	for(const auto& r : resources) {
		auto location = compiler.get_decoration(r.id, spv::DecorationLocation);
		const auto& type = compiler.get_type(r.type_id);

		attribs << ShaderModuleBase::Attribute{location, type.columns, type.vecsize, component_size(type.basetype), component_type(type.basetype)};

		for(usize i = location; i != location + type.columns; ++i) {
			if(!locations.insert(i).second) {
				y_fatal("Duplicate or overlapping attribute locations.");
			}
		}
	}
	return attribs;
}
Beispiel #2
0
const BaseMath &
BaseMath::writeStrongComponents( std::ostream & os ) const {

	typedef InputGraph Graph;
	auto const & g = this->_input_graph;

	Graph::NodeMap< int > component_id(g);
	const int n_components = stronglyConnectedComponents( g, component_id );

	std::vector< int > component_size( n_components, 0 );
	std::vector< int > component_non_dummy_size( n_components, 0 );

	/**
	 * Iterate all nodes, get the component id,
	 * update the size.
	 */
	for ( Graph::NodeIt n(g); n != lemon::INVALID; ++ n ) {
		++ component_size[ component_id[n] ];
		if ( !_dummy[n] ) {
			++ component_non_dummy_size[ component_id[n] ];
		}
	}

	os << "Strongly connected components of input graph = " << n_components << std::endl;
	os << "Component sizes =";
	for ( auto n : component_size ) {
		os << " " << n;
	}
	os << std::endl;

	os << "Component sizes (non-dummy) =";
	for ( auto n : component_non_dummy_size ) {
		os << " " << n;
	}
	os << std::endl;

	return *this;
}