This commit is contained in:
		
							parent
							
								
									baff796eb8
								
							
						
					
					
						commit
						6065ab1636
					
				
					 2 changed files with 21 additions and 10 deletions
				
			
		|  | @ -2,13 +2,18 @@ | ||||||
| 
 | 
 | ||||||
| namespace lt::assets { | namespace lt::assets { | ||||||
| 
 | 
 | ||||||
|  | constexpr auto total_metadata_size =         //
 | ||||||
|  |     sizeof(AssetMetadata::type)              //
 | ||||||
|  |     + sizeof(AssetMetadata::version)         //
 | ||||||
|  |     + sizeof(ShaderAsset::Metadata::type)    //
 | ||||||
|  |     + sizeof(BlobMetadata::tag)              //
 | ||||||
|  |     + sizeof(BlobMetadata::offset)           //
 | ||||||
|  |     + sizeof(BlobMetadata::compression_type) //
 | ||||||
|  |     + sizeof(BlobMetadata::compressed_size)  //
 | ||||||
|  |     + sizeof(BlobMetadata::uncompressed_size); | ||||||
|  | 
 | ||||||
| ShaderAsset::ShaderAsset(const std::filesystem::path &path): m_stream(path) | ShaderAsset::ShaderAsset(const std::filesystem::path &path): m_stream(path) | ||||||
| { | { | ||||||
| 	constexpr auto total_metadata_size = //
 |  | ||||||
| 	    sizeof(AssetMetadata)            //
 |  | ||||||
| 	    + sizeof(Metadata)               //
 |  | ||||||
| 	    + sizeof(BlobMetadata); |  | ||||||
| 
 |  | ||||||
| 	ensure(m_stream.is_open(), "Failed to open shader asset at: {}", path.string()); | 	ensure(m_stream.is_open(), "Failed to open shader asset at: {}", path.string()); | ||||||
| 	const auto read = [this](auto &field) { | 	const auto read = [this](auto &field) { | ||||||
| 		m_stream.read(std::bit_cast<char *>(&field), sizeof(field)); | 		m_stream.read(std::bit_cast<char *>(&field), sizeof(field)); | ||||||
|  | @ -85,9 +90,10 @@ ShaderAsset::ShaderAsset(const std::filesystem::path &path): m_stream(path) | ||||||
| 		destination, | 		destination, | ||||||
| 		std::ios::binary | std::ios::trunc, | 		std::ios::binary | std::ios::trunc, | ||||||
| 	}; | 	}; | ||||||
|  | 
 | ||||||
| 	const auto code_blob_metadata = BlobMetadata { | 	const auto code_blob_metadata = BlobMetadata { | ||||||
| 		.tag = std::to_underlying(BlobTag::code), | 		.tag = std::to_underlying(BlobTag::code), | ||||||
| 		.offset = static_cast<size_t>(stream.tellp()) + sizeof(BlobMetadata), | 		.offset = total_metadata_size, | ||||||
| 		.compression_type = CompressionType::none, | 		.compression_type = CompressionType::none, | ||||||
| 		.compressed_size = code_blob.size(), | 		.compressed_size = code_blob.size(), | ||||||
| 		.uncompressed_size = code_blob.size(), | 		.uncompressed_size = code_blob.size(), | ||||||
|  |  | ||||||
|  | @ -41,9 +41,14 @@ Suite packing = "shader_pack"_suite = [] { | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		const auto expected_size =                    //
 | 		const auto expected_size =                    //
 | ||||||
| 		    sizeof(AssetMetadata)           //
 | 		    sizeof(AssetMetadata::type)               //
 | ||||||
| 		    + sizeof(ShaderAsset::Metadata) //
 | 		    + sizeof(AssetMetadata::version)          //
 | ||||||
| 		    + sizeof(BlobMetadata)          //
 | 		    + sizeof(ShaderAsset::Metadata::type)     //
 | ||||||
|  | 		    + sizeof(BlobMetadata::tag)               //
 | ||||||
|  | 		    + sizeof(BlobMetadata::offset)            //
 | ||||||
|  | 		    + sizeof(BlobMetadata::compression_type)  //
 | ||||||
|  | 		    + sizeof(BlobMetadata::compressed_size)   //
 | ||||||
|  | 		    + sizeof(BlobMetadata::uncompressed_size) //
 | ||||||
| 		    + dummy_blob.size(); | 		    + dummy_blob.size(); | ||||||
| 
 | 
 | ||||||
| 		ShaderAsset::pack( | 		ShaderAsset::pack( | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue