mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 19:07:01 +02:00
shader: keep derived frontend metadata with its owner
This commit is contained in:
@@ -53,8 +53,7 @@ const char* StageName(ShaderType stage) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogDispatcherFallback(const CompileOptions& options, const CFG::Graph& cfg, const char* phase,
|
void LogDispatcherFallback(const CompileOptions& options, const CFG::Graph& cfg, const char* phase) {
|
||||||
const std::string& reason) {
|
|
||||||
const auto* block = cfg.FindBlock(cfg.failure_block);
|
const auto* block = cfg.FindBlock(cfg.failure_block);
|
||||||
const auto start = block != nullptr ? block->start_pc : UINT32_MAX;
|
const auto start = block != nullptr ? block->start_pc : UINT32_MAX;
|
||||||
const auto end = block != nullptr ? block->end_pc : UINT32_MAX;
|
const auto end = block != nullptr ? block->end_pc : UINT32_MAX;
|
||||||
@@ -68,7 +67,7 @@ void LogDispatcherFallback(const CompileOptions& options, const CFG::Graph& cfg,
|
|||||||
CFG::FailureKindToString(cfg.failure_kind).c_str(), cfg.failure_block, start, end,
|
CFG::FailureKindToString(cfg.failure_kind).c_str(), cfg.failure_block, start, end,
|
||||||
static_cast<uint64_t>(predecessors), static_cast<uint64_t>(successors),
|
static_cast<uint64_t>(predecessors), static_cast<uint64_t>(successors),
|
||||||
static_cast<uint64_t>(cfg.blocks.size()), static_cast<uint64_t>(cfg.natural_loops.size()),
|
static_cast<uint64_t>(cfg.blocks.size()), static_cast<uint64_t>(cfg.natural_loops.size()),
|
||||||
static_cast<uint64_t>(cfg.back_edges.size()), reason.c_str());
|
static_cast<uint64_t>(cfg.back_edges.size()), cfg.unsupported_reason.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class EmbeddedFetchValueType {
|
enum class EmbeddedFetchValueType {
|
||||||
@@ -550,27 +549,22 @@ TranslateResult TranslateProgram(std::span<const uint32_t> code, const CompileOp
|
|||||||
GetDumpLabel(options), StageName(options.stage), options.shader_hash,
|
GetDumpLabel(options), StageName(options.stage), options.shader_hash,
|
||||||
static_cast<uint64_t>(cfg.blocks.size()), static_cast<uint64_t>(cfg.natural_loops.size()),
|
static_cast<uint64_t>(cfg.blocks.size()), static_cast<uint64_t>(cfg.natural_loops.size()),
|
||||||
static_cast<uint64_t>(cfg.back_edges.size()), phase_ms());
|
static_cast<uint64_t>(cfg.back_edges.size()), phase_ms());
|
||||||
bool dispatcher_fallback = false;
|
|
||||||
std::string dispatcher_reason;
|
|
||||||
if (cfg.irreducible) {
|
if (cfg.irreducible) {
|
||||||
dispatcher_fallback = true;
|
LogDispatcherFallback(options, cfg, "build");
|
||||||
dispatcher_reason = cfg.unsupported_reason;
|
|
||||||
LogDispatcherFallback(options, cfg, "build", dispatcher_reason);
|
|
||||||
} else {
|
} else {
|
||||||
const auto unstructured_cfg = cfg;
|
const auto unstructured_cfg = cfg;
|
||||||
LOGF("%s phase begin: stage=%s hash=0x%016" PRIx64 " CFG Structurize\n",
|
LOGF("%s phase begin: stage=%s hash=0x%016" PRIx64 " CFG Structurize\n",
|
||||||
GetDumpLabel(options), StageName(options.stage), options.shader_hash);
|
GetDumpLabel(options), StageName(options.stage), options.shader_hash);
|
||||||
if (!CFG::Structurize(cfg)) {
|
if (!CFG::Structurize(cfg)) {
|
||||||
dispatcher_fallback = true;
|
|
||||||
dispatcher_reason = cfg.unsupported_reason;
|
|
||||||
const auto failure_kind = cfg.failure_kind;
|
const auto failure_kind = cfg.failure_kind;
|
||||||
const auto failure_block = cfg.failure_block;
|
const auto failure_block = cfg.failure_block;
|
||||||
LogDispatcherFallback(options, cfg, "structurize", dispatcher_reason);
|
LogDispatcherFallback(options, cfg, "structurize");
|
||||||
|
auto failure_reason = std::move(cfg.unsupported_reason);
|
||||||
cfg = unstructured_cfg;
|
cfg = unstructured_cfg;
|
||||||
cfg.unsupported = true;
|
cfg.unsupported = true;
|
||||||
cfg.failure_kind = failure_kind;
|
cfg.failure_kind = failure_kind;
|
||||||
cfg.failure_block = failure_block;
|
cfg.failure_block = failure_block;
|
||||||
cfg.unsupported_reason = dispatcher_reason;
|
cfg.unsupported_reason = std::move(failure_reason);
|
||||||
} else {
|
} else {
|
||||||
LOGF("%s structured CFG success: blocks=%" PRIu64 "\n", GetDumpLabel(options),
|
LOGF("%s structured CFG success: blocks=%" PRIu64 "\n", GetDumpLabel(options),
|
||||||
static_cast<uint64_t>(cfg.blocks.size()));
|
static_cast<uint64_t>(cfg.blocks.size()));
|
||||||
@@ -594,16 +588,13 @@ TranslateResult TranslateProgram(std::span<const uint32_t> code, const CompileOp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Frontend::TranslateOptions translate_options {
|
Frontend::TranslateOptions translate_options {
|
||||||
.stage = options.stage,
|
.stage = options.stage,
|
||||||
.wave_size = options.wave_size,
|
.wave_size = options.wave_size,
|
||||||
.shader_hash = options.shader_hash,
|
.shader_hash = options.shader_hash,
|
||||||
.user_data_base = options.user_data_base,
|
.user_data_base = options.user_data_base,
|
||||||
.user_data_count = static_cast<uint32_t>(options.user_data.size()),
|
.user_data_count = static_cast<uint32_t>(options.user_data.size()),
|
||||||
.dispatcher_fallback = dispatcher_fallback,
|
.input_info = options.input_info,
|
||||||
.cfg_failure_kind = cfg.failure_kind,
|
.embedded_fetch = embedded_fetch.loads.empty() ? nullptr : &embedded_fetch,
|
||||||
.fallback_reason = dispatcher_reason.empty() ? cfg.unsupported_reason : dispatcher_reason,
|
|
||||||
.input_info = options.input_info,
|
|
||||||
.embedded_fetch = embedded_fetch.loads.empty() ? nullptr : &embedded_fetch,
|
|
||||||
};
|
};
|
||||||
LOGF("%s phase begin: stage=%s hash=0x%016" PRIx64 " IR TranslateProgram\n",
|
LOGF("%s phase begin: stage=%s hash=0x%016" PRIx64 " IR TranslateProgram\n",
|
||||||
GetDumpLabel(options), StageName(options.stage), options.shader_hash);
|
GetDumpLabel(options), StageName(options.stage), options.shader_hash);
|
||||||
|
|||||||
@@ -111,11 +111,6 @@ IR::MemoryInfo MemoryInfoFromDecoded(const Decoder::Instruction& decoded) {
|
|||||||
memory.image_sample_flags = decoded.image_sample_flags;
|
memory.image_sample_flags = decoded.image_sample_flags;
|
||||||
memory.image_dimension = decoded.image_dimension;
|
memory.image_dimension = decoded.image_dimension;
|
||||||
memory.image_address_components = decoded.image_address_components;
|
memory.image_address_components = decoded.image_address_components;
|
||||||
memory.image_nsa_dwords = decoded.image_nsa_dwords;
|
|
||||||
for (uint32_t index = 0; index < Decoder::MaxImageNsaAddressComponents; index++) {
|
|
||||||
memory.image_nsa_addr[index] = decoded.image_nsa_addr[index];
|
|
||||||
}
|
|
||||||
memory.memory_segment = decoded.memory_segment;
|
|
||||||
memory.address_is_full =
|
memory.address_is_full =
|
||||||
memory.kind == ResourceKind::Flat ||
|
memory.kind == ResourceKind::Flat ||
|
||||||
(memory.kind == ResourceKind::Global && decoded.src1.kind == Decoder::OperandKind::Vgpr);
|
(memory.kind == ResourceKind::Global && decoded.src1.kind == Decoder::OperandKind::Vgpr);
|
||||||
@@ -125,8 +120,6 @@ IR::MemoryInfo MemoryInfoFromDecoded(const Decoder::Instruction& decoded) {
|
|||||||
memory.image_has_mip = decoded.opcode == Decoder::Opcode::IMAGE_LOAD_MIP ||
|
memory.image_has_mip = decoded.opcode == Decoder::Opcode::IMAGE_LOAD_MIP ||
|
||||||
decoded.opcode == Decoder::Opcode::IMAGE_STORE_MIP;
|
decoded.opcode == Decoder::Opcode::IMAGE_STORE_MIP;
|
||||||
memory.image_r128 = decoded.image_r128;
|
memory.image_r128 = decoded.image_r128;
|
||||||
memory.glc = decoded.glc;
|
|
||||||
memory.slc = decoded.slc;
|
|
||||||
memory.idxen = decoded.idxen;
|
memory.idxen = decoded.idxen;
|
||||||
memory.offen = decoded.offen;
|
memory.offen = decoded.offen;
|
||||||
memory.resource = ResourceIndexFromOperand(decoded.src1);
|
memory.resource = ResourceIndexFromOperand(decoded.src1);
|
||||||
|
|||||||
@@ -954,9 +954,9 @@ IR::Program TranslateProgram(const Decoder::Program& decoded, const CFG::Graph&
|
|||||||
break;
|
break;
|
||||||
default: break; // ValidateTranslateOptions rejects unsupported stages.
|
default: break; // ValidateTranslateOptions rejects unsupported stages.
|
||||||
}
|
}
|
||||||
result.dispatcher_fallback = options.dispatcher_fallback;
|
result.dispatcher_fallback = cfg.irreducible || cfg.unsupported;
|
||||||
result.cfg_failure_kind = options.cfg_failure_kind;
|
result.cfg_failure_kind = cfg.failure_kind;
|
||||||
result.fallback_reason = options.fallback_reason;
|
result.fallback_reason = cfg.unsupported_reason;
|
||||||
if (options.embedded_fetch != nullptr) {
|
if (options.embedded_fetch != nullptr) {
|
||||||
result.info.vertex_offset_sgpr = options.embedded_fetch->vertex_offset_sgpr;
|
result.info.vertex_offset_sgpr = options.embedded_fetch->vertex_offset_sgpr;
|
||||||
result.info.instance_offset_sgpr = options.embedded_fetch->instance_offset_sgpr;
|
result.info.instance_offset_sgpr = options.embedded_fetch->instance_offset_sgpr;
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#include "graphics/shader/recompiler/ir/ShaderIR.h"
|
#include "graphics/shader/recompiler/ir/ShaderIR.h"
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string_view>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace Libs::Graphics::ShaderRecompiler::Frontend {
|
namespace Libs::Graphics::ShaderRecompiler::Frontend {
|
||||||
@@ -29,9 +28,6 @@ struct TranslateOptions {
|
|||||||
uint64_t shader_hash = 0;
|
uint64_t shader_hash = 0;
|
||||||
uint32_t user_data_base = 0;
|
uint32_t user_data_base = 0;
|
||||||
uint32_t user_data_count = 64;
|
uint32_t user_data_count = 64;
|
||||||
bool dispatcher_fallback = false;
|
|
||||||
CFG::FailureKind cfg_failure_kind = CFG::FailureKind::None;
|
|
||||||
std::string_view fallback_reason;
|
|
||||||
ShaderStageInputInfo input_info;
|
ShaderStageInputInfo input_info;
|
||||||
const EmbeddedFetchPlan* embedded_fetch = nullptr;
|
const EmbeddedFetchPlan* embedded_fetch = nullptr;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -57,17 +57,12 @@ struct MemoryInfo {
|
|||||||
uint32_t image_sample_flags = 0;
|
uint32_t image_sample_flags = 0;
|
||||||
Decoder::ImageDimension image_dimension = Decoder::ImageDimension::Unknown;
|
Decoder::ImageDimension image_dimension = Decoder::ImageDimension::Unknown;
|
||||||
uint32_t image_address_components = 0;
|
uint32_t image_address_components = 0;
|
||||||
uint32_t image_nsa_dwords = 0;
|
|
||||||
uint32_t image_nsa_addr[Decoder::MaxImageNsaAddressComponents] = {};
|
|
||||||
uint32_t memory_segment = 0;
|
|
||||||
bool address_is_full = false;
|
bool address_is_full = false;
|
||||||
bool data_signed = false;
|
bool data_signed = false;
|
||||||
bool typed = false;
|
bool typed = false;
|
||||||
bool formatted = false;
|
bool formatted = false;
|
||||||
bool image_has_mip = false;
|
bool image_has_mip = false;
|
||||||
bool image_r128 = false;
|
bool image_r128 = false;
|
||||||
bool glc = false;
|
|
||||||
bool slc = false;
|
|
||||||
bool idxen = false;
|
bool idxen = false;
|
||||||
bool offen = false;
|
bool offen = false;
|
||||||
bool planning_only = false;
|
bool planning_only = false;
|
||||||
@@ -540,9 +535,8 @@ struct Program: ResourcePlan {
|
|||||||
CFG::FailureKind cfg_failure_kind = CFG::FailureKind::None;
|
CFG::FailureKind cfg_failure_kind = CFG::FailureKind::None;
|
||||||
std::string fallback_reason;
|
std::string fallback_reason;
|
||||||
std::vector<BlockInfo> block_info;
|
std::vector<BlockInfo> block_info;
|
||||||
// Decoded MIMG/VMEM metadata carries details such as RDNA2 NSA address registers and
|
// Typed memory and export instructions reference shader-local metadata by dense index.
|
||||||
// storage-image swizzles. Typed memory instructions carry a dense index into these shader-local
|
// Decoder-only details (such as NSA register numbers) have already become IR operands.
|
||||||
// tables until those fields are consumed by emission.
|
|
||||||
std::vector<ExportInfo> export_info;
|
std::vector<ExportInfo> export_info;
|
||||||
std::vector<Value> dynamic_reads;
|
std::vector<Value> dynamic_reads;
|
||||||
bool shader_info_complete = false;
|
bool shader_info_complete = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user