mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 10:56:58 +02:00
graphics: replace raw GPU enum values with typed formats
This commit is contained in:
+38
-38
@@ -463,14 +463,14 @@ void TestNormalizedImageContracts() {
|
||||
ImageInfo container {};
|
||||
container.data = {0x10000, 0x15000};
|
||||
container.pixel_format = vk::Format::eR8G8B8A8Unorm;
|
||||
container.guest_format = Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8UNorm);
|
||||
container.guest_format = Prospero::BufferFormat::k8_8_8_8UNorm;
|
||||
container.type = Prospero::ImageType::kColor2D;
|
||||
container.extent = {64, 64, 1};
|
||||
container.resources = {3, 4};
|
||||
container.pitch = 64;
|
||||
container.bytes_per_block = 4;
|
||||
container.samples = 1;
|
||||
container.tile_mode = Prospero::GpuEnumValue(Prospero::TileMode::kStandard64KB);
|
||||
container.tile_mode = Prospero::TileMode::kStandard64KB;
|
||||
container.mip_layout[0] = {0, 0x10000, 64, 64};
|
||||
container.mip_layout[1] = {0x10000, 0x4000, 32, 32};
|
||||
container.mip_layout[2] = {0x14000, 0x1000, 16, 16};
|
||||
@@ -495,7 +495,7 @@ void TestNormalizedImageContracts() {
|
||||
"sample-count mismatch was accepted as a compatible image");
|
||||
|
||||
auto compressed = container;
|
||||
compressed.guest_format = Prospero::GpuEnumValue(Prospero::BufferFormat::kBc3UNorm);
|
||||
compressed.guest_format = Prospero::BufferFormat::kBc3UNorm;
|
||||
compressed.pitch = 128;
|
||||
compressed.extent.height = 64;
|
||||
Check(compressed.BlockExtent() == vk::Extent2D {32, 16},
|
||||
@@ -623,9 +623,9 @@ ImageTestUserData(Prospero::ImageType type = Prospero::ImageType::kColor2D) {
|
||||
std::array<uint32_t, 64> data {};
|
||||
for (uint32_t start = 0; start + 3u < data.size(); start += 4u) {
|
||||
data[start] = 0x1000u + start * 0x100u;
|
||||
data[start + 1u] = Prospero::GpuEnumValue(Prospero::BufferFormat::k8UNorm) << 20u;
|
||||
data[start + 1u] = static_cast<uint32_t>(Prospero::BufferFormat::k8UNorm) << 20u;
|
||||
data[start + 2u] = UINT32_MAX;
|
||||
data[start + 3u] = Prospero::GpuEnumValue(type) << 28u;
|
||||
data[start + 3u] = static_cast<uint32_t>(type) << 28u;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
@@ -633,14 +633,14 @@ ImageTestUserData(Prospero::ImageType type = Prospero::ImageType::kColor2D) {
|
||||
void SetImageTestType(std::array<uint32_t, 64>* data, uint32_t srsrc, Prospero::ImageType type) {
|
||||
const auto type_dword = srsrc * 4u + 3u;
|
||||
Check(data != nullptr && type_dword < data->size(), "invalid image test descriptor source");
|
||||
(*data)[type_dword] = Prospero::GpuEnumValue(type) << 28u;
|
||||
(*data)[type_dword] = static_cast<uint32_t>(type) << 28u;
|
||||
}
|
||||
|
||||
void SetImageTestFormat(std::array<uint32_t, 64>* data, uint32_t srsrc,
|
||||
Prospero::BufferFormat format) {
|
||||
const auto format_dword = srsrc * 4u + 1u;
|
||||
Check(data != nullptr && format_dword < data->size(), "invalid image test descriptor source");
|
||||
(*data)[format_dword] = Prospero::GpuEnumValue(format) << 20u;
|
||||
(*data)[format_dword] = static_cast<uint32_t>(format) << 20u;
|
||||
}
|
||||
|
||||
bool ReadZeroTestMemory(void*, uint64_t, uint32_t* value) {
|
||||
@@ -4518,7 +4518,7 @@ void TestNewShaderRecompilerFormattedStoreUsesRuntimeArrayLengthOnly() {
|
||||
std::array<uint32_t, 64> user_data {};
|
||||
user_data[1] = 4u << 16u;
|
||||
user_data[2] = 5u;
|
||||
user_data[3] = Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt) << 12u;
|
||||
user_data[3] = static_cast<uint32_t>(Prospero::BufferFormat::k32UInt) << 12u;
|
||||
|
||||
ShaderRecompiler::CompileOptions options;
|
||||
options.stage = ShaderType::Compute;
|
||||
@@ -6486,9 +6486,9 @@ void TestNewShaderRecompilerExpPixelOutputs() {
|
||||
|
||||
void TestRenderTargetReverseExportMapping() {
|
||||
const auto format =
|
||||
TextureGetRenderTargetFormat(Prospero::GpuEnumValue(Prospero::ChannelLayout::k16_16_16_16),
|
||||
Prospero::GpuEnumValue(Prospero::ChannelType::kFloat),
|
||||
Prospero::GpuEnumValue(Prospero::ChannelOrder::kReversed));
|
||||
TextureGetRenderTargetFormat(Prospero::ChannelLayout::k16_16_16_16,
|
||||
Prospero::ChannelType::kFloat,
|
||||
Prospero::ChannelOrder::kReversed);
|
||||
Check(format.format == vk::Format::eR16G16B16A16Sfloat && format.bytes_per_element == 8u,
|
||||
"reverse RGBA16F render target did not retain its native host format "
|
||||
"and size");
|
||||
@@ -6501,15 +6501,15 @@ void TestRenderTargetReverseExportMapping() {
|
||||
"reverse RGBA16F render-target export or write-mask mapping is "
|
||||
"incorrect");
|
||||
const auto legacy_alt =
|
||||
TextureGetRenderTargetFormat(Prospero::GpuEnumValue(Prospero::ChannelLayout::k8_8_8_8),
|
||||
Prospero::GpuEnumValue(Prospero::ChannelType::kUNorm),
|
||||
Prospero::GpuEnumValue(Prospero::ChannelOrder::kAlt));
|
||||
TextureGetRenderTargetFormat(Prospero::ChannelLayout::k8_8_8_8,
|
||||
Prospero::ChannelType::kUNorm,
|
||||
Prospero::ChannelOrder::kAlt);
|
||||
Check(legacy_alt.format == vk::Format::eB8G8R8A8Unorm && legacy_alt.export_mapping.IsIdentity(),
|
||||
"legacy BGRA render target acquired a duplicate shader export mapping");
|
||||
const auto gr32 =
|
||||
TextureGetRenderTargetFormat(Prospero::GpuEnumValue(Prospero::ChannelLayout::k32_32),
|
||||
Prospero::GpuEnumValue(Prospero::ChannelType::kFloat),
|
||||
Prospero::GpuEnumValue(Prospero::ChannelOrder::kReversed));
|
||||
TextureGetRenderTargetFormat(Prospero::ChannelLayout::k32_32,
|
||||
Prospero::ChannelType::kFloat,
|
||||
Prospero::ChannelOrder::kReversed);
|
||||
Check(gr32.format == vk::Format::eR32G32Sfloat && gr32.bytes_per_element == 8u &&
|
||||
gr32.export_mapping == Prospero::ColorMappingGr,
|
||||
"reverse GR32F render target did not retain its native host format, "
|
||||
@@ -6550,9 +6550,9 @@ void TestRenderTargetReverseExportMapping() {
|
||||
};
|
||||
for (const auto& mapping_case: mapping_cases) {
|
||||
for (uint32_t order = 0; order < 4u; order++) {
|
||||
const auto info =
|
||||
TextureGetRenderTargetFormat(Prospero::GpuEnumValue(mapping_case.layout),
|
||||
Prospero::GpuEnumValue(mapping_case.type), order);
|
||||
const auto info = TextureGetRenderTargetFormat(
|
||||
mapping_case.layout, mapping_case.type,
|
||||
static_cast<Prospero::ChannelOrder>(order));
|
||||
Check(info.format == mapping_case.format &&
|
||||
info.bytes_per_element == mapping_case.bytes &&
|
||||
info.export_mapping == mapping_case.mappings[order],
|
||||
@@ -6568,47 +6568,47 @@ void TestRenderTargetReverseExportMapping() {
|
||||
}
|
||||
|
||||
const auto alt_1010102 =
|
||||
TextureGetRenderTargetFormat(Prospero::GpuEnumValue(Prospero::ChannelLayout::k10_10_10_2),
|
||||
Prospero::GpuEnumValue(Prospero::ChannelType::kUNorm),
|
||||
Prospero::GpuEnumValue(Prospero::ChannelOrder::kAlt));
|
||||
TextureGetRenderTargetFormat(Prospero::ChannelLayout::k10_10_10_2,
|
||||
Prospero::ChannelType::kUNorm,
|
||||
Prospero::ChannelOrder::kAlt);
|
||||
Check(alt_1010102.format == vk::Format::eA2R10G10B10UnormPack32 &&
|
||||
alt_1010102.export_mapping.IsIdentity(),
|
||||
"native alternate 10:10:10:2 render target acquired a shader mapping");
|
||||
const auto reversed_4444 =
|
||||
TextureGetRenderTargetFormat(Prospero::GpuEnumValue(Prospero::ChannelLayout::k4_4_4_4),
|
||||
Prospero::GpuEnumValue(Prospero::ChannelType::kUNorm),
|
||||
Prospero::GpuEnumValue(Prospero::ChannelOrder::kReversed));
|
||||
TextureGetRenderTargetFormat(Prospero::ChannelLayout::k4_4_4_4,
|
||||
Prospero::ChannelType::kUNorm,
|
||||
Prospero::ChannelOrder::kReversed);
|
||||
Check(reversed_4444.format == vk::Format::eR4G4B4A4UnormPack16 &&
|
||||
reversed_4444.export_mapping.IsIdentity(),
|
||||
"reversed 4:4:4:4 render target did not compose storage and channel "
|
||||
"order");
|
||||
const auto standard_4444 =
|
||||
TextureGetRenderTargetFormat(Prospero::GpuEnumValue(Prospero::ChannelLayout::k4_4_4_4),
|
||||
Prospero::GpuEnumValue(Prospero::ChannelType::kUNorm),
|
||||
Prospero::GpuEnumValue(Prospero::ChannelOrder::kStandard));
|
||||
TextureGetRenderTargetFormat(Prospero::ChannelLayout::k4_4_4_4,
|
||||
Prospero::ChannelType::kUNorm,
|
||||
Prospero::ChannelOrder::kStandard);
|
||||
Check(standard_4444.format == vk::Format::eR4G4B4A4UnormPack16 &&
|
||||
standard_4444.export_mapping == Prospero::ColorMappingAbgr,
|
||||
"standard 4:4:4:4 render target did not compensate host packed-bit "
|
||||
"order");
|
||||
const auto standard_5551 =
|
||||
TextureGetRenderTargetFormat(Prospero::GpuEnumValue(Prospero::ChannelLayout::k5_5_5_1),
|
||||
Prospero::GpuEnumValue(Prospero::ChannelType::kUNorm),
|
||||
Prospero::GpuEnumValue(Prospero::ChannelOrder::kStandard));
|
||||
TextureGetRenderTargetFormat(Prospero::ChannelLayout::k5_5_5_1,
|
||||
Prospero::ChannelType::kUNorm,
|
||||
Prospero::ChannelOrder::kStandard);
|
||||
Check(standard_5551.format == vk::Format::eA1R5G5B5UnormPack16 &&
|
||||
standard_5551.export_mapping == Prospero::ColorMappingBgra,
|
||||
"5:5:5:1 render target did not preserve its high one-bit component");
|
||||
const auto standard_1555 =
|
||||
TextureGetRenderTargetFormat(Prospero::GpuEnumValue(Prospero::ChannelLayout::k1_5_5_5),
|
||||
Prospero::GpuEnumValue(Prospero::ChannelType::kUNorm),
|
||||
Prospero::GpuEnumValue(Prospero::ChannelOrder::kStandard));
|
||||
TextureGetRenderTargetFormat(Prospero::ChannelLayout::k1_5_5_5,
|
||||
Prospero::ChannelType::kUNorm,
|
||||
Prospero::ChannelOrder::kStandard);
|
||||
Check(standard_1555.format == vk::Format::eR5G5B5A1UnormPack16 &&
|
||||
standard_1555.export_mapping == Prospero::ColorMappingAbgr,
|
||||
"1:5:5:5 render target did not preserve its low one-bit component");
|
||||
|
||||
const auto argb =
|
||||
TextureGetRenderTargetFormat(Prospero::GpuEnumValue(Prospero::ChannelLayout::k16_16_16_16),
|
||||
Prospero::GpuEnumValue(Prospero::ChannelType::kFloat),
|
||||
Prospero::GpuEnumValue(Prospero::ChannelOrder::kAltReversed));
|
||||
TextureGetRenderTargetFormat(Prospero::ChannelLayout::k16_16_16_16,
|
||||
Prospero::ChannelType::kFloat,
|
||||
Prospero::ChannelOrder::kAltReversed);
|
||||
Check(argb.export_mapping == Prospero::ColorMappingArgb &&
|
||||
argb.export_mapping.ApplyMask(0x1u) == 0x2u &&
|
||||
argb.export_mapping.ApplyMask(0x2u) == 0x4u &&
|
||||
|
||||
Reference in New Issue
Block a user