DXBC_Reflect::DXBC_Reflect(const void *new_data, int new_size)
{
	DXBC_Reader base_reader((const unsigned char *) new_data, new_size);

	DXBC_Reader dxbc_reader(base_reader);

	if (dxbc_reader.get_int32() != TAG_DXBC)
		throw Exception("Not DXBC format");

	dxbc_reader.skip_bytes(4*4);	// GUID
	int file_format_version = dxbc_reader.get_int32();	// Version

	int internal_total_size = dxbc_reader.get_int32();
	if (internal_total_size != new_size)
		throw Exception("Invalid DXBC size");

	int chunk_count = dxbc_reader.get_int32();
	for (int cnt=0; cnt < chunk_count; cnt++)
	{
		int chunk_offset = dxbc_reader.get_int32();
		DXBC_Reader chunk_reader(base_reader);
		chunk_reader.skip_bytes(chunk_offset);

		int chunk_tag = chunk_reader.get_int32();
		int chunk_size = chunk_reader.get_int32();	// We ignore this

		if (chunk_tag == TAG_RDEF)
		{
			DXBC_Reader header_reader(chunk_reader);
			int constant_buffer_count = header_reader.get_int32();
			int constant_buffer_offset = header_reader.get_int32();
			int bound_resource_count = header_reader.get_int32();
			int bound_resource_offset = header_reader.get_int32();
			int target_shader_model = header_reader.get_int32();	// Shader model in low word
			int flags = header_reader.get_int32();

			if (bound_resource_count)
			{
				DXBC_Reader bind_reader(chunk_reader);
				bind_reader.skip_bytes(bound_resource_offset);

				binding.reserve(bound_resource_count);
				for (int i=0; i < bound_resource_count; i++)
				{
					D3D11_SHADER_INPUT_BIND_DESC desc = {0};
					desc.Name = chunk_reader.get_string(bind_reader.get_int32());
					desc.Type = (D3D_SHADER_INPUT_TYPE) bind_reader.get_int32();
					desc.ReturnType = (D3D_RESOURCE_RETURN_TYPE) bind_reader.get_int32();
					desc.Dimension = (D3D_SRV_DIMENSION) bind_reader.get_int32();
					desc.NumSamples = bind_reader.get_int32();
					desc.BindPoint = bind_reader.get_int32();
					desc.BindCount = bind_reader.get_int32();
					desc.uFlags = bind_reader.get_int32();

					binding.push_back(desc);
				}
			}
		}
	}
}
Пример #2
0
void MIDISeq::Sequence::load(Herbs::StreamIn& source)
	{
	MIDISeq::FileHeader header;
	MIDISeq::ChunkReader chunk_reader(source,header);

	time_division=header.time_division;
	tracks.lengthValidSet(header.n_tracks);
	tracks.clear();
	length=0;
	Herbs::Stringbase<char> chunk_name;
	while(chunk_reader.headerRead(chunk_name))
		{
		MIDISeq::TrackReader track_reader(chunk_reader);
		tracks.append(Herbs::Array<Event>());
		auto ptr_begin=tracks.end() - 1;
		MIDISeq::Event e;
		while(track_reader.eventNextGet(e))
			{
			ptr_begin->append(e);
			}
		length=std::max(length,e.time);
		chunk_reader.skip();
		}
	}
Пример #3
0
	virtual bool open_path_internal(file::ptr p_filehint,const char * path,t_input_open_reason p_reason,abort_callback & p_abort,bool p_from_redirect,bool p_skip_hints) {
		if (p_filehint.is_empty()) {
			try {
				filesystem::g_open_read(p_filehint,path,p_abort);
			} catch (exception_io_not_found) {
				return false;
			}
		}
		if (!p_filehint->can_seek()) {
			console::formatter() << "loop sampler: file must be seekable, ignores: \"" << file_path_display(path) << "\"";
			return false;
		}
		pfc::string8 buf;
		t_uint32 size;
		p_filehint->seek(0, p_abort);
		p_filehint->read_string_ex(buf, 4, p_abort); // chunkname: RIFF
		if (!!pfc::strcmp_ex(buf, 4, "RIFF", 4))
			return false;
		p_filehint->read_lendian_t(size, p_abort); // chunksize
		p_filehint->read_string_ex(buf, 4, p_abort); // filetype: WAVE
		while (!p_filehint->is_eof(p_abort)) {
			p_filehint->read_string_ex(buf, 4, p_abort); // chunkname
			p_filehint->read_lendian_t(size, p_abort); // chunksize
			if (!!pfc::strcmp_ex(buf, 4, "smpl", 4)) {
				p_filehint->skip(size, p_abort);
				continue;
			}
			stream_reader_limited_ref chunk_reader(p_filehint.get_ptr(), size);
			// chunk found;
/*
        UnsignedInt('manufacturer'),
        UnsignedInt('product'),
        UnsignedInt('sample_period'),
        UnsignedInt('midi_unity_note'),
        UnsignedInt('midi_pitch_fraction'),
        UnsignedInt('smpte_format'),
        UnsignedInt('smpte_offset'),
        UnsignedInt('num_sample_loops'),
        UnsignedInt('sampler_data'),
*/
			t_uint32 i;
			chunk_reader.skip(4 * 7, p_abort);
			chunk_reader.read_lendian_t(i, p_abort);
			chunk_reader.skip(4, p_abort); // sampler_data
			for (; i>0; i--) {
/*
        UnsignedInt('cue_point_id'),
        UnsignedInt('type'),
        UnsignedInt('start'),
        UnsignedInt('end'),
        UnsignedInt('fraction'),
        UnsignedInt('playcount'),
*/
				loop_event_point_simple * point = new service_impl_t<loop_event_point_simple>();
				t_uint32 temp;
				chunk_reader.read_lendian_t(temp, p_abort); // cue_point_id: ignore
				chunk_reader.read_lendian_t(temp, p_abort); // type: currently known: 0 only
				if (temp != 0) {
					pfc::string8 errmsg;
					errmsg << "Unknown sampleloop type: " << temp;
					throw exception_io_data(errmsg);
				}
				chunk_reader.read_lendian_t(temp, p_abort); // start
				point->to = temp;
				chunk_reader.read_lendian_t(temp, p_abort); // end
				point->from = temp;
				chunk_reader.read_lendian_t(temp, p_abort); // fraction
				if (temp != 0) {
					pfc::string8 errmsg;
					errmsg << "Unknown sampleloop fraction: " << temp;
					throw exception_io_data(errmsg);
				}
				chunk_reader.read_lendian_t(temp, p_abort); // playcount
				point->maxrepeats = temp;
				m_points.add_item(point);
			}
		}
		if (m_points.get_count() == 0)
			return false;
		try {
			open_path_helper(m_input, p_filehint, path, p_abort, p_from_redirect,p_skip_hints);
		} catch (exception_io_not_found) {
			return false;
		}
		switch_input(m_input, path);
		switch_points(m_points);
		return true;
	}