Skip to content

Commit

Permalink
Comment out stuff and hacks
Browse files Browse the repository at this point in the history
  • Loading branch information
Xcedf committed Feb 27, 2025
1 parent 8a1e05f commit f57fef8
Show file tree
Hide file tree
Showing 16 changed files with 142 additions and 15 deletions.
7 changes: 7 additions & 0 deletions src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ static bool separateupdatefolder = false;
static bool compatibilityData = false;
static bool checkCompatibilityOnStartup = false;
static std::string audioBackend = "cubeb";
std::vector<u64> skipedHashes = {};

// Gui
std::vector<std::filesystem::path> settings_install_dirs = {};
Expand Down Expand Up @@ -304,6 +305,10 @@ void setFullscreenMode(bool enable) {
isFullscreen = enable;
}

std::vector<u64> hashesToSkip() {
return skipedHashes;
}

void setisTrophyPopupDisabled(bool disable) {
isTrophyPopupDisabled = disable;
}
Expand Down Expand Up @@ -606,6 +611,7 @@ void load(const std::filesystem::path& path) {
shouldDumpShaders = toml::find_or<bool>(gpu, "dumpShaders", false);
shouldPatchShaders = toml::find_or<bool>(gpu, "patchShaders", true);
vblankDivider = toml::find_or<int>(gpu, "vblankDivider", 1);
skipedHashes = toml::find_or<std::vector<u64>>(gpu, "skipShaders", {});
}

