mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 19:07:01 +02:00
Validate texture descriptor fields
This commit is contained in:
@@ -62,6 +62,13 @@ bool NullImageDescriptor(const DescriptorValue& descriptor) {
|
||||
}
|
||||
|
||||
bool ValidImageDescriptor(const DescriptorValue& descriptor, bool r128 = false) {
|
||||
const auto& words = descriptor.dwords;
|
||||
// Reject texture descriptors with nonzero reserved bits.
|
||||
if ((words[1] & 0x20000000u) != 0u || (words[2] & 0xf0003000u) != 0u ||
|
||||
(!r128 && ((words[4] & 0xe000e000u) != 0u || (words[5] & 0xf9000000u) != 0u ||
|
||||
(words[6] & 0x00007b00u) != 0u))) {
|
||||
return false;
|
||||
}
|
||||
const auto type = static_cast<Prospero::ImageType>((descriptor.dwords[3] >> 28u) & 0xfu);
|
||||
const auto format = static_cast<Prospero::BufferFormat>((descriptor.dwords[1] >> 20u) & 0x1ffu);
|
||||
if (type < Prospero::ImageType::kColor1D || format == Prospero::BufferFormat::kInvalid ||
|
||||
@@ -72,6 +79,13 @@ bool ValidImageDescriptor(const DescriptorValue& descriptor, bool r128 = false)
|
||||
type != Prospero::ImageType::kColor2DMsaa) {
|
||||
return false;
|
||||
}
|
||||
const bool array = type == Prospero::ImageType::kColor1DArray ||
|
||||
type == Prospero::ImageType::kColor2DArray ||
|
||||
type == Prospero::ImageType::kColor2DMsaaArray ||
|
||||
type == Prospero::ImageType::kCube;
|
||||
if (array && ((words[4] >> 16u) & 0x1fffu) > (words[4] & 0x1fffu)) {
|
||||
return false;
|
||||
}
|
||||
if (type == Prospero::ImageType::kColor2DMsaa ||
|
||||
type == Prospero::ImageType::kColor2DMsaaArray) {
|
||||
const auto base_level = (descriptor.dwords[3] >> 12u) & 0xfu;
|
||||
|
||||
Reference in New Issue
Block a user