early-access version 3818
This commit is contained in:
parent
af220eff75
commit
9a361b563a
5 changed files with 52 additions and 9 deletions
|
@ -1,7 +1,7 @@
|
||||||
yuzu emulator early access
|
yuzu emulator early access
|
||||||
=============
|
=============
|
||||||
|
|
||||||
This is the source code for early-access 3817.
|
This is the source code for early-access 3818.
|
||||||
|
|
||||||
## Legal Notice
|
## Legal Notice
|
||||||
|
|
||||||
|
|
|
@ -31,13 +31,9 @@ XCI::XCI(VirtualFile file_, u64 program_id, size_t program_index)
|
||||||
: file(std::move(file_)), program_nca_status{Loader::ResultStatus::ErrorXCIMissingProgramNCA},
|
: file(std::move(file_)), program_nca_status{Loader::ResultStatus::ErrorXCIMissingProgramNCA},
|
||||||
partitions(partition_names.size()),
|
partitions(partition_names.size()),
|
||||||
partitions_raw(partition_names.size()), keys{Core::Crypto::KeyManager::Instance()} {
|
partitions_raw(partition_names.size()), keys{Core::Crypto::KeyManager::Instance()} {
|
||||||
if (file->ReadObject(&header) != sizeof(GamecardHeader)) {
|
const auto header_status = TryReadHeader();
|
||||||
status = Loader::ResultStatus::ErrorBadXCIHeader;
|
if (header_status != Loader::ResultStatus::Success) {
|
||||||
return;
|
status = header_status;
|
||||||
}
|
|
||||||
|
|
||||||
if (header.magic != Common::MakeMagic('H', 'E', 'A', 'D')) {
|
|
||||||
status = Loader::ResultStatus::ErrorBadXCIHeader;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,6 +312,44 @@ Loader::ResultStatus XCI::AddNCAFromPartition(XCIPartition part) {
|
||||||
return Loader::ResultStatus::Success;
|
return Loader::ResultStatus::Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loader::ResultStatus XCI::TryReadHeader() {
|
||||||
|
constexpr size_t CardInitialDataRegionSize = 0x1000;
|
||||||
|
|
||||||
|
// Define the function we'll use to determine if we read a valid header.
|
||||||
|
const auto ReadCardHeader = [&]() {
|
||||||
|
// Ensure we can read the entire header. If we can't, we can't read the card image.
|
||||||
|
if (file->ReadObject(&header) != sizeof(GamecardHeader)) {
|
||||||
|
return Loader::ResultStatus::ErrorBadXCIHeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure the header magic matches. If it doesn't, this isn't a card image header.
|
||||||
|
if (header.magic != Common::MakeMagic('H', 'E', 'A', 'D')) {
|
||||||
|
return Loader::ResultStatus::ErrorBadXCIHeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
// We read a card image header.
|
||||||
|
return Loader::ResultStatus::Success;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Try to read the header directly.
|
||||||
|
if (ReadCardHeader() == Loader::ResultStatus::Success) {
|
||||||
|
return Loader::ResultStatus::Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the size of the file.
|
||||||
|
const size_t card_image_size = file->GetSize();
|
||||||
|
|
||||||
|
// If we are large enough to have a key area, offset past the key area and retry.
|
||||||
|
if (card_image_size >= CardInitialDataRegionSize) {
|
||||||
|
file = std::make_shared<OffsetVfsFile>(file, card_image_size - CardInitialDataRegionSize,
|
||||||
|
CardInitialDataRegionSize);
|
||||||
|
return ReadCardHeader();
|
||||||
|
}
|
||||||
|
|
||||||
|
// We had no header and aren't large enough to have a key area, so this can't be parsed.
|
||||||
|
return Loader::ResultStatus::ErrorBadXCIHeader;
|
||||||
|
}
|
||||||
|
|
||||||
u8 XCI::GetFormatVersion() {
|
u8 XCI::GetFormatVersion() {
|
||||||
return GetLogoPartition() == nullptr ? 0x1 : 0x2;
|
return GetLogoPartition() == nullptr ? 0x1 : 0x2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,6 +128,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Loader::ResultStatus AddNCAFromPartition(XCIPartition part);
|
Loader::ResultStatus AddNCAFromPartition(XCIPartition part);
|
||||||
|
Loader::ResultStatus TryReadHeader();
|
||||||
|
|
||||||
VirtualFile file;
|
VirtualFile file;
|
||||||
GamecardHeader header{};
|
GamecardHeader header{};
|
||||||
|
|
|
@ -126,7 +126,7 @@ struct FormatTuple {
|
||||||
{VK_FORMAT_A1R5G5B5_UNORM_PACK16, Attachable}, // A1R5G5B5_UNORM
|
{VK_FORMAT_A1R5G5B5_UNORM_PACK16, Attachable}, // A1R5G5B5_UNORM
|
||||||
{VK_FORMAT_A2B10G10R10_UNORM_PACK32, Attachable | Storage}, // A2B10G10R10_UNORM
|
{VK_FORMAT_A2B10G10R10_UNORM_PACK32, Attachable | Storage}, // A2B10G10R10_UNORM
|
||||||
{VK_FORMAT_A2B10G10R10_UINT_PACK32, Attachable | Storage}, // A2B10G10R10_UINT
|
{VK_FORMAT_A2B10G10R10_UINT_PACK32, Attachable | Storage}, // A2B10G10R10_UINT
|
||||||
{VK_FORMAT_A2R10G10B10_UNORM_PACK32, Attachable | Storage}, // A2R10G10B10_UNORM
|
{VK_FORMAT_A2R10G10B10_UNORM_PACK32, Attachable}, // A2R10G10B10_UNORM
|
||||||
{VK_FORMAT_A1R5G5B5_UNORM_PACK16, Attachable}, // A1B5G5R5_UNORM (flipped with swizzle)
|
{VK_FORMAT_A1R5G5B5_UNORM_PACK16, Attachable}, // A1B5G5R5_UNORM (flipped with swizzle)
|
||||||
{VK_FORMAT_R5G5B5A1_UNORM_PACK16}, // A5B5G5R1_UNORM (specially swizzled)
|
{VK_FORMAT_R5G5B5A1_UNORM_PACK16}, // A5B5G5R1_UNORM (specially swizzled)
|
||||||
{VK_FORMAT_R8_UNORM, Attachable | Storage}, // R8_UNORM
|
{VK_FORMAT_R8_UNORM, Attachable | Storage}, // R8_UNORM
|
||||||
|
|
|
@ -71,6 +71,11 @@ constexpr std::array R8G8B8_SSCALED{
|
||||||
VK_FORMAT_UNDEFINED,
|
VK_FORMAT_UNDEFINED,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constexpr std::array VK_FORMAT_R32G32B32_SFLOAT{
|
||||||
|
VK_FORMAT_R32G32B32A32_SFLOAT,
|
||||||
|
VK_FORMAT_UNDEFINED,
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace Alternatives
|
} // namespace Alternatives
|
||||||
|
|
||||||
enum class NvidiaArchitecture {
|
enum class NvidiaArchitecture {
|
||||||
|
@ -103,6 +108,8 @@ constexpr const VkFormat* GetFormatAlternatives(VkFormat format) {
|
||||||
return Alternatives::R16G16B16_SSCALED.data();
|
return Alternatives::R16G16B16_SSCALED.data();
|
||||||
case VK_FORMAT_R8G8B8_SSCALED:
|
case VK_FORMAT_R8G8B8_SSCALED:
|
||||||
return Alternatives::R8G8B8_SSCALED.data();
|
return Alternatives::R8G8B8_SSCALED.data();
|
||||||
|
case VK_FORMAT_R32G32B32_SFLOAT:
|
||||||
|
return Alternatives::VK_FORMAT_R32G32B32_SFLOAT.data();
|
||||||
default:
|
default:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
@ -130,6 +137,7 @@ std::unordered_map<VkFormat, VkFormatProperties> GetFormatProperties(vk::Physica
|
||||||
VK_FORMAT_A2B10G10R10_UINT_PACK32,
|
VK_FORMAT_A2B10G10R10_UINT_PACK32,
|
||||||
VK_FORMAT_A2B10G10R10_UNORM_PACK32,
|
VK_FORMAT_A2B10G10R10_UNORM_PACK32,
|
||||||
VK_FORMAT_A2B10G10R10_USCALED_PACK32,
|
VK_FORMAT_A2B10G10R10_USCALED_PACK32,
|
||||||
|
VK_FORMAT_A2R10G10B10_UNORM_PACK32,
|
||||||
VK_FORMAT_A8B8G8R8_SINT_PACK32,
|
VK_FORMAT_A8B8G8R8_SINT_PACK32,
|
||||||
VK_FORMAT_A8B8G8R8_SNORM_PACK32,
|
VK_FORMAT_A8B8G8R8_SNORM_PACK32,
|
||||||
VK_FORMAT_A8B8G8R8_SRGB_PACK32,
|
VK_FORMAT_A8B8G8R8_SRGB_PACK32,
|
||||||
|
|
Loading…
Reference in a new issue