if (data.contains("Vulkan")) {
Expand Down Expand Up @@ -717,6 +723,7 @@ void save(const std::filesystem::path& path) {
data["GPU"]["dumpShaders"] = shouldDumpShaders;
data["GPU"]["patchShaders"] = shouldPatchShaders;
data["GPU"]["vblankDivider"] = vblankDivider;
data["GPU"]["skipShaders"] = skipedHashes;
data["Vulkan"]["gpuId"] = gpuId;
data["Vulkan"]["validation"] = vkValidation;
data["Vulkan"]["validation_sync"] = vkValidationSync;
Expand Down
1 change: 1 addition & 0 deletions src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ bool dumpShaders();
bool patchShaders();
bool isRdocEnabled();
u32 vblankDiv();
std::vector<u64> hashesToSkip();

void setDebugDump(bool enable);
void setCollectShaderForDebug(bool enable);
Expand Down
2 changes: 1 addition & 1 deletion src/core/aerolib/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ template <int stub_index>
static u64 CommonStub() {
auto entry = stub_nids[stub_index];
if (entry) {
LOG_ERROR(Core, "Stub: {} (nid: {}) called, returning zero to {}", entry->name, entry->nid,
LOG_TRACE(Core, "Stub: {} (nid: {}) called, returning zero to {}", entry->name, entry->nid,
__builtin_return_address(0));
} else {
LOG_ERROR(Core, "Stub: Unknown (nid: {}) called, returning zero to {}",
Expand Down
2 changes: 1 addition & 1 deletion src/core/cpu_patches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,7 @@ static bool TryExecuteIllegalInstruction(void* ctx, void* code_address) {
if (length + index > 64) {
// Undefined behavior if length + index is bigger than 64 according to the spec,
// we'll warn and continue execution.
LOG_WARNING(Core,
LOG_TRACE(Core,
"extrq at {} with length {} and index {} is bigger than 64, "
"undefined behavior",
fmt::ptr(code_address), length, index);
Expand Down
15 changes: 13 additions & 2 deletions src/core/libraries/ajm/ajm_at9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,14 @@ std::tuple<u32, u32> AjmAt9Decoder::ProcessData(std::span<u8>& in_buf, SparseOut
AjmInstanceGapless& gapless) {
int ret = 0;
int bytes_used = 0;
Frame* frame = &static_cast<Atrac9Handle*>(m_handle)->Frame;

switch (m_format) {
case AjmFormatEncoding::S16:
ret = Atrac9Decode(m_handle, in_buf.data(), reinterpret_cast<s16*>(m_pcm_buffer.data()),
&bytes_used, True(m_flags & AjmAt9CodecFlags::NonInterleavedOutput));
if (frame->Config != NULL) {
ret = Atrac9Decode(m_handle, in_buf.data(), reinterpret_cast<s16*>(m_pcm_buffer.data()),
&bytes_used, True(m_flags & AjmAt9CodecFlags::NonInterleavedOutput));
}
break;
case AjmFormatEncoding::S32:
ret = Atrac9DecodeS32(m_handle, in_buf.data(), reinterpret_cast<s32*>(m_pcm_buffer.data()),
Expand Down Expand Up @@ -103,6 +107,13 @@ std::tuple<u32, u32> AjmAt9Decoder::ProcessData(std::span<u8>& in_buf, SparseOut
UNREACHABLE();
}

if (m_codec_info.framesInSuperframe == 0) {
m_codec_info.framesInSuperframe = 1;
}
if (m_codec_info.channels == 0) {
m_codec_info.channels = 1;
}

const auto samples_written = pcm_written / m_codec_info.channels;
gapless.current.skipped_samples += m_codec_info.frameSamples - samples_written;
if (gapless.init.total_samples != 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/core/libraries/ajm/ajm_mp3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class BitReader {

int AjmMp3Decoder::ParseMp3Header(const u8* p_begin, u32 stream_size, int parse_ofl,
AjmDecMp3ParseFrame* frame) {
LOG_INFO(Lib_Ajm, "called stream_size = {} parse_ofl = {}", stream_size, parse_ofl);
LOG_TRACE(Lib_Ajm, "called stream_size = {} parse_ofl = {}", stream_size, parse_ofl);

if (p_begin == nullptr || stream_size < 4 || frame == nullptr) {
return ORBIS_AJM_ERROR_INVALID_PARAMETER;
Expand Down Expand Up @@ -416,7 +416,7 @@ int AjmMp3Decoder::ParseMp3Header(const u8* p_begin, u32 stream_size, int parse_
LOG_ERROR(Lib_Ajm, "FGH header CRC is incorrect.");
}
} else {
LOG_ERROR(Lib_Ajm, "Could not find vendor header.");
LOG_TRACE(Lib_Ajm, "Could not find vendor header.");
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/libraries/audio/audioin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ int PS4_SYSV_ABI sceAudioInInit() {
}

int PS4_SYSV_ABI sceAudioInInput() {
LOG_ERROR(Lib_AudioIn, "(STUBBED) called");
LOG_TRACE(Lib_AudioIn, "(STUBBED) called");
return ORBIS_OK;
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/libraries/kernel/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ int PS4_SYSV_ABI sceKernelMapNamedDirectMemory(void** addr, u64 len, int prot, i
const auto mem_prot = static_cast<Core::MemoryProt>(prot);
const auto map_flags = static_cast<Core::MemoryMapFlags>(flags);
SCOPE_EXIT {
LOG_INFO(Kernel_Vmm,
LOG_TRACE(Kernel_Vmm,
"in_addr = {:#x}, out_addr = {}, len = {:#x}, prot = {:#x}, flags = {:#x}, "
"directMemoryStart = {:#x}, "
"alignment = {:#x}",
Expand Down Expand Up @@ -287,7 +287,7 @@ s32 PS4_SYSV_ABI sceKernelBatchMap2(OrbisKernelBatchMapEntry* entries, int numEn
result = sceKernelMapNamedDirectMemory(&entries[i].start, entries[i].length,
entries[i].protection, flags,
static_cast<s64>(entries[i].offset), 0, "");
LOG_INFO(Kernel_Vmm,
LOG_TRACE(Kernel_Vmm,
"entry = {}, operation = {}, len = {:#x}, offset = {:#x}, type = {}, "
"result = {}",
i, entries[i].operation, entries[i].length, entries[i].offset,
Expand Down
2 changes: 1 addition & 1 deletion src/core/libraries/system/sysmodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ int PS4_SYSV_ABI sceSysmoduleIsCameraPreloaded() {
}

int PS4_SYSV_ABI sceSysmoduleIsLoaded(OrbisSysModule id) {
LOG_ERROR(Lib_SysModule, "(DUMMY) called module = {}", magic_enum::enum_name(id));
LOG_TRACE(Lib_SysModule, "(DUMMY) called module = {}", magic_enum::enum_name(id));
if (static_cast<u16>(id) == 0) {
LOG_ERROR(Lib_SysModule, "Invalid sysmodule ID: {:#x}", static_cast<u16>(id));
return ORBIS_SYSMODULE_INVALID_ID;
Expand Down
2 changes: 1 addition & 1 deletion src/core/libraries/videoout/video_out.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ s32 PS4_SYSV_ABI sceVideoOutSubmitFlip(s32 handle, s32 bufferIndex, s32 flipMode
}

if (flipMode != 1) {
LOG_WARNING(Lib_VideoOut, "flipmode = {}", flipMode);
LOG_TRACE(Lib_VideoOut, "flipmode = {}", flipMode);
}

if (bufferIndex < -1 || bufferIndex > 15) {
Expand Down
5 changes: 5 additions & 0 deletions src/video_core/amdgpu/liverpool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,11 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span<const u32> dcb, std::span<c
}
break;
}
case PM4ItOpcode::SetPredication: {
const auto* set_predication = reinterpret_cast<const PM4CmdSetPredication*>(header);
//LOG_WARNING(Lib_GnmDriver, "SetPredication ignored");
break;
}
default:
UNREACHABLE_MSG("Unknown PM4 type 3 opcode {:#x} with count {}",
static_cast<u32>(opcode), count);
Expand Down
80 changes: 80 additions & 0 deletions src/video_core/amdgpu/pm4_cmds.h
Original file line number Diff line number Diff line change
Expand Up @@ -867,4 +867,84 @@ struct PM4CmdDrawIndexIndirectMulti {
u32 draw_initiator; ///< Draw Initiator Register
};

struct PM4CmdSetPredication {
enum class Predication : u32 {
DrawIfNotVisibleOrOverflow = 0u,
DrawIfVisibleOrNoOverflow = 1u
};
enum class PredicationOp : u32 {
ClearPredicate = 0b000u,
SetZPassPredicate = 0b001u,
SetPrimCountPredicate = 0b010u,
};
enum class PredicationHint : u32 {
WaitUntilFinalZPassWritten = 0u,
DrawIfNotFinalZPassWritten = 1u
};

PM4Type3Header header; ///< header
union {
BitField<4, 28, u32> start_addr_lo; ///< Start address bits [31:4]
u32 dw1;
};
union {
BitField<0, 8, u32> start_addr_hi; ///< Start address bits [39:32] - taken from PAL
///< SI programming guide says it's 16 bits but that
///< overlaps with subsequent fields, so likely an error
BitField<8, 1, Predication> predication; ///< Predication boolean, valid for both ops
BitField<12, 1, PredicationHint> hint; ///< Only valid for ZPass/Occlusion Predicate
BitField<16, 3, PredicationOp> op; ///< Predicate operation
BitField<31, 1, u32> cont; ///< Continue set predication, true if subsequent packet
u32 dw2;
};

template <typename T>
T Address() const {
return reinterpret_cast<T>(start_addr_lo | u64(start_addr_hi) << 32);
}
};

struct PM4CmdMemSemaphore {
enum class MemSemaphoreClientCode : u32 {
CommandProcessor = 0b00u,
CommandBuffer = 0b01u,
DataBuffer = 0b10u,
Reserved = 0b11u,
};
enum class MemSemaphoreSelect : u32 {
SignalSemaphore = 0b110u,
WaitSemaphore = 0b1111u
};
enum class MemSemaphoreUseMailbox : u32 {
DoNotWaitForMailboxToBeWritten = 0u,
WaitForMailboxToBeWritten = 1u
};
enum class MemSemaphoreSignalType : u32 {
SignalIncrementOrWait = 0u,
SignalSetOne = 1u
};

PM4Type3Header header; ///< header
union {
BitField<3, 29, u32> addr_lo; ///< Semaphore address bits [31:3]
u32 dw1;
};
union {
u32 dw2;
BitField<0, 8, u32> addr_hi; ///< Semaphore address bits [39:32]
BitField<12, 1, u32>
waitOnSignal; ///< Wait until all outstanding EOP have completed
BitField<16, 1, MemSemaphoreUseMailbox>
useMailbox; ///< Enables waiting until mailbox is written to
BitField<20, 1, MemSemaphoreSignalType> signalType;
BitField<24, 2, MemSemaphoreClientCode> clientCode;
BitField<29, 3, MemSemaphoreSelect> semSel;
};

template <typename T>
T Address() const {
return reinterpret_cast<T>(addr_lo | u64(addr_hi) << 32);
}
};

} // namespace AmdGpu
2 changes: 2 additions & 0 deletions src/video_core/renderer_vulkan/liverpool_to_vk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,8 @@ std::span<const SurfaceFormatInfo> SurfaceFormats() {
vk::Format::eR16G16Sint),
CreateSurfaceFormatInfo(AmdGpu::DataFormat::Format16_16, AmdGpu::NumberFormat::Float,
vk::Format::eR16G16Sfloat),
CreateSurfaceFormatInfo(AmdGpu::DataFormat::Format16_16, AmdGpu::NumberFormat::Ubnorm,
vk::Format::eR16G16Unorm),
// 10_11_11
CreateSurfaceFormatInfo(AmdGpu::DataFormat::Format10_11_11, AmdGpu::NumberFormat::Float,
vk::Format::eB10G11R11UfloatPack32),
Expand Down
4 changes: 4 additions & 0 deletions src/video_core/renderer_vulkan/liverpool_to_vk.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ static inline vk::Format PromoteFormatToDepth(vk::Format fmt) {
return vk::Format::eD32Sfloat;
} else if (fmt == vk::Format::eR16Unorm) {
return vk::Format::eD16Unorm;
} else if (fmt == vk::Format::eR8G8B8A8Unorm) {
return vk::Format::eR32Uint;
} else if (fmt == vk::Format::eR8G8B8A8Srgb) {
return vk::Format::eR32Uint;
}
UNREACHABLE();
}
Expand Down
19 changes: 18 additions & 1 deletion src/video_core/renderer_vulkan/vk_pipeline_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,16 @@ const ComputePipeline* PipelineCache::GetComputePipeline() {
return it->second.get();
}

bool ShouldSkipShader(u64 shader_hash, const char* shader_type) {
std::vector<u64> skip_hashes = Config::hashesToSkip();
shader_hash = shader_hash & INT64_MAX;
if (std::ranges::contains(skip_hashes, shader_hash)) {
//LOG_WARNING(Render_Vulkan, "Skipped {} shader hash {:#x}.", shader_type, shader_hash);
return true;
}
return false;
}

bool PipelineCache::RefreshGraphicsKey() {
std::memset(&graphics_key, 0, sizeof(GraphicsPipelineKey));

Expand Down Expand Up @@ -291,7 +301,7 @@ bool PipelineCache::RefreshGraphicsKey() {
key.cull_mode = regs.polygon_control.CullingMode();
key.clip_space = regs.clipper_control.clip_space;
key.front_face = regs.polygon_control.front_face;
key.num_samples = regs.NumSamples();
key.num_samples = regs.aa_config.NumSamples();

const bool skip_cb_binding =
regs.color_control.mode == AmdGpu::Liverpool::ColorControl::OperationMode::Disable;
Expand Down Expand Up @@ -360,6 +370,10 @@ bool PipelineCache::RefreshGraphicsKey() {
return false;
}

if (ShouldSkipShader(bininfo.shader_hash, "graphics")) {
return false;
}

auto params = Liverpool::GetParams(*pgm);
std::optional<Shader::Gcn::FetchShaderData> fetch_shader_;
std::tie(infos[stage_out_idx], modules[stage_out_idx], fetch_shader_,
Expand Down Expand Up @@ -466,6 +480,9 @@ bool PipelineCache::RefreshComputeKey() {
Shader::Backend::Bindings binding{};
const auto& cs_pgm = liverpool->GetCsRegs();
const auto cs_params = Liverpool::GetParams(cs_pgm);
if (ShouldSkipShader(cs_params.hash, "compute")) {
return false;
}
std::tie(infos[0], modules[0], fetch_shader, compute_key.value) =
GetProgram(Shader::Stage::Compute, LogicalStage::Compute, cs_params, binding);
return true;
Expand Down
6 changes: 3 additions & 3 deletions src/video_core/renderer_vulkan/vk_rasterizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ bool Rasterizer::BindResources(const Pipeline* pipeline) {
}
} else {
if (texture_cache.IsMeta(address)) {
LOG_WARNING(Render_Vulkan, "Unexpected metadata read by a CS shader (buffer)");
LOG_TRACE(Render_Vulkan, "Unexpected metadata read by a CS shader (buffer)");
}
}
return false;
Expand Down Expand Up @@ -588,8 +588,8 @@ void Rasterizer::BindBuffers(const Shader::Info& stage, Shader::Backend::Binding
vsharp.base_address, vsharp.GetSize(), desc.is_written, true, buffer_id);
const u32 fmt_stride = AmdGpu::NumBits(vsharp.GetDataFmt()) >> 3;
const u32 buf_stride = vsharp.GetStride();
ASSERT_MSG(buf_stride % fmt_stride == 0,
"Texel buffer stride must match format stride");
/*ASSERT_MSG(buf_stride % fmt_stride == 0,
"Texel buffer stride must match format stride");*/
const u32 offset_aligned = Common::AlignDown(offset, alignment);
const u32 adjust = offset - offset_aligned;
ASSERT(adjust % fmt_stride == 0);
Expand Down

0 comments on commit f57fef8

Please sign in to comment.