From 21aa7b66cef1a5168c073436ffd7fe030692d8fc Mon Sep 17 00:00:00 2001 From: nmzik Date: Tue, 11 Aug 2026 11:32:43 +0200 Subject: [PATCH] graphics: replace raw GPU enum values with typed formats --- .../command_processor/pm4Handlers.cpp | 56 +- src/graphics/guest_gpu/gpu_defs.h | 7 - src/graphics/guest_gpu/gpu_format.cpp | 186 ++--- src/graphics/guest_gpu/gpu_format.h | 27 +- src/graphics/guest_gpu/hardwareContext.h | 70 +- src/graphics/guest_gpu/tile.cpp | 73 +- src/graphics/guest_gpu/tile.h | 44 +- .../host_gpu/renderer/cache/textureCache.cpp | 14 +- .../host_gpu/renderer/colorRenderTarget.cpp | 34 +- src/graphics/host_gpu/renderer/debug.cpp | 81 ++- src/graphics/host_gpu/renderer/debug.h | 2 +- .../host_gpu/renderer/depthRenderTarget.cpp | 35 +- .../host_gpu/renderer/image/image.cpp | 12 +- src/graphics/host_gpu/renderer/image/image.h | 4 +- .../host_gpu/renderer/image/imageInfo.h | 72 +- .../host_gpu/renderer/image/textureCommon.cpp | 76 +- .../host_gpu/renderer/image/textureCommon.h | 15 +- .../renderer/pipeline/descriptors.cpp | 107 ++- .../host_gpu/renderer/pipeline/shaders.cpp | 17 +- .../host_gpu/renderer/renderCompute.cpp | 8 +- src/graphics/host_gpu/renderer/renderDraw.cpp | 34 +- src/graphics/host_gpu/vulkanCommon.cpp | 10 +- src/graphics/host_gpu/vulkanCommon.h | 4 +- src/graphics/presentation/videoOut.cpp | 3 +- .../recompiler/emitter/spirvEmitterInternal.h | 3 +- .../recompiler/emitter/spirvEmitterMemory.cpp | 7 +- .../recompiler/emitter/spirvEmitterModule.cpp | 40 +- .../recompiler/ir/ResourceMaterialization.cpp | 20 +- src/graphics/shader/recompiler/ir/ShaderIR.h | 23 +- src/graphics/shader/shader.cpp | 30 +- src/graphics/shader/shaderBindings.cpp | 2 +- src/graphics/shader/shaderBindings.h | 40 +- src/libs/agc.cpp | 10 +- tests/ResourceTrackingTests.cpp | 30 +- tests/ShaderRecompilerComputeTests.cpp | 686 +++++++++--------- tests/shaderCfgTests.cpp | 76 +- 36 files changed, 1002 insertions(+), 956 deletions(-) diff --git a/src/graphics/guest_gpu/command_processor/pm4Handlers.cpp b/src/graphics/guest_gpu/command_processor/pm4Handlers.cpp index 9e300884a..fca4c6f31 100644 --- a/src/graphics/guest_gpu/command_processor/pm4Handlers.cpp +++ b/src/graphics/guest_gpu/command_processor/pm4Handlers.cpp @@ -526,9 +526,12 @@ KYTY_HW_CTX_PARSER(HwCtxSetColorInfo) { // r.format = (buffer[4] >> 2u) & 0x1fu; // r.channel_type = (buffer[4] >> 8u) & 0x7u; // r.channel_order = (buffer[4] >> 11u) & 0x3u; - r.format = KYTY_PM4_GET(buffer[0], CB_COLOR0_INFO, FORMAT); - r.channel_type = KYTY_PM4_GET(buffer[0], CB_COLOR0_INFO, NUMBER_TYPE); - r.channel_order = KYTY_PM4_GET(buffer[0], CB_COLOR0_INFO, COMP_SWAP); + r.format = + static_cast(KYTY_PM4_GET(buffer[0], CB_COLOR0_INFO, FORMAT)); + r.channel_type = + static_cast(KYTY_PM4_GET(buffer[0], CB_COLOR0_INFO, NUMBER_TYPE)); + r.channel_order = + static_cast(KYTY_PM4_GET(buffer[0], CB_COLOR0_INFO, COMP_SWAP)); r.cmask_fast_clear_enable = KYTY_PM4_GET(buffer[0], CB_COLOR0_INFO, FAST_CLEAR) != 0; r.fmask_compression_enable = KYTY_PM4_GET(buffer[0], CB_COLOR0_INFO, COMPRESSION) != 0; r.blend_clamp = KYTY_PM4_GET(buffer[0], CB_COLOR0_INFO, BLEND_CLAMP) != 0; @@ -1042,9 +1045,12 @@ KYTY_HW_CTX_PARSER(HwCtxSetRenderTarget) { // info.format = (buffer[4] >> 2u) & 0x1fu; // info.channel_type = (buffer[4] >> 8u) & 0x7u; // info.channel_order = (buffer[4] >> 11u) & 0x3u; - info.format = KYTY_PM4_GET(buffer[4], CB_COLOR0_INFO, FORMAT); - info.channel_type = KYTY_PM4_GET(buffer[4], CB_COLOR0_INFO, NUMBER_TYPE); - info.channel_order = KYTY_PM4_GET(buffer[4], CB_COLOR0_INFO, COMP_SWAP); + info.format = + static_cast(KYTY_PM4_GET(buffer[4], CB_COLOR0_INFO, FORMAT)); + info.channel_type = + static_cast(KYTY_PM4_GET(buffer[4], CB_COLOR0_INFO, NUMBER_TYPE)); + info.channel_order = + static_cast(KYTY_PM4_GET(buffer[4], CB_COLOR0_INFO, COMP_SWAP)); info.cmask_fast_clear_enable = KYTY_PM4_GET(buffer[4], CB_COLOR0_INFO, FAST_CLEAR) != 0; info.fmask_compression_enable = KYTY_PM4_GET(buffer[4], CB_COLOR0_INFO, COMPRESSION) != 0; info.blend_clamp = KYTY_PM4_GET(buffer[4], CB_COLOR0_INFO, BLEND_CLAMP) != 0; @@ -1066,10 +1072,12 @@ KYTY_HW_CTX_PARSER(HwCtxSetRenderTarget) { // attrib.num_fragments = (buffer[5] >> 15u) & 0x3u; attrib.force_dest_alpha_to_one = KYTY_PM4_GET(buffer[5], CB_COLOR0_ATTRIB, FORCE_DST_ALPHA_1) != 0; - attrib.tile_mode = KYTY_PM4_GET(buffer[5], CB_COLOR0_ATTRIB, TILE_MODE_INDEX); - attrib.fmask_tile_mode = KYTY_PM4_GET(buffer[5], CB_COLOR0_ATTRIB, FMASK_TILE_MODE_INDEX); - attrib.num_samples = KYTY_PM4_GET(buffer[5], CB_COLOR0_ATTRIB, NUM_SAMPLES); - attrib.num_fragments = KYTY_PM4_GET(buffer[5], CB_COLOR0_ATTRIB, NUM_FRAGMENTS); + attrib.tile_mode = + static_cast(KYTY_PM4_GET(buffer[5], CB_COLOR0_ATTRIB, TILE_MODE_INDEX)); + attrib.fmask_tile_mode = static_cast( + KYTY_PM4_GET(buffer[5], CB_COLOR0_ATTRIB, FMASK_TILE_MODE_INDEX)); + attrib.num_samples = KYTY_PM4_GET(buffer[5], CB_COLOR0_ATTRIB, NUM_SAMPLES); + attrib.num_fragments = KYTY_PM4_GET(buffer[5], CB_COLOR0_ATTRIB, NUM_FRAGMENTS); // dcc.max_uncompressed_block_size = (buffer[6] >> 2u) & 0x3u; // dcc.max_compressed_block_size = (buffer[6] >> 5u) & 0x3u; @@ -1568,7 +1576,7 @@ KYTY_HW_UC_PARSER(HwUcSetPrimitiveType) { uint32_t prim_type = KYTY_PM4_GET(buffer[0], VGT_PRIMITIVE_TYPE, PRIM_TYPE); - cp.GetUcfg().SetPrimitiveType(prim_type); + cp.GetUcfg().SetPrimitiveType(static_cast(prim_type)); return 1; } @@ -3106,9 +3114,12 @@ void GraphicsInitJmpTablesCxIndirect() { g_hw_ctx_indirect_func[cmd_offset] = [](KYTY_HW_CTX_INDIRECT_ARGS) { uint32_t slot = (cmd_offset - Pm4::CB_COLOR0_INFO) / 15; HW::ColorInfo info; - info.format = KYTY_PM4_GET(value, CB_COLOR0_INFO, FORMAT); - info.channel_type = KYTY_PM4_GET(value, CB_COLOR0_INFO, NUMBER_TYPE); - info.channel_order = KYTY_PM4_GET(value, CB_COLOR0_INFO, COMP_SWAP); + info.format = + static_cast(KYTY_PM4_GET(value, CB_COLOR0_INFO, FORMAT)); + info.channel_type = static_cast( + KYTY_PM4_GET(value, CB_COLOR0_INFO, NUMBER_TYPE)); + info.channel_order = + static_cast(KYTY_PM4_GET(value, CB_COLOR0_INFO, COMP_SWAP)); info.cmask_fast_clear_enable = KYTY_PM4_GET(value, CB_COLOR0_INFO, FAST_CLEAR) != 0; info.fmask_compression_enable = KYTY_PM4_GET(value, CB_COLOR0_INFO, COMPRESSION) != 0; info.blend_clamp = KYTY_PM4_GET(value, CB_COLOR0_INFO, BLEND_CLAMP) != 0; @@ -3133,10 +3144,12 @@ void GraphicsInitJmpTablesCxIndirect() { HW::ColorAttrib attrib; attrib.force_dest_alpha_to_one = KYTY_PM4_GET(value, CB_COLOR0_ATTRIB, FORCE_DST_ALPHA_1) != 0; - attrib.tile_mode = KYTY_PM4_GET(value, CB_COLOR0_ATTRIB, TILE_MODE_INDEX); - attrib.fmask_tile_mode = KYTY_PM4_GET(value, CB_COLOR0_ATTRIB, FMASK_TILE_MODE_INDEX); - attrib.num_samples = KYTY_PM4_GET(value, CB_COLOR0_ATTRIB, NUM_SAMPLES); - attrib.num_fragments = KYTY_PM4_GET(value, CB_COLOR0_ATTRIB, NUM_FRAGMENTS); + attrib.tile_mode = static_cast( + KYTY_PM4_GET(value, CB_COLOR0_ATTRIB, TILE_MODE_INDEX)); + attrib.fmask_tile_mode = static_cast( + KYTY_PM4_GET(value, CB_COLOR0_ATTRIB, FMASK_TILE_MODE_INDEX)); + attrib.num_samples = KYTY_PM4_GET(value, CB_COLOR0_ATTRIB, NUM_SAMPLES); + attrib.num_fragments = KYTY_PM4_GET(value, CB_COLOR0_ATTRIB, NUM_FRAGMENTS); cp.GetCtx().SetColorAttrib(slot, attrib); }; } @@ -3290,8 +3303,9 @@ void GraphicsInitJmpTablesCxIndirect() { g_hw_ctx_indirect_func[cmd_offset] = [](KYTY_HW_CTX_INDIRECT_ARGS) { uint32_t slot = (cmd_offset - Pm4::CB_COLOR0_ATTRIB3); HW::ColorAttrib3 attrib3; - attrib3.depth = KYTY_PM4_GET(value, CB_COLOR0_ATTRIB3, MIP0_DEPTH); - attrib3.tile_mode = KYTY_PM4_GET(value, CB_COLOR0_ATTRIB3, COLOR_SW_MODE); + attrib3.depth = KYTY_PM4_GET(value, CB_COLOR0_ATTRIB3, MIP0_DEPTH); + attrib3.tile_mode = static_cast( + KYTY_PM4_GET(value, CB_COLOR0_ATTRIB3, COLOR_SW_MODE)); attrib3.dimension = KYTY_PM4_GET(value, CB_COLOR0_ATTRIB3, RESOURCE_TYPE); attrib3.cmask_pipe_aligned = KYTY_PM4_GET(value, CB_COLOR0_ATTRIB3, CMASK_PIPE_ALIGNED); attrib3.dcc_pipe_aligned = KYTY_PM4_GET(value, CB_COLOR0_ATTRIB3, DCC_PIPE_ALIGNED); @@ -4467,7 +4481,7 @@ void GraphicsInitJmpTablesUcIndirect() { g_hw_uc_indirect_func[Pm4::VGT_PRIMITIVE_TYPE] = [](KYTY_HW_UC_INDIRECT_ARGS) { uint32_t prim_type = KYTY_PM4_GET(value, VGT_PRIMITIVE_TYPE, PRIM_TYPE); - cp.GetUcfg().SetPrimitiveType(prim_type); + cp.GetUcfg().SetPrimitiveType(static_cast(prim_type)); }; g_hw_uc_indirect_func[Pm4::VGT_INDEX_TYPE] = [](KYTY_HW_UC_INDIRECT_ARGS) { cp.SetIndexType(value & 0x3u); diff --git a/src/graphics/guest_gpu/gpu_defs.h b/src/graphics/guest_gpu/gpu_defs.h index 1b7f1b164..a5bc1f275 100644 --- a/src/graphics/guest_gpu/gpu_defs.h +++ b/src/graphics/guest_gpu/gpu_defs.h @@ -3,15 +3,8 @@ #include "common/common.h" -#include - namespace Libs::Graphics::Prospero { -template -constexpr auto GpuEnumValue(T value) { - return static_cast>(value); -} - enum class PrimitiveType : uint32_t { kNone = 0, kPointList = 1, diff --git a/src/graphics/guest_gpu/gpu_format.cpp b/src/graphics/guest_gpu/gpu_format.cpp index 507b06f2a..c8ac55868 100644 --- a/src/graphics/guest_gpu/gpu_format.cpp +++ b/src/graphics/guest_gpu/gpu_format.cpp @@ -9,83 +9,83 @@ namespace Libs::Graphics::Prospero { namespace { struct FormatInfo { - uint32_t format; - uint32_t bytes_per_element; - uint32_t block_compressed_bytes_per_block; - uint32_t render_target_bytes_per_element; - bool supported_sampled_texture_format; - bool unsigned_integer_texture_format; + BufferFormat format; + uint32_t bytes_per_element; + uint32_t block_compressed_bytes_per_block; + uint32_t render_target_bytes_per_element; + bool supported_sampled_texture_format; + bool unsigned_integer_texture_format; }; constexpr FormatInfo kFormatInfo[] = { - {GpuEnumValue(BufferFormat::k8UNorm), 1, 0, 1, true, false}, - {GpuEnumValue(BufferFormat::k8SNorm), 0, 0, 1, false, false}, - {GpuEnumValue(BufferFormat::k8UInt), 1, 0, 1, true, true}, - {GpuEnumValue(BufferFormat::k16UNorm), 2, 0, 2, true, false}, - {GpuEnumValue(BufferFormat::k16SNorm), 2, 0, 2, true, false}, - {GpuEnumValue(BufferFormat::k16UInt), 2, 0, 2, true, true}, - {GpuEnumValue(BufferFormat::k16SInt), 2, 0, 2, false, false}, - {GpuEnumValue(BufferFormat::k16Float), 2, 0, 2, true, false}, - {GpuEnumValue(BufferFormat::k8_8UNorm), 2, 0, 2, true, false}, - {GpuEnumValue(BufferFormat::k8_8SNorm), 2, 0, 2, true, false}, - {GpuEnumValue(BufferFormat::k8_8UInt), 2, 0, 2, true, true}, - {GpuEnumValue(BufferFormat::k8_8SInt), 2, 0, 2, false, false}, - {GpuEnumValue(BufferFormat::k32UInt), 4, 0, 4, true, true}, - {GpuEnumValue(BufferFormat::k32SInt), 4, 0, 4, false, false}, - {GpuEnumValue(BufferFormat::k32Float), 4, 0, 4, true, false}, - {GpuEnumValue(BufferFormat::k16_16UNorm), 4, 0, 4, true, false}, - {GpuEnumValue(BufferFormat::k16_16SNorm), 4, 0, 4, true, false}, - {GpuEnumValue(BufferFormat::k16_16UInt), 4, 0, 4, true, true}, - {GpuEnumValue(BufferFormat::k16_16SInt), 4, 0, 4, false, false}, - {GpuEnumValue(BufferFormat::k16_16Float), 4, 0, 4, true, false}, - {GpuEnumValue(BufferFormat::k11_11_10Float), 4, 0, 4, true, false}, - {GpuEnumValue(BufferFormat::k10_10_10_2UNorm), 4, 0, 4, true, false}, - {GpuEnumValue(BufferFormat::k10_10_10_2UInt), 4, 0, 4, true, true}, - {GpuEnumValue(BufferFormat::k8_8_8_8UNorm), 4, 0, 4, true, false}, - {GpuEnumValue(BufferFormat::k8_8_8_8SNorm), 4, 0, 4, true, false}, - {GpuEnumValue(BufferFormat::k8_8_8_8UInt), 4, 0, 4, true, true}, - {GpuEnumValue(BufferFormat::k8_8_8_8SInt), 4, 0, 4, false, false}, - {GpuEnumValue(BufferFormat::k32_32UInt), 8, 0, 8, true, true}, - {GpuEnumValue(BufferFormat::k32_32SInt), 8, 0, 8, false, false}, - {GpuEnumValue(BufferFormat::k32_32Float), 8, 0, 8, true, false}, - {GpuEnumValue(BufferFormat::k16_16_16_16UNorm), 8, 0, 8, true, false}, - {GpuEnumValue(BufferFormat::k16_16_16_16SNorm), 8, 0, 8, true, false}, - {GpuEnumValue(BufferFormat::k16_16_16_16UInt), 8, 0, 8, true, true}, - {GpuEnumValue(BufferFormat::k16_16_16_16SInt), 8, 0, 8, false, false}, - {GpuEnumValue(BufferFormat::k16_16_16_16Float), 8, 0, 8, true, false}, - {GpuEnumValue(BufferFormat::k32_32_32UInt), 12, 0, 12, true, true}, - {GpuEnumValue(BufferFormat::k32_32_32SInt), 12, 0, 12, false, false}, - {GpuEnumValue(BufferFormat::k32_32_32Float), 12, 0, 12, true, false}, - {GpuEnumValue(BufferFormat::k32_32_32_32UInt), 16, 0, 16, true, true}, - {GpuEnumValue(BufferFormat::k32_32_32_32SInt), 16, 0, 16, false, false}, - {GpuEnumValue(BufferFormat::k32_32_32_32Float), 16, 0, 16, true, false}, - {GpuEnumValue(BufferFormat::k8Srgb), 1, 0, 0, true, false}, - {GpuEnumValue(BufferFormat::k8_8Srgb), 2, 0, 0, true, false}, - {GpuEnumValue(BufferFormat::k8_8_8_8Srgb), 4, 0, 4, true, false}, - {GpuEnumValue(BufferFormat::k9_9_9_5Float), 4, 0, 0, true, false}, - {GpuEnumValue(BufferFormat::k5_6_5UNorm), 2, 0, 2, true, false}, - {GpuEnumValue(BufferFormat::k5_5_5_1UNorm), 2, 0, 2, true, false}, - {GpuEnumValue(BufferFormat::k1_5_5_5UNorm), 0, 0, 2, false, false}, - {GpuEnumValue(BufferFormat::k4_4_4_4UNorm), 2, 0, 2, true, false}, - {GpuEnumValue(BufferFormat::kFmask8_S4_F4), 1, 0, 1, true, false}, - {GpuEnumValue(BufferFormat::kBc1UNorm), 0, 8, 0, true, false}, - {GpuEnumValue(BufferFormat::kBc1Srgb), 0, 8, 0, true, false}, - {GpuEnumValue(BufferFormat::kBc2UNorm), 0, 16, 0, true, false}, - {GpuEnumValue(BufferFormat::kBc2Srgb), 0, 16, 0, true, false}, - {GpuEnumValue(BufferFormat::kBc3UNorm), 0, 16, 0, true, false}, - {GpuEnumValue(BufferFormat::kBc3Srgb), 0, 16, 0, true, false}, - {GpuEnumValue(BufferFormat::kBc4UNorm), 0, 8, 0, true, false}, - {GpuEnumValue(BufferFormat::kBc4SNorm), 0, 8, 0, true, false}, - {GpuEnumValue(BufferFormat::kBc5UNorm), 0, 16, 0, true, false}, - {GpuEnumValue(BufferFormat::kBc5SNorm), 0, 16, 0, true, false}, - {GpuEnumValue(BufferFormat::kBc6UFloat), 0, 16, 0, true, false}, - {GpuEnumValue(BufferFormat::kBc6SFloat), 0, 16, 0, true, false}, - {GpuEnumValue(BufferFormat::kBc7UNorm), 0, 16, 0, true, false}, - {GpuEnumValue(BufferFormat::kBc7Srgb), 0, 16, 0, true, false}, + {BufferFormat::k8UNorm, 1, 0, 1, true, false}, + {BufferFormat::k8SNorm, 0, 0, 1, false, false}, + {BufferFormat::k8UInt, 1, 0, 1, true, true}, + {BufferFormat::k16UNorm, 2, 0, 2, true, false}, + {BufferFormat::k16SNorm, 2, 0, 2, true, false}, + {BufferFormat::k16UInt, 2, 0, 2, true, true}, + {BufferFormat::k16SInt, 2, 0, 2, false, false}, + {BufferFormat::k16Float, 2, 0, 2, true, false}, + {BufferFormat::k8_8UNorm, 2, 0, 2, true, false}, + {BufferFormat::k8_8SNorm, 2, 0, 2, true, false}, + {BufferFormat::k8_8UInt, 2, 0, 2, true, true}, + {BufferFormat::k8_8SInt, 2, 0, 2, false, false}, + {BufferFormat::k32UInt, 4, 0, 4, true, true}, + {BufferFormat::k32SInt, 4, 0, 4, false, false}, + {BufferFormat::k32Float, 4, 0, 4, true, false}, + {BufferFormat::k16_16UNorm, 4, 0, 4, true, false}, + {BufferFormat::k16_16SNorm, 4, 0, 4, true, false}, + {BufferFormat::k16_16UInt, 4, 0, 4, true, true}, + {BufferFormat::k16_16SInt, 4, 0, 4, false, false}, + {BufferFormat::k16_16Float, 4, 0, 4, true, false}, + {BufferFormat::k11_11_10Float, 4, 0, 4, true, false}, + {BufferFormat::k10_10_10_2UNorm, 4, 0, 4, true, false}, + {BufferFormat::k10_10_10_2UInt, 4, 0, 4, true, true}, + {BufferFormat::k8_8_8_8UNorm, 4, 0, 4, true, false}, + {BufferFormat::k8_8_8_8SNorm, 4, 0, 4, true, false}, + {BufferFormat::k8_8_8_8UInt, 4, 0, 4, true, true}, + {BufferFormat::k8_8_8_8SInt, 4, 0, 4, false, false}, + {BufferFormat::k32_32UInt, 8, 0, 8, true, true}, + {BufferFormat::k32_32SInt, 8, 0, 8, false, false}, + {BufferFormat::k32_32Float, 8, 0, 8, true, false}, + {BufferFormat::k16_16_16_16UNorm, 8, 0, 8, true, false}, + {BufferFormat::k16_16_16_16SNorm, 8, 0, 8, true, false}, + {BufferFormat::k16_16_16_16UInt, 8, 0, 8, true, true}, + {BufferFormat::k16_16_16_16SInt, 8, 0, 8, false, false}, + {BufferFormat::k16_16_16_16Float, 8, 0, 8, true, false}, + {BufferFormat::k32_32_32UInt, 12, 0, 12, true, true}, + {BufferFormat::k32_32_32SInt, 12, 0, 12, false, false}, + {BufferFormat::k32_32_32Float, 12, 0, 12, true, false}, + {BufferFormat::k32_32_32_32UInt, 16, 0, 16, true, true}, + {BufferFormat::k32_32_32_32SInt, 16, 0, 16, false, false}, + {BufferFormat::k32_32_32_32Float, 16, 0, 16, true, false}, + {BufferFormat::k8Srgb, 1, 0, 0, true, false}, + {BufferFormat::k8_8Srgb, 2, 0, 0, true, false}, + {BufferFormat::k8_8_8_8Srgb, 4, 0, 4, true, false}, + {BufferFormat::k9_9_9_5Float, 4, 0, 0, true, false}, + {BufferFormat::k5_6_5UNorm, 2, 0, 2, true, false}, + {BufferFormat::k5_5_5_1UNorm, 2, 0, 2, true, false}, + {BufferFormat::k1_5_5_5UNorm, 0, 0, 2, false, false}, + {BufferFormat::k4_4_4_4UNorm, 2, 0, 2, true, false}, + {BufferFormat::kFmask8_S4_F4, 1, 0, 1, true, false}, + {BufferFormat::kBc1UNorm, 0, 8, 0, true, false}, + {BufferFormat::kBc1Srgb, 0, 8, 0, true, false}, + {BufferFormat::kBc2UNorm, 0, 16, 0, true, false}, + {BufferFormat::kBc2Srgb, 0, 16, 0, true, false}, + {BufferFormat::kBc3UNorm, 0, 16, 0, true, false}, + {BufferFormat::kBc3Srgb, 0, 16, 0, true, false}, + {BufferFormat::kBc4UNorm, 0, 8, 0, true, false}, + {BufferFormat::kBc4SNorm, 0, 8, 0, true, false}, + {BufferFormat::kBc5UNorm, 0, 16, 0, true, false}, + {BufferFormat::kBc5SNorm, 0, 16, 0, true, false}, + {BufferFormat::kBc6UFloat, 0, 16, 0, true, false}, + {BufferFormat::kBc6SFloat, 0, 16, 0, true, false}, + {BufferFormat::kBc7UNorm, 0, 16, 0, true, false}, + {BufferFormat::kBc7Srgb, 0, 16, 0, true, false}, }; constexpr uint8_t RenderTargetTypeBit(ChannelType type) { - return static_cast(1u << GpuEnumValue(type)); + return static_cast(1u << static_cast(type)); } constexpr auto kUNormType = RenderTargetTypeBit(ChannelType::kUNorm); @@ -137,9 +137,9 @@ constexpr RenderTargetLayoutInfo kRenderTargetLayouts[] = { ChannelType::kFloat, ChannelOrderSupport::kStandardOnly}, }; -const RenderTargetLayoutInfo* FindRenderTargetLayout(uint32_t layout) { +const RenderTargetLayoutInfo* FindRenderTargetLayout(ChannelLayout layout) { for (const auto& info: kRenderTargetLayouts) { - if (GpuEnumValue(info.layout) == layout) { + if (info.layout == layout) { return &info; } } @@ -147,38 +147,38 @@ const RenderTargetLayoutInfo* FindRenderTargetLayout(uint32_t layout) { } constexpr auto MakeFormatInfoLookup() { - constexpr uint32_t kMaxFormat = GpuEnumValue(BufferFormat::kBc7Srgb); + constexpr size_t kMaxFormat = static_cast(BufferFormat::kBc7Srgb); std::array lookup {}; for (const auto& info: kFormatInfo) { - lookup[info.format] = &info; + lookup[static_cast(info.format)] = &info; } return lookup; } constexpr auto kFormatInfoLookup = MakeFormatInfoLookup(); -const FormatInfo* FindFormatInfo(uint32_t format) { - return format < kFormatInfoLookup.size() ? kFormatInfoLookup[format] : nullptr; +const FormatInfo* FindFormatInfo(BufferFormat format) { + const auto index = static_cast(format); + return index < kFormatInfoLookup.size() ? kFormatInfoLookup[index] : nullptr; } } // namespace -RenderTargetFormatEncoding ResolveRenderTargetFormat(uint32_t layout, uint32_t type) { +RenderTargetFormatEncoding ResolveRenderTargetFormat(ChannelLayout layout, ChannelType type) { const auto* layout_info = FindRenderTargetLayout(layout); - if (layout_info == nullptr || type >= 8u) { + const auto raw_type = static_cast(type); + if (layout_info == nullptr || raw_type >= 8u) { return {}; } - const auto channel_type = static_cast(type); - auto format = BufferFormat::kInvalid; - if (layout_info->extra_format != BufferFormat::kInvalid && - channel_type == layout_info->extra_type) { + auto format = BufferFormat::kInvalid; + if (layout_info->extra_format != BufferFormat::kInvalid && type == layout_info->extra_type) { format = layout_info->extra_format; - } else if ((layout_info->linear_type_mask & (1u << type)) != 0) { + } else if ((layout_info->linear_type_mask & (1u << raw_type)) != 0) { const auto first_type = std::countr_zero(static_cast(layout_info->linear_type_mask)); - format = static_cast(GpuEnumValue(layout_info->first_linear_format) + type - - first_type); + format = static_cast(static_cast(layout_info->first_linear_format) + + raw_type - first_type); } if (format == BufferFormat::kInvalid) { return {}; @@ -186,33 +186,33 @@ RenderTargetFormatEncoding ResolveRenderTargetFormat(uint32_t layout, uint32_t t return {format, layout_info->components, layout_info->order_support}; } -uint32_t NumBytesPerElement(uint32_t format) { +uint32_t NumBytesPerElement(BufferFormat format) { const auto* info = FindFormatInfo(format); return info != nullptr ? info->bytes_per_element : 0; } -uint32_t BlockCompressedBytesPerBlock(uint32_t format) { +uint32_t BlockCompressedBytesPerBlock(BufferFormat format) { const auto* info = FindFormatInfo(format); return info != nullptr ? info->block_compressed_bytes_per_block : 0; } -uint32_t RenderTargetBytesPerElement(uint32_t format) { +uint32_t RenderTargetBytesPerElement(BufferFormat format) { const auto* info = FindFormatInfo(format); return info != nullptr ? info->render_target_bytes_per_element : 0; } -bool IsSupportedTextureFormat(uint32_t format) { +bool IsSupportedTextureFormat(BufferFormat format) { const auto* info = FindFormatInfo(format); return info != nullptr && info->supported_sampled_texture_format; } -bool IsUintTextureFormat(uint32_t format) { +bool IsUintTextureFormat(BufferFormat format) { const auto* info = FindFormatInfo(format); return info != nullptr && info->unsigned_integer_texture_format; } -bool IsFmaskTextureFormat(uint32_t format) { - return format == GpuEnumValue(BufferFormat::kFmask8_S4_F4); +bool IsFmaskTextureFormat(BufferFormat format) { + return format == BufferFormat::kFmask8_S4_F4; } } // namespace Libs::Graphics::Prospero diff --git a/src/graphics/guest_gpu/gpu_format.h b/src/graphics/guest_gpu/gpu_format.h index 7533e0116..6e88a9210 100644 --- a/src/graphics/guest_gpu/gpu_format.h +++ b/src/graphics/guest_gpu/gpu_format.h @@ -21,24 +21,29 @@ struct RenderTargetFormatEncoding { order_support != ChannelOrderSupport::kNone; } - [[nodiscard]] constexpr bool SupportsOrder(uint32_t raw_order) const { + [[nodiscard]] constexpr bool SupportsOrder(ChannelOrder order) const { switch (order_support) { - case ChannelOrderSupport::kStandardOnly: - return raw_order == GpuEnumValue(ChannelOrder::kStandard); + case ChannelOrderSupport::kStandardOnly: return order == ChannelOrder::kStandard; case ChannelOrderSupport::kAll: - return raw_order <= GpuEnumValue(ChannelOrder::kAltReversed); + switch (order) { + case ChannelOrder::kStandard: + case ChannelOrder::kAlt: + case ChannelOrder::kReversed: + case ChannelOrder::kAltReversed: return true; + } + return false; default: return false; } } }; -RenderTargetFormatEncoding ResolveRenderTargetFormat(uint32_t layout, uint32_t type); -uint32_t NumBytesPerElement(uint32_t format); -uint32_t BlockCompressedBytesPerBlock(uint32_t format); -uint32_t RenderTargetBytesPerElement(uint32_t format); -bool IsSupportedTextureFormat(uint32_t format); -bool IsUintTextureFormat(uint32_t format); -bool IsFmaskTextureFormat(uint32_t format); +RenderTargetFormatEncoding ResolveRenderTargetFormat(ChannelLayout layout, ChannelType type); +uint32_t NumBytesPerElement(BufferFormat format); +uint32_t BlockCompressedBytesPerBlock(BufferFormat format); +uint32_t RenderTargetBytesPerElement(BufferFormat format); +bool IsSupportedTextureFormat(BufferFormat format); +bool IsUintTextureFormat(BufferFormat format); +bool IsFmaskTextureFormat(BufferFormat format); } // namespace Libs::Graphics::Prospero diff --git a/src/graphics/guest_gpu/hardwareContext.h b/src/graphics/guest_gpu/hardwareContext.h index 7f61648a8..d9f8f9d18 100644 --- a/src/graphics/guest_gpu/hardwareContext.h +++ b/src/graphics/guest_gpu/hardwareContext.h @@ -29,27 +29,27 @@ struct ColorView { struct ColorInfo { bool fmask_compression_enable = false; // uint32_t fmask_compression_mode = 0; - bool fmask_data_compression_disable = false; - bool fmask_one_frag_mode = false; - bool cmask_fast_clear_enable = false; - bool dcc_compression_enable = false; - bool blend_clamp = false; - bool blend_bypass = false; - bool round_mode = false; - uint32_t cmask_is_linear = 0; - uint32_t cmask_addr_type = 0; - bool alt_tile_mode = false; - uint32_t format = 0; - uint32_t channel_type = 0; - uint32_t channel_order = 0; + bool fmask_data_compression_disable = false; + bool fmask_one_frag_mode = false; + bool cmask_fast_clear_enable = false; + bool dcc_compression_enable = false; + bool blend_clamp = false; + bool blend_bypass = false; + bool round_mode = false; + uint32_t cmask_is_linear = 0; + uint32_t cmask_addr_type = 0; + bool alt_tile_mode = false; + Prospero::ChannelLayout format = Prospero::ChannelLayout::kInvalid; + Prospero::ChannelType channel_type = Prospero::ChannelType::kUNorm; + Prospero::ChannelOrder channel_order = Prospero::ChannelOrder::kStandard; }; struct ColorAttrib { - bool force_dest_alpha_to_one = false; - uint32_t tile_mode = 0; - uint32_t fmask_tile_mode = 0; - uint32_t num_samples = 0; - uint32_t num_fragments = 0; + bool force_dest_alpha_to_one = false; + Prospero::TileMode tile_mode = Prospero::TileMode::kLinear; + Prospero::TileMode fmask_tile_mode = Prospero::TileMode::kLinear; + uint32_t num_samples = 0; + uint32_t num_fragments = 0; }; struct ColorAttrib2 { @@ -59,11 +59,11 @@ struct ColorAttrib2 { }; struct ColorAttrib3 { - uint32_t depth = 0; - uint32_t tile_mode = 0; - uint32_t dimension = 0; - bool cmask_pipe_aligned = false; - bool dcc_pipe_aligned = false; + uint32_t depth = 0; + Prospero::TileMode tile_mode = Prospero::TileMode::kLinear; + uint32_t dimension = 0; + bool cmask_pipe_aligned = false; + bool dcc_pipe_aligned = false; }; struct ColorDccControl { @@ -132,7 +132,7 @@ struct RenderTarget { }; struct DepthZInfo { - uint32_t format = 0; + Prospero::DepthFormat format = Prospero::DepthFormat::kInvalid; uint32_t num_samples = 0; Prospero::TextureCompatiblePlaneCompression texture_compatibility = Prospero::TextureCompatiblePlaneCompression::kDisable; @@ -144,16 +144,16 @@ struct DepthZInfo { [[nodiscard]] static DepthZInfo Decode(uint32_t value) { DepthZInfo info; - info.format = value & 0x3u; + info.format = static_cast(value & 0x3u); info.num_samples = (value >> 2u) & 0x3u; info.texture_compatibility = static_cast( - value & Prospero::GpuEnumValue(Prospero::TextureCompatiblePlaneCompression::kBitMask)); + value & static_cast(Prospero::TextureCompatiblePlaneCompression::kBitMask)); info.partially_resident = (value & 0x00001000u) != 0; info.max_mip_level = static_cast((value >> 16u) & 0x0fu); info.expclear_enabled = (value & 0x08000000u) != 0; info.htile_acceleration = (value & 0x20000000u) != 0; info.z_compare_base = static_cast( - value & Prospero::GpuEnumValue(Prospero::ZCompareBase::kBitMask)); + value & static_cast(Prospero::ZCompareBase::kBitMask)); return info; } @@ -167,7 +167,7 @@ struct DepthZInfo { }; struct DepthStencilInfo { - uint32_t format = 0; + Prospero::StencilFormat format = Prospero::StencilFormat::kInvalid; Prospero::TextureCompatibleStencil texture_compatibility = Prospero::TextureCompatibleStencil::kDisable; bool expclear_enabled = false; @@ -176,9 +176,9 @@ struct DepthStencilInfo { [[nodiscard]] static DepthStencilInfo Decode(uint32_t value) { DepthStencilInfo info; - info.format = value & 0x1u; + info.format = static_cast(value & 0x1u); info.texture_compatibility = static_cast( - value & Prospero::GpuEnumValue(Prospero::TextureCompatibleStencil::kBitMask)); + value & static_cast(Prospero::TextureCompatibleStencil::kBitMask)); info.partially_resident = (value & 0x00001000u) != 0; info.expclear_enabled = (value & 0x08000000u) != 0; info.htile_stencil_disabled = (value & 0x20000000u) != 0; @@ -1029,8 +1029,8 @@ public: void Reset() { *this = UserConfig(); } - void SetPrimitiveType(uint32_t prim_type) { m_prim_type = prim_type; } - [[nodiscard]] uint32_t GetPrimType() const { return m_prim_type; } + void SetPrimitiveType(Prospero::PrimitiveType prim_type) { m_prim_type = prim_type; } + [[nodiscard]] Prospero::PrimitiveType GetPrimType() const { return m_prim_type; } void SetIndexOffset(uint32_t index_offset) { m_index_offset = index_offset; } [[nodiscard]] uint32_t GetIndexOffset() const { return m_index_offset; } void SetObjectId(uint32_t object_id) { m_object_id = object_id; } @@ -1049,9 +1049,9 @@ public: void SetGdsOaAddress(uint32_t value) { m_gds_oa.counters[m_gds_oa.GetIndex()].address = value; } private: - uint32_t m_prim_type = 0; - uint32_t m_index_offset = 0; - uint32_t m_object_id = 0; + Prospero::PrimitiveType m_prim_type = Prospero::PrimitiveType::kNone; + uint32_t m_index_offset = 0; + uint32_t m_object_id = 0; GeControl m_ge_cntl; GeUserVgprEn m_ge_user_vgpr_en; diff --git a/src/graphics/guest_gpu/tile.cpp b/src/graphics/guest_gpu/tile.cpp index 4b9bbb798..63d93be9a 100644 --- a/src/graphics/guest_gpu/tile.cpp +++ b/src/graphics/guest_gpu/tile.cpp @@ -265,7 +265,7 @@ static bool GetMipTailLayout(const TileBlockLayout& block, MipTailLayout& out) { return false; } -bool TileGetTextureElementLayout(uint32_t format, TileTextureElementLayout& out) { +bool TileGetTextureElementLayout(Prospero::BufferFormat format, TileTextureElementLayout& out) { if (const auto bytes = Prospero::NumBytesPerElement(format); std::has_single_bit(bytes)) { out = {bytes, 1, 1}; return true; @@ -277,10 +277,10 @@ bool TileGetTextureElementLayout(uint32_t format, TileTextureElementLayout& out) return false; } -bool TileGetTextureBlockLayout(uint32_t format, uint32_t tile, bool volume, +bool TileGetTextureBlockLayout(Prospero::BufferFormat format, Prospero::TileMode tile, bool volume, TileTextureBlockLayout& out) { TileBlockFamily family = TileBlockFamily::Count; - switch (static_cast(tile)) { + switch (tile) { case Prospero::TileMode::kStandard256B: if (!volume) family = TileBlockFamily::Standard256B; break; @@ -1130,15 +1130,18 @@ static bool TileGetHtileSize(uint32_t width, uint32_t height, TileSizeAlign& hti return true; } -bool TileGetDepthSize(uint32_t width, uint32_t height, uint32_t pitch, uint32_t z_format, - uint32_t stencil_format, bool htile, TileSizeAlign& stencil_size, - TileSizeAlign& htile_size, TileSizeAlign& depth_size, - uint32_t num_fragments_log2) { +bool TileGetDepthSize(uint32_t width, uint32_t height, uint32_t pitch, + Prospero::DepthFormat z_format, Prospero::StencilFormat stencil_format, + bool htile, TileSizeAlign& stencil_size, TileSizeAlign& htile_size, + TileSizeAlign& depth_size, uint32_t num_fragments_log2) { EXIT_IF(pitch != 0); // Prospero derives uncompressed depth/stencil as independent 64 KiB block surfaces. if (width > 0 && width <= 16384 && height > 0 && height <= 16384 && - (z_format == 1 || z_format == 3) && stencil_format <= 1 && num_fragments_log2 <= 3) { - const uint32_t depth_bytes = z_format == 1 ? 2u : 4u; + (z_format == Prospero::DepthFormat::kZ16 || z_format == Prospero::DepthFormat::kZ32F) && + (stencil_format == Prospero::StencilFormat::kInvalid || + stencil_format == Prospero::StencilFormat::k8UInt) && + num_fragments_log2 <= 3) { + const uint32_t depth_bytes = z_format == Prospero::DepthFormat::kZ16 ? 2u : 4u; uint32_t depth_block_width = 0; uint32_t depth_block_height = 0; uint32_t stencil_block_width = 0; @@ -1146,7 +1149,7 @@ bool TileGetDepthSize(uint32_t width, uint32_t height, uint32_t pitch, uint32_t const bool valid_blocks = Gen5Msaa64KBBlockSizeFromElementBytes(depth_bytes, num_fragments_log2, &depth_block_width, &depth_block_height) && - (stencil_format == 0 || + (stencil_format == Prospero::StencilFormat::kInvalid || Gen5Msaa64KBBlockSizeFromElementBytes(1, num_fragments_log2, &stencil_block_width, &stencil_block_height)); const uint32_t fragments = 1u << num_fragments_log2; @@ -1155,7 +1158,7 @@ bool TileGetDepthSize(uint32_t width, uint32_t height, uint32_t pitch, uint32_t AlignUp(height, depth_block_height) * depth_bytes * fragments : 0; const uint64_t stencil_bytes_total = - stencil_format == 1 && valid_blocks + stencil_format == Prospero::StencilFormat::k8UInt && valid_blocks ? static_cast(AlignUp(width, stencil_block_width)) * AlignUp(height, stencil_block_height) * fragments : 0; @@ -1163,7 +1166,7 @@ bool TileGetDepthSize(uint32_t width, uint32_t height, uint32_t pitch, uint32_t const bool htile_valid = !htile || TileGetHtileSize(width, height, calculated_htile); if (depth_bytes_total <= UINT32_MAX && stencil_bytes_total <= UINT32_MAX && htile_valid) { depth_size = {static_cast(depth_bytes_total), 65536}; - stencil_size = stencil_format == 1 + stencil_size = stencil_format == Prospero::StencilFormat::k8UInt ? TileSizeAlign {static_cast(stencil_bytes_total), 65536} : TileSizeAlign {}; htile_size = calculated_htile; @@ -1236,31 +1239,29 @@ bool TileGetRenderTargetMipLayout(uint32_t width, uint32_t height, uint32_t pitc if (levels > max_levels) { return false; } - uint32_t format = 0; + auto format = Prospero::BufferFormat::kInvalid; switch (bytes_per_element) { - case 1: format = Prospero::GpuEnumValue(Prospero::BufferFormat::k8UNorm); break; - case 2: format = Prospero::GpuEnumValue(Prospero::BufferFormat::k16UNorm); break; - case 4: format = Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float); break; - case 8: format = Prospero::GpuEnumValue(Prospero::BufferFormat::k16_16_16_16Float); break; - case 16: format = Prospero::GpuEnumValue(Prospero::BufferFormat::k32_32_32_32Float); break; + case 1: format = Prospero::BufferFormat::k8UNorm; break; + case 2: format = Prospero::BufferFormat::k16UNorm; break; + case 4: format = Prospero::BufferFormat::k32Float; break; + case 8: format = Prospero::BufferFormat::k16_16_16_16Float; break; + case 16: format = Prospero::BufferFormat::k32_32_32_32Float; break; default: return false; } - TileGetTextureSize(format, width, height, levels, - Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget), &total_size, - level_sizes, padded_size); + TileGetTextureSize(format, width, height, levels, Prospero::TileMode::kRenderTarget, + &total_size, level_sizes, padded_size); return total_size.size != 0 && total_size.align == 65536; } -void TileGetTextureSize(uint32_t format, uint32_t width, uint32_t height, uint32_t levels, - uint32_t tile, TileSizeAlign* total_size, TileSizeOffset* level_sizes, - TilePaddedSize* padded_size) { +void TileGetTextureSize(Prospero::BufferFormat format, uint32_t width, uint32_t height, + uint32_t levels, Prospero::TileMode tile, TileSizeAlign* total_size, + TileSizeOffset* level_sizes, TilePaddedSize* padded_size) { KYTY_PROFILER_FUNCTION(); EXIT_IF(levels == 0 || levels > 16); TileTextureElementLayout element {}; - if (static_cast(tile) == Prospero::TileMode::kLinear && - TileGetTextureElementLayout(format, element)) { + if (tile == Prospero::TileMode::kLinear && TileGetTextureElementLayout(format, element)) { uint32_t mip_pitch[16] {}; uint32_t mip_height[16] {}; uint32_t mip_size[16] {}; @@ -1302,26 +1303,27 @@ void TileGetTextureSize(uint32_t format, uint32_t width, uint32_t height, uint32 } if (total_size != nullptr && total_size->size == 0) { std::vector list; - list.push_back(fmt::format("format = {}", format)); + list.push_back(fmt::format("format = {}", static_cast(format))); list.push_back(fmt::format("width = {}", width)); list.push_back(fmt::format("height = {}", height)); list.push_back(fmt::format("levels = {}", levels)); - list.push_back(fmt::format("tile = {}", tile)); + list.push_back(fmt::format("tile = {}", static_cast(tile))); EXIT("unknown format:\n%s\n", Common::Concat(list, '\n').c_str()); } } -void TileGetTextureTotalSize(uint32_t format, uint32_t width, uint32_t height, uint32_t depth, - uint32_t levels, uint32_t tile, bool volume_texture, - TileSizeAlign& total_size) { +void TileGetTextureTotalSize(Prospero::BufferFormat format, uint32_t width, uint32_t height, + uint32_t depth, uint32_t levels, Prospero::TileMode tile, + bool volume_texture, TileSizeAlign& total_size) { EXIT_NOT_IMPLEMENTED(depth == 0); - if (volume_texture && static_cast(tile) != Prospero::TileMode::kLinear) { + if (volume_texture && tile != Prospero::TileMode::kLinear) { TileSurfaceLayout layout {}; const TileSurfaceDescription description { format, tile, TileSurfaceDimension::Dim3D, width, height, depth, levels, 1}; if (!TileGetTiledTextureLayout(description, layout)) { EXIT("unsupported 3D texture layout: format=%u tile=%u extent=%ux%ux%u levels=%u\n", - format, tile, width, height, depth, levels); + static_cast(format), static_cast(tile), width, height, depth, + levels); } EXIT_NOT_IMPLEMENTED(layout.total_size > UINT32_MAX); total_size.size = static_cast(layout.total_size); @@ -1337,9 +1339,10 @@ void TileGetTextureTotalSize(uint32_t format, uint32_t width, uint32_t height, u total_size.size = static_cast(total); } -uint32_t TileGetTexturePitch(uint32_t format, uint32_t width, uint32_t tile) { +uint32_t TileGetTexturePitch(Prospero::BufferFormat format, uint32_t width, + Prospero::TileMode tile) { uint32_t pitch = width; - switch (static_cast(tile)) { + switch (tile) { case Prospero::TileMode::kLinear: { TileTextureElementLayout element {}; if (TileGetTextureElementLayout(format, element) && element.texel_width == 1 && diff --git a/src/graphics/guest_gpu/tile.h b/src/graphics/guest_gpu/tile.h index 3e753ff10..311df761f 100644 --- a/src/graphics/guest_gpu/tile.h +++ b/src/graphics/guest_gpu/tile.h @@ -3,6 +3,7 @@ #include "common/abi.h" #include "common/common.h" +#include "graphics/guest_gpu/gpu_defs.h" namespace Libs::Graphics { @@ -65,14 +66,14 @@ enum class TileSurfaceDimension : uint32_t { }; struct TileSurfaceDescription { - uint32_t format = 0; - uint32_t tile_mode = 0; - TileSurfaceDimension dimension = TileSurfaceDimension::Dim2D; - uint32_t width = 0; - uint32_t height = 0; - uint32_t depth = 1; - uint32_t levels = 1; - uint32_t layers = 1; + Prospero::BufferFormat format = Prospero::BufferFormat::kInvalid; + Prospero::TileMode tile_mode = Prospero::TileMode::kLinear; + TileSurfaceDimension dimension = TileSurfaceDimension::Dim2D; + uint32_t width = 0; + uint32_t height = 0; + uint32_t depth = 1; + uint32_t levels = 1; + uint32_t layers = 1; }; // Width/height fields are measured in addressable elements, not texture texels. @@ -98,8 +99,8 @@ struct TileSurfaceLayout { bool TileGetBlockLayout(TileBlockFamily family, uint32_t bytes_per_element, TileBlockLayout& layout); -bool TileGetTextureElementLayout(uint32_t format, TileTextureElementLayout& layout); -bool TileGetTextureBlockLayout(uint32_t format, uint32_t tile, bool volume, +bool TileGetTextureElementLayout(Prospero::BufferFormat format, TileTextureElementLayout& layout); +bool TileGetTextureBlockLayout(Prospero::BufferFormat format, Prospero::TileMode tile, bool volume, TileTextureBlockLayout& layout); bool TileGetTiledTextureLayout(const TileSurfaceDescription& description, TileSurfaceLayout& layout); @@ -110,10 +111,10 @@ bool TileGetBlockXor(const TileBlockLayout& layout, uint32_t block_x, uint32_t b bool TileGetBlockXor(const TileBlockLayout& layout, uint32_t block_x, uint32_t block_y, uint32_t block_z, uint32_t& byte_offset); -bool TileGetDepthSize(uint32_t width, uint32_t height, uint32_t pitch, uint32_t z_format, - uint32_t stencil_format, bool htile, TileSizeAlign& stencil_size, - TileSizeAlign& htile_size, TileSizeAlign& depth_size, - uint32_t num_fragments_log2 = 0); +bool TileGetDepthSize(uint32_t width, uint32_t height, uint32_t pitch, + Prospero::DepthFormat z_format, Prospero::StencilFormat stencil_format, + bool htile, TileSizeAlign& stencil_size, TileSizeAlign& htile_size, + TileSizeAlign& depth_size, uint32_t num_fragments_log2 = 0); uint32_t TileGetRenderTargetPitch(uint32_t width, uint32_t bytes_per_element, uint32_t num_fragments_log2 = 0); uint32_t TileGetDepthPitch(uint32_t width, uint32_t bytes_per_element, @@ -125,13 +126,14 @@ bool TileGetRenderTargetMipLayout(uint32_t width, uint32_t height, uint32_t uint32_t bytes_per_element, uint32_t levels, TileSizeAlign& total_size, TileSizeOffset* level_sizes, TilePaddedSize* padded_size); -void TileGetTextureSize(uint32_t format, uint32_t width, uint32_t height, uint32_t levels, - uint32_t tile, TileSizeAlign* total_size, TileSizeOffset* level_sizes, - TilePaddedSize* padded_size); -void TileGetTextureTotalSize(uint32_t format, uint32_t width, uint32_t height, uint32_t depth, - uint32_t levels, uint32_t tile, bool volume_texture, - TileSizeAlign& total_size); -uint32_t TileGetTexturePitch(uint32_t format, uint32_t width, uint32_t tile); +void TileGetTextureSize(Prospero::BufferFormat format, uint32_t width, uint32_t height, + uint32_t levels, Prospero::TileMode tile, TileSizeAlign* total_size, + TileSizeOffset* level_sizes, TilePaddedSize* padded_size); +void TileGetTextureTotalSize(Prospero::BufferFormat format, uint32_t width, uint32_t height, + uint32_t depth, uint32_t levels, Prospero::TileMode tile, + bool volume_texture, TileSizeAlign& total_size); +uint32_t TileGetTexturePitch(Prospero::BufferFormat format, uint32_t width, + Prospero::TileMode tile); } // namespace Libs::Graphics diff --git a/src/graphics/host_gpu/renderer/cache/textureCache.cpp b/src/graphics/host_gpu/renderer/cache/textureCache.cpp index 2e5b2a487..5c59348f0 100644 --- a/src/graphics/host_gpu/renderer/cache/textureCache.cpp +++ b/src/graphics/host_gpu/renderer/cache/textureCache.cpp @@ -516,7 +516,7 @@ ImageId TextureCache::GetNullImage(const ImageDesc& desc) { info.pitch = 1; info.bytes_per_block = std::max(desc.info.bytes_per_block, 1u); info.samples = 1; - info.tile_mode = Prospero::GpuEnumValue(Prospero::TileMode::kLinear); + info.tile_mode = Prospero::TileMode::kLinear; info.mip_layout[0] = {0, info.bytes_per_block, 1, 1}; const auto id = InsertImage(info); m_null_images.emplace(format, id); @@ -822,7 +822,8 @@ TextureCache::OverlapResult TextureCache::ResolveOverlap(const ImageInfo& reques requested.data.address, requested.resources.levels, requested.resources.layers, cached.info.resources.levels, cached.info.resources.layers, requested.data.size, cached.info.data.size, static_cast(requested.type), - static_cast(cached.info.type), requested.tile_mode, cached.info.tile_mode); + static_cast(cached.info.type), static_cast(requested.tile_mode), + static_cast(cached.info.tile_mode)); } if (requested.data.address > cached.info.data.address) { @@ -905,7 +906,7 @@ TextureCache::ColorTransferPlan TextureCache::BuildColorTransfer(const Image& image, BindingType binding, TransferDirection direction) const { const auto& info = image.info; - uint32_t format = info.guest_format; + auto format = info.guest_format; uint32_t layers = info.TransferLayers(); bool volume = info.IsVolume(); bool allow_depth_tile = direction == TransferDirection::Upload; @@ -957,8 +958,7 @@ TextureCache::BuildColorTransfer(const Image& image, BindingType binding, info.resources.levels, layers, info.tile_mode, info.data.size, allow_depth_tile, volume, owner); plan.regions = TextureBuildImageCopies(plan.layout); - plan.tiled = static_cast(plan.layout.surface.description.tile_mode) != - Prospero::TileMode::kLinear; + plan.tiled = plan.layout.surface.description.tile_mode != Prospero::TileMode::kLinear; if (plan.tiled) { if (!TextureBuildGpuTileInfos(info.data.size, plan.regions, plan.layout, info.resources.levels, plan.tiles)) { @@ -1007,7 +1007,7 @@ void TextureCache::UploadImage(Image& image, const ImageDesc& desc, Buffer& sour " size=0x%016" PRIx64 " format=%u tile=%u family=%u extent=%ux%ux%u " "pitch=%u levels=%u layers=%u samples=%u\n", static_cast(desc.type), info.data.address, info.data.size, - info.guest_format, info.tile_mode, + static_cast(info.guest_format), static_cast(info.tile_mode), static_cast(plan.layout.surface.texture.block.family), info.extent.width, info.extent.height, info.extent.depth, info.pitch, info.resources.levels, info.resources.layers, info.samples); @@ -1045,7 +1045,7 @@ void TextureCache::UploadImage(Image& image, const ImageDesc& desc, Buffer& sour copy.bufferImageHeight = info.extent.height; copy.imageSubresource = {vk::ImageAspectFlagBits::eDepth, 0, layer, 1}; copy.imageExtent = {info.extent.width, info.extent.height, 1}; - if (static_cast(info.tile_mode) != Prospero::TileMode::kLinear) { + if (info.tile_mode != Prospero::TileMode::kLinear) { tiles.push_back({block.family, block.bytes_per_element, offset, full_slice_size, offset, full_slice_size, 0, info.extent.width, info.extent.height, 1, info.pitch}); diff --git a/src/graphics/host_gpu/renderer/colorRenderTarget.cpp b/src/graphics/host_gpu/renderer/colorRenderTarget.cpp index b7a9efa63..be89a22f2 100644 --- a/src/graphics/host_gpu/renderer/colorRenderTarget.cpp +++ b/src/graphics/host_gpu/renderer/colorRenderTarget.cpp @@ -101,8 +101,9 @@ void RenderExecutor::ResolveRenderColorTarget(uint64_t submit_id, RenderCommandB " attrib3_tile=0x%08" PRIx32 " attrib3_dim=0x%08" PRIx32 " fmt=0x%08" PRIx32 " nfmt=0x%08" PRIx32 " order=0x%08" PRIx32 "\n", rt_slot, rt.base.addr, mask, rt.attrib2.width, rt.attrib2.height, - rt.attrib3.tile_mode, rt.attrib3.dimension, rt.info.format, rt.info.channel_type, - rt.info.channel_order); + static_cast(rt.attrib3.tile_mode), rt.attrib3.dimension, + static_cast(rt.info.format), static_cast(rt.info.channel_type), + static_cast(rt.info.channel_order)); } } @@ -129,17 +130,16 @@ void RenderExecutor::ResolveRenderColorTarget(uint64_t submit_id, RenderCommandB if (volume && samples != 1) { EXIT("multisampled 3D render targets are unsupported\n"); } - const uint32_t depth = volume ? rt.attrib3.depth + 1u : 1u; - const bool standard64 = - rt.attrib3.tile_mode == Prospero::GpuEnumValue(Prospero::TileMode::kStandard64KB); + const uint32_t depth = volume ? rt.attrib3.depth + 1u : 1u; + const bool standard64 = rt.attrib3.tile_mode == Prospero::TileMode::kStandard64KB; switch (rt.attrib3.tile_mode) { - case Prospero::GpuEnumValue(Prospero::TileMode::kLinear): - case Prospero::GpuEnumValue(Prospero::TileMode::kStandard64KB): - case Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget): + case Prospero::TileMode::kLinear: + case Prospero::TileMode::kStandard64KB: + case Prospero::TileMode::kRenderTarget: tile = !RenderIsColorTileModeLinear(rt.attrib3.tile_mode); break; - default: EXIT("unknown tile mode: %u\n", rt.attrib3.tile_mode); + default: EXIT("unknown tile mode: %u\n", static_cast(rt.attrib3.tile_mode)); } if (!tile && levels > 1) { EXIT("linear mipmapped render targets are unsupported\n"); @@ -180,8 +180,8 @@ void RenderExecutor::ResolveRenderColorTarget(uint64_t submit_id, RenderCommandB if (volume) { pitch = TileGetTexturePitch(transfer_format, width, rt.attrib3.tile_mode); } else if (standard64) { - pitch = TileGetTexturePitch(Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float), - width, rt.attrib3.tile_mode); + pitch = + TileGetTexturePitch(Prospero::BufferFormat::k32Float, width, rt.attrib3.tile_mode); } else { pitch = TileGetRenderTargetPitch(width, bytes_per_element, rt.attrib.num_fragments); } @@ -207,7 +207,7 @@ void RenderExecutor::ResolveRenderColorTarget(uint64_t submit_id, RenderCommandB 1}; if (!tile || !TileGetTiledTextureLayout(description, volume_layout)) { EXIT("unsupported 3D render-target layout: %ux%ux%u levels=%u tile=%u\n", width, height, - depth, levels, rt.attrib3.tile_mode); + depth, levels, static_cast(rt.attrib3.tile_mode)); } size = volume_layout.block_slice_size; backing_size = volume_layout.total_size; @@ -215,9 +215,8 @@ void RenderExecutor::ResolveRenderColorTarget(uint64_t submit_id, RenderCommandB TileSizeAlign layout {}; bool valid_layout = false; if (standard64) { - TileGetTextureSize(Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float), width, - height, levels, rt.attrib3.tile_mode, &layout, mip_sizes, - mip_padded); + TileGetTextureSize(Prospero::BufferFormat::k32Float, width, height, levels, + rt.attrib3.tile_mode, &layout, mip_sizes, mip_padded); valid_layout = layout.size != 0 && layout.align == 65536; } else { valid_layout = @@ -278,8 +277,9 @@ void RenderExecutor::ResolveRenderColorTarget(uint64_t submit_id, RenderCommandB " extent=%ux%ux%u view_mip=%u view_extent=%ux%u levels=%u pitch=%u" " fmt=0x%08" PRIx32 " nfmt=0x%08" PRIx32 " order=0x%08" PRIx32 " samples=%u tile=%s\n", rt_slot, rt.base.addr, backing_size, width, height, depth, rt.view.current_mip_level, - view_extent.width, view_extent.height, levels, pitch, rt.info.format, - rt.info.channel_type, rt.info.channel_order, samples, tile ? "tiled" : "linear"); + view_extent.width, view_extent.height, levels, pitch, + static_cast(rt.info.format), static_cast(rt.info.channel_type), + static_cast(rt.info.channel_order), samples, tile ? "tiled" : "linear"); } TextureCache::ImageDesc desc {}; diff --git a/src/graphics/host_gpu/renderer/debug.cpp b/src/graphics/host_gpu/renderer/debug.cpp index 709c98c24..cf2c83cf3 100644 --- a/src/graphics/host_gpu/renderer/debug.cpp +++ b/src/graphics/host_gpu/renderer/debug.cpp @@ -76,8 +76,8 @@ void uc_print(const char* func, const HW::UserConfig& uc) { "\t en_user_vgpr1 = %s\n" "\t en_user_vgpr2 = %s\n" "\t en_user_vgpr3 = %s\n", - uc.GetPrimType(), uc.GetIndexOffset(), uc.GetObjectId(), ge_cntl.primitive_group_size, - ge_cntl.vertex_group_size, user_en.vgpr1 ? "true" : "false", + static_cast(uc.GetPrimType()), uc.GetIndexOffset(), uc.GetObjectId(), + ge_cntl.primitive_group_size, ge_cntl.vertex_group_size, user_en.vgpr1 ? "true" : "false", user_en.vgpr2 ? "true" : "false", user_en.vgpr3 ? "true" : "false"); } @@ -141,11 +141,12 @@ std::vector rt_print(const char* func, const HW::RenderTarget& rt) fmt::format("\t info.cmask_addr_type = 0x{:08x}\n", rt.info.cmask_addr_type)); dst.push_back(fmt::format("\t info.alt_tile_mode = {}\n", rt.info.alt_tile_mode ? "true" : "false")); - dst.push_back(fmt::format("\t info.format = 0x{:08x}\n", rt.info.format)); - dst.push_back( - fmt::format("\t info.channel_type = 0x{:08x}\n", rt.info.channel_type)); - dst.push_back( - fmt::format("\t info.channel_order = 0x{:08x}\n", rt.info.channel_order)); + dst.push_back(fmt::format("\t info.format = 0x{:08x}\n", + static_cast(rt.info.format))); + dst.push_back(fmt::format("\t info.channel_type = 0x{:08x}\n", + static_cast(rt.info.channel_type))); + dst.push_back(fmt::format("\t info.channel_order = 0x{:08x}\n", + static_cast(rt.info.channel_order))); dst.push_back(fmt::format("\t info.blend_bypa = {}\n", rt.info.blend_bypass ? "true" : "false")); dst.push_back(fmt::format("\t info.blend_clamp = {}\n", @@ -154,10 +155,10 @@ std::vector rt_print(const char* func, const HW::RenderTarget& rt) rt.info.round_mode ? "true" : "false")); dst.push_back(fmt::format("\t attrib.force_dest_alpha_to_one = {}\n", rt.attrib.force_dest_alpha_to_one ? "true" : "false")); - dst.push_back( - fmt::format("\t attrib.tile_mode = 0x{:08x}\n", rt.attrib.tile_mode)); - dst.push_back( - fmt::format("\t attrib.fmask_tile_mode = 0x{:08x}\n", rt.attrib.fmask_tile_mode)); + dst.push_back(fmt::format("\t attrib.tile_mode = 0x{:08x}\n", + static_cast(rt.attrib.tile_mode))); + dst.push_back(fmt::format("\t attrib.fmask_tile_mode = 0x{:08x}\n", + static_cast(rt.attrib.fmask_tile_mode))); dst.push_back( fmt::format("\t attrib.num_samples = 0x{:08x}\n", rt.attrib.num_samples)); dst.push_back( @@ -168,8 +169,8 @@ std::vector rt_print(const char* func, const HW::RenderTarget& rt) dst.push_back( fmt::format("\t attrib2.num_mip_levels = 0x{:08x}\n", rt.attrib2.num_mip_levels)); dst.push_back(fmt::format("\t attrib3.depth = 0x{:08x}\n", rt.attrib3.depth)); - dst.push_back( - fmt::format("\t attrib3.tile_mode = 0x{:08x}\n", rt.attrib3.tile_mode)); + dst.push_back(fmt::format("\t attrib3.tile_mode = 0x{:08x}\n", + static_cast(rt.attrib3.tile_mode))); dst.push_back( fmt::format("\t attrib3.dimension = 0x{:08x}\n", rt.attrib3.dimension)); dst.push_back(fmt::format("\t attrib3.cmask_pipe_aligned = {}\n", @@ -212,22 +213,22 @@ std::vector rt_print(const char* func, const HW::RenderTarget& rt) return dst; } -static bool RenderIsColorTileMode(uint32_t tile_mode) { +static bool RenderIsColorTileMode(Prospero::TileMode tile_mode) { // AGC CxRenderTarget::TileMode shifted by CB_COLOR*_ATTRIB3.COLOR_SW_MODE. switch (tile_mode) { - case Prospero::GpuEnumValue(Prospero::TileMode::kLinear): - case Prospero::GpuEnumValue(Prospero::TileMode::kStandard256B): - case Prospero::GpuEnumValue(Prospero::TileMode::kStandard4KB): - case Prospero::GpuEnumValue(Prospero::TileMode::kStandard64KB): - case Prospero::GpuEnumValue(Prospero::TileMode::kPrt): - case Prospero::GpuEnumValue(Prospero::TileMode::kDepth): - case Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget): return true; + case Prospero::TileMode::kLinear: + case Prospero::TileMode::kStandard256B: + case Prospero::TileMode::kStandard4KB: + case Prospero::TileMode::kStandard64KB: + case Prospero::TileMode::kPrt: + case Prospero::TileMode::kDepth: + case Prospero::TileMode::kRenderTarget: return true; default: return false; } } -bool RenderIsColorTileModeLinear(uint32_t tile_mode) { - return tile_mode == Prospero::GpuEnumValue(Prospero::TileMode::kLinear); +bool RenderIsColorTileModeLinear(Prospero::TileMode tile_mode) { + return tile_mode == Prospero::TileMode::kLinear; } static bool RenderIsColorDimension(uint32_t dimension) { @@ -361,7 +362,8 @@ static void RtCheck(const HW::RenderTarget& rt) { } } if (!RenderIsColorTileMode(rt.attrib3.tile_mode)) { - EXIT("unknown PS5 render-target tile mode: 0x%08" PRIx32 "\n", rt.attrib3.tile_mode); + EXIT("unknown PS5 render-target tile mode: 0x%08" PRIx32 "\n", + static_cast(rt.attrib3.tile_mode)); } if (!RenderIsColorDimension(rt.attrib3.dimension)) { EXIT("unknown PS5 render-target dimension: 0x%08" PRIx32 "\n", rt.attrib3.dimension); @@ -456,13 +458,14 @@ static void ZPrint(const char* func, const HW::DepthRenderTarget& z) { "\t height = 0x%08" PRIx32 "\n" "\t size.x_max = 0x%04" PRIx16 "\n" "\t size.y_max = 0x%04" PRIx16 "\n", - z.z_info.format, z.z_info.num_samples, - Prospero::GpuEnumValue(z.z_info.texture_compatibility), + static_cast(z.z_info.format), z.z_info.num_samples, + static_cast(z.z_info.texture_compatibility), z.z_info.htile_acceleration ? "true" : "false", z.z_info.expclear_enabled ? "true" : "false", - Prospero::GpuEnumValue(z.z_info.z_compare_base), + static_cast(z.z_info.z_compare_base), z.z_info.partially_resident ? "true" : "false", z.z_info.max_mip_level, - z.stencil_info.format, Prospero::GpuEnumValue(z.stencil_info.texture_compatibility), + static_cast(z.stencil_info.format), + static_cast(z.stencil_info.texture_compatibility), z.stencil_info.htile_stencil_disabled ? "true" : "false", z.stencil_info.expclear_enabled ? "true" : "false", z.stencil_info.partially_resident ? "true" : "false", z.depth_info.addr5_swizzle_mask, @@ -491,15 +494,16 @@ static void ZCheck(const HW::DepthRenderTarget& z, const HW::DepthControl& dc, EXIT_NOT_IMPLEMENTED(!z.z_info.HasValidTextureCompatibility()); EXIT_NOT_IMPLEMENTED(!z.stencil_info.HasValidTextureCompatibility()); - if (z.z_info.format == 0) { - EXIT_NOT_IMPLEMENTED(z.z_info.format != 0); + if (z.z_info.format == Prospero::DepthFormat::kInvalid) { + EXIT_NOT_IMPLEMENTED(z.z_info.format != Prospero::DepthFormat::kInvalid); EXIT_NOT_IMPLEMENTED(z.z_info.num_samples != 0); EXIT_NOT_IMPLEMENTED(z.z_info.htile_acceleration != false); EXIT_NOT_IMPLEMENTED(z.z_info.expclear_enabled != false); EXIT_NOT_IMPLEMENTED(z.z_info.partially_resident != false); EXIT_NOT_IMPLEMENTED(z.z_info.max_mip_level != 0); } else { - EXIT_NOT_IMPLEMENTED(z.z_info.format != 0x00000001 && z.z_info.format != 0x00000003); + EXIT_NOT_IMPLEMENTED(z.z_info.format != Prospero::DepthFormat::kZ16 && + z.z_info.format != Prospero::DepthFormat::kZ32F); if (z.z_info.num_samples != 0x00000000) { static bool logged = false; if (!logged) { @@ -513,16 +517,17 @@ static void ZCheck(const HW::DepthRenderTarget& z, const HW::DepthControl& dc, EXIT_NOT_IMPLEMENTED(z.z_info.max_mip_level != 0); } - if (z.stencil_info.format == 0) { + if (z.stencil_info.format == Prospero::StencilFormat::kInvalid) { EXIT_NOT_IMPLEMENTED(z.stencil_info.expclear_enabled != false); EXIT_NOT_IMPLEMENTED(z.stencil_info.partially_resident != false); } else { - EXIT_NOT_IMPLEMENTED(z.stencil_info.format != 0x00000001); + EXIT_NOT_IMPLEMENTED(z.stencil_info.format != Prospero::StencilFormat::k8UInt); EXIT_NOT_IMPLEMENTED(z.stencil_info.expclear_enabled != false); EXIT_NOT_IMPLEMENTED(z.stencil_info.partially_resident != false); } - if (z.z_info.format != 0 || z.stencil_info.format != 0) { + if (z.z_info.format != Prospero::DepthFormat::kInvalid || + z.stencil_info.format != Prospero::StencilFormat::kInvalid) { EXIT_NOT_IMPLEMENTED(z.depth_info.addr5_swizzle_mask != 0x00000000); EXIT_NOT_IMPLEMENTED(z.depth_info.array_mode != 0x00000000); @@ -557,7 +562,8 @@ static void ZCheck(const HW::DepthRenderTarget& z, const HW::DepthControl& dc, EXIT_NOT_IMPLEMENTED(z.z_read_base_addr != z.z_write_base_addr); EXIT_NOT_IMPLEMENTED(z.stencil_read_base_addr != z.stencil_write_base_addr); EXIT_NOT_IMPLEMENTED(z.z_write_base_addr == 0); - if (z.stencil_info.format != 0 && z.stencil_write_base_addr == 0) { + if (z.stencil_info.format != Prospero::StencilFormat::kInvalid && + z.stencil_write_base_addr == 0) { LOGF("\t warning: stencil format is set without a stencil base address, continuing " "without stencil attachment\n"); } @@ -1218,8 +1224,9 @@ void hw_check(const RenderCommandBuffer& buffer) { const auto& mrt = hw.GetRenderTarget(i); LOGF("\t RT%u addr=0x%010" PRIx64 " mask=0x%x fmt=0x%08" PRIx32 " width=%u height=%u tile=%u\n", - i, mrt.base.addr, (hw.GetRenderTargetMask() >> (i * 4u)) & 0x0fu, mrt.info.format, - mrt.attrib2.width + 1, mrt.attrib2.height + 1, mrt.attrib3.tile_mode); + i, mrt.base.addr, (hw.GetRenderTargetMask() >> (i * 4u)) & 0x0fu, + static_cast(mrt.info.format), mrt.attrib2.width + 1, + mrt.attrib2.height + 1, static_cast(mrt.attrib3.tile_mode)); } } if (rc.depth_clear_enable && hw.GetDepthClearValue() != 0.0f && diff --git a/src/graphics/host_gpu/renderer/debug.h b/src/graphics/host_gpu/renderer/debug.h index b06022f56..759d543d3 100644 --- a/src/graphics/host_gpu/renderer/debug.h +++ b/src/graphics/host_gpu/renderer/debug.h @@ -34,7 +34,7 @@ void uc_print(const char* func, const HW::UserConfig& uc); void uc_check(const HW::UserConfig& uc); void sh_print(const char* func, const HW::Shader& uc); std::vector rt_print(const char* func, const HW::RenderTarget& rt); -bool RenderIsColorTileModeLinear(uint32_t tile_mode); +bool RenderIsColorTileModeLinear(Prospero::TileMode tile_mode); void hw_print(const RenderCommandBuffer& buffer); void hw_check(const RenderCommandBuffer& buffer); void LogDrawPhase(const char* draw_name, const char* phase); diff --git a/src/graphics/host_gpu/renderer/depthRenderTarget.cpp b/src/graphics/host_gpu/renderer/depthRenderTarget.cpp index dc37a6e5b..1ac2e2822 100644 --- a/src/graphics/host_gpu/renderer/depthRenderTarget.cpp +++ b/src/graphics/host_gpu/renderer/depthRenderTarget.cpp @@ -67,9 +67,8 @@ static vk::StencilOp ConvertStencilOp(uint8_t value, uint8_t write_mask, uint8_t } static bool UsesStencilOpValue(uint8_t fail, uint8_t pass, uint8_t depth_fail) { - return fail == Prospero::GpuEnumValue(Prospero::StencilOp::kReplaceOp) || - pass == Prospero::GpuEnumValue(Prospero::StencilOp::kReplaceOp) || - depth_fail == Prospero::GpuEnumValue(Prospero::StencilOp::kReplaceOp); + constexpr auto replace_op = static_cast(Prospero::StencilOp::kReplaceOp); + return fail == replace_op || pass == replace_op || depth_fail == replace_op; } [[nodiscard]] static vk::Format ResolveHostDepthAttachmentFormat(const RenderCommandBuffer& buffer, @@ -103,15 +102,14 @@ void RenderExecutor::ResolveRenderDepthTarget(uint64_t submit_id, RenderCommandB RenderDepthInfo& r) { KYTY_PROFILER_FUNCTION(); (void)submit_id; - const auto& hw = buffer.GetRegisters(); - const auto& z = hw.GetDepthRenderTarget(); - const auto& rc = hw.GetRenderControl(); - const auto& dc = hw.GetDepthControl(); - const auto& sc = hw.GetStencilControl(); - const auto& sm = hw.GetStencilMask(); - const bool has_stencil = - z.stencil_info.format != Prospero::GpuEnumValue(Prospero::StencilFormat::kInvalid); - const bool depth_active = + const auto& hw = buffer.GetRegisters(); + const auto& z = hw.GetDepthRenderTarget(); + const auto& rc = hw.GetRenderControl(); + const auto& dc = hw.GetDepthControl(); + const auto& sc = hw.GetStencilControl(); + const auto& sm = hw.GetStencilMask(); + const bool has_stencil = z.stencil_info.format != Prospero::StencilFormat::kInvalid; + const bool depth_active = dc.z_enable || dc.z_write_enable || dc.depth_bounds_enable || rc.depth_clear_enable; const bool stencil_active = has_stencil && (dc.stencil_enable || rc.stencil_clear_enable); if (!depth_active && !stencil_active) { @@ -122,9 +120,8 @@ void RenderExecutor::ResolveRenderDepthTarget(uint64_t submit_id, RenderCommandB DepthFatal("invalid PS5 depth texture-compatibility encoding"); } const bool attachment_unbound = - z.z_info.format == Prospero::GpuEnumValue(Prospero::DepthFormat::kInvalid) && - z.stencil_info.format == Prospero::GpuEnumValue(Prospero::StencilFormat::kInvalid) && - z.z_info.num_samples == 0 && + z.z_info.format == Prospero::DepthFormat::kInvalid && + z.stencil_info.format == Prospero::StencilFormat::kInvalid && z.z_info.num_samples == 0 && z.z_info.texture_compatibility == Prospero::TextureCompatiblePlaneCompression::kDisable && !z.z_info.expclear_enabled && !z.z_info.partially_resident && z.z_info.max_mip_level == 0 && z.stencil_info.texture_compatibility == Prospero::TextureCompatibleStencil::kDisable && @@ -186,8 +183,8 @@ void RenderExecutor::ResolveRenderDepthTarget(uint64_t submit_id, RenderCommandB DepthFatal("unsupported depth register state"); } if (has_stencil) { - if (z.stencil_info.format != Prospero::GpuEnumValue(Prospero::StencilFormat::k8UInt) || - !htile_stencil_compat || z.stencil_read_base_addr == 0 || + if (z.stencil_info.format != Prospero::StencilFormat::k8UInt || !htile_stencil_compat || + z.stencil_read_base_addr == 0 || z.stencil_write_base_addr != z.stencil_read_base_addr || (z.stencil_read_base_addr & 0xffffu) != 0 || z.depth_view.stencil_write_disable) { DepthFatal("unsupported stencil attachment state"); @@ -229,7 +226,7 @@ void RenderExecutor::ResolveRenderDepthTarget(uint64_t submit_id, RenderCommandB DepthFatal("no host depth/stencil format supports required usage for %s", VulkanToString(ideal_format).c_str()); } - const uint32_t guest_format = Prospero::GpuEnumValue(policy->guest_format); + const auto guest_format = policy->guest_format; const uint32_t bytes = policy->bytes_per_element; const auto pitch = TileGetDepthPitch(width, bytes, z.z_info.num_samples); if (z.pitch_height_valid && ((static_cast(z.pitch_div8_minus1) + 1u) * 8u != pitch || @@ -343,7 +340,7 @@ void RenderExecutor::ResolveRenderDepthTarget(uint64_t submit_id, RenderCommandB desc.info.pitch = pitch; desc.info.bytes_per_block = bytes; desc.info.samples = samples; - desc.info.tile_mode = Prospero::GpuEnumValue(Prospero::TileMode::kDepth); + desc.info.tile_mode = Prospero::TileMode::kDepth; desc.info.mip_layout[0] = {0, r.depth_buffer_size, pitch, height}; desc.info.metadata.range = {r.htile_buffer_vaddr, r.htile_buffer_size}; desc.info.metadata.kind = has_htile ? ImageMetadataKind::Htile : ImageMetadataKind::None; diff --git a/src/graphics/host_gpu/renderer/image/image.cpp b/src/graphics/host_gpu/renderer/image/image.cpp index c142c631a..3685793b7 100644 --- a/src/graphics/host_gpu/renderer/image/image.cpp +++ b/src/graphics/host_gpu/renderer/image/image.cpp @@ -646,13 +646,13 @@ void Validate(const ImageInfo& info) { } } -uint32_t RenderTargetTransferFormat(uint32_t bytes_per_element) { +Prospero::BufferFormat RenderTargetTransferFormat(uint32_t bytes_per_element) { switch (bytes_per_element) { - case 1: return Prospero::GpuEnumValue(Prospero::BufferFormat::k8UNorm); - case 2: return Prospero::GpuEnumValue(Prospero::BufferFormat::k16UNorm); - case 4: return Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float); - case 8: return Prospero::GpuEnumValue(Prospero::BufferFormat::k16_16_16_16Float); - case 16: return Prospero::GpuEnumValue(Prospero::BufferFormat::k32_32_32_32Float); + case 1: return Prospero::BufferFormat::k8UNorm; + case 2: return Prospero::BufferFormat::k16UNorm; + case 4: return Prospero::BufferFormat::k32Float; + case 8: return Prospero::BufferFormat::k16_16_16_16Float; + case 16: return Prospero::BufferFormat::k32_32_32_32Float; default: EXIT("unsupported render-target element size: %u\n", bytes_per_element); } } diff --git a/src/graphics/host_gpu/renderer/image/image.h b/src/graphics/host_gpu/renderer/image/image.h index afea6ad34..9746ac67c 100644 --- a/src/graphics/host_gpu/renderer/image/image.h +++ b/src/graphics/host_gpu/renderer/image/image.h @@ -188,8 +188,8 @@ private: namespace ImageOps { -void Validate(const ImageInfo& info); -[[nodiscard]] uint32_t RenderTargetTransferFormat(uint32_t bytes_per_element); +void Validate(const ImageInfo& info); +[[nodiscard]] Prospero::BufferFormat RenderTargetTransferFormat(uint32_t bytes_per_element); } // namespace ImageOps diff --git a/src/graphics/host_gpu/renderer/image/imageInfo.h b/src/graphics/host_gpu/renderer/image/imageInfo.h index 6991926fd..20716b807 100644 --- a/src/graphics/host_gpu/renderer/image/imageInfo.h +++ b/src/graphics/host_gpu/renderer/image/imageInfo.h @@ -67,14 +67,14 @@ struct ImageInfo { ImageMetadataInfo metadata; uint32_t htile_clear_mask = UINT32_MAX; vk::Format pixel_format = vk::Format::eUndefined; - uint32_t guest_format = 0; + Prospero::BufferFormat guest_format = Prospero::BufferFormat::kInvalid; Prospero::ImageType type = Prospero::ImageType::kColor2D; vk::Extent3D extent = {1, 1, 1}; ImageSubresources resources; uint32_t pitch = 0; uint32_t bytes_per_block = 0; uint32_t samples = 1; - uint32_t tile_mode = 0; + Prospero::TileMode tile_mode = Prospero::TileMode::kLinear; bool bgra16 = false; std::array mip_layout {}; @@ -86,9 +86,7 @@ struct ImageInfo { [[nodiscard]] bool IsBlock() const noexcept { return Prospero::BlockCompressedBytesPerBlock(guest_format) != 0; } - [[nodiscard]] bool IsTiled() const noexcept { - return tile_mode != Prospero::GpuEnumValue(Prospero::TileMode::kLinear); - } + [[nodiscard]] bool IsTiled() const noexcept { return tile_mode != Prospero::TileMode::kLinear; } [[nodiscard]] constexpr bool IsVolume() const noexcept { return type == Prospero::ImageType::kColor3D; } @@ -235,9 +233,9 @@ inline constexpr std::array DEPTH_FORMAT_POLICIES {{ }}; [[nodiscard]] inline constexpr const DepthFormatPolicy* -FindDepthFormatPolicy(uint32_t depth_format) noexcept { +FindDepthFormatPolicy(Prospero::DepthFormat depth_format) noexcept { for (const auto& policy: DEPTH_FORMAT_POLICIES) { - if (Prospero::GpuEnumValue(policy.depth_format) == depth_format) { + if (policy.depth_format == depth_format) { return &policy; } } @@ -245,9 +243,9 @@ FindDepthFormatPolicy(uint32_t depth_format) noexcept { } [[nodiscard]] inline constexpr const DepthFormatPolicy* -FindGuestDepthFormatPolicy(uint32_t guest_format) noexcept { +FindGuestDepthFormatPolicy(Prospero::BufferFormat guest_format) noexcept { for (const auto& policy: DEPTH_FORMAT_POLICIES) { - if (Prospero::GpuEnumValue(policy.guest_format) == guest_format) { + if (policy.guest_format == guest_format) { return &policy; } } @@ -269,10 +267,11 @@ FindGuestDepthFormatPolicy(uint32_t guest_format) noexcept { return has_stencil ? policy.stencil_attachment_formats.front() : policy.depth_attachment_format; } -[[nodiscard]] inline constexpr vk::Format DepthAttachmentFormat(uint32_t depth_format, - uint32_t stencil_format) noexcept { +[[nodiscard]] inline constexpr vk::Format +DepthAttachmentFormat(Prospero::DepthFormat depth_format, + Prospero::StencilFormat stencil_format) noexcept { bool has_stencil = false; - switch (static_cast(stencil_format)) { + switch (stencil_format) { case Prospero::StencilFormat::kInvalid: break; case Prospero::StencilFormat::k8UInt: has_stencil = true; break; default: return vk::Format::eUndefined; @@ -318,9 +317,9 @@ inline bool ImageInfo::IsDepth() const noexcept { return std::bit_cast(static_cast(value) / 65535.0f); } -[[nodiscard]] inline constexpr bool IsSupportedSampledDepthFormat(vk::Format image_format, - uint32_t guest_format, - vk::Format view_format) noexcept { +[[nodiscard]] inline constexpr bool +IsSupportedSampledDepthFormat(vk::Format image_format, Prospero::BufferFormat guest_format, + vk::Format view_format) noexcept { const auto* policy = FindGuestDepthFormatPolicy(guest_format); return policy != nullptr && view_format == policy->sampled_view_format && (image_format == policy->depth_attachment_format || @@ -330,8 +329,7 @@ inline bool ImageInfo::IsDepth() const noexcept { [[nodiscard]] inline constexpr bool IsSupportedSampledDepthFormat(vk::Format image_format, vk::Format view_format) noexcept { for (const auto& policy: DEPTH_FORMAT_POLICIES) { - if (IsSupportedSampledDepthFormat(image_format, Prospero::GpuEnumValue(policy.guest_format), - view_format)) { + if (IsSupportedSampledDepthFormat(image_format, policy.guest_format, view_format)) { return true; } } @@ -383,10 +381,10 @@ CanUseVideoOutNativeWithoutUpload(VideoOutCompression compression, bool render_t } struct VideoOutPixelFormatInfo { - vk::Format format = vk::Format::eUndefined; - uint32_t guest_format = 0; - uint32_t bytes_per_element = 0; - bool bgra16 = false; + vk::Format format = vk::Format::eUndefined; + Prospero::BufferFormat guest_format = Prospero::BufferFormat::kInvalid; + uint32_t bytes_per_element = 0; + bool bgra16 = false; }; struct VideoOutFormatPolicy { @@ -396,23 +394,17 @@ struct VideoOutFormatPolicy { inline constexpr std::array VIDEO_OUT_FORMAT_POLICIES {{ {0x8000000022000000ull, - {vk::Format::eR8G8B8A8Srgb, Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8Srgb), 4, - false}}, + {vk::Format::eR8G8B8A8Srgb, Prospero::BufferFormat::k8_8_8_8Srgb, 4, false}}, {0x8000000000000000ull, - {vk::Format::eB8G8R8A8Srgb, Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8Srgb), 4, - false}}, + {vk::Format::eB8G8R8A8Srgb, Prospero::BufferFormat::k8_8_8_8Srgb, 4, false}}, {0x8100000022000000ull, - {vk::Format::eA2B10G10R10UnormPack32, - Prospero::GpuEnumValue(Prospero::BufferFormat::k10_10_10_2UNorm), 4, false}}, + {vk::Format::eA2B10G10R10UnormPack32, Prospero::BufferFormat::k10_10_10_2UNorm, 4, false}}, {0x8100000000000000ull, - {vk::Format::eA2R10G10B10UnormPack32, - Prospero::GpuEnumValue(Prospero::BufferFormat::k10_10_10_2UNorm), 4, false}}, + {vk::Format::eA2R10G10B10UnormPack32, Prospero::BufferFormat::k10_10_10_2UNorm, 4, false}}, {0xc001000622000000ull, - {vk::Format::eR16G16B16A16Sfloat, - Prospero::GpuEnumValue(Prospero::BufferFormat::k16_16_16_16Float), 8, false}}, + {vk::Format::eR16G16B16A16Sfloat, Prospero::BufferFormat::k16_16_16_16Float, 8, false}}, {0xc001000600000000ull, - {vk::Format::eR16G16B16A16Sfloat, - Prospero::GpuEnumValue(Prospero::BufferFormat::k16_16_16_16Float), 8, true}}, + {vk::Format::eR16G16B16A16Sfloat, Prospero::BufferFormat::k16_16_16_16Float, 8, true}}, }}; [[nodiscard]] inline bool DecodeVideoOutPixelFormat(uint64_t pixel_format, @@ -439,15 +431,15 @@ inline constexpr std::array VIDEO_OUT_FORMAT_POLICIES { } [[nodiscard]] inline constexpr bool -IsSupportedDisplayRenderTargetTileMode(uint32_t tile_mode) noexcept { - return tile_mode == Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget); +IsSupportedDisplayRenderTargetTileMode(Prospero::TileMode tile_mode) noexcept { + return tile_mode == Prospero::TileMode::kRenderTarget; } [[nodiscard]] inline constexpr bool IsSupportedStandard64RenderTarget(const ImageInfo& info) { - if (info.tile_mode != Prospero::GpuEnumValue(Prospero::TileMode::kStandard64KB) || - info.data.address == 0 || (info.data.address & 0xffffu) != 0 || info.extent.width == 0 || - info.extent.height == 0 || info.bytes_per_block != 4 || info.resources.levels != 1 || - info.resources.layers != 1 || info.samples != 1) { + if (info.tile_mode != Prospero::TileMode::kStandard64KB || info.data.address == 0 || + (info.data.address & 0xffffu) != 0 || info.extent.width == 0 || info.extent.height == 0 || + info.bytes_per_block != 4 || info.resources.levels != 1 || info.resources.layers != 1 || + info.samples != 1) { return false; } const auto expected_pitch = @@ -460,7 +452,7 @@ IsSupportedDisplayRenderTargetTileMode(uint32_t tile_mode) noexcept { } [[nodiscard]] inline constexpr bool IsTiledRenderTarget(const ImageInfo& info) noexcept { - return info.tile_mode == Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget) || + return info.tile_mode == Prospero::TileMode::kRenderTarget || IsSupportedStandard64RenderTarget(info); } diff --git a/src/graphics/host_gpu/renderer/image/textureCommon.cpp b/src/graphics/host_gpu/renderer/image/textureCommon.cpp index 61197ef9a..fd35a1216 100644 --- a/src/graphics/host_gpu/renderer/image/textureCommon.cpp +++ b/src/graphics/host_gpu/renderer/image/textureCommon.cpp @@ -54,28 +54,27 @@ RenderTargetHostFormatInfo ResolveRenderTargetHostFormat(Prospero::BufferFormat return {vk::Format::eR5G5B5A1UnormPack16, Prospero::ColorMappingAbgr}; case Prospero::BufferFormat::k4_4_4_4UNorm: return {vk::Format::eR4G4B4A4UnormPack16, Prospero::ColorMappingAbgr}; - default: return {VulkanFormat(Prospero::GpuEnumValue(guest_format)), {}}; + default: return {VulkanFormat(guest_format), {}}; } } } // namespace -RenderTargetFormatInfo TextureGetRenderTargetFormat(uint32_t raw_layout, uint32_t raw_type, - uint32_t raw_order) { - const auto encoding = Prospero::ResolveRenderTargetFormat(raw_layout, raw_type); - if (encoding.IsValid() && encoding.SupportsOrder(raw_order)) { - const auto order = static_cast(raw_order); +RenderTargetFormatInfo TextureGetRenderTargetFormat(Prospero::ChannelLayout layout, + Prospero::ChannelType type, + Prospero::ChannelOrder order) { + const auto encoding = Prospero::ResolveRenderTargetFormat(layout, type); + if (encoding.IsValid() && encoding.SupportsOrder(order)) { const auto host = ResolveRenderTargetHostFormat(encoding.buffer_format, order); - const auto bytes = - Prospero::RenderTargetBytesPerElement(Prospero::GpuEnumValue(encoding.buffer_format)); + const auto bytes = Prospero::RenderTargetBytesPerElement(encoding.buffer_format); if (host.format != vk::Format::eUndefined && bytes != 0) { const auto order_mapping = - kRenderTargetColorMappings[raw_order][encoding.components - 1u]; + kRenderTargetColorMappings[static_cast(order)][encoding.components - 1u]; return {host.format, bytes, host.host_to_storage.Then(order_mapping)}; } } - EXIT("unsupported render-target format combination: layout=%u type=%u order=%u\n", raw_layout, - raw_type, raw_order); + EXIT("unsupported render-target format combination: layout=%u type=%u order=%u\n", + static_cast(layout), static_cast(type), static_cast(order)); } namespace { @@ -120,12 +119,12 @@ vk::ComponentMapping TextureGetComponentMapping(uint32_t swizzle) { return components; } -vk::Format TextureGetFormat(uint32_t fmt) { - const auto vk_format = VulkanFormat(fmt); +vk::Format TextureGetFormat(Prospero::BufferFormat format) { + const auto vk_format = VulkanFormat(format); if (vk_format != vk::Format::eUndefined) { return vk_format; } - EXIT("unknown format: fmt = %u\n", fmt); + EXIT("unknown format: fmt = %u\n", static_cast(format)); return vk::Format::eUndefined; } @@ -183,13 +182,14 @@ uint64_t SetLinearUploadLevels(TextureUploadMipLayout* mips, } // namespace -TextureUploadLayout TextureCalcUploadLayout(uint32_t fmt, uint32_t width, uint32_t height, - uint32_t levels, uint32_t depth, uint32_t tile, - uint64_t upload_size, bool allow_depth_tile, - bool volume_texture, const char* owner) { +TextureUploadLayout TextureCalcUploadLayout(Prospero::BufferFormat format, uint32_t width, + uint32_t height, uint32_t levels, uint32_t depth, + Prospero::TileMode tile, uint64_t upload_size, + bool allow_depth_tile, bool volume_texture, + const char* owner) { TextureUploadLayout layout {}; layout.surface.description = { - fmt, + format, tile, volume_texture ? TileSurfaceDimension::Dim3D : TileSurfaceDimension::Dim2D, width, @@ -199,35 +199,39 @@ TextureUploadLayout TextureCalcUploadLayout(uint32_t fmt, uint32_t width, uint32 volume_texture ? 1u : depth, }; const auto& description = layout.surface.description; - const auto tile_mode = static_cast(description.tile_mode); + const auto tile_mode = description.tile_mode; TileTextureElementLayout element {}; - if (fmt == 0) { + if (format == Prospero::BufferFormat::kInvalid) { EXIT("%s: legacy texture upload format unsupported: fmt=0 tile=%u size=%" PRIu64 " extent=%ux%u levels=%u\n", - owner, description.tile_mode, upload_size, width, height, levels); + owner, static_cast(description.tile_mode), upload_size, width, height, + levels); } switch (tile_mode) { case Prospero::TileMode::kLinear: - if (!TileGetTextureElementLayout(fmt, element)) { - EXIT("%s: unsupported linear texture format: fmt=%u\n", owner, fmt); + if (!TileGetTextureElementLayout(format, element)) { + EXIT("%s: unsupported linear texture format: fmt=%u\n", owner, + static_cast(format)); } break; case Prospero::TileMode::kDepth: if (!allow_depth_tile || !TileGetTiledTextureLayout(description, layout.surface)) { EXIT("%s: unsupported typed tiled upload: fmt=%u tile=%u " "size=%" PRIu64 " extent=%ux%u levels=%u\n", - owner, static_cast(fmt), description.tile_mode, upload_size, width, - height, levels); + owner, static_cast(format), + static_cast(description.tile_mode), upload_size, width, height, + levels); } break; default: if (!TileGetTiledTextureLayout(description, layout.surface)) { EXIT("%s: unsupported typed tiled upload: fmt=%u tile=%u " "size=%" PRIu64 " extent=%ux%u levels=%u\n", - owner, static_cast(fmt), description.tile_mode, upload_size, width, - height, levels); + owner, static_cast(format), + static_cast(description.tile_mode), upload_size, width, height, + levels); } break; } @@ -236,12 +240,12 @@ TextureUploadLayout TextureCalcUploadLayout(uint32_t fmt, uint32_t width, uint32 element = {layout.surface.texture.block.bytes_per_element, layout.surface.texture.texel_width, layout.surface.texture.texel_height}; } - layout.pitch = TileGetTexturePitch(fmt, width, description.tile_mode); + layout.pitch = TileGetTexturePitch(format, width, description.tile_mode); if (tile_mode == Prospero::TileMode::kLinear) { TileSizeOffset level_sizes[16] {}; TilePaddedSize padded_sizes[16] {}; - TileGetTextureSize(fmt, width, height, levels, description.tile_mode, nullptr, level_sizes, - padded_sizes); + TileGetTextureSize(format, width, height, levels, description.tile_mode, nullptr, + level_sizes, padded_sizes); for (uint32_t level = 0; level < levels; ++level) { layout.mips[level] = {level_sizes[level].offset, level_sizes[level].size, padded_sizes[level].width, padded_sizes[level].height}; @@ -268,10 +272,9 @@ std::vector TextureBuildImageCopies(const TextureUploadLayo const auto depth = volume_texture ? description.depth : description.layers; uint32_t mip_width = description.width; uint32_t mip_height = description.height; - uint32_t mip_pitch = volume_texture && static_cast(description.tile_mode) != - Prospero::TileMode::kLinear - ? description.width - : layout.pitch; + uint32_t mip_pitch = volume_texture && description.tile_mode != Prospero::TileMode::kLinear + ? description.width + : layout.pitch; std::vector regions; regions.reserve(GetTextureRegionCount(depth, description.levels, volume_texture)); @@ -288,8 +291,7 @@ std::vector TextureBuildImageCopies(const TextureUploadLayo 1}; region.imageOffset.z = volume_texture ? static_cast(z) : 0; region.imageExtent = {mip_width, mip_height, 1}; - const bool linear = static_cast(description.tile_mode) == - Prospero::TileMode::kLinear; + const bool linear = description.tile_mode == Prospero::TileMode::kLinear; if (linear) { region.bufferRowLength = layout.mips[i].row_length; region.bufferImageHeight = layout.mips[i].image_height; diff --git a/src/graphics/host_gpu/renderer/image/textureCommon.h b/src/graphics/host_gpu/renderer/image/textureCommon.h index 80ed3c98b..dc3bef4e4 100644 --- a/src/graphics/host_gpu/renderer/image/textureCommon.h +++ b/src/graphics/host_gpu/renderer/image/textureCommon.h @@ -35,12 +35,15 @@ struct TextureUploadLayout { }; vk::ComponentMapping TextureGetComponentMapping(uint32_t swizzle); -vk::Format TextureGetFormat(uint32_t fmt); -RenderTargetFormatInfo TextureGetRenderTargetFormat(uint32_t layout, uint32_t type, uint32_t order); -TextureUploadLayout TextureCalcUploadLayout(uint32_t fmt, uint32_t width, uint32_t height, - uint32_t levels, uint32_t depth, uint32_t tile, - uint64_t upload_size, bool allow_depth_tile, - bool volume_texture, const char* owner); +vk::Format TextureGetFormat(Prospero::BufferFormat format); +RenderTargetFormatInfo TextureGetRenderTargetFormat(Prospero::ChannelLayout layout, + Prospero::ChannelType type, + Prospero::ChannelOrder order); +TextureUploadLayout TextureCalcUploadLayout(Prospero::BufferFormat format, uint32_t width, + uint32_t height, uint32_t levels, uint32_t depth, + Prospero::TileMode tile, uint64_t upload_size, + bool allow_depth_tile, bool volume_texture, + const char* owner); std::vector TextureBuildImageCopies(const TextureUploadLayout& layout); bool TextureBuildGpuTileInfos(uint64_t tiled_size, const std::vector& regions, const TextureUploadLayout& layout, uint32_t levels, diff --git a/src/graphics/host_gpu/renderer/pipeline/descriptors.cpp b/src/graphics/host_gpu/renderer/pipeline/descriptors.cpp index 52675038d..74080de3c 100644 --- a/src/graphics/host_gpu/renderer/pipeline/descriptors.cpp +++ b/src/graphics/host_gpu/renderer/pipeline/descriptors.cpp @@ -59,7 +59,7 @@ static void CopyNativeDescriptor(const ShaderRecompiler::IR::DescriptorValue& so } static Prospero::ImageType TextureType(const ShaderTextureResource& descriptor) { - const auto type = static_cast(descriptor.Type()); + const auto type = descriptor.Type(); return type == Prospero::ImageType::kCube ? Prospero::ImageType::kColor2DArray : type; } @@ -227,14 +227,14 @@ bool IsSupportedSampledVideoOutView(const ShaderRecompiler::IR::ImageResource& r return image.usage.video_out && image.info.resources.layers == 1 && IsSupportedSampledColorResource(resource) && resource.dimension == ShaderRecompiler::Decoder::ImageDimension::Dim2D && - descriptor.Type() == Prospero::GpuEnumValue(Prospero::ImageType::kColor2D) && - descriptor.Depth() == 0 && descriptor.BaseArray5() == 0; + descriptor.Type() == Prospero::ImageType::kColor2D && descriptor.Depth() == 0 && + descriptor.BaseArray5() == 0; } bool IsSupportedDepthTargetDescriptor(const ShaderTextureResource& descriptor, const Image& image) { const auto width = static_cast(descriptor.Width5()) + 1u; const auto height = static_cast(descriptor.Height5()) + 1u; - const auto type = static_cast(descriptor.Type()); + const auto type = descriptor.Type(); const bool multisampled = IsMultisampledTexture(type); const auto samples = multisampled ? 1u << descriptor.LastLevel() : 1u; const auto pitch = @@ -269,9 +269,8 @@ bool IsSupportedDepthTargetDescriptor(const ShaderTextureResource& descriptor, c (supported_2d || supported_array || supported_cube || supported_msaa_2d || supported_msaa_array) && levels_ok && descriptor.MinLod() == 0 && - descriptor.TileMode() == Prospero::GpuEnumValue(Prospero::TileMode::kDepth) && - descriptor.BCSwizzle() == 0 && (!descriptor.MsaaDepth() || multisampled) && - pitch >= width && pitch == image.info.pitch; + descriptor.TileMode() == Prospero::TileMode::kDepth && descriptor.BCSwizzle() == 0 && + (!descriptor.MsaaDepth() || multisampled) && pitch >= width && pitch == image.info.pitch; } bool IsSupportedDepthTextureEncoding(const ShaderTextureResource& descriptor, const Image& image) { @@ -300,8 +299,8 @@ bool IsSupportedDepthTextureEncoding(const ShaderTextureResource& descriptor, co const uint32_t expected_control = htile_control | (descriptor.MsaaDepth() ? (1u << 10u) : 0u); const auto metadata_addr = descriptor.MetaAddr() << 8u; return (descriptor.fields[6] & 0x00ffffffu) == expected_control && metadata_addr != 0 && - descriptor.TileMode() == Prospero::GpuEnumValue(Prospero::TileMode::kDepth) && - image.info.tile_mode == Prospero::GpuEnumValue(Prospero::TileMode::kDepth) && + descriptor.TileMode() == Prospero::TileMode::kDepth && + image.info.tile_mode == Prospero::TileMode::kDepth && image.info.metadata.kind == ImageMetadataKind::Htile && image.info.metadata.range.Valid() && image.info.metadata.range.address == metadata_addr; } @@ -332,23 +331,21 @@ static void ValidateDepthTargetBinding(const ShaderRecompiler::IR::ImageResource resource_ok, descriptor_ok, encoding_ok, format_ok, static_cast(resource.kind), static_cast(resource.dimension), static_cast(resource.mip_mode), resource.read, resource.written, resource.atomic, resource.depth_compare, - descriptor.Format(), descriptor.DstSelXYZW(), + static_cast(descriptor.Format()), descriptor.DstSelXYZW(), image == nullptr ? static_cast(vk::Format::eUndefined) : static_cast(image->info.pixel_format), static_cast(view_format), image == nullptr ? 0u : image->info.resources.layers, - descriptor.Type(), descriptor.BaseArray5(), descriptor.Depth(), descriptor_pitch, - image == nullptr ? 0u : image->info.pitch, descriptor.Base40(), size, descriptor.fields[0], - descriptor.fields[1], descriptor.fields[2], descriptor.fields[3], descriptor.fields[4], - descriptor.fields[5], descriptor.fields[6], descriptor.fields[7]); + static_cast(descriptor.Type()), descriptor.BaseArray5(), descriptor.Depth(), + descriptor_pitch, image == nullptr ? 0u : image->info.pitch, descriptor.Base40(), size, + descriptor.fields[0], descriptor.fields[1], descriptor.fields[2], descriptor.fields[3], + descriptor.fields[4], descriptor.fields[5], descriptor.fields[6], descriptor.fields[7]); } static bool IsSupportedStorageTextureDescriptor(const ShaderRecompiler::IR::ImageResource& resource, const ShaderTextureResource& descriptor) { - const auto tile = descriptor.TileMode(); - const bool is_color_1d = - descriptor.Type() == Prospero::GpuEnumValue(Prospero::ImageType::kColor1D); - const bool is_color_1d_array = - descriptor.Type() == Prospero::GpuEnumValue(Prospero::ImageType::kColor1DArray); + const auto tile = descriptor.TileMode(); + const bool is_color_1d = descriptor.Type() == Prospero::ImageType::kColor1D; + const bool is_color_1d_array = descriptor.Type() == Prospero::ImageType::kColor1DArray; const bool valid_1d_slice = (is_color_1d && descriptor.Depth() == 0 && descriptor.BaseArray5() == 0) || (is_color_1d_array && descriptor.BaseArray5() <= descriptor.Depth()); @@ -358,10 +355,8 @@ static bool IsSupportedStorageTextureDescriptor(const ShaderRecompiler::IR::Imag resource.dimension == ShaderRecompiler::Decoder::ImageDimension::Dim1DArray && is_color_1d_array && descriptor.Height5() == 0 && descriptor.BaseArray5() <= descriptor.Depth(); - const bool is_color_2d = - descriptor.Type() == Prospero::GpuEnumValue(Prospero::ImageType::kColor2D); - const bool is_color_2d_array = - descriptor.Type() == Prospero::GpuEnumValue(Prospero::ImageType::kColor2DArray); + const bool is_color_2d = descriptor.Type() == Prospero::ImageType::kColor2D; + const bool is_color_2d_array = descriptor.Type() == Prospero::ImageType::kColor2DArray; const bool valid_2d_slice = (is_color_2d && descriptor.Depth() == 0 && descriptor.BaseArray5() == 0) || (is_color_2d_array && descriptor.BaseArray5() <= descriptor.Depth()); @@ -371,11 +366,11 @@ static bool IsSupportedStorageTextureDescriptor(const ShaderRecompiler::IR::Imag resource.dimension == ShaderRecompiler::Decoder::ImageDimension::Dim2DArray && is_color_2d_array && descriptor.BaseArray5() <= descriptor.Depth(); const bool is_3d = resource.dimension == ShaderRecompiler::Decoder::ImageDimension::Dim3D && - descriptor.Type() == Prospero::GpuEnumValue(Prospero::ImageType::kColor3D) && + descriptor.Type() == Prospero::ImageType::kColor3D && descriptor.BaseArray5() == 0; TileTextureBlockLayout tile_layout {}; bool supported_tile = false; - switch (static_cast(tile)) { + switch (tile) { case Prospero::TileMode::kLinear: supported_tile = true; break; case Prospero::TileMode::kDepth: supported_tile = @@ -435,14 +430,12 @@ void ValidateStorageTexture(const ShaderRecompiler::IR::ImageResource& resource, const bool encoding_ok = IsSupportedStorageTextureEncoding(descriptor); const bool uint_resource = resource.kind == ShaderRecompiler::IR::ResourceKind::StorageImageUint; - const bool raw_sint_storage = - format == Prospero::GpuEnumValue(Prospero::BufferFormat::k32SInt) && uint_resource && - resource.written && !resource.read && !resource.atomic; + const bool raw_sint_storage = format == Prospero::BufferFormat::k32SInt && uint_resource && + resource.written && !resource.read && !resource.atomic; const bool format_ok = - raw_sint_storage || - (Prospero::IsSupportedTextureFormat(format) && - uint_resource == Prospero::IsUintTextureFormat(format) && - (!resource.atomic || format == Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt))); + raw_sint_storage || (Prospero::IsSupportedTextureFormat(format) && + uint_resource == Prospero::IsUintTextureFormat(format) && + (!resource.atomic || format == Prospero::BufferFormat::k32UInt)); if (resource_ok && descriptor_ok && encoding_ok && format_ok && size != 0) { return; } @@ -461,24 +454,23 @@ void ValidateStorageTexture(const ShaderRecompiler::IR::ImageResource& resource, IsValidImageSwizzle(descriptor.DstSelXYZW()), descriptor.Base40(), size, static_cast(descriptor.Width5()) + 1u, static_cast(descriptor.Height5()) + 1u, - static_cast(descriptor.Depth()) + 1u, descriptor.Type(), format, - descriptor.TileMode(), descriptor.DstSelXYZW(), resource.read, resource.written, - descriptor.fields[0], descriptor.fields[1], descriptor.fields[2], descriptor.fields[3], - descriptor.fields[4], descriptor.fields[5], descriptor.fields[6], descriptor.fields[7]); + static_cast(descriptor.Depth()) + 1u, static_cast(descriptor.Type()), + static_cast(format), static_cast(descriptor.TileMode()), + descriptor.DstSelXYZW(), resource.read, resource.written, descriptor.fields[0], + descriptor.fields[1], descriptor.fields[2], descriptor.fields[3], descriptor.fields[4], + descriptor.fields[5], descriptor.fields[6], descriptor.fields[7]); } struct NullImageSpec { - vk::Format format; - uint32_t guest_format; + vk::Format format; + Prospero::BufferFormat guest_format; }; static NullImageSpec NullTextureSpec(const ShaderRecompiler::IR::ImageResource& resource) { const bool uint_image = resource.kind == ShaderRecompiler::IR::ResourceKind::ImageUint || resource.kind == ShaderRecompiler::IR::ResourceKind::StorageImageUint; - return uint_image ? NullImageSpec {vk::Format::eR32Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt)} - : NullImageSpec {vk::Format::eR32Sfloat, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float)}; + return uint_image ? NullImageSpec {vk::Format::eR32Uint, Prospero::BufferFormat::k32UInt} + : NullImageSpec {vk::Format::eR32Sfloat, Prospero::BufferFormat::k32Float}; } static TextureCache::ImageDesc NullTextureDesc(const ShaderRecompiler::IR::ImageResource& resource, @@ -504,7 +496,7 @@ static TextureCache::ImageDesc NullTextureDesc(const ShaderRecompiler::IR::Image } static void PopulateTextureMipLayout(ImageInfo& info) { - if (info.IsVolume() && info.tile_mode != Prospero::GpuEnumValue(Prospero::TileMode::kLinear)) { + if (info.IsVolume() && info.tile_mode != Prospero::TileMode::kLinear) { TileSurfaceLayout surface {}; const TileSurfaceDescription description { info.guest_format, info.tile_mode, TileSurfaceDimension::Dim3D, info.extent.width, @@ -631,10 +623,9 @@ RenderExecutor::ResolveTexture(const ShaderRecompiler::IR::ImageResource& reso const bool multisampled = IsMultisampledTexture(type); const auto levels = multisampled ? 1u : static_cast(descriptor.MaxMip()) + 1u; const auto tile = descriptor.TileMode(); - const bool depth_tile = tile == Prospero::GpuEnumValue(Prospero::TileMode::kDepth); - const bool msaa_tile = - depth_tile || tile == Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget); - const bool msaa_array = type == Prospero::ImageType::kColor2DMsaaArray; + const bool depth_tile = tile == Prospero::TileMode::kDepth; + const bool msaa_tile = depth_tile || tile == Prospero::TileMode::kRenderTarget; + const bool msaa_array = type == Prospero::ImageType::kColor2DMsaaArray; if ((!multisampled && (base_level > last_level || last_level >= levels)) || (multisampled && (base_level != 0 || last_level == 0 || last_level > 3 || @@ -644,7 +635,8 @@ RenderExecutor::ResolveTexture(const ShaderRecompiler::IR::ImageResource& reso EXIT("unsupported texture mip view: base=%u last=%u levels=%u max=%u type=%u tile=%u " "kind=%u dimension=%u mip_mode=%u read=%d written=%d " "dwords=%08x,%08x,%08x,%08x,%08x,%08x,%08x,%08x\n", - base_level, last_level, levels, descriptor.MaxMip(), descriptor.Type(), tile, + base_level, last_level, levels, descriptor.MaxMip(), + static_cast(descriptor.Type()), static_cast(tile), static_cast(resource.kind), static_cast(resource.dimension), static_cast(resource.mip_mode), resource.read, resource.written, descriptor.fields[0], descriptor.fields[1], descriptor.fields[2], descriptor.fields[3], @@ -664,7 +656,7 @@ RenderExecutor::ResolveTexture(const ShaderRecompiler::IR::ImageResource& reso resource.kind == ShaderRecompiler::IR::ResourceKind::ImageUint) && !sampled_numeric_class) { EXIT("sampled image numeric class mismatch: kind=%u format=%u addr=0x%016" PRIx64 "\n", - static_cast(resource.kind), format, address); + static_cast(resource.kind), static_cast(format), address); } const bool volume = type == Prospero::ImageType::kColor3D; @@ -694,15 +686,14 @@ RenderExecutor::ResolveTexture(const ShaderRecompiler::IR::ImageResource& reso ValidateStorageTexture(resource, descriptor, size.size); } - const auto pixel_format = TextureGetFormat(format); - const auto storage_view_format = - storage && format == Prospero::GpuEnumValue(Prospero::BufferFormat::k32SInt) - ? vk::Format::eR32Uint - : SrgbStorageViewFormat(pixel_format); - const auto view_format = storage && storage_view_format != vk::Format::eUndefined - ? storage_view_format - : pixel_format; - const auto block_bytes = Prospero::BlockCompressedBytesPerBlock(format); + const auto pixel_format = TextureGetFormat(format); + const auto storage_view_format = storage && format == Prospero::BufferFormat::k32SInt + ? vk::Format::eR32Uint + : SrgbStorageViewFormat(pixel_format); + const auto view_format = storage && storage_view_format != vk::Format::eUndefined + ? storage_view_format + : pixel_format; + const auto block_bytes = Prospero::BlockCompressedBytesPerBlock(format); TextureCache::ImageDesc desc {}; desc.info.data = {address, size.size}; desc.info.pixel_format = pixel_format; diff --git a/src/graphics/host_gpu/renderer/pipeline/shaders.cpp b/src/graphics/host_gpu/renderer/pipeline/shaders.cpp index be304a547..e9c5bfed8 100644 --- a/src/graphics/host_gpu/renderer/pipeline/shaders.cpp +++ b/src/graphics/host_gpu/renderer/pipeline/shaders.cpp @@ -24,6 +24,8 @@ namespace Libs::Graphics { // IDK: maybe we can remove it? +constexpr uint8_t kTemporaryVertexAttribFormat113 = + static_cast(Prospero::VertexAttribFormat::k16_16SInt); constexpr uint32_t kTemporaryPs5BufferFormat121 = 121u; static bool NarrowInputFormat(vk::Format& format, uint32_t& size, uint32_t used_components) { @@ -88,8 +90,9 @@ static bool NarrowInputFormat(vk::Format& format, uint32_t& size, uint32_t used_ static void GetInputFormat(const ShaderBufferResource& res, vk::Format& format, uint32_t& size, uint32_t used_components) { - auto fmt = res.Format(); - if (fmt == Prospero::GpuEnumValue(Prospero::VertexAttribFormat::k16_16SInt)) { + const auto fmt = res.Format(); + const auto raw_format = res.RawFormat(); + if (raw_format == kTemporaryVertexAttribFormat113) { static bool logged_113 = false; if (!logged_113) { LOGF("InputFormat: temporary: accepting invalid PS5 buffer format 113 as " @@ -99,12 +102,12 @@ static void GetInputFormat(const ShaderBufferResource& res, vk::Format& format, format = vk::Format::eR32G32B32A32Sfloat; size = 4; if (NarrowInputFormat(format, size, used_components)) { - LOGF("InputFormat: narrowing fmt=%u to %s for used_components=%u\n", fmt, + LOGF("InputFormat: narrowing fmt=%u to %s for used_components=%u\n", raw_format, VulkanToString(format).c_str(), used_components); } return; } - if (fmt == kTemporaryPs5BufferFormat121) { + if (raw_format == kTemporaryPs5BufferFormat121) { static bool logged_121 = false; if (!logged_121) { LOGF("InputFormat: accepting PS5 buffer format 121 as vk::Format::eR16G16Sfloat\n"); @@ -113,13 +116,13 @@ static void GetInputFormat(const ShaderBufferResource& res, vk::Format& format, format = vk::Format::eR16G16Sfloat; size = 2; if (NarrowInputFormat(format, size, used_components)) { - LOGF("InputFormat: narrowing fmt=%u to %s for used_components=%u\n", fmt, + LOGF("InputFormat: narrowing fmt=%u to %s for used_components=%u\n", raw_format, VulkanToString(format).c_str(), used_components); } return; } - switch (static_cast(fmt)) { + switch (fmt) { case Prospero::BufferFormat::k32_32_32_32Float: format = vk::Format::eR32G32B32A32Sfloat; size = 4; @@ -329,7 +332,7 @@ static void GetInputFormat(const ShaderBufferResource& res, vk::Format& format, size = 1; break; default: - EXIT("unknown format: fmt = %u\n", fmt); + EXIT("unknown format: fmt = %u\n", raw_format); format = vk::Format::eUndefined; size = 4; break; diff --git a/src/graphics/host_gpu/renderer/renderCompute.cpp b/src/graphics/host_gpu/renderer/renderCompute.cpp index 740edb641..6aa624407 100644 --- a/src/graphics/host_gpu/renderer/renderCompute.cpp +++ b/src/graphics/host_gpu/renderer/renderCompute.cpp @@ -93,7 +93,7 @@ bool ResolveComputeImageClear(const ShaderComputeInputInfo& input, uint32_t grou const auto descriptor = DecodeNativeDescriptor(raw); if (!resource.formatted || !resource.written || resource.read || resource.atomic || resource.scalar || resource.max_byte_extent != 16 || descriptor.Stride() != 16 || - descriptor.Format() != Prospero::GpuEnumValue(Prospero::BufferFormat::k32_32_32_32UInt) || + descriptor.Format() != Prospero::BufferFormat::k32_32_32_32UInt || descriptor.SwizzleEnabled() || descriptor.IndexStride() != 0 || descriptor.AddTid() || resource.packed_stride != descriptor.PackedStride() || raw.dword_count != 4 || program.user_data_base != 0 || resources.user_data.size() != 8) { @@ -246,7 +246,7 @@ void RenderExecutor::DispatchDirect(uint64_t submit_id, RenderCommandBuffer& buf LOGF(" CS buffer[%u]: source=%u usage=%s addr=0x%012" PRIx64 " stride=%u records=%u format=%u\n", i, buffer.source, buffer.written ? "read-write" : "read-only", r.Base48(), - r.Stride(), r.NumRecords(), r.Format()); + r.Stride(), r.NumRecords(), r.RawFormat()); } for (uint32_t i = 0; i < program.info.images.size(); i++) { const auto& image = program.info.images[i]; @@ -258,13 +258,13 @@ void RenderExecutor::DispatchDirect(uint64_t submit_id, RenderCommandBuffer& buf image.kind == ShaderRecompiler::IR::ResourceKind::ImageUint) ? "true" : "false", - r.Base40(), static_cast(r.Type()), r.Format(), + r.Base40(), static_cast(r.Type()), static_cast(r.Format()), static_cast(r.Width5()) + 1u, static_cast(r.Height5()) + 1u, static_cast(r.Depth()) + 1u, std::max(static_cast(r.LastLevel()), static_cast(r.MaxMip())) + 1u, - r.TileMode()); + static_cast(r.TileMode())); } for (uint32_t i = 0; i < program.info.samplers.size(); i++) { const auto r = DecodeNativeDescriptor(resources.samplers[i]); diff --git a/src/graphics/host_gpu/renderer/renderDraw.cpp b/src/graphics/host_gpu/renderer/renderDraw.cpp index fb775053f..abcc2024e 100644 --- a/src/graphics/host_gpu/renderer/renderDraw.cpp +++ b/src/graphics/host_gpu/renderer/renderDraw.cpp @@ -123,7 +123,7 @@ static void LogFramebufferSkip(const char* draw_name, const RenderColorInfo& col log_id, draw_name, RenderColorTypeName(color.type), color.base_addr, color.buffer_size, color.image_id ? "yes" : "no", VulkanToString(depth.format).c_str(), depth.image_id ? "yes" : "no", depth.vaddr_num, ctx.GetRenderTargetMask(), - ucfg.GetPrimType(), index_count, flags); + static_cast(ucfg.GetPrimType()), index_count, flags); } static void LogMrtState(const char* draw_name, const RenderCommandBuffer& buffer, @@ -179,10 +179,12 @@ static void LogMrtState(const char* draw_name, const RenderCommandBuffer& buffer " fmt=0x%08" PRIx32 " nfmt=0x%08" PRIx32 " order=0x%08" PRIx32 " width=%u height=%u tile=%u" " blend=%s src=%u dst=%u alpha_src=%u alpha_dst=%u\n", - log_id, i, rt.base.addr, ctm, csm, ps_input_info.target_output_mode[i], rt.info.format, - rt.info.channel_type, rt.info.channel_order, rt.attrib2.width + 1, - rt.attrib2.height + 1, rt.attrib3.tile_mode, bc.enable ? "true" : "false", - bc.color_srcblend, bc.color_destblend, bc.alpha_srcblend, bc.alpha_destblend); + log_id, i, rt.base.addr, ctm, csm, ps_input_info.target_output_mode[i], + static_cast(rt.info.format), static_cast(rt.info.channel_type), + static_cast(rt.info.channel_order), rt.attrib2.width + 1, + rt.attrib2.height + 1, static_cast(rt.attrib3.tile_mode), + bc.enable ? "true" : "false", bc.color_srcblend, bc.color_destblend, bc.alpha_srcblend, + bc.alpha_destblend); } } @@ -225,7 +227,7 @@ static void LogDrawTargetState(const char* draw_name, const RenderColorInfo& col "scissor=(%d,%d)-(%d,%d)\n", log_id, buffer.GetContext().GetGpu().GetFrameNum(), draw_name, RenderColorTypeName(color.type), color.base_addr, extent.width, extent.height, - ucfg.GetPrimType(), index_count, flags, ctx.GetRenderTargetMask(), + static_cast(ucfg.GetPrimType()), index_count, flags, ctx.GetRenderTargetMask(), color.color_clear_enable ? "true" : "false", color.color_clear_value.float32[0], color.color_clear_value.float32[1], color.color_clear_value.float32[2], color.color_clear_value.float32[3], cc.mode, cc.op, bc.enable ? "true" : "false", @@ -289,8 +291,7 @@ static void LogDrawInputState(const RenderCommandBuffer& buffer, const RenderCol const auto& rd = vs_input_info.resources_dst[res_index]; const auto offset = b.attr_offsets[ai]; if (offset + 4u <= b.stride && - r.Format() == - Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8UNorm)) { + r.Format() == Prospero::BufferFormat::k8_8_8_8UNorm) { uint32_t packed = 0; std::memcpy(&packed, rec_bytes + offset, sizeof(packed)); const auto r8 = (packed >> 0u) & 0xffu; @@ -844,7 +845,7 @@ static bool GetDrawTopology(const HW::UserConfig& ucfg, bool auto_draw, topology = vk::PrimitiveTopology::ePointList; - switch (static_cast(ucfg.GetPrimType())) { + switch (ucfg.GetPrimType()) { case Prospero::PrimitiveType::kNone: return false; case Prospero::PrimitiveType::kPointList: topology = vk::PrimitiveTopology::ePointList; @@ -867,14 +868,14 @@ static bool GetDrawTopology(const HW::UserConfig& ucfg, bool auto_draw, break; case Prospero::PrimitiveType::kRectListLegacy: if (!auto_draw) { - EXIT("unknown primitive type: %u\n", ucfg.GetPrimType()); + EXIT("unknown primitive type: %u\n", static_cast(ucfg.GetPrimType())); } topology = vk::PrimitiveTopology::eTriangleStrip; break; case Prospero::PrimitiveType::kQuadListLegacy: topology = vk::PrimitiveTopology::eTriangleFan; break; - default: EXIT("unknown primitive type: %u\n", ucfg.GetPrimType()); + default: EXIT("unknown primitive type: %u\n", static_cast(ucfg.GetPrimType())); } return true; @@ -1051,7 +1052,7 @@ static void EmitDrawPrimitives(const HW::UserConfig& ucfg, vk::CommandBuffer vk_ const DrawEmitInfo& emit) { EXIT_IF(draw.name == nullptr); - switch (static_cast(ucfg.GetPrimType())) { + switch (ucfg.GetPrimType()) { case Prospero::PrimitiveType::kPointList: case Prospero::PrimitiveType::kLineList: case Prospero::PrimitiveType::kLineStrip: @@ -1069,7 +1070,7 @@ static void EmitDrawPrimitives(const HW::UserConfig& ucfg, vk::CommandBuffer vk_ break; case Prospero::PrimitiveType::kRectListLegacy: if (emit.indexed) { - EXIT("unknown primitive type: %u\n", ucfg.GetPrimType()); + EXIT("unknown primitive type: %u\n", static_cast(ucfg.GetPrimType())); } // Sarah EXIT_NOT_IMPLEMENTED(!(draw.index_count == 3 && vs_input_info.buffers_num == 0)); @@ -1087,7 +1088,7 @@ static void EmitDrawPrimitives(const HW::UserConfig& ucfg, vk::CommandBuffer vk_ } } break; - default: EXIT("unknown primitive type: %u\n", ucfg.GetPrimType()); + default: EXIT("unknown primitive type: %u\n", static_cast(ucfg.GetPrimType())); } } @@ -1387,9 +1388,8 @@ void RenderExecutor::DrawAuto(uint64_t submit_id, RenderCommandBuffer& buffer, u } LogDrawStateIfNeeded(buffer, draw, state, false, - ucfg.GetPrimType() == - Prospero::GpuEnumValue(Prospero::PrimitiveType::kRectListLegacy), - 0, nullptr); + ucfg.GetPrimType() == Prospero::PrimitiveType::kRectListLegacy, 0, + nullptr); const auto vertex_offset = ResolveVertexOffset(ucfg.GetIndexOffset(), state.vs_input_info) + static_cast(first_vertex); diff --git a/src/graphics/host_gpu/vulkanCommon.cpp b/src/graphics/host_gpu/vulkanCommon.cpp index f236b1e4f..91b5c7335 100644 --- a/src/graphics/host_gpu/vulkanCommon.cpp +++ b/src/graphics/host_gpu/vulkanCommon.cpp @@ -83,11 +83,11 @@ constexpr FormatMapping kFormatMappings[] = { }; constexpr auto MakeFormatLookup() { - constexpr auto kMaxFormat = Prospero::GpuEnumValue(Prospero::BufferFormat::kBc7Srgb); + constexpr auto kMaxFormat = static_cast(Prospero::BufferFormat::kBc7Srgb); std::array lookup {}; lookup.fill(vk::Format::eUndefined); for (const auto& mapping: kFormatMappings) { - lookup[Prospero::GpuEnumValue(mapping.guest)] = mapping.host; + lookup[static_cast(mapping.guest)] = mapping.host; } return lookup; } @@ -112,9 +112,9 @@ std::string VulkanToString(vk::QueueFlags value) { return vk::to_string(value); } -vk::Format VulkanFormat(uint32_t guest_format) { - return guest_format < kFormatLookup.size() ? kFormatLookup[guest_format] - : vk::Format::eUndefined; +vk::Format VulkanFormat(Prospero::BufferFormat guest_format) { + const auto index = static_cast(guest_format); + return index < kFormatLookup.size() ? kFormatLookup[index] : vk::Format::eUndefined; } void RequireVulkanSuccess(vk::Result result, const char* operation) { diff --git a/src/graphics/host_gpu/vulkanCommon.h b/src/graphics/host_gpu/vulkanCommon.h index eff804423..cb485339c 100644 --- a/src/graphics/host_gpu/vulkanCommon.h +++ b/src/graphics/host_gpu/vulkanCommon.h @@ -10,6 +10,8 @@ #define VMA_STATIC_VULKAN_FUNCTIONS 0 #define VMA_DYNAMIC_VULKAN_FUNCTIONS 1 +#include "graphics/guest_gpu/gpu_defs.h" + #include #include #include @@ -29,7 +31,7 @@ std::string VulkanToString(vk::Result value); std::string VulkanToString(vk::Format value); std::string VulkanToString(vk::ImageLayout value); std::string VulkanToString(vk::QueueFlags value); -vk::Format VulkanFormat(uint32_t guest_format); +vk::Format VulkanFormat(Prospero::BufferFormat guest_format); void RequireVulkanSuccess(vk::Result result, const char* operation); template diff --git a/src/graphics/presentation/videoOut.cpp b/src/graphics/presentation/videoOut.cpp index cf0d4f280..fa0fc3963 100644 --- a/src/graphics/presentation/videoOut.cpp +++ b/src/graphics/presentation/videoOut.cpp @@ -534,8 +534,7 @@ Graphics::ImageInfo BufferAttributeGroup::ImageInfo(const VideoOutBuffer& buffer if (!Graphics::DecodeVideoOutPixelFormat(attribute.pixel_format, pixel_format)) { EXIT("unsupported video-out pixel format: 0x%016" PRIx64 "\n", attribute.pixel_format); } - const auto tile_mode = - Graphics::Prospero::GpuEnumValue(Graphics::Prospero::TileMode::kRenderTarget); + const auto tile_mode = Graphics::Prospero::TileMode::kRenderTarget; const auto pitch = Graphics::TileGetTexturePitch(pixel_format.guest_format, attribute.width, tile_mode); Graphics::TileSizeAlign total {}; diff --git a/src/graphics/shader/recompiler/emitter/spirvEmitterInternal.h b/src/graphics/shader/recompiler/emitter/spirvEmitterInternal.h index 3e23e30cf..57bb3b8c7 100644 --- a/src/graphics/shader/recompiler/emitter/spirvEmitterInternal.h +++ b/src/graphics/shader/recompiler/emitter/spirvEmitterInternal.h @@ -893,7 +893,8 @@ uint32_t EmitByteAddress(EmitterState& state, const IR::Instruction& inst, uint3 uint32_t StorageBufferPackedStride(const EmitterState& state, const IR::MemoryInfo& mem, uint32_t use_pc); -uint32_t StorageBufferFormat(const EmitterState& state, const IR::MemoryInfo& mem, uint32_t use_pc); +Prospero::BufferFormat StorageBufferFormat(const EmitterState& state, const IR::MemoryInfo& mem, + uint32_t use_pc); bool ShouldApplyBufferAddTid(const IR::Instruction& inst); diff --git a/src/graphics/shader/recompiler/emitter/spirvEmitterMemory.cpp b/src/graphics/shader/recompiler/emitter/spirvEmitterMemory.cpp index 11493570c..957343d6e 100644 --- a/src/graphics/shader/recompiler/emitter/spirvEmitterMemory.cpp +++ b/src/graphics/shader/recompiler/emitter/spirvEmitterMemory.cpp @@ -153,8 +153,8 @@ uint32_t StorageBufferPackedStride(const EmitterState& state, const IR::MemoryIn return state.program.info.buffers[mem.resource].packed_stride; } -uint32_t StorageBufferFormat(const EmitterState& state, const IR::MemoryInfo& mem, - uint32_t use_pc) { +Prospero::BufferFormat StorageBufferFormat(const EmitterState& state, const IR::MemoryInfo& mem, + uint32_t use_pc) { (void)use_pc; if (mem.resource >= state.program.info.buffers.size()) { ExitDescriptorBindingFailure(state, IR::DescriptorBindingKind::Buffers, mem.resource, @@ -749,8 +749,7 @@ Prospero::BufferFormat FormattedBufferFormat(const EmitterState& state, const IR::Instruction& inst) { return inst.memory.typed ? Format::DecodeTBufferFormat(inst.memory.data_format, inst.memory.number_format) - : static_cast( - StorageBufferFormat(state, inst.memory, inst.pc)); + : StorageBufferFormat(state, inst.memory, inst.pc); } IR::Instruction WithFormatComponentByteOffset(const IR::Instruction& inst, diff --git a/src/graphics/shader/recompiler/emitter/spirvEmitterModule.cpp b/src/graphics/shader/recompiler/emitter/spirvEmitterModule.cpp index cec1b73cc..a149420f8 100644 --- a/src/graphics/shader/recompiler/emitter/spirvEmitterModule.cpp +++ b/src/graphics/shader/recompiler/emitter/spirvEmitterModule.cpp @@ -64,26 +64,26 @@ VertexInputScalarKind VertexParameterScalarKind(const EmitterState& state, uint3 } switch (state.vertex_input_info->resources[location].Format()) { - case 5: - case 11: - case 18: - case 20: - case 27: - case 60: - case 62: - case 69: - case 72: - case 75: return VertexInputScalarKind::Uint; - case 6: - case 12: - case 19: - case 21: - case 28: - case 61: - case 63: - case 70: - case 73: - case 76: return VertexInputScalarKind::Sint; + case Prospero::BufferFormat::k8UInt: + case Prospero::BufferFormat::k16UInt: + case Prospero::BufferFormat::k8_8UInt: + case Prospero::BufferFormat::k32UInt: + case Prospero::BufferFormat::k16_16UInt: + case Prospero::BufferFormat::k8_8_8_8UInt: + case Prospero::BufferFormat::k32_32UInt: + case Prospero::BufferFormat::k16_16_16_16UInt: + case Prospero::BufferFormat::k32_32_32UInt: + case Prospero::BufferFormat::k32_32_32_32UInt: return VertexInputScalarKind::Uint; + case Prospero::BufferFormat::k8SInt: + case Prospero::BufferFormat::k16SInt: + case Prospero::BufferFormat::k8_8SInt: + case Prospero::BufferFormat::k32SInt: + case Prospero::BufferFormat::k16_16SInt: + case Prospero::BufferFormat::k8_8_8_8SInt: + case Prospero::BufferFormat::k32_32SInt: + case Prospero::BufferFormat::k16_16_16_16SInt: + case Prospero::BufferFormat::k32_32_32SInt: + case Prospero::BufferFormat::k32_32_32_32SInt: return VertexInputScalarKind::Sint; default: return VertexInputScalarKind::Float; } } diff --git a/src/graphics/shader/recompiler/ir/ResourceMaterialization.cpp b/src/graphics/shader/recompiler/ir/ResourceMaterialization.cpp index 76af1d3b7..80ac6b9ab 100644 --- a/src/graphics/shader/recompiler/ir/ResourceMaterialization.cpp +++ b/src/graphics/shader/recompiler/ir/ResourceMaterialization.cpp @@ -220,13 +220,13 @@ bool ValidateResourceSpecialization(const Program& program, const ResourceSnapsh } return false; } - const auto format = (descriptor.dwords[1] >> 20u) & 0x1ffu; - const bool raw_sint_storage = - storage && format == Prospero::GpuEnumValue(Prospero::BufferFormat::k32SInt) && - !image.read && !image.atomic; - const bool uint_descriptor = Prospero::IsUintTextureFormat(format) || raw_sint_storage; - const auto uint_program = image.kind == ResourceKind::ImageUint || - image.kind == ResourceKind::StorageImageUint; + const auto format = + static_cast((descriptor.dwords[1] >> 20u) & 0x1ffu); + const bool raw_sint_storage = storage && format == Prospero::BufferFormat::k32SInt && + !image.read && !image.atomic; + const bool uint_descriptor = Prospero::IsUintTextureFormat(format) || raw_sint_storage; + const auto uint_program = image.kind == ResourceKind::ImageUint || + image.kind == ResourceKind::StorageImageUint; if (uint_descriptor != uint_program && !(image.atomic && uint_program)) { if (error != nullptr) { *error = fmt::format( @@ -415,12 +415,12 @@ bool SpecializeResources(Program& program, const ResourceSnapshot& snapshot, std image.kind == ResourceKind::StorageImageUint) { image.storage_swizzle = DescriptorImageSwizzle(descriptor); } - const auto format = (descriptor.dwords[1] >> 20u) & 0x1ffu; + const auto format = + static_cast((descriptor.dwords[1] >> 20u) & 0x1ffu); const bool storage = image.kind == ResourceKind::StorageImage || image.kind == ResourceKind::StorageImageUint; const bool raw_sint_storage = - storage && format == Prospero::GpuEnumValue(Prospero::BufferFormat::k32SInt) && - !image.read && !image.atomic; + storage && format == Prospero::BufferFormat::k32SInt && !image.read && !image.atomic; const bool uint_image = Prospero::IsUintTextureFormat(format) || raw_sint_storage; if (uint_image) { switch (image.kind) { diff --git a/src/graphics/shader/recompiler/ir/ShaderIR.h b/src/graphics/shader/recompiler/ir/ShaderIR.h index 8f66ad885..8eb3763bd 100644 --- a/src/graphics/shader/recompiler/ir/ShaderIR.h +++ b/src/graphics/shader/recompiler/ir/ShaderIR.h @@ -3,6 +3,7 @@ #include "common/common.h" #include "common/stringUtils.h" +#include "graphics/guest_gpu/gpu_defs.h" #include "graphics/shader/recompiler/cfg/ShaderCFG.h" #include "graphics/shader/recompiler/decompiler/ShaderDecoder.h" #include "graphics/shader/shader.h" @@ -276,17 +277,17 @@ struct SrtPlan { struct BufferResource { static constexpr uint32_t NoImageAlias = UINT32_MAX; - uint32_t source = 0; - uint32_t first_use_pc = 0; - uint32_t max_byte_extent = 0; - uint32_t packed_stride = 0; - uint32_t descriptor_format = 0; - uint32_t image_alias = NoImageAlias; - bool read = false; - bool written = false; - bool atomic = false; - bool formatted = false; - bool scalar = false; + uint32_t source = 0; + uint32_t first_use_pc = 0; + uint32_t max_byte_extent = 0; + uint32_t packed_stride = 0; + Prospero::BufferFormat descriptor_format = Prospero::BufferFormat::kInvalid; + uint32_t image_alias = NoImageAlias; + bool read = false; + bool written = false; + bool atomic = false; + bool formatted = false; + bool scalar = false; bool operator==(const BufferResource& other) const = default; }; diff --git a/src/graphics/shader/shader.cpp b/src/graphics/shader/shader.cpp index 2ae0ff0b8..cb9b20227 100644 --- a/src/graphics/shader/shader.cpp +++ b/src/graphics/shader/shader.cpp @@ -535,7 +535,8 @@ static void ShaderDetectBuffers(ShaderVertexInputInfo& info) { } } -static uint32_t VertexAttribFormatToBufferFormat(uint32_t format) { +static Prospero::BufferFormat +VertexAttribFormatToBufferFormat(Prospero::VertexAttribFormat format) { struct FormatMap { Prospero::VertexAttribFormat vertex; Prospero::BufferFormat buffer; @@ -633,12 +634,12 @@ static uint32_t VertexAttribFormatToBufferFormat(uint32_t format) { }; for (const auto& entry: format_map) { - if (format == Prospero::GpuEnumValue(entry.vertex)) { - return Prospero::GpuEnumValue(entry.buffer); + if (format == entry.vertex) { + return entry.buffer; } } - return format; + return static_cast(static_cast(format)); } static void ShaderApplyAttribSemantics(ShaderVertexInputInfo& info, @@ -659,8 +660,9 @@ static void ShaderApplyAttribSemantics(ShaderVertexInputInfo& info, LOGF("reg = %u, size = %u, va[%u] = 0x%08" PRIx32 "\n", reg, size, i, attrib[in.semantic]); - size_t index = attrib[in.semantic] & 0x1fu; - uint32_t format = (attrib[in.semantic] >> 5u) & 0x1ffu; + size_t index = attrib[in.semantic] & 0x1fu; + auto format = + static_cast((attrib[in.semantic] >> 5u) & 0x1ffu); uint32_t offset = (attrib[in.semantic] >> 14u) & 0xfffu; uint32_t fetch_index = (attrib[in.semantic] >> 26u) & 0x1u; @@ -690,17 +692,19 @@ static void ShaderApplyAttribSemantics(ShaderVertexInputInfo& info, r.fields[1] = sharp[1]; r.fields[2] = sharp[2]; r.fields[3] = sharp[3]; - if (format != 0) { + if (format != Prospero::VertexAttribFormat::kInvalid) { auto buffer_format = VertexAttribFormatToBufferFormat(format); static std::atomic log_count = 0; auto log_id = log_count.fetch_add(1); if (log_id < 64) { LOGF("\t temporary: PS5 vertex attrib semantic %u uses attrib format %u -> buffer " "format %u, offset %u, buffer index %zu\n", - static_cast(in.semantic), format, buffer_format, offset, index); + static_cast(in.semantic), static_cast(format), + static_cast(buffer_format), offset, index); } + const auto buffer_format_raw = static_cast(buffer_format); r.fields[3] = (r.fields[3] & ~((0x7fu << 12u) | 0xfffu)) | - ((buffer_format & 0x7fu) << 12u) | DstSel(4, 5, 6, 7); + ((buffer_format_raw & 0x7fu) << 12u) | DstSel(4, 5, 6, 7); } if (offset != 0) { r.UpdateAddress48(r.Base48() + offset); @@ -1011,7 +1015,7 @@ static std::string ShaderDescribeSpecialization(const ShaderRecompiler::IR::Prog for (uint32_t i = 0; i < program.info.buffers.size(); i++) { const auto& buffer = program.info.buffers[i]; ret += fmt::format(" b{}[stride={} format={}]", i, buffer.packed_stride, - buffer.descriptor_format); + static_cast(buffer.descriptor_format)); } for (uint32_t i = 0; i < program.info.images.size(); i++) { const auto& image = program.info.images[i]; @@ -1047,7 +1051,7 @@ static void ShaderAppendNativeSpecialization(std::vector& ids.push_back(static_cast(program.info.buffers.size())); for (const auto& buffer: program.info.buffers) { ids.push_back(buffer.packed_stride); - ids.push_back(buffer.descriptor_format); + ids.push_back(static_cast(buffer.descriptor_format)); } ids.push_back(static_cast(program.info.images.size())); for (const auto& image: program.info.images) { @@ -1250,7 +1254,7 @@ void ShaderDbgDumpInputInfo(const ShaderVertexInputInfo& info) { r.DstSelX(), r.DstSelY(), r.DstSelZ(), r.DstSelW()); LOGF("\t\t Format() = %" PRIu8 "\n" "\t\t OutOfBounds() = %" PRIu8 "\n", - r.Format(), r.OutOfBounds()); + r.RawFormat(), r.OutOfBounds()); LOGF("\t\t AddTid() = %s\n", r.AddTid() ? "true" : "false"); } @@ -1596,7 +1600,7 @@ ShaderId ShaderGetIdVS(const HW::VertexShaderInfo& regs, const ShaderVertexInput ret.ids.push_back(r.DstSelY()); ret.ids.push_back(r.DstSelZ()); ret.ids.push_back(r.DstSelW()); - ret.ids.push_back(r.Format()); + ret.ids.push_back(r.RawFormat()); ret.ids.push_back(r.OutOfBounds()); ret.ids.push_back(static_cast(r.AddTid())); } diff --git a/src/graphics/shader/shaderBindings.cpp b/src/graphics/shader/shaderBindings.cpp index 244f893f5..f84045bce 100644 --- a/src/graphics/shader/shaderBindings.cpp +++ b/src/graphics/shader/shaderBindings.cpp @@ -29,7 +29,7 @@ ResourceDescriptorType ShaderClassifyResourceDescriptor(const uint32_t* desc) { default: break; } - return (raw_type & Prospero::GpuEnumValue(Prospero::ImageType::kColor1D)) == 0 + return (raw_type & static_cast(Prospero::ImageType::kColor1D)) == 0 ? ResourceDescriptorType::Buffer : ResourceDescriptorType::Unused; } diff --git a/src/graphics/shader/shaderBindings.h b/src/graphics/shader/shaderBindings.h index 051c142de..9bc0ac424 100644 --- a/src/graphics/shader/shaderBindings.h +++ b/src/graphics/shader/shaderBindings.h @@ -3,6 +3,7 @@ #include "common/abi.h" #include "common/common.h" +#include "graphics/guest_gpu/gpu_defs.h" namespace Libs::Graphics { @@ -61,7 +62,10 @@ struct ShaderBufferResource { [[nodiscard]] uint64_t Base48() const { return (fields[0] | (static_cast(fields[1]) << 32u)) & 0xFFFFFFFFFFFFu; } - [[nodiscard]] uint8_t Format() const { return (fields[3] >> 12u) & 0x7Fu; } + [[nodiscard]] uint8_t RawFormat() const { return (fields[3] >> 12u) & 0x7Fu; } + [[nodiscard]] Prospero::BufferFormat Format() const { + return static_cast(RawFormat()); + } [[nodiscard]] uint8_t OutOfBounds() const { return (fields[3] >> 28u) & 0x3u; } [[nodiscard]] uint8_t Type() const { return (fields[3] >> 30u) & 0x3u; } }; @@ -69,25 +73,31 @@ struct ShaderBufferResource { struct ShaderTextureResource { uint32_t fields[8] = {0}; - [[nodiscard]] uint16_t MinLod() const { return (fields[1] >> 8u) & 0xFFFu; } - [[nodiscard]] uint8_t DstSelX() const { return (fields[3] >> 0u) & 0x7u; } - [[nodiscard]] uint8_t DstSelY() const { return (fields[3] >> 3u) & 0x7u; } - [[nodiscard]] uint8_t DstSelZ() const { return (fields[3] >> 6u) & 0x7u; } - [[nodiscard]] uint8_t DstSelW() const { return (fields[3] >> 9u) & 0x7u; } - [[nodiscard]] uint32_t DstSelXY() const { return (fields[3] >> 0u) & 0x3Fu; } - [[nodiscard]] uint32_t DstSelXYZ() const { return (fields[3] >> 0u) & 0x1FFu; } - [[nodiscard]] uint32_t DstSelXYZW() const { return (fields[3] >> 0u) & 0xFFFu; } - [[nodiscard]] uint8_t BaseLevel() const { return (fields[3] >> 12u) & 0xFu; } - [[nodiscard]] uint8_t LastLevel() const { return (fields[3] >> 16u) & 0xFu; } - [[nodiscard]] uint8_t TileMode() const { return (fields[3] >> 20u) & 0x1Fu; } - [[nodiscard]] uint8_t Type() const { return (fields[3] >> 28u) & 0xFu; } + [[nodiscard]] uint16_t MinLod() const { return (fields[1] >> 8u) & 0xFFFu; } + [[nodiscard]] uint8_t DstSelX() const { return (fields[3] >> 0u) & 0x7u; } + [[nodiscard]] uint8_t DstSelY() const { return (fields[3] >> 3u) & 0x7u; } + [[nodiscard]] uint8_t DstSelZ() const { return (fields[3] >> 6u) & 0x7u; } + [[nodiscard]] uint8_t DstSelW() const { return (fields[3] >> 9u) & 0x7u; } + [[nodiscard]] uint32_t DstSelXY() const { return (fields[3] >> 0u) & 0x3Fu; } + [[nodiscard]] uint32_t DstSelXYZ() const { return (fields[3] >> 0u) & 0x1FFu; } + [[nodiscard]] uint32_t DstSelXYZW() const { return (fields[3] >> 0u) & 0xFFFu; } + [[nodiscard]] uint8_t BaseLevel() const { return (fields[3] >> 12u) & 0xFu; } + [[nodiscard]] uint8_t LastLevel() const { return (fields[3] >> 16u) & 0xFu; } + [[nodiscard]] Prospero::TileMode TileMode() const { + return static_cast((fields[3] >> 20u) & 0x1Fu); + } + [[nodiscard]] Prospero::ImageType Type() const { + return static_cast((fields[3] >> 28u) & 0xFu); + } [[nodiscard]] uint16_t Depth() const { return (fields[4] >> 0u) & 0x1FFFu; } [[nodiscard]] uint64_t Base40() const { return ((fields[0] | (static_cast(fields[1]) << 32u)) & 0xFFFFFFFFFFu) << 8u; } - [[nodiscard]] bool IsNull() const { return Base40() == 0; } - [[nodiscard]] uint16_t Format() const { return (fields[1] >> 20u) & 0x1FFu; } + [[nodiscard]] bool IsNull() const { return Base40() == 0; } + [[nodiscard]] Prospero::BufferFormat Format() const { + return static_cast((fields[1] >> 20u) & 0x1FFu); + } [[nodiscard]] uint16_t Width5() const { return ((fields[1] >> 30u) & 0x3u) | (((fields[2] >> 0u) & 0xFFFu) << 2u); } diff --git a/src/libs/agc.cpp b/src/libs/agc.cpp index f12638143..6bef6ed57 100644 --- a/src/libs/agc.cpp +++ b/src/libs/agc.cpp @@ -1076,18 +1076,18 @@ int KYTY_SYSV_ABI GraphicsSetUcRegIndirectPatchAddRegisters(uint32_t* cmd, uint3 static uint32_t GraphicsPrimitiveTypeToGsOut(uint32_t prim_type) { switch (static_cast(prim_type)) { case Prospero::PrimitiveType::kPointList: - return Prospero::GpuEnumValue(Prospero::GsOutputPrimitiveType::kPoints); + return static_cast(Prospero::GsOutputPrimitiveType::kPoints); case Prospero::PrimitiveType::kLineList: case Prospero::PrimitiveType::kLineStrip: case Prospero::PrimitiveType::kLineListAdjacency: case Prospero::PrimitiveType::kLineStripAdjacency: case Prospero::PrimitiveType::kLineLoop: - return Prospero::GpuEnumValue(Prospero::GsOutputPrimitiveType::kLines); + return static_cast(Prospero::GsOutputPrimitiveType::kLines); case Prospero::PrimitiveType::kRectList: - return Prospero::GpuEnumValue(Prospero::GsOutputPrimitiveType::k2dRectangle); + return static_cast(Prospero::GsOutputPrimitiveType::k2dRectangle); case Prospero::PrimitiveType::kRectListLegacy: - return Prospero::GpuEnumValue(Prospero::GsOutputPrimitiveType::kRectList); - default: return Prospero::GpuEnumValue(Prospero::GsOutputPrimitiveType::kTriangles); + return static_cast(Prospero::GsOutputPrimitiveType::kRectList); + default: return static_cast(Prospero::GsOutputPrimitiveType::kTriangles); } } diff --git a/tests/ResourceTrackingTests.cpp b/tests/ResourceTrackingTests.cpp index 87c187f83..dfaedce4e 100644 --- a/tests/ResourceTrackingTests.cpp +++ b/tests/ResourceTrackingTests.cpp @@ -870,8 +870,8 @@ void TestMaterializationSharesReadConstEvaluation() { for (uint32_t i = 0; i < memory.words.size(); i++) { memory.words[i] = 0x100 + i; } - memory.words[1] |= Prospero::GpuEnumValue(Prospero::BufferFormat::k8UNorm) << 20u; - memory.words[3] |= Prospero::GpuEnumValue(Prospero::ImageType::kColor2D) << 28u; + memory.words[1] |= static_cast(Prospero::BufferFormat::k8UNorm) << 20u; + memory.words[3] |= static_cast(Prospero::ImageType::kColor2D) << 28u; std::array user_data {}; user_data[16] = static_cast(memory.base); user_data[17] = static_cast(memory.base >> 32u); @@ -911,7 +911,7 @@ void TestInvalidImagesMaterializeAsNull() { std::string error; for (uint32_t type = 0; type < 8; type++) { auto descriptor = stale; - descriptor[1] |= Prospero::GpuEnumValue(Prospero::BufferFormat::k8UNorm) << 20u; + descriptor[1] |= static_cast(Prospero::BufferFormat::k8UNorm) << 20u; descriptor[3] = (descriptor[3] & 0x0fffffffu) | (type << 28u); ResourceSnapshot snapshot; Check(MaterializeResources(sampled, {descriptor}, snapshot, &error) && @@ -951,7 +951,7 @@ void TestInvalidImagesMaterializeAsNull() { std::array msaa {}; msaa[0] = 1; msaa[1] = 36u << 20u; - msaa[3] = (Prospero::GpuEnumValue(type) << 28u) | (test.base_level << 12u) | + msaa[3] = (static_cast(type) << 28u) | (test.base_level << 12u) | (test.fragments << 16u); msaa[5] = test.max_mip << 4u; ResourceSnapshot msaa_snapshot; @@ -970,7 +970,7 @@ void TestInvalidImagesMaterializeAsNull() { std::array invalid_format {}; invalid_format[0] = 1; - invalid_format[3] = Prospero::GpuEnumValue(Prospero::ImageType::kColor2D) << 28u; + invalid_format[3] = static_cast(Prospero::ImageType::kColor2D) << 28u; ResourceSnapshot invalid_format_snapshot; Check(MaterializeResources(sampled, {invalid_format}, invalid_format_snapshot, &error) && std::all_of(invalid_format_snapshot.images[0].dwords.begin(), @@ -979,9 +979,9 @@ void TestInvalidImagesMaterializeAsNull() { "invalid-format image descriptor was not normalized to null"); auto valid = stale; - valid[1] |= Prospero::GpuEnumValue(Prospero::BufferFormat::k8UNorm) << 20u; + valid[1] |= static_cast(Prospero::BufferFormat::k8UNorm) << 20u; valid[3] = - (valid[3] & 0x0fffffffu) | (Prospero::GpuEnumValue(Prospero::ImageType::kColor2D) << 28u); + (valid[3] & 0x0fffffffu) | (static_cast(Prospero::ImageType::kColor2D) << 28u); ResourceSnapshot valid_snapshot; Check(MaterializeResources(sampled, {valid}, valid_snapshot, &error) && std::equal(valid.begin(), valid.end(), valid_snapshot.images[0].dwords.begin()), @@ -1099,7 +1099,7 @@ void TestResourceSpecializationIsTypedAndTransactional() { array_snapshot.images.resize(1); array_snapshot.images[0].dword_count = 8; array_snapshot.images[0].dwords[0] = 0x1000; - array_snapshot.images[0].dwords[3] = Prospero::GpuEnumValue(Prospero::ImageType::kColor1DArray) + array_snapshot.images[0].dwords[3] = static_cast(Prospero::ImageType::kColor1DArray) << 28u; Check(SpecializeResources(array_view, array_snapshot, &error) && array_view.info.images[0].dimension == Decoder::ImageDimension::Dim1D && @@ -1132,7 +1132,7 @@ void TestResourceSpecializationIsTypedAndTransactional() { Prepare(cross_family_2d_array); auto array_2d_snapshot = array_snapshot; array_2d_snapshot.images[0].dwords[3] = - Prospero::GpuEnumValue(Prospero::ImageType::kColor2DArray) << 28u; + static_cast(Prospero::ImageType::kColor2DArray) << 28u; Check(SpecializeResources(cross_family_2d_array, array_2d_snapshot, &error) && cross_family_2d_array.info.images[0].dimension == Decoder::ImageDimension::Dim2DArray, "array MIMG intent did not produce a 2D-array view"); @@ -1144,7 +1144,7 @@ void TestResourceSpecializationIsTypedAndTransactional() { Decoder::ImageDimension::Dim2DArray)}; Prepare(cube_view); auto cube_snapshot = array_2d_snapshot; - cube_snapshot.images[0].dwords[3] = Prospero::GpuEnumValue(Prospero::ImageType::kCube) << 28u; + cube_snapshot.images[0].dwords[3] = static_cast(Prospero::ImageType::kCube) << 28u; Check(SpecializeResources(cube_view, cube_snapshot, &error) && ValidateResourceSpecialization(cube_view, cube_snapshot, &error) && cube_view.info.images[0].cube && @@ -1152,7 +1152,7 @@ void TestResourceSpecializationIsTypedAndTransactional() { "cube descriptor identity did not reach the specialized image and IR"); auto array_after_cube = cube_snapshot; array_after_cube.images[0].dwords[3] = - Prospero::GpuEnumValue(Prospero::ImageType::kColor2DArray) << 28u; + static_cast(Prospero::ImageType::kColor2DArray) << 28u; Check(!ValidateResourceSpecialization(cube_view, array_after_cube, &error), "2D-array descriptor reused a cube-coordinate specialization"); auto null_after_cube = cube_snapshot; @@ -1185,9 +1185,9 @@ void TestResourceSpecializationIsTypedAndTransactional() { snapshot.images[0].dword_count = 8; snapshot.images[0].dwords[0] = 0x1000; - snapshot.images[0].dwords[1] = Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt) << 20u; + snapshot.images[0].dwords[1] = static_cast(Prospero::BufferFormat::k32UInt) << 20u; snapshot.images[0].dwords[3] = - (Prospero::GpuEnumValue(Prospero::ImageType::kColor2D) << 28u) | 0x3acu; + (static_cast(Prospero::ImageType::kColor2D) << 28u) | 0x3acu; Check(SpecializeResources(program, snapshot, &error), error.c_str()); const auto& image = program.info.images[0]; const auto& inst = program.blocks[0].instructions[0]; @@ -1235,7 +1235,7 @@ void TestRuntimeSpecializationCoversBakedBufferAndAddressFields() { buffer_snapshot.buffers[0].dword_count = 4; buffer_snapshot.buffers[0].dwords[1] = (16u << 16u) | (1u << 31u); buffer_snapshot.buffers[0].dwords[3] = - (Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt) << 12u) | (2u << 21u) | + (static_cast(Prospero::BufferFormat::k32UInt) << 12u) | (2u << 21u) | (1u << 23u); std::string error; Check(SpecializeResources(buffer_program, buffer_snapshot, &error) && @@ -1244,7 +1244,7 @@ void TestRuntimeSpecializationCoversBakedBufferAndAddressFields() { Check(buffer_program.info.buffers[0].packed_stride == (16u | (1u << 14u) | (2u << 16u) | (1u << 20u)) && buffer_program.info.buffers[0].descriptor_format == - Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt), + Prospero::BufferFormat::k32UInt, "buffer specialization omitted SPIR-V-baked descriptor fields"); auto stale_buffer = buffer_snapshot; stale_buffer.buffers[0].dwords[1] ^= 4u << 16u; diff --git a/tests/ShaderRecompilerComputeTests.cpp b/tests/ShaderRecompilerComputeTests.cpp index 6d8721323..3e3a6b99a 100644 --- a/tests/ShaderRecompilerComputeTests.cpp +++ b/tests/ShaderRecompilerComputeTests.cpp @@ -627,7 +627,7 @@ void AppendTBufferLoadOpcode(std::vector* code, u32 opcode, u32 dst_vgpr, u } constexpr u32 BufferFormat(Prospero::BufferFormat format) { - return Prospero::GpuEnumValue(format); + return static_cast(format); } void AppendTBufferLoadFormatOpcode(std::vector* code, u32 opcode, u32 dst_vgpr, @@ -964,7 +964,7 @@ CompiledShader CompileCase(const TestCase& test) { return op >= ShaderOpcode::ImageGetResinfo && op <= ShaderOpcode::ImageGather4H; }); if (uses_image && ((user_data[3] >> 28u) & 0xfu) == 0) { - user_data[3] = Prospero::GpuEnumValue(Prospero::ImageType::kColor2D) << 28u; + user_data[3] = static_cast(Prospero::ImageType::kColor2D) << 28u; } if (uses_image) { user_data[3] = (user_data[3] & ~0xfffu) | test.image_descriptor_swizzle; @@ -1046,8 +1046,8 @@ std::array MakeStructuredStorageBufferData(u32 stride_bytes, u32 num_re std::array MakeStorageTextureData(Prospero::BufferFormat format) { std::array data {}; data[0] = 0x1000u; - data[1] = (Prospero::GpuEnumValue(format) & 0x1ffu) << 20u; - data[3] = Prospero::GpuEnumValue(Prospero::ImageType::kColor2D) << 28u; + data[1] = (static_cast(format) & 0x1ffu) << 20u; + data[3] = static_cast(Prospero::ImageType::kColor2D) << 28u; return data; } @@ -2218,14 +2218,14 @@ public: ImageInfo color_info {}; color_info.pixel_format = vk::Format::eR8G8B8A8Unorm; - color_info.guest_format = Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8UNorm); + color_info.guest_format = Prospero::BufferFormat::k8_8_8_8UNorm; color_info.type = Prospero::ImageType::kColor2D; color_info.extent = {8, 8, 1}; color_info.resources = {2, 2}; color_info.pitch = 8; color_info.bytes_per_block = 4; color_info.samples = 1; - color_info.tile_mode = Prospero::GpuEnumValue(Prospero::TileMode::kLinear); + color_info.tile_mode = Prospero::TileMode::kLinear; color_info.mip_layout[0] = {0, 512, 8, 8}; color_info.mip_layout[1] = {512, 128, 4, 4}; @@ -2281,14 +2281,14 @@ public: ImageInfo depth_info {}; depth_info.pixel_format = vk::Format::eD32Sfloat; - depth_info.guest_format = Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float); + depth_info.guest_format = Prospero::BufferFormat::k32Float; depth_info.type = Prospero::ImageType::kColor2D; depth_info.extent = {8, 8, 1}; depth_info.resources = {1, 2}; depth_info.pitch = 8; depth_info.bytes_per_block = 4; depth_info.samples = 1; - depth_info.tile_mode = Prospero::GpuEnumValue(Prospero::TileMode::kDepth); + depth_info.tile_mode = Prospero::TileMode::kDepth; depth_info.mip_layout[0] = {0, 512, 8, 8}; Libs::Graphics::Image depth(m_runtime_context, scheduler, depth_info); @@ -2900,14 +2900,14 @@ public: sampled.info.data = {base, sizeof(initial)}; sampled.info.pixel_format = vk::Format::eR8G8B8A8Srgb; sampled.info.guest_format = - Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8Srgb); + Prospero::BufferFormat::k8_8_8_8Srgb; sampled.info.type = Prospero::ImageType::kColor2D; sampled.info.extent = {1, 1, 1}; sampled.info.resources = {1, 1}; sampled.info.pitch = 1; sampled.info.bytes_per_block = 4; sampled.info.samples = 1; - sampled.info.tile_mode = Prospero::GpuEnumValue(Prospero::TileMode::kLinear); + sampled.info.tile_mode = Prospero::TileMode::kLinear; sampled.info.mip_layout[0] = {0, 4, 1, 1}; sampled.view_info.format = sampled.info.pixel_format; sampled.view_info.type = vk::ImageViewType::e2D; @@ -2922,7 +2922,7 @@ public: auto compatible_desc = sampled; compatible_desc.info.pixel_format = vk::Format::eR8G8B8A8Uint; compatible_desc.info.guest_format = - Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8UInt); + Prospero::BufferFormat::k8_8_8_8UInt; compatible_desc.view_info.format = compatible_desc.info.pixel_format; const auto compatible = texture_cache.FindImage(compatible_desc); Require(name, "normalized FindImage", @@ -3105,7 +3105,7 @@ public: "typed null-image lookup was not stable"); auto MakeLinearDesc = [&](uint64_t address, uint64_t size, vk::Format format, - uint32_t guest_format, Prospero::ImageType type, + Prospero::BufferFormat guest_format, Prospero::ImageType type, vk::Extent3D extent, uint32_t layers, uint32_t bytes_per_block, uint32_t samples) { ImageDesc desc {}; @@ -3119,7 +3119,7 @@ public: desc.info.pitch = extent.width; desc.info.bytes_per_block = bytes_per_block; desc.info.samples = samples; - desc.info.tile_mode = Prospero::GpuEnumValue(Prospero::TileMode::kLinear); + desc.info.tile_mode = Prospero::TileMode::kLinear; desc.info.mip_layout[0] = {0, size, extent.width, extent.height}; desc.view_info.format = format; if (type == Prospero::ImageType::kColor3D) { @@ -3171,8 +3171,8 @@ public: // after upload so stale CPU staging cannot accidentally // satisfy the content check. constexpr uint64_t mip_prefix_offset = 0x2740000; - constexpr uint32_t mip_format = Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt); - constexpr uint32_t mip_tile = Prospero::GpuEnumValue(Prospero::TileMode::kLinear); + constexpr auto mip_format = Prospero::BufferFormat::k32UInt; + constexpr auto mip_tile = Prospero::TileMode::kLinear; constexpr uint32_t mip_width = 4097; constexpr uint32_t mip_height = 1; constexpr uint32_t mip_levels = 1; @@ -3270,7 +3270,7 @@ public: std::memcpy(memory + 0x1000, volume_values.data(), sizeof(volume_values)); auto array_desc = MakeLinearDesc(base + 0x1000, sizeof(volume_values), vk::Format::eR32Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt), + Prospero::BufferFormat::k32UInt, Prospero::ImageType::kColor2D, {1, 1, 1}, 2, 4, 1); const auto array_image = texture_cache.FindImage(array_desc); (void)texture_cache.FindTexture(array_image, array_desc); @@ -3294,7 +3294,7 @@ public: std::memcpy(memory + unique_volume_offset, volume_values.data(), sizeof(volume_values)); auto unique_volume_desc = MakeLinearDesc( base + unique_volume_offset, sizeof(volume_values), vk::Format::eR32Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt), + Prospero::BufferFormat::k32UInt, Prospero::ImageType::kColor3D, {1, 1, 2}, 1, sizeof(uint32_t), 1); const auto unique_volume_image = texture_cache.FindImage(unique_volume_desc); (void)texture_cache.FindTexture(unique_volume_image, unique_volume_desc); @@ -3326,7 +3326,7 @@ public: sizeof(depth_containment_values)); auto depth_containment = MakeLinearDesc( base + depth_containment_offset, sizeof(depth_containment_values), - vk::Format::eD32Sfloat, Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float), + vk::Format::eD32Sfloat, Prospero::BufferFormat::k32Float, Prospero::ImageType::kColor2D, {2, 1, 1}, 1, sizeof(float), 1); depth_containment.type = BindingType::DepthTarget; depth_containment.info.resources.levels = 2; @@ -3377,14 +3377,14 @@ public: sizeof(block_alias_data)); auto uncompressed_block = MakeLinearDesc( base + block_alias_offset, sizeof(block_alias_data), vk::Format::eR32G32B32A32Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32_32_32_32UInt), + Prospero::BufferFormat::k32_32_32_32UInt, Prospero::ImageType::kColor2D, {1, 1, 1}, 1, 16, 1); const auto uncompressed_block_image = texture_cache.FindImage(uncompressed_block); (void)texture_cache.FindTexture(uncompressed_block_image, uncompressed_block); texture_cache.MarkGpuWritten(uncompressed_block_image); auto compressed_block = MakeLinearDesc( base + block_alias_offset, sizeof(block_alias_data), vk::Format::eBc3UnormBlock, - Prospero::GpuEnumValue(Prospero::BufferFormat::kBc3UNorm), + Prospero::BufferFormat::kBc3UNorm, Prospero::ImageType::kColor2D, {4, 4, 1}, 1, 16, 1); const auto compressed_block_image = texture_cache.FindImage(compressed_block); const bool compressed_block_download = @@ -3405,7 +3405,7 @@ public: ImageInfo resolve_source_info {}; resolve_source_info.pixel_format = vk::Format::eR8G8B8A8Unorm; resolve_source_info.guest_format = - Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8UNorm); + Prospero::BufferFormat::k8_8_8_8UNorm; resolve_source_info.type = Prospero::ImageType::kColor2D; resolve_source_info.extent = {4, 4, 1}; resolve_source_info.resources = {1, 1}; @@ -3413,7 +3413,7 @@ public: resolve_source_info.bytes_per_block = 4; resolve_source_info.samples = 2; resolve_source_info.tile_mode = - Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget); + Prospero::TileMode::kRenderTarget; ImageInfo resolve_destination_info = resolve_source_info; resolve_destination_info.type = Prospero::ImageType::kColor2D; resolve_destination_info.samples = 1; @@ -3439,7 +3439,7 @@ public: std::memcpy(memory + 0x2000, &multisample_source, sizeof(multisample_source)); auto color_desc = MakeLinearDesc(base + 0x2000, sizeof(multisample_source), vk::Format::eR16G16Unorm, - Prospero::GpuEnumValue(Prospero::BufferFormat::k16_16UNorm), + Prospero::BufferFormat::k16_16UNorm, Prospero::ImageType::kColor2D, {1, 1, 1}, 1, 4, 1); const auto color_image = texture_cache.FindImage(color_desc); (void)texture_cache.FindTexture(color_image, color_desc); @@ -3464,7 +3464,7 @@ public: ms_depth_desc.info.stencil = {base + ms_stencil_offset, ms_stencil_size}; ms_depth_desc.info.pixel_format = vk::Format::eD24UnormS8Uint; ms_depth_desc.info.guest_format = - Prospero::GpuEnumValue(Prospero::BufferFormat::k16UNorm); + Prospero::BufferFormat::k16UNorm; ms_depth_desc.info.bytes_per_block = 2; ms_depth_desc.info.samples = 2; ms_depth_desc.info.type = Prospero::ImageType::kColor2D; @@ -3524,14 +3524,14 @@ public: sizeof(multisample_source_4x)); auto color_desc_4x = MakeLinearDesc( base + 0x7000, sizeof(multisample_source_4x), vk::Format::eR16G16B16A16Unorm, - Prospero::GpuEnumValue(Prospero::BufferFormat::k16_16_16_16UNorm), + Prospero::BufferFormat::k16_16_16_16UNorm, Prospero::ImageType::kColor2D, {1, 1, 1}, 1, 8, 1); const auto color_image_4x = texture_cache.FindImage(color_desc_4x); auto ms_depth_desc_4x = color_desc_4x; ms_depth_desc_4x.type = BindingType::DepthTarget; ms_depth_desc_4x.info.pixel_format = vk::Format::eD16Unorm; ms_depth_desc_4x.info.guest_format = - Prospero::GpuEnumValue(Prospero::BufferFormat::k16UNorm); + Prospero::BufferFormat::k16UNorm; ms_depth_desc_4x.info.bytes_per_block = 2; ms_depth_desc_4x.info.samples = 4; ms_depth_desc_4x.info.type = Prospero::ImageType::kColor2D; @@ -3564,7 +3564,7 @@ public: exact_ms_depth_alias.info.stencil = {}; exact_ms_depth_alias.info.pixel_format = vk::Format::eR8G8B8A8Unorm; exact_ms_depth_alias.info.guest_format = - Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8UNorm); + Prospero::BufferFormat::k8_8_8_8UNorm; exact_ms_depth_alias.info.bytes_per_block = 4; exact_ms_depth_alias.view_info.format = vk::Format::eR8G8B8A8Unorm; exact_ms_depth_alias.view_info.aspect = vk::ImageAspectFlagBits::eColor; @@ -3608,7 +3608,7 @@ public: sizeof(added_stencil_depth_value)); auto depth_only_source = MakeLinearDesc(base + added_stencil_depth_offset, 0x10000, vk::Format::eD32Sfloat, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float), + Prospero::BufferFormat::k32Float, Prospero::ImageType::kColor2D, {1, 1, 1}, 1, 4, 1); depth_only_source.type = BindingType::DepthTarget; depth_only_source.view_info.format = vk::Format::eD32Sfloat; @@ -3641,7 +3641,7 @@ public: std::memcpy(memory + 0x5000, &mirror_value, sizeof(mirror_value)); auto mirror_desc = MakeLinearDesc(base + 0x5000, sizeof(mirror_value), vk::Format::eR32Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt), + Prospero::BufferFormat::k32UInt, Prospero::ImageType::kColor2D, {1, 1, 1}, 1, 4, 1); const auto mirror_image = texture_cache.FindImage(mirror_desc); (void)texture_cache.FindTexture(mirror_image, mirror_desc); @@ -3686,7 +3686,7 @@ public: sizeof(exact_buffer_value)); auto exact_buffer_desc = MakeLinearDesc( base + exact_buffer_offset, sizeof(exact_buffer_value), vk::Format::eR32Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt), + Prospero::BufferFormat::k32UInt, Prospero::ImageType::kColor2D, {1, 1, 1}, 1, 4, 1); const auto exact_buffer_image = texture_cache.FindImage(exact_buffer_desc); (void)texture_cache.FindTexture(exact_buffer_image, exact_buffer_desc); @@ -3705,7 +3705,7 @@ public: auto exact_float_desc = exact_buffer_desc; exact_float_desc.info.pixel_format = vk::Format::eR32Sfloat; exact_float_desc.info.guest_format = - Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float); + Prospero::BufferFormat::k32Float; exact_float_desc.view_info.format = vk::Format::eR32Sfloat; const auto exact_float_image = texture_cache.FindImage(exact_float_desc, true); (void)texture_cache.FindTexture(exact_float_image, exact_float_desc); @@ -3738,7 +3738,7 @@ public: std::memcpy(memory + 0x6000, &clear_source, sizeof(clear_source)); auto clear_desc = MakeLinearDesc(base + 0x6000, sizeof(clear_source), vk::Format::eR8G8B8A8Unorm, - Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8UNorm), + Prospero::BufferFormat::k8_8_8_8UNorm, Prospero::ImageType::kColor2D, {1, 1, 1}, 1, 4, 1); const auto clear_image = texture_cache.FindImage(clear_desc); auto buffer_write = resources.GetBufferCache().ObtainBuffer( @@ -3782,7 +3782,7 @@ public: base + partial_buffer_offset, sizeof(partial_buffer_value), partial_buffer_value); auto partial_desc = MakeLinearDesc( base + partial_image_offset, sizeof(partial_image_value), vk::Format::eR32Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt), + Prospero::BufferFormat::k32UInt, Prospero::ImageType::kColor2D, {1, 1, 1}, 1, 4, 1); const auto partial_image = texture_cache.FindImage(partial_desc); Require(name, "partial-page image upload", @@ -3852,7 +3852,7 @@ public: std::memcpy(memory + 0x8010, &fault_b, sizeof(fault_b)); auto fault_a_desc = MakeLinearDesc(base + 0x8000, sizeof(fault_a), vk::Format::eR32Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt), + Prospero::BufferFormat::k32UInt, Prospero::ImageType::kColor2D, {1, 1, 1}, 1, 4, 1); auto fault_b_desc = fault_a_desc; fault_b_desc.info.data.address = base + 0x8010; @@ -3930,7 +3930,7 @@ public: sizeof(publish_image_value)); auto publish_image_desc = MakeLinearDesc( base + publish_image_offset, sizeof(publish_image_value), vk::Format::eR32Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt), + Prospero::BufferFormat::k32UInt, Prospero::ImageType::kColor2D, {1, 1, 1}, 1, 4, 1); const auto publish_image = texture_cache.FindImage(publish_image_desc); (void)texture_cache.FindTexture(publish_image, publish_image_desc); @@ -3940,7 +3940,7 @@ public: auto publish_replacement_desc = publish_image_desc; publish_replacement_desc.info.pixel_format = vk::Format::eR32Sfloat; publish_replacement_desc.info.guest_format = - Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float); + Prospero::BufferFormat::k32Float; publish_replacement_desc.view_info.format = vk::Format::eR32Sfloat; const auto publish_replacement = texture_cache.FindImage(publish_replacement_desc, true); @@ -3967,7 +3967,7 @@ public: std::memset(memory + offset, 0, samples * sizeof(uint16_t)); auto standalone_ms = MakeLinearDesc(base + offset, samples * sizeof(uint16_t), vk::Format::eD16Unorm, - Prospero::GpuEnumValue(Prospero::BufferFormat::k16UNorm), + Prospero::BufferFormat::k16UNorm, Prospero::ImageType::kColor2D, {1, 1, 1}, 1, 2, samples); standalone_ms.type = BindingType::DepthTarget; standalone_ms.view_info.aspect = vk::ImageAspectFlagBits::eDepth; @@ -3992,7 +3992,7 @@ public: constexpr uint64_t metadata_b = 0x13100; auto MakeMetadataDepth = [&](uint64_t data, uint64_t metadata) { auto desc = MakeLinearDesc(base + data, sizeof(uint32_t), vk::Format::eD32Sfloat, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float), + Prospero::BufferFormat::k32Float, Prospero::ImageType::kColor2D, {1, 1, 1}, 1, 4, 1); desc.type = BindingType::DepthTarget; desc.info.metadata.kind = ImageMetadataKind::Htile; @@ -4016,7 +4016,7 @@ public: "shared-page metadata did not retain logical clear state"); auto metadata_alias = MakeLinearDesc(base + metadata_a, sizeof(uint32_t), vk::Format::eR32Sfloat, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float), + Prospero::BufferFormat::k32Float, Prospero::ImageType::kColor2D, {1, 1, 1}, 1, 4, 1); metadata_alias.type = BindingType::RenderTarget; metadata_alias.view_info.usage = vk::ImageUsageFlagBits::eColorAttachment; @@ -4046,7 +4046,7 @@ public: constexpr uint64_t partial_unmap_image_offset = 0x2700000; auto partial_unmap_image = MakeLinearDesc(base + partial_unmap_image_offset, 0x2000, vk::Format::eR32Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt), + Prospero::BufferFormat::k32UInt, Prospero::ImageType::kColor2D, {2048, 1, 1}, 1, 4, 1); const auto partial_unmap_image_id = texture_cache.FindImage(partial_unmap_image); texture_cache.UnmapMemory(partial_unmap_image.info.data.address, 0x1000); @@ -4059,7 +4059,7 @@ public: constexpr uint64_t unformatted_alias_offset = 0x2500000; auto unformatted_alias = MakeLinearDesc( base + unformatted_alias_offset, sizeof(uint32_t), vk::Format::eR32Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt), + Prospero::BufferFormat::k32UInt, Prospero::ImageType::kColor2D, {1, 1, 1}, 1, 4, 1); const auto unformatted_alias_image = texture_cache.FindImage(unformatted_alias); (void)texture_cache.FindTexture(unformatted_alias_image, unformatted_alias); @@ -4083,8 +4083,8 @@ public: 0.625f, 0.75f, 0.875f, 1.0f, 0.0625f}; std::memset(memory + layered_offset, 0, layered_guest_size); const auto layered_layout = TextureCalcUploadLayout( - Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float), 2, 2, 2, 2, - Prospero::GpuEnumValue(Prospero::TileMode::kLinear), layered_guest_size, true, + Prospero::BufferFormat::k32Float, 2, 2, 2, 2, + Prospero::TileMode::kLinear, layered_guest_size, true, false, "UnifiedTextureCacheFlow"); const auto layered_upload_regions = TextureBuildImageCopies(layered_layout); Require(name, "layered guest layout", layered_upload_regions.size() == 4, @@ -4109,7 +4109,7 @@ public: } auto layered_color = MakeLinearDesc(base + layered_offset, layered_guest_size, vk::Format::eR32Sfloat, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float), + Prospero::BufferFormat::k32Float, Prospero::ImageType::kColor2D, {2, 2, 1}, 2, 4, 1); layered_color.info.resources.levels = 2; layered_color.info.mip_layout[0] = {0, 32, 2, 2}; @@ -4153,14 +4153,14 @@ public: &replacement_tail, sizeof(replacement_tail)); auto replacement_source = MakeLinearDesc(base + replacement_offset, sizeof(uint32_t), vk::Format::eR32Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt), + Prospero::BufferFormat::k32UInt, Prospero::ImageType::kColor2D, {1, 1, 1}, 1, 4, 1); const auto replacement_source_image = texture_cache.FindImage(replacement_source); (void)texture_cache.FindTexture(replacement_source_image, replacement_source); texture_cache.MarkGpuWritten(replacement_source_image); auto replacement_desc = MakeLinearDesc(base + replacement_offset, replacement_size, vk::Format::eR32Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt), + Prospero::BufferFormat::k32UInt, Prospero::ImageType::kColor2D, {1, 1, 1}, 2, 4, 1); const auto replacement = texture_cache.FindImage(replacement_desc); const bool replacement_changed = replacement != replacement_source_image; @@ -4189,7 +4189,7 @@ public: std::memcpy(memory + 0xc000, &compressed_value, sizeof(compressed_value)); auto compressed_desc = MakeLinearDesc(base + 0xc000, sizeof(compressed_value), vk::Format::eR8G8B8A8Srgb, - Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8Srgb), + Prospero::BufferFormat::k8_8_8_8Srgb, Prospero::ImageType::kColor2D, {1, 1, 1}, 1, 4, 1); compressed_desc.type = BindingType::RenderTarget; compressed_desc.info.metadata.kind = ImageMetadataKind::Dcc; @@ -4240,7 +4240,7 @@ public: sizeof(mixed_gpu_value), mixed_gpu_value); auto mixed_source_desc = MakeLinearDesc(base + mixed_source_offset, mixed_source_size, vk::Format::eR32Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt), + Prospero::BufferFormat::k32UInt, Prospero::ImageType::kColor2D, {mixed_source_width, 1, 1}, 1, 4, 1); const auto mixed_source_image = texture_cache.FindImage(mixed_source_desc); (void)texture_cache.FindTexture(mixed_source_image, mixed_source_desc); @@ -4272,7 +4272,7 @@ public: byte_mirror_guest.size()); auto byte_mirror_desc = MakeLinearDesc(base + byte_mirror_offset, 1, vk::Format::eR8Unorm, - Prospero::GpuEnumValue(Prospero::BufferFormat::k8UNorm), + Prospero::BufferFormat::k8UNorm, Prospero::ImageType::kColor2D, {1, 1, 1}, 1, 1, 1); const auto byte_mirror_image = texture_cache.FindImage(byte_mirror_desc); (void)texture_cache.FindTexture(byte_mirror_image, byte_mirror_desc); @@ -4292,7 +4292,7 @@ public: std::memcpy(memory + 0xb000, bgra16_guest.data(), sizeof(bgra16_guest)); auto bgra16_desc = MakeLinearDesc(base + 0xb000, sizeof(bgra16_guest), vk::Format::eR16G16B16A16Sfloat, - Prospero::GpuEnumValue(Prospero::BufferFormat::k16_16_16_16Float), + Prospero::BufferFormat::k16_16_16_16Float, Prospero::ImageType::kColor2D, {1, 1, 1}, 1, 8, 1); bgra16_desc.type = BindingType::RenderTarget; bgra16_desc.info.bgra16 = true; @@ -4542,7 +4542,7 @@ public: auto unrelated_stencil_alias = MakeLinearDesc( base + second_stencil_offset, ms_stencil_size, vk::Format::eR32Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt), + Prospero::BufferFormat::k32UInt, Prospero::ImageType::kColor2D, {static_cast(ms_stencil_size / sizeof(uint32_t)), 1, 1}, 1, 4, 1); const auto unrelated_stencil_image = texture_cache.FindImage(unrelated_stencil_alias); @@ -4587,7 +4587,7 @@ public: sizeof(dirty_sibling_value), dirty_sibling_value); auto exact_image_desc = MakeLinearDesc(base + exact_image_offset, sizeof(uint32_t), vk::Format::eR32Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt), + Prospero::BufferFormat::k32UInt, Prospero::ImageType::kColor2D, {1, 1, 1}, 1, 4, 1); const auto exact_image = texture_cache.FindImage(exact_image_desc); (void)texture_cache.FindTexture(exact_image, exact_image_desc); @@ -4612,7 +4612,7 @@ public: } auto gc_image_desc_a = MakeLinearDesc(base + gc_image_offsets[0], sizeof(uint32_t), vk::Format::eR32Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt), + Prospero::BufferFormat::k32UInt, Prospero::ImageType::kColor2D, {1, 1, 1}, 1, 4, 1); auto gc_image_desc_b = gc_image_desc_a; gc_image_desc_b.info.data.address = base + gc_image_offsets[1]; @@ -4729,7 +4729,7 @@ public: constexpr uint32_t submit_readback_stale = 0x2468ace0u; auto submit_readback_desc = MakeLinearDesc( base + submit_readback_offset, sizeof(uint32_t), vk::Format::eR32Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt), + Prospero::BufferFormat::k32UInt, Prospero::ImageType::kColor2D, {1, 1, 1}, 1, 4, 1); submit_readback_desc.type = BindingType::Storage; submit_readback_desc.view_info.usage = vk::ImageUsageFlagBits::eStorage; @@ -4790,7 +4790,7 @@ public: auto linear_depth_desc = MakeLinearDesc( base + linear_depth_offset, sizeof(linear_depth_guest), vk::Format::eD32SfloatS8Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float), + Prospero::BufferFormat::k32Float, Prospero::ImageType::kColor2D, {linear_depth_width, linear_depth_height, 1}, linear_depth_layers, 4, 1); linear_depth_desc.type = BindingType::DepthTarget; @@ -4880,12 +4880,12 @@ public: std::memcpy(memory + tiled_depth_offset, tiled_depth_guest.data(), tiled_depth_size); auto tiled_depth_desc = MakeLinearDesc( base + tiled_depth_offset, tiled_depth_size, vk::Format::eD32Sfloat, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float), + Prospero::BufferFormat::k32Float, Prospero::ImageType::kColor2D, {tiled_depth_width, tiled_depth_height, 1}, tiled_depth_layers, 4, 1); tiled_depth_desc.type = BindingType::DepthTarget; tiled_depth_desc.info.pitch = tiled_depth_pitch; - tiled_depth_desc.info.tile_mode = Prospero::GpuEnumValue(Prospero::TileMode::kDepth); + tiled_depth_desc.info.tile_mode = Prospero::TileMode::kDepth; tiled_depth_desc.info.mip_layout[0] = {0, tiled_depth_size, tiled_depth_pitch, tiled_depth_height}; tiled_depth_desc.view_info.aspect = vk::ImageAspectFlagBits::eDepth; @@ -4996,12 +4996,12 @@ public: tiled_d16_stencil.size()); auto tiled_d16_desc = MakeLinearDesc( base + tiled_d16_offset, tiled_depth_size, vk::Format::eD32SfloatS8Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k16UNorm), + Prospero::BufferFormat::k16UNorm, Prospero::ImageType::kColor2D, {tiled_depth_width, tiled_depth_height, 1}, tiled_depth_layers, 2, 1); tiled_d16_desc.type = BindingType::DepthTarget; tiled_d16_desc.info.pitch = tiled_depth_pitch; - tiled_d16_desc.info.tile_mode = Prospero::GpuEnumValue(Prospero::TileMode::kDepth); + tiled_d16_desc.info.tile_mode = Prospero::TileMode::kDepth; tiled_d16_desc.info.stencil = {base + tiled_d16_stencil_offset, tiled_d16_stencil.size()}; tiled_d16_desc.info.mip_layout[0] = {0, tiled_depth_size, tiled_depth_pitch, @@ -5100,7 +5100,7 @@ public: auto d16_depth_desc = MakeLinearDesc(base + d16_fallback_offset, sizeof(d16_fallback_values), vk::Format::eD24UnormS8Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k16UNorm), + Prospero::BufferFormat::k16UNorm, Prospero::ImageType::kColor2D, {4, 1, 1}, 1, 2, 1); d16_depth_desc.type = BindingType::DepthTarget; d16_depth_desc.info.stencil = {base + d16_fallback_stencil_offset, 4}; @@ -5196,7 +5196,7 @@ public: auto depth = MakeLinearDesc(base + gc_depth_pair_offset + index * gc_depth_pair_stride, sizeof(float), vk::Format::eD32SfloatS8Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float), + Prospero::BufferFormat::k32Float, Prospero::ImageType::kColor2D, {1, 1, 1}, 1, 4, 1); depth.type = BindingType::DepthTarget; depth.info.stencil = {depth.info.data.address + gc_depth_pair_stride / 2, @@ -5244,7 +5244,7 @@ public: std::memset(memory + large_offset, 0, static_cast(large_size)); auto large_desc = MakeLinearDesc( base + large_offset, large_size, vk::Format::eR8G8B8A8Unorm, - Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8UNorm), + Prospero::BufferFormat::k8_8_8_8UNorm, Prospero::ImageType::kColor2D, {large_width, large_height, 1}, 1, 4, 1); const auto RunLargeReadback = [&](uint32_t clear_value) { const auto image = texture_cache.FindImage(large_desc); @@ -5295,18 +5295,18 @@ public: std::memset(memory + tile_alias_offset, 0, static_cast(tile_alias_size)); auto render_target_alias = MakeLinearDesc( base + tile_alias_offset, tile_alias_size, vk::Format::eR8G8B8A8Unorm, - Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8UNorm), + Prospero::BufferFormat::k8_8_8_8UNorm, Prospero::ImageType::kColor2D, {tile_alias_extent, tile_alias_extent, 1}, 1, 4, 1); render_target_alias.type = BindingType::Storage; render_target_alias.info.tile_mode = - Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget); + Prospero::TileMode::kRenderTarget; render_target_alias.view_info.usage = vk::ImageUsageFlagBits::eStorage; const auto render_target_alias_image = texture_cache.FindImage(render_target_alias); auto standard_4kb_alias = render_target_alias; standard_4kb_alias.type = BindingType::Texture; standard_4kb_alias.info.tile_mode = - Prospero::GpuEnumValue(Prospero::TileMode::kStandard4KB); + Prospero::TileMode::kStandard4KB; standard_4kb_alias.view_info.usage = vk::ImageUsageFlagBits::eSampled; const auto standard_4kb_alias_image = texture_cache.FindImage(standard_4kb_alias); auto repeated_standard_4kb_alias = standard_4kb_alias; @@ -5323,12 +5323,10 @@ public: texture_cache .GetImage(render_target_alias_image) .info.tile_mode == - Prospero::GpuEnumValue( - Prospero::TileMode::kRenderTarget) && + Prospero::TileMode::kRenderTarget && texture_cache.GetImage(standard_4kb_alias_image) .info.tile_mode == - Prospero::GpuEnumValue( - Prospero::TileMode::kStandard4KB), + Prospero::TileMode::kStandard4KB, "equal address/size lookup reused an incompatible " "tiled backing"); @@ -5371,9 +5369,8 @@ public: constexpr const char* name = "Bgra16Readback"; constexpr uintptr_t base = 0x0000000204000000ull; constexpr uint64_t allocation_size = 0x200000; - constexpr uint32_t format = - Prospero::GpuEnumValue(Prospero::BufferFormat::k16_16_16_16Float); - constexpr uint32_t tile = Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget); + constexpr auto format = Prospero::BufferFormat::k16_16_16_16Float; + constexpr auto tile = Prospero::TileMode::kRenderTarget; EnsureRuntimeContext(); int64_t direct_offset = -1; @@ -5526,13 +5523,13 @@ public: HW::Shader shaders {}; registers.SetColorBase(0, {.addr = base}); registers.SetColorInfo( - 0, {.format = Prospero::GpuEnumValue(Prospero::ChannelLayout::k10_10_10_2), - .channel_type = Prospero::GpuEnumValue(Prospero::ChannelType::kUNorm), - .channel_order = Prospero::GpuEnumValue(Prospero::ChannelOrder::kStandard)}); + 0, {.format = Prospero::ChannelLayout::k10_10_10_2, + .channel_type = Prospero::ChannelType::kUNorm, + .channel_order = Prospero::ChannelOrder::kStandard}); registers.SetColorAttrib2(0, {.height = 31, .width = 31}); registers.SetColorAttrib3( 0, {.depth = 31, - .tile_mode = Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget), + .tile_mode = Prospero::TileMode::kRenderTarget, .dimension = 2, .cmask_pipe_aligned = true, .dcc_pipe_aligned = true}); @@ -5585,7 +5582,7 @@ public: auto storage_desc = color.desc; storage_desc.type = BindingType::Storage; storage_desc.info.guest_format = - Prospero::GpuEnumValue(Prospero::BufferFormat::k10_10_10_2UNorm); + Prospero::BufferFormat::k10_10_10_2UNorm; storage_desc.view_info.type = vk::ImageViewType::e3D; storage_desc.view_info.usage = vk::ImageUsageFlagBits::eStorage; const auto storage_id = texture_cache.FindImage(storage_desc); @@ -5679,8 +5676,8 @@ public: auto& executor = context.GetRenderExecutor(); resources.MapMemory(base, allocation_size); - constexpr auto stencil_format = Prospero::GpuEnumValue(Prospero::BufferFormat::k8UInt); - constexpr auto linear = Prospero::GpuEnumValue(Prospero::TileMode::kLinear); + constexpr auto stencil_format = Prospero::BufferFormat::k8UInt; + constexpr auto linear = Prospero::TileMode::kLinear; TileSizeAlign stencil_layout {}; TileGetTextureTotalSize(stencil_format, 1, 1, 1, 1, linear, false, stencil_layout); @@ -5760,7 +5757,7 @@ public: desc.type = BindingType::RenderTarget; desc.info.data = {address, size}; desc.info.pixel_format = vk::Format::eR32Uint; - desc.info.guest_format = Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt); + desc.info.guest_format = Prospero::BufferFormat::k32UInt; desc.info.type = Prospero::ImageType::kColor2D; desc.info.extent = extent; desc.info.resources = {1, 1}; @@ -5786,9 +5783,11 @@ public: const uint64_t encoded_storage_address = storage_address >> 8u; storage.fields[0] = static_cast(encoded_storage_address); storage.fields[1] = - static_cast(encoded_storage_address >> 32u) | (stencil_format << 20u); - storage.fields[3] = DstSel(4, 5, 6, 7) | (linear << 20u) | - (Prospero::GpuEnumValue(Prospero::ImageType::kColor2D) << 28u); + static_cast(encoded_storage_address >> 32u) | + (static_cast(stencil_format) << 20u); + storage.fields[3] = DstSel(4, 5, 6, 7) | + (static_cast(linear) << 20u) | + (static_cast(Prospero::ImageType::kColor2D) << 28u); storage.fields[5] = 0x00700000u; ShaderRecompiler::IR::Program storage_program {}; storage_program.stage = ShaderType::Vertex; @@ -5804,7 +5803,7 @@ public: storage_descriptor.dword_count = 8; auto srgb_storage = storage; constexpr auto srgb_format = - Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8Srgb); + static_cast(Prospero::BufferFormat::k8_8_8_8Srgb); constexpr uint64_t srgb_storage_address = base + 0xc0000; const auto encoded_srgb_storage_address = srgb_storage_address >> 8u; srgb_storage.fields[0] = static_cast(encoded_srgb_storage_address); @@ -5836,11 +5835,11 @@ public: sint_storage.Base40() == 0x1514b0000ull && sint_storage.Width5() + 1u == 48 && sint_storage.Height5() + 1u == 48 && sint_storage.Depth() + 1u == 1 && sint_storage.Format() == - Prospero::GpuEnumValue(Prospero::BufferFormat::k32SInt) && + Prospero::BufferFormat::k32SInt && sint_storage.Type() == - Prospero::GpuEnumValue(Prospero::ImageType::kColor2D) && + Prospero::ImageType::kColor2D && sint_storage.TileMode() == - Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget) && + Prospero::TileMode::kRenderTarget && sint_storage.DstSelXYZW() == DstSel(4, 0, 0, 1), "captured write-only signed storage descriptor was decoded " "incorrectly"); @@ -5874,10 +5873,11 @@ public: const auto encoded_narrowed_address = narrowed_storage_address >> 8u; narrowed_storage.fields[0] = static_cast(encoded_narrowed_address); narrowed_storage.fields[1] = - static_cast(encoded_narrowed_address >> 32u) | (stencil_format << 20u); + static_cast(encoded_narrowed_address >> 32u) | + (static_cast(stencil_format) << 20u); narrowed_storage.fields[3] = - DstSel(4, 5, 6, 7) | (linear << 20u) | - (Prospero::GpuEnumValue(Prospero::ImageType::kColor1DArray) << 28u); + DstSel(4, 5, 6, 7) | (static_cast(linear) << 20u) | + (static_cast(Prospero::ImageType::kColor1DArray) << 28u); narrowed_storage.fields[4] = 1u | (1u << 16u); ShaderRecompiler::IR::DescriptorValue narrowed_storage_descriptor {}; std::copy(std::begin(narrowed_storage.fields), std::end(narrowed_storage.fields), @@ -5943,7 +5943,8 @@ public: const auto encoded_ordered_address = ordered_sampled_address >> 8u; ordered_sampled.fields[0] = static_cast(encoded_ordered_address); ordered_sampled.fields[1] = - static_cast(encoded_ordered_address >> 32u) | (stencil_format << 20u); + static_cast(encoded_ordered_address >> 32u) | + (static_cast(stencil_format) << 20u); ShaderRecompiler::IR::DescriptorValue ordered_descriptor {}; std::copy(std::begin(ordered_sampled.fields), std::end(ordered_sampled.fields), ordered_descriptor.dwords.begin()); @@ -6032,7 +6033,7 @@ public: split_desc.type = BindingType::Texture; split_desc.info.data = {base + 0x50000, sizeof(split_mip_data)}; split_desc.info.pixel_format = vk::Format::eR32Uint; - split_desc.info.guest_format = Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt); + split_desc.info.guest_format = Prospero::BufferFormat::k32UInt; split_desc.info.type = Prospero::ImageType::kColor2D; split_desc.info.extent = {2, 1, 1}; split_desc.info.resources = {2, 1}; @@ -6117,14 +6118,12 @@ public: constexpr uint64_t phased_stencil_address = base + 0xa0000; constexpr uint64_t phased_htile_address = base + 0xb0000; HW::DepthRenderTarget phased_depth_target {}; - phased_depth_target.z_info.format = - Prospero::GpuEnumValue(Prospero::DepthFormat::kZ32F); + phased_depth_target.z_info.format = Prospero::DepthFormat::kZ32F; phased_depth_target.z_info.texture_compatibility = Prospero::TextureCompatiblePlaneCompression::kEnable; phased_depth_target.z_info.htile_acceleration = true; phased_depth_target.z_info.z_compare_base = Prospero::ZCompareBase::kZMax; - phased_depth_target.stencil_info.format = - Prospero::GpuEnumValue(Prospero::StencilFormat::k8UInt); + phased_depth_target.stencil_info.format = Prospero::StencilFormat::k8UInt; phased_depth_target.stencil_info.texture_compatibility = Prospero::TextureCompatibleStencil::kEnable; phased_depth_target.z_read_base_addr = phased_depth_address; @@ -6191,8 +6190,7 @@ public: constexpr uint64_t depth_only_address = base + 0x140000; HW::DepthRenderTarget depth_only_target {}; - depth_only_target.z_info.format = - Prospero::GpuEnumValue(Prospero::DepthFormat::kZ32F); + depth_only_target.z_info.format = Prospero::DepthFormat::kZ32F; depth_only_target.z_info.z_compare_base = Prospero::ZCompareBase::kZMax; depth_only_target.stencil_info.htile_stencil_disabled = true; depth_only_target.z_read_base_addr = depth_only_address; @@ -6230,7 +6228,7 @@ public: video_subresource.type = BindingType::VideoOut; video_subresource.info.pixel_format = vk::Format::eR8G8B8A8Srgb; video_subresource.info.guest_format = - Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8Srgb); + Prospero::BufferFormat::k8_8_8_8Srgb; video_subresource.view_info.format = video_subresource.info.pixel_format; video_subresource.view_info.usage = vk::ImageUsageFlagBits::eSampled; const auto video_subresource_id = texture_cache.FindImage(video_subresource); @@ -6240,7 +6238,7 @@ public: video_parent.type = BindingType::VideoOut; video_parent.info.pixel_format = vk::Format::eR8G8B8A8Srgb; video_parent.info.guest_format = - Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8Srgb); + Prospero::BufferFormat::k8_8_8_8Srgb; video_parent.info.resources.levels = 2; video_parent.info.mip_layout[0] = {0, target_mip_size, 2, 2}; video_parent.info.mip_layout[1] = {target_mip_size, target_mip_size, 1, 1}; @@ -6275,14 +6273,14 @@ public: ShaderTextureResource array_texture {}; const auto encoded_array_address = array_target_address >> 8u; - constexpr auto array_format = Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt); + constexpr auto array_format = static_cast(Prospero::BufferFormat::k32UInt); array_texture.fields[0] = static_cast(encoded_array_address); array_texture.fields[1] = static_cast(encoded_array_address >> 32u) | (array_format << 20u) | (3u << 30u); array_texture.fields[2] = (127u >> 2u) | (127u << 14u); array_texture.fields[3] = - DstSel(4, 5, 6, 7) | (linear << 20u) | - (Prospero::GpuEnumValue(Prospero::ImageType::kColor2DArray) << 28u); + DstSel(4, 5, 6, 7) | (static_cast(linear) << 20u) | + (static_cast(Prospero::ImageType::kColor2DArray) << 28u); array_texture.fields[4] = 1; ShaderRecompiler::IR::Program array_program {}; @@ -6353,8 +6351,8 @@ public: auto colliding_msaa_texture = array_texture; colliding_msaa_texture.fields[3] = DstSel(4, 5, 6, 7) | (1u << 16u) | - (Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget) << 20u) | - (Prospero::GpuEnumValue(Prospero::ImageType::kColor2DMsaa) << 28u); + (static_cast(Prospero::TileMode::kRenderTarget) << 20u) | + (static_cast(Prospero::ImageType::kColor2DMsaa) << 28u); colliding_msaa_texture.fields[4] = 0; colliding_msaa_texture.fields[5] = (7u << 20u) | (1u << 4u); ShaderRecompiler::IR::DescriptorValue colliding_msaa_descriptor {}; @@ -6394,7 +6392,7 @@ public: constexpr uint32_t msaa_samples = 4; auto msaa_target = make_target_desc(msaa_target_address, 0x40000, {128, 128, 1}); msaa_target.info.samples = msaa_samples; - msaa_target.info.tile_mode = Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget); + msaa_target.info.tile_mode = Prospero::TileMode::kRenderTarget; msaa_target.info.mip_layout[0].size = msaa_target.info.data.size; const auto msaa_target_id = texture_cache.FindImage(msaa_target); RenderExecutorTestAccess::BindRenderTarget(executor, msaa_target_id); @@ -6408,8 +6406,8 @@ public: (array_format << 20u) | (3u << 30u); msaa_texture.fields[3] = DstSel(4, 5, 6, 7) | (2u << 16u) | - (Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget) << 20u) | - (Prospero::GpuEnumValue(Prospero::ImageType::kColor2DMsaa) << 28u); + (static_cast(Prospero::TileMode::kRenderTarget) << 20u) | + (static_cast(Prospero::ImageType::kColor2DMsaa) << 28u); msaa_texture.fields[4] = 0; msaa_texture.fields[5] = (7u << 20u) | (2u << 4u); ShaderRecompiler::IR::DescriptorValue msaa_descriptor {}; @@ -6444,7 +6442,7 @@ public: auto msaa_array_texture = msaa_texture; msaa_array_texture.fields[3] = (msaa_array_texture.fields[3] & ~(0xfu << 28u)) | - (Prospero::GpuEnumValue(Prospero::ImageType::kColor2DMsaaArray) << 28u); + (static_cast(Prospero::ImageType::kColor2DMsaaArray) << 28u); msaa_array_texture.fields[4] = 1; ShaderRecompiler::IR::DescriptorValue msaa_array_descriptor {}; std::copy(std::begin(msaa_array_texture.fields), std::end(msaa_array_texture.fields), @@ -6483,7 +6481,7 @@ public: depth.info.data = {depth_address, 0x10000}; depth.info.stencil = {stencil_address, stencil_layout.size}; depth.info.pixel_format = vk::Format::eD32SfloatS8Uint; - depth.info.guest_format = Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float); + depth.info.guest_format = Prospero::BufferFormat::k32Float; depth.info.type = Prospero::ImageType::kColor2D; depth.info.extent = {1, 1, 1}; depth.info.resources = {1, 1}; @@ -6657,9 +6655,11 @@ public: const uint64_t encoded_address = stencil_address >> 8u; stencil.fields[0] = static_cast(encoded_address); stencil.fields[1] = - static_cast(encoded_address >> 32u) | (stencil_format << 20u); - stencil.fields[3] = DstSel(4, 5, 6, 7) | (linear << 20u) | - (Prospero::GpuEnumValue(Prospero::ImageType::kColor2D) << 28u); + static_cast(encoded_address >> 32u) | + (static_cast(stencil_format) << 20u); + stencil.fields[3] = DstSel(4, 5, 6, 7) | + (static_cast(linear) << 20u) | + (static_cast(Prospero::ImageType::kColor2D) << 28u); ShaderRecompiler::IR::Program program {}; program.stage = ShaderType::Compute; @@ -7927,13 +7927,13 @@ public: standard_3d.block_depth == 16 && color_z == 0x800 && depth_z == 0xf00, "a fixed block address changed"); - constexpr u32 format = Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float); + constexpr auto format = Prospero::BufferFormat::k32Float; constexpr u32 levels = 7; TileSizeAlign total {}; TileSizeOffset mip[levels] {}; TilePaddedSize padded[levels] {}; TileGetTextureSize(format, 65, 33, levels, - Prospero::GpuEnumValue(Prospero::TileMode::kStandard256B), &total, + Prospero::TileMode::kStandard256B, &total, mip, padded); constexpr u32 offsets[levels] = {0x1a00, 0xb00, 0x500, 0x300, 0x200, 0x100, 0}; constexpr u32 sizes[levels] = {0x2d00, 0xf00, 0x600, 0x200, 0x100, 0x100, 0x100}; @@ -8039,17 +8039,17 @@ public: // intentionally share a shader, but this loop still validates their // texel-to-element conversion (notably every BCn format). struct StandardMode { - u32 tile; + Prospero::TileMode tile; TileBlockFamily family; }; constexpr StandardMode standard_modes[] = { - {Prospero::GpuEnumValue(Prospero::TileMode::kStandard256B), + {Prospero::TileMode::kStandard256B, TileBlockFamily::Standard256B}, - {Prospero::GpuEnumValue(Prospero::TileMode::kStandard4KB), + {Prospero::TileMode::kStandard4KB, TileBlockFamily::Standard4KB}, - {Prospero::GpuEnumValue(Prospero::TileMode::kStandard64KB), + {Prospero::TileMode::kStandard64KB, TileBlockFamily::Standard64KB}, - {Prospero::GpuEnumValue(Prospero::TileMode::kPrt), TileBlockFamily::Prt64KB}, + {Prospero::TileMode::kPrt, TileBlockFamily::Prt64KB}, }; for (const auto format: {Prospero::BufferFormat::k8Srgb, Prospero::BufferFormat::k8_8Srgb, @@ -8058,16 +8058,15 @@ public: Prospero::TileMode::kRenderTarget}) { TileTextureBlockLayout texture {}; Require(name, "RT format policy", - !TileGetTextureBlockLayout(Prospero::GpuEnumValue(format), - Prospero::GpuEnumValue(tile), false, texture), + !TileGetTextureBlockLayout(format, tile, false, texture), "non-render-target format admitted by an RT/depth tile family"); } } { TileSurfaceLayout invalid {}; const TileSurfaceDescription description { - Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float), - Prospero::GpuEnumValue(Prospero::TileMode::kStandard256B), + Prospero::BufferFormat::k32Float, + Prospero::TileMode::kStandard256B, TileSurfaceDimension::Dim3D, 16, 16, @@ -8079,9 +8078,9 @@ public: "Standard256B volume silently fell back to a 2D array layout"); } { - constexpr u32 format = - Prospero::GpuEnumValue(Prospero::BufferFormat::kFmask8_S4_F4); - constexpr u32 tile = Prospero::GpuEnumValue(Prospero::TileMode::kStandard64KB); + constexpr auto format = + Prospero::BufferFormat::kFmask8_S4_F4; + constexpr auto tile = Prospero::TileMode::kStandard64KB; TileSizeAlign total {}; TileGetTextureSize(format, 128, 128, 1, tile, &total, nullptr, nullptr); const auto layout = TextureCalcUploadLayout(format, 128, 128, 1, 1, tile, total.size, @@ -8093,8 +8092,10 @@ public: "FMASK entered the texel tiler through a non-depth family"); } u32 format_cases = 0; - for (u32 format = 1; format <= Prospero::GpuEnumValue(Prospero::BufferFormat::kBc7Srgb); - ++format) { + for (u32 raw_format = 1; + raw_format <= static_cast(Prospero::BufferFormat::kBc7Srgb); + ++raw_format) { + const auto format = static_cast(raw_format); // FMASK is synthesized as identity metadata by TextureUploadFmask; it is // deliberately not a texel surface and must never enter the GPU tiler. if (Prospero::IsFmaskTextureFormat(format)) { @@ -8124,8 +8125,9 @@ public: std::vector infos; if (!TextureBuildGpuTileInfos(total.size, regions, layout, 1, infos)) { std::ostringstream out; - out << "format=" << format << " tile=" << mode.tile << " size=" << total.size - << " pitch=" << pitch; + out << "format=" << raw_format + << " tile=" << static_cast(mode.tile) + << " size=" << total.size << " pitch=" << pitch; Fail(name, "format infos", out.str()); } Require(name, "format family", @@ -8147,15 +8149,15 @@ public: "no CPU-supported standard formats were tested"); { - constexpr u32 format = Prospero::GpuEnumValue(Prospero::BufferFormat::k32_32_32Float); + constexpr auto format = Prospero::BufferFormat::k32_32_32Float; TileTextureElementLayout element {}; Require(name, "RGB32 texture policy", !TileGetTextureElementLayout(format, element), "12-byte texel layouts must be rejected"); } { - constexpr u32 format = Prospero::GpuEnumValue(Prospero::BufferFormat::kBc1UNorm); - constexpr u32 tile = Prospero::GpuEnumValue(Prospero::TileMode::kStandard64KB); + constexpr auto format = Prospero::BufferFormat::kBc1UNorm; + constexpr auto tile = Prospero::TileMode::kStandard64KB; constexpr u32 width = 256, height = 256, levels = 9; TileSizeAlign total {}; TileGetTextureSize(format, width, height, levels, tile, &total, nullptr, @@ -8177,8 +8179,8 @@ public: } { - constexpr u32 format = Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float); - constexpr u32 tile = Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget); + constexpr auto format = Prospero::BufferFormat::k32Float; + constexpr auto tile = Prospero::TileMode::kRenderTarget; constexpr u32 width = 129, height = 65, layers = 3; TileSizeAlign total {}; TileGetTextureTotalSize(format, width, height, layers, 1, tile, false, total); @@ -8195,7 +8197,7 @@ public: } for (const auto& mode: standard_modes) { - constexpr u32 format = Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float); + constexpr auto format = Prospero::BufferFormat::k32Float; constexpr u32 levels = 2; TileBlockLayout block {}; Require(name, "odd mip block", TileGetBlockLayout(mode.family, 4, block), @@ -8222,21 +8224,21 @@ public: } struct TailMode { - u32 tile; + Prospero::TileMode tile; TileBlockFamily family; }; constexpr TailMode tail_modes[] = { - {Prospero::GpuEnumValue(Prospero::TileMode::kStandard4KB), + {Prospero::TileMode::kStandard4KB, TileBlockFamily::Standard4KB}, - {Prospero::GpuEnumValue(Prospero::TileMode::kStandard64KB), + {Prospero::TileMode::kStandard64KB, TileBlockFamily::Standard64KB}, - {Prospero::GpuEnumValue(Prospero::TileMode::kPrt), TileBlockFamily::Prt64KB}, - {Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget), + {Prospero::TileMode::kPrt, TileBlockFamily::Prt64KB}, + {Prospero::TileMode::kRenderTarget, TileBlockFamily::RenderTarget64KB}, - {Prospero::GpuEnumValue(Prospero::TileMode::kDepth), TileBlockFamily::Depth64KB}, + {Prospero::TileMode::kDepth, TileBlockFamily::Depth64KB}, }; for (const auto& mode: tail_modes) { - constexpr u32 format = Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float); + constexpr auto format = Prospero::BufferFormat::k32Float; constexpr u32 levels = 7; TileBlockLayout block {}; Require(name, "2D tail block", TileGetBlockLayout(mode.family, 4, block), @@ -8261,8 +8263,8 @@ public: } { - constexpr u32 format = Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float); - constexpr u32 tile = Prospero::GpuEnumValue(Prospero::TileMode::kStandard4KB); + constexpr auto format = Prospero::BufferFormat::k32Float; + constexpr auto tile = Prospero::TileMode::kStandard4KB; constexpr u32 width = 65; constexpr u32 height = 129; constexpr u32 depth = 17; @@ -8287,8 +8289,8 @@ public: } { - constexpr u32 format = Prospero::GpuEnumValue(Prospero::BufferFormat::kBc1UNorm); - constexpr u32 tile = Prospero::GpuEnumValue(Prospero::TileMode::kStandard4KB); + constexpr auto format = Prospero::BufferFormat::kBc1UNorm; + constexpr auto tile = Prospero::TileMode::kStandard4KB; constexpr u32 width = 65; constexpr u32 height = 129; constexpr u32 depth = 17; @@ -8308,8 +8310,8 @@ public: } { - constexpr u32 format = Prospero::GpuEnumValue(Prospero::BufferFormat::kBc3UNorm); - constexpr u32 tile = Prospero::GpuEnumValue(Prospero::TileMode::kLinear); + constexpr auto format = Prospero::BufferFormat::kBc3UNorm; + constexpr auto tile = Prospero::TileMode::kLinear; constexpr u32 width = 8, height = 8, levels = 4; TileSizeAlign total {}; TileGetTextureSize(format, width, height, levels, tile, &total, nullptr, @@ -8331,26 +8333,26 @@ public: } struct VolumeModeCase { - u32 tile; + Prospero::TileMode tile; TileBlockFamily family; - u32 format; + Prospero::BufferFormat format; }; constexpr VolumeModeCase volume_modes[] = { - {Prospero::GpuEnumValue(Prospero::TileMode::kStandard64KB), + {Prospero::TileMode::kStandard64KB, TileBlockFamily::Standard64KB3D, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float)}, - {Prospero::GpuEnumValue(Prospero::TileMode::kPrt), TileBlockFamily::Prt64KB3D, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float)}, - {Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget), + Prospero::BufferFormat::k32Float}, + {Prospero::TileMode::kPrt, TileBlockFamily::Prt64KB3D, + Prospero::BufferFormat::k32Float}, + {Prospero::TileMode::kRenderTarget, TileBlockFamily::RenderTarget64KB, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float)}, - {Prospero::GpuEnumValue(Prospero::TileMode::kDepth), TileBlockFamily::Depth64KB, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float)}, - {Prospero::GpuEnumValue(Prospero::TileMode::kStandard64KB), + Prospero::BufferFormat::k32Float}, + {Prospero::TileMode::kDepth, TileBlockFamily::Depth64KB, + Prospero::BufferFormat::k32Float}, + {Prospero::TileMode::kStandard64KB, TileBlockFamily::Standard64KB3D, - Prospero::GpuEnumValue(Prospero::BufferFormat::kBc1UNorm)}, - {Prospero::GpuEnumValue(Prospero::TileMode::kPrt), TileBlockFamily::Prt64KB3D, - Prospero::GpuEnumValue(Prospero::BufferFormat::kBc3UNorm)}, + Prospero::BufferFormat::kBc1UNorm}, + {Prospero::TileMode::kPrt, TileBlockFamily::Prt64KB3D, + Prospero::BufferFormat::kBc3UNorm}, }; for (const auto test: volume_modes) { constexpr u32 width = 65, height = 33, depth = 37, levels = 6; @@ -8377,17 +8379,17 @@ public: } struct VolumeTailCase { - u32 format; - u32 bytes; + Prospero::BufferFormat format; + u32 bytes; }; constexpr VolumeTailCase volume_tails[] = { - {Prospero::GpuEnumValue(Prospero::BufferFormat::k8UNorm), 1}, - {Prospero::GpuEnumValue(Prospero::BufferFormat::k16UNorm), 2}, - {Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float), 4}, - {Prospero::GpuEnumValue(Prospero::BufferFormat::k16_16_16_16Float), 8}, - {Prospero::GpuEnumValue(Prospero::BufferFormat::k32_32_32_32Float), 16}, - {Prospero::GpuEnumValue(Prospero::BufferFormat::kBc1UNorm), 8}, - {Prospero::GpuEnumValue(Prospero::BufferFormat::kBc3UNorm), 16}, + {Prospero::BufferFormat::k8UNorm, 1}, + {Prospero::BufferFormat::k16UNorm, 2}, + {Prospero::BufferFormat::k32Float, 4}, + {Prospero::BufferFormat::k16_16_16_16Float, 8}, + {Prospero::BufferFormat::k32_32_32_32Float, 16}, + {Prospero::BufferFormat::kBc1UNorm, 8}, + {Prospero::BufferFormat::kBc3UNorm, 16}, }; constexpr u32 volume_tail_xy[5][5][2] = { {{0, 8}, {8, 4}, {8, 0}, {0, 4}, {0, 0}}, {{0, 8}, {4, 4}, {4, 0}, {0, 4}, {0, 0}}, @@ -8395,7 +8397,7 @@ public: {{0, 4}, {2, 2}, {2, 0}, {0, 2}, {0, 0}}, }; for (const auto& tail: volume_tails) { - constexpr u32 tile = Prospero::GpuEnumValue(Prospero::TileMode::kStandard4KB); + constexpr auto tile = Prospero::TileMode::kStandard4KB; constexpr u32 levels = 5; TileBlockLayout block {}; Require(name, "3D tail block", @@ -8509,8 +8511,8 @@ public: std::span(&small_info, 1)); compare("scheduler-owned reuse", small_expected, small_output); - constexpr u32 volume_format = Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt); - constexpr u32 volume_tile = Prospero::GpuEnumValue(Prospero::TileMode::kLinear); + constexpr auto volume_format = Prospero::BufferFormat::k32UInt; + constexpr auto volume_tile = Prospero::TileMode::kLinear; constexpr u32 volume_width = 8, volume_height = 4, volume_depth = 5; constexpr u32 volume_levels = 3; const u32 volume_pitch = @@ -14581,7 +14583,7 @@ TestCase ImageLoad1DUsesScalarCoordinate() { test.sampled_image_type = vk::ImageType::e1D; test.sampled_image_view_type = vk::ImageViewType::e1D; test.user_data = MakeSampledTextureData(Prospero::BufferFormat::k32UInt); - test.user_data[3] = Prospero::GpuEnumValue(Prospero::ImageType::kColor1D) << 28u; + test.user_data[3] = static_cast(Prospero::ImageType::kColor1D) << 28u; test.has_user_data = true; test.required_spirv = {"sampled_uint_1d"}; return test; @@ -14612,7 +14614,7 @@ TestCase ImageLoad1DArrayUsesLayerCoordinate() { test.sampled_image_view_type = vk::ImageViewType::e1DArray; test.sampled_image_layers = 2; test.user_data = MakeSampledTextureData(Prospero::BufferFormat::k32UInt); - test.user_data[3] = Prospero::GpuEnumValue(Prospero::ImageType::kColor1DArray) << 28u; + test.user_data[3] = static_cast(Prospero::ImageType::kColor1DArray) << 28u; test.has_user_data = true; test.required_spirv = {"sampled_uint_1d_array"}; return test; @@ -14646,7 +14648,7 @@ TestCase ImageLoad1DArrayDescriptorUsesSelectedLayer() { test.sampled_image_view_base_layer = 1; test.sampled_image_view_layers = 1; test.user_data = MakeSampledTextureData(Prospero::BufferFormat::k32UInt); - test.user_data[3] = Prospero::GpuEnumValue(Prospero::ImageType::kColor1DArray) << 28u; + test.user_data[3] = static_cast(Prospero::ImageType::kColor1DArray) << 28u; test.user_data[4] = 1u | (1u << 16u); test.has_user_data = true; test.required_spirv = {"sampled_uint_1d"}; @@ -15035,7 +15037,7 @@ TestCase ImageStoreRgbOneUsesInverseSwizzle() { test.opcodes = {O::VMovB32, O::ImageStore, O::SEndpgm}; test.has_user_data = true; test.user_data[0] = 0x1000u; - test.user_data[1] = Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8UNorm) << 20u; + test.user_data[1] = static_cast(Prospero::BufferFormat::k8_8_8_8UNorm) << 20u; test.image_descriptor_swizzle = DstSel(4, 5, 6, 1); test.storage_image_format = vk::Format::eR8G8B8A8Unorm; test.storage_image_dwords_per_pixel = 1; @@ -15074,7 +15076,7 @@ TestCase ImageStoreBgraUsesInverseSwizzle() { test.opcodes = {O::VMovB32, O::ImageStore, O::SEndpgm}; test.has_user_data = true; test.user_data[0] = 0x1000u; - test.user_data[1] = Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8UNorm) << 20u; + test.user_data[1] = static_cast(Prospero::BufferFormat::k8_8_8_8UNorm) << 20u; test.image_descriptor_swizzle = DstSel(6, 5, 4, 7); test.storage_image_format = vk::Format::eR8G8B8A8Unorm; test.storage_image_dwords_per_pixel = 1; @@ -15802,7 +15804,7 @@ void CheckPs5GameExampleImageClearRuntimeShape() { user_data[0] = 0x00010000u; user_data[1] = 16u << 16u; user_data[2] = 64; - user_data[3] = (Prospero::GpuEnumValue(Prospero::BufferFormat::k32_32_32_32UInt) << 12u) | 4u | + user_data[3] = (static_cast(Prospero::BufferFormat::k32_32_32_32UInt) << 12u) | 4u | (5u << 3u) | (6u << 6u) | (7u << 9u); std::fill(user_data.begin() + 4, user_data.end(), 0xff000000u); ShaderComputeInputInfo compute {}; @@ -15970,34 +15972,42 @@ void CheckEmbeddedFetchVertexOffset() { } [[noreturn]] void RunReverseRenderTargetDeathCase() { - (void)TextureGetRenderTargetFormat(12u, 6u, 0u); + (void)TextureGetRenderTargetFormat(Prospero::ChannelLayout::k16_16_16_16, + Prospero::ChannelType::kSrgb, + Prospero::ChannelOrder::kStandard); std::_Exit(0x7f); } #if KYTY_PLATFORM == KYTY_PLATFORM_WINDOWS void CheckRenderTargetFormatContract() { const auto r8_uint = - TextureGetRenderTargetFormat(Prospero::GpuEnumValue(Prospero::ChannelLayout::k8), - Prospero::GpuEnumValue(Prospero::ChannelType::kUInt), - Prospero::GpuEnumValue(Prospero::ChannelOrder::kStandard)); + TextureGetRenderTargetFormat(Prospero::ChannelLayout::k8, + Prospero::ChannelType::kUInt, + Prospero::ChannelOrder::kStandard); Require("RenderTargetFormat", "R8 uint", r8_uint.format == vk::Format::eR8Uint && r8_uint.bytes_per_element == 1u && r8_uint.export_mapping.IsIdentity(), "R8 uint render-target tuple was rejected"); - const auto rgb565 = TextureGetRenderTargetFormat(16u, 0u, 0u); + const auto rgb565 = TextureGetRenderTargetFormat(Prospero::ChannelLayout::k5_6_5, + Prospero::ChannelType::kUNorm, + Prospero::ChannelOrder::kStandard); Require("RenderTargetFormat", "RGB565 UNorm", rgb565.format == vk::Format::eB5G6R5UnormPack16 && rgb565.bytes_per_element == 2u && rgb565.export_mapping.IsIdentity(), "RGB565 UNorm render-target tuple was rejected"); - const auto uint_format = TextureGetRenderTargetFormat(12u, 4u, 0u); + const auto uint_format = TextureGetRenderTargetFormat( + Prospero::ChannelLayout::k16_16_16_16, Prospero::ChannelType::kUInt, + Prospero::ChannelOrder::kStandard); Require("RenderTargetFormat", "RGBA16 uint", uint_format.format == vk::Format::eR16G16B16A16Uint && uint_format.bytes_per_element == 8u && uint_format.export_mapping.IsIdentity(), "RGBA16 uint render-target tuple was rejected"); - const auto format = TextureGetRenderTargetFormat(12u, 7u, 2u); + const auto format = TextureGetRenderTargetFormat( + Prospero::ChannelLayout::k16_16_16_16, Prospero::ChannelType::kFloat, + Prospero::ChannelOrder::kReversed); Require("ReverseRenderTarget", "exact format", format.format == vk::Format::eR16G16B16A16Sfloat && format.bytes_per_element == 8u && format.export_mapping == Prospero::ColorMappingAbgr, @@ -16010,7 +16020,9 @@ void CheckRenderTargetFormatContract() { format.export_mapping.ApplyMask(0xfu) == 0xfu, "reverse RGBA16F component mask was not mapped exactly once"); - const auto rg32 = TextureGetRenderTargetFormat(11u, 7u, 2u); + const auto rg32 = TextureGetRenderTargetFormat(Prospero::ChannelLayout::k32_32, + Prospero::ChannelType::kFloat, + Prospero::ChannelOrder::kReversed); Require("ReverseRenderTarget", "GR32 float", rg32.format == vk::Format::eR32G32Sfloat && rg32.bytes_per_element == 8u && rg32.export_mapping == Prospero::ColorMappingGr && @@ -16020,7 +16032,9 @@ void CheckRenderTargetFormatContract() { rg32.export_mapping.ApplyMask(0xfu) == 0xfu, "reverse GR32F render-target export or write-mask mapping is incorrect"); - const auto argb = TextureGetRenderTargetFormat(12u, 7u, 3u); + const auto argb = TextureGetRenderTargetFormat( + Prospero::ChannelLayout::k16_16_16_16, Prospero::ChannelType::kFloat, + Prospero::ChannelOrder::kAltReversed); Require("ReverseRenderTarget", "ARGB float", argb.format == vk::Format::eR16G16B16A16Sfloat && argb.export_mapping == Prospero::ColorMappingArgb && @@ -16081,14 +16095,14 @@ void CheckRenderTargetFormatContract() { CommandScheduler scheduler(vulkan.RuntimeRenderer(), graphics); ImageInfo volume_info {}; volume_info.pixel_format = vk::Format::eR8G8B8A8Unorm; - volume_info.guest_format = Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8UNorm); + volume_info.guest_format = Prospero::BufferFormat::k8_8_8_8UNorm; volume_info.type = Prospero::ImageType::kColor3D; volume_info.extent = {8, 8, 4}; volume_info.resources = {2, 1}; volume_info.pitch = 8; volume_info.bytes_per_block = 4; volume_info.samples = 1; - volume_info.tile_mode = Prospero::GpuEnumValue(Prospero::TileMode::kLinear); + volume_info.tile_mode = Prospero::TileMode::kLinear; Libs::Graphics::Image volume(graphics, scheduler, volume_info); ImageViewInfo view {}; view.format = volume_info.pixel_format; @@ -16401,17 +16415,17 @@ void CheckSampledVideoOutView(RenderContext& renderer) { resource.read = true; ShaderTextureResource descriptor {}; - descriptor.fields[3] = Prospero::GpuEnumValue(Prospero::ImageType::kColor2D) << 28u; + descriptor.fields[3] = static_cast(Prospero::ImageType::kColor2D) << 28u; ImageInfo info {}; info.pixel_format = vk::Format::eR8G8B8A8Unorm; - info.guest_format = Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8UNorm); + info.guest_format = Prospero::BufferFormat::k8_8_8_8UNorm; info.type = Prospero::ImageType::kColor2D; info.extent = {1, 1, 1}; info.resources = {1, 1}; info.pitch = 1; info.bytes_per_block = 4; info.samples = 1; - info.tile_mode = Prospero::GpuEnumValue(Prospero::TileMode::kLinear); + info.tile_mode = Prospero::TileMode::kLinear; info.mip_layout[0] = {0, 4, 1, 1}; Image image(context, scheduler, info); image.usage.video_out = true; @@ -16424,10 +16438,10 @@ void CheckSampledVideoOutView(RenderContext& renderer) { const bool rejects_array_resource = !IsSupportedSampledVideoOutView(resource, descriptor, image); resource = basic_resource; - descriptor.fields[3] = Prospero::GpuEnumValue(Prospero::ImageType::kColor2DArray) << 28u; + descriptor.fields[3] = static_cast(Prospero::ImageType::kColor2DArray) << 28u; const bool rejects_array_descriptor = !IsSupportedSampledVideoOutView(resource, descriptor, image); - descriptor.fields[3] = Prospero::GpuEnumValue(Prospero::ImageType::kColor2D) << 28u; + descriptor.fields[3] = static_cast(Prospero::ImageType::kColor2D) << 28u; descriptor.fields[4] = 1u << 16u; const bool rejects_base_layer = !IsSupportedSampledVideoOutView(resource, descriptor, image); descriptor.fields[4] = 1u; @@ -16449,14 +16463,14 @@ void CheckImageTransitionState(RenderContext& renderer) { const auto MakeInfo = [](vk::Format format, uint32_t levels, uint32_t layers) { ImageInfo info {}; info.pixel_format = format; - info.guest_format = Prospero::GpuEnumValue(Prospero::BufferFormat::k8UNorm); + info.guest_format = Prospero::BufferFormat::k8UNorm; info.type = Prospero::ImageType::kColor2D; info.extent = {4, 4, 1}; info.resources = {levels, layers}; info.pitch = 4; info.bytes_per_block = 1; info.samples = 1; - info.tile_mode = Prospero::GpuEnumValue(Prospero::TileMode::kLinear); + info.tile_mode = Prospero::TileMode::kLinear; return info; }; const auto graphics_stage = @@ -16588,9 +16602,9 @@ void CheckImageTransitionState(RenderContext& renderer) { "normalized state did not return to one full barrier"); auto depth_info = MakeInfo(vk::Format::eD32SfloatS8Uint, 1, 1); - depth_info.guest_format = Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float); + depth_info.guest_format = Prospero::BufferFormat::k32Float; depth_info.bytes_per_block = 4; - depth_info.tile_mode = Prospero::GpuEnumValue(Prospero::TileMode::kDepth); + depth_info.tile_mode = Prospero::TileMode::kDepth; Image depth(context, scheduler, depth_info); barriers = depth.GetBarriers(vk::ImageLayout::eDepthStencilReadOnlyOptimal, vk::AccessFlagBits2::eShaderRead, graphics_stage, {}); @@ -16712,14 +16726,14 @@ void CheckSampledDepthDescriptor(RenderContext& renderer) { vk::Format format, Prospero::ImageType type, uint32_t samples = 1) { ImageInfo info {}; info.pixel_format = format; - info.guest_format = Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float); + info.guest_format = Prospero::BufferFormat::k32Float; info.type = type; info.extent = {width, height, 1}; info.resources = {1, layers}; info.pitch = pitch; info.bytes_per_block = 4; info.samples = samples; - info.tile_mode = Prospero::GpuEnumValue(Prospero::TileMode::kDepth); + info.tile_mode = Prospero::TileMode::kDepth; info.mip_layout[0] = {0, static_cast(pitch) * height * layers * 4, pitch, height}; return info; }; @@ -16758,12 +16772,12 @@ void CheckSampledDepthDescriptor(RenderContext& renderer) { "compatibility flag"); descriptor.fields[3] = (descriptor.fields[3] & ~(0xfu << 28u)) | - (Prospero::GpuEnumValue(Prospero::ImageType::kColor2DArray) << 28u); + (static_cast(Prospero::ImageType::kColor2DArray) << 28u); Require("SampledDepthDescriptor", "singleton array descriptor", IsSupportedDepthTargetDescriptor(descriptor, image), "normalized singleton-array depth view was rejected"); descriptor.fields[3] = (descriptor.fields[3] & ~(0xfu << 28u)) | - (Prospero::GpuEnumValue(Prospero::ImageType::kColor2D) << 28u); + (static_cast(Prospero::ImageType::kColor2D) << 28u); ShaderTextureResource cube_descriptor {{0x01267d00u, 0xc0700000u, 0x00ffc0ffu, 0xb1800924u, 0x00000005u, 0x00700000u, 0x00000000u, 0x00000000u}}; @@ -17019,10 +17033,10 @@ ShaderTextureResource AtomicStorageTextureDescriptor() { resource.written = false; } else if (std::strcmp(kind, "type") == 0) { descriptor.fields[3] = (descriptor.fields[3] & 0x0fffffffu) | - (Prospero::GpuEnumValue(Prospero::ImageType::kColor2D) << 28u); + (static_cast(Prospero::ImageType::kColor2D) << 28u); } else if (std::strcmp(kind, "standard256b-volume") == 0) { descriptor.fields[3] = (descriptor.fields[3] & ~(0x1fu << 20u)) | - (Prospero::GpuEnumValue(Prospero::TileMode::kStandard256B) << 20u); + (static_cast(Prospero::TileMode::kStandard256B) << 20u); } else if (std::strcmp(kind, "mip") == 0) { descriptor.fields[3] |= 1u << 16u; } else if (std::strcmp(kind, "swizzle") == 0) { @@ -17036,7 +17050,7 @@ ShaderTextureResource AtomicStorageTextureDescriptor() { } else if (std::strcmp(kind, "uint-format") == 0) { descriptor.fields[1] = (descriptor.fields[1] & ~0x1ff00000u) | - (Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8UInt) << 20u); + (static_cast(Prospero::BufferFormat::k8_8_8_8UInt) << 20u); } else if (std::strcmp(kind, "uint-resource-float-format") == 0) { resource = BasicUintArrayStorageTextureResource(); descriptor = BasicArrayStorageTextureDescriptor(); @@ -17044,7 +17058,7 @@ ShaderTextureResource AtomicStorageTextureDescriptor() { resource = AtomicStorageTextureResource(); descriptor = AtomicStorageTextureDescriptor(); descriptor.fields[1] = (descriptor.fields[1] & ~0x1ff00000u) | - (Prospero::GpuEnumValue(Prospero::BufferFormat::k8UInt) << 20u); + (static_cast(Prospero::BufferFormat::k8UInt) << 20u); } else if (std::strcmp(kind, "depth-tile-read") == 0) { resource = Ppsa14053DepthTileStorageTextureResource(); descriptor = Ppsa14053DepthTileStorageTextureDescriptor(); @@ -17054,14 +17068,14 @@ ShaderTextureResource AtomicStorageTextureDescriptor() { descriptor = Ppsa14053DepthTileStorageTextureDescriptor(); resource.dimension = ShaderRecompiler::Decoder::ImageDimension::Dim2D; descriptor.fields[3] = (descriptor.fields[3] & 0x0fffffffu) | - (Prospero::GpuEnumValue(Prospero::ImageType::kColor2D) << 28u); + (static_cast(Prospero::ImageType::kColor2D) << 28u); descriptor.fields[4] |= 1u; } else if (std::strcmp(kind, "depth-tile-fmask") == 0) { resource = BasicArrayStorageTextureResource(); descriptor = Ppsa10112D16StorageTextureDescriptor(); descriptor.fields[1] = (descriptor.fields[1] & ~(0x1ffu << 20u)) | - (Prospero::GpuEnumValue(Prospero::BufferFormat::kFmask8_S4_F4) << 20u); + (static_cast(Prospero::BufferFormat::kFmask8_S4_F4) << 20u); } else { std::_Exit(0x7e); } @@ -17091,8 +17105,8 @@ void CheckBasicStorageTextureDescriptor() { Require("BasicStorageTexture", "linear descriptor", linear.Base40() == 0x4bcc40100ull && linear.Width5() + 1u == 3840 && linear.Height5() + 1u == 2160 && linear.Depth() + 1u == 1 && - linear.Format() == Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8UNorm) && - linear.TileMode() == Prospero::GpuEnumValue(Prospero::TileMode::kLinear), + linear.Format() == Prospero::BufferFormat::k8_8_8_8UNorm && + linear.TileMode() == Prospero::TileMode::kLinear, "PPSA07429 linear 2D storage descriptor fixture is malformed"); ValidateStorageTexture(BasicLinearStorageTextureResource(), linear, 0x1fa4000); @@ -17100,8 +17114,8 @@ void CheckBasicStorageTextureDescriptor() { Require("BasicStorageTexture", "BGRA descriptor", bgra.Base40() == 0x7c650000ull && bgra.Width5() + 1u == 1920 && bgra.Height5() + 1u == 1080 && bgra.Depth() + 1u == 1 && - bgra.Format() == Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8UNorm) && - bgra.TileMode() == Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget) && + bgra.Format() == Prospero::BufferFormat::k8_8_8_8UNorm && + bgra.TileMode() == Prospero::TileMode::kRenderTarget && bgra.DstSelXYZW() == DstSel(6, 5, 4, 7), "PPSA02604 BGRA 2D storage descriptor fixture is malformed"); ValidateStorageTexture(BasicBgraStorageTextureResource(), bgra, 0x870000); @@ -17111,8 +17125,8 @@ void CheckBasicStorageTextureDescriptor() { r11g11b10.Base40() == 0x10c6b50000ull && r11g11b10.Width5() + 1u == 1920 && r11g11b10.Height5() + 1u == 1080 && r11g11b10.Depth() + 1u == 1 && r11g11b10.Format() == - Prospero::GpuEnumValue(Prospero::BufferFormat::k11_11_10Float) && - r11g11b10.TileMode() == Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget) && + Prospero::BufferFormat::k11_11_10Float && + r11g11b10.TileMode() == Prospero::TileMode::kRenderTarget && r11g11b10.DstSelXYZW() == DstSel(4, 5, 6, 1), "PPSA06228 R11G11B10 storage descriptor fixture is malformed"); ValidateStorageTexture(BasicBgraStorageTextureResource(), r11g11b10, 0x870000); @@ -17124,8 +17138,8 @@ void CheckBasicStorageTextureDescriptor() { max_mip.Base40() == 0x4a4290000ull && max_mip.Width5() + 1u == 64 && max_mip.Height5() + 1u == 64 && max_mip.Depth() + 1u == 1 && max_mip.BaseLevel() == 0 && max_mip.LastLevel() == 0 && max_mip.MaxMip() == 5 && - max_mip.Format() == Prospero::GpuEnumValue(Prospero::BufferFormat::k32_32UInt) && - max_mip.TileMode() == Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget) && + max_mip.Format() == Prospero::BufferFormat::k32_32UInt && + max_mip.TileMode() == Prospero::TileMode::kRenderTarget && max_mip.DstSelXYZW() == DstSel(4, 5, 0, 1), "PPSA01530 max-mip storage descriptor fixture is malformed"); ValidateStorageTexture(Ppsa01530MaxMipStorageTextureResource(), max_mip, 0x20000); @@ -17140,8 +17154,8 @@ void CheckBasicStorageTextureDescriptor() { Require("BasicStorageTexture", "PPSA02527 R16F descriptor", r16_float.Base40() == 0xce350000ull && r16_float.Width5() + 1u == 1920 && r16_float.Height5() + 1u == 1080 && r16_float.Depth() + 1u == 1 && - r16_float.Format() == Prospero::GpuEnumValue(Prospero::BufferFormat::k16Float) && - r16_float.TileMode() == Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget) && + r16_float.Format() == Prospero::BufferFormat::k16Float && + r16_float.TileMode() == Prospero::TileMode::kRenderTarget && r16_float.DstSelXYZW() == DstSel(4, 0, 0, 1), "PPSA02527 R16F 2D storage descriptor fixture is malformed"); ValidateStorageTexture(BasicBgraStorageTextureResource(), r16_float, 0x480000); @@ -17150,8 +17164,8 @@ void CheckBasicStorageTextureDescriptor() { Require("BasicStorageTexture", "PPSA02527 R32F descriptor", r32_float.Base40() == 0xcea90000ull && r32_float.Width5() + 1u == 960 && r32_float.Height5() + 1u == 540 && r32_float.Depth() + 1u == 1 && - r32_float.Format() == Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float) && - r32_float.TileMode() == Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget) && + r32_float.Format() == Prospero::BufferFormat::k32Float && + r32_float.TileMode() == Prospero::TileMode::kRenderTarget && r32_float.DstSelXYZW() == DstSel(4, 0, 0, 1), "PPSA02527 R32F 2D storage descriptor fixture is malformed"); ValidateStorageTexture(BasicBgraStorageTextureResource(), r32_float, 0x280000); @@ -17160,8 +17174,8 @@ void CheckBasicStorageTextureDescriptor() { Require("BasicStorageTexture", "PPSA02527 R8 UNORM descriptor", r8_unorm.Base40() == 0xc7d50000ull && r8_unorm.Width5() + 1u == 960 && r8_unorm.Height5() + 1u == 540 && r8_unorm.Depth() + 1u == 1 && - r8_unorm.Format() == Prospero::GpuEnumValue(Prospero::BufferFormat::k8UNorm) && - r8_unorm.TileMode() == Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget) && + r8_unorm.Format() == Prospero::BufferFormat::k8UNorm && + r8_unorm.TileMode() == Prospero::TileMode::kRenderTarget && r8_unorm.DstSelXYZW() == DstSel(4, 0, 0, 1), "PPSA02527 R8 UNORM 2D storage descriptor fixture is malformed"); ValidateStorageTexture(BasicBgraStorageTextureResource(), r8_unorm, 0xc0000); @@ -17171,15 +17185,15 @@ void CheckBasicStorageTextureDescriptor() { yzwx.Base40() == 0x62780100ull && yzwx.Width5() + 1u == 8 && yzwx.Height5() + 1u == 8 && yzwx.Depth() + 1u == 1 && yzwx.Format() == - Prospero::GpuEnumValue(Prospero::BufferFormat::k32_32_32_32Float) && - yzwx.TileMode() == Prospero::GpuEnumValue(Prospero::TileMode::kLinear) && + Prospero::BufferFormat::k32_32_32_32Float && + yzwx.TileMode() == Prospero::TileMode::kLinear && yzwx.DstSelXYZW() == DstSel(5, 6, 7, 4), "PPSA04181 linear YZWX storage descriptor fixture is malformed"); ValidateStorageTexture(BasicLinearStorageTextureResource(), yzwx, 0x800); auto all_swizzles = yzwx; all_swizzles.fields[1] = (all_swizzles.fields[1] & ~0x1ff00000u) | - (Prospero::GpuEnumValue(Prospero::BufferFormat::k16_16_16_16Float) << 20u); + (static_cast(Prospero::BufferFormat::k16_16_16_16Float) << 20u); uint32_t valid_storage_swizzles = 0; for (uint32_t swizzle = 0; swizzle <= 0xfffu; swizzle++) { if (!IsValidImageSwizzle(swizzle)) { @@ -17200,9 +17214,9 @@ void CheckBasicStorageTextureDescriptor() { Require("BasicStorageTexture", "2D-array descriptor", array.Base40() == 0x2017900000ull && array.Width5() + 1u == 1 && array.Height5() + 1u == 1 && array.Depth() + 1u == 1 && array.BaseArray5() == 0 && - array.Type() == Prospero::GpuEnumValue(Prospero::ImageType::kColor2DArray) && - array.Format() == Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8UNorm) && - array.TileMode() == Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget) && + array.Type() == Prospero::ImageType::kColor2DArray && + array.Format() == Prospero::BufferFormat::k8_8_8_8UNorm && + array.TileMode() == Prospero::TileMode::kRenderTarget && array.DstSelXYZW() == DstSel(6, 5, 4, 7), "PPSA21268 2D-array storage descriptor fixture is malformed"); ValidateStorageTexture(BasicArrayStorageTextureResource(), array, 0x10000); @@ -17212,7 +17226,7 @@ void CheckBasicStorageTextureDescriptor() { Require("BasicStorageTexture", "PPSA14457 mip-one 2D-array descriptor", mip_array.BaseLevel() == 1 && mip_array.LastLevel() == 1 && mip_array.MaxMip() == 7 && - mip_array.Type() == Prospero::GpuEnumValue(Prospero::ImageType::kColor2DArray) && + mip_array.Type() == Prospero::ImageType::kColor2DArray && mip_array.Depth() == 0 && mip_array.BaseArray5() == 0, "PPSA14457 mip-one 2D-array storage descriptor fixture is malformed"); ValidateStorageTexture(BasicArrayStorageTextureResource(), mip_array, 0x30000); @@ -17222,10 +17236,10 @@ void CheckBasicStorageTextureDescriptor() { uint_array.Base40() == 0x2017920000ull && uint_array.Width5() + 1u == 1 && uint_array.Height5() + 1u == 1 && uint_array.Depth() + 1u == 1 && uint_array.BaseArray5() == 0 && - uint_array.Type() == Prospero::GpuEnumValue(Prospero::ImageType::kColor2DArray) && - uint_array.Format() == Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt) && + uint_array.Type() == Prospero::ImageType::kColor2DArray && + uint_array.Format() == Prospero::BufferFormat::k32UInt && uint_array.TileMode() == - Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget) && + Prospero::TileMode::kRenderTarget && uint_array.DstSelXYZW() == DstSel(4, 0, 0, 1), "PPSA21268 uint 2D-array storage descriptor fixture is malformed"); ValidateStorageTexture(BasicUintArrayStorageTextureResource(), uint_array, 0x10000); @@ -17250,11 +17264,11 @@ void CheckBasicStorageTextureDescriptor() { Require("BasicStorageTexture", "Standard256B uint 2D descriptor", standard256b.Width5() + 1u == 2 && standard256b.Height5() + 1u == 2 && standard256b.Depth() + 1u == 1 && - standard256b.Type() == Prospero::GpuEnumValue(Prospero::ImageType::kColor2D) && + standard256b.Type() == Prospero::ImageType::kColor2D && standard256b.Format() == - Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8UInt) && + Prospero::BufferFormat::k8_8_8_8UInt && standard256b.TileMode() == - Prospero::GpuEnumValue(Prospero::TileMode::kStandard256B) && + Prospero::TileMode::kStandard256B && standard256b.DstSelXYZW() == DstSel(4, 5, 6, 7) && standard256b_size.size == 0x100 && standard256b_size.align == 0x100, "captured PPSA08511 Standard256B storage descriptor is malformed"); @@ -17266,10 +17280,10 @@ void CheckBasicStorageTextureDescriptor() { standard4kb_array.TileMode(), false, standard4kb_size); Require( "BasicStorageTexture", "Standard4KB uint 2D-array descriptor", - standard4kb_array.Type() == Prospero::GpuEnumValue(Prospero::ImageType::kColor2DArray) && - standard4kb_array.Format() == Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt) && + standard4kb_array.Type() == Prospero::ImageType::kColor2DArray && + standard4kb_array.Format() == Prospero::BufferFormat::k32UInt && standard4kb_array.TileMode() == - Prospero::GpuEnumValue(Prospero::TileMode::kStandard4KB) && + Prospero::TileMode::kStandard4KB && standard4kb_array.DstSelXYZW() == DstSel(4, 0, 0, 1) && standard4kb_size.size == 0x1000 && standard4kb_size.align == 0x1000, "captured Standard4KB uint 2D-array descriptor is malformed"); @@ -17298,11 +17312,11 @@ void CheckBasicStorageTextureDescriptor() { 1, standard64kb.TileMode(), false, standard64kb_size); Require("BasicStorageTexture", "Standard64KB 2D descriptor", - standard64kb.Type() == Prospero::GpuEnumValue(Prospero::ImageType::kColor2DArray) && + standard64kb.Type() == Prospero::ImageType::kColor2DArray && standard64kb.Format() == - Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8UNorm) && + Prospero::BufferFormat::k8_8_8_8UNorm && standard64kb.TileMode() == - Prospero::GpuEnumValue(Prospero::TileMode::kStandard64KB) && + Prospero::TileMode::kStandard64KB && standard64kb.DstSelXYZW() == DstSel(4, 5, 6, 7) && standard64kb_size.size == 0x10000 && standard64kb_size.align == 0x10000, "captured Standard64KB storage descriptor is malformed"); @@ -17313,9 +17327,9 @@ void CheckBasicStorageTextureDescriptor() { uint_volume.Base40() == 0x2018060000ull && uint_volume.Width5() + 1u == 16 && uint_volume.Height5() + 1u == 16 && uint_volume.Depth() + 1u == 16 && uint_volume.BaseArray5() == 0 && - uint_volume.Type() == Prospero::GpuEnumValue(Prospero::ImageType::kColor3D) && - uint_volume.Format() == Prospero::GpuEnumValue(Prospero::BufferFormat::k16UInt) && - uint_volume.TileMode() == Prospero::GpuEnumValue(Prospero::TileMode::kLinear) && + uint_volume.Type() == Prospero::ImageType::kColor3D && + uint_volume.Format() == Prospero::BufferFormat::k16UInt && + uint_volume.TileMode() == Prospero::TileMode::kLinear && uint_volume.DstSelXYZW() == DstSel(4, 0, 0, 0), "PPSA21268 uint 3D storage descriptor fixture is malformed"); ValidateStorageTexture(BasicUintVolumeStorageTextureResource(), uint_volume, 0x10000); @@ -17326,9 +17340,9 @@ void CheckBasicStorageTextureDescriptor() { Require("BasicStorageTexture", "tiled uint 3D descriptor", tiled_uint_volume.Width5() + 1u == 16 && tiled_uint_volume.Height5() + 1u == 16 && tiled_uint_volume.Depth() + 1u == 16 && - tiled_uint_volume.Type() == Prospero::GpuEnumValue(Prospero::ImageType::kColor3D) && + tiled_uint_volume.Type() == Prospero::ImageType::kColor3D && tiled_uint_volume.TileMode() == - Prospero::GpuEnumValue(Prospero::TileMode::kStandard4KB), + Prospero::TileMode::kStandard4KB, "captured tiled uint 3D storage descriptor fixture is malformed"); ValidateStorageTexture(BasicUintVolumeStorageTextureResource(), tiled_uint_volume, 0x2000); @@ -17337,9 +17351,9 @@ void CheckBasicStorageTextureDescriptor() { depth_tile.Base40() == 0x20144c0000ull && depth_tile.Width5() + 1u == 1 && depth_tile.Height5() + 1u == 1 && depth_tile.Depth() + 1u == 1 && depth_tile.BaseArray5() == 0 && - depth_tile.Type() == Prospero::GpuEnumValue(Prospero::ImageType::kColor2DArray) && - depth_tile.Format() == Prospero::GpuEnumValue(Prospero::BufferFormat::k8UInt) && - depth_tile.TileMode() == Prospero::GpuEnumValue(Prospero::TileMode::kDepth) && + depth_tile.Type() == Prospero::ImageType::kColor2DArray && + depth_tile.Format() == Prospero::BufferFormat::k8UInt && + depth_tile.TileMode() == Prospero::TileMode::kDepth && depth_tile.DstSelXYZW() == DstSel(4, 0, 0, 1), "PPSA14053 write-only depth-tile storage descriptor fixture is " "malformed"); @@ -17349,9 +17363,9 @@ void CheckBasicStorageTextureDescriptor() { "BasicStorageTexture", "PPSA10112 D16 depth-tile descriptor", d16_depth_tile.Base40() == 0x205b900000ull && d16_depth_tile.Width5() + 1u == 240 && d16_depth_tile.Height5() + 1u == 135 && d16_depth_tile.Depth() + 1u == 1 && - d16_depth_tile.Type() == Prospero::GpuEnumValue(Prospero::ImageType::kColor2DArray) && - d16_depth_tile.Format() == Prospero::GpuEnumValue(Prospero::BufferFormat::k16UNorm) && - d16_depth_tile.TileMode() == Prospero::GpuEnumValue(Prospero::TileMode::kDepth) && + d16_depth_tile.Type() == Prospero::ImageType::kColor2DArray && + d16_depth_tile.Format() == Prospero::BufferFormat::k16UNorm && + d16_depth_tile.TileMode() == Prospero::TileMode::kDepth && d16_depth_tile.DstSelXYZW() == DstSel(4, 0, 0, 1), "PPSA10112 writable D16 depth-plane descriptor fixture is malformed"); const auto d16_pitch = TileGetTexturePitch( @@ -17366,9 +17380,9 @@ void CheckBasicStorageTextureDescriptor() { ValidateStorageTexture(BasicArrayStorageTextureResource(), d16_depth_tile, d16_size.size); auto depth_tile_r32 = depth_tile; depth_tile_r32.fields[1] = (depth_tile_r32.fields[1] & ~(0x1ffu << 20u)) | - (Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt) << 20u); + (static_cast(Prospero::BufferFormat::k32UInt) << 20u); depth_tile_r32.fields[3] = (depth_tile_r32.fields[3] & ~(0xfu << 28u)) | - (Prospero::GpuEnumValue(Prospero::ImageType::kColor2D) << 28u); + (static_cast(Prospero::ImageType::kColor2D) << 28u); auto depth_tile_r32_resource = Ppsa14053DepthTileStorageTextureResource(); depth_tile_r32_resource.dimension = ShaderRecompiler::Decoder::ImageDimension::Dim2D; ValidateStorageTexture(depth_tile_r32_resource, depth_tile_r32, 0x10000); @@ -17379,8 +17393,8 @@ void CheckBasicStorageTextureDescriptor() { const auto atomic = AtomicStorageTextureDescriptor(); Require("BasicStorageTexture", "atomic R32_UINT descriptor", atomic.Width5() + 1u == 128 && atomic.Height5() + 1u == 1 && atomic.Depth() + 1u == 1 && - atomic.Type() == Prospero::GpuEnumValue(Prospero::ImageType::kColor2D) && - atomic.Format() == Prospero::GpuEnumValue(Prospero::BufferFormat::k32UInt) && + atomic.Type() == Prospero::ImageType::kColor2D && + atomic.Format() == Prospero::BufferFormat::k32UInt && atomic.DstSelXYZW() == DstSel(4, 0, 0, 1), "PPSA22102 image-atomic descriptor fixture is malformed"); ValidateStorageTexture(AtomicStorageTextureResource(), atomic, 0x10000); @@ -17432,11 +17446,11 @@ void CheckBasicStorageTextureDescriptor() { #endif void CheckStorageTextureLinearUploadLayout() { - constexpr uint32_t format = Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8UNorm); + constexpr auto format = Prospero::BufferFormat::k8_8_8_8UNorm; constexpr uint32_t width = 3840; constexpr uint32_t height = 2160; constexpr uint32_t depth = 1; - constexpr uint32_t tile = Prospero::GpuEnumValue(Prospero::TileMode::kLinear); + constexpr auto tile = Prospero::TileMode::kLinear; const auto pitch = TileGetTexturePitch(format, width, tile); TileSizeAlign total {}; TileGetTextureTotalSize(format, width, height, depth, 1, tile, false, total); @@ -17456,11 +17470,11 @@ void CheckStorageTextureLinearUploadLayout() { } void CheckStorageTextureDepthTileUploadLayout() { - constexpr uint32_t format = Prospero::GpuEnumValue(Prospero::BufferFormat::k8UInt); + constexpr auto format = Prospero::BufferFormat::k8UInt; constexpr uint32_t width = 1; constexpr uint32_t height = 1; constexpr uint32_t depth = 1; - constexpr uint32_t tile = Prospero::GpuEnumValue(Prospero::TileMode::kDepth); + constexpr auto tile = Prospero::TileMode::kDepth; const auto pitch = TileGetTexturePitch(format, width, tile); TileSizeAlign slice {}; TileSizeAlign total {}; @@ -17518,18 +17532,18 @@ void CheckStorageImageSwizzleSpecializationId() { } void CheckStorageTextureVolumeUploadLayout() { - constexpr uint32_t format = Prospero::GpuEnumValue(Prospero::BufferFormat::k16_16_16_16Float); + constexpr auto format = Prospero::BufferFormat::k16_16_16_16Float; constexpr uint32_t width = 33; constexpr uint32_t height = 33; constexpr uint32_t depth = 33; const auto pitch = TileGetTexturePitch( - format, width, Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget)); + format, width, Prospero::TileMode::kRenderTarget); TileSizeAlign total {}; TileGetTextureTotalSize(format, width, height, depth, 1, - Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget), true, total); + Prospero::TileMode::kRenderTarget, true, total); const auto layout = TextureCalcUploadLayout(format, width, height, 1, depth, - Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget), + Prospero::TileMode::kRenderTarget, total.size, true, true, "StorageTextureVolumeTest"); const auto regions = TextureBuildImageCopies(layout); Require("StorageTextureVolumeUpload", "layout", @@ -17554,12 +17568,12 @@ void CheckStorageTextureVolumeUploadLayout() { } void CheckStorageTextureVolumeMipRegions() { - constexpr uint32_t format = Prospero::GpuEnumValue(Prospero::BufferFormat::k8_8_8_8UNorm); + constexpr auto format = Prospero::BufferFormat::k8_8_8_8UNorm; constexpr uint32_t width = 8; constexpr uint32_t height = 4; constexpr uint32_t depth = 5; constexpr uint32_t levels = 3; - constexpr uint32_t tile = Prospero::GpuEnumValue(Prospero::TileMode::kLinear); + constexpr auto tile = Prospero::TileMode::kLinear; TileSizeAlign total {}; TileGetTextureTotalSize(format, width, height, depth, levels, tile, true, total); const auto layout = @@ -17591,8 +17605,8 @@ void CheckStorageTextureVolumeMipRegions() { std::printf("[host] %-32s ok\n", "StorageTextureVolumeMipRegions"); } void CheckStandard64RenderTargetTileRoundTrip() { - constexpr uint32_t format = Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float); - constexpr uint32_t tile = Prospero::GpuEnumValue(Prospero::TileMode::kStandard64KB); + constexpr auto format = Prospero::BufferFormat::k32Float; + constexpr auto tile = Prospero::TileMode::kStandard64KB; constexpr uint32_t observed_width = 3840; constexpr uint32_t observed_height = 2160; @@ -17630,7 +17644,7 @@ void CheckStandard64RenderTargetTileRoundTrip() { "exact Standard64KB render target was not classified as tiled"); Require("Standard64RenderTarget", "display tile boundary", IsSupportedDisplayRenderTargetTileMode( - Prospero::GpuEnumValue(Prospero::TileMode::kRenderTarget)) && + Prospero::TileMode::kRenderTarget) && !IsSupportedDisplayRenderTargetTileMode(tile), "Standard64KB render target could alias a mode-27 display image"); auto unsupported = info; @@ -17756,8 +17770,8 @@ void CheckNativeMsaaState() { Require("NativeMsaaState", "8x depth/stencil footprint", TileGetDepthPitch(1920, 4, 3) == 1920 && TileGetDepthSize(1920, 1080, 0, - Prospero::GpuEnumValue(Prospero::DepthFormat::kZ32F), - Prospero::GpuEnumValue(Prospero::StencilFormat::k8UInt), true, + Prospero::DepthFormat::kZ32F, + Prospero::StencilFormat::k8UInt, true, stencil, htile, depth, 3) && depth.align == 0x10000 && depth.size == 0x03fc0000 && stencil.align == 0x10000 && stencil.size == 0x010e0000 && htile.align == 0x8000 && htile.size == 0x00030000, @@ -17787,13 +17801,13 @@ void CheckPs5DepthRegisterDecoding() { const auto z = HW::DepthZInfo::Decode(captured_z); const auto stencil = HW::DepthStencilInfo::Decode(captured_stencil); Require("Ps5DepthRegisterDecoding", "captured texture-compatible state", - z.format == Prospero::GpuEnumValue(Prospero::DepthFormat::kZ32F) && + z.format == Prospero::DepthFormat::kZ32F && z.num_samples == 0 && z.htile_acceleration && !z.expclear_enabled && !z.partially_resident && z.max_mip_level == 0 && z.z_compare_base == Prospero::ZCompareBase::kZMin && z.texture_compatibility == Prospero::TextureCompatiblePlaneCompression::kEnable && z.HasValidTextureCompatibility() && - stencil.format == Prospero::GpuEnumValue(Prospero::StencilFormat::k8UInt) && + stencil.format == Prospero::StencilFormat::k8UInt && !stencil.htile_stencil_disabled && !stencil.expclear_enabled && !stencil.partially_resident && stencil.texture_compatibility == Prospero::TextureCompatibleStencil::kEnable && @@ -17953,23 +17967,25 @@ void CheckDepthTargetFootprints() { TileSizeAlign htile {}; TileSizeAlign depth {}; struct AttachmentFormatCase { - const char* name; - uint32_t depth_format; - uint32_t stencil_format; - vk::Format expected; + const char* name; + Prospero::DepthFormat depth_format; + Prospero::StencilFormat stencil_format; + vk::Format expected; }; constexpr AttachmentFormatCase attachment_cases[] = { - {"Z16", Prospero::GpuEnumValue(Prospero::DepthFormat::kZ16), - Prospero::GpuEnumValue(Prospero::StencilFormat::kInvalid), vk::Format::eD16Unorm}, - {"Z16S8", Prospero::GpuEnumValue(Prospero::DepthFormat::kZ16), - Prospero::GpuEnumValue(Prospero::StencilFormat::k8UInt), vk::Format::eD16UnormS8Uint}, - {"Z32", Prospero::GpuEnumValue(Prospero::DepthFormat::kZ32F), - Prospero::GpuEnumValue(Prospero::StencilFormat::kInvalid), vk::Format::eD32Sfloat}, - {"Z32S8", Prospero::GpuEnumValue(Prospero::DepthFormat::kZ32F), - Prospero::GpuEnumValue(Prospero::StencilFormat::k8UInt), vk::Format::eD32SfloatS8Uint}, - {"invalid depth", 2, Prospero::GpuEnumValue(Prospero::StencilFormat::k8UInt), + {"Z16", Prospero::DepthFormat::kZ16, + Prospero::StencilFormat::kInvalid, vk::Format::eD16Unorm}, + {"Z16S8", Prospero::DepthFormat::kZ16, + Prospero::StencilFormat::k8UInt, vk::Format::eD16UnormS8Uint}, + {"Z32", Prospero::DepthFormat::kZ32F, + Prospero::StencilFormat::kInvalid, vk::Format::eD32Sfloat}, + {"Z32S8", Prospero::DepthFormat::kZ32F, + Prospero::StencilFormat::k8UInt, vk::Format::eD32SfloatS8Uint}, + {"invalid depth", static_cast(2u), + Prospero::StencilFormat::k8UInt, vk::Format::eUndefined}, - {"invalid stencil", Prospero::GpuEnumValue(Prospero::DepthFormat::kZ16), 2, + {"invalid stencil", Prospero::DepthFormat::kZ16, + static_cast(2u), vk::Format::eUndefined}, }; for (const auto& test: attachment_cases) { @@ -17978,42 +17994,42 @@ void CheckDepthTargetFootprints() { "PS5 depth/stencil attachment mapping changed"); } Require("DepthTargetFootprints", "1920x1080 Z16S8 without HTile", - TileGetDepthSize(1920, 1080, 0, Prospero::GpuEnumValue(Prospero::DepthFormat::kZ16), - Prospero::GpuEnumValue(Prospero::StencilFormat::k8UInt), false, + TileGetDepthSize(1920, 1080, 0, Prospero::DepthFormat::kZ16, + Prospero::StencilFormat::k8UInt, false, stencil, htile, depth) && depth.size == 0x480000 && depth.align == 0x10000 && stencil.size == 0x280000 && stencil.align == 0x10000 && htile.size == 0, "captured Z16S8 footprint disagrees with Prospero block rules"); struct TargetFormatCase { - const char* name; - vk::Format host_format; - uint32_t guest_format; - uint32_t bytes_per_element; - bool stencil; - bool supported; - bool readback; + const char* name; + vk::Format host_format; + Prospero::BufferFormat guest_format; + uint32_t bytes_per_element; + bool stencil; + bool supported; + bool readback; }; constexpr TargetFormatCase target_cases[] = { - {"D16", vk::Format::eD16Unorm, Prospero::GpuEnumValue(Prospero::BufferFormat::k16UNorm), 2, + {"D16", vk::Format::eD16Unorm, Prospero::BufferFormat::k16UNorm, 2, false, true, true}, {"D16S8", vk::Format::eD16UnormS8Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k16UNorm), 2, true, true, true}, + Prospero::BufferFormat::k16UNorm, 2, true, true, true}, {"D16 via D24S8", vk::Format::eD24UnormS8Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k16UNorm), 2, true, true, true}, + Prospero::BufferFormat::k16UNorm, 2, true, true, true}, {"D16 via D32S8", vk::Format::eD32SfloatS8Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k16UNorm), 2, true, true, true}, - {"D32", vk::Format::eD32Sfloat, Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float), 4, + Prospero::BufferFormat::k16UNorm, 2, true, true, true}, + {"D32", vk::Format::eD32Sfloat, Prospero::BufferFormat::k32Float, 4, false, true, true}, {"D32S8", vk::Format::eD32SfloatS8Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float), 4, true, true, true}, + Prospero::BufferFormat::k32Float, 4, true, true, true}, {"D16 plus stencil mismatch", vk::Format::eD16Unorm, - Prospero::GpuEnumValue(Prospero::BufferFormat::k16UNorm), 2, true, false, false}, + Prospero::BufferFormat::k16UNorm, 2, true, false, false}, {"fallback without stencil", vk::Format::eD24UnormS8Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k16UNorm), 2, false, false, false}, + Prospero::BufferFormat::k16UNorm, 2, false, false, false}, {"D32 guest via D24", vk::Format::eD24UnormS8Uint, - Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float), 4, true, false, false}, + Prospero::BufferFormat::k32Float, 4, true, false, false}, {"D16 byte mismatch", vk::Format::eD16Unorm, - Prospero::GpuEnumValue(Prospero::BufferFormat::k16UNorm), 4, false, false, false}, + Prospero::BufferFormat::k16UNorm, 4, false, false, false}, }; for (const auto& test: target_cases) { ImageInfo target {}; @@ -18028,7 +18044,7 @@ void CheckDepthTargetFootprints() { } ImageInfo compressed_stencil {}; compressed_stencil.pixel_format = vk::Format::eD32SfloatS8Uint; - compressed_stencil.guest_format = Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float); + compressed_stencil.guest_format = Prospero::BufferFormat::k32Float; compressed_stencil.bytes_per_block = 4; compressed_stencil.stencil = {0x10000, 0x10000}; compressed_stencil.metadata.stencil_compressed = true; @@ -18076,8 +18092,8 @@ void CheckDepthTargetFootprints() { "D16 host promotion changed the represented depth value"); } Require("DepthTargetFootprints", "640x360 Z32S8 without HTile", - TileGetDepthSize(640, 360, 0, Prospero::GpuEnumValue(Prospero::DepthFormat::kZ32F), - Prospero::GpuEnumValue(Prospero::StencilFormat::k8UInt), false, + TileGetDepthSize(640, 360, 0, Prospero::DepthFormat::kZ32F, + Prospero::StencilFormat::k8UInt, false, stencil, htile, depth), "valid non-HTile depth/stencil footprint was rejected"); Require("DepthTargetFootprints", "640x360 Prospero block sizes", @@ -18086,53 +18102,54 @@ void CheckDepthTargetFootprints() { "non-HTile depth/stencil footprint disagrees with Prospero block rules"); const auto depth_pitch = - TileGetTexturePitch(Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float), 640, - Prospero::GpuEnumValue(Prospero::TileMode::kDepth)); + TileGetTexturePitch(Prospero::BufferFormat::k32Float, 640, + Prospero::TileMode::kDepth); TileSizeAlign texture_depth {}; - TileGetTextureTotalSize(Prospero::GpuEnumValue(Prospero::BufferFormat::k32Float), 640, 360, 1, - 1, Prospero::GpuEnumValue(Prospero::TileMode::kDepth), + TileGetTextureTotalSize(Prospero::BufferFormat::k32Float, 640, 360, 1, + 1, Prospero::TileMode::kDepth, false, texture_depth); Require("DepthTargetFootprints", "640x360 generic depth tile", depth_pitch == 640 && texture_depth.size == 0xf0000 && texture_depth.align == 0x10000, "generic depth texture sizing bypassed 64 KiB block padding"); Require("DepthTargetFootprints", "960x540 Z32S8 with HTile", - TileGetDepthSize(960, 540, 0, Prospero::GpuEnumValue(Prospero::DepthFormat::kZ32F), - Prospero::GpuEnumValue(Prospero::StencilFormat::k8UInt), true, stencil, + TileGetDepthSize(960, 540, 0, Prospero::DepthFormat::kZ32F, + Prospero::StencilFormat::k8UInt, true, stencil, htile, depth) && depth.size == 0x280000 && depth.align == 0x10000 && stencil.size == 0xc0000 && stencil.align == 0x10000 && htile.size == 0x10000 && htile.align == 0x8000, "generic Prospero HTile block calculation rejected the title footprint"); Require("DepthTargetFootprints", "known HTile extent", - TileGetDepthSize(1280, 720, 0, Prospero::GpuEnumValue(Prospero::DepthFormat::kZ32F), - Prospero::GpuEnumValue(Prospero::StencilFormat::k8UInt), true, stencil, + TileGetDepthSize(1280, 720, 0, Prospero::DepthFormat::kZ32F, + Prospero::StencilFormat::k8UInt, true, stencil, htile, depth) && depth.size == 0x3c0000 && stencil.size == 0xf0000 && htile.size == 0x20000, "validated 1280x720 HTile footprint regressed"); Require("DepthTargetFootprints", "PPSA06228 3840x2160 Z32S8 with HTile", - TileGetDepthSize(3840, 2160, 0, Prospero::GpuEnumValue(Prospero::DepthFormat::kZ32F), - Prospero::GpuEnumValue(Prospero::StencilFormat::k8UInt), true, stencil, + TileGetDepthSize(3840, 2160, 0, Prospero::DepthFormat::kZ32F, + Prospero::StencilFormat::k8UInt, true, stencil, htile, depth) && depth.size == 0x1fe0000 && depth.align == 0x10000 && stencil.size == 0x870000 && stencil.align == 0x10000 && htile.size == 0xa0000 && htile.align == 0x8000, "captured 3840x2160 depth/stencil/HTile footprint disagrees with " "Prospero rules"); Require("DepthTargetFootprints", "invalid depth format", - !TileGetDepthSize(960, 540, 0, 2, - Prospero::GpuEnumValue(Prospero::StencilFormat::k8UInt), true, + !TileGetDepthSize(960, 540, 0, static_cast(2u), + Prospero::StencilFormat::k8UInt, true, stencil, htile, depth), "unsupported depth format was silently admitted"); Require("DepthTargetFootprints", "invalid stencil format", - !TileGetDepthSize(960, 540, 0, Prospero::GpuEnumValue(Prospero::DepthFormat::kZ32F), 2, + !TileGetDepthSize(960, 540, 0, Prospero::DepthFormat::kZ32F, + static_cast(2u), true, stencil, htile, depth), "unsupported stencil format was silently admitted"); Require("DepthTargetFootprints", "invalid extent", - !TileGetDepthSize(0, 540, 0, Prospero::GpuEnumValue(Prospero::DepthFormat::kZ32F), - Prospero::GpuEnumValue(Prospero::StencilFormat::k8UInt), true, + !TileGetDepthSize(0, 540, 0, Prospero::DepthFormat::kZ32F, + Prospero::StencilFormat::k8UInt, true, stencil, htile, depth) && !TileGetDepthSize(16385, 540, 0, - Prospero::GpuEnumValue(Prospero::DepthFormat::kZ32F), - Prospero::GpuEnumValue(Prospero::StencilFormat::k8UInt), true, + Prospero::DepthFormat::kZ32F, + Prospero::StencilFormat::k8UInt, true, stencil, htile, depth), "invalid HTile extent was silently admitted"); std::printf("[host] %-32s ok\n", "DepthTargetFootprints"); @@ -18289,7 +18306,7 @@ void CheckPm4StencilInfoValueLane(RenderContext& renderer) { const auto& stencil = processor.GetCtx().GetDepthStencilInfo(); Require("Pm4StencilInfoValueLane", "standalone register value", consumed == 1 && - stencil.format == Prospero::GpuEnumValue(Prospero::StencilFormat::k8UInt) && + stencil.format == Prospero::StencilFormat::k8UInt && stencil.texture_compatibility == Prospero::TextureCompatibleStencil::kEnable && !stencil.expclear_enabled && !stencil.htile_stencil_disabled, "standalone DB_STENCIL_INFO did not decode its sole payload value"); @@ -18334,6 +18351,7 @@ void CheckPm4PolygonOffsetRegisters(RenderContext& renderer) { void CheckPm4ContextStateOperations(RenderContext& renderer) { GraphicsInitJmpTables(); CommandProcessor processor(renderer); + constexpr auto primitive_type = static_cast(0x35u); struct AgcCommandBufferLayout { using Callback = KYTY_SYSV_ABI bool (*)(Gen5::CommandBuffer*, uint32_t, void*); @@ -18353,7 +18371,7 @@ void CheckPm4ContextStateOperations(RenderContext& renderer) { original_control.stencil_clear_enable = true; processor.GetCtx().SetRenderControl(original_control); processor.GetCtx().SetRenderTargetMask(0x1234abcd); - processor.GetUcfg().SetPrimitiveType(0x35); + processor.GetUcfg().SetPrimitiveType(primitive_type); g_hw_sh_indirect_func[Pm4::SPI_SHADER_PGM_LO_PS](processor, Pm4::SPI_SHADER_PGM_LO_PS, 0x00123456); const auto shader_address = processor.GetShCtx().GetPs().ps_regs.data_addr; @@ -18409,7 +18427,7 @@ void CheckPm4ContextStateOperations(RenderContext& renderer) { !processor.GetCtx().GetRenderControl().depth_clear_enable && !processor.GetCtx().GetRenderControl().stencil_clear_enable && processor.GetCtx().GetRenderTargetMask() == HW::Context {}.GetRenderTargetMask() && - processor.GetUcfg().GetPrimType() == 0x35 && + processor.GetUcfg().GetPrimType() == primitive_type && processor.GetShCtx().GetPs().ps_regs.data_addr == shader_address, "push-clear did not save and clear only Cx state"); @@ -18438,7 +18456,7 @@ void CheckPm4ContextStateOperations(RenderContext& renderer) { !processor.GetCtx().GetRenderControl().depth_clear_enable && processor.GetCtx().GetRenderTargetMask() == HW::Context{}.GetRenderTargetMask() && - processor.GetUcfg().GetPrimType() == 0x35 && + processor.GetUcfg().GetPrimType() == primitive_type && processor.GetShCtx().GetPs().ps_regs.data_addr == shader_address, "clear reset state outside the Cx register domain"); diff --git a/tests/shaderCfgTests.cpp b/tests/shaderCfgTests.cpp index ff3978cbc..c968fa4b9 100644 --- a/tests/shaderCfgTests.cpp +++ b/tests/shaderCfgTests.cpp @@ -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 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(Prospero::BufferFormat::k8UNorm) << 20u; data[start + 2u] = UINT32_MAX; - data[start + 3u] = Prospero::GpuEnumValue(type) << 28u; + data[start + 3u] = static_cast(type) << 28u; } return data; } @@ -633,14 +633,14 @@ ImageTestUserData(Prospero::ImageType type = Prospero::ImageType::kColor2D) { void SetImageTestType(std::array* 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(type) << 28u; } void SetImageTestFormat(std::array* 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(format) << 20u; } bool ReadZeroTestMemory(void*, uint64_t, uint32_t* value) { @@ -4518,7 +4518,7 @@ void TestNewShaderRecompilerFormattedStoreUsesRuntimeArrayLengthOnly() { std::array 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(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(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 &&