Log: Simplify macros
This commit is contained in:
+10
-10
@@ -290,7 +290,7 @@ void AudioStream::ReadFrames(SampleType* samples, u32 num_frames)
|
||||
else
|
||||
{
|
||||
m_filling = false;
|
||||
Log_VerboseFmt("Underrun compensation done ({} frames buffered)", toFill);
|
||||
VERBOSE_LOG("Underrun compensation done ({} frames buffered)", toFill);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ void AudioStream::ReadFrames(SampleType* samples, u32 num_frames)
|
||||
resample_subpos %= 65536u;
|
||||
}
|
||||
|
||||
Log_VerboseFmt("Audio buffer underflow, resampled {} frames to {}", frames_to_read, num_frames);
|
||||
VERBOSE_LOG("Audio buffer underflow, resampled {} frames to {}", frames_to_read, num_frames);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -441,7 +441,7 @@ void AudioStream::InternalWriteFrames(s16* data, u32 num_frames)
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_DebugPrint("Buffer overrun, chunk dropped");
|
||||
DEBUG_LOG("Buffer overrun, chunk dropped");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -498,7 +498,7 @@ void AudioStream::AllocateBuffer()
|
||||
if (IsExpansionEnabled())
|
||||
m_expand_buffer = std::make_unique<float[]>(m_parameters.expand_block_size * NUM_INPUT_CHANNELS);
|
||||
|
||||
Log_DevFmt(
|
||||
DEV_LOG(
|
||||
"Allocated buffer of {} frames for buffer of {} ms [expansion {} (block size {}), stretch {}, target size {}].",
|
||||
m_buffer_size, m_parameters.buffer_ms, GetExpansionModeName(m_parameters.expansion_mode),
|
||||
m_parameters.expand_block_size, GetStretchModeName(m_parameters.stretch_mode), m_target_buffer_size);
|
||||
@@ -891,7 +891,7 @@ void AudioStream::UpdateStretchTempo()
|
||||
// state vars
|
||||
if (m_stretch_reset >= STRETCH_RESET_THRESHOLD)
|
||||
{
|
||||
Log_VerbosePrint("___ Stretcher is being reset.");
|
||||
VERBOSE_LOG("___ Stretcher is being reset.");
|
||||
m_stretch_inactive = false;
|
||||
m_stretch_ok_count = 0;
|
||||
m_dynamic_target_usage = base_target_usage;
|
||||
@@ -928,13 +928,13 @@ void AudioStream::UpdateStretchTempo()
|
||||
|
||||
if (m_stretch_ok_count >= INACTIVE_MIN_OK_COUNT)
|
||||
{
|
||||
Log_VerbosePrint("=== Stretcher is now inactive.");
|
||||
VERBOSE_LOG("=== Stretcher is now inactive.");
|
||||
m_stretch_inactive = true;
|
||||
}
|
||||
}
|
||||
else if (!IsInRange(tempo, 1.0f / INACTIVE_BAD_FACTOR, INACTIVE_BAD_FACTOR))
|
||||
{
|
||||
Log_VerboseFmt("~~~ Stretcher is now active @ tempo {}.", tempo);
|
||||
VERBOSE_LOG("~~~ Stretcher is now active @ tempo {}.", tempo);
|
||||
m_stretch_inactive = false;
|
||||
m_stretch_ok_count = 0;
|
||||
}
|
||||
@@ -951,9 +951,9 @@ void AudioStream::UpdateStretchTempo()
|
||||
|
||||
if (Common::Timer::ConvertValueToSeconds(now - last_log_time) > 1.0f)
|
||||
{
|
||||
Log_VerboseFmt("buffers: {:4d} ms ({:3.0f}%), tempo: {}, comp: {:2.3f}, iters: {}, reset:{}",
|
||||
(ibuffer_usage * 1000u) / m_sample_rate, 100.0f * buffer_usage / base_target_usage, tempo,
|
||||
m_dynamic_target_usage / base_target_usage, iterations, m_stretch_reset);
|
||||
VERBOSE_LOG("buffers: {:4d} ms ({:3.0f}%), tempo: {}, comp: {:2.3f}, iters: {}, reset:{}",
|
||||
(ibuffer_usage * 1000u) / m_sample_rate, 100.0f * buffer_usage / base_target_usage, tempo,
|
||||
m_dynamic_target_usage / base_target_usage, iterations, m_stretch_reset);
|
||||
|
||||
last_log_time = now;
|
||||
iterations = 0;
|
||||
|
||||
@@ -302,7 +302,7 @@ bool CDImage::ReadRawSector(void* buffer, SubChannelQ* subq)
|
||||
// TODO: This is where we'd reconstruct the header for other mode tracks.
|
||||
if (!ReadSectorFromIndex(buffer, *m_current_index, m_position_in_index))
|
||||
{
|
||||
Log_ErrorFmt("Read of LBA {} failed", m_position_on_disc);
|
||||
ERROR_LOG("Read of LBA {} failed", m_position_on_disc);
|
||||
Seek(m_position_on_disc);
|
||||
return false;
|
||||
}
|
||||
@@ -324,7 +324,7 @@ bool CDImage::ReadRawSector(void* buffer, SubChannelQ* subq)
|
||||
|
||||
if (subq && !ReadSubChannelQ(subq, *m_current_index, m_position_in_index))
|
||||
{
|
||||
Log_ErrorFmt("Subchannel read of LBA {} failed", m_position_on_disc);
|
||||
ERROR_LOG("Subchannel read of LBA {} failed", m_position_on_disc);
|
||||
Seek(m_position_on_disc);
|
||||
return false;
|
||||
}
|
||||
|
||||
+17
-17
@@ -116,14 +116,14 @@ chd_file* CDImageCHD::OpenCHD(std::string_view filename, FileSystem::ManagedCFil
|
||||
}
|
||||
else if (err != CHDERR_REQUIRES_PARENT)
|
||||
{
|
||||
Log_ErrorFmt("Failed to open CHD '{}': {}", filename, chd_error_string(err));
|
||||
ERROR_LOG("Failed to open CHD '{}': {}", filename, chd_error_string(err));
|
||||
Error::SetString(error, chd_error_string(err));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (recursion_level >= MAX_PARENTS)
|
||||
{
|
||||
Log_ErrorFmt("Failed to open CHD '{}': Too many parent files", filename);
|
||||
ERROR_LOG("Failed to open CHD '{}': Too many parent files", filename);
|
||||
Error::SetString(error, "Too many parent files");
|
||||
return nullptr;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ chd_file* CDImageCHD::OpenCHD(std::string_view filename, FileSystem::ManagedCFil
|
||||
err = chd_read_header_file(fp.get(), &header);
|
||||
if (err != CHDERR_NONE)
|
||||
{
|
||||
Log_ErrorFmt("Failed to read CHD header '{}': {}", filename, chd_error_string(err));
|
||||
ERROR_LOG("Failed to read CHD header '{}': {}", filename, chd_error_string(err));
|
||||
Error::SetString(error, chd_error_string(err));
|
||||
return nullptr;
|
||||
}
|
||||
@@ -166,8 +166,8 @@ chd_file* CDImageCHD::OpenCHD(std::string_view filename, FileSystem::ManagedCFil
|
||||
parent_chd = OpenCHD(filename_to_open, std::move(parent_fp), error, recursion_level + 1);
|
||||
if (parent_chd)
|
||||
{
|
||||
Log_VerboseFmt("Using parent CHD '{}' from cache for '{}'.", Path::GetFileName(filename_to_open),
|
||||
Path::GetFileName(filename));
|
||||
VERBOSE_LOG("Using parent CHD '{}' from cache for '{}'.", Path::GetFileName(filename_to_open),
|
||||
Path::GetFileName(filename));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,14 +208,14 @@ chd_file* CDImageCHD::OpenCHD(std::string_view filename, FileSystem::ManagedCFil
|
||||
parent_chd = OpenCHD(fd.FileName, std::move(parent_fp), error, recursion_level + 1);
|
||||
if (parent_chd)
|
||||
{
|
||||
Log_VerboseFmt("Using parent CHD '{}' for '{}'.", Path::GetFileName(fd.FileName), Path::GetFileName(filename));
|
||||
VERBOSE_LOG("Using parent CHD '{}' for '{}'.", Path::GetFileName(fd.FileName), Path::GetFileName(filename));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!parent_chd)
|
||||
{
|
||||
Log_ErrorFmt("Failed to open CHD '{}': Failed to find parent CHD, it must be in the same directory.", filename);
|
||||
ERROR_LOG("Failed to open CHD '{}': Failed to find parent CHD, it must be in the same directory.", filename);
|
||||
Error::SetString(error, "Failed to find parent CHD, it must be in the same directory.");
|
||||
return nullptr;
|
||||
}
|
||||
@@ -224,7 +224,7 @@ chd_file* CDImageCHD::OpenCHD(std::string_view filename, FileSystem::ManagedCFil
|
||||
err = chd_open_file(fp.get(), CHD_OPEN_READ | CHD_OPEN_TRANSFER_FILE, parent_chd, &chd);
|
||||
if (err != CHDERR_NONE)
|
||||
{
|
||||
Log_ErrorFmt("Failed to open CHD '{}': {}", filename, chd_error_string(err));
|
||||
ERROR_LOG("Failed to open CHD '{}': {}", filename, chd_error_string(err));
|
||||
Error::SetString(error, chd_error_string(err));
|
||||
return nullptr;
|
||||
}
|
||||
@@ -239,7 +239,7 @@ bool CDImageCHD::Open(const char* filename, Error* error)
|
||||
auto fp = FileSystem::OpenManagedSharedCFile(filename, "rb", FileSystem::FileShareMode::DenyWrite);
|
||||
if (!fp)
|
||||
{
|
||||
Log_ErrorFmt("Failed to open CHD '{}': errno {}", filename, errno);
|
||||
ERROR_LOG("Failed to open CHD '{}': errno {}", filename, errno);
|
||||
if (error)
|
||||
error->SetErrno(errno);
|
||||
|
||||
@@ -254,7 +254,7 @@ bool CDImageCHD::Open(const char* filename, Error* error)
|
||||
m_hunk_size = header->hunkbytes;
|
||||
if ((m_hunk_size % CHD_CD_SECTOR_DATA_SIZE) != 0)
|
||||
{
|
||||
Log_ErrorFmt("Hunk size ({}) is not a multiple of {}", m_hunk_size, CHD_CD_SECTOR_DATA_SIZE);
|
||||
ERROR_LOG("Hunk size ({}) is not a multiple of {}", m_hunk_size, CHD_CD_SECTOR_DATA_SIZE);
|
||||
Error::SetString(error, fmt::format("Hunk size ({}) is not a multiple of {}", m_hunk_size,
|
||||
static_cast<u32>(CHD_CD_SECTOR_DATA_SIZE)));
|
||||
return false;
|
||||
@@ -286,7 +286,7 @@ bool CDImageCHD::Open(const char* filename, Error* error)
|
||||
if (std::sscanf(metadata_str, CDROM_TRACK_METADATA2_FORMAT, &track_num, type_str, subtype_str, &frames,
|
||||
&pregap_frames, pgtype_str, pgsub_str, &postgap_frames) != 8)
|
||||
{
|
||||
Log_ErrorFmt("Invalid track v2 metadata: '{}'", metadata_str);
|
||||
ERROR_LOG("Invalid track v2 metadata: '{}'", metadata_str);
|
||||
Error::SetString(error, fmt::format("Invalid track v2 metadata: '{}'", metadata_str));
|
||||
return false;
|
||||
}
|
||||
@@ -304,7 +304,7 @@ bool CDImageCHD::Open(const char* filename, Error* error)
|
||||
|
||||
if (std::sscanf(metadata_str, CDROM_TRACK_METADATA_FORMAT, &track_num, type_str, subtype_str, &frames) != 4)
|
||||
{
|
||||
Log_ErrorFmt("Invalid track metadata: '{}'", metadata_str);
|
||||
ERROR_LOG("Invalid track metadata: '{}'", metadata_str);
|
||||
Error::SetString(error, fmt::format("Invalid track v2 metadata: '{}'", metadata_str));
|
||||
return false;
|
||||
}
|
||||
@@ -319,7 +319,7 @@ bool CDImageCHD::Open(const char* filename, Error* error)
|
||||
|
||||
if (track_num != (num_tracks + 1))
|
||||
{
|
||||
Log_ErrorFmt("Incorrect track number at index {}, expected {} got {}", num_tracks, (num_tracks + 1), track_num);
|
||||
ERROR_LOG("Incorrect track number at index {}, expected {} got {}", num_tracks, (num_tracks + 1), track_num);
|
||||
Error::SetString(error, fmt::format("Incorrect track number at index {}, expected {} got {}", num_tracks,
|
||||
(num_tracks + 1), track_num));
|
||||
return false;
|
||||
@@ -328,7 +328,7 @@ bool CDImageCHD::Open(const char* filename, Error* error)
|
||||
std::optional<TrackMode> mode = ParseTrackModeString(type_str);
|
||||
if (!mode.has_value())
|
||||
{
|
||||
Log_ErrorFmt("Invalid track mode: '{}'", type_str);
|
||||
ERROR_LOG("Invalid track mode: '{}'", type_str);
|
||||
Error::SetString(error, fmt::format("Invalid track mode: '{}'", type_str));
|
||||
return false;
|
||||
}
|
||||
@@ -360,7 +360,7 @@ bool CDImageCHD::Open(const char* filename, Error* error)
|
||||
{
|
||||
if (pregap_frames > frames)
|
||||
{
|
||||
Log_ErrorFmt("Pregap length {} exceeds track length {}", pregap_frames, frames);
|
||||
ERROR_LOG("Pregap length {} exceeds track length {}", pregap_frames, frames);
|
||||
Error::SetString(error, fmt::format("Pregap length {} exceeds track length {}", pregap_frames, frames));
|
||||
return false;
|
||||
}
|
||||
@@ -407,7 +407,7 @@ bool CDImageCHD::Open(const char* filename, Error* error)
|
||||
|
||||
if (m_tracks.empty())
|
||||
{
|
||||
Log_ErrorFmt("File '{}' contains no tracks", filename);
|
||||
ERROR_LOG("File '{}' contains no tracks", filename);
|
||||
Error::SetString(error, fmt::format("File '{}' contains no tracks", filename));
|
||||
return false;
|
||||
}
|
||||
@@ -561,7 +561,7 @@ ALWAYS_INLINE_RELEASE bool CDImageCHD::UpdateHunkBuffer(const Index& index, LBA
|
||||
const chd_error err = chd_read(m_chd, hunk_index, m_hunk_buffer.data());
|
||||
if (err != CHDERR_NONE)
|
||||
{
|
||||
Log_ErrorFmt("chd_read({}) failed: %s", hunk_index, chd_error_string(err));
|
||||
ERROR_LOG("chd_read({}) failed: %s", hunk_index, chd_error_string(err));
|
||||
|
||||
// data might have been partially written
|
||||
m_current_hunk_index = static_cast<u32>(-1);
|
||||
|
||||
@@ -110,15 +110,15 @@ bool CDImageCueSheet::OpenAndParse(const char* filename, Error* error)
|
||||
track_fp = FileSystem::OpenCFile(alternative_filename.c_str(), "rb");
|
||||
if (track_fp)
|
||||
{
|
||||
Log_WarningFmt("Your cue sheet references an invalid file '{}', but this was found at '{}' instead.",
|
||||
track_filename, alternative_filename);
|
||||
WARNING_LOG("Your cue sheet references an invalid file '{}', but this was found at '{}' instead.",
|
||||
track_filename, alternative_filename);
|
||||
}
|
||||
}
|
||||
|
||||
if (!track_fp)
|
||||
{
|
||||
Log_ErrorFmt("Failed to open track filename '{}' (from '{}' and '{}'): {}", track_full_filename, track_filename,
|
||||
filename, track_error.GetDescription());
|
||||
ERROR_LOG("Failed to open track filename '{}' (from '{}' and '{}'): {}", track_full_filename, track_filename,
|
||||
filename, track_error.GetDescription());
|
||||
Error::SetStringFmt(error, "Failed to open track filename '{}' (from '{}' and '{}'): {}", track_full_filename,
|
||||
track_filename, Path::GetFileName(filename), track_error.GetDescription());
|
||||
return false;
|
||||
@@ -149,8 +149,8 @@ bool CDImageCueSheet::OpenAndParse(const char* filename, Error* error)
|
||||
file_size /= track_sector_size;
|
||||
if (track_start >= file_size)
|
||||
{
|
||||
Log_ErrorFmt("Failed to open track {} in '{}': track start is out of range ({} vs {})", track_num, filename,
|
||||
track_start, file_size);
|
||||
ERROR_LOG("Failed to open track {} in '{}': track start is out of range ({} vs {})", track_num, filename,
|
||||
track_start, file_size);
|
||||
Error::SetStringFmt(error, "Failed to open track {} in '{}': track start is out of range ({} vs {}))",
|
||||
track_num, Path::GetFileName(filename), track_start, file_size);
|
||||
return false;
|
||||
@@ -285,7 +285,7 @@ bool CDImageCueSheet::OpenAndParse(const char* filename, Error* error)
|
||||
|
||||
if (m_tracks.empty())
|
||||
{
|
||||
Log_ErrorFmt("File '{}' contains no tracks", filename);
|
||||
ERROR_LOG("File '{}' contains no tracks", filename);
|
||||
Error::SetStringFmt(error, "File '{}' contains no tracks", Path::GetFileName(filename));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ enum class SCSIReadMode : u8
|
||||
const u32 expected_size = SCSIReadCommandOutputSize(mode);
|
||||
if (buffer.size() != expected_size)
|
||||
{
|
||||
Log_ErrorFmt("SCSI returned {} bytes, expected {}", buffer.size(), expected_size);
|
||||
ERROR_LOG("SCSI returned {} bytes, expected {}", buffer.size(), expected_size);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -115,14 +115,14 @@ enum class SCSIReadMode : u8
|
||||
CDImage::DeinterleaveSubcode(buffer.data() + CDImage::RAW_SECTOR_SIZE, deinterleaved_subcode);
|
||||
std::memcpy(&subq, &deinterleaved_subcode[CDImage::SUBCHANNEL_BYTES_PER_FRAME], sizeof(subq));
|
||||
|
||||
Log_DevFmt("SCSI full subcode read returned [{}] for {:02d}:{:02d}:{:02d}",
|
||||
StringUtil::EncodeHex(subq.data.data(), static_cast<int>(subq.data.size())), expected_pos.minute,
|
||||
expected_pos.second, expected_pos.frame);
|
||||
DEV_LOG("SCSI full subcode read returned [{}] for {:02d}:{:02d}:{:02d}",
|
||||
StringUtil::EncodeHex(subq.data.data(), static_cast<int>(subq.data.size())), expected_pos.minute,
|
||||
expected_pos.second, expected_pos.frame);
|
||||
|
||||
if (!subq.IsCRCValid())
|
||||
{
|
||||
Log_WarningFmt("SCSI full subcode read returned invalid SubQ CRC (got {:02X} expected {:02X})", subq.crc,
|
||||
CDImage::SubChannelQ::ComputeCRC(subq.data));
|
||||
WARNING_LOG("SCSI full subcode read returned invalid SubQ CRC (got {:02X} expected {:02X})", subq.crc,
|
||||
CDImage::SubChannelQ::ComputeCRC(subq.data));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ enum class SCSIReadMode : u8
|
||||
CDImage::Position::FromBCD(subq.absolute_minute_bcd, subq.absolute_second_bcd, subq.absolute_frame_bcd);
|
||||
if (expected_pos != got_pos)
|
||||
{
|
||||
Log_WarningFmt(
|
||||
WARNING_LOG(
|
||||
"SCSI full subcode read returned invalid MSF (got {:02x}:{:02x}:{:02x}, expected {:02d}:{:02d}:{:02d})",
|
||||
subq.absolute_minute_bcd, subq.absolute_second_bcd, subq.absolute_frame_bcd, expected_pos.minute,
|
||||
expected_pos.second, expected_pos.frame);
|
||||
@@ -143,14 +143,14 @@ enum class SCSIReadMode : u8
|
||||
{
|
||||
CDImage::SubChannelQ subq;
|
||||
std::memcpy(&subq, buffer.data() + CDImage::RAW_SECTOR_SIZE, sizeof(subq));
|
||||
Log_DevFmt("SCSI subq read returned [{}] for {:02d}:{:02d}:{:02d}",
|
||||
StringUtil::EncodeHex(subq.data.data(), static_cast<int>(subq.data.size())), expected_pos.minute,
|
||||
expected_pos.second, expected_pos.frame);
|
||||
DEV_LOG("SCSI subq read returned [{}] for {:02d}:{:02d}:{:02d}",
|
||||
StringUtil::EncodeHex(subq.data.data(), static_cast<int>(subq.data.size())), expected_pos.minute,
|
||||
expected_pos.second, expected_pos.frame);
|
||||
|
||||
if (!subq.IsCRCValid())
|
||||
{
|
||||
Log_WarningFmt("SCSI subq read returned invalid SubQ CRC (got {:02X} expected {:02X})", subq.crc,
|
||||
CDImage::SubChannelQ::ComputeCRC(subq.data));
|
||||
WARNING_LOG("SCSI subq read returned invalid SubQ CRC (got {:02X} expected {:02X})", subq.crc,
|
||||
CDImage::SubChannelQ::ComputeCRC(subq.data));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -158,9 +158,9 @@ enum class SCSIReadMode : u8
|
||||
CDImage::Position::FromBCD(subq.absolute_minute_bcd, subq.absolute_second_bcd, subq.absolute_frame_bcd);
|
||||
if (expected_pos != got_pos)
|
||||
{
|
||||
Log_WarningFmt("SCSI subq read returned invalid MSF (got {:02x}:{:02x}:{:02x}, expected {:02d}:{:02d}:{:02d})",
|
||||
subq.absolute_minute_bcd, subq.absolute_second_bcd, subq.absolute_frame_bcd, expected_pos.minute,
|
||||
expected_pos.second, expected_pos.frame);
|
||||
WARNING_LOG("SCSI subq read returned invalid MSF (got {:02x}:{:02x}:{:02x}, expected {:02d}:{:02d}:{:02d})",
|
||||
subq.absolute_minute_bcd, subq.absolute_second_bcd, subq.absolute_frame_bcd, expected_pos.minute,
|
||||
expected_pos.second, expected_pos.frame);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -257,12 +257,12 @@ bool CDImageDeviceWin32::Open(const char* filename, Error* error)
|
||||
m_hDevice = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, NULL);
|
||||
if (m_hDevice != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
Log_WarningFmt("Could not open '{}' as read/write, can't use SPTD", filename);
|
||||
WARNING_LOG("Could not open '{}' as read/write, can't use SPTD", filename);
|
||||
try_sptd = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorFmt("CreateFile('{}') failed: %08X", filename, GetLastError());
|
||||
ERROR_LOG("CreateFile('{}') failed: %08X", filename, GetLastError());
|
||||
if (error)
|
||||
error->SetWin32(GetLastError());
|
||||
|
||||
@@ -275,7 +275,7 @@ bool CDImageDeviceWin32::Open(const char* filename, Error* error)
|
||||
static constexpr u32 READ_SPEED_KBS = (DATA_SECTOR_SIZE * FRAMES_PER_SECOND * READ_SPEED_MULTIPLIER) / 1024;
|
||||
CDROM_SET_SPEED set_speed = {CdromSetSpeed, READ_SPEED_KBS, 0, CdromDefaultRotation};
|
||||
if (!DeviceIoControl(m_hDevice, IOCTL_CDROM_SET_SPEED, &set_speed, sizeof(set_speed), nullptr, 0, nullptr, nullptr))
|
||||
Log_WarningFmt("DeviceIoControl(IOCTL_CDROM_SET_SPEED) failed: {:08X}", GetLastError());
|
||||
WARNING_LOG("DeviceIoControl(IOCTL_CDROM_SET_SPEED) failed: {:08X}", GetLastError());
|
||||
|
||||
CDROM_READ_TOC_EX read_toc_ex = {};
|
||||
read_toc_ex.Format = CDROM_READ_TOC_EX_FORMAT_TOC;
|
||||
@@ -290,7 +290,7 @@ bool CDImageDeviceWin32::Open(const char* filename, Error* error)
|
||||
&bytes_returned, nullptr) ||
|
||||
toc.LastTrack < toc.FirstTrack)
|
||||
{
|
||||
Log_ErrorFmt("DeviceIoCtl(IOCTL_CDROM_READ_TOC_EX) failed: {:08X}", GetLastError());
|
||||
ERROR_LOG("DeviceIoCtl(IOCTL_CDROM_READ_TOC_EX) failed: {:08X}", GetLastError());
|
||||
if (error)
|
||||
error->SetWin32(GetLastError());
|
||||
|
||||
@@ -299,7 +299,7 @@ bool CDImageDeviceWin32::Open(const char* filename, Error* error)
|
||||
|
||||
DWORD last_track_address = 0;
|
||||
LBA disc_lba = 0;
|
||||
Log_DevFmt("FirstTrack={}, LastTrack={}", toc.FirstTrack, toc.LastTrack);
|
||||
DEV_LOG("FirstTrack={}, LastTrack={}", toc.FirstTrack, toc.LastTrack);
|
||||
|
||||
const u32 num_tracks_to_check = (toc.LastTrack - toc.FirstTrack) + 1 + 1;
|
||||
for (u32 track_index = 0; track_index < num_tracks_to_check; track_index++)
|
||||
@@ -307,14 +307,14 @@ bool CDImageDeviceWin32::Open(const char* filename, Error* error)
|
||||
const TRACK_DATA& td = toc.TrackData[track_index];
|
||||
const u8 track_num = td.TrackNumber;
|
||||
const DWORD track_address = BEToU32(td.Address);
|
||||
Log_DevFmt(" [{}]: Num={:02X}, Address={}", track_index, track_num, track_address);
|
||||
DEV_LOG(" [{}]: Num={:02X}, Address={}", track_index, track_num, track_address);
|
||||
|
||||
// fill in the previous track's length
|
||||
if (!m_tracks.empty())
|
||||
{
|
||||
if (track_num < m_tracks.back().track_number)
|
||||
{
|
||||
Log_ErrorFmt("Invalid TOC, track {} less than {}", track_num, m_tracks.back().track_number);
|
||||
ERROR_LOG("Invalid TOC, track {} less than {}", track_num, m_tracks.back().track_number);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -382,29 +382,29 @@ bool CDImageDeviceWin32::Open(const char* filename, Error* error)
|
||||
|
||||
if (m_tracks.empty())
|
||||
{
|
||||
Log_ErrorFmt("File '{}' contains no tracks", filename);
|
||||
ERROR_LOG("File '{}' contains no tracks", filename);
|
||||
Error::SetString(error, fmt::format("File '{}' contains no tracks", filename));
|
||||
return false;
|
||||
}
|
||||
|
||||
m_lba_count = disc_lba;
|
||||
|
||||
Log_DevFmt("{} tracks, {} indices, {} lbas", m_tracks.size(), m_indices.size(), m_lba_count);
|
||||
DEV_LOG("{} tracks, {} indices, {} lbas", m_tracks.size(), m_indices.size(), m_lba_count);
|
||||
for (u32 i = 0; i < m_tracks.size(); i++)
|
||||
{
|
||||
Log_DevFmt(" Track {}: Start {}, length {}, mode {}, control 0x{:02X}", m_tracks[i].track_number,
|
||||
m_tracks[i].start_lba, m_tracks[i].length, static_cast<u8>(m_tracks[i].mode), m_tracks[i].control.bits);
|
||||
DEV_LOG(" Track {}: Start {}, length {}, mode {}, control 0x{:02X}", m_tracks[i].track_number,
|
||||
m_tracks[i].start_lba, m_tracks[i].length, static_cast<u8>(m_tracks[i].mode), m_tracks[i].control.bits);
|
||||
}
|
||||
for (u32 i = 0; i < m_indices.size(); i++)
|
||||
{
|
||||
Log_DevFmt(" Index {}: Track {}, Index [], Start {}, length {}, file sector size {}, file offset {}", i,
|
||||
m_indices[i].track_number, m_indices[i].index_number, m_indices[i].start_lba_on_disc,
|
||||
m_indices[i].length, m_indices[i].file_sector_size, m_indices[i].file_offset);
|
||||
DEV_LOG(" Index {}: Track {}, Index [], Start {}, length {}, file sector size {}, file offset {}", i,
|
||||
m_indices[i].track_number, m_indices[i].index_number, m_indices[i].start_lba_on_disc, m_indices[i].length,
|
||||
m_indices[i].file_sector_size, m_indices[i].file_offset);
|
||||
}
|
||||
|
||||
if (!DetermineReadMode(try_sptd))
|
||||
{
|
||||
Log_ErrorPrint("Could not determine read mode");
|
||||
ERROR_LOG("Could not determine read mode");
|
||||
Error::SetString(error, "Could not determine read mode");
|
||||
return false;
|
||||
}
|
||||
@@ -479,18 +479,18 @@ std::optional<u32> CDImageDeviceWin32::DoSCSICommand(u8 cmd[SCSI_CMD_LENGTH], st
|
||||
if (!DeviceIoControl(m_hDevice, IOCTL_SCSI_PASS_THROUGH_DIRECT, &sptd, sizeof(sptd), &sptd, sizeof(sptd),
|
||||
&bytes_returned, nullptr))
|
||||
{
|
||||
Log_ErrorFmt("DeviceIoControl() for SCSI 0x{:02X} failed: {}", cmd[0], GetLastError());
|
||||
ERROR_LOG("DeviceIoControl() for SCSI 0x{:02X} failed: {}", cmd[0], GetLastError());
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (sptd.cmd.ScsiStatus != 0)
|
||||
{
|
||||
Log_ErrorFmt("SCSI command 0x{:02X} failed: {}", cmd[0], sptd.cmd.ScsiStatus);
|
||||
ERROR_LOG("SCSI command 0x{:02X} failed: {}", cmd[0], sptd.cmd.ScsiStatus);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (sptd.cmd.DataTransferLength != out_buffer.size())
|
||||
Log_WarningFmt("Only read {} of {} bytes", sptd.cmd.DataTransferLength, out_buffer.size());
|
||||
WARNING_LOG("Only read {} of {} bytes", sptd.cmd.DataTransferLength, out_buffer.size());
|
||||
|
||||
return sptd.cmd.DataTransferLength;
|
||||
}
|
||||
@@ -524,12 +524,12 @@ bool CDImageDeviceWin32::DoRawRead(LBA lba)
|
||||
if (!DeviceIoControl(m_hDevice, IOCTL_CDROM_RAW_READ, &rri, sizeof(rri), m_buffer.data(),
|
||||
static_cast<DWORD>(m_buffer.size()), &bytes_returned, nullptr))
|
||||
{
|
||||
Log_ErrorFmt("DeviceIoControl(IOCTL_CDROM_RAW_READ) for LBA {} failed: {:08X}", lba, GetLastError());
|
||||
ERROR_LOG("DeviceIoControl(IOCTL_CDROM_RAW_READ) for LBA {} failed: {:08X}", lba, GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (bytes_returned != expected_size)
|
||||
Log_WarningFmt("Only read {} of {} bytes", bytes_returned, expected_size);
|
||||
WARNING_LOG("Only read {} of {} bytes", bytes_returned, expected_size);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -542,7 +542,7 @@ bool CDImageDeviceWin32::ReadSectorToBuffer(LBA lba)
|
||||
const u32 expected_size = SCSIReadCommandOutputSize(m_scsi_read_mode);
|
||||
if (size.value_or(0) != expected_size)
|
||||
{
|
||||
Log_ErrorFmt("Read of LBA {} failed: only got {} of {} bytes", lba, size.value(), expected_size);
|
||||
ERROR_LOG("Read of LBA {} failed: only got {} of {} bytes", lba, size.value(), expected_size);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -568,26 +568,26 @@ bool CDImageDeviceWin32::DetermineReadMode(bool try_sptd)
|
||||
{
|
||||
std::optional<u32> transfer_size;
|
||||
|
||||
Log_DevPrint("Trying SCSI read with full subcode...");
|
||||
DEV_LOG("Trying SCSI read with full subcode...");
|
||||
if (check_subcode && (transfer_size = DoSCSIRead(track_1_lba, SCSIReadMode::Full)).has_value())
|
||||
{
|
||||
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), transfer_size.value()), SCSIReadMode::Full,
|
||||
track_1_subq_lba))
|
||||
{
|
||||
Log_VerbosePrint("Using SCSI reads with subcode");
|
||||
VERBOSE_LOG("Using SCSI reads with subcode");
|
||||
m_scsi_read_mode = SCSIReadMode::Full;
|
||||
m_has_valid_subcode = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Log_WarningPrint("Full subcode failed, trying SCSI read with only subq...");
|
||||
WARNING_LOG("Full subcode failed, trying SCSI read with only subq...");
|
||||
if (check_subcode && (transfer_size = DoSCSIRead(track_1_lba, SCSIReadMode::SubQOnly)).has_value())
|
||||
{
|
||||
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), transfer_size.value()), SCSIReadMode::SubQOnly,
|
||||
track_1_subq_lba))
|
||||
{
|
||||
Log_VerbosePrint("Using SCSI reads with subq only");
|
||||
VERBOSE_LOG("Using SCSI reads with subq only");
|
||||
m_scsi_read_mode = SCSIReadMode::SubQOnly;
|
||||
m_has_valid_subcode = true;
|
||||
return true;
|
||||
@@ -595,13 +595,13 @@ bool CDImageDeviceWin32::DetermineReadMode(bool try_sptd)
|
||||
}
|
||||
|
||||
// As a last ditch effort, try SCSI without subcode.
|
||||
Log_WarningPrint("Subq only failed failed, trying SCSI without subcode...");
|
||||
WARNING_LOG("Subq only failed failed, trying SCSI without subcode...");
|
||||
if ((transfer_size = DoSCSIRead(track_1_lba, SCSIReadMode::Raw)).has_value())
|
||||
{
|
||||
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), transfer_size.value()), SCSIReadMode::Raw,
|
||||
track_1_subq_lba))
|
||||
{
|
||||
Log_WarningPrint("Using SCSI raw reads, libcrypt games will not run correctly");
|
||||
WARNING_LOG("Using SCSI raw reads, libcrypt games will not run correctly");
|
||||
m_scsi_read_mode = SCSIReadMode::Raw;
|
||||
m_has_valid_subcode = false;
|
||||
return true;
|
||||
@@ -609,26 +609,26 @@ bool CDImageDeviceWin32::DetermineReadMode(bool try_sptd)
|
||||
}
|
||||
}
|
||||
|
||||
Log_WarningPrint("SCSI reads failed, trying raw read...");
|
||||
WARNING_LOG("SCSI reads failed, trying raw read...");
|
||||
if (DoRawRead(track_1_lba))
|
||||
{
|
||||
// verify subcode
|
||||
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), SCSIReadCommandOutputSize(SCSIReadMode::Full)),
|
||||
SCSIReadMode::Full, track_1_subq_lba))
|
||||
{
|
||||
Log_VerbosePrint("Using raw reads with full subcode");
|
||||
VERBOSE_LOG("Using raw reads with full subcode");
|
||||
m_scsi_read_mode = SCSIReadMode::None;
|
||||
m_has_valid_subcode = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
Log_WarningPrint("Using raw reads without subcode, libcrypt games will not run correctly");
|
||||
WARNING_LOG("Using raw reads without subcode, libcrypt games will not run correctly");
|
||||
m_scsi_read_mode = SCSIReadMode::None;
|
||||
m_has_valid_subcode = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
Log_ErrorPrint("No read modes were successful, cannot use device.");
|
||||
ERROR_LOG("No read modes were successful, cannot use device.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -751,7 +751,7 @@ bool CDImageDeviceLinux::Open(const char* filename, Error* error)
|
||||
// Set it to 4x speed. A good balance between readahead and spinning up way too high.
|
||||
const int read_speed = 4;
|
||||
if (!DoSetSpeed(read_speed) && ioctl(m_fd, CDROM_SELECT_SPEED, &read_speed) != 0)
|
||||
Log_WarningFmt("ioctl(CDROM_SELECT_SPEED) failed: {}", errno);
|
||||
WARNING_LOG("ioctl(CDROM_SELECT_SPEED) failed: {}", errno);
|
||||
|
||||
// Read ToC
|
||||
cdrom_tochdr toc_hdr = {};
|
||||
@@ -761,7 +761,7 @@ bool CDImageDeviceLinux::Open(const char* filename, Error* error)
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_DevFmt("FirstTrack={}, LastTrack={}", toc_hdr.cdth_trk0, toc_hdr.cdth_trk1);
|
||||
DEV_LOG("FirstTrack={}, LastTrack={}", toc_hdr.cdth_trk0, toc_hdr.cdth_trk1);
|
||||
if (toc_hdr.cdth_trk1 < toc_hdr.cdth_trk0)
|
||||
{
|
||||
Error::SetStringFmt(error, "Last track {} is before first track {}", toc_hdr.cdth_trk1, toc_hdr.cdth_trk0);
|
||||
@@ -785,14 +785,14 @@ bool CDImageDeviceLinux::Open(const char* filename, Error* error)
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_DevFmt(" [{}]: Num={}, LBA={}", track_index, track_num, toc_ent.cdte_addr.lba);
|
||||
DEV_LOG(" [{}]: Num={}, LBA={}", track_index, track_num, toc_ent.cdte_addr.lba);
|
||||
|
||||
// fill in the previous track's length
|
||||
if (!m_tracks.empty())
|
||||
{
|
||||
if (track_num < m_tracks.back().track_number)
|
||||
{
|
||||
Log_ErrorFmt("Invalid TOC, track {} less than {}", track_num, m_tracks.back().track_number);
|
||||
ERROR_LOG("Invalid TOC, track {} less than {}", track_num, m_tracks.back().track_number);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -855,7 +855,7 @@ bool CDImageDeviceLinux::Open(const char* filename, Error* error)
|
||||
|
||||
if (m_tracks.empty())
|
||||
{
|
||||
Log_ErrorFmt("File '{}' contains no tracks", filename);
|
||||
ERROR_LOG("File '{}' contains no tracks", filename);
|
||||
Error::SetString(error, fmt::format("File '{}' contains no tracks", filename));
|
||||
return false;
|
||||
}
|
||||
@@ -884,17 +884,17 @@ bool CDImageDeviceLinux::Open(const char* filename, Error* error)
|
||||
|
||||
m_lba_count = disc_lba;
|
||||
|
||||
Log_DevFmt("{} tracks, {} indices, {} lbas", m_tracks.size(), m_indices.size(), m_lba_count);
|
||||
DEV_LOG("{} tracks, {} indices, {} lbas", m_tracks.size(), m_indices.size(), m_lba_count);
|
||||
for (u32 i = 0; i < m_tracks.size(); i++)
|
||||
{
|
||||
Log_DevFmt(" Track {}: Start {}, length {}, mode {}, control 0x{:02X}", m_tracks[i].track_number,
|
||||
m_tracks[i].start_lba, m_tracks[i].length, static_cast<u8>(m_tracks[i].mode), m_tracks[i].control.bits);
|
||||
DEV_LOG(" Track {}: Start {}, length {}, mode {}, control 0x{:02X}", m_tracks[i].track_number,
|
||||
m_tracks[i].start_lba, m_tracks[i].length, static_cast<u8>(m_tracks[i].mode), m_tracks[i].control.bits);
|
||||
}
|
||||
for (u32 i = 0; i < m_indices.size(); i++)
|
||||
{
|
||||
Log_DevFmt(" Index {}: Track {}, Index [], Start {}, length {}, file sector size {}, file offset {}", i,
|
||||
m_indices[i].track_number, m_indices[i].index_number, m_indices[i].start_lba_on_disc,
|
||||
m_indices[i].length, m_indices[i].file_sector_size, m_indices[i].file_offset);
|
||||
DEV_LOG(" Index {}: Track {}, Index [], Start {}, length {}, file sector size {}, file offset {}", i,
|
||||
m_indices[i].track_number, m_indices[i].index_number, m_indices[i].start_lba_on_disc, m_indices[i].length,
|
||||
m_indices[i].file_sector_size, m_indices[i].file_offset);
|
||||
}
|
||||
|
||||
if (!DetermineReadMode(error))
|
||||
@@ -964,12 +964,12 @@ std::optional<u32> CDImageDeviceLinux::DoSCSICommand(u8 cmd[SCSI_CMD_LENGTH], st
|
||||
|
||||
if (ioctl(m_fd, SG_IO, &hdr) != 0)
|
||||
{
|
||||
Log_ErrorFmt("ioctl(SG_IO) for command {:02X} failed: {}", cmd[0], errno);
|
||||
ERROR_LOG("ioctl(SG_IO) for command {:02X} failed: {}", cmd[0], errno);
|
||||
return std::nullopt;
|
||||
}
|
||||
else if (hdr.status != 0)
|
||||
{
|
||||
Log_ErrorFmt("SCSI command {:02X} failed with status {}", cmd[0], hdr.status);
|
||||
ERROR_LOG("SCSI command {:02X} failed with status {}", cmd[0], hdr.status);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -998,7 +998,7 @@ bool CDImageDeviceLinux::DoRawRead(LBA lba)
|
||||
std::memcpy(m_buffer.data(), &msf, sizeof(msf));
|
||||
if (ioctl(m_fd, CDROMREADRAW, m_buffer.data()) != 0)
|
||||
{
|
||||
Log_ErrorFmt("CDROMREADRAW for LBA {} (MSF {}:{}:{}) failed: {}", lba, msf.minute, msf.second, msf.frame, errno);
|
||||
ERROR_LOG("CDROMREADRAW for LBA {} (MSF {}:{}:{}) failed: {}", lba, msf.minute, msf.second, msf.frame, errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1013,7 +1013,7 @@ bool CDImageDeviceLinux::ReadSectorToBuffer(LBA lba)
|
||||
const u32 expected_size = SCSIReadCommandOutputSize(m_scsi_read_mode);
|
||||
if (size.value_or(0) != expected_size)
|
||||
{
|
||||
Log_ErrorFmt("Read of LBA {} failed: only got {} of {} bytes", lba, size.value(), expected_size);
|
||||
ERROR_LOG("Read of LBA {} failed: only got {} of {} bytes", lba, size.value(), expected_size);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1034,50 +1034,50 @@ bool CDImageDeviceLinux::DetermineReadMode(Error* error)
|
||||
const bool check_subcode = ShouldTryReadingSubcode();
|
||||
std::optional<u32> transfer_size;
|
||||
|
||||
Log_DevPrint("Trying SCSI read with full subcode...");
|
||||
DEV_LOG("Trying SCSI read with full subcode...");
|
||||
if (check_subcode && (transfer_size = DoSCSIRead(track_1_lba, SCSIReadMode::Full)).has_value())
|
||||
{
|
||||
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), transfer_size.value()), SCSIReadMode::Full, track_1_subq_lba))
|
||||
{
|
||||
Log_VerbosePrint("Using SCSI reads with subcode");
|
||||
VERBOSE_LOG("Using SCSI reads with subcode");
|
||||
m_scsi_read_mode = SCSIReadMode::Full;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Log_WarningPrint("Full subcode failed, trying SCSI read with only subq...");
|
||||
WARNING_LOG("Full subcode failed, trying SCSI read with only subq...");
|
||||
if (check_subcode && (transfer_size = DoSCSIRead(track_1_lba, SCSIReadMode::SubQOnly)).has_value())
|
||||
{
|
||||
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), transfer_size.value()), SCSIReadMode::SubQOnly,
|
||||
track_1_subq_lba))
|
||||
{
|
||||
Log_VerbosePrint("Using SCSI reads with subq only");
|
||||
VERBOSE_LOG("Using SCSI reads with subq only");
|
||||
m_scsi_read_mode = SCSIReadMode::SubQOnly;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Log_WarningPrint("SCSI subcode reads failed, trying CDROMREADRAW...");
|
||||
WARNING_LOG("SCSI subcode reads failed, trying CDROMREADRAW...");
|
||||
if (DoRawRead(track_1_lba))
|
||||
{
|
||||
Log_WarningPrint("Using CDROMREADRAW, libcrypt games will not run correctly");
|
||||
WARNING_LOG("Using CDROMREADRAW, libcrypt games will not run correctly");
|
||||
m_scsi_read_mode = SCSIReadMode::None;
|
||||
return true;
|
||||
}
|
||||
|
||||
// As a last ditch effort, try SCSI without subcode.
|
||||
Log_WarningPrint("CDROMREADRAW failed, trying SCSI without subcode...");
|
||||
WARNING_LOG("CDROMREADRAW failed, trying SCSI without subcode...");
|
||||
if ((transfer_size = DoSCSIRead(track_1_lba, SCSIReadMode::Raw)).has_value())
|
||||
{
|
||||
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), transfer_size.value()), SCSIReadMode::Raw, track_1_subq_lba))
|
||||
{
|
||||
Log_WarningPrint("Using SCSI raw reads, libcrypt games will not run correctly");
|
||||
WARNING_LOG("Using SCSI raw reads, libcrypt games will not run correctly");
|
||||
m_scsi_read_mode = SCSIReadMode::Raw;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Log_ErrorPrint("No read modes were successful, cannot use device.");
|
||||
ERROR_LOG("No read modes were successful, cannot use device.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1200,7 +1200,7 @@ static io_service_t GetDeviceMediaService(std::string_view devname)
|
||||
kern_return_t ret = IOServiceGetMatchingServices(0, IOBSDNameMatching(0, 0, rdevname.c_str()), &iterator);
|
||||
if (ret != KERN_SUCCESS)
|
||||
{
|
||||
Log_ErrorFmt("IOServiceGetMatchingService() returned {}", ret);
|
||||
ERROR_LOG("IOServiceGetMatchingService() returned {}", ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1259,7 +1259,7 @@ bool CDImageDeviceMacOS::Open(const char* filename, Error* error)
|
||||
}
|
||||
|
||||
const u32 desc_count = CDTOCGetDescriptorCount(toc.get());
|
||||
Log_DevFmt("sessionFirst={}, sessionLast={}, count={}", toc->sessionFirst, toc->sessionLast, desc_count);
|
||||
DEV_LOG("sessionFirst={}, sessionLast={}, count={}", toc->sessionFirst, toc->sessionLast, desc_count);
|
||||
if (toc->sessionLast < toc->sessionFirst)
|
||||
{
|
||||
Error::SetStringFmt(error, "Last track {} is before first track {}", toc->sessionLast, toc->sessionFirst);
|
||||
@@ -1273,8 +1273,8 @@ bool CDImageDeviceMacOS::Open(const char* filename, Error* error)
|
||||
for (u32 i = 0; i < desc_count; i++)
|
||||
{
|
||||
const CDTOCDescriptor& desc = toc->descriptors[i];
|
||||
Log_DevFmt(" [{}]: Num={}, Point=0x{:02X} ADR={} MSF={}:{}:{}", i, desc.tno, desc.point, desc.adr, desc.p.minute,
|
||||
desc.p.second, desc.p.frame);
|
||||
DEV_LOG(" [{}]: Num={}, Point=0x{:02X} ADR={} MSF={}:{}:{}", i, desc.tno, desc.point, desc.adr, desc.p.minute,
|
||||
desc.p.second, desc.p.frame);
|
||||
|
||||
// Why does MacOS use 0xA2 instead of 0xAA for leadout??
|
||||
if (desc.point == 0xA2)
|
||||
@@ -1374,7 +1374,7 @@ bool CDImageDeviceMacOS::Open(const char* filename, Error* error)
|
||||
|
||||
if (m_tracks.empty())
|
||||
{
|
||||
Log_ErrorFmt("File '{}' contains no tracks", filename);
|
||||
ERROR_LOG("File '{}' contains no tracks", filename);
|
||||
Error::SetString(error, fmt::format("File '{}' contains no tracks", filename));
|
||||
return false;
|
||||
}
|
||||
@@ -1392,17 +1392,17 @@ bool CDImageDeviceMacOS::Open(const char* filename, Error* error)
|
||||
|
||||
m_lba_count = disc_lba;
|
||||
|
||||
Log_DevFmt("{} tracks, {} indices, {} lbas", m_tracks.size(), m_indices.size(), m_lba_count);
|
||||
DEV_LOG("{} tracks, {} indices, {} lbas", m_tracks.size(), m_indices.size(), m_lba_count);
|
||||
for (u32 i = 0; i < m_tracks.size(); i++)
|
||||
{
|
||||
Log_DevFmt(" Track {}: Start {}, length {}, mode {}, control 0x{:02X}", m_tracks[i].track_number,
|
||||
m_tracks[i].start_lba, m_tracks[i].length, static_cast<u8>(m_tracks[i].mode), m_tracks[i].control.bits);
|
||||
DEV_LOG(" Track {}: Start {}, length {}, mode {}, control 0x{:02X}", m_tracks[i].track_number,
|
||||
m_tracks[i].start_lba, m_tracks[i].length, static_cast<u8>(m_tracks[i].mode), m_tracks[i].control.bits);
|
||||
}
|
||||
for (u32 i = 0; i < m_indices.size(); i++)
|
||||
{
|
||||
Log_DevFmt(" Index {}: Track {}, Index [], Start {}, length {}, file sector size {}, file offset {}", i,
|
||||
m_indices[i].track_number, m_indices[i].index_number, m_indices[i].start_lba_on_disc,
|
||||
m_indices[i].length, m_indices[i].file_sector_size, m_indices[i].file_offset);
|
||||
DEV_LOG(" Index {}: Track {}, Index [], Start {}, length {}, file sector size {}, file offset {}", i,
|
||||
m_indices[i].track_number, m_indices[i].index_number, m_indices[i].start_lba_on_disc, m_indices[i].length,
|
||||
m_indices[i].file_sector_size, m_indices[i].file_offset);
|
||||
}
|
||||
|
||||
if (!DetermineReadMode(error))
|
||||
@@ -1462,7 +1462,7 @@ bool CDImageDeviceMacOS::DoSetSpeed(u32 speed_multiplier)
|
||||
const u16 speed = static_cast<u16>((FRAMES_PER_SECOND * RAW_SECTOR_SIZE * speed_multiplier) / 1024);
|
||||
if (ioctl(m_fd, DKIOCCDSETSPEED, &speed) != 0)
|
||||
{
|
||||
Log_ErrorFmt("DKIOCCDSETSPEED for speed {} failed: {}", speed, errno);
|
||||
ERROR_LOG("DKIOCCDSETSPEED for speed {} failed: {}", speed, errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1473,7 +1473,7 @@ bool CDImageDeviceMacOS::ReadSectorToBuffer(LBA lba)
|
||||
{
|
||||
if (lba < RAW_READ_OFFSET)
|
||||
{
|
||||
Log_ErrorFmt("Out of bounds LBA {}", lba);
|
||||
ERROR_LOG("Out of bounds LBA {}", lba);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1493,7 +1493,7 @@ bool CDImageDeviceMacOS::ReadSectorToBuffer(LBA lba)
|
||||
if (ioctl(m_fd, DKIOCCDREAD, &desc) != 0)
|
||||
{
|
||||
const Position msf = Position::FromLBA(lba);
|
||||
Log_ErrorFmt("DKIOCCDREAD for LBA {} (MSF {}:{}:{}) failed: {}", lba, msf.minute, msf.second, msf.frame, errno);
|
||||
ERROR_LOG("DKIOCCDREAD for LBA {} (MSF {}:{}:{}) failed: {}", lba, msf.minute, msf.second, msf.frame, errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1506,7 +1506,7 @@ bool CDImageDeviceMacOS::DetermineReadMode(Error* error)
|
||||
const LBA track_1_lba = static_cast<LBA>(m_indices[m_tracks[0].first_index].file_offset);
|
||||
const bool check_subcode = ShouldTryReadingSubcode();
|
||||
|
||||
Log_DevPrint("Trying read with full subcode...");
|
||||
DEV_LOG("Trying read with full subcode...");
|
||||
m_read_mode = SCSIReadMode::Full;
|
||||
m_current_lba = m_lba_count;
|
||||
if (check_subcode && ReadSectorToBuffer(track_1_lba))
|
||||
@@ -1514,7 +1514,7 @@ bool CDImageDeviceMacOS::DetermineReadMode(Error* error)
|
||||
if (VerifySCSIReadData(std::span<u8>(m_buffer.data(), RAW_SECTOR_SIZE + ALL_SUBCODE_SIZE), SCSIReadMode::Full,
|
||||
track_1_lba))
|
||||
{
|
||||
Log_VerbosePrint("Using reads with subcode");
|
||||
VERBOSE_LOG("Using reads with subcode");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1535,16 +1535,16 @@ bool CDImageDeviceMacOS::DetermineReadMode(Error* error)
|
||||
}
|
||||
#endif
|
||||
|
||||
Log_WarningPrint("SCSI reads failed, trying without subcode...");
|
||||
WARNING_LOG("SCSI reads failed, trying without subcode...");
|
||||
m_read_mode = SCSIReadMode::Raw;
|
||||
m_current_lba = m_lba_count;
|
||||
if (ReadSectorToBuffer(track_1_lba))
|
||||
{
|
||||
Log_WarningPrint("Using non-subcode reads, libcrypt games will not run correctly");
|
||||
WARNING_LOG("Using non-subcode reads, libcrypt games will not run correctly");
|
||||
return true;
|
||||
}
|
||||
|
||||
Log_ErrorPrint("No read modes were successful, cannot use device.");
|
||||
ERROR_LOG("No read modes were successful, cannot use device.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -246,7 +246,7 @@ bool CDImageEcm::Open(const char* filename, Error* error)
|
||||
if (FileSystem::FSeek64(m_fp, 0, SEEK_END) != 0 || (file_size = FileSystem::FTell64(m_fp)) <= 0 ||
|
||||
FileSystem::FSeek64(m_fp, 0, SEEK_SET) != 0)
|
||||
{
|
||||
Log_ErrorFmt("Get file size failed: errno {}", errno);
|
||||
ERROR_LOG("Get file size failed: errno {}", errno);
|
||||
if (error)
|
||||
error->SetErrno(errno);
|
||||
|
||||
@@ -257,7 +257,7 @@ bool CDImageEcm::Open(const char* filename, Error* error)
|
||||
if (std::fread(header, sizeof(header), 1, m_fp) != 1 || header[0] != 'E' || header[1] != 'C' || header[2] != 'M' ||
|
||||
header[3] != 0)
|
||||
{
|
||||
Log_ErrorPrint("Failed to read/invalid header");
|
||||
ERROR_LOG("Failed to read/invalid header");
|
||||
Error::SetStringView(error, "Failed to read/invalid header");
|
||||
return false;
|
||||
}
|
||||
@@ -271,7 +271,7 @@ bool CDImageEcm::Open(const char* filename, Error* error)
|
||||
int bits = std::fgetc(m_fp);
|
||||
if (bits == EOF)
|
||||
{
|
||||
Log_ErrorFmt("Unexpected EOF after {} chunks", m_data_map.size());
|
||||
ERROR_LOG("Unexpected EOF after {} chunks", m_data_map.size());
|
||||
Error::SetStringFmt(error, "Unexpected EOF after {} chunks", m_data_map.size());
|
||||
return false;
|
||||
}
|
||||
@@ -285,7 +285,7 @@ bool CDImageEcm::Open(const char* filename, Error* error)
|
||||
bits = std::fgetc(m_fp);
|
||||
if (bits == EOF)
|
||||
{
|
||||
Log_ErrorFmt("Unexpected EOF after {} chunks", m_data_map.size());
|
||||
ERROR_LOG("Unexpected EOF after {} chunks", m_data_map.size());
|
||||
Error::SetStringFmt(error, "Unexpected EOF after {} chunks", m_data_map.size());
|
||||
return false;
|
||||
}
|
||||
@@ -303,7 +303,7 @@ bool CDImageEcm::Open(const char* filename, Error* error)
|
||||
|
||||
if (count >= 0x80000000u)
|
||||
{
|
||||
Log_ErrorFmt("Corrupted header after {} chunks", m_data_map.size());
|
||||
ERROR_LOG("Corrupted header after {} chunks", m_data_map.size());
|
||||
Error::SetStringFmt(error, "Corrupted header after {} chunks", m_data_map.size());
|
||||
return false;
|
||||
}
|
||||
@@ -320,7 +320,7 @@ bool CDImageEcm::Open(const char* filename, Error* error)
|
||||
|
||||
if (static_cast<s64>(file_offset) > file_size)
|
||||
{
|
||||
Log_ErrorFmt("Out of file bounds after {} chunks", m_data_map.size());
|
||||
ERROR_LOG("Out of file bounds after {} chunks", m_data_map.size());
|
||||
Error::SetStringFmt(error, "Out of file bounds after {} chunks", m_data_map.size());
|
||||
}
|
||||
}
|
||||
@@ -337,7 +337,7 @@ bool CDImageEcm::Open(const char* filename, Error* error)
|
||||
|
||||
if (static_cast<s64>(file_offset) > file_size)
|
||||
{
|
||||
Log_ErrorFmt("Out of file bounds after {} chunks", m_data_map.size());
|
||||
ERROR_LOG("Out of file bounds after {} chunks", m_data_map.size());
|
||||
Error::SetStringFmt(error, "Out of file bounds after {} chunks", m_data_map.size());
|
||||
}
|
||||
}
|
||||
@@ -345,7 +345,7 @@ bool CDImageEcm::Open(const char* filename, Error* error)
|
||||
|
||||
if (std::fseek(m_fp, file_offset, SEEK_SET) != 0)
|
||||
{
|
||||
Log_ErrorFmt("Failed to seek to offset {} after {} chunks", file_offset, m_data_map.size());
|
||||
ERROR_LOG("Failed to seek to offset {} after {} chunks", file_offset, m_data_map.size());
|
||||
Error::SetStringFmt(error, "Failed to seek to offset {} after {} chunks", file_offset, m_data_map.size());
|
||||
return false;
|
||||
}
|
||||
@@ -353,14 +353,14 @@ bool CDImageEcm::Open(const char* filename, Error* error)
|
||||
|
||||
if (m_data_map.empty())
|
||||
{
|
||||
Log_ErrorFmt("No data in image '{}'", filename);
|
||||
ERROR_LOG("No data in image '{}'", filename);
|
||||
Error::SetStringFmt(error, "No data in image '{}'", filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_lba_count = disc_offset / RAW_SECTOR_SIZE;
|
||||
if ((disc_offset % RAW_SECTOR_SIZE) != 0)
|
||||
Log_WarningFmt("ECM image is misaligned with offset {}", disc_offset);
|
||||
WARNING_LOG("ECM image is misaligned with offset {}", disc_offset);
|
||||
if (m_lba_count == 0)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -107,11 +107,11 @@ bool CDImageM3u::Open(const char* path, bool apply_patches, Error* error)
|
||||
else
|
||||
entry.filename = std::move(entry_filename);
|
||||
|
||||
Log_DevFmt("Read path from m3u: '{}'", entry.filename);
|
||||
DEV_LOG("Read path from m3u: '{}'", entry.filename);
|
||||
m_entries.push_back(std::move(entry));
|
||||
}
|
||||
|
||||
Log_InfoFmt("Loaded {} paths from m3u '{}'", m_entries.size(), path);
|
||||
INFO_LOG("Loaded {} paths from m3u '{}'", m_entries.size(), path);
|
||||
return !m_entries.empty() && SwitchSubImage(0, error);
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ bool CDImageM3u::SwitchSubImage(u32 index, Error* error)
|
||||
std::unique_ptr<CDImage> new_image = CDImage::Open(entry.filename.c_str(), m_apply_patches, error);
|
||||
if (!new_image)
|
||||
{
|
||||
Log_ErrorFmt("Failed to load subimage {} ({})", index, entry.filename);
|
||||
ERROR_LOG("Failed to load subimage {} ({})", index, entry.filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ bool CDImageMds::OpenAndParse(const char* filename, Error* error)
|
||||
std::fclose(mds_fp);
|
||||
if (!mds_data_opt.has_value() || mds_data_opt->size() < 0x54)
|
||||
{
|
||||
Log_ErrorFmt("Failed to read mds file '{}'", Path::GetFileName(filename));
|
||||
ERROR_LOG("Failed to read mds file '{}'", Path::GetFileName(filename));
|
||||
Error::SetStringFmt(error, "Failed to read mds file '{}'", filename);
|
||||
return false;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ bool CDImageMds::OpenAndParse(const char* filename, Error* error)
|
||||
static constexpr char expected_signature[] = "MEDIA DESCRIPTOR";
|
||||
if (std::memcmp(&mds[0], expected_signature, sizeof(expected_signature) - 1) != 0)
|
||||
{
|
||||
Log_ErrorFmt("Incorrect signature in '{}'", Path::GetFileName(filename));
|
||||
ERROR_LOG("Incorrect signature in '{}'", Path::GetFileName(filename));
|
||||
Error::SetStringFmt(error, "Incorrect signature in '{}'", Path::GetFileName(filename));
|
||||
return false;
|
||||
}
|
||||
@@ -108,7 +108,7 @@ bool CDImageMds::OpenAndParse(const char* filename, Error* error)
|
||||
std::memcpy(&session_offset, &mds[0x50], sizeof(session_offset));
|
||||
if ((session_offset + 24) > mds.size())
|
||||
{
|
||||
Log_ErrorFmt("Invalid session offset in '{}'", Path::GetFileName(filename));
|
||||
ERROR_LOG("Invalid session offset in '{}'", Path::GetFileName(filename));
|
||||
Error::SetStringFmt(error, "Invalid session offset in '{}'", Path::GetFileName(filename));
|
||||
return false;
|
||||
}
|
||||
@@ -119,7 +119,7 @@ bool CDImageMds::OpenAndParse(const char* filename, Error* error)
|
||||
std::memcpy(&track_offset, &mds[session_offset + 20], sizeof(track_offset));
|
||||
if (track_count > 99 || track_offset >= mds.size())
|
||||
{
|
||||
Log_ErrorFmt("Invalid track count/block offset {}/{} in '{}'", track_count, track_offset, Path::GetFileName(filename));
|
||||
ERROR_LOG("Invalid track count/block offset {}/{} in '{}'", track_count, track_offset, Path::GetFileName(filename));
|
||||
Error::SetStringFmt(error, "Invalid track count/block offset {}/{} in '{}'", track_count, track_offset,
|
||||
Path::GetFileName(filename));
|
||||
return false;
|
||||
@@ -139,7 +139,7 @@ bool CDImageMds::OpenAndParse(const char* filename, Error* error)
|
||||
{
|
||||
if ((track_offset + sizeof(TrackEntry)) > mds.size())
|
||||
{
|
||||
Log_ErrorFmt("End of file in '{}' at track {}", Path::GetFileName(filename), track_number);
|
||||
ERROR_LOG("End of file in '{}' at track {}", Path::GetFileName(filename), track_number);
|
||||
Error::SetStringFmt(error, "End of file in '{}' at track {}", Path::GetFileName(filename), track_number);
|
||||
return false;
|
||||
}
|
||||
@@ -150,7 +150,7 @@ bool CDImageMds::OpenAndParse(const char* filename, Error* error)
|
||||
|
||||
if (PackedBCDToBinary(track.track_number) != track_number)
|
||||
{
|
||||
Log_ErrorFmt("Unexpected track number 0x{:02X} in track {}", track.track_number, track_number);
|
||||
ERROR_LOG("Unexpected track number 0x{:02X} in track {}", track.track_number, track_number);
|
||||
Error::SetStringFmt(error, "Unexpected track number 0x{:02X} in track {}", track.track_number, track_number);
|
||||
return false;
|
||||
}
|
||||
@@ -161,7 +161,7 @@ bool CDImageMds::OpenAndParse(const char* filename, Error* error)
|
||||
|
||||
if ((track.extra_offset + sizeof(u32) + sizeof(u32)) > mds.size())
|
||||
{
|
||||
Log_ErrorFmt("Invalid extra offset {} in track {}", track.extra_offset, track_number);
|
||||
ERROR_LOG("Invalid extra offset {} in track {}", track.extra_offset, track_number);
|
||||
Error::SetStringFmt(error, "Invalid extra offset {} in track {}", track.extra_offset, track_number);
|
||||
return false;
|
||||
}
|
||||
@@ -184,7 +184,7 @@ bool CDImageMds::OpenAndParse(const char* filename, Error* error)
|
||||
{
|
||||
if (track_pregap > track_start_lba)
|
||||
{
|
||||
Log_ErrorFmt("Track pregap {} is too large for start lba {}", track_pregap, track_start_lba);
|
||||
ERROR_LOG("Track pregap {} is too large for start lba {}", track_pregap, track_start_lba);
|
||||
Error::SetStringFmt(error, "Track pregap {} is too large for start lba {}", track_pregap, track_start_lba);
|
||||
return false;
|
||||
}
|
||||
@@ -235,7 +235,7 @@ bool CDImageMds::OpenAndParse(const char* filename, Error* error)
|
||||
|
||||
if (m_tracks.empty())
|
||||
{
|
||||
Log_ErrorFmt("File '{}' contains no tracks", Path::GetFileName(filename));
|
||||
ERROR_LOG("File '{}' contains no tracks", Path::GetFileName(filename));
|
||||
Error::SetStringFmt(error, "File '{}' contains no tracks", Path::GetFileName(filename));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ bool CDImageMemory::CopyImage(CDImage* image, ProgressCallback* progress)
|
||||
{
|
||||
if (!image->ReadSectorFromIndex(memory_ptr, index, lba))
|
||||
{
|
||||
Log_ErrorFmt("Failed to read LBA {} in index {}", lba, i);
|
||||
ERROR_LOG("Failed to read LBA {} in index {}", lba, i);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+36
-37
@@ -225,13 +225,13 @@ bool CDImagePBP::LoadPBPHeader()
|
||||
|
||||
if (std::fread(&m_pbp_header, sizeof(PBPHeader), 1, m_file) != 1)
|
||||
{
|
||||
Log_ErrorPrint("Unable to read PBP header");
|
||||
ERROR_LOG("Unable to read PBP header");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (std::strncmp((char*)m_pbp_header.magic, "\0PBP", 4) != 0)
|
||||
{
|
||||
Log_ErrorPrint("PBP magic number mismatch");
|
||||
ERROR_LOG("PBP magic number mismatch");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -252,7 +252,7 @@ bool CDImagePBP::LoadSFOHeader()
|
||||
|
||||
if (std::strncmp((char*)m_sfo_header.magic, "\0PSF", 4) != 0)
|
||||
{
|
||||
Log_ErrorPrint("SFO magic number mismatch");
|
||||
ERROR_LOG("SFO magic number mismatch");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -298,7 +298,7 @@ bool CDImagePBP::LoadSFOTable()
|
||||
|
||||
if (FileSystem::FSeek64(m_file, abs_key_offset, SEEK_SET) != 0)
|
||||
{
|
||||
Log_ErrorFmt("Failed seek to key for SFO table entry {}", i);
|
||||
ERROR_LOG("Failed seek to key for SFO table entry {}", i);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -306,19 +306,19 @@ bool CDImagePBP::LoadSFOTable()
|
||||
char key_cstr[20] = {};
|
||||
if (std::fgets(key_cstr, sizeof(key_cstr), m_file) == nullptr)
|
||||
{
|
||||
Log_ErrorFmt("Failed to read key string for SFO table entry {}", i);
|
||||
ERROR_LOG("Failed to read key string for SFO table entry {}", i);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (FileSystem::FSeek64(m_file, abs_data_offset, SEEK_SET) != 0)
|
||||
{
|
||||
Log_ErrorFmt("Failed seek to data for SFO table entry {}", i);
|
||||
ERROR_LOG("Failed seek to data for SFO table entry {}", i);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_sfo_index_table[i].data_type == 0x0004) // "special mode" UTF-8 (not null terminated)
|
||||
{
|
||||
Log_ErrorFmt("Unhandled special mode UTF-8 type found in SFO table for entry {}", i);
|
||||
ERROR_LOG("Unhandled special mode UTF-8 type found in SFO table for entry {}", i);
|
||||
return false;
|
||||
}
|
||||
else if (m_sfo_index_table[i].data_type == 0x0204) // null-terminated UTF-8 character string
|
||||
@@ -326,7 +326,7 @@ bool CDImagePBP::LoadSFOTable()
|
||||
std::vector<char> data_cstr(m_sfo_index_table[i].data_size);
|
||||
if (fgets(data_cstr.data(), static_cast<int>(data_cstr.size() * sizeof(char)), m_file) == nullptr)
|
||||
{
|
||||
Log_ErrorFmt("Failed to read data string for SFO table entry {}", i);
|
||||
ERROR_LOG("Failed to read data string for SFO table entry {}", i);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ bool CDImagePBP::LoadSFOTable()
|
||||
u32 val;
|
||||
if (std::fread(&val, sizeof(u32), 1, m_file) != 1)
|
||||
{
|
||||
Log_ErrorFmt("Failed to read unsigned data value for SFO table entry {}", i);
|
||||
ERROR_LOG("Failed to read unsigned data value for SFO table entry {}", i);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -345,8 +345,7 @@ bool CDImagePBP::LoadSFOTable()
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorFmt("Unhandled SFO data type 0x{:04X} found in SFO table for entry {}", m_sfo_index_table[i].data_type,
|
||||
i);
|
||||
ERROR_LOG("Unhandled SFO data type 0x{:04X} found in SFO table for entry {}", m_sfo_index_table[i].data_type, i);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -368,14 +367,14 @@ bool CDImagePBP::IsValidEboot(Error* error)
|
||||
SFOTableDataValue data_value = a_it->second;
|
||||
if (!std::holds_alternative<u32>(data_value) || std::get<u32>(data_value) != 1)
|
||||
{
|
||||
Log_ErrorPrint("Invalid BOOTABLE value");
|
||||
ERROR_LOG("Invalid BOOTABLE value");
|
||||
Error::SetString(error, "Invalid BOOTABLE value");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorPrint("No BOOTABLE value found");
|
||||
ERROR_LOG("No BOOTABLE value found");
|
||||
Error::SetString(error, "No BOOTABLE value found");
|
||||
return false;
|
||||
}
|
||||
@@ -386,14 +385,14 @@ bool CDImagePBP::IsValidEboot(Error* error)
|
||||
SFOTableDataValue data_value = a_it->second;
|
||||
if (!std::holds_alternative<std::string>(data_value) || std::get<std::string>(data_value) != "ME")
|
||||
{
|
||||
Log_ErrorPrint("Invalid CATEGORY value");
|
||||
ERROR_LOG("Invalid CATEGORY value");
|
||||
Error::SetString(error, "Invalid CATEGORY value");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorPrint("No CATEGORY value found");
|
||||
ERROR_LOG("No CATEGORY value found");
|
||||
Error::SetString(error, "No CATEGORY value found");
|
||||
return false;
|
||||
}
|
||||
@@ -415,7 +414,7 @@ bool CDImagePBP::Open(const char* filename, Error* error)
|
||||
// Read in PBP header
|
||||
if (!LoadPBPHeader())
|
||||
{
|
||||
Log_ErrorPrint("Failed to load PBP header");
|
||||
ERROR_LOG("Failed to load PBP header");
|
||||
Error::SetString(error, "Failed to load PBP header");
|
||||
return false;
|
||||
}
|
||||
@@ -423,7 +422,7 @@ bool CDImagePBP::Open(const char* filename, Error* error)
|
||||
// Read in SFO header
|
||||
if (!LoadSFOHeader())
|
||||
{
|
||||
Log_ErrorPrint("Failed to load SFO header");
|
||||
ERROR_LOG("Failed to load SFO header");
|
||||
Error::SetString(error, "Failed to load SFO header");
|
||||
return false;
|
||||
}
|
||||
@@ -431,7 +430,7 @@ bool CDImagePBP::Open(const char* filename, Error* error)
|
||||
// Read in SFO index table
|
||||
if (!LoadSFOIndexTable())
|
||||
{
|
||||
Log_ErrorPrint("Failed to load SFO index table");
|
||||
ERROR_LOG("Failed to load SFO index table");
|
||||
Error::SetString(error, "Failed to load SFO index table");
|
||||
return false;
|
||||
}
|
||||
@@ -439,7 +438,7 @@ bool CDImagePBP::Open(const char* filename, Error* error)
|
||||
// Read in SFO table
|
||||
if (!LoadSFOTable())
|
||||
{
|
||||
Log_ErrorPrint("Failed to load SFO table");
|
||||
ERROR_LOG("Failed to load SFO table");
|
||||
Error::SetString(error, "Failed to load SFO table");
|
||||
return false;
|
||||
}
|
||||
@@ -447,7 +446,7 @@ bool CDImagePBP::Open(const char* filename, Error* error)
|
||||
// Since PBP files can store things that aren't PS1 CD images, make sure we're loading the right kind
|
||||
if (!IsValidEboot(error))
|
||||
{
|
||||
Log_ErrorPrint("Couldn't validate EBOOT");
|
||||
ERROR_LOG("Couldn't validate EBOOT");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -476,7 +475,7 @@ bool CDImagePBP::Open(const char* filename, Error* error)
|
||||
// Ignore encrypted files
|
||||
if (disc_table[0] == 0x44475000) // "\0PGD"
|
||||
{
|
||||
Log_ErrorFmt("Encrypted PBP images are not supported, skipping %s", m_filename);
|
||||
ERROR_LOG("Encrypted PBP images are not supported, skipping %s", m_filename);
|
||||
Error::SetString(error, "Encrypted PBP images are not supported");
|
||||
return false;
|
||||
}
|
||||
@@ -492,7 +491,7 @@ bool CDImagePBP::Open(const char* filename, Error* error)
|
||||
|
||||
if (m_disc_offsets.size() < 1)
|
||||
{
|
||||
Log_ErrorFmt("Invalid number of discs ({}) in multi-disc PBP file", m_disc_offsets.size());
|
||||
ERROR_LOG("Invalid number of discs ({}) in multi-disc PBP file", m_disc_offsets.size());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -509,7 +508,7 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||
{
|
||||
if (index >= m_disc_offsets.size())
|
||||
{
|
||||
Log_ErrorFmt("File does not contain disc {}", index + 1);
|
||||
ERROR_LOG("File does not contain disc {}", index + 1);
|
||||
Error::SetString(error, fmt::format("File does not contain disc {}", index + 1));
|
||||
return false;
|
||||
}
|
||||
@@ -531,7 +530,7 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||
|
||||
if (std::strncmp(iso_header_magic, "PSISOIMG0000", 12) != 0)
|
||||
{
|
||||
Log_ErrorPrint("ISO header magic number mismatch");
|
||||
ERROR_LOG("ISO header magic number mismatch");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -545,7 +544,7 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||
|
||||
if (pgd_magic == 0x44475000) // "\0PGD"
|
||||
{
|
||||
Log_ErrorFmt("Encrypted PBP images are not supported, skipping {}", m_filename);
|
||||
ERROR_LOG("Encrypted PBP images are not supported, skipping {}", m_filename);
|
||||
Error::SetString(error, "Encrypted PBP images are not supported");
|
||||
return false;
|
||||
}
|
||||
@@ -594,7 +593,7 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||
// valid. Not sure what m_toc[0].userdata_start.s encodes on homebrew EBOOTs though, so ignore that
|
||||
if (m_toc[0].point != 0xA0 || m_toc[1].point != 0xA1 || m_toc[2].point != 0xA2)
|
||||
{
|
||||
Log_ErrorPrint("Invalid points on information tracks");
|
||||
ERROR_LOG("Invalid points on information tracks");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -605,7 +604,7 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||
|
||||
if (first_track != 1 || last_track < first_track)
|
||||
{
|
||||
Log_ErrorPrint("Invalid starting track number or track count");
|
||||
ERROR_LOG("Invalid starting track number or track count");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -623,7 +622,7 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||
const TOCEntry& t = m_toc[static_cast<size_t>(curr_track) + 2];
|
||||
const u8 track_num = PackedBCDToBinary(t.point);
|
||||
if (track_num != curr_track)
|
||||
Log_WarningFmt("Mismatched TOC track number, expected {} but got {}", curr_track, track_num);
|
||||
WARNING_LOG("Mismatched TOC track number, expected {} but got {}", curr_track, track_num);
|
||||
|
||||
const bool is_audio_track = t.type == 0x01;
|
||||
const bool is_first_track = curr_track == 1;
|
||||
@@ -643,12 +642,12 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||
{
|
||||
if (!is_first_track || is_audio_track)
|
||||
{
|
||||
Log_ErrorFmt("Invalid TOC entry at index {}, user data ({}) should not start before pregap ({})", curr_track,
|
||||
userdata_start, pregap_start);
|
||||
ERROR_LOG("Invalid TOC entry at index {}, user data ({}) should not start before pregap ({})", curr_track,
|
||||
userdata_start, pregap_start);
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_WarningFmt(
|
||||
WARNING_LOG(
|
||||
"Invalid TOC entry at index {}, user data ({}) should not start before pregap ({}), assuming not in file.",
|
||||
curr_track, userdata_start, pregap_start);
|
||||
pregap_start = 0;
|
||||
@@ -701,7 +700,7 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||
{
|
||||
if (userdata_start >= m_lba_count)
|
||||
{
|
||||
Log_ErrorFmt("Last user data index on disc for TOC entry {} should not be 0 or less in length", curr_track);
|
||||
ERROR_LOG("Last user data index on disc for TOC entry {} should not be 0 or less in length", curr_track);
|
||||
return false;
|
||||
}
|
||||
userdata_index.length = m_lba_count - userdata_start;
|
||||
@@ -715,7 +714,7 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||
|
||||
if (next_track_num != curr_track + 1 || next_track_start < userdata_start)
|
||||
{
|
||||
Log_ErrorFmt("Unable to calculate user data index length for TOC entry {}", curr_track);
|
||||
ERROR_LOG("Unable to calculate user data index length for TOC entry {}", curr_track);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -734,7 +733,7 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||
// Initialize zlib stream
|
||||
if (!InitDecompressionStream())
|
||||
{
|
||||
Log_ErrorPrint("Failed to initialize zlib decompression stream");
|
||||
ERROR_LOG("Failed to initialize zlib decompression stream");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -810,7 +809,7 @@ bool CDImagePBP::DecompressBlock(const BlockInfo& block_info)
|
||||
int err = inflate(&m_inflate_stream, Z_FINISH);
|
||||
if (err != Z_STREAM_END) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Inflate error {}", err);
|
||||
ERROR_LOG("Inflate error {}", err);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -840,13 +839,13 @@ bool CDImagePBP::ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_i
|
||||
|
||||
if (bi.size == 0) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Invalid block {} requested", requested_block);
|
||||
ERROR_LOG("Invalid block {} requested", requested_block);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_current_block != requested_block && !DecompressBlock(bi)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Failed to decompress block {}", requested_block);
|
||||
ERROR_LOG("Failed to decompress block {}", requested_block);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+35
-35
@@ -69,7 +69,7 @@ bool CDImagePPF::Open(const char* filename, std::unique_ptr<CDImage> parent_imag
|
||||
auto fp = FileSystem::OpenManagedSharedCFile(filename, "rb", FileSystem::FileShareMode::DenyWrite);
|
||||
if (!fp)
|
||||
{
|
||||
Log_ErrorFmt("Failed to open '%s'", filename);
|
||||
ERROR_LOG("Failed to open '%s'", filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ bool CDImagePPF::Open(const char* filename, std::unique_ptr<CDImage> parent_imag
|
||||
u32 magic;
|
||||
if (std::fread(&magic, sizeof(magic), 1, fp.get()) != 1)
|
||||
{
|
||||
Log_ErrorFmt("Failed to read magic from '%s'", filename);
|
||||
ERROR_LOG("Failed to read magic from '%s'", filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ bool CDImagePPF::Open(const char* filename, std::unique_ptr<CDImage> parent_imag
|
||||
else if (magic == 0x31465050) // PPF1
|
||||
return ReadV1Patch(fp.get());
|
||||
|
||||
Log_ErrorFmt("Unknown PPF magic {:08X}", magic);
|
||||
ERROR_LOG("Unknown PPF magic {:08X}", magic);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ u32 CDImagePPF::ReadFileIDDiz(std::FILE* fp, u32 version)
|
||||
u32 magic;
|
||||
if (std::fseek(fp, -(lenidx + 4), SEEK_END) != 0 || std::fread(&magic, sizeof(magic), 1, fp) != 1) [[unlikely]]
|
||||
{
|
||||
Log_WarningPrint("Failed to read diz magic");
|
||||
WARNING_LOG("Failed to read diz magic");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -121,13 +121,13 @@ u32 CDImagePPF::ReadFileIDDiz(std::FILE* fp, u32 version)
|
||||
u32 dlen = 0;
|
||||
if (std::fseek(fp, -lenidx, SEEK_END) != 0 || std::fread(&dlen, lenidx, 1, fp) != 1) [[unlikely]]
|
||||
{
|
||||
Log_WarningPrint("Failed to read diz length");
|
||||
WARNING_LOG("Failed to read diz length");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (dlen > static_cast<u32>(std::ftell(fp))) [[unlikely]]
|
||||
{
|
||||
Log_WarningPrint("diz length out of range");
|
||||
WARNING_LOG("diz length out of range");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -136,11 +136,11 @@ u32 CDImagePPF::ReadFileIDDiz(std::FILE* fp, u32 version)
|
||||
if (std::fseek(fp, -(lenidx + 16 + static_cast<int>(dlen)), SEEK_END) != 0 ||
|
||||
std::fread(fdiz.data(), 1, dlen, fp) != dlen) [[unlikely]]
|
||||
{
|
||||
Log_WarningPrint("Failed to read fdiz");
|
||||
WARNING_LOG("Failed to read fdiz");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Log_InfoFmt("File_Id.diz: %s", fdiz);
|
||||
INFO_LOG("File_Id.diz: %s", fdiz);
|
||||
return dlen;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ bool CDImagePPF::ReadV1Patch(std::FILE* fp)
|
||||
char desc[DESC_SIZE + 1] = {};
|
||||
if (std::fseek(fp, 6, SEEK_SET) != 0 || std::fread(desc, sizeof(char), DESC_SIZE, fp) != DESC_SIZE) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrint("Failed to read description");
|
||||
ERROR_LOG("Failed to read description");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ bool CDImagePPF::ReadV1Patch(std::FILE* fp)
|
||||
if (std::fseek(fp, 0, SEEK_END) != 0 || (filelen = static_cast<u32>(std::ftell(fp))) == 0 || filelen < 56)
|
||||
[[unlikely]]
|
||||
{
|
||||
Log_ErrorPrint("Invalid ppf file");
|
||||
ERROR_LOG("Invalid ppf file");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -176,14 +176,14 @@ bool CDImagePPF::ReadV1Patch(std::FILE* fp)
|
||||
if (std::fread(&offset, sizeof(offset), 1, fp) != 1 || std::fread(&chunk_size, sizeof(chunk_size), 1, fp) != 1)
|
||||
[[unlikely]]
|
||||
{
|
||||
Log_ErrorPrint("Incomplete ppf");
|
||||
ERROR_LOG("Incomplete ppf");
|
||||
return false;
|
||||
}
|
||||
|
||||
temp.resize(chunk_size);
|
||||
if (std::fread(temp.data(), 1, chunk_size, fp) != chunk_size) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrint("Failed to read patch data");
|
||||
ERROR_LOG("Failed to read patch data");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ bool CDImagePPF::ReadV1Patch(std::FILE* fp)
|
||||
count -= sizeof(offset) + sizeof(chunk_size) + chunk_size;
|
||||
}
|
||||
|
||||
Log_InfoFmt("Loaded {} replacement sectors from version 1 PPF", m_replacement_map.size());
|
||||
INFO_LOG("Loaded {} replacement sectors from version 1 PPF", m_replacement_map.size());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -202,18 +202,18 @@ bool CDImagePPF::ReadV2Patch(std::FILE* fp)
|
||||
char desc[DESC_SIZE + 1] = {};
|
||||
if (std::fseek(fp, 6, SEEK_SET) != 0 || std::fread(desc, sizeof(char), DESC_SIZE, fp) != DESC_SIZE) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrint("Failed to read description");
|
||||
ERROR_LOG("Failed to read description");
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_InfoFmt("Patch description: %s", desc);
|
||||
INFO_LOG("Patch description: %s", desc);
|
||||
|
||||
const u32 idlen = ReadFileIDDiz(fp, 2);
|
||||
|
||||
u32 origlen;
|
||||
if (std::fseek(fp, 56, SEEK_SET) != 0 || std::fread(&origlen, sizeof(origlen), 1, fp) != 1) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrint("Failed to read size");
|
||||
ERROR_LOG("Failed to read size");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ bool CDImagePPF::ReadV2Patch(std::FILE* fp)
|
||||
temp.resize(BLOCKCHECK_SIZE);
|
||||
if (std::fread(temp.data(), 1, BLOCKCHECK_SIZE, fp) != BLOCKCHECK_SIZE) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrint("Failed to read blockcheck data");
|
||||
ERROR_LOG("Failed to read blockcheck data");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -234,11 +234,11 @@ bool CDImagePPF::ReadV2Patch(std::FILE* fp)
|
||||
if (m_parent_image->Seek(blockcheck_src_sector) && m_parent_image->ReadRawSector(src_sector.data(), nullptr))
|
||||
{
|
||||
if (std::memcmp(&src_sector[blockcheck_src_offset], temp.data(), BLOCKCHECK_SIZE) != 0)
|
||||
Log_WarningPrint("Blockcheck failed. The patch may not apply correctly.");
|
||||
WARNING_LOG("Blockcheck failed. The patch may not apply correctly.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_WarningFmt("Failed to read blockcheck sector {}", blockcheck_src_sector);
|
||||
WARNING_LOG("Failed to read blockcheck sector {}", blockcheck_src_sector);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ bool CDImagePPF::ReadV2Patch(std::FILE* fp)
|
||||
if (std::fseek(fp, 0, SEEK_END) != 0 || (filelen = static_cast<u32>(std::ftell(fp))) == 0 || filelen < 1084)
|
||||
[[unlikely]]
|
||||
{
|
||||
Log_ErrorPrint("Invalid ppf file");
|
||||
ERROR_LOG("Invalid ppf file");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -267,14 +267,14 @@ bool CDImagePPF::ReadV2Patch(std::FILE* fp)
|
||||
if (std::fread(&offset, sizeof(offset), 1, fp) != 1 || std::fread(&chunk_size, sizeof(chunk_size), 1, fp) != 1)
|
||||
[[unlikely]]
|
||||
{
|
||||
Log_ErrorPrint("Incomplete ppf");
|
||||
ERROR_LOG("Incomplete ppf");
|
||||
return false;
|
||||
}
|
||||
|
||||
temp.resize(chunk_size);
|
||||
if (std::fread(temp.data(), 1, chunk_size, fp) != chunk_size) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrint("Failed to read patch data");
|
||||
ERROR_LOG("Failed to read patch data");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ bool CDImagePPF::ReadV2Patch(std::FILE* fp)
|
||||
count -= sizeof(offset) + sizeof(chunk_size) + chunk_size;
|
||||
}
|
||||
|
||||
Log_InfoFmt("Loaded {} replacement sectors from version 2 PPF", m_replacement_map.size());
|
||||
INFO_LOG("Loaded {} replacement sectors from version 2 PPF", m_replacement_map.size());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -293,11 +293,11 @@ bool CDImagePPF::ReadV3Patch(std::FILE* fp)
|
||||
char desc[DESC_SIZE + 1] = {};
|
||||
if (std::fseek(fp, 6, SEEK_SET) != 0 || std::fread(desc, sizeof(char), DESC_SIZE, fp) != DESC_SIZE)
|
||||
{
|
||||
Log_ErrorPrint("Failed to read description");
|
||||
ERROR_LOG("Failed to read description");
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_InfoFmt("Patch description: {}", desc);
|
||||
INFO_LOG("Patch description: {}", desc);
|
||||
|
||||
u32 idlen = ReadFileIDDiz(fp, 3);
|
||||
|
||||
@@ -307,7 +307,7 @@ bool CDImagePPF::ReadV3Patch(std::FILE* fp)
|
||||
if (std::fseek(fp, 56, SEEK_SET) != 0 || std::fread(&image_type, sizeof(image_type), 1, fp) != 1 ||
|
||||
std::fread(&block_check, sizeof(block_check), 1, fp) != 1 || std::fread(&undo, sizeof(undo), 1, fp) != 1)
|
||||
{
|
||||
Log_ErrorPrint("Failed to read headers");
|
||||
ERROR_LOG("Failed to read headers");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ bool CDImagePPF::ReadV3Patch(std::FILE* fp)
|
||||
u32 seekpos = (block_check) ? 1084 : 60;
|
||||
if (seekpos >= count)
|
||||
{
|
||||
Log_ErrorPrint("File is too short");
|
||||
ERROR_LOG("File is too short");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ bool CDImagePPF::ReadV3Patch(std::FILE* fp)
|
||||
const u32 extralen = idlen + 18 + 16 + 2;
|
||||
if (count < extralen)
|
||||
{
|
||||
Log_ErrorPrint("File is too short (diz)");
|
||||
ERROR_LOG("File is too short (diz)");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -347,14 +347,14 @@ bool CDImagePPF::ReadV3Patch(std::FILE* fp)
|
||||
u8 chunk_size;
|
||||
if (std::fread(&offset, sizeof(offset), 1, fp) != 1 || std::fread(&chunk_size, sizeof(chunk_size), 1, fp) != 1)
|
||||
{
|
||||
Log_ErrorPrint("Incomplete ppf");
|
||||
ERROR_LOG("Incomplete ppf");
|
||||
return false;
|
||||
}
|
||||
|
||||
temp.resize(chunk_size);
|
||||
if (std::fread(temp.data(), 1, chunk_size, fp) != chunk_size)
|
||||
{
|
||||
Log_ErrorPrint("Failed to read patch data");
|
||||
ERROR_LOG("Failed to read patch data");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -364,13 +364,13 @@ bool CDImagePPF::ReadV3Patch(std::FILE* fp)
|
||||
count -= sizeof(offset) + sizeof(chunk_size) + chunk_size;
|
||||
}
|
||||
|
||||
Log_InfoFmt("Loaded {} replacement sectors from version 3 PPF", m_replacement_map.size());
|
||||
INFO_LOG("Loaded {} replacement sectors from version 3 PPF", m_replacement_map.size());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDImagePPF::AddPatch(u64 offset, const u8* patch, u32 patch_size)
|
||||
{
|
||||
Log_DebugFmt("Starting applying patch of {} bytes at at offset {}", patch_size, offset);
|
||||
DEBUG_LOG("Starting applying patch of {} bytes at at offset {}", patch_size, offset);
|
||||
|
||||
while (patch_size > 0)
|
||||
{
|
||||
@@ -378,7 +378,7 @@ bool CDImagePPF::AddPatch(u64 offset, const u8* patch, u32 patch_size)
|
||||
const u32 sector_offset = Truncate32(offset % RAW_SECTOR_SIZE);
|
||||
if (sector_index >= m_parent_image->GetLBACount())
|
||||
{
|
||||
Log_ErrorFmt("Sector {} in patch is out of range", sector_index);
|
||||
ERROR_LOG("Sector {} in patch is out of range", sector_index);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ bool CDImagePPF::AddPatch(u64 offset, const u8* patch, u32 patch_size)
|
||||
if (!m_parent_image->Seek(sector_index) ||
|
||||
!m_parent_image->ReadRawSector(&m_replacement_data[replacement_buffer_start], nullptr))
|
||||
{
|
||||
Log_ErrorFmt("Failed to read sector {} from parent image", sector_index);
|
||||
ERROR_LOG("Failed to read sector {} from parent image", sector_index);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -400,7 +400,7 @@ bool CDImagePPF::AddPatch(u64 offset, const u8* patch, u32 patch_size)
|
||||
}
|
||||
|
||||
// patch it!
|
||||
Log_DebugFmt(" Patching {} bytes at sector {} offset {}", bytes_to_patch, sector_index, sector_offset);
|
||||
DEBUG_LOG(" Patching {} bytes at sector {} offset {}", bytes_to_patch, sector_index, sector_offset);
|
||||
std::memcpy(&m_replacement_data[iter->second + sector_offset], patch, bytes_to_patch);
|
||||
offset += bytes_to_patch;
|
||||
patch += bytes_to_patch;
|
||||
|
||||
@@ -50,14 +50,14 @@ bool CDSubChannelReplacement::LoadSBI(const std::string& path)
|
||||
char header[4];
|
||||
if (std::fread(header, sizeof(header), 1, fp.get()) != 1)
|
||||
{
|
||||
Log_ErrorFmt("Failed to read header for '{}'", path);
|
||||
ERROR_LOG("Failed to read header for '{}'", path);
|
||||
return true;
|
||||
}
|
||||
|
||||
static constexpr char expected_header[] = {'S', 'B', 'I', '\0'};
|
||||
if (std::memcmp(header, expected_header, sizeof(header)) != 0)
|
||||
{
|
||||
Log_ErrorFmt("Invalid header in '{}'", path);
|
||||
ERROR_LOG("Invalid header in '{}'", path);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -69,14 +69,14 @@ bool CDSubChannelReplacement::LoadSBI(const std::string& path)
|
||||
if (!IsValidPackedBCD(entry.minute_bcd) || !IsValidPackedBCD(entry.second_bcd) ||
|
||||
!IsValidPackedBCD(entry.frame_bcd))
|
||||
{
|
||||
Log_ErrorFmt("Invalid position [{:02x}:{:02x}:{:02x}] in '{}'", entry.minute_bcd, entry.second_bcd,
|
||||
entry.frame_bcd, path);
|
||||
ERROR_LOG("Invalid position [{:02x}:{:02x}:{:02x}] in '{}'", entry.minute_bcd, entry.second_bcd, entry.frame_bcd,
|
||||
path);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (entry.type != 1)
|
||||
{
|
||||
Log_ErrorFmt("Invalid type 0x{:02X} in '{}'", entry.type, path);
|
||||
ERROR_LOG("Invalid type 0x{:02X} in '{}'", entry.type, path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ bool CDSubChannelReplacement::LoadSBI(const std::string& path)
|
||||
m_replacement_subq.emplace(lba, subq);
|
||||
}
|
||||
|
||||
Log_InfoFmt("Loaded {} replacement sectors from SBI '{}'", m_replacement_subq.size(), path);
|
||||
INFO_LOG("Loaded {} replacement sectors from SBI '{}'", m_replacement_subq.size(), path);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -111,8 +111,8 @@ bool CDSubChannelReplacement::LoadLSD(const std::string& path)
|
||||
if (!IsValidPackedBCD(entry.minute_bcd) || !IsValidPackedBCD(entry.second_bcd) ||
|
||||
!IsValidPackedBCD(entry.frame_bcd))
|
||||
{
|
||||
Log_ErrorFmt("Invalid position [{:02x}:{:02x}:{:02x}] in '{}'", entry.minute_bcd, entry.second_bcd,
|
||||
entry.frame_bcd, path);
|
||||
ERROR_LOG("Invalid position [{:02x}:{:02x}:{:02x}] in '{}'", entry.minute_bcd, entry.second_bcd, entry.frame_bcd,
|
||||
path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -121,12 +121,12 @@ bool CDSubChannelReplacement::LoadLSD(const std::string& path)
|
||||
CDImage::SubChannelQ subq;
|
||||
std::copy_n(entry.data, countof(entry.data), subq.data.data());
|
||||
|
||||
Log_DebugFmt("{:02x}:{:02x}:{:02x}: CRC {}", entry.minute_bcd, entry.second_bcd, entry.frame_bcd,
|
||||
subq.IsCRCValid() ? "VALID" : "INVALID");
|
||||
DEBUG_LOG("{:02x}:{:02x}:{:02x}: CRC {}", entry.minute_bcd, entry.second_bcd, entry.frame_bcd,
|
||||
subq.IsCRCValid() ? "VALID" : "INVALID");
|
||||
m_replacement_subq.emplace(lba, subq);
|
||||
}
|
||||
|
||||
Log_InfoFmt("Loaded {} replacement sectors from LSD '{}'", m_replacement_subq.size(), path);
|
||||
INFO_LOG("Loaded {} replacement sectors from LSD '{}'", m_replacement_subq.size(), path);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ void CubebAudioStream::LogCallback(const char* fmt, ...)
|
||||
va_start(ap, fmt);
|
||||
str.vsprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
Log_DevPrint(str);
|
||||
DEV_LOG(str);
|
||||
}
|
||||
|
||||
void CubebAudioStream::DestroyContextAndStream()
|
||||
@@ -172,8 +172,8 @@ bool CubebAudioStream::Initialize(const char* driver_name, const char* device_na
|
||||
rv = cubeb_get_min_latency(m_context, ¶ms, &min_latency_frames);
|
||||
if (rv == CUBEB_ERROR_NOT_SUPPORTED)
|
||||
{
|
||||
Log_DevFmt("Cubeb backend does not support latency queries, using latency of {} ms ({} frames).",
|
||||
m_parameters.buffer_ms, latency_frames);
|
||||
DEV_LOG("Cubeb backend does not support latency queries, using latency of {} ms ({} frames).",
|
||||
m_parameters.buffer_ms, latency_frames);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -185,7 +185,7 @@ bool CubebAudioStream::Initialize(const char* driver_name, const char* device_na
|
||||
}
|
||||
|
||||
const u32 minimum_latency_ms = GetMSForBufferSize(m_sample_rate, min_latency_frames);
|
||||
Log_DevFmt("Minimum latency: {} ms ({} audio frames)", minimum_latency_ms, min_latency_frames);
|
||||
DEV_LOG("Minimum latency: {} ms ({} audio frames)", minimum_latency_ms, min_latency_frames);
|
||||
if (m_parameters.output_latency_minimal)
|
||||
{
|
||||
// use minimum
|
||||
@@ -193,8 +193,8 @@ bool CubebAudioStream::Initialize(const char* driver_name, const char* device_na
|
||||
}
|
||||
else if (minimum_latency_ms > m_parameters.output_latency_ms)
|
||||
{
|
||||
Log_WarningFmt("Minimum latency is above requested latency: {} vs {}, adjusting to compensate.",
|
||||
min_latency_frames, latency_frames);
|
||||
WARNING_LOG("Minimum latency is above requested latency: {} vs {}, adjusting to compensate.", min_latency_frames,
|
||||
latency_frames);
|
||||
latency_frames = min_latency_frames;
|
||||
}
|
||||
}
|
||||
@@ -214,8 +214,7 @@ bool CubebAudioStream::Initialize(const char* driver_name, const char* device_na
|
||||
const cubeb_device_info& di = devices.device[i];
|
||||
if (di.device_id && selected_device_name == di.device_id)
|
||||
{
|
||||
Log_InfoFmt("Using output device '{}' ({}).", di.device_id,
|
||||
di.friendly_name ? di.friendly_name : di.device_id);
|
||||
INFO_LOG("Using output device '{}' ({}).", di.device_id, di.friendly_name ? di.friendly_name : di.device_id);
|
||||
selected_device = di.devid;
|
||||
break;
|
||||
}
|
||||
@@ -229,7 +228,7 @@ bool CubebAudioStream::Initialize(const char* driver_name, const char* device_na
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_WarningFmt("cubeb_enumerate_devices() returned {}, using default device.", GetCubebErrorString(rv));
|
||||
WARNING_LOG("cubeb_enumerate_devices() returned {}, using default device.", GetCubebErrorString(rv));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,7 +281,7 @@ void CubebAudioStream::SetPaused(bool paused)
|
||||
const int rv = paused ? cubeb_stream_stop(stream) : cubeb_stream_start(stream);
|
||||
if (rv != CUBEB_OK)
|
||||
{
|
||||
Log_ErrorFmt("Could not {} stream: {}", paused ? "pause" : "resume", rv);
|
||||
ERROR_LOG("Could not {} stream: {}", paused ? "pause" : "resume", rv);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -320,7 +319,7 @@ std::vector<AudioStream::DeviceInfo> AudioStream::GetCubebOutputDevices(const ch
|
||||
int rv = cubeb_init(&context, "DuckStation", (driver && *driver) ? driver : nullptr);
|
||||
if (rv != CUBEB_OK)
|
||||
{
|
||||
Log_ErrorFmt("cubeb_init() failed: {}", GetCubebErrorString(rv));
|
||||
ERROR_LOG("cubeb_init() failed: {}", GetCubebErrorString(rv));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -330,7 +329,7 @@ std::vector<AudioStream::DeviceInfo> AudioStream::GetCubebOutputDevices(const ch
|
||||
rv = cubeb_enumerate_devices(context, CUBEB_DEVICE_TYPE_OUTPUT, &devices);
|
||||
if (rv != CUBEB_OK)
|
||||
{
|
||||
Log_ErrorFmt("cubeb_enumerate_devices() failed: {}", GetCubebErrorString(rv));
|
||||
ERROR_LOG("cubeb_enumerate_devices() failed: {}", GetCubebErrorString(rv));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ void CueParser::File::SetError(u32 line_number, Error* error, const char* format
|
||||
str.vsprintf(format, ap);
|
||||
va_end(ap);
|
||||
|
||||
Log_ErrorFmt("Cue parse error at line {}: {}", line_number, str.c_str());
|
||||
ERROR_LOG("Cue parse error at line {}: {}", line_number, str.c_str());
|
||||
Error::SetString(error, fmt::format("Cue parse error at line {}: {}", line_number, str));
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ bool CueParser::File::ParseLine(const char* line, u32 line_number, Error* error)
|
||||
|
||||
if (TokenMatch(command, "POSTGAP"))
|
||||
{
|
||||
Log_WarningFmt("Ignoring '{}' command", command);
|
||||
WARNING_LOG("Ignoring '{}' command", command);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -231,7 +231,7 @@ bool CueParser::File::HandleFileCommand(const char* line, u32 line_number, Error
|
||||
}
|
||||
|
||||
m_current_file = filename;
|
||||
Log_DebugFmt("File '{}'", filename);
|
||||
DEBUG_LOG("File '{}'", filename);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ bool CueParser::File::HandleFlagCommand(const char* line, u32 line_number, Error
|
||||
else if (TokenMatch(token, "SCMS"))
|
||||
m_current_track->SetFlag(TrackFlag::SerialCopyManagement);
|
||||
else
|
||||
Log_WarningFmt("Unknown track flag '{}'", token);
|
||||
WARNING_LOG("Unknown track flag '{}'", token);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -428,7 +428,7 @@ bool CueParser::File::CompleteLastTrack(u32 line_number, Error* error)
|
||||
const MSF* index0 = m_current_track->GetIndex(0);
|
||||
if (index0 && m_current_track->zero_pregap.has_value())
|
||||
{
|
||||
Log_WarningFmt("Zero pregap and index 0 specified in track {}, ignoring zero pregap", m_current_track->number);
|
||||
WARNING_LOG("Zero pregap and index 0 specified in track {}, ignoring zero pregap", m_current_track->number);
|
||||
m_current_track->zero_pregap.reset();
|
||||
}
|
||||
|
||||
|
||||
+20
-20
@@ -126,10 +126,10 @@ bool D3D11Device::CreateDevice(std::string_view adapter, bool threaded_presentat
|
||||
ComPtr<IDXGIDevice> dxgi_device;
|
||||
if (SUCCEEDED(m_device.As(&dxgi_device)) &&
|
||||
SUCCEEDED(dxgi_device->GetParent(IID_PPV_ARGS(dxgi_adapter.GetAddressOf()))))
|
||||
Log_InfoFmt("D3D Adapter: %s", D3DCommon::GetAdapterName(dxgi_adapter.Get()));
|
||||
INFO_LOG("D3D Adapter: %s", D3DCommon::GetAdapterName(dxgi_adapter.Get()));
|
||||
else
|
||||
Log_ErrorPrint("Failed to obtain D3D adapter name.");
|
||||
Log_InfoFmt("Max device feature level: {}", D3DCommon::GetFeatureLevelString(m_max_feature_level));
|
||||
ERROR_LOG("Failed to obtain D3D adapter name.");
|
||||
INFO_LOG("Max device feature level: {}", D3DCommon::GetFeatureLevelString(m_max_feature_level));
|
||||
|
||||
BOOL allow_tearing_supported = false;
|
||||
hr = m_dxgi_factory->CheckFeatureSupport(DXGI_FEATURE_PRESENT_ALLOW_TEARING, &allow_tearing_supported,
|
||||
@@ -263,12 +263,12 @@ bool D3D11Device::CreateSwapChain()
|
||||
fs_desc.Scaling = fullscreen_mode.Scaling;
|
||||
fs_desc.Windowed = FALSE;
|
||||
|
||||
Log_VerboseFmt("Creating a {}x{} exclusive fullscreen swap chain", fs_sd_desc.Width, fs_sd_desc.Height);
|
||||
VERBOSE_LOG("Creating a {}x{} exclusive fullscreen swap chain", fs_sd_desc.Width, fs_sd_desc.Height);
|
||||
hr = m_dxgi_factory->CreateSwapChainForHwnd(m_device.Get(), window_hwnd, &fs_sd_desc, &fs_desc,
|
||||
fullscreen_output.Get(), m_swap_chain.ReleaseAndGetAddressOf());
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_WarningPrint("Failed to create fullscreen swap chain, trying windowed.");
|
||||
WARNING_LOG("Failed to create fullscreen swap chain, trying windowed.");
|
||||
m_is_exclusive_fullscreen = false;
|
||||
m_using_allow_tearing = m_allow_tearing_supported && m_using_flip_model_swap_chain;
|
||||
}
|
||||
@@ -276,15 +276,15 @@ bool D3D11Device::CreateSwapChain()
|
||||
|
||||
if (!m_is_exclusive_fullscreen)
|
||||
{
|
||||
Log_VerboseFmt("Creating a {}x{} {} windowed swap chain", swap_chain_desc.Width, swap_chain_desc.Height,
|
||||
m_using_flip_model_swap_chain ? "flip-discard" : "discard");
|
||||
VERBOSE_LOG("Creating a {}x{} {} windowed swap chain", swap_chain_desc.Width, swap_chain_desc.Height,
|
||||
m_using_flip_model_swap_chain ? "flip-discard" : "discard");
|
||||
hr = m_dxgi_factory->CreateSwapChainForHwnd(m_device.Get(), window_hwnd, &swap_chain_desc, nullptr, nullptr,
|
||||
m_swap_chain.ReleaseAndGetAddressOf());
|
||||
}
|
||||
|
||||
if (FAILED(hr) && m_using_flip_model_swap_chain)
|
||||
{
|
||||
Log_WarningPrint("Failed to create a flip-discard swap chain, trying discard.");
|
||||
WARNING_LOG("Failed to create a flip-discard swap chain, trying discard.");
|
||||
swap_chain_desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
|
||||
swap_chain_desc.Flags = 0;
|
||||
m_using_flip_model_swap_chain = false;
|
||||
@@ -294,7 +294,7 @@ bool D3D11Device::CreateSwapChain()
|
||||
m_swap_chain.ReleaseAndGetAddressOf());
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("CreateSwapChainForHwnd failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("CreateSwapChainForHwnd failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -304,7 +304,7 @@ bool D3D11Device::CreateSwapChain()
|
||||
if (FAILED(m_swap_chain->GetParent(IID_PPV_ARGS(parent_factory.GetAddressOf()))) ||
|
||||
FAILED(parent_factory->MakeWindowAssociation(window_hwnd, DXGI_MWA_NO_WINDOW_CHANGES)))
|
||||
{
|
||||
Log_WarningPrint("MakeWindowAssociation() to disable ALT+ENTER failed");
|
||||
WARNING_LOG("MakeWindowAssociation() to disable ALT+ENTER failed");
|
||||
}
|
||||
|
||||
if (!CreateSwapChainRTV())
|
||||
@@ -325,7 +325,7 @@ bool D3D11Device::CreateSwapChainRTV()
|
||||
HRESULT hr = m_swap_chain->GetBuffer(0, IID_PPV_ARGS(backbuffer.GetAddressOf()));
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("GetBuffer for RTV failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("GetBuffer for RTV failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ bool D3D11Device::CreateSwapChainRTV()
|
||||
hr = m_device->CreateRenderTargetView(backbuffer.Get(), &rtv_desc, m_swap_chain_rtv.ReleaseAndGetAddressOf());
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("CreateRenderTargetView for swap chain failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("CreateRenderTargetView for swap chain failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
m_swap_chain_rtv.Reset();
|
||||
return false;
|
||||
}
|
||||
@@ -345,7 +345,7 @@ bool D3D11Device::CreateSwapChainRTV()
|
||||
m_window_info.surface_width = backbuffer_desc.Width;
|
||||
m_window_info.surface_height = backbuffer_desc.Height;
|
||||
m_window_info.surface_format = s_swap_chain_format;
|
||||
Log_VerboseFmt("Swap chain buffer size: {}x{}", m_window_info.surface_width, m_window_info.surface_height);
|
||||
VERBOSE_LOG("Swap chain buffer size: {}x{}", m_window_info.surface_width, m_window_info.surface_height);
|
||||
|
||||
if (m_window_info.type == WindowInfo::Type::Win32)
|
||||
{
|
||||
@@ -391,7 +391,7 @@ bool D3D11Device::UpdateWindow()
|
||||
|
||||
if (m_window_info.type != WindowInfo::Type::Surfaceless && !CreateSwapChain())
|
||||
{
|
||||
Log_ErrorPrint("Failed to create swap chain on updated window");
|
||||
ERROR_LOG("Failed to create swap chain on updated window");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -421,7 +421,7 @@ void D3D11Device::ResizeWindow(s32 new_window_width, s32 new_window_height, floa
|
||||
HRESULT hr = m_swap_chain->ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN,
|
||||
m_using_allow_tearing ? DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING : 0);
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
Log_ErrorFmt("ResizeBuffers() failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("ResizeBuffers() failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
|
||||
if (!CreateSwapChainRTV())
|
||||
Panic("Failed to recreate swap chain RTV after resize");
|
||||
@@ -470,7 +470,7 @@ bool D3D11Device::CreateBuffers()
|
||||
!m_index_buffer.Create(D3D11_BIND_INDEX_BUFFER, INDEX_BUFFER_SIZE, INDEX_BUFFER_SIZE) ||
|
||||
!m_uniform_buffer.Create(D3D11_BIND_CONSTANT_BUFFER, MIN_UNIFORM_BUFFER_SIZE, MAX_UNIFORM_BUFFER_SIZE))
|
||||
{
|
||||
Log_ErrorPrint("Failed to create vertex/index/uniform buffers.");
|
||||
ERROR_LOG("Failed to create vertex/index/uniform buffers.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -600,7 +600,7 @@ std::optional<float> D3D11Device::GetHostRefreshRate()
|
||||
if (SUCCEEDED(m_swap_chain->GetDesc(&desc)) && desc.BufferDesc.RefreshRate.Numerator > 0 &&
|
||||
desc.BufferDesc.RefreshRate.Denominator > 0)
|
||||
{
|
||||
Log_DevFmt("using fs rr: {} {}", desc.BufferDesc.RefreshRate.Numerator, desc.BufferDesc.RefreshRate.Denominator);
|
||||
DEV_LOG("using fs rr: {} {}", desc.BufferDesc.RefreshRate.Numerator, desc.BufferDesc.RefreshRate.Denominator);
|
||||
return static_cast<float>(desc.BufferDesc.RefreshRate.Numerator) /
|
||||
static_cast<float>(desc.BufferDesc.RefreshRate.Denominator);
|
||||
}
|
||||
@@ -776,7 +776,7 @@ void D3D11Device::PopTimestampQuery()
|
||||
|
||||
if (disjoint.Disjoint)
|
||||
{
|
||||
Log_VerbosePrint("GPU timing disjoint, resetting.");
|
||||
VERBOSE_LOG("GPU timing disjoint, resetting.");
|
||||
m_read_timestamp_query = 0;
|
||||
m_write_timestamp_query = 0;
|
||||
m_waiting_timestamp_queries = 0;
|
||||
@@ -1078,7 +1078,7 @@ void D3D11Device::UnbindTexture(D3D11Texture* tex)
|
||||
{
|
||||
if (m_current_render_targets[i] == tex)
|
||||
{
|
||||
Log_WarningPrint("Unbinding current RT");
|
||||
WARNING_LOG("Unbinding current RT");
|
||||
SetRenderTargets(nullptr, 0, m_current_depth_target);
|
||||
break;
|
||||
}
|
||||
@@ -1086,7 +1086,7 @@ void D3D11Device::UnbindTexture(D3D11Texture* tex)
|
||||
}
|
||||
else if (m_current_depth_target == tex)
|
||||
{
|
||||
Log_WarningPrint("Unbinding current DS");
|
||||
WARNING_LOG("Unbinding current DS");
|
||||
SetRenderTargets(nullptr, 0, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ D3D11Device::ComPtr<ID3D11RasterizerState> D3D11Device::GetRasterizationState(co
|
||||
|
||||
HRESULT hr = m_device->CreateRasterizerState(&desc, drs.GetAddressOf());
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
Log_ErrorFmt("Failed to create depth state with {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("Failed to create depth state with {:08X}", static_cast<unsigned>(hr));
|
||||
|
||||
m_rasterization_states.emplace(rs.key, drs);
|
||||
return drs;
|
||||
@@ -188,7 +188,7 @@ D3D11Device::ComPtr<ID3D11DepthStencilState> D3D11Device::GetDepthState(const GP
|
||||
|
||||
HRESULT hr = m_device->CreateDepthStencilState(&desc, dds.GetAddressOf());
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
Log_ErrorFmt("Failed to create depth state with {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("Failed to create depth state with {:08X}", static_cast<unsigned>(hr));
|
||||
|
||||
m_depth_states.emplace(ds.key, dds);
|
||||
return dds;
|
||||
@@ -246,7 +246,7 @@ D3D11Device::ComPtr<ID3D11BlendState> D3D11Device::GetBlendState(const GPUPipeli
|
||||
|
||||
HRESULT hr = m_device->CreateBlendState(&blend_desc, dbs.GetAddressOf());
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
Log_ErrorFmt("Failed to create blend state with {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("Failed to create blend state with {:08X}", static_cast<unsigned>(hr));
|
||||
|
||||
m_blend_states.emplace(bs.key, dbs);
|
||||
return dbs;
|
||||
@@ -298,7 +298,7 @@ D3D11Device::ComPtr<ID3D11InputLayout> D3D11Device::GetInputLayout(const GPUPipe
|
||||
HRESULT hr = m_device->CreateInputLayout(elems, static_cast<UINT>(il.vertex_attributes.size()),
|
||||
vs->GetBytecode().data(), vs->GetBytecode().size(), dil.GetAddressOf());
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
Log_ErrorFmt("Failed to create input layout with {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("Failed to create input layout with {:08X}", static_cast<unsigned>(hr));
|
||||
|
||||
m_input_layouts.emplace(il, dil);
|
||||
return dil;
|
||||
|
||||
@@ -40,7 +40,7 @@ bool D3D11StreamBuffer::Create(D3D11_BIND_FLAG bind_flags, u32 min_size, u32 max
|
||||
m_use_map_no_overwrite = options.MapNoOverwriteOnDynamicConstantBuffer;
|
||||
if (m_use_map_no_overwrite && D3D11Device::GetMaxFeatureLevel() < D3D_FEATURE_LEVEL_12_0)
|
||||
{
|
||||
Log_WarningPrint("Ignoring MapNoOverwriteOnDynamicConstantBuffer on driver due to feature level.");
|
||||
WARNING_LOG("Ignoring MapNoOverwriteOnDynamicConstantBuffer on driver due to feature level.");
|
||||
m_use_map_no_overwrite = false;
|
||||
}
|
||||
|
||||
@@ -55,14 +55,14 @@ bool D3D11StreamBuffer::Create(D3D11_BIND_FLAG bind_flags, u32 min_size, u32 max
|
||||
|
||||
if (!m_use_map_no_overwrite)
|
||||
{
|
||||
Log_WarningFmt("Unable to use MAP_NO_OVERWRITE on buffer with bind flag {}, this may affect performance. "
|
||||
"Update your driver/operating system.",
|
||||
static_cast<unsigned>(bind_flags));
|
||||
WARNING_LOG("Unable to use MAP_NO_OVERWRITE on buffer with bind flag {}, this may affect performance. "
|
||||
"Update your driver/operating system.",
|
||||
static_cast<unsigned>(bind_flags));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_WarningFmt("ID3D11Device::CheckFeatureSupport() failed: {}", Error::CreateHResult(hr).GetDescription());
|
||||
WARNING_LOG("ID3D11Device::CheckFeatureSupport() failed: {}", Error::CreateHResult(hr).GetDescription());
|
||||
m_use_map_no_overwrite = false;
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ bool D3D11StreamBuffer::Create(D3D11_BIND_FLAG bind_flags, u32 min_size, u32 max
|
||||
hr = D3D11Device::GetD3DDevice()->CreateBuffer(&desc, nullptr, &buffer);
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Creating buffer failed: {}", Error::CreateHResult(hr).GetDescription());
|
||||
ERROR_LOG("Creating buffer failed: {}", Error::CreateHResult(hr).GetDescription());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ D3D11StreamBuffer::MappingResult D3D11StreamBuffer::Map(ID3D11DeviceContext1* co
|
||||
Assert(min_size < m_max_size);
|
||||
|
||||
const u32 new_size = std::min(m_max_size, Common::AlignUp(std::max(m_size * 2, min_size), alignment));
|
||||
Log_WarningFmt("Growing buffer from {} bytes to {} bytes", m_size, new_size);
|
||||
WARNING_LOG("Growing buffer from {} bytes to {} bytes", m_size, new_size);
|
||||
|
||||
D3D11_BUFFER_DESC new_desc;
|
||||
m_buffer->GetDesc(&new_desc);
|
||||
@@ -115,7 +115,7 @@ D3D11StreamBuffer::MappingResult D3D11StreamBuffer::Map(ID3D11DeviceContext1* co
|
||||
hr = D3D11Device::GetD3DDevice()->CreateBuffer(&new_desc, nullptr, m_buffer.ReleaseAndGetAddressOf());
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Creating buffer failed: {}", Error::CreateHResult(hr).GetDescription());
|
||||
ERROR_LOG("Creating buffer failed: {}", Error::CreateHResult(hr).GetDescription());
|
||||
Panic("Failed to grow buffer");
|
||||
}
|
||||
|
||||
@@ -128,8 +128,8 @@ D3D11StreamBuffer::MappingResult D3D11StreamBuffer::Map(ID3D11DeviceContext1* co
|
||||
hr = context->Map(m_buffer.Get(), 0, map_type, 0, &sr);
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Map failed: 0x{:08X} (alignment {}, minsize {}, size {}, position [], map type {})",
|
||||
static_cast<unsigned>(hr), alignment, min_size, m_size, m_position, static_cast<u32>(map_type));
|
||||
ERROR_LOG("Map failed: 0x{:08X} (alignment {}, minsize {}, size {}, position [], map type {})",
|
||||
static_cast<unsigned>(hr), alignment, min_size, m_size, m_position, static_cast<u32>(map_type));
|
||||
Panic("Map failed");
|
||||
}
|
||||
|
||||
|
||||
+12
-13
@@ -86,7 +86,7 @@ std::unique_ptr<GPUSampler> D3D11Device::CreateSampler(const GPUSampler::Config&
|
||||
const HRESULT hr = m_device->CreateSamplerState(&desc, ss.GetAddressOf());
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("CreateSamplerState() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("CreateSamplerState() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ bool D3D11Texture::Map(void** map, u32* map_stride, u32 x, u32 y, u32 width, u32
|
||||
HRESULT hr = context->Map(m_texture.Get(), srnum, discard ? D3D11_MAP_WRITE_DISCARD : D3D11_MAP_READ_WRITE, 0, &sr);
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Map pixels texture failed: {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("Map pixels texture failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -267,10 +267,9 @@ std::unique_ptr<D3D11Texture> D3D11Texture::Create(ID3D11Device* device, u32 wid
|
||||
const HRESULT tex_hr = device->CreateTexture2D(&desc, initial_data ? &srd : nullptr, texture.GetAddressOf());
|
||||
if (FAILED(tex_hr))
|
||||
{
|
||||
Log_ErrorFmt(
|
||||
"Create texture failed: 0x{:08X} ({}x{} levels:{} samples:{} format:{} bind_flags:{:X} initial_data:{})",
|
||||
static_cast<unsigned>(tex_hr), width, height, levels, samples, static_cast<unsigned>(format), bind_flags,
|
||||
initial_data);
|
||||
ERROR_LOG("Create texture failed: 0x{:08X} ({}x{} levels:{} samples:{} format:{} bind_flags:{:X} initial_data:{})",
|
||||
static_cast<unsigned>(tex_hr), width, height, levels, samples, static_cast<unsigned>(format), bind_flags,
|
||||
initial_data);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -291,7 +290,7 @@ std::unique_ptr<D3D11Texture> D3D11Texture::Create(ID3D11Device* device, u32 wid
|
||||
const HRESULT hr = device->CreateShaderResourceView(texture.Get(), &srv_desc, srv.GetAddressOf());
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Create SRV for texture failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("Create SRV for texture failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@@ -306,7 +305,7 @@ std::unique_ptr<D3D11Texture> D3D11Texture::Create(ID3D11Device* device, u32 wid
|
||||
const HRESULT hr = device->CreateRenderTargetView(texture.Get(), &rtv_desc, rtv.GetAddressOf());
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Create RTV for texture failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("Create RTV for texture failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -321,7 +320,7 @@ std::unique_ptr<D3D11Texture> D3D11Texture::Create(ID3D11Device* device, u32 wid
|
||||
const HRESULT hr = device->CreateDepthStencilView(texture.Get(), &dsv_desc, dsv.GetAddressOf());
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Create DSV for texture failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("Create DSV for texture failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -354,7 +353,7 @@ bool D3D11TextureBuffer::CreateBuffer()
|
||||
D3D11Device::GetD3DDevice()->CreateShaderResourceView(m_buffer.GetD3DBuffer(), &srv_desc, m_srv.GetAddressOf());
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("CreateShaderResourceView() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("CreateShaderResourceView() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -421,7 +420,7 @@ std::unique_ptr<D3D11DownloadTexture> D3D11DownloadTexture::Create(u32 width, u3
|
||||
HRESULT hr = D3D11Device::GetD3DDevice()->CreateTexture2D(&desc, nullptr, tex.GetAddressOf());
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorFmt("CreateTexture2D() failed: {:08X}", hr);
|
||||
ERROR_LOG("CreateTexture2D() failed: {:08X}", hr);
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -471,7 +470,7 @@ bool D3D11DownloadTexture::Map(u32 x, u32 y, u32 width, u32 height)
|
||||
HRESULT hr = D3D11Device::GetD3DContext()->Map(m_texture.Get(), 0, D3D11_MAP_READ, 0, &sr);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorFmt("Map() failed: {:08X}", hr);
|
||||
ERROR_LOG("Map() failed: {:08X}", hr);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -517,6 +516,6 @@ std::unique_ptr<GPUDownloadTexture> D3D11Device::CreateDownloadTexture(u32 width
|
||||
void* memory, size_t memory_size,
|
||||
u32 memory_stride)
|
||||
{
|
||||
Log_ErrorPrint("D3D11 cannot import memory for download textures");
|
||||
ERROR_LOG("D3D11 cannot import memory for download textures");
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ Microsoft::WRL::ComPtr<ID3D12PipelineState> D3D12::GraphicsPipelineBuilder::Crea
|
||||
HRESULT hr = device->CreateGraphicsPipelineState(&m_desc, IID_PPV_ARGS(ps.GetAddressOf()));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorFmt("CreateGraphicsPipelineState() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("CreateGraphicsPipelineState() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ Microsoft::WRL::ComPtr<ID3D12PipelineState> D3D12::ComputePipelineBuilder::Creat
|
||||
HRESULT hr = device->CreateComputePipelineState(&m_desc, IID_PPV_ARGS(ps.GetAddressOf()));
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("CreateComputePipelineState() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("CreateComputePipelineState() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@@ -14,14 +14,14 @@ D3D12DescriptorHeapManager::~D3D12DescriptorHeapManager() = default;
|
||||
bool D3D12DescriptorHeapManager::Create(ID3D12Device* device, D3D12_DESCRIPTOR_HEAP_TYPE type, u32 num_descriptors,
|
||||
bool shader_visible)
|
||||
{
|
||||
D3D12_DESCRIPTOR_HEAP_DESC desc = {type, static_cast<UINT>(num_descriptors),
|
||||
shader_visible ? D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE :
|
||||
D3D12_DESCRIPTOR_HEAP_FLAG_NONE, 0u};
|
||||
D3D12_DESCRIPTOR_HEAP_DESC desc = {
|
||||
type, static_cast<UINT>(num_descriptors),
|
||||
shader_visible ? D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE : D3D12_DESCRIPTOR_HEAP_FLAG_NONE, 0u};
|
||||
|
||||
HRESULT hr = device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(m_descriptor_heap.ReleaseAndGetAddressOf()));
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("CreateDescriptorHeap() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("CreateDescriptorHeap() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ bool D3D12DescriptorAllocator::Create(ID3D12Device* device, D3D12_DESCRIPTOR_HEA
|
||||
const HRESULT hr = device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(m_descriptor_heap.ReleaseAndGetAddressOf()));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorFmt("CreateDescriptorHeap() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("CreateDescriptorHeap() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+39
-39
@@ -89,9 +89,9 @@ D3D12Device::ComPtr<ID3DBlob> D3D12Device::SerializeRootSignature(const D3D12_RO
|
||||
D3D12SerializeRootSignature(desc, D3D_ROOT_SIGNATURE_VERSION_1, blob.GetAddressOf(), error_blob.GetAddressOf());
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("D3D12SerializeRootSignature() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("D3D12SerializeRootSignature() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
if (error_blob)
|
||||
Log_ErrorPrint(static_cast<const char*>(error_blob->GetBufferPointer()));
|
||||
ERROR_LOG(static_cast<const char*>(error_blob->GetBufferPointer()));
|
||||
|
||||
return {};
|
||||
}
|
||||
@@ -110,7 +110,7 @@ D3D12Device::ComPtr<ID3D12RootSignature> D3D12Device::CreateRootSignature(const
|
||||
m_device->CreateRootSignature(0, blob->GetBufferPointer(), blob->GetBufferSize(), IID_PPV_ARGS(rs.GetAddressOf()));
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("CreateRootSignature() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("CreateRootSignature() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ bool D3D12Device::CreateDevice(std::string_view adapter, bool threaded_presentat
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorPrint("Debug layer requested but not available.");
|
||||
ERROR_LOG("Debug layer requested but not available.");
|
||||
m_debug_device = false;
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ bool D3D12Device::CreateDevice(std::string_view adapter, bool threaded_presentat
|
||||
{
|
||||
const LUID luid(m_device->GetAdapterLuid());
|
||||
if (FAILED(m_dxgi_factory->EnumAdapterByLuid(luid, IID_PPV_ARGS(m_adapter.GetAddressOf()))))
|
||||
Log_ErrorPrint("Failed to get lookup adapter by device LUID");
|
||||
ERROR_LOG("Failed to get lookup adapter by device LUID");
|
||||
}
|
||||
|
||||
if (m_debug_device)
|
||||
@@ -303,22 +303,22 @@ bool D3D12Device::ReadPipelineCache(const std::string& filename)
|
||||
// Try without the cache data.
|
||||
if (data.has_value())
|
||||
{
|
||||
Log_WarningFmt("CreatePipelineLibrary() failed, trying without cache data. Error: {}",
|
||||
Error::CreateHResult(hr).GetDescription());
|
||||
WARNING_LOG("CreatePipelineLibrary() failed, trying without cache data. Error: {}",
|
||||
Error::CreateHResult(hr).GetDescription());
|
||||
|
||||
hr = m_device->CreatePipelineLibrary(nullptr, 0, IID_PPV_ARGS(m_pipeline_library.ReleaseAndGetAddressOf()));
|
||||
if (SUCCEEDED(hr))
|
||||
{
|
||||
// Delete cache file, it's no longer relevant.
|
||||
Log_InfoFmt("Deleting pipeline cache file {}", filename);
|
||||
INFO_LOG("Deleting pipeline cache file {}", filename);
|
||||
FileSystem::DeleteFile(filename.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_WarningFmt("CreatePipelineLibrary() failed, pipeline caching will not be available. Error: {}",
|
||||
Error::CreateHResult(hr).GetDescription());
|
||||
WARNING_LOG("CreatePipelineLibrary() failed, pipeline caching will not be available. Error: {}",
|
||||
Error::CreateHResult(hr).GetDescription());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -333,7 +333,7 @@ bool D3D12Device::GetPipelineCacheData(DynamicHeapArray<u8>* data)
|
||||
const size_t size = m_pipeline_library->GetSerializedSize();
|
||||
if (size == 0)
|
||||
{
|
||||
Log_WarningPrint("Empty serialized pipeline state returned.");
|
||||
WARNING_LOG("Empty serialized pipeline state returned.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ bool D3D12Device::GetPipelineCacheData(DynamicHeapArray<u8>* data)
|
||||
const HRESULT hr = m_pipeline_library->Serialize(data->data(), data->size());
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorFmt("Serialize() failed with HRESULT {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("Serialize() failed with HRESULT {:08X}", static_cast<unsigned>(hr));
|
||||
data->deallocate();
|
||||
return false;
|
||||
}
|
||||
@@ -362,7 +362,7 @@ bool D3D12Device::CreateCommandLists()
|
||||
IID_PPV_ARGS(res.command_allocators[j].GetAddressOf()));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorFmt("CreateCommandAllocator() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("CreateCommandAllocator() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ bool D3D12Device::CreateCommandLists()
|
||||
IID_PPV_ARGS(res.command_lists[j].GetAddressOf()));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorFmt("CreateCommandList() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("CreateCommandList() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -378,7 +378,7 @@ bool D3D12Device::CreateCommandLists()
|
||||
hr = res.command_lists[j]->Close();
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorFmt("Close() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("Close() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -386,13 +386,13 @@ bool D3D12Device::CreateCommandLists()
|
||||
if (!res.descriptor_allocator.Create(m_device.Get(), D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV,
|
||||
MAX_DESCRIPTORS_PER_FRAME))
|
||||
{
|
||||
Log_ErrorPrint("Failed to create per frame descriptor allocator");
|
||||
ERROR_LOG("Failed to create per frame descriptor allocator");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!res.sampler_allocator.Create(m_device.Get(), MAX_SAMPLERS_PER_FRAME))
|
||||
{
|
||||
Log_ErrorPrint("Failed to create per frame sampler allocator");
|
||||
ERROR_LOG("Failed to create per frame sampler allocator");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -439,7 +439,7 @@ void D3D12Device::MoveToNextCommandList()
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_WarningFmt("Map() for timestamp query failed: {:08X}", static_cast<unsigned>(hr));
|
||||
WARNING_LOG("Map() for timestamp query failed: {:08X}", static_cast<unsigned>(hr));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -490,7 +490,7 @@ bool D3D12Device::CreateDescriptorHeaps()
|
||||
|
||||
if (!m_descriptor_heap_manager.Allocate(&m_null_srv_descriptor))
|
||||
{
|
||||
Log_ErrorPrint("Failed to allocate null descriptor");
|
||||
ERROR_LOG("Failed to allocate null descriptor");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -551,7 +551,7 @@ void D3D12Device::SubmitCommandList(bool wait_for_completion)
|
||||
hr = res.command_lists[0]->Close();
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Closing init command list failed with HRESULT {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("Closing init command list failed with HRESULT {:08X}", static_cast<unsigned>(hr));
|
||||
Panic("TODO cannot continue");
|
||||
}
|
||||
}
|
||||
@@ -560,7 +560,7 @@ void D3D12Device::SubmitCommandList(bool wait_for_completion)
|
||||
hr = res.command_lists[1]->Close();
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Closing main command list failed with HRESULT {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("Closing main command list failed with HRESULT {:08X}", static_cast<unsigned>(hr));
|
||||
Panic("TODO cannot continue");
|
||||
}
|
||||
|
||||
@@ -592,7 +592,7 @@ void D3D12Device::SubmitCommandList(bool wait_for_completion, const char* reason
|
||||
const std::string reason_str(StringUtil::StdStringFromFormatV(reason, ap));
|
||||
va_end(ap);
|
||||
|
||||
Log_WarningFmt("Executing command buffer due to '{}'", reason_str);
|
||||
WARNING_LOG("Executing command buffer due to '{}'", reason_str);
|
||||
SubmitCommandList(wait_for_completion);
|
||||
}
|
||||
|
||||
@@ -647,7 +647,7 @@ bool D3D12Device::CreateTimestampQuery()
|
||||
HRESULT hr = m_device->CreateQueryHeap(&desc, IID_PPV_ARGS(m_timestamp_query_heap.GetAddressOf()));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorFmt("CreateQueryHeap() for timestamp failed with {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("CreateQueryHeap() for timestamp failed with {:08X}", static_cast<unsigned>(hr));
|
||||
m_features.gpu_timing = false;
|
||||
return false;
|
||||
}
|
||||
@@ -669,7 +669,7 @@ bool D3D12Device::CreateTimestampQuery()
|
||||
IID_PPV_ARGS(m_timestamp_query_buffer.GetAddressOf()));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorFmt("CreateResource() for timestamp failed with {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("CreateResource() for timestamp failed with {:08X}", static_cast<unsigned>(hr));
|
||||
m_features.gpu_timing = false;
|
||||
return false;
|
||||
}
|
||||
@@ -678,7 +678,7 @@ bool D3D12Device::CreateTimestampQuery()
|
||||
hr = m_command_queue->GetTimestampFrequency(&frequency);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorFmt("GetTimestampFrequency() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("GetTimestampFrequency() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
m_features.gpu_timing = false;
|
||||
return false;
|
||||
}
|
||||
@@ -860,12 +860,12 @@ bool D3D12Device::CreateSwapChain()
|
||||
fs_desc.Scaling = fullscreen_mode.Scaling;
|
||||
fs_desc.Windowed = FALSE;
|
||||
|
||||
Log_VerboseFmt("Creating a {}x{} exclusive fullscreen swap chain", fs_sd_desc.Width, fs_sd_desc.Height);
|
||||
VERBOSE_LOG("Creating a {}x{} exclusive fullscreen swap chain", fs_sd_desc.Width, fs_sd_desc.Height);
|
||||
hr = m_dxgi_factory->CreateSwapChainForHwnd(m_command_queue.Get(), window_hwnd, &fs_sd_desc, &fs_desc,
|
||||
fullscreen_output.Get(), m_swap_chain.ReleaseAndGetAddressOf());
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_WarningPrint("Failed to create fullscreen swap chain, trying windowed.");
|
||||
WARNING_LOG("Failed to create fullscreen swap chain, trying windowed.");
|
||||
m_is_exclusive_fullscreen = false;
|
||||
m_using_allow_tearing = m_allow_tearing_supported;
|
||||
}
|
||||
@@ -873,14 +873,14 @@ bool D3D12Device::CreateSwapChain()
|
||||
|
||||
if (!m_is_exclusive_fullscreen)
|
||||
{
|
||||
Log_VerboseFmt("Creating a {}x{} windowed swap chain", swap_chain_desc.Width, swap_chain_desc.Height);
|
||||
VERBOSE_LOG("Creating a {}x{} windowed swap chain", swap_chain_desc.Width, swap_chain_desc.Height);
|
||||
hr = m_dxgi_factory->CreateSwapChainForHwnd(m_command_queue.Get(), window_hwnd, &swap_chain_desc, nullptr, nullptr,
|
||||
m_swap_chain.ReleaseAndGetAddressOf());
|
||||
}
|
||||
|
||||
hr = m_dxgi_factory->MakeWindowAssociation(window_hwnd, DXGI_MWA_NO_WINDOW_CHANGES);
|
||||
if (FAILED(hr))
|
||||
Log_WarningPrint("MakeWindowAssociation() to disable ALT+ENTER failed");
|
||||
WARNING_LOG("MakeWindowAssociation() to disable ALT+ENTER failed");
|
||||
|
||||
if (!CreateSwapChainRTV())
|
||||
{
|
||||
@@ -908,7 +908,7 @@ bool D3D12Device::CreateSwapChainRTV()
|
||||
hr = m_swap_chain->GetBuffer(i, IID_PPV_ARGS(backbuffer.GetAddressOf()));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorFmt("GetBuffer for RTV failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("GetBuffer for RTV failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
DestroySwapChainRTVs();
|
||||
return false;
|
||||
}
|
||||
@@ -918,7 +918,7 @@ bool D3D12Device::CreateSwapChainRTV()
|
||||
D3D12DescriptorHandle rtv;
|
||||
if (!m_rtv_heap_manager.Allocate(&rtv))
|
||||
{
|
||||
Log_ErrorPrint("Failed to allocate RTV handle");
|
||||
ERROR_LOG("Failed to allocate RTV handle");
|
||||
DestroySwapChainRTVs();
|
||||
return false;
|
||||
}
|
||||
@@ -930,7 +930,7 @@ bool D3D12Device::CreateSwapChainRTV()
|
||||
m_window_info.surface_width = swap_chain_desc.BufferDesc.Width;
|
||||
m_window_info.surface_height = swap_chain_desc.BufferDesc.Height;
|
||||
m_window_info.surface_format = s_swap_chain_format;
|
||||
Log_VerboseFmt("Swap chain buffer size: {}x{}", m_window_info.surface_width, m_window_info.surface_height);
|
||||
VERBOSE_LOG("Swap chain buffer size: {}x{}", m_window_info.surface_width, m_window_info.surface_height);
|
||||
|
||||
if (m_window_info.type == WindowInfo::Type::Win32)
|
||||
{
|
||||
@@ -1014,7 +1014,7 @@ bool D3D12Device::UpdateWindow()
|
||||
|
||||
if (!CreateSwapChain())
|
||||
{
|
||||
Log_ErrorPrint("Failed to create swap chain on updated window");
|
||||
ERROR_LOG("Failed to create swap chain on updated window");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1040,7 +1040,7 @@ void D3D12Device::ResizeWindow(s32 new_window_width, s32 new_window_height, floa
|
||||
HRESULT hr = m_swap_chain->ResizeBuffers(0, 0, 0, DXGI_FORMAT_UNKNOWN,
|
||||
m_using_allow_tearing ? DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING : 0);
|
||||
if (FAILED(hr))
|
||||
Log_ErrorFmt("ResizeBuffers() failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("ResizeBuffers() failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
|
||||
if (!CreateSwapChainRTV())
|
||||
Panic("Failed to recreate swap chain RTV after resize");
|
||||
@@ -1096,7 +1096,7 @@ std::optional<float> D3D12Device::GetHostRefreshRate()
|
||||
if (SUCCEEDED(m_swap_chain->GetDesc(&desc)) && desc.BufferDesc.RefreshRate.Numerator > 0 &&
|
||||
desc.BufferDesc.RefreshRate.Denominator > 0)
|
||||
{
|
||||
Log_DevFmt("using fs rr: {} {}", desc.BufferDesc.RefreshRate.Numerator, desc.BufferDesc.RefreshRate.Denominator);
|
||||
DEV_LOG("using fs rr: {} {}", desc.BufferDesc.RefreshRate.Numerator, desc.BufferDesc.RefreshRate.Denominator);
|
||||
return static_cast<float>(desc.BufferDesc.RefreshRate.Numerator) /
|
||||
static_cast<float>(desc.BufferDesc.RefreshRate.Denominator);
|
||||
}
|
||||
@@ -1426,25 +1426,25 @@ bool D3D12Device::CreateBuffers()
|
||||
{
|
||||
if (!m_vertex_buffer.Create(VERTEX_BUFFER_SIZE))
|
||||
{
|
||||
Log_ErrorPrint("Failed to allocate vertex buffer");
|
||||
ERROR_LOG("Failed to allocate vertex buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_index_buffer.Create(INDEX_BUFFER_SIZE))
|
||||
{
|
||||
Log_ErrorPrint("Failed to allocate index buffer");
|
||||
ERROR_LOG("Failed to allocate index buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_uniform_buffer.Create(VERTEX_UNIFORM_BUFFER_SIZE))
|
||||
{
|
||||
Log_ErrorPrint("Failed to allocate uniform buffer");
|
||||
ERROR_LOG("Failed to allocate uniform buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_texture_upload_buffer.Create(TEXTURE_BUFFER_SIZE))
|
||||
{
|
||||
Log_ErrorPrint("Failed to allocate texture upload buffer");
|
||||
ERROR_LOG("Failed to allocate texture upload buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -231,7 +231,7 @@ std::unique_ptr<GPUPipeline> D3D12Device::CreatePipeline(const GPUPipeline::Grap
|
||||
{
|
||||
// E_INVALIDARG = not found.
|
||||
if (hr != E_INVALIDARG)
|
||||
Log_ErrorFmt("LoadGraphicsPipeline() failed with HRESULT {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("LoadGraphicsPipeline() failed with HRESULT {:08X}", static_cast<unsigned>(hr));
|
||||
|
||||
// Need to create it normally.
|
||||
pipeline = gpb.Create(m_device.Get(), false);
|
||||
@@ -241,7 +241,7 @@ std::unique_ptr<GPUPipeline> D3D12Device::CreatePipeline(const GPUPipeline::Grap
|
||||
{
|
||||
hr = m_pipeline_library->StorePipeline(name.c_str(), pipeline.Get());
|
||||
if (FAILED(hr))
|
||||
Log_ErrorFmt("StorePipeline() failed with HRESULT {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("StorePipeline() failed with HRESULT {:08X}", static_cast<unsigned>(hr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ bool D3D12StreamBuffer::Create(u32 size)
|
||||
IID_PPV_ARGS(buffer.GetAddressOf()));
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("CreateResource() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("CreateResource() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ bool D3D12StreamBuffer::Create(u32 size)
|
||||
hr = buffer->Map(0, &read_range, reinterpret_cast<void**>(&host_pointer));
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Map() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("Map() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -68,8 +68,8 @@ bool D3D12StreamBuffer::ReserveMemory(u32 num_bytes, u32 alignment)
|
||||
// Check for sane allocations
|
||||
if (num_bytes > m_size) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Attempting to allocate {} bytes from a {} byte stream buffer", static_cast<u32>(num_bytes),
|
||||
static_cast<u32>(m_size));
|
||||
ERROR_LOG("Attempting to allocate {} bytes from a {} byte stream buffer", static_cast<u32>(num_bytes),
|
||||
static_cast<u32>(m_size));
|
||||
Panic("Stream buffer overflow");
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -119,7 +119,7 @@ std::unique_ptr<GPUTexture> D3D12Device::CreateTexture(u32 width, u32 height, u3
|
||||
{
|
||||
// OOM isn't fatal.
|
||||
if (hr != E_OUTOFMEMORY)
|
||||
Log_ErrorFmt("Create texture failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("Create texture failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
|
||||
return {};
|
||||
}
|
||||
@@ -186,7 +186,7 @@ bool D3D12Device::CreateSRVDescriptor(ID3D12Resource* resource, u32 layers, u32
|
||||
{
|
||||
if (!m_descriptor_heap_manager.Allocate(dh))
|
||||
{
|
||||
Log_ErrorPrint("Failed to allocate SRV descriptor");
|
||||
ERROR_LOG("Failed to allocate SRV descriptor");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ bool D3D12Device::CreateRTVDescriptor(ID3D12Resource* resource, u32 samples, DXG
|
||||
{
|
||||
if (!m_rtv_heap_manager.Allocate(dh))
|
||||
{
|
||||
Log_ErrorPrint("Failed to allocate SRV descriptor");
|
||||
ERROR_LOG("Failed to allocate SRV descriptor");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ bool D3D12Device::CreateDSVDescriptor(ID3D12Resource* resource, u32 samples, DXG
|
||||
{
|
||||
if (!m_dsv_heap_manager.Allocate(dh))
|
||||
{
|
||||
Log_ErrorPrint("Failed to allocate SRV descriptor");
|
||||
ERROR_LOG("Failed to allocate SRV descriptor");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ bool D3D12Device::CreateUAVDescriptor(ID3D12Resource* resource, u32 samples, DXG
|
||||
{
|
||||
if (!m_descriptor_heap_manager.Allocate(dh))
|
||||
{
|
||||
Log_ErrorPrint("Failed to allocate UAV descriptor");
|
||||
ERROR_LOG("Failed to allocate UAV descriptor");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -358,9 +358,9 @@ ID3D12Resource* D3D12Texture::AllocateUploadStagingBuffer(const void* data, u32
|
||||
HRESULT hr = D3D12Device::GetInstance().GetAllocator()->CreateResource(
|
||||
&allocation_desc, &resource_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, allocation.GetAddressOf(),
|
||||
IID_PPV_ARGS(resource.GetAddressOf()));
|
||||
if (FAILED(hr))[[unlikely]]
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("CreateResource() failed with {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("CreateResource() failed with {:08X}", static_cast<unsigned>(hr));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -368,7 +368,7 @@ ID3D12Resource* D3D12Texture::AllocateUploadStagingBuffer(const void* data, u32
|
||||
hr = resource->Map(0, nullptr, &map_ptr);
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Map() failed with {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("Map() failed with {:08X}", static_cast<unsigned>(hr));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -421,7 +421,7 @@ bool D3D12Texture::Update(u32 x, u32 y, u32 width, u32 height, const void* data,
|
||||
required_size);
|
||||
if (!sbuffer.ReserveMemory(required_size, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Failed to reserve texture upload memory ({} bytes).", required_size);
|
||||
ERROR_LOG("Failed to reserve texture upload memory ({} bytes).", required_size);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -872,7 +872,7 @@ std::unique_ptr<D3D12DownloadTexture> D3D12DownloadTexture::Create(u32 width, u3
|
||||
IID_PPV_ARGS(buffer.GetAddressOf()));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorFmt("CreateResource() failed with HRESULT {:08X}", hr);
|
||||
ERROR_LOG("CreateResource() failed with HRESULT {:08X}", hr);
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -954,7 +954,7 @@ bool D3D12DownloadTexture::Map(u32 x, u32 y, u32 width, u32 height)
|
||||
const HRESULT hr = m_buffer->Map(0, &read_range, reinterpret_cast<void**>(const_cast<u8**>(&m_map_pointer)));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorFmt("Map() failed with HRESULT {:08X}", hr);
|
||||
ERROR_LOG("Map() failed with HRESULT {:08X}", hr);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1006,6 +1006,6 @@ std::unique_ptr<GPUDownloadTexture> D3D12Device::CreateDownloadTexture(u32 width
|
||||
void* memory, size_t memory_size,
|
||||
u32 memory_stride)
|
||||
{
|
||||
Log_ErrorPrint("D3D12 cannot import memory for download textures");
|
||||
ERROR_LOG("D3D12 cannot import memory for download textures");
|
||||
return {};
|
||||
}
|
||||
|
||||
+15
-15
@@ -73,7 +73,7 @@ D3D_FEATURE_LEVEL D3DCommon::GetDeviceMaxFeatureLevel(IDXGIAdapter1* adapter)
|
||||
requested_feature_levels.data(), static_cast<UINT>(requested_feature_levels.size()),
|
||||
D3D11_SDK_VERSION, nullptr, &max_supported_level, nullptr);
|
||||
if (FAILED(hr))
|
||||
Log_WarningFmt("D3D11CreateDevice() for getting max feature level failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
WARNING_LOG("D3D11CreateDevice() for getting max feature level failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
|
||||
return max_supported_level;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ std::vector<std::string> D3DCommon::GetAdapterNames(IDXGIFactory5* factory)
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorFmt("IDXGIFactory2::EnumAdapters() returned {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("IDXGIFactory2::EnumAdapters() returned {:08X}", static_cast<unsigned>(hr));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -146,21 +146,21 @@ std::vector<std::string> D3DCommon::GetFullscreenModes(IDXGIFactory5* factory, s
|
||||
Microsoft::WRL::ComPtr<IDXGIOutput> output;
|
||||
if (FAILED(hr = adapter->EnumOutputs(0, &output)))
|
||||
{
|
||||
Log_ErrorFmt("EnumOutputs() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("EnumOutputs() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return modes;
|
||||
}
|
||||
|
||||
UINT num_modes = 0;
|
||||
if (FAILED(hr = output->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, 0, &num_modes, nullptr)))
|
||||
{
|
||||
Log_ErrorFmt("GetDisplayModeList() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("GetDisplayModeList() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return modes;
|
||||
}
|
||||
|
||||
std::vector<DXGI_MODE_DESC> dmodes(num_modes);
|
||||
if (FAILED(hr = output->GetDisplayModeList(DXGI_FORMAT_R8G8B8A8_UNORM, 0, &num_modes, dmodes.data())))
|
||||
{
|
||||
Log_ErrorFmt("GetDisplayModeList() (2) failed: {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("GetDisplayModeList() (2) failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return modes;
|
||||
}
|
||||
|
||||
@@ -223,11 +223,11 @@ bool D3DCommon::GetRequestedExclusiveFullscreenModeDesc(IDXGIFactory5* factory,
|
||||
{
|
||||
if (!first_output)
|
||||
{
|
||||
Log_ErrorPrint("No DXGI output found. Can't use exclusive fullscreen.");
|
||||
ERROR_LOG("No DXGI output found. Can't use exclusive fullscreen.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_WarningPrint("No DXGI output found for window, using first.");
|
||||
WARNING_LOG("No DXGI output found for window, using first.");
|
||||
intersecting_output = std::move(first_output);
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ bool D3DCommon::GetRequestedExclusiveFullscreenModeDesc(IDXGIFactory5* factory,
|
||||
if (FAILED(hr = intersecting_output->FindClosestMatchingMode(&request_mode, fullscreen_mode, nullptr)) ||
|
||||
request_mode.Format != format)
|
||||
{
|
||||
Log_ErrorFmt("Failed to find closest matching mode, hr={:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("Failed to find closest matching mode, hr={:08X}", static_cast<unsigned>(hr));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -268,21 +268,21 @@ Microsoft::WRL::ComPtr<IDXGIAdapter1> D3DCommon::GetAdapterByName(IDXGIFactory5*
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorFmt("IDXGIFactory2::EnumAdapters() returned {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("IDXGIFactory2::EnumAdapters() returned {:08X}", static_cast<unsigned>(hr));
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string adapter_name = FixupDuplicateAdapterNames(adapter_names, GetAdapterName(adapter.Get()));
|
||||
if (adapter_name == name)
|
||||
{
|
||||
Log_VerboseFmt("Found adapter '{}'", adapter_name);
|
||||
VERBOSE_LOG("Found adapter '{}'", adapter_name);
|
||||
return adapter;
|
||||
}
|
||||
|
||||
adapter_names.push_back(std::move(adapter_name));
|
||||
}
|
||||
|
||||
Log_ErrorFmt("Adapter '{}' not found.", name);
|
||||
ERROR_LOG("Adapter '{}' not found.", name);
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ Microsoft::WRL::ComPtr<IDXGIAdapter1> D3DCommon::GetFirstAdapter(IDXGIFactory5*
|
||||
Microsoft::WRL::ComPtr<IDXGIAdapter1> adapter;
|
||||
HRESULT hr = factory->EnumAdapters1(0, adapter.GetAddressOf());
|
||||
if (FAILED(hr))
|
||||
Log_ErrorFmt("IDXGIFactory2::EnumAdapters() for first adapter returned {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("IDXGIFactory2::EnumAdapters() for first adapter returned {:08X}", static_cast<unsigned>(hr));
|
||||
|
||||
return adapter;
|
||||
}
|
||||
@@ -317,7 +317,7 @@ std::string D3DCommon::GetAdapterName(IDXGIAdapter1* adapter)
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorFmt("IDXGIAdapter1::GetDesc() returned {:08X}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("IDXGIAdapter1::GetDesc() returned {:08X}", static_cast<unsigned>(hr));
|
||||
}
|
||||
|
||||
if (ret.empty())
|
||||
@@ -429,13 +429,13 @@ std::optional<DynamicHeapArray<u8>> D3DCommon::CompileShader(D3D_FEATURE_LEVEL f
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorFmt("Failed to compile '{}':\n{}", target, error_string);
|
||||
ERROR_LOG("Failed to compile '{}':\n{}", target, error_string);
|
||||
GPUDevice::DumpBadShader(source, error_string);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (!error_string.empty())
|
||||
Log_WarningFmt("'{}' compiled with warnings:\n{}", target, error_string);
|
||||
WARNING_LOG("'{}' compiled with warnings:\n{}", target, error_string);
|
||||
|
||||
error_blob.Reset();
|
||||
|
||||
|
||||
+18
-18
@@ -64,7 +64,7 @@ bool DInputSource::Initialize(SettingsInterface& si, std::unique_lock<std::mutex
|
||||
m_dinput_module = LoadLibraryW(L"dinput8");
|
||||
if (!m_dinput_module)
|
||||
{
|
||||
Log_ErrorPrint("Failed to load DInput module.");
|
||||
ERROR_LOG("Failed to load DInput module.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ bool DInputSource::Initialize(SettingsInterface& si, std::unique_lock<std::mutex
|
||||
reinterpret_cast<PFNGETDFDIJOYSTICK>(GetProcAddress(m_dinput_module, "GetdfDIJoystick"));
|
||||
if (!create || !get_joystick_data_format)
|
||||
{
|
||||
Log_ErrorPrint("Failed to get DInput function pointers.");
|
||||
ERROR_LOG("Failed to get DInput function pointers.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ bool DInputSource::Initialize(SettingsInterface& si, std::unique_lock<std::mutex
|
||||
m_joystick_data_format = get_joystick_data_format();
|
||||
if (FAILED(hr) || !m_joystick_data_format)
|
||||
{
|
||||
Log_ErrorFmt("DirectInput8Create() failed: {}", static_cast<unsigned>(hr));
|
||||
ERROR_LOG("DirectInput8Create() failed: {}", static_cast<unsigned>(hr));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ bool DInputSource::Initialize(SettingsInterface& si, std::unique_lock<std::mutex
|
||||
|
||||
if (!toplevel_wi.has_value() || toplevel_wi->type != WindowInfo::Type::Win32)
|
||||
{
|
||||
Log_ErrorPrint("Missing top level window, cannot add DInput devices.");
|
||||
ERROR_LOG("Missing top level window, cannot add DInput devices.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ bool DInputSource::ReloadDevices()
|
||||
std::vector<DIDEVICEINSTANCEW> devices;
|
||||
m_dinput->EnumDevices(DI8DEVCLASS_GAMECTRL, EnumCallback, &devices, DIEDFL_ATTACHEDONLY);
|
||||
|
||||
Log_VerboseFmt("Enumerated {} devices", devices.size());
|
||||
VERBOSE_LOG("Enumerated {} devices", devices.size());
|
||||
|
||||
bool changed = false;
|
||||
for (DIDEVICEINSTANCEW inst : devices)
|
||||
@@ -141,9 +141,9 @@ bool DInputSource::ReloadDevices()
|
||||
HRESULT hr = m_dinput->CreateDevice(inst.guidInstance, cd.device.GetAddressOf(), nullptr);
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_WarningFmt("Failed to create instance of device [{}, {}]",
|
||||
StringUtil::WideStringToUTF8String(inst.tszProductName),
|
||||
StringUtil::WideStringToUTF8String(inst.tszInstanceName));
|
||||
WARNING_LOG("Failed to create instance of device [{}, {}]",
|
||||
StringUtil::WideStringToUTF8String(inst.tszProductName),
|
||||
StringUtil::WideStringToUTF8String(inst.tszInstanceName));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -179,24 +179,24 @@ bool DInputSource::AddDevice(ControllerData& cd, const std::string& name)
|
||||
hr = cd.device->SetCooperativeLevel(m_toplevel_window, DISCL_BACKGROUND | DISCL_NONEXCLUSIVE);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorFmt("Failed to set cooperative level for '{}'", name);
|
||||
ERROR_LOG("Failed to set cooperative level for '{}'", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_WarningFmt("Failed to set exclusive mode for '{}'", name);
|
||||
WARNING_LOG("Failed to set exclusive mode for '{}'", name);
|
||||
}
|
||||
|
||||
hr = cd.device->SetDataFormat(m_joystick_data_format);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorFmt("Failed to set data format for '{}'", name);
|
||||
ERROR_LOG("Failed to set data format for '{}'", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
hr = cd.device->Acquire();
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorFmt("Failed to acquire device '{}'", name);
|
||||
ERROR_LOG("Failed to acquire device '{}'", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ bool DInputSource::AddDevice(ControllerData& cd, const std::string& name)
|
||||
hr = cd.device->GetCapabilities(&caps);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorFmt("Failed to get capabilities for '{}'", name);
|
||||
ERROR_LOG("Failed to get capabilities for '{}'", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -239,14 +239,14 @@ bool DInputSource::AddDevice(ControllerData& cd, const std::string& name)
|
||||
if (hr == DI_NOEFFECT)
|
||||
cd.needs_poll = false;
|
||||
else if (hr != DI_OK)
|
||||
Log_WarningFmt("Polling device '{}' failed: {:08X}", name, static_cast<unsigned>(hr));
|
||||
WARNING_LOG("Polling device '{}' failed: {:08X}", name, static_cast<unsigned>(hr));
|
||||
|
||||
hr = cd.device->GetDeviceState(sizeof(cd.last_state), &cd.last_state);
|
||||
if (hr != DI_OK)
|
||||
Log_WarningFmt("GetDeviceState() for '{}' failed: {:08X}", name, static_cast<unsigned>(hr));
|
||||
WARNING_LOG("GetDeviceState() for '{}' failed: {:08X}", name, static_cast<unsigned>(hr));
|
||||
|
||||
Log_InfoFmt("{} has {} buttons, {} axes, {} hats", name, cd.num_buttons, static_cast<u32>(cd.axis_offsets.size()),
|
||||
cd.num_hats);
|
||||
INFO_LOG("{} has {} buttons, {} axes, {} hats", name, cd.num_buttons, static_cast<u32>(cd.axis_offsets.size()),
|
||||
cd.num_hats);
|
||||
|
||||
return (cd.num_buttons > 0 || !cd.axis_offsets.empty() || cd.num_hats > 0);
|
||||
}
|
||||
@@ -278,7 +278,7 @@ void DInputSource::PollEvents()
|
||||
}
|
||||
else if (hr != DI_OK)
|
||||
{
|
||||
Log_WarningFmt("GetDeviceState() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
WARNING_LOG("GetDeviceState() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
+24
-25
@@ -241,7 +241,7 @@ RenderAPI GPUDevice::GetPreferredAPI()
|
||||
preferred_renderer = RenderAPI::Vulkan;
|
||||
#else
|
||||
// Uhhh, what?
|
||||
Log_ErrorPrint("Somehow don't have any renderers available...");
|
||||
ERROR_LOG("Somehow don't have any renderers available...");
|
||||
preferred_renderer = RenderAPI::None;
|
||||
#endif
|
||||
}
|
||||
@@ -296,7 +296,7 @@ bool GPUDevice::Create(std::string_view adapter, std::string_view shader_cache_p
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_InfoFmt("Graphics Driver Info:\n{}", GetDriverInfo());
|
||||
INFO_LOG("Graphics Driver Info:\n{}", GetDriverInfo());
|
||||
|
||||
OpenShaderCache(shader_cache_path, shader_cache_version);
|
||||
|
||||
@@ -332,9 +332,9 @@ void GPUDevice::OpenShaderCache(std::string_view base_path, u32 version)
|
||||
const std::string filename = Path::Combine(base_path, basename);
|
||||
if (!m_shader_cache.Open(filename.c_str(), version))
|
||||
{
|
||||
Log_WarningPrint("Failed to open shader cache. Creating new cache.");
|
||||
WARNING_LOG("Failed to open shader cache. Creating new cache.");
|
||||
if (!m_shader_cache.Create())
|
||||
Log_ErrorPrint("Failed to create new shader cache.");
|
||||
ERROR_LOG("Failed to create new shader cache.");
|
||||
|
||||
// Squish the pipeline cache too, it's going to be stale.
|
||||
if (m_features.pipeline_cache)
|
||||
@@ -343,7 +343,7 @@ void GPUDevice::OpenShaderCache(std::string_view base_path, u32 version)
|
||||
Path::Combine(base_path, TinyString::from_format("{}.bin", GetShaderCacheBaseName("pipelines")));
|
||||
if (FileSystem::FileExists(pc_filename.c_str()))
|
||||
{
|
||||
Log_InfoFmt("Removing old pipeline cache '{}'", Path::GetFileName(pc_filename));
|
||||
INFO_LOG("Removing old pipeline cache '{}'", Path::GetFileName(pc_filename));
|
||||
FileSystem::DeleteFile(pc_filename.c_str());
|
||||
}
|
||||
}
|
||||
@@ -363,7 +363,7 @@ void GPUDevice::OpenShaderCache(std::string_view base_path, u32 version)
|
||||
if (ReadPipelineCache(filename))
|
||||
s_pipeline_cache_path = std::move(filename);
|
||||
else
|
||||
Log_WarningPrint("Failed to read pipeline cache.");
|
||||
WARNING_LOG("Failed to read pipeline cache.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -380,14 +380,13 @@ void GPUDevice::CloseShaderCache()
|
||||
FILESYSTEM_STAT_DATA sd;
|
||||
if (!FileSystem::StatFile(s_pipeline_cache_path.c_str(), &sd) || sd.Size != static_cast<s64>(data.size()))
|
||||
{
|
||||
Log_InfoFmt("Writing {} bytes to '{}'", data.size(), Path::GetFileName(s_pipeline_cache_path));
|
||||
INFO_LOG("Writing {} bytes to '{}'", data.size(), Path::GetFileName(s_pipeline_cache_path));
|
||||
if (!FileSystem::WriteBinaryFile(s_pipeline_cache_path.c_str(), data.data(), data.size()))
|
||||
Log_ErrorFmt("Failed to write pipeline cache to '{}'", Path::GetFileName(s_pipeline_cache_path));
|
||||
ERROR_LOG("Failed to write pipeline cache to '{}'", Path::GetFileName(s_pipeline_cache_path));
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_InfoFmt("Skipping updating pipeline cache '{}' due to no changes.",
|
||||
Path::GetFileName(s_pipeline_cache_path));
|
||||
INFO_LOG("Skipping updating pipeline cache '{}' due to no changes.", Path::GetFileName(s_pipeline_cache_path));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,7 +454,7 @@ bool GPUDevice::AcquireWindow(bool recreate_window)
|
||||
if (!wi.has_value())
|
||||
return false;
|
||||
|
||||
Log_InfoFmt("Render window is {}x{}.", wi->surface_width, wi->surface_height);
|
||||
INFO_LOG("Render window is {}x{}.", wi->surface_width, wi->surface_height);
|
||||
m_window_info = wi.value();
|
||||
return true;
|
||||
}
|
||||
@@ -506,7 +505,7 @@ bool GPUDevice::CreateResources()
|
||||
m_imgui_pipeline = CreatePipeline(plconfig);
|
||||
if (!m_imgui_pipeline)
|
||||
{
|
||||
Log_ErrorPrint("Failed to compile ImGui pipeline.");
|
||||
ERROR_LOG("Failed to compile ImGui pipeline.");
|
||||
return false;
|
||||
}
|
||||
GL_OBJECT_NAME(m_imgui_pipeline, "ImGui Pipeline");
|
||||
@@ -666,7 +665,7 @@ std::unique_ptr<GPUShader> GPUDevice::CreateShader(GPUShaderStage stage, std::st
|
||||
if (shader)
|
||||
return shader;
|
||||
|
||||
Log_ErrorPrint("Failed to create shader from binary (driver changed?). Clearing cache.");
|
||||
ERROR_LOG("Failed to create shader from binary (driver changed?). Clearing cache.");
|
||||
m_shader_cache.Clear();
|
||||
}
|
||||
|
||||
@@ -874,7 +873,7 @@ std::unique_ptr<GPUTexture> GPUDevice::FetchTexture(u32 width, u32 height, u32 l
|
||||
else
|
||||
{
|
||||
// This shouldn't happen...
|
||||
Log_ErrorFmt("Failed to upload {}x{} to pooled texture", width, height);
|
||||
ERROR_LOG("Failed to upload {}x{} to pooled texture", width, height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -913,7 +912,7 @@ void GPUDevice::RecycleTexture(std::unique_ptr<GPUTexture> texture)
|
||||
const u32 max_size = is_texture ? MAX_TEXTURE_POOL_SIZE : MAX_TARGET_POOL_SIZE;
|
||||
while (pool.size() > max_size)
|
||||
{
|
||||
Log_ProfileFmt("Trim {}x{} texture from pool", pool.front().texture->GetWidth(), pool.front().texture->GetHeight());
|
||||
DEBUG_LOG("Trim {}x{} texture from pool", pool.front().texture->GetWidth(), pool.front().texture->GetHeight());
|
||||
pool.pop_front();
|
||||
}
|
||||
}
|
||||
@@ -931,8 +930,8 @@ void GPUDevice::TrimTexturePool()
|
||||
GL_INS_FMT("Target Pool Size: {}", m_target_pool.size());
|
||||
GL_INS_FMT("VRAM Usage: {:.2f} MB", s_total_vram_usage / 1048576.0);
|
||||
|
||||
Log_DebugFmt("Texture Pool Size: {} Target Pool Size: {} VRAM: {:.2f} MB", m_texture_pool.size(),
|
||||
m_target_pool.size(), s_total_vram_usage / 1048756.0);
|
||||
DEBUG_LOG("Texture Pool Size: {} Target Pool Size: {} VRAM: {:.2f} MB", m_texture_pool.size(), m_target_pool.size(),
|
||||
s_total_vram_usage / 1048756.0);
|
||||
|
||||
if (m_texture_pool.empty() && m_target_pool.empty())
|
||||
return;
|
||||
@@ -947,7 +946,7 @@ void GPUDevice::TrimTexturePool()
|
||||
if (delta < POOL_PURGE_DELAY)
|
||||
break;
|
||||
|
||||
Log_ProfileFmt("Trim {}x{} texture from pool", it->texture->GetWidth(), it->texture->GetHeight());
|
||||
DEBUG_LOG("Trim {}x{} texture from pool", it->texture->GetWidth(), it->texture->GetHeight());
|
||||
it = pool.erase(it);
|
||||
}
|
||||
}
|
||||
@@ -990,7 +989,7 @@ bool GPUDevice::ResizeTexture(std::unique_ptr<GPUTexture>* tex, u32 new_width, u
|
||||
std::unique_ptr<GPUTexture> new_tex = FetchTexture(new_width, new_height, 1, 1, 1, type, format);
|
||||
if (!new_tex) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Failed to create new {}x{} texture", new_width, new_height);
|
||||
ERROR_LOG("Failed to create new {}x{} texture", new_width, new_height);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1157,14 +1156,14 @@ bool dyn_shaderc::Open()
|
||||
#endif
|
||||
if (!s_library.Open(libname.c_str(), &error))
|
||||
{
|
||||
Log_ErrorFmt("Failed to load shaderc: {}", error.GetDescription());
|
||||
ERROR_LOG("Failed to load shaderc: {}", error.GetDescription());
|
||||
return false;
|
||||
}
|
||||
|
||||
#define LOAD_FUNC(F) \
|
||||
if (!s_library.GetSymbol(#F, &F)) \
|
||||
{ \
|
||||
Log_ErrorFmt("Failed to find function {}", #F); \
|
||||
ERROR_LOG("Failed to find function {}", #F); \
|
||||
Close(); \
|
||||
return false; \
|
||||
}
|
||||
@@ -1175,7 +1174,7 @@ bool dyn_shaderc::Open()
|
||||
s_compiler = shaderc_compiler_initialize();
|
||||
if (!s_compiler)
|
||||
{
|
||||
Log_ErrorPrint("shaderc_compiler_initialize() failed");
|
||||
ERROR_LOG("shaderc_compiler_initialize() failed");
|
||||
Close();
|
||||
return false;
|
||||
}
|
||||
@@ -1233,15 +1232,15 @@ bool GPUDevice::CompileGLSLShaderToVulkanSpv(GPUShaderStage stage, std::string_v
|
||||
{
|
||||
const std::string_view errors(result ? dyn_shaderc::shaderc_result_get_error_message(result) :
|
||||
"null result object");
|
||||
Log_ErrorFmt("Failed to compile shader to SPIR-V: {}\n{}",
|
||||
dyn_shaderc::shaderc_compilation_status_to_string(status), errors);
|
||||
ERROR_LOG("Failed to compile shader to SPIR-V: {}\n{}", dyn_shaderc::shaderc_compilation_status_to_string(status),
|
||||
errors);
|
||||
DumpBadShader(source, errors);
|
||||
}
|
||||
else
|
||||
{
|
||||
const size_t num_warnings = dyn_shaderc::shaderc_result_get_num_warnings(result);
|
||||
if (num_warnings > 0)
|
||||
Log_WarningFmt("Shader compiled with warnings:\n{}", dyn_shaderc::shaderc_result_get_error_message(result));
|
||||
WARNING_LOG("Shader compiled with warnings:\n{}", dyn_shaderc::shaderc_result_get_error_message(result));
|
||||
|
||||
const size_t spirv_size = dyn_shaderc::shaderc_result_get_length(result);
|
||||
DebugAssert(spirv_size > 0);
|
||||
|
||||
@@ -98,7 +98,7 @@ void GPUShaderCache::Clear()
|
||||
|
||||
Close();
|
||||
|
||||
Log_WarningFmt("Clearing shader cache at {}.", Path::GetFileName(m_base_filename));
|
||||
WARNING_LOG("Clearing shader cache at {}.", Path::GetFileName(m_base_filename));
|
||||
|
||||
const std::string index_filename = fmt::format("{}.idx", m_base_filename);
|
||||
const std::string blob_filename = fmt::format("{}.bin", m_base_filename);
|
||||
@@ -109,25 +109,25 @@ bool GPUShaderCache::CreateNew(const std::string& index_filename, const std::str
|
||||
{
|
||||
if (FileSystem::FileExists(index_filename.c_str()))
|
||||
{
|
||||
Log_WarningFmt("Removing existing index file '{}'", Path::GetFileName(index_filename));
|
||||
WARNING_LOG("Removing existing index file '{}'", Path::GetFileName(index_filename));
|
||||
FileSystem::DeleteFile(index_filename.c_str());
|
||||
}
|
||||
if (FileSystem::FileExists(blob_filename.c_str()))
|
||||
{
|
||||
Log_WarningFmt("Removing existing blob file '{}'", Path::GetFileName(blob_filename));
|
||||
WARNING_LOG("Removing existing blob file '{}'", Path::GetFileName(blob_filename));
|
||||
FileSystem::DeleteFile(blob_filename.c_str());
|
||||
}
|
||||
|
||||
m_index_file = FileSystem::OpenCFile(index_filename.c_str(), "wb");
|
||||
if (!m_index_file) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Failed to open index file '{}' for writing", Path::GetFileName(index_filename));
|
||||
ERROR_LOG("Failed to open index file '{}' for writing", Path::GetFileName(index_filename));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (std::fwrite(&m_version, sizeof(m_version), 1, m_index_file) != 1) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Failed to write version to index file '{}'", Path::GetFileName(index_filename));
|
||||
ERROR_LOG("Failed to write version to index file '{}'", Path::GetFileName(index_filename));
|
||||
std::fclose(m_index_file);
|
||||
m_index_file = nullptr;
|
||||
FileSystem::DeleteFile(index_filename.c_str());
|
||||
@@ -137,7 +137,7 @@ bool GPUShaderCache::CreateNew(const std::string& index_filename, const std::str
|
||||
m_blob_file = FileSystem::OpenCFile(blob_filename.c_str(), "w+b");
|
||||
if (!m_blob_file) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Failed to open blob file '{}' for writing", Path::GetFileName(blob_filename));
|
||||
ERROR_LOG("Failed to open blob file '{}' for writing", Path::GetFileName(blob_filename));
|
||||
std::fclose(m_index_file);
|
||||
m_index_file = nullptr;
|
||||
FileSystem::DeleteFile(index_filename.c_str());
|
||||
@@ -156,7 +156,7 @@ bool GPUShaderCache::ReadExisting(const std::string& index_filename, const std::
|
||||
// we don't want to blow away the cache. so just continue without a cache.
|
||||
if (errno == EACCES)
|
||||
{
|
||||
Log_WarningPrint("Failed to open shader cache index with EACCES, are you running two instances?");
|
||||
WARNING_LOG("Failed to open shader cache index with EACCES, are you running two instances?");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ bool GPUShaderCache::ReadExisting(const std::string& index_filename, const std::
|
||||
u32 file_version = 0;
|
||||
if (std::fread(&file_version, sizeof(file_version), 1, m_index_file) != 1 || file_version != m_version) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Bad file/data version in '{}'", Path::GetFileName(index_filename));
|
||||
ERROR_LOG("Bad file/data version in '{}'", Path::GetFileName(index_filename));
|
||||
std::fclose(m_index_file);
|
||||
m_index_file = nullptr;
|
||||
return false;
|
||||
@@ -175,7 +175,7 @@ bool GPUShaderCache::ReadExisting(const std::string& index_filename, const std::
|
||||
m_blob_file = FileSystem::OpenCFile(blob_filename.c_str(), "a+b");
|
||||
if (!m_blob_file) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Blob file '{}' is missing", Path::GetFileName(blob_filename));
|
||||
ERROR_LOG("Blob file '{}' is missing", Path::GetFileName(blob_filename));
|
||||
std::fclose(m_index_file);
|
||||
m_index_file = nullptr;
|
||||
return false;
|
||||
@@ -193,7 +193,7 @@ bool GPUShaderCache::ReadExisting(const std::string& index_filename, const std::
|
||||
if (std::feof(m_index_file))
|
||||
break;
|
||||
|
||||
Log_ErrorFmt("Failed to read entry from '{}', corrupt file?", Path::GetFileName(index_filename));
|
||||
ERROR_LOG("Failed to read entry from '{}', corrupt file?", Path::GetFileName(index_filename));
|
||||
m_index.clear();
|
||||
std::fclose(m_blob_file);
|
||||
m_blob_file = nullptr;
|
||||
@@ -211,7 +211,7 @@ bool GPUShaderCache::ReadExisting(const std::string& index_filename, const std::
|
||||
// ensure we don't write before seeking
|
||||
std::fseek(m_index_file, 0, SEEK_END);
|
||||
|
||||
Log_DevFmt("Read {} entries from '{}'", m_index.size(), Path::GetFileName(index_filename));
|
||||
DEV_LOG("Read {} entries from '{}'", m_index.size(), Path::GetFileName(index_filename));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -260,8 +260,8 @@ bool GPUShaderCache::Lookup(const CacheIndexKey& key, ShaderBinary* binary)
|
||||
if (std::fseek(m_blob_file, iter->second.file_offset, SEEK_SET) != 0 ||
|
||||
std::fread(compressed_data.data(), iter->second.compressed_size, 1, m_blob_file) != 1) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Read {} byte {} shader from file failed", iter->second.compressed_size,
|
||||
GPUShader::GetStageName(static_cast<GPUShaderStage>(key.shader_type)));
|
||||
ERROR_LOG("Read {} byte {} shader from file failed", iter->second.compressed_size,
|
||||
GPUShader::GetStageName(static_cast<GPUShaderStage>(key.shader_type)));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ bool GPUShaderCache::Lookup(const CacheIndexKey& key, ShaderBinary* binary)
|
||||
ZSTD_decompress(binary->data(), binary->size(), compressed_data.data(), compressed_data.size());
|
||||
if (ZSTD_isError(decompress_result)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Failed to decompress shader: {}", ZSTD_getErrorName(decompress_result));
|
||||
ERROR_LOG("Failed to decompress shader: {}", ZSTD_getErrorName(decompress_result));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ bool GPUShaderCache::Insert(const CacheIndexKey& key, const void* data, u32 data
|
||||
const size_t compress_result = ZSTD_compress(compress_buffer.data(), compress_buffer.size(), data, data_size, 0);
|
||||
if (ZSTD_isError(compress_result)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Failed to compress shader: {}", ZSTD_getErrorName(compress_result));
|
||||
ERROR_LOG("Failed to compress shader: {}", ZSTD_getErrorName(compress_result));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -308,13 +308,13 @@ bool GPUShaderCache::Insert(const CacheIndexKey& key, const void* data, u32 data
|
||||
if (std::fwrite(compress_buffer.data(), compress_result, 1, m_blob_file) != 1 || std::fflush(m_blob_file) != 0 ||
|
||||
std::fwrite(&entry, sizeof(entry), 1, m_index_file) != 1 || std::fflush(m_index_file) != 0) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Failed to write {} byte {} shader blob to file", data_size,
|
||||
GPUShader::GetStageName(static_cast<GPUShaderStage>(key.shader_type)));
|
||||
ERROR_LOG("Failed to write {} byte {} shader blob to file", data_size,
|
||||
GPUShader::GetStageName(static_cast<GPUShaderStage>(key.shader_type)));
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_DevFmt("Cached compressed {} shader: {} -> {} bytes",
|
||||
GPUShader::GetStageName(static_cast<GPUShaderStage>(key.shader_type)), data_size, compress_result);
|
||||
DEV_LOG("Cached compressed {} shader: {} -> {} bytes",
|
||||
GPUShader::GetStageName(static_cast<GPUShaderStage>(key.shader_type)), data_size, compress_result);
|
||||
m_index.emplace(key, idata);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -190,39 +190,39 @@ bool GPUTexture::ValidateConfig(u32 width, u32 height, u32 layers, u32 levels, u
|
||||
{
|
||||
if (width > MAX_WIDTH || height > MAX_HEIGHT || layers > MAX_LAYERS || levels > MAX_LEVELS || samples > MAX_SAMPLES)
|
||||
{
|
||||
Log_ErrorFmt("Invalid dimensions: {}x{}x{} {} {}.", width, height, layers, levels, samples);
|
||||
ERROR_LOG("Invalid dimensions: {}x{}x{} {} {}.", width, height, layers, levels, samples);
|
||||
return false;
|
||||
}
|
||||
|
||||
const u32 max_texture_size = g_gpu_device->GetMaxTextureSize();
|
||||
if (width > max_texture_size || height > max_texture_size)
|
||||
{
|
||||
Log_ErrorFmt("Texture width ({}) or height ({}) exceeds max texture size ({}).", width, height, max_texture_size);
|
||||
ERROR_LOG("Texture width ({}) or height ({}) exceeds max texture size ({}).", width, height, max_texture_size);
|
||||
return false;
|
||||
}
|
||||
|
||||
const u32 max_samples = g_gpu_device->GetMaxMultisamples();
|
||||
if (samples > max_samples)
|
||||
{
|
||||
Log_ErrorFmt("Texture samples ({}) exceeds max samples ({}).", samples, max_samples);
|
||||
ERROR_LOG("Texture samples ({}) exceeds max samples ({}).", samples, max_samples);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (samples > 1 && levels > 1)
|
||||
{
|
||||
Log_ErrorPrint("Multisampled textures can't have mip levels.");
|
||||
ERROR_LOG("Multisampled textures can't have mip levels.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (layers > 1 && type != Type::Texture && type != Type::DynamicTexture)
|
||||
{
|
||||
Log_ErrorPrint("Texture arrays are not supported on targets.");
|
||||
ERROR_LOG("Texture arrays are not supported on targets.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (levels > 1 && type != Type::Texture && type != Type::DynamicTexture)
|
||||
{
|
||||
Log_ErrorPrint("Mipmaps are not supported on targets.");
|
||||
ERROR_LOG("Mipmaps are not supported on targets.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ bool GPUTexture::ConvertTextureDataToRGBA8(u32 width, u32 height, std::vector<u3
|
||||
}
|
||||
|
||||
default:
|
||||
[[unlikely]] Log_ErrorFmt("Unknown pixel format {}", static_cast<u32>(format));
|
||||
[[unlikely]] ERROR_LOG("Unknown pixel format {}", static_cast<u32>(format));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ add_string:
|
||||
Internal::GetTranslatedStringImpl(context, msg, &s_translation_string_cache[s_translation_string_cache_pos],
|
||||
TRANSLATION_STRING_CACHE_SIZE - 1 - s_translation_string_cache_pos)) < 0)
|
||||
{
|
||||
Log_ErrorPrint("WARNING: Clearing translation string cache, it might need to be larger.");
|
||||
ERROR_LOG("WARNING: Clearing translation string cache, it might need to be larger.");
|
||||
s_translation_string_cache_pos = 0;
|
||||
if ((len =
|
||||
Internal::GetTranslatedStringImpl(context, msg, &s_translation_string_cache[s_translation_string_cache_pos],
|
||||
|
||||
@@ -103,7 +103,7 @@ void HTTPDownloader::LockedPollRequests(std::unique_lock<std::mutex>& lock)
|
||||
Common::Timer::ConvertValueToSeconds(current_time - req->start_time) >= m_timeout)
|
||||
{
|
||||
// request timed out
|
||||
Log_ErrorFmt("Request for '{}' timed out", req->url);
|
||||
ERROR_LOG("Request for '{}' timed out", req->url);
|
||||
|
||||
req->state.store(Request::State::Cancelled);
|
||||
m_pending_http_requests.erase(m_pending_http_requests.begin() + index);
|
||||
@@ -120,7 +120,7 @@ void HTTPDownloader::LockedPollRequests(std::unique_lock<std::mutex>& lock)
|
||||
req->progress->IsCancelled())
|
||||
{
|
||||
// request timed out
|
||||
Log_ErrorFmt("Request for '{}' cancelled", req->url);
|
||||
ERROR_LOG("Request for '{}' cancelled", req->url);
|
||||
|
||||
req->state.store(Request::State::Cancelled);
|
||||
m_pending_http_requests.erase(m_pending_http_requests.begin() + index);
|
||||
@@ -153,8 +153,8 @@ void HTTPDownloader::LockedPollRequests(std::unique_lock<std::mutex>& lock)
|
||||
}
|
||||
|
||||
// request complete
|
||||
Log_VerboseFmt("Request for '{}' complete, returned status code {} and {} bytes", req->url, req->status_code,
|
||||
req->data.size());
|
||||
VERBOSE_LOG("Request for '{}' complete, returned status code {} and {} bytes", req->url, req->status_code,
|
||||
req->data.size());
|
||||
m_pending_http_requests.erase(m_pending_http_requests.begin() + index);
|
||||
|
||||
// run callback with lock unheld
|
||||
|
||||
@@ -53,7 +53,7 @@ bool HTTPDownloaderCurl::Initialize(std::string user_agent)
|
||||
});
|
||||
if (!s_curl_initialized)
|
||||
{
|
||||
Log_ErrorPrint("curl_global_init() failed");
|
||||
ERROR_LOG("curl_global_init() failed");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ bool HTTPDownloaderCurl::Initialize(std::string user_agent)
|
||||
m_multi_handle = curl_multi_init();
|
||||
if (!m_multi_handle)
|
||||
{
|
||||
Log_ErrorPrint("curl_multi_init() failed");
|
||||
ERROR_LOG("curl_multi_init() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -111,12 +111,12 @@ void HTTPDownloaderCurl::InternalPollRequests()
|
||||
sigemptyset(&new_block_mask);
|
||||
sigaddset(&new_block_mask, SIGPIPE);
|
||||
if (pthread_sigmask(SIG_BLOCK, &new_block_mask, &old_block_mask) != 0)
|
||||
Log_WarningPrint("Failed to block SIGPIPE");
|
||||
WARNING_LOG("Failed to block SIGPIPE");
|
||||
|
||||
int running_handles;
|
||||
const CURLMcode err = curl_multi_perform(m_multi_handle, &running_handles);
|
||||
if (err != CURLM_OK)
|
||||
Log_ErrorFmt("curl_multi_perform() returned {}", static_cast<int>(err));
|
||||
ERROR_LOG("curl_multi_perform() returned {}", static_cast<int>(err));
|
||||
|
||||
for (;;)
|
||||
{
|
||||
@@ -127,14 +127,14 @@ void HTTPDownloaderCurl::InternalPollRequests()
|
||||
|
||||
if (msg->msg != CURLMSG_DONE)
|
||||
{
|
||||
Log_WarningFmt("Unexpected multi message {}", static_cast<int>(msg->msg));
|
||||
WARNING_LOG("Unexpected multi message {}", static_cast<int>(msg->msg));
|
||||
continue;
|
||||
}
|
||||
|
||||
Request* req;
|
||||
if (curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, &req) != CURLE_OK)
|
||||
{
|
||||
Log_ErrorPrint("curl_easy_getinfo() failed");
|
||||
ERROR_LOG("curl_easy_getinfo() failed");
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -148,18 +148,18 @@ void HTTPDownloaderCurl::InternalPollRequests()
|
||||
if (curl_easy_getinfo(req->handle, CURLINFO_CONTENT_TYPE, &content_type) == CURLE_OK && content_type)
|
||||
req->content_type = content_type;
|
||||
|
||||
Log_DevFmt("Request for '{}' returned status code {} and {} bytes", req->url, req->status_code, req->data.size());
|
||||
DEV_LOG("Request for '{}' returned status code {} and {} bytes", req->url, req->status_code, req->data.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorFmt("Request for '{}' returned error {}", req->url, static_cast<int>(msg->data.result));
|
||||
ERROR_LOG("Request for '{}' returned error {}", req->url, static_cast<int>(msg->data.result));
|
||||
}
|
||||
|
||||
req->state.store(Request::State::Complete, std::memory_order_release);
|
||||
}
|
||||
|
||||
if (pthread_sigmask(SIG_UNBLOCK, &new_block_mask, &old_block_mask) != 0)
|
||||
Log_WarningPrint("Failed to unblock SIGPIPE");
|
||||
WARNING_LOG("Failed to unblock SIGPIPE");
|
||||
}
|
||||
|
||||
bool HTTPDownloaderCurl::StartRequest(HTTPDownloader::Request* request)
|
||||
@@ -179,14 +179,14 @@ bool HTTPDownloaderCurl::StartRequest(HTTPDownloader::Request* request)
|
||||
curl_easy_setopt(req->handle, CURLOPT_POSTFIELDS, request->post_data.c_str());
|
||||
}
|
||||
|
||||
Log_DevFmt("Started HTTP request for '{}'", req->url);
|
||||
DEV_LOG("Started HTTP request for '{}'", req->url);
|
||||
req->state.store(Request::State::Started, std::memory_order_release);
|
||||
req->start_time = Common::Timer::GetCurrentValue();
|
||||
|
||||
const CURLMcode err = curl_multi_add_handle(m_multi_handle, req->handle);
|
||||
if (err != CURLM_OK)
|
||||
{
|
||||
Log_ErrorFmt("curl_multi_add_handle() returned {}", static_cast<int>(err));
|
||||
ERROR_LOG("curl_multi_add_handle() returned {}", static_cast<int>(err));
|
||||
req->callback(HTTP_STATUS_ERROR, std::string(), req->data);
|
||||
curl_easy_cleanup(req->handle);
|
||||
delete req;
|
||||
|
||||
@@ -42,7 +42,7 @@ bool HTTPDownloaderWinHttp::Initialize(std::string user_agent)
|
||||
WINHTTP_FLAG_ASYNC);
|
||||
if (m_hSession == NULL)
|
||||
{
|
||||
Log_ErrorFmt("WinHttpOpen() failed: {}", GetLastError());
|
||||
ERROR_LOG("WinHttpOpen() failed: {}", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ bool HTTPDownloaderWinHttp::Initialize(std::string user_agent)
|
||||
if (WinHttpSetStatusCallback(m_hSession, HTTPStatusCallback, notification_flags, NULL) ==
|
||||
WINHTTP_INVALID_STATUS_CALLBACK)
|
||||
{
|
||||
Log_ErrorFmt("WinHttpSetStatusCallback() failed: {}", GetLastError());
|
||||
ERROR_LOG("WinHttpSetStatusCallback() failed: {}", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -89,17 +89,17 @@ void CALLBACK HTTPDownloaderWinHttp::HTTPStatusCallback(HINTERNET hRequest, DWOR
|
||||
case WINHTTP_CALLBACK_STATUS_REQUEST_ERROR:
|
||||
{
|
||||
const WINHTTP_ASYNC_RESULT* res = reinterpret_cast<const WINHTTP_ASYNC_RESULT*>(lpvStatusInformation);
|
||||
Log_ErrorFmt("WinHttp async function {} returned error {}", res->dwResult, res->dwError);
|
||||
ERROR_LOG("WinHttp async function {} returned error {}", res->dwResult, res->dwError);
|
||||
req->status_code = HTTP_STATUS_ERROR;
|
||||
req->state.store(Request::State::Complete);
|
||||
return;
|
||||
}
|
||||
case WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE:
|
||||
{
|
||||
Log_DevPrint("SendRequest complete");
|
||||
DEV_LOG("SendRequest complete");
|
||||
if (!WinHttpReceiveResponse(hRequest, nullptr))
|
||||
{
|
||||
Log_ErrorFmt("WinHttpReceiveResponse() failed: {}", GetLastError());
|
||||
ERROR_LOG("WinHttpReceiveResponse() failed: {}", GetLastError());
|
||||
req->status_code = HTTP_STATUS_ERROR;
|
||||
req->state.store(Request::State::Complete);
|
||||
}
|
||||
@@ -108,13 +108,13 @@ void CALLBACK HTTPDownloaderWinHttp::HTTPStatusCallback(HINTERNET hRequest, DWOR
|
||||
}
|
||||
case WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE:
|
||||
{
|
||||
Log_DevPrint("Headers available");
|
||||
DEV_LOG("Headers available");
|
||||
|
||||
DWORD buffer_size = sizeof(req->status_code);
|
||||
if (!WinHttpQueryHeaders(hRequest, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER,
|
||||
WINHTTP_HEADER_NAME_BY_INDEX, &req->status_code, &buffer_size, WINHTTP_NO_HEADER_INDEX))
|
||||
{
|
||||
Log_ErrorFmt("WinHttpQueryHeaders() for status code failed: {}", GetLastError());
|
||||
ERROR_LOG("WinHttpQueryHeaders() for status code failed: {}", GetLastError());
|
||||
req->status_code = HTTP_STATUS_ERROR;
|
||||
req->state.store(Request::State::Complete);
|
||||
return;
|
||||
@@ -126,7 +126,7 @@ void CALLBACK HTTPDownloaderWinHttp::HTTPStatusCallback(HINTERNET hRequest, DWOR
|
||||
WINHTTP_NO_HEADER_INDEX))
|
||||
{
|
||||
if (GetLastError() != ERROR_WINHTTP_HEADER_NOT_FOUND)
|
||||
Log_WarningFmt("WinHttpQueryHeaders() for content length failed: {}", GetLastError());
|
||||
WARNING_LOG("WinHttpQueryHeaders() for content length failed: {}", GetLastError());
|
||||
|
||||
req->content_length = 0;
|
||||
}
|
||||
@@ -145,14 +145,14 @@ void CALLBACK HTTPDownloaderWinHttp::HTTPStatusCallback(HINTERNET hRequest, DWOR
|
||||
}
|
||||
}
|
||||
|
||||
Log_DevFmt("Status code {}, content-length is {}", req->status_code, req->content_length);
|
||||
DEV_LOG("Status code {}, content-length is {}", req->status_code, req->content_length);
|
||||
req->data.reserve(req->content_length);
|
||||
req->state = Request::State::Receiving;
|
||||
|
||||
// start reading
|
||||
if (!WinHttpQueryDataAvailable(hRequest, nullptr) && GetLastError() != ERROR_IO_PENDING)
|
||||
{
|
||||
Log_ErrorFmt("WinHttpQueryDataAvailable() failed: {}", GetLastError());
|
||||
ERROR_LOG("WinHttpQueryDataAvailable() failed: {}", GetLastError());
|
||||
req->status_code = HTTP_STATUS_ERROR;
|
||||
req->state.store(Request::State::Complete);
|
||||
}
|
||||
@@ -166,19 +166,19 @@ void CALLBACK HTTPDownloaderWinHttp::HTTPStatusCallback(HINTERNET hRequest, DWOR
|
||||
if (bytes_available == 0)
|
||||
{
|
||||
// end of request
|
||||
Log_DevFmt("End of request '{}', {} bytes received", req->url, req->data.size());
|
||||
DEV_LOG("End of request '{}', {} bytes received", req->url, req->data.size());
|
||||
req->state.store(Request::State::Complete);
|
||||
return;
|
||||
}
|
||||
|
||||
// start the transfer
|
||||
Log_DevFmt("{} bytes available", bytes_available);
|
||||
DEV_LOG("{} bytes available", bytes_available);
|
||||
req->io_position = static_cast<u32>(req->data.size());
|
||||
req->data.resize(req->io_position + bytes_available);
|
||||
if (!WinHttpReadData(hRequest, req->data.data() + req->io_position, bytes_available, nullptr) &&
|
||||
GetLastError() != ERROR_IO_PENDING)
|
||||
{
|
||||
Log_ErrorFmt("WinHttpReadData() failed: {}", GetLastError());
|
||||
ERROR_LOG("WinHttpReadData() failed: {}", GetLastError());
|
||||
req->status_code = HTTP_STATUS_ERROR;
|
||||
req->state.store(Request::State::Complete);
|
||||
}
|
||||
@@ -187,7 +187,7 @@ void CALLBACK HTTPDownloaderWinHttp::HTTPStatusCallback(HINTERNET hRequest, DWOR
|
||||
}
|
||||
case WINHTTP_CALLBACK_STATUS_READ_COMPLETE:
|
||||
{
|
||||
Log_DevFmt("Read of {} complete", dwStatusInformationLength);
|
||||
DEV_LOG("Read of {} complete", dwStatusInformationLength);
|
||||
|
||||
const u32 new_size = req->io_position + dwStatusInformationLength;
|
||||
Assert(new_size <= req->data.size());
|
||||
@@ -196,7 +196,7 @@ void CALLBACK HTTPDownloaderWinHttp::HTTPStatusCallback(HINTERNET hRequest, DWOR
|
||||
|
||||
if (!WinHttpQueryDataAvailable(hRequest, nullptr) && GetLastError() != ERROR_IO_PENDING)
|
||||
{
|
||||
Log_ErrorFmt("WinHttpQueryDataAvailable() failed: {}", GetLastError());
|
||||
ERROR_LOG("WinHttpQueryDataAvailable() failed: {}", GetLastError());
|
||||
req->status_code = HTTP_STATUS_ERROR;
|
||||
req->state.store(Request::State::Complete);
|
||||
}
|
||||
@@ -238,7 +238,7 @@ bool HTTPDownloaderWinHttp::StartRequest(HTTPDownloader::Request* request)
|
||||
const std::wstring url_wide(StringUtil::UTF8StringToWideString(req->url));
|
||||
if (!WinHttpCrackUrl(url_wide.c_str(), static_cast<DWORD>(url_wide.size()), 0, &uc))
|
||||
{
|
||||
Log_ErrorFmt("WinHttpCrackUrl() failed: {}", GetLastError());
|
||||
ERROR_LOG("WinHttpCrackUrl() failed: {}", GetLastError());
|
||||
req->callback(HTTP_STATUS_ERROR, std::string(), req->data);
|
||||
delete req;
|
||||
return false;
|
||||
@@ -250,7 +250,7 @@ bool HTTPDownloaderWinHttp::StartRequest(HTTPDownloader::Request* request)
|
||||
req->hConnection = WinHttpConnect(m_hSession, host_name.c_str(), uc.nPort, 0);
|
||||
if (!req->hConnection)
|
||||
{
|
||||
Log_ErrorFmt("Failed to start HTTP request for '{}': {}", req->url, GetLastError());
|
||||
ERROR_LOG("Failed to start HTTP request for '{}': {}", req->url, GetLastError());
|
||||
req->callback(HTTP_STATUS_ERROR, std::string(), req->data);
|
||||
delete req;
|
||||
return false;
|
||||
@@ -262,7 +262,7 @@ bool HTTPDownloaderWinHttp::StartRequest(HTTPDownloader::Request* request)
|
||||
req->object_name.c_str(), NULL, NULL, NULL, request_flags);
|
||||
if (!req->hRequest)
|
||||
{
|
||||
Log_ErrorFmt("WinHttpOpenRequest() failed: {}", GetLastError());
|
||||
ERROR_LOG("WinHttpOpenRequest() failed: {}", GetLastError());
|
||||
WinHttpCloseHandle(req->hConnection);
|
||||
return false;
|
||||
}
|
||||
@@ -283,12 +283,12 @@ bool HTTPDownloaderWinHttp::StartRequest(HTTPDownloader::Request* request)
|
||||
|
||||
if (!result && GetLastError() != ERROR_IO_PENDING)
|
||||
{
|
||||
Log_ErrorFmt("WinHttpSendRequest() failed: {}", GetLastError());
|
||||
ERROR_LOG("WinHttpSendRequest() failed: {}", GetLastError());
|
||||
req->status_code = HTTP_STATUS_ERROR;
|
||||
req->state.store(Request::State::Complete);
|
||||
}
|
||||
|
||||
Log_DevFmt("Started HTTP request for '{}'", req->url);
|
||||
DEV_LOG("Started HTTP request for '{}'", req->url);
|
||||
req->state = Request::State::Started;
|
||||
req->start_time = Common::Timer::GetCurrentValue();
|
||||
return true;
|
||||
|
||||
+12
-12
@@ -131,7 +131,7 @@ bool RGBA8Image::LoadFromFile(std::string_view filename, std::FILE* fp)
|
||||
const FormatHandler* handler = GetFormatHandler(extension);
|
||||
if (!handler || !handler->file_loader)
|
||||
{
|
||||
Log_ErrorFmt("Unknown extension '{}'", extension);
|
||||
ERROR_LOG("Unknown extension '{}'", extension);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ bool RGBA8Image::LoadFromBuffer(std::string_view filename, const void* buffer, s
|
||||
const FormatHandler* handler = GetFormatHandler(extension);
|
||||
if (!handler || !handler->buffer_loader)
|
||||
{
|
||||
Log_ErrorFmt("Unknown extension '{}'", extension);
|
||||
ERROR_LOG("Unknown extension '{}'", extension);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ bool RGBA8Image::SaveToFile(std::string_view filename, std::FILE* fp, u8 quality
|
||||
const FormatHandler* handler = GetFormatHandler(extension);
|
||||
if (!handler || !handler->file_saver)
|
||||
{
|
||||
Log_ErrorFmt("Unknown extension '{}'", extension);
|
||||
ERROR_LOG("Unknown extension '{}'", extension);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ std::optional<std::vector<u8>> RGBA8Image::SaveToBuffer(std::string_view filenam
|
||||
const FormatHandler* handler = GetFormatHandler(extension);
|
||||
if (!handler || !handler->file_saver)
|
||||
{
|
||||
Log_ErrorFmt("Unknown extension '{}'", extension);
|
||||
ERROR_LOG("Unknown extension '{}'", extension);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -438,7 +438,7 @@ static bool HandleJPEGError(JPEGErrorHandler* eh)
|
||||
JPEGErrorHandler* eh = (JPEGErrorHandler*)cinfo->err;
|
||||
char msg[JMSG_LENGTH_MAX];
|
||||
eh->err.format_message(cinfo, msg);
|
||||
Log_ErrorFmt("libjpeg fatal error: {}", msg);
|
||||
ERROR_LOG("libjpeg fatal error: {}", msg);
|
||||
longjmp(eh->jbuf, 1);
|
||||
};
|
||||
|
||||
@@ -465,13 +465,13 @@ static bool WrapJPEGDecompress(RGBA8Image* image, T setup_func)
|
||||
const int herr = jpeg_read_header(&info, TRUE);
|
||||
if (herr != JPEG_HEADER_OK)
|
||||
{
|
||||
Log_ErrorFmt("jpeg_read_header() returned {}", herr);
|
||||
ERROR_LOG("jpeg_read_header() returned {}", herr);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (info.image_width == 0 || info.image_height == 0 || info.num_components < 3)
|
||||
{
|
||||
Log_ErrorFmt("Invalid image dimensions: {}x{}x{}", info.image_width, info.image_height, info.num_components);
|
||||
ERROR_LOG("Invalid image dimensions: {}x{}x{}", info.image_width, info.image_height, info.num_components);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -480,7 +480,7 @@ static bool WrapJPEGDecompress(RGBA8Image* image, T setup_func)
|
||||
|
||||
if (!jpeg_start_decompress(&info))
|
||||
{
|
||||
Log_ErrorFmt("jpeg_start_decompress() returned failure");
|
||||
ERROR_LOG("jpeg_start_decompress() returned failure");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -493,7 +493,7 @@ static bool WrapJPEGDecompress(RGBA8Image* image, T setup_func)
|
||||
{
|
||||
if (jpeg_read_scanlines(&info, scanline_buffer, 1) != 1)
|
||||
{
|
||||
Log_ErrorFmt("jpeg_read_scanlines() failed at row {}", y);
|
||||
ERROR_LOG("jpeg_read_scanlines() failed at row {}", y);
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
@@ -622,7 +622,7 @@ static bool WrapJPEGCompress(const RGBA8Image& image, u8 quality, T setup_func)
|
||||
|
||||
if (jpeg_write_scanlines(&info, scanline_buffer, 1) != 1)
|
||||
{
|
||||
Log_ErrorFmt("jpeg_write_scanlines() failed at row {}", y);
|
||||
ERROR_LOG("jpeg_write_scanlines() failed at row {}", y);
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
@@ -723,7 +723,7 @@ bool WebPBufferLoader(RGBA8Image* image, const void* buffer, size_t buffer_size)
|
||||
int width, height;
|
||||
if (!WebPGetInfo(static_cast<const u8*>(buffer), buffer_size, &width, &height) || width <= 0 || height <= 0)
|
||||
{
|
||||
Log_ErrorPrint("WebPGetInfo() failed");
|
||||
ERROR_LOG("WebPGetInfo() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -732,7 +732,7 @@ bool WebPBufferLoader(RGBA8Image* image, const void* buffer, size_t buffer_size)
|
||||
if (!WebPDecodeRGBAInto(static_cast<const u8*>(buffer), buffer_size, reinterpret_cast<u8*>(pixels.data()),
|
||||
sizeof(u32) * pixels.size(), sizeof(u32) * static_cast<u32>(width)))
|
||||
{
|
||||
Log_ErrorPrint("WebPDecodeRGBAInto() failed");
|
||||
ERROR_LOG("WebPDecodeRGBAInto() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -219,7 +219,7 @@ bool ImGuiFullscreen::Initialize(const char* placeholder_image_path)
|
||||
s_placeholder_texture = LoadTexture(placeholder_image_path);
|
||||
if (!s_placeholder_texture)
|
||||
{
|
||||
Log_ErrorFmt("Missing placeholder texture '{}', cannot continue", placeholder_image_path);
|
||||
ERROR_LOG("Missing placeholder texture '{}', cannot continue", placeholder_image_path);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -295,11 +295,11 @@ std::optional<RGBA8Image> ImGuiFullscreen::LoadTextureImage(std::string_view pat
|
||||
{
|
||||
image = RGBA8Image();
|
||||
if (!image->LoadFromFile(path_str.c_str(), fp.get()))
|
||||
Log_ErrorFmt("Failed to read texture file '{}'", path);
|
||||
ERROR_LOG("Failed to read texture file '{}'", path);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorFmt("Failed to open texture file '{}': {}", path, error.GetDescription());
|
||||
ERROR_LOG("Failed to open texture file '{}': {}", path, error.GetDescription());
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -310,13 +310,13 @@ std::optional<RGBA8Image> ImGuiFullscreen::LoadTextureImage(std::string_view pat
|
||||
image = RGBA8Image();
|
||||
if (!image->LoadFromBuffer(path, data->data(), data->size()))
|
||||
{
|
||||
Log_ErrorFmt("Failed to read texture resource '{}'", path);
|
||||
ERROR_LOG("Failed to read texture resource '{}'", path);
|
||||
image.reset();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorFmt("Failed to open texture resource '{}'", path);
|
||||
ERROR_LOG("Failed to open texture resource '{}'", path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,11 +330,11 @@ std::shared_ptr<GPUTexture> ImGuiFullscreen::UploadTexture(std::string_view path
|
||||
GPUTexture::Format::RGBA8, image.GetPixels(), image.GetPitch());
|
||||
if (!texture)
|
||||
{
|
||||
Log_ErrorFmt("failed to create {}x{} texture for resource", image.GetWidth(), image.GetHeight());
|
||||
ERROR_LOG("failed to create {}x{} texture for resource", image.GetWidth(), image.GetHeight());
|
||||
return {};
|
||||
}
|
||||
|
||||
Log_DevFmt("Uploaded texture resource '{}' ({}x{})", path, image.GetWidth(), image.GetHeight());
|
||||
DEV_LOG("Uploaded texture resource '{}' ({}x{})", path, image.GetWidth(), image.GetHeight());
|
||||
return std::shared_ptr<GPUTexture>(texture.release(), GPUDevice::PooledTextureDeleter());
|
||||
}
|
||||
|
||||
|
||||
@@ -663,7 +663,7 @@ bool ImGuiManager::AddFullscreenFontsIfMissing()
|
||||
|
||||
if (!AddImGuiFonts(true))
|
||||
{
|
||||
Log_ErrorPrint("Failed to lazily allocate fullscreen fonts.");
|
||||
ERROR_LOG("Failed to lazily allocate fullscreen fonts.");
|
||||
AddImGuiFonts(false);
|
||||
}
|
||||
|
||||
@@ -686,9 +686,9 @@ void Host::AddOSDMessage(std::string message, float duration /*= 2.0f*/)
|
||||
void Host::AddKeyedOSDMessage(std::string key, std::string message, float duration /* = 2.0f */)
|
||||
{
|
||||
if (!key.empty())
|
||||
Log_InfoFmt("OSD [{}]: {}", key, message);
|
||||
INFO_LOG("OSD [{}]: {}", key, message);
|
||||
else
|
||||
Log_InfoFmt("OSD: {}", message);
|
||||
INFO_LOG("OSD: {}", message);
|
||||
|
||||
if (!ImGuiManager::s_show_osd_messages)
|
||||
return;
|
||||
@@ -1045,7 +1045,7 @@ void ImGuiManager::UpdateSoftwareCursorTexture(u32 index)
|
||||
RGBA8Image image;
|
||||
if (!image.LoadFromFile(sc.image_path.c_str()))
|
||||
{
|
||||
Log_ErrorFmt("Failed to load software cursor {} image '{}'", index, sc.image_path);
|
||||
ERROR_LOG("Failed to load software cursor {} image '{}'", index, sc.image_path);
|
||||
return;
|
||||
}
|
||||
g_gpu_device->RecycleTexture(std::move(sc.texture));
|
||||
@@ -1053,8 +1053,8 @@ void ImGuiManager::UpdateSoftwareCursorTexture(u32 index)
|
||||
GPUTexture::Format::RGBA8, image.GetPixels(), image.GetPitch());
|
||||
if (!sc.texture)
|
||||
{
|
||||
Log_ErrorFmt("Failed to upload {}x{} software cursor {} image '{}'", image.GetWidth(), image.GetHeight(), index,
|
||||
sc.image_path);
|
||||
ERROR_LOG("Failed to upload {}x{} software cursor {} image '{}'", image.GetWidth(), image.GetHeight(), index,
|
||||
sc.image_path);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ bool INISettingsInterface::Save(Error* error /* = nullptr */)
|
||||
|
||||
if (err != SI_OK)
|
||||
{
|
||||
Log_WarningFmt("Failed to save settings to '{}'.", m_filename);
|
||||
WARNING_LOG("Failed to save settings to '{}'.", m_filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ std::vector<std::pair<std::string, std::string>> INISettingsInterface::GetKeyVal
|
||||
{
|
||||
if (!m_ini.GetAllValues(section, key.pItem, values)) // [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrint("Got no values for a key returned from GetAllKeys!");
|
||||
ERROR_LOG("Got no values for a key returned from GetAllKeys!");
|
||||
continue;
|
||||
}
|
||||
for (const Entry& value : values)
|
||||
|
||||
@@ -222,7 +222,7 @@ bool InputManager::SplitBinding(std::string_view binding, std::string_view* sour
|
||||
const std::string_view::size_type slash_pos = binding.find('/');
|
||||
if (slash_pos == std::string_view::npos)
|
||||
{
|
||||
Log_WarningFmt("Malformed binding: '{}'", binding);
|
||||
WARNING_LOG("Malformed binding: '{}'", binding);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -493,7 +493,7 @@ void InputManager::AddBinding(std::string_view binding, const InputEventHandler&
|
||||
std::optional<InputBindingKey> key = ParseInputBindingKey(chord_binding);
|
||||
if (!key.has_value())
|
||||
{
|
||||
Log_ErrorFmt("Invalid binding: '{}'", binding);
|
||||
ERROR_LOG("Invalid binding: '{}'", binding);
|
||||
ibinding.reset();
|
||||
break;
|
||||
}
|
||||
@@ -506,7 +506,7 @@ void InputManager::AddBinding(std::string_view binding, const InputEventHandler&
|
||||
|
||||
if (ibinding->num_keys == MAX_KEYS_PER_BINDING)
|
||||
{
|
||||
Log_ErrorFmt("Too many chord parts, max is {} ({})", static_cast<unsigned>(MAX_KEYS_PER_BINDING), binding.size());
|
||||
ERROR_LOG("Too many chord parts, max is {} ({})", static_cast<unsigned>(MAX_KEYS_PER_BINDING), binding.size());
|
||||
ibinding.reset();
|
||||
break;
|
||||
}
|
||||
@@ -861,7 +861,7 @@ void InputManager::AddPadBindings(SettingsInterface& si, const std::string& sect
|
||||
break;
|
||||
|
||||
default:
|
||||
Log_ErrorFmt("Unhandled binding info type {}", static_cast<u32>(bi.type));
|
||||
ERROR_LOG("Unhandled binding info type {}", static_cast<u32>(bi.type));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1378,7 +1378,7 @@ static u32 TryMapGenericMapping(SettingsInterface& si, const std::string& sectio
|
||||
|
||||
if (found_mapping)
|
||||
{
|
||||
Log_InfoFmt("Map {}/{} to '{}'", section, bind_name, *found_mapping);
|
||||
INFO_LOG("Map {}/{} to '{}'", section, bind_name, *found_mapping);
|
||||
si.SetStringValue(section.c_str(), bind_name, found_mapping->c_str());
|
||||
return 1;
|
||||
}
|
||||
@@ -1605,7 +1605,7 @@ void InputManager::LoadMacroButtonConfig(SettingsInterface& si, const std::strin
|
||||
}
|
||||
if (!binding)
|
||||
{
|
||||
Log_DevFmt("Invalid bind '{}' in macro button {} for pad {}", button, pad, i);
|
||||
DEV_LOG("Invalid bind '{}' in macro button {} for pad {}", button, pad, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1927,7 +1927,7 @@ void InputManager::UpdateInputSourceState(SettingsInterface& si, std::unique_loc
|
||||
std::unique_ptr<InputSource> source(factory_function());
|
||||
if (!source->Initialize(si, settings_lock))
|
||||
{
|
||||
Log_ErrorFmt("Source '{}' failed to initialize.", InputManager::InputSourceToString(type));
|
||||
ERROR_LOG("Source '{}' failed to initialize.", InputManager::InputSourceToString(type));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ bool IsoReader::ReadPVD(Error* error)
|
||||
|
||||
m_pvd_lba = START_SECTOR + i;
|
||||
std::memcpy(&m_pvd, buffer, sizeof(ISOPrimaryVolumeDescriptor));
|
||||
Log_DevFmt("ISOReader: PVD found at index {}", i);
|
||||
DEV_LOG("ISOReader: PVD found at index {}", i);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,19 +61,19 @@ bool JitCodeBuffer::Allocate(u32 size /* = 64 * 1024 * 1024 */, u32 far_code_siz
|
||||
for (u32 offset = 0; offset < steps; offset++)
|
||||
{
|
||||
const u8* addr = max_address - (offset * step);
|
||||
Log_VerboseFmt("Trying {} (base {}, offset {}, displacement 0x{:X})", static_cast<const void*>(addr),
|
||||
static_cast<const void*>(base), offset, static_cast<ptrdiff_t>(addr - base));
|
||||
VERBOSE_LOG("Trying {} (base {}, offset {}, displacement 0x{:X})", static_cast<const void*>(addr),
|
||||
static_cast<const void*>(base), offset, static_cast<ptrdiff_t>(addr - base));
|
||||
if (TryAllocateAt(addr))
|
||||
break;
|
||||
}
|
||||
if (m_code_ptr)
|
||||
{
|
||||
Log_InfoFmt("Allocated JIT buffer of size {} at {} (0x{:X} bytes away)", m_total_size,
|
||||
static_cast<void*>(m_code_ptr), static_cast<ptrdiff_t>(m_code_ptr - base));
|
||||
INFO_LOG("Allocated JIT buffer of size {} at {} (0x{:X} bytes away)", m_total_size, static_cast<void*>(m_code_ptr),
|
||||
static_cast<ptrdiff_t>(m_code_ptr - base));
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorPrint("Failed to allocate JIT buffer in range, expect crashes.");
|
||||
ERROR_LOG("Failed to allocate JIT buffer in range, expect crashes.");
|
||||
if (!TryAllocateAt(nullptr))
|
||||
return false;
|
||||
}
|
||||
@@ -104,7 +104,7 @@ bool JitCodeBuffer::TryAllocateAt(const void* addr)
|
||||
if (!m_code_ptr)
|
||||
{
|
||||
if (!addr)
|
||||
Log_ErrorFmt("VirtualAlloc(RWX, %u) for internal buffer failed: {}", m_total_size, GetLastError());
|
||||
ERROR_LOG("VirtualAlloc(RWX, %u) for internal buffer failed: {}", m_total_size, GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -134,14 +134,14 @@ bool JitCodeBuffer::TryAllocateAt(const void* addr)
|
||||
if (!m_code_ptr)
|
||||
{
|
||||
if (!addr)
|
||||
Log_ErrorFmt("mmap(RWX, %u) for internal buffer failed: {}", m_total_size, errno);
|
||||
ERROR_LOG("mmap(RWX, %u) for internal buffer failed: {}", m_total_size, errno);
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (addr && m_code_ptr != addr)
|
||||
{
|
||||
if (munmap(m_code_ptr, m_total_size) != 0)
|
||||
Log_ErrorFmt("Failed to munmap() incorrectly hinted allocation: {}", errno);
|
||||
ERROR_LOG("Failed to munmap() incorrectly hinted allocation: {}", errno);
|
||||
m_code_ptr = nullptr;
|
||||
return false;
|
||||
}
|
||||
@@ -163,7 +163,7 @@ bool JitCodeBuffer::Initialize(void* buffer, u32 size, u32 far_code_size /* = 0
|
||||
DWORD old_protect = 0;
|
||||
if (!VirtualProtect(buffer, size, PAGE_EXECUTE_READWRITE, &old_protect))
|
||||
{
|
||||
Log_ErrorFmt("VirtualProtect(RWX) for external buffer failed: {}", GetLastError());
|
||||
ERROR_LOG("VirtualProtect(RWX) for external buffer failed: {}", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ bool JitCodeBuffer::Initialize(void* buffer, u32 size, u32 far_code_size /* = 0
|
||||
if (!VirtualProtect(buffer, guard_size, PAGE_NOACCESS, &old_guard_protect) ||
|
||||
!VirtualProtect(guard_at_end, guard_size, PAGE_NOACCESS, &old_guard_protect))
|
||||
{
|
||||
Log_ErrorFmt("VirtualProtect(NOACCESS) for guard page failed: {}", GetLastError());
|
||||
ERROR_LOG("VirtualProtect(NOACCESS) for guard page failed: {}", GetLastError());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -184,7 +184,7 @@ bool JitCodeBuffer::Initialize(void* buffer, u32 size, u32 far_code_size /* = 0
|
||||
#elif defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__) || defined(__HAIKU__) || defined(__FreeBSD__)
|
||||
if (mprotect(buffer, size, PROT_READ | PROT_WRITE | PROT_EXEC) != 0)
|
||||
{
|
||||
Log_ErrorFmt("mprotect(RWX) for external buffer failed: {}", errno);
|
||||
ERROR_LOG("mprotect(RWX) for external buffer failed: {}", errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ bool JitCodeBuffer::Initialize(void* buffer, u32 size, u32 far_code_size /* = 0
|
||||
u8* guard_at_end = (static_cast<u8*>(buffer) + size) - guard_size;
|
||||
if (mprotect(buffer, guard_size, PROT_NONE) != 0 || mprotect(guard_at_end, guard_size, PROT_NONE) != 0)
|
||||
{
|
||||
Log_ErrorFmt("mprotect(NONE) for guard page failed: {}", errno);
|
||||
ERROR_LOG("mprotect(NONE) for guard page failed: {}", errno);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -229,10 +229,10 @@ void JitCodeBuffer::Destroy()
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
if (!VirtualFree(m_code_ptr, 0, MEM_RELEASE))
|
||||
Log_ErrorFmt("Failed to free code pointer %p", static_cast<void*>(m_code_ptr));
|
||||
ERROR_LOG("Failed to free code pointer %p", static_cast<void*>(m_code_ptr));
|
||||
#elif defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__) || defined(__HAIKU__) || defined(__FreeBSD__)
|
||||
if (munmap(m_code_ptr, m_total_size) != 0)
|
||||
Log_ErrorFmt("Failed to free code pointer %p", static_cast<void*>(m_code_ptr));
|
||||
ERROR_LOG("Failed to free code pointer %p", static_cast<void*>(m_code_ptr));
|
||||
#endif
|
||||
}
|
||||
else if (m_code_ptr)
|
||||
@@ -240,10 +240,10 @@ void JitCodeBuffer::Destroy()
|
||||
#if defined(_WIN32)
|
||||
DWORD old_protect = 0;
|
||||
if (!VirtualProtect(m_code_ptr, m_total_size, m_old_protection, &old_protect))
|
||||
Log_ErrorFmt("Failed to restore protection on %p", static_cast<void*>(m_code_ptr));
|
||||
ERROR_LOG("Failed to restore protection on %p", static_cast<void*>(m_code_ptr));
|
||||
#else
|
||||
if (mprotect(m_code_ptr, m_total_size, m_old_protection) != 0)
|
||||
Log_ErrorFmt("Failed to restore protection on %p", static_cast<void*>(m_code_ptr));
|
||||
ERROR_LOG("Failed to restore protection on %p", static_cast<void*>(m_code_ptr));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
+36
-40
@@ -68,15 +68,11 @@ static NSString* StringViewToNSString(std::string_view str)
|
||||
encoding:NSUTF8StringEncoding];
|
||||
}
|
||||
|
||||
static void LogNSError(NSError* error, const char* desc, ...)
|
||||
static void LogNSError(NSError* error, std::string_view message)
|
||||
{
|
||||
std::va_list ap;
|
||||
va_start(ap, desc);
|
||||
Log::Writev("MetalDevice", "", LOGLEVEL_ERROR, desc, ap);
|
||||
va_end(ap);
|
||||
|
||||
Log::Writef("MetalDevice", "", LOGLEVEL_ERROR, " NSError Code: %u", static_cast<u32>(error.code));
|
||||
Log::Writef("MetalDevice", "", LOGLEVEL_ERROR, " NSError Description: %s", [error.description UTF8String]);
|
||||
Log::FastWrite("MetalDevice", LOGLEVEL_ERROR, message);
|
||||
Log::FastWrite("MetalDevice", LOGLEVEL_ERROR, " NSError Code: {}", static_cast<u32>(error.code));
|
||||
Log::FastWrite("MetalDevice", LOGLEVEL_ERROR, " NSError Description: {}", [error.description UTF8String]);
|
||||
}
|
||||
|
||||
static GPUTexture::Format GetTextureFormatForMTLFormat(MTLPixelFormat fmt)
|
||||
@@ -156,7 +152,7 @@ bool MetalDevice::CreateDevice(std::string_view adapter, bool threaded_presentat
|
||||
}
|
||||
|
||||
if (device == nil)
|
||||
Log_ErrorFmt("Failed to find device named '{}'. Trying default.", adapter);
|
||||
ERROR_LOG("Failed to find device named '{}'. Trying default.", adapter);
|
||||
}
|
||||
|
||||
if (device == nil)
|
||||
@@ -178,7 +174,7 @@ bool MetalDevice::CreateDevice(std::string_view adapter, bool threaded_presentat
|
||||
|
||||
m_device = [device retain];
|
||||
m_queue = [queue retain];
|
||||
Log_InfoFmt("Metal Device: {}", [[m_device name] UTF8String]);
|
||||
INFO_LOG("Metal Device: {}", [[m_device name] UTF8String]);
|
||||
|
||||
SetFeatures(disabled_features);
|
||||
|
||||
@@ -381,7 +377,7 @@ bool MetalDevice::CreateLayer()
|
||||
RunOnMainThread([this]() {
|
||||
@autoreleasepool
|
||||
{
|
||||
Log_InfoFmt("Creating a {}x{} Metal layer.", m_window_info.surface_width, m_window_info.surface_height);
|
||||
INFO_LOG("Creating a {}x{} Metal layer.", m_window_info.surface_width, m_window_info.surface_height);
|
||||
const auto size =
|
||||
CGSizeMake(static_cast<float>(m_window_info.surface_width), static_cast<float>(m_window_info.surface_height));
|
||||
m_layer = [CAMetalLayer layer];
|
||||
@@ -393,12 +389,12 @@ bool MetalDevice::CreateLayer()
|
||||
m_window_info.surface_format = GetTextureFormatForMTLFormat(layer_fmt);
|
||||
if (m_window_info.surface_format == GPUTexture::Format::Unknown)
|
||||
{
|
||||
Log_ErrorFmt("Invalid pixel format {} in layer, using BGRA8.", static_cast<u32>(layer_fmt));
|
||||
ERROR_LOG("Invalid pixel format {} in layer, using BGRA8.", static_cast<u32>(layer_fmt));
|
||||
[m_layer setPixelFormat:MTLPixelFormatBGRA8Unorm];
|
||||
m_window_info.surface_format = GPUTexture::Format::BGRA8;
|
||||
}
|
||||
|
||||
Log_VerboseFmt("Metal layer pixel format is {}.", GPUTexture::GetFormatName(m_window_info.surface_format));
|
||||
VERBOSE_LOG("Metal layer pixel format is {}.", GPUTexture::GetFormatName(m_window_info.surface_format));
|
||||
|
||||
NSView* view = GetWindowView();
|
||||
[view setWantsLayer:TRUE];
|
||||
@@ -469,7 +465,7 @@ bool MetalDevice::UpdateWindow()
|
||||
|
||||
if (m_window_info.type != WindowInfo::Type::Surfaceless && !CreateLayer())
|
||||
{
|
||||
Log_ErrorPrint("Failed to create layer on updated window");
|
||||
ERROR_LOG("Failed to create layer on updated window");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -515,7 +511,7 @@ bool MetalDevice::CreateBuffers()
|
||||
!m_uniform_buffer.Create(m_device, UNIFORM_BUFFER_SIZE) ||
|
||||
!m_texture_upload_buffer.Create(m_device, TEXTURE_STREAM_BUFFER_SIZE))
|
||||
{
|
||||
Log_ErrorPrint("Failed to create vertex/index/uniform buffers.");
|
||||
ERROR_LOG("Failed to create vertex/index/uniform buffers.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -625,7 +621,7 @@ std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromMSL(GPUShaderStage stage
|
||||
id<MTLLibrary> library = [m_device newLibraryWithSource:ns_source options:nil error:&error];
|
||||
if (!library)
|
||||
{
|
||||
LogNSError(error, "Failed to compile %s shader", GPUShader::GetStageName(stage));
|
||||
LogNSError(error, TinyString::from_format("Failed to compile {} shader", GPUShader::GetStageName(stage)));
|
||||
|
||||
const char* utf_error = [error.description UTF8String];
|
||||
DumpBadShader(source, fmt::format("Error {}: {}", static_cast<u32>(error.code), utf_error ? utf_error : ""));
|
||||
@@ -635,7 +631,7 @@ std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromMSL(GPUShaderStage stage
|
||||
id<MTLFunction> function = [library newFunctionWithName:StringViewToNSString(entry_point)];
|
||||
if (!function)
|
||||
{
|
||||
Log_ErrorPrint("Failed to get main function in compiled library");
|
||||
ERROR_LOG("Failed to get main function in compiled library");
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -666,19 +662,19 @@ std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromSource(GPUShaderStage st
|
||||
spvc_result sres;
|
||||
if ((sres = spvc_context_create(&sctx)) != SPVC_SUCCESS)
|
||||
{
|
||||
Log_ErrorFmt("spvc_context_create() failed: {}", static_cast<int>(sres));
|
||||
ERROR_LOG("spvc_context_create() failed: {}", static_cast<int>(sres));
|
||||
return {};
|
||||
}
|
||||
|
||||
const ScopedGuard sctx_guard = [&sctx]() { spvc_context_destroy(sctx); };
|
||||
|
||||
spvc_context_set_error_callback(
|
||||
sctx, [](void*, const char* error) { Log_ErrorFmt("SPIRV-Cross reported an error: {}", error); }, nullptr);
|
||||
sctx, [](void*, const char* error) { ERROR_LOG("SPIRV-Cross reported an error: {}", error); }, nullptr);
|
||||
|
||||
spvc_parsed_ir sir;
|
||||
if ((sres = spvc_context_parse_spirv(sctx, reinterpret_cast<const u32*>(dest_binary->data()), dest_binary->size() / 4, &sir)) != SPVC_SUCCESS)
|
||||
{
|
||||
Log_ErrorFmt("spvc_context_parse_spirv() failed: {}", static_cast<int>(sres));
|
||||
ERROR_LOG("spvc_context_parse_spirv() failed: {}", static_cast<int>(sres));
|
||||
DumpBadShader(source, std::string_view());
|
||||
return {};
|
||||
}
|
||||
@@ -687,21 +683,21 @@ std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromSource(GPUShaderStage st
|
||||
if ((sres = spvc_context_create_compiler(sctx, SPVC_BACKEND_MSL, sir, SPVC_CAPTURE_MODE_TAKE_OWNERSHIP,
|
||||
&scompiler)) != SPVC_SUCCESS)
|
||||
{
|
||||
Log_ErrorFmt("spvc_context_create_compiler() failed: {}", static_cast<int>(sres));
|
||||
ERROR_LOG("spvc_context_create_compiler() failed: {}", static_cast<int>(sres));
|
||||
return {};
|
||||
}
|
||||
|
||||
spvc_compiler_options soptions;
|
||||
if ((sres = spvc_compiler_create_compiler_options(scompiler, &soptions)) != SPVC_SUCCESS)
|
||||
{
|
||||
Log_ErrorFmt("spvc_compiler_create_compiler_options() failed: {}", static_cast<int>(sres));
|
||||
ERROR_LOG("spvc_compiler_create_compiler_options() failed: {}", static_cast<int>(sres));
|
||||
return {};
|
||||
}
|
||||
|
||||
if ((sres = spvc_compiler_options_set_bool(soptions, SPVC_COMPILER_OPTION_MSL_PAD_FRAGMENT_OUTPUT_COMPONENTS,
|
||||
true)) != SPVC_SUCCESS)
|
||||
{
|
||||
Log_ErrorFmt("spvc_compiler_options_set_bool(SPVC_COMPILER_OPTION_MSL_PAD_FRAGMENT_OUTPUT_COMPONENTS) failed: {}",
|
||||
ERROR_LOG("spvc_compiler_options_set_bool(SPVC_COMPILER_OPTION_MSL_PAD_FRAGMENT_OUTPUT_COMPONENTS) failed: {}",
|
||||
static_cast<int>(sres));
|
||||
return {};
|
||||
}
|
||||
@@ -709,7 +705,7 @@ std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromSource(GPUShaderStage st
|
||||
if ((sres = spvc_compiler_options_set_bool(soptions, SPVC_COMPILER_OPTION_MSL_FRAMEBUFFER_FETCH_SUBPASS,
|
||||
m_features.framebuffer_fetch)) != SPVC_SUCCESS)
|
||||
{
|
||||
Log_ErrorFmt("spvc_compiler_options_set_bool(SPVC_COMPILER_OPTION_MSL_FRAMEBUFFER_FETCH_SUBPASS) failed: {}",
|
||||
ERROR_LOG("spvc_compiler_options_set_bool(SPVC_COMPILER_OPTION_MSL_FRAMEBUFFER_FETCH_SUBPASS) failed: {}",
|
||||
static_cast<int>(sres));
|
||||
return {};
|
||||
}
|
||||
@@ -718,7 +714,7 @@ std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromSource(GPUShaderStage st
|
||||
((sres = spvc_compiler_options_set_uint(soptions, SPVC_COMPILER_OPTION_MSL_VERSION,
|
||||
SPVC_MAKE_MSL_VERSION(2, 3, 0))) != SPVC_SUCCESS))
|
||||
{
|
||||
Log_ErrorFmt("spvc_compiler_options_set_uint(SPVC_COMPILER_OPTION_MSL_VERSION) failed: {}", static_cast<int>(sres));
|
||||
ERROR_LOG("spvc_compiler_options_set_uint(SPVC_COMPILER_OPTION_MSL_VERSION) failed: {}", static_cast<int>(sres));
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -735,7 +731,7 @@ std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromSource(GPUShaderStage st
|
||||
|
||||
if ((sres = spvc_compiler_msl_add_resource_binding(scompiler, &rb)) != SPVC_SUCCESS)
|
||||
{
|
||||
Log_ErrorFmt("spvc_compiler_msl_add_resource_binding() failed: {}", static_cast<int>(sres));
|
||||
ERROR_LOG("spvc_compiler_msl_add_resource_binding() failed: {}", static_cast<int>(sres));
|
||||
return {};
|
||||
}
|
||||
}
|
||||
@@ -747,7 +743,7 @@ std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromSource(GPUShaderStage st
|
||||
|
||||
if ((sres = spvc_compiler_msl_add_resource_binding(scompiler, &rb)) != SPVC_SUCCESS)
|
||||
{
|
||||
Log_ErrorFmt("spvc_compiler_msl_add_resource_binding() for FB failed: {}", static_cast<int>(sres));
|
||||
ERROR_LOG("spvc_compiler_msl_add_resource_binding() for FB failed: {}", static_cast<int>(sres));
|
||||
return {};
|
||||
}
|
||||
}
|
||||
@@ -755,14 +751,14 @@ std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromSource(GPUShaderStage st
|
||||
|
||||
if ((sres = spvc_compiler_install_compiler_options(scompiler, soptions)) != SPVC_SUCCESS)
|
||||
{
|
||||
Log_ErrorFmt("spvc_compiler_install_compiler_options() failed: {}", static_cast<int>(sres));
|
||||
ERROR_LOG("spvc_compiler_install_compiler_options() failed: {}", static_cast<int>(sres));
|
||||
return {};
|
||||
}
|
||||
|
||||
const char* msl;
|
||||
if ((sres = spvc_compiler_compile(scompiler, &msl)) != SPVC_SUCCESS)
|
||||
{
|
||||
Log_ErrorFmt("spvc_compiler_compile() failed: {}", static_cast<int>(sres));
|
||||
ERROR_LOG("spvc_compiler_compile() failed: {}", static_cast<int>(sres));
|
||||
DumpBadShader(source, std::string_view());
|
||||
return {};
|
||||
}
|
||||
@@ -770,7 +766,7 @@ std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromSource(GPUShaderStage st
|
||||
const size_t msl_length = msl ? std::strlen(msl) : 0;
|
||||
if (msl_length == 0)
|
||||
{
|
||||
Log_ErrorPrint("Failed to compile SPIR-V to MSL.");
|
||||
ERROR_LOG("Failed to compile SPIR-V to MSL.");
|
||||
DumpBadShader(source, std::string_view());
|
||||
return {};
|
||||
}
|
||||
@@ -835,7 +831,7 @@ id<MTLDepthStencilState> MetalDevice::GetDepthState(const GPUPipeline::DepthStat
|
||||
id<MTLDepthStencilState> state = [m_device newDepthStencilStateWithDescriptor:desc];
|
||||
m_depth_states.emplace(ds.key, state);
|
||||
if (state == nil) [[unlikely]]
|
||||
Log_ErrorPrint("Failed to create depth-stencil state.");
|
||||
ERROR_LOG("Failed to create depth-stencil state.");
|
||||
|
||||
return state;
|
||||
}
|
||||
@@ -1216,7 +1212,7 @@ std::unique_ptr<GPUTexture> MetalDevice::CreateTexture(u32 width, u32 height, u3
|
||||
id<MTLTexture> tex = [m_device newTextureWithDescriptor:desc];
|
||||
if (tex == nil)
|
||||
{
|
||||
Log_ErrorFmt("Failed to create {}x{} texture.", width, height);
|
||||
ERROR_LOG("Failed to create {}x{} texture.", width, height);
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -1269,7 +1265,7 @@ std::unique_ptr<MetalDownloadTexture> MetalDownloadTexture::Create(u32 width, u3
|
||||
buffer = [[dev.m_device newBufferWithLength:buffer_size options:options] retain];
|
||||
if (buffer == nil)
|
||||
{
|
||||
Log_ErrorFmt("Failed to create {} byte buffer", buffer_size);
|
||||
ERROR_LOG("Failed to create {} byte buffer", buffer_size);
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -1286,7 +1282,7 @@ std::unique_ptr<MetalDownloadTexture> MetalDownloadTexture::Create(u32 width, u3
|
||||
reinterpret_cast<void*>(Common::AlignDownPow2(reinterpret_cast<uintptr_t>(memory), HOST_PAGE_SIZE));
|
||||
const size_t page_offset = static_cast<size_t>(static_cast<u8*>(memory) - static_cast<u8*>(page_aligned_memory));
|
||||
const size_t page_aligned_size = Common::AlignUpPow2(page_offset + memory_size, HOST_PAGE_SIZE);
|
||||
Log_DevFmt("Trying to import {} bytes of memory at {} for download texture", page_aligned_memory,
|
||||
DEV_LOG("Trying to import {} bytes of memory at {} for download texture", page_aligned_memory,
|
||||
page_aligned_size);
|
||||
|
||||
buffer = [[dev.m_device newBufferWithBytesNoCopy:page_aligned_memory
|
||||
@@ -1295,7 +1291,7 @@ std::unique_ptr<MetalDownloadTexture> MetalDownloadTexture::Create(u32 width, u3
|
||||
deallocator:nil] retain];
|
||||
if (buffer == nil)
|
||||
{
|
||||
Log_ErrorFmt("Failed to import {} byte buffer", page_aligned_size);
|
||||
ERROR_LOG("Failed to import {} byte buffer", page_aligned_size);
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -1460,7 +1456,7 @@ std::unique_ptr<GPUSampler> MetalDevice::CreateSampler(const GPUSampler::Config&
|
||||
}
|
||||
if (i == std::size(border_color_mapping))
|
||||
{
|
||||
Log_ErrorFmt("Unsupported border color: {:08X}", config.border_color.GetValue());
|
||||
ERROR_LOG("Unsupported border color: {:08X}", config.border_color.GetValue());
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -1471,7 +1467,7 @@ std::unique_ptr<GPUSampler> MetalDevice::CreateSampler(const GPUSampler::Config&
|
||||
id<MTLSamplerState> ss = [m_device newSamplerStateWithDescriptor:desc];
|
||||
if (ss == nil)
|
||||
{
|
||||
Log_ErrorPrint("Failed to create sampler state.");
|
||||
ERROR_LOG("Failed to create sampler state.");
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -2029,7 +2025,7 @@ void MetalDevice::UnbindTexture(MetalTexture* tex)
|
||||
{
|
||||
if (m_current_render_targets[i] == tex)
|
||||
{
|
||||
Log_WarningPrint("Unbinding current RT");
|
||||
WARNING_LOG("Unbinding current RT");
|
||||
SetRenderTargets(nullptr, 0, m_current_depth_target, GPUPipeline::NoRenderPassFlags); // TODO: Wrong
|
||||
break;
|
||||
}
|
||||
@@ -2039,7 +2035,7 @@ void MetalDevice::UnbindTexture(MetalTexture* tex)
|
||||
{
|
||||
if (m_current_depth_target == tex)
|
||||
{
|
||||
Log_WarningPrint("Unbinding current DS");
|
||||
WARNING_LOG("Unbinding current DS");
|
||||
SetRenderTargets(nullptr, 0, nullptr, GPUPipeline::NoRenderPassFlags);
|
||||
}
|
||||
}
|
||||
@@ -2557,7 +2553,7 @@ void MetalDevice::SubmitCommandBuffer(bool wait_for_completion)
|
||||
|
||||
void MetalDevice::SubmitCommandBufferAndRestartRenderPass(const char* reason)
|
||||
{
|
||||
Log_DevFmt("Submitting command buffer and restarting render pass due to {}", reason);
|
||||
DEV_LOG("Submitting command buffer and restarting render pass due to {}", reason);
|
||||
|
||||
const bool in_render_pass = InRenderPass();
|
||||
SubmitCommandBuffer();
|
||||
|
||||
@@ -27,7 +27,7 @@ bool MetalStreamBuffer::Create(id<MTLDevice> device, u32 size)
|
||||
id<MTLBuffer> new_buffer = [device newBufferWithLength:size options:options];
|
||||
if (new_buffer == nil)
|
||||
{
|
||||
Log_ErrorPrint("Failed to create buffer.");
|
||||
ERROR_LOG("Failed to create buffer.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ bool MetalStreamBuffer::ReserveMemory(u32 num_bytes, u32 alignment)
|
||||
// Check for sane allocations
|
||||
if (required_bytes > m_size) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Attempting to allocate {} bytes from a {} byte stream buffer", num_bytes, m_size);
|
||||
ERROR_LOG("Attempting to allocate {} bytes from a {} byte stream buffer", num_bytes, m_size);
|
||||
Panic("Stream buffer overflow");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -67,13 +67,13 @@ static void DisableBrokenExtensions(const char* gl_vendor, const char* gl_render
|
||||
// Log_VerbosePrint("Keeping copy_image for driver version '%s'", gl_version);
|
||||
|
||||
// Framebuffer blits still end up faster.
|
||||
Log_VerbosePrint("Newer Mali driver detected, disabling GL_{EXT,OES}_copy_image.");
|
||||
VERBOSE_LOG("Newer Mali driver detected, disabling GL_{EXT,OES}_copy_image.");
|
||||
GLAD_GL_EXT_copy_image = 0;
|
||||
GLAD_GL_OES_copy_image = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_VerbosePrint("Older Mali driver detected, disabling GL_{EXT,OES}_copy_image, disjoint_timer_query.");
|
||||
VERBOSE_LOG("Older Mali driver detected, disabling GL_{EXT,OES}_copy_image, disjoint_timer_query.");
|
||||
GLAD_GL_EXT_copy_image = 0;
|
||||
GLAD_GL_OES_copy_image = 0;
|
||||
GLAD_GL_EXT_disjoint_timer_query = 0;
|
||||
@@ -86,13 +86,13 @@ static void DisableBrokenExtensions(const char* gl_vendor, const char* gl_render
|
||||
if ((std::sscanf(gl_version, "OpenGL ES %d.%d V@%d", &gl_major_version, &gl_minor_version, &major_version) == 3 &&
|
||||
gl_major_version >= 3 && gl_minor_version >= 2 && major_version < 502))
|
||||
{
|
||||
Log_VerboseFmt("Disabling GL_EXT_shader_framebuffer_fetch on Adreno version {}", major_version);
|
||||
VERBOSE_LOG("Disabling GL_EXT_shader_framebuffer_fetch on Adreno version {}", major_version);
|
||||
GLAD_GL_EXT_shader_framebuffer_fetch = 0;
|
||||
GLAD_GL_ARM_shader_framebuffer_fetch = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_VerboseFmt("Keeping GL_EXT_shader_framebuffer_fetch on Adreno version {}", major_version);
|
||||
VERBOSE_LOG("Keeping GL_EXT_shader_framebuffer_fetch on Adreno version {}", major_version);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ std::unique_ptr<OpenGLContext> OpenGLContext::Create(const WindowInfo& wi, Error
|
||||
if (!context)
|
||||
return nullptr;
|
||||
|
||||
Log_InfoPrint(context->IsGLES() ? "Created an OpenGL ES context" : "Created an OpenGL context");
|
||||
INFO_LOG(context->IsGLES() ? "Created an OpenGL ES context" : "Created an OpenGL context");
|
||||
|
||||
// TODO: Not thread-safe.
|
||||
static OpenGLContext* context_being_created;
|
||||
@@ -203,10 +203,10 @@ std::unique_ptr<OpenGLContext> OpenGLContext::Create(const WindowInfo& wi, Error
|
||||
const char* gl_renderer = reinterpret_cast<const char*>(glGetString(GL_RENDERER));
|
||||
const char* gl_version = reinterpret_cast<const char*>(glGetString(GL_VERSION));
|
||||
const char* gl_shading_language_version = reinterpret_cast<const char*>(glGetString(GL_SHADING_LANGUAGE_VERSION));
|
||||
Log_InfoFmt("GL_VENDOR: {}", gl_vendor);
|
||||
Log_InfoFmt("GL_RENDERER: {}", gl_renderer);
|
||||
Log_InfoFmt("GL_VERSION: {}", gl_version);
|
||||
Log_InfoFmt("GL_SHADING_LANGUAGE_VERSION: {}", gl_shading_language_version);
|
||||
INFO_LOG("GL_VENDOR: {}", gl_vendor);
|
||||
INFO_LOG("GL_RENDERER: {}", gl_renderer);
|
||||
INFO_LOG("GL_VERSION: {}", gl_version);
|
||||
INFO_LOG("GL_SHADING_LANGUAGE_VERSION: {}", gl_shading_language_version);
|
||||
|
||||
DisableBrokenExtensions(gl_vendor, gl_renderer, gl_version);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ OpenGLContextAGL::OpenGLContextAGL(const WindowInfo& wi) : OpenGLContext(wi)
|
||||
{
|
||||
m_opengl_module_handle = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", RTLD_NOW);
|
||||
if (!m_opengl_module_handle)
|
||||
Log_ErrorPrint("Could not open OpenGL.framework, function lookups will probably fail");
|
||||
ERROR_LOG("Could not open OpenGL.framework, function lookups will probably fail");
|
||||
}
|
||||
|
||||
OpenGLContextAGL::~OpenGLContextAGL()
|
||||
|
||||
@@ -27,16 +27,16 @@ static bool LoadEGL()
|
||||
DebugAssert(!s_egl_library.IsOpen());
|
||||
|
||||
std::string egl_libname = DynamicLibrary::GetVersionedFilename("libEGL");
|
||||
Log_InfoFmt("Loading EGL from {}...", egl_libname);
|
||||
INFO_LOG("Loading EGL from {}...", egl_libname);
|
||||
|
||||
Error error;
|
||||
if (!s_egl_library.Open(egl_libname.c_str(), &error))
|
||||
{
|
||||
// Try versioned.
|
||||
egl_libname = DynamicLibrary::GetVersionedFilename("libEGL", 1);
|
||||
Log_InfoFmt("Loading EGL from {}...", egl_libname);
|
||||
INFO_LOG("Loading EGL from {}...", egl_libname);
|
||||
if (!s_egl_library.Open(egl_libname.c_str(), &error))
|
||||
Log_ErrorFmt("Failed to load EGL: {}", error.GetDescription());
|
||||
ERROR_LOG("Failed to load EGL: {}", error.GetDescription());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ static void UnloadEGL()
|
||||
DebugAssert(s_egl_refcount.load(std::memory_order_acquire) > 0);
|
||||
if (s_egl_refcount.fetch_sub(1, std::memory_order_acq_rel) == 1)
|
||||
{
|
||||
Log_InfoPrint("Unloading EGL.");
|
||||
INFO_LOG("Unloading EGL.");
|
||||
s_egl_library.Close();
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ static bool LoadGLADEGL(EGLDisplay display, Error* error)
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_DevFmt("GLAD EGL Version: {}.{}", GLAD_VERSION_MAJOR(version), GLAD_VERSION_MINOR(version));
|
||||
DEV_LOG("GLAD EGL Version: {}.{}", GLAD_VERSION_MAJOR(version), GLAD_VERSION_MINOR(version));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -106,14 +106,14 @@ bool OpenGLContextEGL::Initialize(std::span<const Version> versions_to_try, Erro
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_DevFmt("eglInitialize() version: {}.{}", egl_major, egl_minor);
|
||||
DEV_LOG("eglInitialize() version: {}.{}", egl_major, egl_minor);
|
||||
|
||||
// Re-initialize EGL/GLAD.
|
||||
if (!LoadGLADEGL(m_display, error))
|
||||
return false;
|
||||
|
||||
if (!GLAD_EGL_KHR_surfaceless_context)
|
||||
Log_WarningPrint("EGL implementation does not support surfaceless contexts, emulating with pbuffers");
|
||||
WARNING_LOG("EGL implementation does not support surfaceless contexts, emulating with pbuffers");
|
||||
|
||||
for (const Version& cv : versions_to_try)
|
||||
{
|
||||
@@ -147,14 +147,14 @@ EGLDisplay OpenGLContextEGL::TryGetPlatformDisplay(EGLenum platform, const char*
|
||||
const char* extensions_str = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
|
||||
if (!extensions_str)
|
||||
{
|
||||
Log_ErrorPrint("No extensions supported.");
|
||||
ERROR_LOG("No extensions supported.");
|
||||
return EGL_NO_DISPLAY;
|
||||
}
|
||||
|
||||
EGLDisplay dpy = EGL_NO_DISPLAY;
|
||||
if (platform_ext && std::strstr(extensions_str, platform_ext))
|
||||
{
|
||||
Log_DevFmt("Using EGL platform {}.", platform_ext);
|
||||
DEV_LOG("Using EGL platform {}.", platform_ext);
|
||||
|
||||
PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display_ext =
|
||||
(PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
|
||||
@@ -165,17 +165,17 @@ EGLDisplay OpenGLContextEGL::TryGetPlatformDisplay(EGLenum platform, const char*
|
||||
if (!m_use_ext_platform_base)
|
||||
{
|
||||
const EGLint err = eglGetError();
|
||||
Log_ErrorFmt("eglGetPlatformDisplayEXT() failed: {} (0x{:X})", err, err);
|
||||
ERROR_LOG("eglGetPlatformDisplayEXT() failed: {} (0x{:X})", err, err);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_WarningPrint("eglGetPlatformDisplayEXT() was not found");
|
||||
WARNING_LOG("eglGetPlatformDisplayEXT() was not found");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_WarningFmt("{} is not supported.", platform_ext);
|
||||
WARNING_LOG("{} is not supported.", platform_ext);
|
||||
}
|
||||
|
||||
return dpy;
|
||||
@@ -199,7 +199,7 @@ EGLSurface OpenGLContextEGL::TryCreatePlatformSurface(EGLConfig config, void* wi
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorPrint("eglCreatePlatformWindowSurfaceEXT() not found");
|
||||
ERROR_LOG("eglCreatePlatformWindowSurfaceEXT() not found");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ EGLSurface OpenGLContextEGL::TryCreatePlatformSurface(EGLConfig config, void* wi
|
||||
|
||||
EGLDisplay OpenGLContextEGL::GetFallbackDisplay(Error* error)
|
||||
{
|
||||
Log_WarningPrint("Using fallback eglGetDisplay() path.");
|
||||
WARNING_LOG("Using fallback eglGetDisplay() path.");
|
||||
|
||||
EGLDisplay dpy = eglGetDisplay(m_wi.display_connection);
|
||||
if (dpy == EGL_NO_DISPLAY)
|
||||
@@ -222,7 +222,7 @@ EGLDisplay OpenGLContextEGL::GetFallbackDisplay(Error* error)
|
||||
|
||||
EGLSurface OpenGLContextEGL::CreateFallbackSurface(EGLConfig config, void* win, Error* error)
|
||||
{
|
||||
Log_WarningPrint("Using fallback eglCreateWindowSurface() path.");
|
||||
WARNING_LOG("Using fallback eglCreateWindowSurface() path.");
|
||||
|
||||
EGLSurface surface = eglCreateWindowSurface(m_display, config, (EGLNativeWindowType)win, nullptr);
|
||||
if (surface == EGL_NO_SURFACE)
|
||||
@@ -257,7 +257,7 @@ bool OpenGLContextEGL::ChangeSurface(const WindowInfo& new_wi)
|
||||
|
||||
if (was_current && !eglMakeCurrent(m_display, m_surface, m_surface, m_context))
|
||||
{
|
||||
Log_ErrorPrint("Failed to make context current again after surface change");
|
||||
ERROR_LOG("Failed to make context current again after surface change");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ void OpenGLContextEGL::ResizeSurface(u32 new_surface_width /*= 0*/, u32 new_surf
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorFmt("eglQuerySurface() failed: 0x{:X}", eglGetError());
|
||||
ERROR_LOG("eglQuerySurface() failed: 0x{:X}", eglGetError());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ bool OpenGLContextEGL::MakeCurrent()
|
||||
{
|
||||
if (!eglMakeCurrent(m_display, m_surface, m_surface, m_context)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("eglMakeCurrent() failed: 0x{:X}", eglGetError());
|
||||
ERROR_LOG("eglMakeCurrent() failed: 0x{:X}", eglGetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ bool OpenGLContextEGL::CreateSurface()
|
||||
m_surface = CreatePlatformSurface(m_config, m_wi.window_handle, &error);
|
||||
if (m_surface == EGL_NO_SURFACE)
|
||||
{
|
||||
Log_ErrorFmt("Failed to create platform surface: {}", error.GetDescription());
|
||||
ERROR_LOG("Failed to create platform surface: {}", error.GetDescription());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ bool OpenGLContextEGL::CreateSurface()
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorFmt("eglQuerySurface() failed: 0x{:X}", eglGetError());
|
||||
ERROR_LOG("eglQuerySurface() failed: 0x{:X}", eglGetError());
|
||||
}
|
||||
|
||||
m_wi.surface_format = GetSurfaceTextureFormat();
|
||||
@@ -385,13 +385,13 @@ bool OpenGLContextEGL::CreatePBufferSurface()
|
||||
m_surface = eglCreatePbufferSurface(m_display, m_config, attrib_list);
|
||||
if (!m_surface) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("eglCreatePbufferSurface() failed: {}", eglGetError());
|
||||
ERROR_LOG("eglCreatePbufferSurface() failed: {}", eglGetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
m_wi.surface_format = GetSurfaceTextureFormat();
|
||||
|
||||
Log_DevFmt("Created {}x{} pbuffer surface", width, height);
|
||||
DEV_LOG("Created {}x{} pbuffer surface", width, height);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -447,7 +447,7 @@ GPUTexture::Format OpenGLContextEGL::GetSurfaceTextureFormat() const
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorFmt("Unknown surface format: R={}, G={}, B={}, A={}", red_size, green_size, blue_size, alpha_size);
|
||||
ERROR_LOG("Unknown surface format: R={}, G={}, B={}, A={}", red_size, green_size, blue_size, alpha_size);
|
||||
return GPUTexture::Format::RGBA8;
|
||||
}
|
||||
}
|
||||
@@ -478,10 +478,10 @@ void OpenGLContextEGL::DestroySurface()
|
||||
|
||||
bool OpenGLContextEGL::CreateContext(const Version& version, EGLContext share_context)
|
||||
{
|
||||
Log_DevFmt("Trying version {}.{} ({})", version.major_version, version.minor_version,
|
||||
version.profile == OpenGLContext::Profile::ES ?
|
||||
"ES" :
|
||||
(version.profile == OpenGLContext::Profile::Core ? "Core" : "None"));
|
||||
DEV_LOG("Trying version {}.{} ({})", version.major_version, version.minor_version,
|
||||
version.profile == OpenGLContext::Profile::ES ?
|
||||
"ES" :
|
||||
(version.profile == OpenGLContext::Profile::Core ? "Core" : "None"));
|
||||
int surface_attribs[16] = {
|
||||
EGL_RENDERABLE_TYPE,
|
||||
(version.profile == Profile::ES) ?
|
||||
@@ -496,7 +496,7 @@ bool OpenGLContextEGL::CreateContext(const Version& version, EGLContext share_co
|
||||
const GPUTexture::Format format = m_wi.surface_format;
|
||||
if (format == GPUTexture::Format::Unknown)
|
||||
{
|
||||
Log_WarningPrint("Surface format not specified, assuming RGBA8.");
|
||||
WARNING_LOG("Surface format not specified, assuming RGBA8.");
|
||||
m_wi.surface_format = GPUTexture::Format::RGBA8;
|
||||
}
|
||||
|
||||
@@ -536,14 +536,14 @@ bool OpenGLContextEGL::CreateContext(const Version& version, EGLContext share_co
|
||||
EGLint num_configs;
|
||||
if (!eglChooseConfig(m_display, surface_attribs, nullptr, 0, &num_configs) || num_configs == 0)
|
||||
{
|
||||
Log_ErrorFmt("eglChooseConfig() failed: 0x{:x}", static_cast<unsigned>(eglGetError()));
|
||||
ERROR_LOG("eglChooseConfig() failed: 0x{:x}", static_cast<unsigned>(eglGetError()));
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<EGLConfig> configs(static_cast<u32>(num_configs));
|
||||
if (!eglChooseConfig(m_display, surface_attribs, configs.data(), num_configs, &num_configs))
|
||||
{
|
||||
Log_ErrorFmt("eglChooseConfig() failed: 0x{:x}", static_cast<unsigned>(eglGetError()));
|
||||
ERROR_LOG("eglChooseConfig() failed: 0x{:x}", static_cast<unsigned>(eglGetError()));
|
||||
return false;
|
||||
}
|
||||
configs.resize(static_cast<u32>(num_configs));
|
||||
@@ -560,7 +560,7 @@ bool OpenGLContextEGL::CreateContext(const Version& version, EGLContext share_co
|
||||
|
||||
if (!config.has_value())
|
||||
{
|
||||
Log_WarningPrint("No EGL configs matched exactly, using first.");
|
||||
WARNING_LOG("No EGL configs matched exactly, using first.");
|
||||
config = configs.front();
|
||||
}
|
||||
|
||||
@@ -578,33 +578,33 @@ bool OpenGLContextEGL::CreateContext(const Version& version, EGLContext share_co
|
||||
|
||||
if (!eglBindAPI((version.profile == Profile::ES) ? EGL_OPENGL_ES_API : EGL_OPENGL_API))
|
||||
{
|
||||
Log_ErrorFmt("eglBindAPI({}) failed", (version.profile == Profile::ES) ? "EGL_OPENGL_ES_API" : "EGL_OPENGL_API");
|
||||
ERROR_LOG("eglBindAPI({}) failed", (version.profile == Profile::ES) ? "EGL_OPENGL_ES_API" : "EGL_OPENGL_API");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_context = eglCreateContext(m_display, config.value(), share_context, attribs);
|
||||
if (!m_context)
|
||||
{
|
||||
Log_ErrorFmt("eglCreateContext() failed: 0x{:x}", static_cast<unsigned>(eglGetError()));
|
||||
ERROR_LOG("eglCreateContext() failed: 0x{:x}", static_cast<unsigned>(eglGetError()));
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_InfoFmt("Got version {}.{} ({})", version.major_version, version.minor_version,
|
||||
version.profile == OpenGLContext::Profile::ES ?
|
||||
"ES" :
|
||||
(version.profile == OpenGLContext::Profile::Core ? "Core" : "None"));
|
||||
INFO_LOG("Got version {}.{} ({})", version.major_version, version.minor_version,
|
||||
version.profile == OpenGLContext::Profile::ES ?
|
||||
"ES" :
|
||||
(version.profile == OpenGLContext::Profile::Core ? "Core" : "None"));
|
||||
|
||||
EGLint min_swap_interval, max_swap_interval;
|
||||
m_supports_negative_swap_interval = false;
|
||||
if (eglGetConfigAttrib(m_display, config.value(), EGL_MIN_SWAP_INTERVAL, &min_swap_interval) &&
|
||||
eglGetConfigAttrib(m_display, config.value(), EGL_MAX_SWAP_INTERVAL, &max_swap_interval))
|
||||
{
|
||||
Log_VerboseFmt("EGL_MIN_SWAP_INTERVAL = {}", min_swap_interval);
|
||||
Log_VerboseFmt("EGL_MAX_SWAP_INTERVAL = {}", max_swap_interval);
|
||||
VERBOSE_LOG("EGL_MIN_SWAP_INTERVAL = {}", min_swap_interval);
|
||||
VERBOSE_LOG("EGL_MAX_SWAP_INTERVAL = {}", max_swap_interval);
|
||||
m_supports_negative_swap_interval = (min_swap_interval <= -1);
|
||||
}
|
||||
|
||||
Log_InfoFmt("Negative swap interval/tear-control is {}supported", m_supports_negative_swap_interval ? "" : "NOT ");
|
||||
INFO_LOG("Negative swap interval/tear-control is {}supported", m_supports_negative_swap_interval ? "" : "NOT ");
|
||||
|
||||
m_config = config.value();
|
||||
m_version = version;
|
||||
@@ -618,7 +618,7 @@ bool OpenGLContextEGL::CreateContextAndSurface(const Version& version, EGLContex
|
||||
|
||||
if (!CreateSurface())
|
||||
{
|
||||
Log_ErrorPrint("Failed to create surface for context");
|
||||
ERROR_LOG("Failed to create surface for context");
|
||||
eglDestroyContext(m_display, m_context);
|
||||
m_context = EGL_NO_CONTEXT;
|
||||
return false;
|
||||
@@ -626,7 +626,7 @@ bool OpenGLContextEGL::CreateContextAndSurface(const Version& version, EGLContex
|
||||
|
||||
if (make_current && !eglMakeCurrent(m_display, m_surface, m_surface, m_context))
|
||||
{
|
||||
Log_ErrorFmt("eglMakeCurrent() failed: 0x{:X}", eglGetError());
|
||||
ERROR_LOG("eglMakeCurrent() failed: 0x{:X}", eglGetError());
|
||||
if (m_surface != EGL_NO_SURFACE)
|
||||
{
|
||||
eglDestroySurface(m_display, m_surface);
|
||||
|
||||
@@ -29,7 +29,7 @@ static bool ReloadWGL(HDC dc)
|
||||
{
|
||||
if (!gladLoadWGL(dc, [](const char* name) { return (GLADapiproc)wglGetProcAddress(name); }))
|
||||
{
|
||||
Log_ErrorPrint("Loading GLAD WGL functions failed");
|
||||
ERROR_LOG("Loading GLAD WGL functions failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -112,14 +112,14 @@ bool OpenGLContextWGL::ChangeSurface(const WindowInfo& new_wi)
|
||||
m_wi = new_wi;
|
||||
if (!InitializeDC(&error))
|
||||
{
|
||||
Log_ErrorFmt("Failed to change surface: {}", error.GetDescription());
|
||||
ERROR_LOG("Failed to change surface: {}", error.GetDescription());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (was_current && !wglMakeCurrent(m_dc, m_rc))
|
||||
{
|
||||
error.SetWin32(GetLastError());
|
||||
Log_ErrorFmt("Failed to make context current again after surface change: {}", error.GetDescription());
|
||||
ERROR_LOG("Failed to make context current again after surface change: {}", error.GetDescription());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ bool OpenGLContextWGL::MakeCurrent()
|
||||
{
|
||||
if (!wglMakeCurrent(m_dc, m_rc))
|
||||
{
|
||||
Log_ErrorFmt("wglMakeCurrent() failed: {}", GetLastError());
|
||||
ERROR_LOG("wglMakeCurrent() failed: {}", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+35
-35
@@ -254,13 +254,13 @@ static void GLAD_API_PTR GLDebugCallback(GLenum source, GLenum type, GLuint id,
|
||||
switch (severity)
|
||||
{
|
||||
case GL_DEBUG_SEVERITY_HIGH_KHR:
|
||||
Log_ErrorPrint(message);
|
||||
ERROR_LOG(message);
|
||||
break;
|
||||
case GL_DEBUG_SEVERITY_MEDIUM_KHR:
|
||||
Log_WarningPrint(message);
|
||||
WARNING_LOG(message);
|
||||
break;
|
||||
case GL_DEBUG_SEVERITY_LOW_KHR:
|
||||
Log_InfoPrint(message);
|
||||
INFO_LOG(message);
|
||||
break;
|
||||
case GL_DEBUG_SEVERITY_NOTIFICATION:
|
||||
// Log_DebugPrint(message);
|
||||
@@ -280,7 +280,7 @@ bool OpenGLDevice::CreateDevice(std::string_view adapter, bool threaded_presenta
|
||||
m_gl_context = OpenGLContext::Create(m_window_info, error);
|
||||
if (!m_gl_context)
|
||||
{
|
||||
Log_ErrorPrint("Failed to create any GL context");
|
||||
ERROR_LOG("Failed to create any GL context");
|
||||
m_gl_context.reset();
|
||||
return false;
|
||||
}
|
||||
@@ -351,32 +351,32 @@ bool OpenGLDevice::CheckFeatures(FeatureMask disabled_features)
|
||||
if (std::strstr(vendor, "Advanced Micro Devices") || std::strstr(vendor, "ATI Technologies Inc.") ||
|
||||
std::strstr(vendor, "ATI"))
|
||||
{
|
||||
Log_InfoPrint("AMD GPU detected.");
|
||||
INFO_LOG("AMD GPU detected.");
|
||||
vendor_id_amd = true;
|
||||
}
|
||||
else if (std::strstr(vendor, "NVIDIA Corporation"))
|
||||
{
|
||||
Log_InfoPrint("NVIDIA GPU detected.");
|
||||
INFO_LOG("NVIDIA GPU detected.");
|
||||
// vendor_id_nvidia = true;
|
||||
}
|
||||
else if (std::strstr(vendor, "Intel"))
|
||||
{
|
||||
Log_InfoPrint("Intel GPU detected.");
|
||||
INFO_LOG("Intel GPU detected.");
|
||||
vendor_id_intel = true;
|
||||
}
|
||||
else if (std::strstr(vendor, "ARM"))
|
||||
{
|
||||
Log_InfoPrint("ARM GPU detected.");
|
||||
INFO_LOG("ARM GPU detected.");
|
||||
vendor_id_arm = true;
|
||||
}
|
||||
else if (std::strstr(vendor, "Qualcomm"))
|
||||
{
|
||||
Log_InfoPrint("Qualcomm GPU detected.");
|
||||
INFO_LOG("Qualcomm GPU detected.");
|
||||
vendor_id_qualcomm = true;
|
||||
}
|
||||
else if (std::strstr(vendor, "Imagination Technologies") || std::strstr(renderer, "PowerVR"))
|
||||
{
|
||||
Log_InfoPrint("PowerVR GPU detected.");
|
||||
INFO_LOG("PowerVR GPU detected.");
|
||||
vendor_id_powervr = true;
|
||||
}
|
||||
|
||||
@@ -387,14 +387,14 @@ bool OpenGLDevice::CheckFeatures(FeatureMask disabled_features)
|
||||
m_disable_pbo =
|
||||
(!GLAD_GL_VERSION_4_4 && !GLAD_GL_ARB_buffer_storage && !GLAD_GL_EXT_buffer_storage) || is_shitty_mobile_driver;
|
||||
if (m_disable_pbo && !is_shitty_mobile_driver)
|
||||
Log_WarningPrint("Not using PBOs for texture uploads because buffer_storage is unavailable.");
|
||||
WARNING_LOG("Not using PBOs for texture uploads because buffer_storage is unavailable.");
|
||||
|
||||
GLint max_texture_size = 1024;
|
||||
GLint max_samples = 1;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
|
||||
Log_DevFmt("GL_MAX_TEXTURE_SIZE: {}", max_texture_size);
|
||||
DEV_LOG("GL_MAX_TEXTURE_SIZE: {}", max_texture_size);
|
||||
glGetIntegerv(GL_MAX_SAMPLES, &max_samples);
|
||||
Log_DevFmt("GL_MAX_SAMPLES: {}", max_samples);
|
||||
DEV_LOG("GL_MAX_SAMPLES: {}", max_samples);
|
||||
m_max_texture_size = std::max(1024u, static_cast<u32>(max_texture_size));
|
||||
m_max_multisamples = std::max(1u, static_cast<u32>(max_samples));
|
||||
|
||||
@@ -423,11 +423,11 @@ bool OpenGLDevice::CheckFeatures(FeatureMask disabled_features)
|
||||
{
|
||||
GLint max_texel_buffer_size = 0;
|
||||
glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, reinterpret_cast<GLint*>(&max_texel_buffer_size));
|
||||
Log_DevFmt("GL_MAX_TEXTURE_BUFFER_SIZE: {}", max_texel_buffer_size);
|
||||
DEV_LOG("GL_MAX_TEXTURE_BUFFER_SIZE: {}", max_texel_buffer_size);
|
||||
if (max_texel_buffer_size < static_cast<GLint>(MIN_TEXEL_BUFFER_ELEMENTS))
|
||||
{
|
||||
Log_WarningFmt("GL_MAX_TEXTURE_BUFFER_SIZE ({}) is below required minimum ({}), not using texture buffers.",
|
||||
max_texel_buffer_size, MIN_TEXEL_BUFFER_ELEMENTS);
|
||||
WARNING_LOG("GL_MAX_TEXTURE_BUFFER_SIZE ({}) is below required minimum ({}), not using texture buffers.",
|
||||
max_texel_buffer_size, MIN_TEXEL_BUFFER_ELEMENTS);
|
||||
m_features.supports_texture_buffers = false;
|
||||
}
|
||||
}
|
||||
@@ -444,18 +444,18 @@ bool OpenGLDevice::CheckFeatures(FeatureMask disabled_features)
|
||||
glGetInteger64v(GL_MAX_SHADER_STORAGE_BLOCK_SIZE, &max_ssbo_size);
|
||||
}
|
||||
|
||||
Log_DevFmt("GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS: {}", max_fragment_storage_blocks);
|
||||
Log_DevFmt("GL_MAX_SHADER_STORAGE_BLOCK_SIZE: {}", max_ssbo_size);
|
||||
DEV_LOG("GL_MAX_FRAGMENT_SHADER_STORAGE_BLOCKS: {}", max_fragment_storage_blocks);
|
||||
DEV_LOG("GL_MAX_SHADER_STORAGE_BLOCK_SIZE: {}", max_ssbo_size);
|
||||
m_features.texture_buffers_emulated_with_ssbo =
|
||||
(max_fragment_storage_blocks > 0 && max_ssbo_size >= static_cast<GLint64>(1024 * 512 * sizeof(u16)));
|
||||
if (m_features.texture_buffers_emulated_with_ssbo)
|
||||
{
|
||||
Log_InfoPrint("Using shader storage buffers for VRAM writes.");
|
||||
INFO_LOG("Using shader storage buffers for VRAM writes.");
|
||||
m_features.supports_texture_buffers = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_WarningPrint("Both texture buffers and SSBOs are not supported. Performance will suffer.");
|
||||
WARNING_LOG("Both texture buffers and SSBOs are not supported. Performance will suffer.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -490,14 +490,14 @@ bool OpenGLDevice::CheckFeatures(FeatureMask disabled_features)
|
||||
// check that there's at least one format and the extension isn't being "faked"
|
||||
GLint num_formats = 0;
|
||||
glGetIntegerv(GL_NUM_PROGRAM_BINARY_FORMATS, &num_formats);
|
||||
Log_DevFmt("{} program binary formats supported by driver", num_formats);
|
||||
DEV_LOG("{} program binary formats supported by driver", num_formats);
|
||||
m_features.pipeline_cache = (num_formats > 0);
|
||||
}
|
||||
|
||||
if (!m_features.pipeline_cache)
|
||||
{
|
||||
Log_WarningPrint("Your GL driver does not support program binaries. Hopefully it has a built-in cache, otherwise "
|
||||
"startup will be slow due to compiling shaders.");
|
||||
WARNING_LOG("Your GL driver does not support program binaries. Hopefully it has a built-in cache, otherwise "
|
||||
"startup will be slow due to compiling shaders.");
|
||||
}
|
||||
|
||||
// Mobile drivers prefer textures to not be updated mid-frame.
|
||||
@@ -506,7 +506,7 @@ bool OpenGLDevice::CheckFeatures(FeatureMask disabled_features)
|
||||
if (vendor_id_intel)
|
||||
{
|
||||
// Intel drivers corrupt image on readback when syncs are used for downloads.
|
||||
Log_WarningPrint("Disabling async downloads with PBOs due to it being broken on Intel drivers.");
|
||||
WARNING_LOG("Disabling async downloads with PBOs due to it being broken on Intel drivers.");
|
||||
m_disable_async_download = true;
|
||||
}
|
||||
|
||||
@@ -536,7 +536,7 @@ bool OpenGLDevice::UpdateWindow()
|
||||
|
||||
if (!m_gl_context->ChangeSurface(m_window_info))
|
||||
{
|
||||
Log_ErrorPrint("Failed to change surface");
|
||||
ERROR_LOG("Failed to change surface");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -590,7 +590,7 @@ void OpenGLDevice::SetSwapInterval()
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
|
||||
if (!m_gl_context->SetSwapInterval(interval))
|
||||
Log_WarningFmt("Failed to set swap interval to {}", interval);
|
||||
WARNING_LOG("Failed to set swap interval to {}", interval);
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, current_fbo);
|
||||
}
|
||||
@@ -643,7 +643,7 @@ GLuint OpenGLDevice::CreateFramebuffer(GPUTexture* const* rts, u32 num_rts, GPUT
|
||||
|
||||
if (glGetError() != GL_NO_ERROR || glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
||||
{
|
||||
Log_ErrorFmt("Failed to create GL framebuffer: {}", static_cast<s32>(glGetError()));
|
||||
ERROR_LOG("Failed to create GL framebuffer: {}", static_cast<s32>(glGetError()));
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, OpenGLDevice::GetInstance().m_current_fbo);
|
||||
glDeleteFramebuffers(1, &fbo_id);
|
||||
return {};
|
||||
@@ -681,7 +681,7 @@ void OpenGLDevice::DestroySurface()
|
||||
|
||||
m_window_info.SetSurfaceless();
|
||||
if (!m_gl_context->ChangeSurface(m_window_info))
|
||||
Log_ErrorPrint("Failed to switch to surfaceless");
|
||||
ERROR_LOG("Failed to switch to surfaceless");
|
||||
}
|
||||
|
||||
bool OpenGLDevice::CreateBuffers()
|
||||
@@ -690,7 +690,7 @@ bool OpenGLDevice::CreateBuffers()
|
||||
!(m_index_buffer = OpenGLStreamBuffer::Create(GL_ELEMENT_ARRAY_BUFFER, INDEX_BUFFER_SIZE)) ||
|
||||
!(m_uniform_buffer = OpenGLStreamBuffer::Create(GL_UNIFORM_BUFFER, UNIFORM_BUFFER_SIZE))) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrint("Failed to create one or more device buffers.");
|
||||
ERROR_LOG("Failed to create one or more device buffers.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -705,7 +705,7 @@ bool OpenGLDevice::CreateBuffers()
|
||||
if (!(m_texture_stream_buffer = OpenGLStreamBuffer::Create(GL_PIXEL_UNPACK_BUFFER, TEXTURE_STREAM_BUFFER_SIZE)))
|
||||
[[unlikely]]
|
||||
{
|
||||
Log_ErrorPrint("Failed to create texture stream buffer");
|
||||
ERROR_LOG("Failed to create texture stream buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -720,7 +720,7 @@ bool OpenGLDevice::CreateBuffers()
|
||||
glGenFramebuffers(static_cast<GLsizei>(std::size(fbos)), fbos);
|
||||
if (const GLenum err = glGetError(); err != GL_NO_ERROR) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Failed to create framebuffers: {}", err);
|
||||
ERROR_LOG("Failed to create framebuffers: {}", err);
|
||||
return false;
|
||||
}
|
||||
m_read_fbo = fbos[0];
|
||||
@@ -839,7 +839,7 @@ void OpenGLDevice::PopTimestampQuery()
|
||||
glGetIntegerv(GL_GPU_DISJOINT_EXT, &disjoint);
|
||||
if (disjoint)
|
||||
{
|
||||
Log_VerbosePrint("GPU timing disjoint, resetting.");
|
||||
VERBOSE_LOG("GPU timing disjoint, resetting.");
|
||||
if (m_timestamp_query_started)
|
||||
glEndQueryEXT(GL_TIME_ELAPSED);
|
||||
|
||||
@@ -953,7 +953,7 @@ void OpenGLDevice::UnbindTexture(OpenGLTexture* tex)
|
||||
{
|
||||
if (m_current_render_targets[i] == tex)
|
||||
{
|
||||
Log_WarningPrint("Unbinding current RT");
|
||||
WARNING_LOG("Unbinding current RT");
|
||||
SetRenderTargets(nullptr, 0, m_current_depth_target);
|
||||
break;
|
||||
}
|
||||
@@ -965,7 +965,7 @@ void OpenGLDevice::UnbindTexture(OpenGLTexture* tex)
|
||||
{
|
||||
if (m_current_depth_target == tex)
|
||||
{
|
||||
Log_WarningPrint("Unbinding current DS");
|
||||
WARNING_LOG("Unbinding current DS");
|
||||
SetRenderTargets(nullptr, 0, nullptr);
|
||||
}
|
||||
|
||||
@@ -1130,7 +1130,7 @@ void OpenGLDevice::SetRenderTargets(GPUTexture* const* rts, u32 num_rts, GPUText
|
||||
{
|
||||
if ((fbo = m_framebuffer_manager.Lookup(rts, num_rts, ds, 0)) == 0)
|
||||
{
|
||||
Log_ErrorFmt("Failed to get FBO for {} render targets", num_rts);
|
||||
ERROR_LOG("Failed to get FBO for {} render targets", num_rts);
|
||||
m_current_fbo = 0;
|
||||
std::memset(m_current_render_targets.data(), 0, sizeof(m_current_render_targets));
|
||||
m_num_current_render_targets = 0;
|
||||
|
||||
@@ -110,7 +110,7 @@ bool OpenGLShader::Compile()
|
||||
GLuint shader = glCreateShader(GetGLShaderType(m_stage));
|
||||
if (GLenum err = glGetError(); err != GL_NO_ERROR)
|
||||
{
|
||||
Log_ErrorFmt("glCreateShader() failed: {}", err);
|
||||
ERROR_LOG("glCreateShader() failed: {}", err);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -133,11 +133,11 @@ bool OpenGLShader::Compile()
|
||||
|
||||
if (status == GL_TRUE)
|
||||
{
|
||||
Log_ErrorFmt("Shader compiled with warnings:\n{}", info_log);
|
||||
ERROR_LOG("Shader compiled with warnings:\n{}", info_log);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorFmt("Shader failed to compile:\n{}", info_log);
|
||||
ERROR_LOG("Shader failed to compile:\n{}", info_log);
|
||||
GPUDevice::DumpBadShader(m_source, info_log);
|
||||
glDeleteShader(shader);
|
||||
return false;
|
||||
@@ -170,7 +170,7 @@ std::unique_ptr<GPUShader> OpenGLDevice::CreateShaderFromSource(GPUShaderStage s
|
||||
{
|
||||
if (std::strcmp(entry_point, "main") != 0)
|
||||
{
|
||||
Log_ErrorFmt("Entry point must be 'main', but got '{}' instead.", entry_point);
|
||||
ERROR_LOG("Entry point must be 'main', but got '{}' instead.", entry_point);
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -265,7 +265,7 @@ GLuint OpenGLDevice::LookupProgramCache(const OpenGLPipeline::ProgramCacheKey& k
|
||||
it->second.program_id = CreateProgramFromPipelineCache(it->second, plconfig);
|
||||
if (it->second.program_id == 0)
|
||||
{
|
||||
Log_ErrorPrint("Failed to create program from binary.");
|
||||
ERROR_LOG("Failed to create program from binary.");
|
||||
m_program_cache.erase(it);
|
||||
it = m_program_cache.end();
|
||||
DiscardPipelineCache();
|
||||
@@ -309,7 +309,7 @@ GLuint OpenGLDevice::CompileProgram(const GPUPipeline::GraphicsConfig& plconfig)
|
||||
if (!vertex_shader || !fragment_shader || !vertex_shader->Compile() || !fragment_shader->Compile() ||
|
||||
(geometry_shader && !geometry_shader->Compile())) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrint("Failed to compile shaders.");
|
||||
ERROR_LOG("Failed to compile shaders.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -317,7 +317,7 @@ GLuint OpenGLDevice::CompileProgram(const GPUPipeline::GraphicsConfig& plconfig)
|
||||
const GLuint program_id = glCreateProgram();
|
||||
if (glGetError() != GL_NO_ERROR) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrint("Failed to create program object.");
|
||||
ERROR_LOG("Failed to create program object.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -381,11 +381,11 @@ GLuint OpenGLDevice::CompileProgram(const GPUPipeline::GraphicsConfig& plconfig)
|
||||
|
||||
if (status == GL_TRUE)
|
||||
{
|
||||
Log_ErrorFmt("Program linked with warnings:\n{}", info_log.c_str());
|
||||
ERROR_LOG("Program linked with warnings:\n{}", info_log.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorFmt("Program failed to link:\n{}", info_log.c_str());
|
||||
ERROR_LOG("Program failed to link:\n{}", info_log.c_str());
|
||||
glDeleteProgram(program_id);
|
||||
return 0;
|
||||
}
|
||||
@@ -469,7 +469,7 @@ GLuint OpenGLDevice::CreateVAO(std::span<const GPUPipeline::VertexAttribute> att
|
||||
glGenVertexArrays(1, &vao);
|
||||
if (const GLenum err = glGetError(); err != GL_NO_ERROR)
|
||||
{
|
||||
Log_ErrorFmt("Failed to create vertex array object: {}", err);
|
||||
ERROR_LOG("Failed to create vertex array object: {}", err);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -737,12 +737,12 @@ bool OpenGLDevice::ReadPipelineCache(const std::string& filename)
|
||||
// If it doesn't exist, we're going to create it.
|
||||
if (errno != ENOENT)
|
||||
{
|
||||
Log_WarningFmt("Failed to open shader cache: {}", error.GetDescription());
|
||||
WARNING_LOG("Failed to open shader cache: {}", error.GetDescription());
|
||||
m_pipeline_disk_cache_filename = {};
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_WarningPrint("Disk cache does not exist, creating.");
|
||||
WARNING_LOG("Disk cache does not exist, creating.");
|
||||
return DiscardPipelineCache();
|
||||
}
|
||||
|
||||
@@ -758,7 +758,7 @@ bool OpenGLDevice::ReadPipelineCache(const std::string& filename)
|
||||
if (FileSystem::FSeek64(m_pipeline_disk_cache_file, size - sizeof(PipelineDiskCacheFooter), SEEK_SET) != 0 ||
|
||||
std::fread(&file_footer, sizeof(file_footer), 1, m_pipeline_disk_cache_file) != 1)
|
||||
{
|
||||
Log_ErrorPrint("Failed to read disk cache footer.");
|
||||
ERROR_LOG("Failed to read disk cache footer.");
|
||||
return DiscardPipelineCache();
|
||||
}
|
||||
|
||||
@@ -773,7 +773,7 @@ bool OpenGLDevice::ReadPipelineCache(const std::string& filename)
|
||||
std::strncmp(file_footer.driver_version, expected_footer.driver_version, std::size(file_footer.driver_version)) !=
|
||||
0)
|
||||
{
|
||||
Log_ErrorPrint("Disk cache does not match expected driver/version.");
|
||||
ERROR_LOG("Disk cache does not match expected driver/version.");
|
||||
return DiscardPipelineCache();
|
||||
}
|
||||
|
||||
@@ -782,7 +782,7 @@ bool OpenGLDevice::ReadPipelineCache(const std::string& filename)
|
||||
if (m_pipeline_disk_cache_data_end < 0 ||
|
||||
FileSystem::FSeek64(m_pipeline_disk_cache_file, m_pipeline_disk_cache_data_end, SEEK_SET) != 0)
|
||||
{
|
||||
Log_ErrorPrint("Failed to seek to start of index entries.");
|
||||
ERROR_LOG("Failed to seek to start of index entries.");
|
||||
return DiscardPipelineCache();
|
||||
}
|
||||
|
||||
@@ -793,13 +793,13 @@ bool OpenGLDevice::ReadPipelineCache(const std::string& filename)
|
||||
if (std::fread(&entry, sizeof(entry), 1, m_pipeline_disk_cache_file) != 1 ||
|
||||
(static_cast<s64>(entry.offset) + static_cast<s64>(entry.compressed_size)) >= size)
|
||||
{
|
||||
Log_ErrorPrint("Failed to read disk cache entry.");
|
||||
ERROR_LOG("Failed to read disk cache entry.");
|
||||
return DiscardPipelineCache();
|
||||
}
|
||||
|
||||
if (m_program_cache.find(entry.key) != m_program_cache.end())
|
||||
{
|
||||
Log_ErrorPrint("Duplicate program in disk cache.");
|
||||
ERROR_LOG("Duplicate program in disk cache.");
|
||||
return DiscardPipelineCache();
|
||||
}
|
||||
|
||||
@@ -813,7 +813,7 @@ bool OpenGLDevice::ReadPipelineCache(const std::string& filename)
|
||||
m_program_cache.emplace(entry.key, pitem);
|
||||
}
|
||||
|
||||
Log_VerboseFmt("Read {} programs from disk cache.", m_program_cache.size());
|
||||
VERBOSE_LOG("Read {} programs from disk cache.", m_program_cache.size());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -832,7 +832,7 @@ GLuint OpenGLDevice::CreateProgramFromPipelineCache(const OpenGLPipeline::Progra
|
||||
if (FileSystem::FSeek64(m_pipeline_disk_cache_file, it.file_offset, SEEK_SET) != 0 ||
|
||||
std::fread(compressed_data.data(), it.file_compressed_size, 1, m_pipeline_disk_cache_file) != 1) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrint("Failed to read program from disk cache.");
|
||||
ERROR_LOG("Failed to read program from disk cache.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -840,7 +840,7 @@ GLuint OpenGLDevice::CreateProgramFromPipelineCache(const OpenGLPipeline::Progra
|
||||
ZSTD_decompress(data.data(), data.size(), compressed_data.data(), compressed_data.size());
|
||||
if (ZSTD_isError(decompress_result)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Failed to decompress program from disk cache: {}", ZSTD_getErrorName(decompress_result));
|
||||
ERROR_LOG("Failed to decompress program from disk cache: {}", ZSTD_getErrorName(decompress_result));
|
||||
return 0;
|
||||
}
|
||||
compressed_data.deallocate();
|
||||
@@ -849,7 +849,7 @@ GLuint OpenGLDevice::CreateProgramFromPipelineCache(const OpenGLPipeline::Progra
|
||||
GLuint prog = glCreateProgram();
|
||||
if (const GLenum err = glGetError(); err != GL_NO_ERROR) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Failed to create program object: {}", err);
|
||||
ERROR_LOG("Failed to create program object: {}", err);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -859,7 +859,7 @@ GLuint OpenGLDevice::CreateProgramFromPipelineCache(const OpenGLPipeline::Progra
|
||||
glGetProgramiv(prog, GL_LINK_STATUS, &link_status);
|
||||
if (link_status != GL_TRUE) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Failed to create GL program from binary: status {}, discarding cache.", link_status);
|
||||
ERROR_LOG("Failed to create GL program from binary: status {}, discarding cache.", link_status);
|
||||
glDeleteProgram(prog);
|
||||
return 0;
|
||||
}
|
||||
@@ -878,7 +878,7 @@ void OpenGLDevice::AddToPipelineCache(OpenGLPipeline::ProgramCacheItem* it)
|
||||
glGetProgramiv(it->program_id, GL_PROGRAM_BINARY_LENGTH, &binary_size);
|
||||
if (binary_size == 0)
|
||||
{
|
||||
Log_WarningPrint("glGetProgramiv(GL_PROGRAM_BINARY_LENGTH) returned 0");
|
||||
WARNING_LOG("glGetProgramiv(GL_PROGRAM_BINARY_LENGTH) returned 0");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -887,12 +887,12 @@ void OpenGLDevice::AddToPipelineCache(OpenGLPipeline::ProgramCacheItem* it)
|
||||
glGetProgramBinary(it->program_id, binary_size, &binary_size, &format, uncompressed_data.data());
|
||||
if (binary_size == 0)
|
||||
{
|
||||
Log_WarningPrint("glGetProgramBinary() failed");
|
||||
WARNING_LOG("glGetProgramBinary() failed");
|
||||
return;
|
||||
}
|
||||
else if (static_cast<size_t>(binary_size) != uncompressed_data.size()) [[unlikely]]
|
||||
{
|
||||
Log_WarningFmt("Size changed from {} to {} after glGetProgramBinary()", uncompressed_data.size(), binary_size);
|
||||
WARNING_LOG("Size changed from {} to {} after glGetProgramBinary()", uncompressed_data.size(), binary_size);
|
||||
}
|
||||
|
||||
DynamicHeapArray<u8> compressed_data(ZSTD_compressBound(binary_size));
|
||||
@@ -900,17 +900,16 @@ void OpenGLDevice::AddToPipelineCache(OpenGLPipeline::ProgramCacheItem* it)
|
||||
ZSTD_compress(compressed_data.data(), compressed_data.size(), uncompressed_data.data(), binary_size, 0);
|
||||
if (ZSTD_isError(compress_result)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Failed to compress program: {}", ZSTD_getErrorName(compress_result));
|
||||
ERROR_LOG("Failed to compress program: {}", ZSTD_getErrorName(compress_result));
|
||||
return;
|
||||
}
|
||||
|
||||
Log_DevFmt("Program binary retrieved and compressed, {} -> {} bytes, format {}", binary_size, compress_result,
|
||||
format);
|
||||
DEV_LOG("Program binary retrieved and compressed, {} -> {} bytes, format {}", binary_size, compress_result, format);
|
||||
|
||||
if (FileSystem::FSeek64(m_pipeline_disk_cache_file, m_pipeline_disk_cache_data_end, SEEK_SET) != 0 ||
|
||||
std::fwrite(compressed_data.data(), compress_result, 1, m_pipeline_disk_cache_file) != 1)
|
||||
{
|
||||
Log_ErrorPrint("Failed to write binary to disk cache.");
|
||||
ERROR_LOG("Failed to write binary to disk cache.");
|
||||
}
|
||||
|
||||
it->file_format = format;
|
||||
@@ -947,7 +946,7 @@ bool OpenGLDevice::DiscardPipelineCache()
|
||||
m_pipeline_disk_cache_file = FileSystem::OpenCFile(m_pipeline_disk_cache_filename.c_str(), "w+b", &error);
|
||||
if (!m_pipeline_disk_cache_file) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Failed to reopen pipeline cache: {}", error.GetDescription());
|
||||
ERROR_LOG("Failed to reopen pipeline cache: {}", error.GetDescription());
|
||||
m_pipeline_disk_cache_filename = {};
|
||||
return false;
|
||||
}
|
||||
@@ -967,13 +966,13 @@ void OpenGLDevice::ClosePipelineCache()
|
||||
|
||||
if (!m_pipeline_disk_cache_changed)
|
||||
{
|
||||
Log_VerbosePrint("Not updating pipeline cache because it has not changed.");
|
||||
VERBOSE_LOG("Not updating pipeline cache because it has not changed.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (FileSystem::FSeek64(m_pipeline_disk_cache_file, m_pipeline_disk_cache_data_end, SEEK_SET) != 0) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrint("Failed to seek to data end.");
|
||||
ERROR_LOG("Failed to seek to data end.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -993,7 +992,7 @@ void OpenGLDevice::ClosePipelineCache()
|
||||
|
||||
if (std::fwrite(&entry, sizeof(entry), 1, m_pipeline_disk_cache_file) != 1) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrint("Failed to write index entry.");
|
||||
ERROR_LOG("Failed to write index entry.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1005,5 +1004,5 @@ void OpenGLDevice::ClosePipelineCache()
|
||||
footer.num_programs = count;
|
||||
|
||||
if (std::fwrite(&footer, sizeof(footer), 1, m_pipeline_disk_cache_file) != 1) [[unlikely]]
|
||||
Log_ErrorPrint("Failed to write footer.");
|
||||
ERROR_LOG("Failed to write footer.");
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ std::unique_ptr<OpenGLTexture> OpenGLTexture::Create(u32 width, u32 height, u32
|
||||
|
||||
if (layers > 1 && data)
|
||||
{
|
||||
Log_ErrorPrint("Loading texture array data not currently supported");
|
||||
ERROR_LOG("Loading texture array data not currently supported");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ std::unique_ptr<OpenGLTexture> OpenGLTexture::Create(u32 width, u32 height, u32
|
||||
GLenum error = glGetError();
|
||||
if (error != GL_NO_ERROR)
|
||||
{
|
||||
Log_ErrorFmt("Failed to create texture: 0x{:X}", error);
|
||||
ERROR_LOG("Failed to create texture: 0x{:X}", error);
|
||||
glDeleteTextures(1, &id);
|
||||
return nullptr;
|
||||
}
|
||||
@@ -411,7 +411,7 @@ std::unique_ptr<GPUSampler> OpenGLDevice::CreateSampler(const GPUSampler::Config
|
||||
glGenSamplers(1, &sampler);
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
{
|
||||
Log_ErrorFmt("Failed to create sampler: {:X}", sampler);
|
||||
ERROR_LOG("Failed to create sampler: {:X}", sampler);
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -630,7 +630,7 @@ bool OpenGLTextureBuffer::CreateBuffer()
|
||||
glGenTextures(1, &m_texture_id);
|
||||
if (const GLenum err = glGetError(); err != GL_NO_ERROR)
|
||||
{
|
||||
Log_ErrorFmt("Failed to create texture for buffer: 0x{:X}", err);
|
||||
ERROR_LOG("Failed to create texture for buffer: 0x{:X}", err);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -683,7 +683,7 @@ std::unique_ptr<GPUTextureBuffer> OpenGLDevice::CreateTextureBuffer(GPUTextureBu
|
||||
glGetInteger64v(GL_MAX_SHADER_STORAGE_BLOCK_SIZE, &max_ssbo_size);
|
||||
if (static_cast<GLint64>(buffer_size) > max_ssbo_size)
|
||||
{
|
||||
Log_ErrorFmt("Buffer size of {} not supported, max is {}", buffer_size, max_ssbo_size);
|
||||
ERROR_LOG("Buffer size of {} not supported, max is {}", buffer_size, max_ssbo_size);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
@@ -701,7 +701,7 @@ std::unique_ptr<GPUTextureBuffer> OpenGLDevice::CreateTextureBuffer(GPUTextureBu
|
||||
glGenTextures(1, &texture_id);
|
||||
if (const GLenum err = glGetError(); err != GL_NO_ERROR)
|
||||
{
|
||||
Log_ErrorFmt("Failed to create texture for buffer: 0x{:X}", err);
|
||||
ERROR_LOG("Failed to create texture for buffer: 0x{:X}", err);
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -776,7 +776,7 @@ std::unique_ptr<OpenGLDownloadTexture> OpenGLDownloadTexture::Create(u32 width,
|
||||
|
||||
if (!buffer_map)
|
||||
{
|
||||
Log_ErrorPrint("Failed to map persistent download buffer");
|
||||
ERROR_LOG("Failed to map persistent download buffer");
|
||||
glDeleteBuffers(1, &buffer_id);
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ static bool SetScreensaverInhibitMacOS(bool inhibit)
|
||||
if (IOPMAssertionCreateWithName(kIOPMAssertionTypePreventUserIdleDisplaySleep, kIOPMAssertionLevelOn, reason,
|
||||
&s_prevent_idle_assertion) != kIOReturnSuccess)
|
||||
{
|
||||
Log_ErrorPrint("IOPMAssertionCreateWithName() failed");
|
||||
ERROR_LOG("IOPMAssertionCreateWithName() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ void PlatformMisc::SuspendScreensaver()
|
||||
|
||||
if (!SetScreensaverInhibitMacOS(true))
|
||||
{
|
||||
Log_ErrorPrint("Failed to suspend screensaver.");
|
||||
ERROR_LOG("Failed to suspend screensaver.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ void PlatformMisc::ResumeScreensaver()
|
||||
return;
|
||||
|
||||
if (!SetScreensaverInhibitMacOS(false))
|
||||
Log_ErrorPrint("Failed to resume screensaver.");
|
||||
ERROR_LOG("Failed to resume screensaver.");
|
||||
|
||||
s_screensaver_suspended = false;
|
||||
}
|
||||
@@ -116,7 +116,7 @@ bool CocoaTools::CreateMetalLayer(WindowInfo* wi)
|
||||
CAMetalLayer* layer = [CAMetalLayer layer];
|
||||
if (layer == nil)
|
||||
{
|
||||
Log_ErrorPrint("Failed to create CAMetalLayer");
|
||||
ERROR_LOG("Failed to create CAMetalLayer");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ static bool SetScreensaverInhibitDBus(const bool inhibit_requested, const char*
|
||||
ScopedGuard cleanup = [&]() {
|
||||
if (dbus_error_is_set(&error))
|
||||
{
|
||||
Log_ErrorFmt("SetScreensaverInhibitDBus error: {}", error.message);
|
||||
ERROR_LOG("SetScreensaverInhibitDBus error: {}", error.message);
|
||||
dbus_error_free(&error);
|
||||
}
|
||||
if (message)
|
||||
@@ -103,7 +103,7 @@ void PlatformMisc::SuspendScreensaver()
|
||||
|
||||
if (!SetScreensaverInhibit(true))
|
||||
{
|
||||
Log_ErrorPrint("Failed to suspend screensaver.");
|
||||
ERROR_LOG("Failed to suspend screensaver.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ void PlatformMisc::ResumeScreensaver()
|
||||
return;
|
||||
|
||||
if (!SetScreensaverInhibit(false))
|
||||
Log_ErrorPrint("Failed to resume screensaver.");
|
||||
ERROR_LOG("Failed to resume screensaver.");
|
||||
|
||||
s_screensaver_suspended = false;
|
||||
}
|
||||
@@ -179,8 +179,8 @@ bool PlatformMisc::PlaySoundAsync(const char* path)
|
||||
if (res == 0)
|
||||
return true;
|
||||
|
||||
Log_ErrorFmt("Failed to play sound effect {}. Make sure you have aplay, gst-play-1.0, or gst-launch-1.0 available.",
|
||||
path);
|
||||
ERROR_LOG("Failed to play sound effect {}. Make sure you have aplay, gst-play-1.0, or gst-launch-1.0 available.",
|
||||
path);
|
||||
return false;
|
||||
#else
|
||||
return false;
|
||||
|
||||
@@ -21,7 +21,7 @@ static bool SetScreensaverInhibitWin32(bool inhibit)
|
||||
{
|
||||
if (SetThreadExecutionState(ES_CONTINUOUS | (inhibit ? (ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED) : 0)) == NULL)
|
||||
{
|
||||
Log_ErrorFmt("SetThreadExecutionState() failed: {}", GetLastError());
|
||||
ERROR_LOG("SetThreadExecutionState() failed: {}", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ void PlatformMisc::SuspendScreensaver()
|
||||
|
||||
if (!SetScreensaverInhibitWin32(true))
|
||||
{
|
||||
Log_ErrorPrint("Failed to suspend screensaver.");
|
||||
ERROR_LOG("Failed to suspend screensaver.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ void PlatformMisc::ResumeScreensaver()
|
||||
return;
|
||||
|
||||
if (!SetScreensaverInhibitWin32(false))
|
||||
Log_ErrorPrint("Failed to resume screensaver.");
|
||||
ERROR_LOG("Failed to resume screensaver.");
|
||||
|
||||
s_screensaver_suspended = false;
|
||||
}
|
||||
|
||||
@@ -422,7 +422,7 @@ std::unique_ptr<PostProcessing::Shader> PostProcessing::TryLoadingShader(const s
|
||||
return shader;
|
||||
}
|
||||
|
||||
Log_ErrorFmt("Failed to load shader '{}'", shader_name);
|
||||
ERROR_LOG("Failed to load shader '{}'", shader_name);
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -499,7 +499,7 @@ void PostProcessing::LoadStages()
|
||||
if (stage_count > 0)
|
||||
{
|
||||
s_timer.Reset();
|
||||
Log_DevFmt("Loaded {} post-processing stages.", stage_count);
|
||||
DEV_LOG("Loaded {} post-processing stages.", stage_count);
|
||||
}
|
||||
|
||||
// precompile shaders
|
||||
@@ -577,7 +577,7 @@ void PostProcessing::UpdateSettings()
|
||||
if (stage_count > 0)
|
||||
{
|
||||
s_timer.Reset();
|
||||
Log_DevFmt("Loaded {} post-processing stages.", stage_count);
|
||||
DEV_LOG("Loaded {} post-processing stages.", stage_count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -647,7 +647,7 @@ GPUSampler* PostProcessing::GetSampler(const GPUSampler::Config& config)
|
||||
|
||||
std::unique_ptr<GPUSampler> sampler = g_gpu_device->CreateSampler(config);
|
||||
if (!sampler)
|
||||
Log_ErrorFmt("Failed to create GPU sampler with config={:X}", config.key);
|
||||
ERROR_LOG("Failed to create GPU sampler with config={:X}", config.key);
|
||||
|
||||
it = s_samplers.emplace(config.key, std::move(sampler)).first;
|
||||
return it->second.get();
|
||||
@@ -662,7 +662,7 @@ GPUTexture* PostProcessing::GetDummyTexture()
|
||||
s_dummy_texture = g_gpu_device->FetchTexture(1, 1, 1, 1, 1, GPUTexture::Type::Texture, GPUTexture::Format::RGBA8,
|
||||
&zero, sizeof(zero));
|
||||
if (!s_dummy_texture)
|
||||
Log_ErrorPrint("Failed to create dummy texture.");
|
||||
ERROR_LOG("Failed to create dummy texture.");
|
||||
|
||||
return s_dummy_texture.get();
|
||||
}
|
||||
@@ -700,7 +700,7 @@ bool PostProcessing::CheckTargets(GPUTexture::Format target_format, u32 target_w
|
||||
if (!shader->CompilePipeline(target_format, target_width, target_height, progress) ||
|
||||
!shader->ResizeOutput(target_format, target_width, target_height))
|
||||
{
|
||||
Log_ErrorPrint("Failed to compile one or more post-processing shaders, disabling.");
|
||||
ERROR_LOG("Failed to compile one or more post-processing shaders, disabling.");
|
||||
Host::AddIconOSDMessage(
|
||||
"PostProcessLoadFail", ICON_FA_EXCLAMATION_TRIANGLE,
|
||||
fmt::format("Failed to compile post-processing shader '{}'. Disabling post-processing.", shader->GetName()));
|
||||
|
||||
@@ -91,8 +91,8 @@ void PostProcessing::Shader::LoadOptions(const SettingsInterface& si, const char
|
||||
ShaderOption::ParseFloatVector(config_value, &value);
|
||||
if (value_vector_size != option.vector_size)
|
||||
{
|
||||
Log_WarningFmt("Only got {} of {} elements for '{}' in config section %s.", value_vector_size,
|
||||
option.vector_size, option.name, section);
|
||||
WARNING_LOG("Only got {} of {} elements for '{}' in config section %s.", value_vector_size,
|
||||
option.vector_size, option.name, section);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -286,7 +286,7 @@ bool PostProcessing::ReShadeFXShader::LoadFromFile(std::string name, std::string
|
||||
std::optional<std::string> data = FileSystem::ReadFileToString(filename.c_str(), error);
|
||||
if (!data.has_value())
|
||||
{
|
||||
Log_ErrorFmt("Failed to read '{}'.", filename);
|
||||
ERROR_LOG("Failed to read '{}'.", filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -526,8 +526,8 @@ GetVectorAnnotationValue(const reshadefx::uniform_info& uniform, const std::stri
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorFmt("Unhandled string value for '{}' (annotation type: {}, uniform type {})", uniform.name,
|
||||
an.type.description(), uniform.type.description());
|
||||
ERROR_LOG("Unhandled string value for '{}' (annotation type: {}, uniform type {})", uniform.name,
|
||||
an.type.description(), uniform.type.description());
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -576,7 +576,7 @@ bool PostProcessing::ReShadeFXShader::CreateOptions(const reshadefx::module& mod
|
||||
return false;
|
||||
if (so != SourceOptionType::None)
|
||||
{
|
||||
Log_DevFmt("Add source based option {} at offset {} ({})", static_cast<u32>(so), ui.offset, ui.name);
|
||||
DEV_LOG("Add source based option {} at offset {} ({})", static_cast<u32>(so), ui.offset, ui.name);
|
||||
|
||||
SourceOption sopt;
|
||||
sopt.source = so;
|
||||
@@ -709,8 +709,8 @@ bool PostProcessing::ReShadeFXShader::CreateOptions(const reshadefx::module& mod
|
||||
|
||||
if (!ui_type.empty() && opt.vector_size > 1)
|
||||
{
|
||||
Log_WarningFmt("Uniform '{}' has UI type of '{}' but is vector not scalar ({}), ignoring", opt.name, ui_type,
|
||||
opt.vector_size);
|
||||
WARNING_LOG("Uniform '{}' has UI type of '{}' but is vector not scalar ({}), ignoring", opt.name, ui_type,
|
||||
opt.vector_size);
|
||||
}
|
||||
else if (!ui_type.empty())
|
||||
{
|
||||
@@ -746,7 +746,7 @@ bool PostProcessing::ReShadeFXShader::CreateOptions(const reshadefx::module& mod
|
||||
[](const ShaderOption& lhs, const ShaderOption& rhs) { return lhs.category < rhs.category; });
|
||||
|
||||
m_uniforms_size = mod.total_uniform_size;
|
||||
Log_DevFmt("{}: {} options", m_filename, m_options.size());
|
||||
DEV_LOG("{}: {} options", m_filename, m_options.size());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -818,7 +818,7 @@ bool PostProcessing::ReShadeFXShader::GetSourceOption(const reshadefx::uniform_i
|
||||
}
|
||||
else if (source == "mousebutton")
|
||||
{
|
||||
Log_WarningFmt("Ignoring mousebutton source in uniform '{}', not supported.", ui.name);
|
||||
WARNING_LOG("Ignoring mousebutton source in uniform '{}', not supported.", ui.name);
|
||||
*si = SourceOptionType::Zero;
|
||||
return true;
|
||||
}
|
||||
@@ -910,14 +910,14 @@ bool PostProcessing::ReShadeFXShader::CreatePasses(GPUTexture::Format backbuffer
|
||||
|
||||
if (!ti.semantic.empty())
|
||||
{
|
||||
Log_DevFmt("Ignoring semantic {} texture {}", ti.semantic, ti.unique_name);
|
||||
DEV_LOG("Ignoring semantic {} texture {}", ti.semantic, ti.unique_name);
|
||||
continue;
|
||||
}
|
||||
if (ti.render_target)
|
||||
{
|
||||
tex.rt_scale = 1.0f;
|
||||
tex.format = MapTextureFormat(ti.format);
|
||||
Log_DevFmt("Creating render target '{}' {}", ti.unique_name, GPUTexture::GetFormatName(tex.format));
|
||||
DEV_LOG("Creating render target '{}' {}", ti.unique_name, GPUTexture::GetFormatName(tex.format));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -953,7 +953,7 @@ bool PostProcessing::ReShadeFXShader::CreatePasses(GPUTexture::Format backbuffer
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_DevFmt("Loaded {}x{} texture ({})", image.GetWidth(), image.GetHeight(), source);
|
||||
DEV_LOG("Loaded {}x{} texture ({})", image.GetWidth(), image.GetHeight(), source);
|
||||
}
|
||||
|
||||
tex.reshade_name = ti.unique_name;
|
||||
@@ -1028,7 +1028,7 @@ bool PostProcessing::ReShadeFXShader::CreatePasses(GPUTexture::Format backbuffer
|
||||
}
|
||||
else if (ti.semantic == "DEPTH")
|
||||
{
|
||||
Log_WarningFmt("Shader '{}' uses input depth as '{}' which is not supported.", m_name, si.texture_name);
|
||||
WARNING_LOG("Shader '{}' uses input depth as '{}' which is not supported.", m_name, si.texture_name);
|
||||
sampler.texture_id = INPUT_DEPTH_TEXTURE;
|
||||
break;
|
||||
}
|
||||
@@ -1059,7 +1059,7 @@ bool PostProcessing::ReShadeFXShader::CreatePasses(GPUTexture::Format backbuffer
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_DevFmt("Pass {} Texture {} => {}", pi.name, si.texture_name, sampler.texture_id);
|
||||
DEV_LOG("Pass {} Texture {} => {}", pi.name, si.texture_name, sampler.texture_id);
|
||||
|
||||
sampler.sampler = GetSampler(MapSampler(si));
|
||||
if (!sampler.sampler)
|
||||
@@ -1138,7 +1138,7 @@ bool PostProcessing::ReShadeFXShader::CompilePipeline(GPUTexture::Format format,
|
||||
std::string fxcode;
|
||||
if (!PreprocessorReadFileCallback(m_filename, fxcode))
|
||||
{
|
||||
Log_ErrorFmt("Failed to re-read shader for pipeline: '{}'", m_filename);
|
||||
ERROR_LOG("Failed to re-read shader for pipeline: '{}'", m_filename);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1150,7 +1150,7 @@ bool PostProcessing::ReShadeFXShader::CompilePipeline(GPUTexture::Format format,
|
||||
reshadefx::module mod;
|
||||
if (!CreateModule(width, height, &mod, std::move(fxcode), &error))
|
||||
{
|
||||
Log_ErrorFmt("Failed to create module for '{}': {}", m_name, error.GetDescription());
|
||||
ERROR_LOG("Failed to create module for '{}': {}", m_name, error.GetDescription());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1158,7 +1158,7 @@ bool PostProcessing::ReShadeFXShader::CompilePipeline(GPUTexture::Format format,
|
||||
|
||||
if (!CreatePasses(format, mod, &error))
|
||||
{
|
||||
Log_ErrorFmt("Failed to create passes for '{}': {}", m_name, error.GetDescription());
|
||||
ERROR_LOG("Failed to create passes for '{}': {}", m_name, error.GetDescription());
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1213,7 +1213,7 @@ bool PostProcessing::ReShadeFXShader::CompilePipeline(GPUTexture::Format format,
|
||||
std::unique_ptr<GPUShader> sshader =
|
||||
g_gpu_device->CreateShader(stage, real_code, needs_main_defn ? "main" : name.c_str());
|
||||
if (!sshader)
|
||||
Log_ErrorFmt("Failed to compile function '{}'", name);
|
||||
ERROR_LOG("Failed to compile function '{}'", name);
|
||||
|
||||
return sshader;
|
||||
};
|
||||
@@ -1276,7 +1276,7 @@ bool PostProcessing::ReShadeFXShader::CompilePipeline(GPUTexture::Format format,
|
||||
pass.pipeline = g_gpu_device->CreatePipeline(plconfig);
|
||||
if (!pass.pipeline)
|
||||
{
|
||||
Log_ErrorFmt("Failed to create pipeline for pass '{}'", info.name);
|
||||
ERROR_LOG("Failed to create pipeline for pass '{}'", info.name);
|
||||
progress->PopState();
|
||||
return false;
|
||||
}
|
||||
@@ -1307,7 +1307,7 @@ bool PostProcessing::ReShadeFXShader::ResizeOutput(GPUTexture::Format format, u3
|
||||
tex.texture = g_gpu_device->FetchTexture(t_width, t_height, 1, 1, 1, GPUTexture::Type::RenderTarget, tex.format);
|
||||
if (!tex.texture)
|
||||
{
|
||||
Log_ErrorFmt("Failed to create {}x{} texture", t_width, t_height);
|
||||
ERROR_LOG("Failed to create {}x{} texture", t_width, t_height);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +112,8 @@ void PostProcessing::GLSLShader::FillUniformBuffer(void* buffer, u32 texture_wid
|
||||
}
|
||||
}
|
||||
|
||||
bool PostProcessing::GLSLShader::CompilePipeline(GPUTexture::Format format, u32 width, u32 height, ProgressCallback* progress)
|
||||
bool PostProcessing::GLSLShader::CompilePipeline(GPUTexture::Format format, u32 width, u32 height,
|
||||
ProgressCallback* progress)
|
||||
{
|
||||
if (m_pipeline)
|
||||
m_pipeline.reset();
|
||||
@@ -254,7 +255,7 @@ void PostProcessing::GLSLShader::LoadOptions()
|
||||
else if (sub == "OptionRangeInteger")
|
||||
current_option.type = ShaderOption::Type::Int;
|
||||
else
|
||||
Log_ErrorFmt("Invalid option type: '{}'", line_str);
|
||||
ERROR_LOG("Invalid option type: '{}'", line_str);
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -304,7 +305,7 @@ void PostProcessing::GLSLShader::LoadOptions()
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorFmt("Invalid option key: '{}'", line_str);
|
||||
ERROR_LOG("Invalid option key: '{}'", line_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
#include "audio_stream.h"
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/log.h"
|
||||
#include "common/error.h"
|
||||
#include "common/log.h"
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
@@ -62,7 +62,8 @@ SDLAudioStream::~SDLAudioStream()
|
||||
SDLAudioStream::CloseDevice();
|
||||
}
|
||||
|
||||
std::unique_ptr<AudioStream> AudioStream::CreateSDLAudioStream(u32 sample_rate, const AudioStreamParameters& parameters, Error* error)
|
||||
std::unique_ptr<AudioStream> AudioStream::CreateSDLAudioStream(u32 sample_rate, const AudioStreamParameters& parameters,
|
||||
Error* error)
|
||||
{
|
||||
if (!InitializeSDLAudio(error))
|
||||
return {};
|
||||
@@ -116,7 +117,7 @@ bool SDLAudioStream::OpenDevice(Error* error)
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_DevFmt("Requested {} frame buffer, got {} frame buffer", spec.samples, obtained_spec.samples);
|
||||
DEV_LOG("Requested {} frame buffer, got {} frame buffer", spec.samples, obtained_spec.samples);
|
||||
|
||||
BaseInitialize(sample_readers[static_cast<size_t>(m_parameters.expansion_mode)]);
|
||||
SDL_PauseAudioDevice(m_device_id, 0);
|
||||
|
||||
@@ -259,18 +259,18 @@ void SDLInputSource::SetHints()
|
||||
if (const std::string upath = Path::Combine(EmuFolders::DataRoot, CONTROLLER_DB_FILENAME);
|
||||
FileSystem::FileExists(upath.c_str()))
|
||||
{
|
||||
Log_InfoFmt("Using Controller DB from user directory: '{}'", upath);
|
||||
INFO_LOG("Using Controller DB from user directory: '{}'", upath);
|
||||
SDL_SetHint(SDL_HINT_GAMECONTROLLERCONFIG_FILE, upath.c_str());
|
||||
}
|
||||
else if (const std::string rpath = EmuFolders::GetOverridableResourcePath(CONTROLLER_DB_FILENAME);
|
||||
FileSystem::FileExists(rpath.c_str()))
|
||||
{
|
||||
Log_InfoPrint("Using Controller DB from resources.");
|
||||
INFO_LOG("Using Controller DB from resources.");
|
||||
SDL_SetHint(SDL_HINT_GAMECONTROLLERCONFIG_FILE, rpath.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorFmt("Controller DB not found, it should be named '{}'", CONTROLLER_DB_FILENAME);
|
||||
ERROR_LOG("Controller DB not found, it should be named '{}'", CONTROLLER_DB_FILENAME);
|
||||
}
|
||||
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, m_controller_enhanced_mode ? "1" : "0");
|
||||
@@ -279,8 +279,8 @@ void SDLInputSource::SetHints()
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS3, "1");
|
||||
|
||||
#ifdef __APPLE__
|
||||
Log_InfoFmt("IOKit is {}, MFI is {}.", m_enable_iokit_driver ? "enabled" : "disabled",
|
||||
m_enable_mfi_driver ? "enabled" : "disabled");
|
||||
INFO_LOG("IOKit is {}, MFI is {}.", m_enable_iokit_driver ? "enabled" : "disabled",
|
||||
m_enable_mfi_driver ? "enabled" : "disabled");
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_IOKIT, m_enable_iokit_driver ? "1" : "0");
|
||||
SDL_SetHint(SDL_HINT_JOYSTICK_MFI, m_enable_mfi_driver ? "1" : "0");
|
||||
#endif
|
||||
@@ -293,7 +293,7 @@ bool SDLInputSource::InitializeSubsystem()
|
||||
{
|
||||
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC) < 0)
|
||||
{
|
||||
Log_ErrorPrint("SDL_InitSubSystem(SDL_INIT_JOYSTICK |SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC) failed");
|
||||
ERROR_LOG("SDL_InitSubSystem(SDL_INIT_JOYSTICK |SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC) failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -306,7 +306,7 @@ bool SDLInputSource::InitializeSubsystem()
|
||||
|
||||
// we should open the controllers as the connected events come in, so no need to do any more here
|
||||
m_sdl_subsystem_initialized = true;
|
||||
Log_InfoFmt("{} controller mappings are loaded.", SDL_GameControllerNumMappings());
|
||||
INFO_LOG("{} controller mappings are loaded.", SDL_GameControllerNumMappings());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -580,14 +580,14 @@ bool SDLInputSource::ProcessSDLEvent(const SDL_Event* event)
|
||||
{
|
||||
case SDL_CONTROLLERDEVICEADDED:
|
||||
{
|
||||
Log_InfoFmt("Controller {} inserted", event->cdevice.which);
|
||||
INFO_LOG("Controller {} inserted", event->cdevice.which);
|
||||
OpenDevice(event->cdevice.which, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
case SDL_CONTROLLERDEVICEREMOVED:
|
||||
{
|
||||
Log_InfoFmt("Controller {} removed", event->cdevice.which);
|
||||
INFO_LOG("Controller {} removed", event->cdevice.which);
|
||||
CloseDevice(event->cdevice.which);
|
||||
return true;
|
||||
}
|
||||
@@ -598,7 +598,7 @@ bool SDLInputSource::ProcessSDLEvent(const SDL_Event* event)
|
||||
if (SDL_IsGameController(event->jdevice.which))
|
||||
return false;
|
||||
|
||||
Log_InfoFmt("Joystick {} inserted", event->jdevice.which);
|
||||
INFO_LOG("Joystick {} inserted", event->jdevice.which);
|
||||
OpenDevice(event->cdevice.which, false);
|
||||
return true;
|
||||
}
|
||||
@@ -610,7 +610,7 @@ bool SDLInputSource::ProcessSDLEvent(const SDL_Event* event)
|
||||
it != m_controllers.end() && it->game_controller)
|
||||
return false;
|
||||
|
||||
Log_InfoFmt("Joystick {} removed", event->jdevice.which);
|
||||
INFO_LOG("Joystick {} removed", event->jdevice.which);
|
||||
CloseDevice(event->cdevice.which);
|
||||
return true;
|
||||
}
|
||||
@@ -700,7 +700,7 @@ bool SDLInputSource::OpenDevice(int index, bool is_gamecontroller)
|
||||
|
||||
if (!gcontroller && !joystick)
|
||||
{
|
||||
Log_ErrorFmt("Failed to open controller {}", index);
|
||||
ERROR_LOG("Failed to open controller {}", index);
|
||||
if (gcontroller)
|
||||
SDL_GameControllerClose(gcontroller);
|
||||
|
||||
@@ -712,9 +712,8 @@ bool SDLInputSource::OpenDevice(int index, bool is_gamecontroller)
|
||||
if (player_id < 0 || GetControllerDataForPlayerId(player_id) != m_controllers.end())
|
||||
{
|
||||
const int free_player_id = GetFreePlayerId();
|
||||
Log_WarningFmt(
|
||||
"Controller {} (joystick {}) returned player ID {}, which is invalid or in use. Using ID {} instead.", index,
|
||||
joystick_id, player_id, free_player_id);
|
||||
WARNING_LOG("Controller {} (joystick {}) returned player ID {}, which is invalid or in use. Using ID {} instead.",
|
||||
index, joystick_id, player_id, free_player_id);
|
||||
player_id = free_player_id;
|
||||
}
|
||||
|
||||
@@ -722,8 +721,8 @@ bool SDLInputSource::OpenDevice(int index, bool is_gamecontroller)
|
||||
if (!name)
|
||||
name = "Unknown Device";
|
||||
|
||||
Log_VerboseFmt("Opened {} {} (instance id {}, player id {}): {}", is_gamecontroller ? "game controller" : "joystick",
|
||||
index, joystick_id, player_id, name);
|
||||
VERBOSE_LOG("Opened {} {} (instance id {}, player id {}): {}", is_gamecontroller ? "game controller" : "joystick",
|
||||
index, joystick_id, player_id, name);
|
||||
|
||||
ControllerData cd = {};
|
||||
cd.player_id = player_id;
|
||||
@@ -749,7 +748,7 @@ bool SDLInputSource::OpenDevice(int index, bool is_gamecontroller)
|
||||
for (size_t i = 0; i < std::size(s_sdl_button_names); i++)
|
||||
mark_bind(SDL_GameControllerGetBindForButton(gcontroller, static_cast<SDL_GameControllerButton>(i)));
|
||||
|
||||
Log_VerboseFmt("Controller {} has {} axes and {} buttons", player_id, num_axes, num_buttons);
|
||||
VERBOSE_LOG("Controller {} has {} axes and {} buttons", player_id, num_axes, num_buttons);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -758,14 +757,14 @@ bool SDLInputSource::OpenDevice(int index, bool is_gamecontroller)
|
||||
if (num_hats > 0)
|
||||
cd.last_hat_state.resize(static_cast<size_t>(num_hats), u8(0));
|
||||
|
||||
Log_VerboseFmt("Joystick {} has {} axes, {} buttons and {} hats", player_id, SDL_JoystickNumAxes(joystick),
|
||||
SDL_JoystickNumButtons(joystick), num_hats);
|
||||
VERBOSE_LOG("Joystick {} has {} axes, {} buttons and {} hats", player_id, SDL_JoystickNumAxes(joystick),
|
||||
SDL_JoystickNumButtons(joystick), num_hats);
|
||||
}
|
||||
|
||||
cd.use_game_controller_rumble = (gcontroller && SDL_GameControllerRumble(gcontroller, 0, 0, 0) == 0);
|
||||
if (cd.use_game_controller_rumble)
|
||||
{
|
||||
Log_VerboseFmt("Rumble is supported on '{}' via gamecontroller", name);
|
||||
VERBOSE_LOG("Rumble is supported on '{}' via gamecontroller", name);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -784,25 +783,25 @@ bool SDLInputSource::OpenDevice(int index, bool is_gamecontroller)
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorFmt("Failed to create haptic left/right effect: {}", SDL_GetError());
|
||||
ERROR_LOG("Failed to create haptic left/right effect: {}", SDL_GetError());
|
||||
if (SDL_HapticRumbleSupported(haptic) && SDL_HapticRumbleInit(haptic) != 0)
|
||||
{
|
||||
cd.haptic = haptic;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorFmt("No haptic rumble supported: {}", SDL_GetError());
|
||||
ERROR_LOG("No haptic rumble supported: {}", SDL_GetError());
|
||||
SDL_HapticClose(haptic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cd.haptic)
|
||||
Log_VerboseFmt("Rumble is supported on '{}' via haptic", name);
|
||||
VERBOSE_LOG("Rumble is supported on '{}' via haptic", name);
|
||||
}
|
||||
|
||||
if (!cd.haptic && !cd.use_game_controller_rumble)
|
||||
Log_VerboseFmt("Rumble is not supported on '{}'", name);
|
||||
VERBOSE_LOG("Rumble is not supported on '{}'", name);
|
||||
|
||||
if (player_id >= 0 && static_cast<u32>(player_id) < MAX_LED_COLORS && gcontroller &&
|
||||
SDL_GameControllerHasLED(gcontroller))
|
||||
|
||||
@@ -100,7 +100,7 @@ TinyString ShaderGen::GetGLSLVersionString(RenderAPI render_api)
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorFmt("Invalid GLSL version string: '{}' ('{}')", glsl_version, glsl_version_start);
|
||||
ERROR_LOG("Invalid GLSL version string: '{}' ('{}')", glsl_version, glsl_version_start);
|
||||
if (glsl_es)
|
||||
{
|
||||
major_version = 3;
|
||||
|
||||
@@ -87,6 +87,6 @@ bool StateWrapper::DoMarker(const char* marker)
|
||||
if (m_mode == Mode::Write || file_value.equals(marker))
|
||||
return true;
|
||||
|
||||
Log_ErrorFmt("Marker mismatch at offset {}: found '{}' expected '{}'", m_stream->GetPosition(), file_value, marker);
|
||||
ERROR_LOG("Marker mismatch at offset {}: found '{}' expected '{}'", m_stream->GetPosition(), file_value, marker);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -105,8 +105,8 @@ const char* Vulkan::VkResultToString(VkResult res)
|
||||
|
||||
void Vulkan::LogVulkanResult(const char* func_name, VkResult res, std::string_view msg)
|
||||
{
|
||||
Log::WriteFmt("VulkanDevice", func_name, LOGLEVEL_ERROR, "{} (0x{:08X}: {})", msg, static_cast<unsigned>(res),
|
||||
VkResultToString(res));
|
||||
Log::FastWrite("VulkanDevice", func_name, LOGLEVEL_ERROR, "{} (0x{:08X}: {})", msg, static_cast<unsigned>(res),
|
||||
VkResultToString(res));
|
||||
}
|
||||
|
||||
Vulkan::DescriptorSetLayoutBuilder::DescriptorSetLayoutBuilder()
|
||||
|
||||
+100
-102
@@ -149,14 +149,14 @@ VkInstance VulkanDevice::CreateVulkanInstance(const WindowInfo& wi, OptionalExte
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_WarningPrint("Driver does not provide vkEnumerateInstanceVersion().");
|
||||
WARNING_LOG("Driver does not provide vkEnumerateInstanceVersion().");
|
||||
}
|
||||
|
||||
// Cap out at 1.1 for consistency.
|
||||
const u32 apiVersion = std::min(maxApiVersion, VK_API_VERSION_1_1);
|
||||
Log_InfoFmt("Supported instance version: {}.{}.{}, requesting version {}.{}.{}", VK_API_VERSION_MAJOR(maxApiVersion),
|
||||
VK_API_VERSION_MINOR(maxApiVersion), VK_API_VERSION_PATCH(maxApiVersion),
|
||||
VK_API_VERSION_MAJOR(apiVersion), VK_API_VERSION_MINOR(apiVersion), VK_API_VERSION_PATCH(apiVersion));
|
||||
INFO_LOG("Supported instance version: {}.{}.{}, requesting version {}.{}.{}", VK_API_VERSION_MAJOR(maxApiVersion),
|
||||
VK_API_VERSION_MINOR(maxApiVersion), VK_API_VERSION_PATCH(maxApiVersion), VK_API_VERSION_MAJOR(apiVersion),
|
||||
VK_API_VERSION_MINOR(apiVersion), VK_API_VERSION_PATCH(apiVersion));
|
||||
|
||||
// Remember to manually update this every release. We don't pull in svnrev.h here, because
|
||||
// it's only the major/minor version, and rebuilding the file every time something else changes
|
||||
@@ -212,7 +212,7 @@ bool VulkanDevice::SelectInstanceExtensions(ExtensionList* extension_list, const
|
||||
|
||||
if (extension_count == 0)
|
||||
{
|
||||
Log_ErrorPrint("Vulkan: No extensions supported by instance.");
|
||||
ERROR_LOG("Vulkan: No extensions supported by instance.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -226,13 +226,13 @@ bool VulkanDevice::SelectInstanceExtensions(ExtensionList* extension_list, const
|
||||
return !strcmp(name, properties.extensionName);
|
||||
}) != available_extension_list.end())
|
||||
{
|
||||
Log_DevFmt("Enabling extension: {}", name);
|
||||
DEV_LOG("Enabling extension: {}", name);
|
||||
extension_list->push_back(name);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (required)
|
||||
Log_ErrorFmt("Vulkan: Missing required extension {}.", name);
|
||||
ERROR_LOG("Vulkan: Missing required extension {}.", name);
|
||||
|
||||
return false;
|
||||
};
|
||||
@@ -264,7 +264,7 @@ bool VulkanDevice::SelectInstanceExtensions(ExtensionList* extension_list, const
|
||||
|
||||
// VK_EXT_debug_utils
|
||||
if (enable_debug_utils && !SupportsExtension(VK_EXT_DEBUG_UTILS_EXTENSION_NAME, false))
|
||||
Log_WarningPrint("Vulkan: Debug report requested, but extension is not available.");
|
||||
WARNING_LOG("Vulkan: Debug report requested, but extension is not available.");
|
||||
|
||||
// Needed for exclusive fullscreen control.
|
||||
SupportsExtension(VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME, false);
|
||||
@@ -291,8 +291,8 @@ VulkanDevice::GPUList VulkanDevice::EnumerateGPUs(VkInstance instance)
|
||||
res = vkEnumeratePhysicalDevices(instance, &gpu_count, physical_devices.data());
|
||||
if (res == VK_INCOMPLETE)
|
||||
{
|
||||
Log_WarningFmt("First vkEnumeratePhysicalDevices() call returned {} devices, but second returned {}",
|
||||
physical_devices.size(), gpu_count);
|
||||
WARNING_LOG("First vkEnumeratePhysicalDevices() call returned {} devices, but second returned {}",
|
||||
physical_devices.size(), gpu_count);
|
||||
}
|
||||
else if (res != VK_SUCCESS)
|
||||
{
|
||||
@@ -344,7 +344,7 @@ bool VulkanDevice::SelectDeviceExtensions(ExtensionList* extension_list, bool en
|
||||
|
||||
if (extension_count == 0)
|
||||
{
|
||||
Log_ErrorPrint("Vulkan: No extensions supported by device.");
|
||||
ERROR_LOG("Vulkan: No extensions supported by device.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ bool VulkanDevice::SelectDeviceExtensions(ExtensionList* extension_list, bool en
|
||||
if (std::none_of(extension_list->begin(), extension_list->end(),
|
||||
[&](const char* existing_name) { return (std::strcmp(existing_name, name) == 0); }))
|
||||
{
|
||||
Log_DevFmt("Enabling extension: {}", name);
|
||||
DEV_LOG("Enabling extension: {}", name);
|
||||
extension_list->push_back(name);
|
||||
}
|
||||
|
||||
@@ -370,7 +370,7 @@ bool VulkanDevice::SelectDeviceExtensions(ExtensionList* extension_list, bool en
|
||||
}
|
||||
|
||||
if (required)
|
||||
Log_ErrorFmt("Vulkan: Missing required extension {}.", name);
|
||||
ERROR_LOG("Vulkan: Missing required extension {}.", name);
|
||||
|
||||
return false;
|
||||
};
|
||||
@@ -413,8 +413,8 @@ bool VulkanDevice::SelectDeviceExtensions(ExtensionList* extension_list, bool en
|
||||
#ifdef _WIN32
|
||||
m_optional_extensions.vk_ext_full_screen_exclusive =
|
||||
enable_surface && SupportsExtension(VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME, false);
|
||||
Log_InfoFmt("VK_EXT_full_screen_exclusive is {}",
|
||||
m_optional_extensions.vk_ext_full_screen_exclusive ? "supported" : "NOT supported");
|
||||
INFO_LOG("VK_EXT_full_screen_exclusive is {}",
|
||||
m_optional_extensions.vk_ext_full_screen_exclusive ? "supported" : "NOT supported");
|
||||
#endif
|
||||
|
||||
return true;
|
||||
@@ -450,13 +450,13 @@ bool VulkanDevice::CreateDevice(VkSurfaceKHR surface, bool enable_validation_lay
|
||||
vkGetPhysicalDeviceQueueFamilyProperties(m_physical_device, &queue_family_count, nullptr);
|
||||
if (queue_family_count == 0)
|
||||
{
|
||||
Log_ErrorPrint("No queue families found on specified vulkan physical device.");
|
||||
ERROR_LOG("No queue families found on specified vulkan physical device.");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<VkQueueFamilyProperties> queue_family_properties(queue_family_count);
|
||||
vkGetPhysicalDeviceQueueFamilyProperties(m_physical_device, &queue_family_count, queue_family_properties.data());
|
||||
Log_DevFmt("{} vulkan queue families", queue_family_count);
|
||||
DEV_LOG("{} vulkan queue families", queue_family_count);
|
||||
|
||||
// Find graphics and present queues.
|
||||
m_graphics_queue_family_index = queue_family_count;
|
||||
@@ -498,12 +498,12 @@ bool VulkanDevice::CreateDevice(VkSurfaceKHR surface, bool enable_validation_lay
|
||||
}
|
||||
if (m_graphics_queue_family_index == queue_family_count)
|
||||
{
|
||||
Log_ErrorPrint("Vulkan: Failed to find an acceptable graphics queue.");
|
||||
ERROR_LOG("Vulkan: Failed to find an acceptable graphics queue.");
|
||||
return false;
|
||||
}
|
||||
if (surface != VK_NULL_HANDLE && m_present_queue_family_index == queue_family_count)
|
||||
{
|
||||
Log_ErrorPrint("Vulkan: Failed to find an acceptable present queue.");
|
||||
ERROR_LOG("Vulkan: Failed to find an acceptable present queue.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -593,11 +593,11 @@ bool VulkanDevice::CreateDevice(VkSurfaceKHR surface, bool enable_validation_lay
|
||||
m_features.gpu_timing = (m_device_properties.limits.timestampComputeAndGraphics != 0 &&
|
||||
queue_family_properties[m_graphics_queue_family_index].timestampValidBits > 0 &&
|
||||
m_device_properties.limits.timestampPeriod > 0);
|
||||
Log_DevFmt("GPU timing is {} (TS={} TS valid bits={}, TS period={})",
|
||||
m_features.gpu_timing ? "supported" : "not supported",
|
||||
static_cast<u32>(m_device_properties.limits.timestampComputeAndGraphics),
|
||||
queue_family_properties[m_graphics_queue_family_index].timestampValidBits,
|
||||
m_device_properties.limits.timestampPeriod);
|
||||
DEV_LOG("GPU timing is {} (TS={} TS valid bits={}, TS period={})",
|
||||
m_features.gpu_timing ? "supported" : "not supported",
|
||||
static_cast<u32>(m_device_properties.limits.timestampComputeAndGraphics),
|
||||
queue_family_properties[m_graphics_queue_family_index].timestampValidBits,
|
||||
m_device_properties.limits.timestampPeriod);
|
||||
|
||||
ProcessDeviceExtensions();
|
||||
return true;
|
||||
@@ -631,8 +631,7 @@ void VulkanDevice::ProcessDeviceExtensions()
|
||||
if (!vkGetPhysicalDeviceFeatures2KHR || !vkGetPhysicalDeviceProperties2KHR ||
|
||||
!vkGetPhysicalDeviceMemoryProperties2KHR)
|
||||
{
|
||||
Log_ErrorPrint(
|
||||
"One or more functions from VK_KHR_get_physical_device_properties2 is missing, disabling extension.");
|
||||
ERROR_LOG("One or more functions from VK_KHR_get_physical_device_properties2 is missing, disabling extension.");
|
||||
m_optional_extensions.vk_khr_get_physical_device_properties2 = false;
|
||||
vkGetPhysicalDeviceFeatures2 = nullptr;
|
||||
vkGetPhysicalDeviceProperties2 = nullptr;
|
||||
@@ -691,43 +690,42 @@ void VulkanDevice::ProcessDeviceExtensions()
|
||||
{
|
||||
m_optional_extensions.vk_khr_dynamic_rendering = false;
|
||||
m_optional_extensions.vk_khr_dynamic_rendering_local_read = false;
|
||||
Log_WarningPrint("Disabling VK_KHR_dynamic_rendering on broken mobile driver.");
|
||||
WARNING_LOG("Disabling VK_KHR_dynamic_rendering on broken mobile driver.");
|
||||
}
|
||||
if (m_optional_extensions.vk_khr_push_descriptor)
|
||||
{
|
||||
m_optional_extensions.vk_khr_push_descriptor = false;
|
||||
Log_WarningPrint("Disabling VK_KHR_push_descriptor on broken mobile driver.");
|
||||
WARNING_LOG("Disabling VK_KHR_push_descriptor on broken mobile driver.");
|
||||
}
|
||||
}
|
||||
|
||||
Log_InfoFmt("VK_EXT_memory_budget is {}", m_optional_extensions.vk_ext_memory_budget ? "supported" : "NOT supported");
|
||||
Log_InfoFmt("VK_EXT_rasterization_order_attachment_access is {}",
|
||||
m_optional_extensions.vk_ext_rasterization_order_attachment_access ? "supported" : "NOT supported");
|
||||
Log_InfoFmt("VK_KHR_get_memory_requirements2 is {}",
|
||||
m_optional_extensions.vk_khr_get_memory_requirements2 ? "supported" : "NOT supported");
|
||||
Log_InfoFmt("VK_KHR_bind_memory2 is {}", m_optional_extensions.vk_khr_bind_memory2 ? "supported" : "NOT supported");
|
||||
Log_InfoFmt("VK_KHR_get_physical_device_properties2 is {}",
|
||||
m_optional_extensions.vk_khr_get_physical_device_properties2 ? "supported" : "NOT supported");
|
||||
Log_InfoFmt("VK_KHR_dedicated_allocation is {}",
|
||||
m_optional_extensions.vk_khr_dedicated_allocation ? "supported" : "NOT supported");
|
||||
Log_InfoFmt("VK_KHR_dynamic_rendering is {}",
|
||||
m_optional_extensions.vk_khr_dynamic_rendering ? "supported" : "NOT supported");
|
||||
Log_InfoFmt("VK_KHR_dynamic_rendering_local_read is {}",
|
||||
m_optional_extensions.vk_khr_dynamic_rendering_local_read ? "supported" : "NOT supported");
|
||||
Log_InfoFmt("VK_KHR_push_descriptor is {}",
|
||||
m_optional_extensions.vk_khr_push_descriptor ? "supported" : "NOT supported");
|
||||
Log_InfoFmt("VK_EXT_external_memory_host is {}",
|
||||
m_optional_extensions.vk_ext_external_memory_host ? "supported" : "NOT supported");
|
||||
INFO_LOG("VK_EXT_memory_budget is {}", m_optional_extensions.vk_ext_memory_budget ? "supported" : "NOT supported");
|
||||
INFO_LOG("VK_EXT_rasterization_order_attachment_access is {}",
|
||||
m_optional_extensions.vk_ext_rasterization_order_attachment_access ? "supported" : "NOT supported");
|
||||
INFO_LOG("VK_KHR_get_memory_requirements2 is {}",
|
||||
m_optional_extensions.vk_khr_get_memory_requirements2 ? "supported" : "NOT supported");
|
||||
INFO_LOG("VK_KHR_bind_memory2 is {}", m_optional_extensions.vk_khr_bind_memory2 ? "supported" : "NOT supported");
|
||||
INFO_LOG("VK_KHR_get_physical_device_properties2 is {}",
|
||||
m_optional_extensions.vk_khr_get_physical_device_properties2 ? "supported" : "NOT supported");
|
||||
INFO_LOG("VK_KHR_dedicated_allocation is {}",
|
||||
m_optional_extensions.vk_khr_dedicated_allocation ? "supported" : "NOT supported");
|
||||
INFO_LOG("VK_KHR_dynamic_rendering is {}",
|
||||
m_optional_extensions.vk_khr_dynamic_rendering ? "supported" : "NOT supported");
|
||||
INFO_LOG("VK_KHR_dynamic_rendering_local_read is {}",
|
||||
m_optional_extensions.vk_khr_dynamic_rendering_local_read ? "supported" : "NOT supported");
|
||||
INFO_LOG("VK_KHR_push_descriptor is {}",
|
||||
m_optional_extensions.vk_khr_push_descriptor ? "supported" : "NOT supported");
|
||||
INFO_LOG("VK_EXT_external_memory_host is {}",
|
||||
m_optional_extensions.vk_ext_external_memory_host ? "supported" : "NOT supported");
|
||||
}
|
||||
|
||||
bool VulkanDevice::CreateAllocator()
|
||||
{
|
||||
const u32 apiVersion = std::min(m_device_properties.apiVersion, VK_API_VERSION_1_1);
|
||||
Log_InfoFmt("Supported device API version: {}.{}.{}, using version {}.{}.{} for allocator.",
|
||||
VK_API_VERSION_MAJOR(m_device_properties.apiVersion),
|
||||
VK_API_VERSION_MINOR(m_device_properties.apiVersion),
|
||||
VK_API_VERSION_PATCH(m_device_properties.apiVersion), VK_API_VERSION_MAJOR(apiVersion),
|
||||
VK_API_VERSION_MINOR(apiVersion), VK_API_VERSION_PATCH(apiVersion));
|
||||
INFO_LOG("Supported device API version: {}.{}.{}, using version {}.{}.{} for allocator.",
|
||||
VK_API_VERSION_MAJOR(m_device_properties.apiVersion), VK_API_VERSION_MINOR(m_device_properties.apiVersion),
|
||||
VK_API_VERSION_PATCH(m_device_properties.apiVersion), VK_API_VERSION_MAJOR(apiVersion),
|
||||
VK_API_VERSION_MINOR(apiVersion), VK_API_VERSION_PATCH(apiVersion));
|
||||
|
||||
VmaAllocatorCreateInfo ci = {};
|
||||
ci.vulkanApiVersion = apiVersion;
|
||||
@@ -740,19 +738,19 @@ bool VulkanDevice::CreateAllocator()
|
||||
{
|
||||
if (m_optional_extensions.vk_khr_get_memory_requirements2 && m_optional_extensions.vk_khr_dedicated_allocation)
|
||||
{
|
||||
Log_DevPrint("Enabling VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT on < Vulkan 1.1.");
|
||||
DEV_LOG("Enabling VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT on < Vulkan 1.1.");
|
||||
ci.flags |= VMA_ALLOCATOR_CREATE_KHR_DEDICATED_ALLOCATION_BIT;
|
||||
}
|
||||
if (m_optional_extensions.vk_khr_bind_memory2)
|
||||
{
|
||||
Log_DevPrint("Enabling VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT on < Vulkan 1.1.");
|
||||
DEV_LOG("Enabling VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT on < Vulkan 1.1.");
|
||||
ci.flags |= VMA_ALLOCATOR_CREATE_KHR_BIND_MEMORY2_BIT;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_optional_extensions.vk_ext_memory_budget)
|
||||
{
|
||||
Log_DevPrint("Enabling VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT.");
|
||||
DEV_LOG("Enabling VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT.");
|
||||
ci.flags |= VMA_ALLOCATOR_CREATE_EXT_MEMORY_BUDGET_BIT;
|
||||
}
|
||||
|
||||
@@ -783,8 +781,8 @@ bool VulkanDevice::CreateAllocator()
|
||||
|
||||
if (heap_size_limits[type.heapIndex] == VK_WHOLE_SIZE)
|
||||
{
|
||||
Log_WarningFmt("Disabling allocation from upload heap #{} ({:.2f} MB) due to debug device.", type.heapIndex,
|
||||
static_cast<float>(heap.size) / 1048576.0f);
|
||||
WARNING_LOG("Disabling allocation from upload heap #{} ({:.2f} MB) due to debug device.", type.heapIndex,
|
||||
static_cast<float>(heap.size) / 1048576.0f);
|
||||
heap_size_limits[type.heapIndex] = 0;
|
||||
has_upload_heap = true;
|
||||
}
|
||||
@@ -1179,7 +1177,7 @@ void VulkanDevice::WaitForCommandBufferCompletion(u32 index)
|
||||
// We might be waiting for the buffer we just submitted to the worker thread.
|
||||
if (m_queued_present.command_buffer_index == index && !m_present_done.load(std::memory_order_acquire))
|
||||
{
|
||||
Log_WarningFmt("Waiting for threaded submission of cmdbuffer {}", index);
|
||||
WARNING_LOG("Waiting for threaded submission of cmdbuffer {}", index);
|
||||
WaitForPresentComplete();
|
||||
}
|
||||
|
||||
@@ -1194,7 +1192,7 @@ void VulkanDevice::WaitForCommandBufferCompletion(u32 index)
|
||||
|
||||
if (res == VK_TIMEOUT && (++timeouts) <= MAX_TIMEOUTS)
|
||||
{
|
||||
Log_ErrorFmt("vkWaitForFences() for cmdbuffer {} failed with VK_TIMEOUT, trying again.", index);
|
||||
ERROR_LOG("vkWaitForFences() for cmdbuffer {} failed with VK_TIMEOUT, trying again.", index);
|
||||
continue;
|
||||
}
|
||||
else if (res != VK_SUCCESS)
|
||||
@@ -1506,7 +1504,7 @@ void VulkanDevice::SubmitCommandBuffer(bool wait_for_completion, const char* rea
|
||||
const std::string reason_str(StringUtil::StdStringFromFormatV(reason, ap));
|
||||
va_end(ap);
|
||||
|
||||
Log_WarningFmt("Executing command buffer due to '{}'", reason_str);
|
||||
WARNING_LOG("Executing command buffer due to '{}'", reason_str);
|
||||
SubmitCommandBuffer(wait_for_completion);
|
||||
}
|
||||
|
||||
@@ -1588,23 +1586,23 @@ VKAPI_ATTR VkBool32 VKAPI_CALL DebugMessengerCallback(VkDebugUtilsMessageSeverit
|
||||
{
|
||||
if (severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT)
|
||||
{
|
||||
Log_ErrorFmt("Vulkan debug report: ({}) {}", pCallbackData->pMessageIdName ? pCallbackData->pMessageIdName : "",
|
||||
pCallbackData->pMessage);
|
||||
ERROR_LOG("Vulkan debug report: ({}) {}", pCallbackData->pMessageIdName ? pCallbackData->pMessageIdName : "",
|
||||
pCallbackData->pMessage);
|
||||
}
|
||||
else if (severity & (VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT))
|
||||
{
|
||||
Log_WarningFmt("Vulkan debug report: ({}) {}", pCallbackData->pMessageIdName ? pCallbackData->pMessageIdName : "",
|
||||
pCallbackData->pMessage);
|
||||
WARNING_LOG("Vulkan debug report: ({}) {}", pCallbackData->pMessageIdName ? pCallbackData->pMessageIdName : "",
|
||||
pCallbackData->pMessage);
|
||||
}
|
||||
else if (severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT)
|
||||
{
|
||||
Log_InfoFmt("Vulkan debug report: ({}) {}", pCallbackData->pMessageIdName ? pCallbackData->pMessageIdName : "",
|
||||
pCallbackData->pMessage);
|
||||
INFO_LOG("Vulkan debug report: ({}) {}", pCallbackData->pMessageIdName ? pCallbackData->pMessageIdName : "",
|
||||
pCallbackData->pMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_DevFmt("Vulkan debug report: ({}) {}", pCallbackData->pMessageIdName ? pCallbackData->pMessageIdName : "",
|
||||
pCallbackData->pMessage);
|
||||
DEV_LOG("Vulkan debug report: ({}) {}", pCallbackData->pMessageIdName ? pCallbackData->pMessageIdName : "",
|
||||
pCallbackData->pMessage);
|
||||
}
|
||||
|
||||
return VK_FALSE;
|
||||
@@ -1894,12 +1892,12 @@ bool VulkanDevice::IsSuitableDefaultRenderer()
|
||||
|
||||
// Check the first GPU, should be enough.
|
||||
const std::string& name = aml.adapter_names.front();
|
||||
Log_InfoFmt("Using Vulkan GPU '{}' for automatic renderer check.", name);
|
||||
INFO_LOG("Using Vulkan GPU '{}' for automatic renderer check.", name);
|
||||
|
||||
// Any software rendering (LLVMpipe, SwiftShader).
|
||||
if (StringUtil::StartsWithNoCase(name, "llvmpipe") || StringUtil::StartsWithNoCase(name, "SwiftShader"))
|
||||
{
|
||||
Log_InfoPrint("Not using Vulkan for software renderer.");
|
||||
INFO_LOG("Not using Vulkan for software renderer.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1907,11 +1905,11 @@ bool VulkanDevice::IsSuitableDefaultRenderer()
|
||||
// Plus, the Ivy Bridge and Haswell drivers are incomplete.
|
||||
if (StringUtil::StartsWithNoCase(name, "Intel"))
|
||||
{
|
||||
Log_InfoPrint("Not using Vulkan for Intel GPU.");
|
||||
INFO_LOG("Not using Vulkan for Intel GPU.");
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_InfoPrint("Allowing Vulkan as default renderer.");
|
||||
INFO_LOG("Allowing Vulkan as default renderer.");
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
@@ -1957,13 +1955,13 @@ bool VulkanDevice::CreateDevice(std::string_view adapter, bool threaded_presenta
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_ErrorPrint("Vulkan validation/debug layers requested but are unavailable. Creating non-debug device.");
|
||||
ERROR_LOG("Vulkan validation/debug layers requested but are unavailable. Creating non-debug device.");
|
||||
}
|
||||
}
|
||||
|
||||
if (!Vulkan::LoadVulkanInstanceFunctions(m_instance))
|
||||
{
|
||||
Log_ErrorPrint("Failed to load Vulkan instance functions");
|
||||
ERROR_LOG("Failed to load Vulkan instance functions");
|
||||
Error::SetStringView(error, "Failed to load Vulkan instance functions");
|
||||
return false;
|
||||
}
|
||||
@@ -1980,7 +1978,7 @@ bool VulkanDevice::CreateDevice(std::string_view adapter, bool threaded_presenta
|
||||
u32 gpu_index = 0;
|
||||
for (; gpu_index < static_cast<u32>(gpus.size()); gpu_index++)
|
||||
{
|
||||
Log_InfoFmt("GPU {}: {}", gpu_index, gpus[gpu_index].second);
|
||||
INFO_LOG("GPU {}: {}", gpu_index, gpus[gpu_index].second);
|
||||
if (gpus[gpu_index].second == adapter)
|
||||
{
|
||||
m_physical_device = gpus[gpu_index].first;
|
||||
@@ -1990,13 +1988,13 @@ bool VulkanDevice::CreateDevice(std::string_view adapter, bool threaded_presenta
|
||||
|
||||
if (gpu_index == static_cast<u32>(gpus.size()))
|
||||
{
|
||||
Log_WarningFmt("Requested GPU '{}' not found, using first ({})", adapter, gpus[0].second);
|
||||
WARNING_LOG("Requested GPU '{}' not found, using first ({})", adapter, gpus[0].second);
|
||||
m_physical_device = gpus[0].first;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_InfoFmt("No GPU requested, using first ({})", gpus[0].second);
|
||||
INFO_LOG("No GPU requested, using first ({})", gpus[0].second);
|
||||
m_physical_device = gpus[0].first;
|
||||
}
|
||||
|
||||
@@ -2144,33 +2142,33 @@ bool VulkanDevice::ValidatePipelineCacheHeader(const VK_PIPELINE_CACHE_HEADER& h
|
||||
{
|
||||
if (header.header_length < sizeof(VK_PIPELINE_CACHE_HEADER))
|
||||
{
|
||||
Log_ErrorPrint("Pipeline cache failed validation: Invalid header length");
|
||||
ERROR_LOG("Pipeline cache failed validation: Invalid header length");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (header.header_version != VK_PIPELINE_CACHE_HEADER_VERSION_ONE)
|
||||
{
|
||||
Log_ErrorPrint("Pipeline cache failed validation: Invalid header version");
|
||||
ERROR_LOG("Pipeline cache failed validation: Invalid header version");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (header.vendor_id != m_device_properties.vendorID)
|
||||
{
|
||||
Log_ErrorFmt("Pipeline cache failed validation: Incorrect vendor ID (file: 0x{:X}, device: 0x{:X})",
|
||||
header.vendor_id, m_device_properties.vendorID);
|
||||
ERROR_LOG("Pipeline cache failed validation: Incorrect vendor ID (file: 0x{:X}, device: 0x{:X})", header.vendor_id,
|
||||
m_device_properties.vendorID);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (header.device_id != m_device_properties.deviceID)
|
||||
{
|
||||
Log_ErrorFmt("Pipeline cache failed validation: Incorrect device ID (file: 0x{:X}, device: 0x{:X})",
|
||||
header.device_id, m_device_properties.deviceID);
|
||||
ERROR_LOG("Pipeline cache failed validation: Incorrect device ID (file: 0x{:X}, device: 0x{:X})", header.device_id,
|
||||
m_device_properties.deviceID);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (std::memcmp(header.uuid, m_device_properties.pipelineCacheUUID, VK_UUID_SIZE) != 0)
|
||||
{
|
||||
Log_ErrorPrint("Pipeline cache failed validation: Incorrect UUID");
|
||||
ERROR_LOG("Pipeline cache failed validation: Incorrect UUID");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2199,7 +2197,7 @@ bool VulkanDevice::ReadPipelineCache(const std::string& filename)
|
||||
{
|
||||
if (data->size() < sizeof(VK_PIPELINE_CACHE_HEADER))
|
||||
{
|
||||
Log_ErrorFmt("Pipeline cache at '{}' is too small", Path::GetFileName(filename));
|
||||
ERROR_LOG("Pipeline cache at '{}' is too small", Path::GetFileName(filename));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -2266,14 +2264,14 @@ bool VulkanDevice::UpdateWindow()
|
||||
VkSurfaceKHR surface = VulkanSwapChain::CreateVulkanSurface(m_instance, m_physical_device, &m_window_info);
|
||||
if (surface == VK_NULL_HANDLE)
|
||||
{
|
||||
Log_ErrorPrint("Failed to create new surface for swap chain");
|
||||
ERROR_LOG("Failed to create new surface for swap chain");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_swap_chain = VulkanSwapChain::Create(m_window_info, surface, SelectPresentMode(), m_exclusive_fullscreen_control);
|
||||
if (!m_swap_chain)
|
||||
{
|
||||
Log_ErrorPrint("Failed to create swap chain");
|
||||
ERROR_LOG("Failed to create swap chain");
|
||||
VulkanSwapChain::DestroyVulkanSurface(m_instance, &m_window_info, surface);
|
||||
return false;
|
||||
}
|
||||
@@ -2302,7 +2300,7 @@ void VulkanDevice::ResizeWindow(s32 new_window_width, s32 new_window_height, flo
|
||||
if (!m_swap_chain->ResizeSwapChain(new_window_width, new_window_height, new_window_scale))
|
||||
{
|
||||
// AcquireNextImage() will fail, and we'll recreate the surface.
|
||||
Log_ErrorPrint("Failed to resize swap chain. Next present will fail.");
|
||||
ERROR_LOG("Failed to resize swap chain. Next present will fail.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2405,10 +2403,10 @@ bool VulkanDevice::BeginPresent(bool frame_skip)
|
||||
}
|
||||
else if (res == VK_ERROR_SURFACE_LOST_KHR)
|
||||
{
|
||||
Log_WarningPrint("Surface lost, attempting to recreate");
|
||||
WARNING_LOG("Surface lost, attempting to recreate");
|
||||
if (!m_swap_chain->RecreateSurface(m_window_info))
|
||||
{
|
||||
Log_ErrorPrint("Failed to recreate surface after loss");
|
||||
ERROR_LOG("Failed to recreate surface after loss");
|
||||
SubmitCommandBuffer(false);
|
||||
TrimTexturePool();
|
||||
return false;
|
||||
@@ -2544,7 +2542,7 @@ bool VulkanDevice::CheckFeatures(FeatureMask disabled_features)
|
||||
m_optional_extensions.vk_ext_rasterization_order_attachment_access;
|
||||
|
||||
if (!m_features.dual_source_blend)
|
||||
Log_WarningPrint("Vulkan driver is missing dual-source blending. This will have an impact on performance.");
|
||||
WARNING_LOG("Vulkan driver is missing dual-source blending. This will have an impact on performance.");
|
||||
|
||||
m_features.noperspective_interpolation = true;
|
||||
m_features.texture_copy_to_self = !(disabled_features & FEATURE_MASK_TEXTURE_COPY_TO_SELF);
|
||||
@@ -2557,7 +2555,7 @@ bool VulkanDevice::CheckFeatures(FeatureMask disabled_features)
|
||||
m_features.texture_buffers_emulated_with_ssbo = true;
|
||||
#else
|
||||
const u32 max_texel_buffer_elements = m_device_properties.limits.maxTexelBufferElements;
|
||||
Log_InfoFmt("Max texel buffer elements: {}", max_texel_buffer_elements);
|
||||
INFO_LOG("Max texel buffer elements: {}", max_texel_buffer_elements);
|
||||
if (max_texel_buffer_elements < MIN_TEXEL_BUFFER_ELEMENTS)
|
||||
{
|
||||
m_features.texture_buffers_emulated_with_ssbo = true;
|
||||
@@ -2565,7 +2563,7 @@ bool VulkanDevice::CheckFeatures(FeatureMask disabled_features)
|
||||
#endif
|
||||
|
||||
if (m_features.texture_buffers_emulated_with_ssbo)
|
||||
Log_WarningPrint("Emulating texture buffers with SSBOs.");
|
||||
WARNING_LOG("Emulating texture buffers with SSBOs.");
|
||||
|
||||
m_features.geometry_shaders =
|
||||
!(disabled_features & FEATURE_MASK_GEOMETRY_SHADERS) && m_device_features.geometryShader;
|
||||
@@ -2773,25 +2771,25 @@ bool VulkanDevice::CreateBuffers()
|
||||
{
|
||||
if (!m_vertex_buffer.Create(VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, VERTEX_BUFFER_SIZE))
|
||||
{
|
||||
Log_ErrorPrint("Failed to allocate vertex buffer");
|
||||
ERROR_LOG("Failed to allocate vertex buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_index_buffer.Create(VK_BUFFER_USAGE_INDEX_BUFFER_BIT, INDEX_BUFFER_SIZE))
|
||||
{
|
||||
Log_ErrorPrint("Failed to allocate index buffer");
|
||||
ERROR_LOG("Failed to allocate index buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_uniform_buffer.Create(VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VERTEX_UNIFORM_BUFFER_SIZE))
|
||||
{
|
||||
Log_ErrorPrint("Failed to allocate uniform buffer");
|
||||
ERROR_LOG("Failed to allocate uniform buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_texture_upload_buffer.Create(VK_BUFFER_USAGE_TRANSFER_SRC_BIT, TEXTURE_BUFFER_SIZE))
|
||||
{
|
||||
Log_ErrorPrint("Failed to allocate texture upload buffer");
|
||||
ERROR_LOG("Failed to allocate texture upload buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3069,7 +3067,7 @@ void VulkanDevice::RenderBlankFrame()
|
||||
VkResult res = m_swap_chain->AcquireNextImage();
|
||||
if (res != VK_SUCCESS)
|
||||
{
|
||||
Log_ErrorPrint("Failed to acquire image for blank frame present");
|
||||
ERROR_LOG("Failed to acquire image for blank frame present");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3172,7 +3170,7 @@ bool VulkanDevice::TryImportHostMemory(void* data, size_t data_size, VkBufferUsa
|
||||
*out_memory = imported_memory;
|
||||
*out_buffer = imported_buffer;
|
||||
*out_offset = data_offset;
|
||||
Log_DevFmt("Imported {} byte buffer covering {} bytes at {}", data_size, data_size_aligned, data);
|
||||
DEV_LOG("Imported {} byte buffer covering {} bytes at {}", data_size, data_size_aligned, data);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3216,7 +3214,7 @@ void VulkanDevice::SetRenderTargets(GPUTexture* const* rts, u32 num_rts, GPUText
|
||||
m_num_current_render_targets, m_current_depth_target, feedback_loop);
|
||||
if (m_current_framebuffer == VK_NULL_HANDLE)
|
||||
{
|
||||
Log_ErrorPrint("Failed to create framebuffer");
|
||||
ERROR_LOG("Failed to create framebuffer");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -3355,7 +3353,7 @@ void VulkanDevice::BeginRenderPass()
|
||||
m_current_render_targets.data(), m_num_current_render_targets, m_current_depth_target, m_current_feedback_loop);
|
||||
if (bi.renderPass == VK_NULL_HANDLE)
|
||||
{
|
||||
Log_ErrorPrint("Failed to create render pass");
|
||||
ERROR_LOG("Failed to create render pass");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3640,7 +3638,7 @@ void VulkanDevice::UnbindTexture(VulkanTexture* tex)
|
||||
{
|
||||
if (m_current_render_targets[i] == tex)
|
||||
{
|
||||
Log_WarningPrint("Unbinding current RT");
|
||||
WARNING_LOG("Unbinding current RT");
|
||||
SetRenderTargets(nullptr, 0, m_current_depth_target);
|
||||
break;
|
||||
}
|
||||
@@ -3652,7 +3650,7 @@ void VulkanDevice::UnbindTexture(VulkanTexture* tex)
|
||||
{
|
||||
if (m_current_depth_target == tex)
|
||||
{
|
||||
Log_WarningPrint("Unbinding current DS");
|
||||
WARNING_LOG("Unbinding current DS");
|
||||
SetRenderTargets(nullptr, 0, nullptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ bool Vulkan::LoadVulkanLibrary(Error* error)
|
||||
#define VULKAN_MODULE_ENTRY_POINT(name, required) \
|
||||
if (!s_vulkan_library.GetSymbol(#name, &name)) \
|
||||
{ \
|
||||
Log_ErrorFmt("Vulkan: Failed to load required module function {}", #name); \
|
||||
ERROR_LOG("Vulkan: Failed to load required module function {}", #name); \
|
||||
required_functions_missing = true; \
|
||||
}
|
||||
#include "vulkan_entry_points.inl"
|
||||
|
||||
@@ -116,7 +116,7 @@ bool VulkanStreamBuffer::ReserveMemory(u32 num_bytes, u32 alignment)
|
||||
// Check for sane allocations
|
||||
if (required_bytes > m_size) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Attempting to allocate {} bytes from a {} byte stream buffer", num_bytes, m_size);
|
||||
ERROR_LOG("Attempting to allocate {} bytes from a {} byte stream buffer", num_bytes, m_size);
|
||||
Panic("Stream buffer overflow");
|
||||
}
|
||||
|
||||
|
||||
@@ -253,9 +253,9 @@ std::optional<VkSurfaceFormatKHR> VulkanSwapChain::SelectSurfaceFormat(VkSurface
|
||||
return VkSurfaceFormatKHR{format, VK_COLOR_SPACE_SRGB_NONLINEAR_KHR};
|
||||
}
|
||||
|
||||
Log_ErrorPrint("Failed to find a suitable format for swap chain buffers. Available formats were:");
|
||||
ERROR_LOG("Failed to find a suitable format for swap chain buffers. Available formats were:");
|
||||
for (const VkSurfaceFormatKHR& sf : surface_formats)
|
||||
Log_ErrorFmt(" {}", static_cast<unsigned>(sf.format));
|
||||
ERROR_LOG(" {}", static_cast<unsigned>(sf.format));
|
||||
|
||||
return std::nullopt;
|
||||
}
|
||||
@@ -302,8 +302,8 @@ std::optional<VkPresentModeKHR> VulkanSwapChain::SelectPresentMode(VkSurfaceKHR
|
||||
selected_mode = VK_PRESENT_MODE_FIFO_KHR;
|
||||
}
|
||||
|
||||
Log_DevFmt("Preferred present mode: {}, selected: {}", PresentModeToString(requested_mode),
|
||||
PresentModeToString(selected_mode));
|
||||
DEV_LOG("Preferred present mode: {}, selected: {}", PresentModeToString(requested_mode),
|
||||
PresentModeToString(selected_mode));
|
||||
|
||||
return selected_mode;
|
||||
}
|
||||
@@ -333,7 +333,7 @@ bool VulkanSwapChain::CreateSwapChain()
|
||||
u32 image_count = std::clamp<u32>(
|
||||
(m_requested_present_mode == VK_PRESENT_MODE_MAILBOX_KHR) ? 3 : 2, surface_capabilities.minImageCount,
|
||||
(surface_capabilities.maxImageCount == 0) ? std::numeric_limits<u32>::max() : surface_capabilities.maxImageCount);
|
||||
Log_DevFmt("Creating a swap chain with {} images", image_count);
|
||||
DEV_LOG("Creating a swap chain with {} images", image_count);
|
||||
|
||||
// Determine the dimensions of the swap chain. Values of -1 indicate the size we specify here
|
||||
// determines window size? Android sometimes lags updating currentExtent, so don't use it.
|
||||
@@ -367,7 +367,7 @@ bool VulkanSwapChain::CreateSwapChain()
|
||||
VkImageUsageFlags image_usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT;
|
||||
if ((surface_capabilities.supportedUsageFlags & image_usage) != image_usage)
|
||||
{
|
||||
Log_ErrorPrint("Vulkan: Swap chain does not support usage as color attachment");
|
||||
ERROR_LOG("Vulkan: Swap chain does not support usage as color attachment");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -422,19 +422,19 @@ bool VulkanSwapChain::CreateSwapChain()
|
||||
exclusive_win32_info.hmonitor =
|
||||
MonitorFromWindow(reinterpret_cast<HWND>(m_window_info.window_handle), MONITOR_DEFAULTTONEAREST);
|
||||
if (!exclusive_win32_info.hmonitor)
|
||||
Log_ErrorPrint("MonitorFromWindow() for exclusive fullscreen exclusive override failed.");
|
||||
ERROR_LOG("MonitorFromWindow() for exclusive fullscreen exclusive override failed.");
|
||||
|
||||
Vulkan::AddPointerToChain(&swap_chain_info, &exclusive_info);
|
||||
Vulkan::AddPointerToChain(&swap_chain_info, &exclusive_win32_info);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorPrint("Exclusive fullscreen control requested, but VK_EXT_full_screen_exclusive is not supported.");
|
||||
ERROR_LOG("Exclusive fullscreen control requested, but VK_EXT_full_screen_exclusive is not supported.");
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (m_exclusive_fullscreen_control.has_value())
|
||||
Log_ErrorPrint("Exclusive fullscreen control requested, but is not supported on this platform.");
|
||||
ERROR_LOG("Exclusive fullscreen control requested, but is not supported on this platform.");
|
||||
#endif
|
||||
|
||||
res = vkCreateSwapchainKHR(dev.GetVulkanDevice(), &swap_chain_info, nullptr, &m_swap_chain);
|
||||
@@ -456,7 +456,7 @@ bool VulkanSwapChain::CreateSwapChain()
|
||||
m_actual_present_mode = present_mode.value();
|
||||
if (m_window_info.surface_format == GPUTexture::Format::Unknown)
|
||||
{
|
||||
Log_ErrorFmt("Unknown Vulkan surface format {}", static_cast<u32>(surface_format->format));
|
||||
ERROR_LOG("Unknown Vulkan surface format {}", static_cast<u32>(surface_format->format));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -632,7 +632,7 @@ bool VulkanSwapChain::SetRequestedPresentMode(VkPresentModeKHR mode)
|
||||
m_requested_present_mode = mode;
|
||||
|
||||
// Recreate the swap chain with the new present mode.
|
||||
Log_VerbosePrint("Recreating swap chain to change present mode.");
|
||||
VERBOSE_LOG("Recreating swap chain to change present mode.");
|
||||
DestroySwapChainImages();
|
||||
if (!CreateSwapChain())
|
||||
{
|
||||
|
||||
@@ -147,7 +147,7 @@ std::unique_ptr<VulkanTexture> VulkanTexture::Create(u32 width, u32 height, u32
|
||||
}
|
||||
if (res == VK_ERROR_OUT_OF_DEVICE_MEMORY)
|
||||
{
|
||||
Log_ErrorFmt("Failed to allocate device memory for {}x{} texture", width, height);
|
||||
ERROR_LOG("Failed to allocate device memory for {}x{} texture", width, height);
|
||||
return {};
|
||||
}
|
||||
else if (res != VK_SUCCESS)
|
||||
@@ -334,7 +334,7 @@ bool VulkanTexture::Update(u32 x, u32 y, u32 width, u32 height, const void* data
|
||||
dev.SubmitCommandBuffer(false, "While waiting for %u bytes in texture upload buffer", required_size);
|
||||
if (!sbuffer.ReserveMemory(required_size, dev.GetBufferCopyOffsetAlignment()))
|
||||
{
|
||||
Log_ErrorFmt("Failed to reserve texture upload memory ({} bytes).", required_size);
|
||||
ERROR_LOG("Failed to reserve texture upload memory ({} bytes).", required_size);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -822,7 +822,7 @@ VkSampler VulkanDevice::GetSampler(const GPUSampler::Config& config)
|
||||
}
|
||||
if (i == std::size(border_color_mapping))
|
||||
{
|
||||
Log_ErrorFmt("Unsupported border color: {:08X}", config.border_color.GetValue());
|
||||
ERROR_LOG("Unsupported border color: {:08X}", config.border_color.GetValue());
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -938,7 +938,7 @@ std::unique_ptr<GPUTextureBuffer> VulkanDevice::CreateTextureBuffer(GPUTextureBu
|
||||
tb->m_descriptor_set = AllocatePersistentDescriptorSet(m_single_texture_buffer_ds_layout);
|
||||
if (tb->m_descriptor_set == VK_NULL_HANDLE)
|
||||
{
|
||||
Log_ErrorPrint("Failed to allocate persistent descriptor set for texture buffer.");
|
||||
ERROR_LOG("Failed to allocate persistent descriptor set for texture buffer.");
|
||||
tb->Destroy(false);
|
||||
return {};
|
||||
}
|
||||
@@ -955,7 +955,7 @@ std::unique_ptr<GPUTextureBuffer> VulkanDevice::CreateTextureBuffer(GPUTextureBu
|
||||
bvb.Set(tb->GetBuffer(), format_mapping[static_cast<u8>(format)], 0, tb->GetSizeInBytes());
|
||||
if ((tb->m_buffer_view = bvb.Create(m_device, false)) == VK_NULL_HANDLE)
|
||||
{
|
||||
Log_ErrorPrint("Failed to create buffer view for texture buffer.");
|
||||
ERROR_LOG("Failed to create buffer view for texture buffer.");
|
||||
tb->Destroy(false);
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ bool WAVWriter::Open(const char* filename, u32 sample_rate, u32 num_channels)
|
||||
|
||||
if (!WriteHeader())
|
||||
{
|
||||
Log_ErrorPrint("Failed to write header to file");
|
||||
ERROR_LOG("Failed to write header to file");
|
||||
m_sample_rate = 0;
|
||||
m_num_channels = 0;
|
||||
std::fclose(m_file);
|
||||
@@ -74,7 +74,7 @@ void WAVWriter::Close()
|
||||
return;
|
||||
|
||||
if (std::fseek(m_file, 0, SEEK_SET) != 0 || !WriteHeader())
|
||||
Log_ErrorPrint("Failed to re-write header on file, file may be unplayable");
|
||||
ERROR_LOG("Failed to re-write header on file, file may be unplayable");
|
||||
|
||||
std::fclose(m_file);
|
||||
m_file = nullptr;
|
||||
@@ -88,7 +88,7 @@ void WAVWriter::WriteFrames(const s16* samples, u32 num_frames)
|
||||
const u32 num_frames_written =
|
||||
static_cast<u32>(std::fwrite(samples, sizeof(s16) * m_num_channels, num_frames, m_file));
|
||||
if (num_frames_written != num_frames)
|
||||
Log_ErrorFmt("Only wrote {} of {} frames to output file", num_frames_written, num_frames);
|
||||
ERROR_LOG("Only wrote {} of {} frames to output file", num_frames_written, num_frames);
|
||||
|
||||
m_num_frames += num_frames_written;
|
||||
}
|
||||
|
||||
@@ -30,19 +30,19 @@ bool Win32RawInputSource::Initialize(SettingsInterface& si, std::unique_lock<std
|
||||
{
|
||||
if (!RegisterDummyClass())
|
||||
{
|
||||
Log_ErrorPrint("Failed to register dummy window class");
|
||||
ERROR_LOG("Failed to register dummy window class");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CreateDummyWindow())
|
||||
{
|
||||
Log_ErrorPrint("Failed to create dummy window");
|
||||
ERROR_LOG("Failed to create dummy window");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!OpenDevices())
|
||||
{
|
||||
Log_ErrorPrint("Failed to open devices");
|
||||
ERROR_LOG("Failed to open devices");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ bool Win32RawInputSource::OpenDevices()
|
||||
m_mice.push_back({rid.hDevice, 0u, 0, 0});
|
||||
}
|
||||
|
||||
Log_DevFmt("Found {} keyboards and {} mice", m_num_keyboards, m_mice.size());
|
||||
DEV_LOG("Found {} keyboards and {} mice", m_num_keyboards, m_mice.size());
|
||||
|
||||
// Grab all keyboard/mouse input.
|
||||
if (m_num_keyboards > 0)
|
||||
|
||||
+16
-16
@@ -37,7 +37,7 @@ static std::optional<float> GetRefreshRateFromDisplayConfig(HWND hwnd)
|
||||
const HMONITOR monitor = MonitorFromWindow(hwnd, 0);
|
||||
if (!monitor) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("{}() failed: {}", "MonitorFromWindow", Error::CreateWin32(GetLastError()).GetDescription());
|
||||
ERROR_LOG("{}() failed: {}", "MonitorFromWindow", Error::CreateWin32(GetLastError()).GetDescription());
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ static std::optional<float> GetRefreshRateFromDisplayConfig(HWND hwnd)
|
||||
mi.cbSize = sizeof(mi);
|
||||
if (!GetMonitorInfoW(monitor, &mi))
|
||||
{
|
||||
Log_ErrorFmt("{}() failed: {}", "GetMonitorInfoW", Error::CreateWin32(GetLastError()).GetDescription());
|
||||
ERROR_LOG("{}() failed: {}", "GetMonitorInfoW", Error::CreateWin32(GetLastError()).GetDescription());
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ static std::optional<float> GetRefreshRateFromDisplayConfig(HWND hwnd)
|
||||
LONG res = GetDisplayConfigBufferSizes(QDC_ONLY_ACTIVE_PATHS, &path_size, &mode_size);
|
||||
if (res != ERROR_SUCCESS)
|
||||
{
|
||||
Log_ErrorFmt("{}() failed: {}", "GetDisplayConfigBufferSizes", Error::CreateWin32(res).GetDescription());
|
||||
ERROR_LOG("{}() failed: {}", "GetDisplayConfigBufferSizes", Error::CreateWin32(res).GetDescription());
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ static std::optional<float> GetRefreshRateFromDisplayConfig(HWND hwnd)
|
||||
break;
|
||||
if (res != ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
Log_ErrorFmt("{}() failed: {}", "QueryDisplayConfig", Error::CreateWin32(res).GetDescription());
|
||||
ERROR_LOG("{}() failed: {}", "QueryDisplayConfig", Error::CreateWin32(res).GetDescription());
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,7 @@ static std::optional<float> GetRefreshRateFromDisplayConfig(HWND hwnd)
|
||||
LONG res = DisplayConfigGetDeviceInfo(&sdn.header);
|
||||
if (res != ERROR_SUCCESS)
|
||||
{
|
||||
Log_ErrorFmt("{}() failed: {}", "DisplayConfigGetDeviceInfo", Error::CreateWin32(res).GetDescription());
|
||||
ERROR_LOG("{}() failed: {}", "DisplayConfigGetDeviceInfo", Error::CreateWin32(res).GetDescription());
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -198,8 +198,8 @@ private:
|
||||
{
|
||||
char error_string[256] = {};
|
||||
XGetErrorText(display, ee->error_code, error_string, sizeof(error_string));
|
||||
Log_WarningFmt("X11 Error: {} (Error {} Minor {} Request {})", error_string, ee->error_code, ee->minor_code,
|
||||
ee->request_code);
|
||||
WARNING_LOG("X11 Error: {} (Error {} Minor {} Request {})", error_string, ee->error_code, ee->minor_code,
|
||||
ee->request_code);
|
||||
|
||||
s_current_error_inhibiter->m_had_error = true;
|
||||
return 0;
|
||||
@@ -222,7 +222,7 @@ static std::optional<float> GetRefreshRateFromXRandR(const WindowInfo& wi)
|
||||
XRRScreenResources* res = XRRGetScreenResources(display, window);
|
||||
if (!res)
|
||||
{
|
||||
Log_ErrorPrint("XRRGetScreenResources() failed");
|
||||
ERROR_LOG("XRRGetScreenResources() failed");
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -232,29 +232,29 @@ static std::optional<float> GetRefreshRateFromXRandR(const WindowInfo& wi)
|
||||
XRRMonitorInfo* mi = XRRGetMonitors(display, window, True, &num_monitors);
|
||||
if (num_monitors < 0)
|
||||
{
|
||||
Log_ErrorPrint("XRRGetMonitors() failed");
|
||||
ERROR_LOG("XRRGetMonitors() failed");
|
||||
return std::nullopt;
|
||||
}
|
||||
else if (num_monitors > 1)
|
||||
{
|
||||
Log_WarningFmt("XRRGetMonitors() returned {} monitors, using first", num_monitors);
|
||||
WARNING_LOG("XRRGetMonitors() returned {} monitors, using first", num_monitors);
|
||||
}
|
||||
|
||||
ScopedGuard mi_guard([mi]() { XRRFreeMonitors(mi); });
|
||||
if (mi->noutput <= 0)
|
||||
{
|
||||
Log_ErrorPrint("Monitor has no outputs");
|
||||
ERROR_LOG("Monitor has no outputs");
|
||||
return std::nullopt;
|
||||
}
|
||||
else if (mi->noutput > 1)
|
||||
{
|
||||
Log_WarningFmt("Monitor has {} outputs, using first", mi->noutput);
|
||||
WARNING_LOG("Monitor has {} outputs, using first", mi->noutput);
|
||||
}
|
||||
|
||||
XRROutputInfo* oi = XRRGetOutputInfo(display, res, mi->outputs[0]);
|
||||
if (!oi)
|
||||
{
|
||||
Log_ErrorPrint("XRRGetOutputInfo() failed");
|
||||
ERROR_LOG("XRRGetOutputInfo() failed");
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ static std::optional<float> GetRefreshRateFromXRandR(const WindowInfo& wi)
|
||||
XRRCrtcInfo* ci = XRRGetCrtcInfo(display, res, oi->crtc);
|
||||
if (!ci)
|
||||
{
|
||||
Log_ErrorPrint("XRRGetCrtcInfo() failed");
|
||||
ERROR_LOG("XRRGetCrtcInfo() failed");
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
@@ -280,13 +280,13 @@ static std::optional<float> GetRefreshRateFromXRandR(const WindowInfo& wi)
|
||||
}
|
||||
if (!mode)
|
||||
{
|
||||
Log_ErrorFmt("Failed to look up mode {} (of {})", static_cast<int>(ci->mode), res->nmode);
|
||||
ERROR_LOG("Failed to look up mode {} (of {})", static_cast<int>(ci->mode), res->nmode);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (mode->dotClock == 0 || mode->hTotal == 0 || mode->vTotal == 0)
|
||||
{
|
||||
Log_ErrorFmt("Modeline is invalid: {}/{}/{}", mode->dotClock, mode->hTotal, mode->vTotal);
|
||||
ERROR_LOG("Modeline is invalid: {}/{}/{}", mode->dotClock, mode->hTotal, mode->vTotal);
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
|
||||
@@ -127,7 +127,7 @@ bool XInputSource::Initialize(SettingsInterface& si, std::unique_lock<std::mutex
|
||||
}
|
||||
if (!m_xinput_module)
|
||||
{
|
||||
Log_ErrorPrint("Failed to load XInput module.");
|
||||
ERROR_LOG("Failed to load XInput module.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ bool XInputSource::Initialize(SettingsInterface& si, std::unique_lock<std::mutex
|
||||
|
||||
if (!m_xinput_get_state || !m_xinput_set_state || !m_xinput_get_capabilities)
|
||||
{
|
||||
Log_ErrorPrint("Failed to get XInput function pointers.");
|
||||
ERROR_LOG("Failed to get XInput function pointers.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ void XInputSource::PollEvents()
|
||||
else
|
||||
{
|
||||
if (result != ERROR_DEVICE_NOT_CONNECTED)
|
||||
Log_WarningFmt("XInputGetState({}) failed: 0x{:08X} / 0x{:08X}", i, result, GetLastError());
|
||||
WARNING_LOG("XInputGetState({}) failed: 0x{:08X} / 0x{:08X}", i, result, GetLastError());
|
||||
|
||||
if (was_connected)
|
||||
HandleControllerDisconnection(i);
|
||||
@@ -424,11 +424,11 @@ bool XInputSource::GetGenericBindingMapping(std::string_view device, GenericInpu
|
||||
|
||||
void XInputSource::HandleControllerConnection(u32 index)
|
||||
{
|
||||
Log_InfoFmt("XInput controller {} connected.", index);
|
||||
INFO_LOG("XInput controller {} connected.", index);
|
||||
|
||||
XINPUT_CAPABILITIES caps = {};
|
||||
if (m_xinput_get_capabilities(index, 0, &caps) != ERROR_SUCCESS)
|
||||
Log_WarningFmt("Failed to get XInput capabilities for controller {}", index);
|
||||
WARNING_LOG("Failed to get XInput capabilities for controller {}", index);
|
||||
|
||||
ControllerData& cd = m_controllers[index];
|
||||
cd.connected = true;
|
||||
@@ -441,7 +441,7 @@ void XInputSource::HandleControllerConnection(u32 index)
|
||||
|
||||
void XInputSource::HandleControllerDisconnection(u32 index)
|
||||
{
|
||||
Log_InfoFmt("XInput controller {} disconnected.", index);
|
||||
INFO_LOG("XInput controller {} disconnected.", index);
|
||||
|
||||
InputManager::OnInputDeviceDisconnected({{
|
||||
.source_type = InputSourceType::XInput,
|
||||
|
||||
@@ -105,8 +105,8 @@ private:
|
||||
const size_t ret = ZSTD_compressStream2(m_cstream, &outbuf, &inbuf, action);
|
||||
if (ZSTD_isError(ret))
|
||||
{
|
||||
Log_ErrorFmt("ZSTD_compressStream2() failed: {} ({})", static_cast<unsigned>(ZSTD_getErrorCode(ret)),
|
||||
ZSTD_getErrorString(ZSTD_getErrorCode(ret)));
|
||||
ERROR_LOG("ZSTD_compressStream2() failed: {} ({})", static_cast<unsigned>(ZSTD_getErrorCode(ret)),
|
||||
ZSTD_getErrorString(ZSTD_getErrorCode(ret)));
|
||||
SetErrorState();
|
||||
return false;
|
||||
}
|
||||
@@ -284,8 +284,8 @@ private:
|
||||
size_t ret = ZSTD_decompressStream(m_cstream, &outbuf, &m_in_buffer);
|
||||
if (ZSTD_isError(ret))
|
||||
{
|
||||
Log_ErrorFmt("ZSTD_decompressStream() failed: {} ({})", static_cast<unsigned>(ZSTD_getErrorCode(ret)),
|
||||
ZSTD_getErrorString(ZSTD_getErrorCode(ret)));
|
||||
ERROR_LOG("ZSTD_decompressStream() failed: {} ({})", static_cast<unsigned>(ZSTD_getErrorCode(ret)),
|
||||
ZSTD_getErrorString(ZSTD_getErrorCode(ret)));
|
||||
m_in_buffer.pos = m_in_buffer.size;
|
||||
m_output_buffer_rpos = 0;
|
||||
m_output_buffer_wpos = 0;
|
||||
|
||||
Reference in New Issue
Block a user