Misc: Replace log printf calls with fmt
This commit is contained in:
@ -290,7 +290,7 @@ void AudioStream::ReadFrames(SampleType* samples, u32 num_frames)
|
||||
else
|
||||
{
|
||||
m_filling = false;
|
||||
Log_VerbosePrintf("Underrun compensation done (%d frames buffered)", toFill);
|
||||
Log_VerboseFmt("Underrun compensation done ({} frames buffered)", toFill);
|
||||
}
|
||||
}
|
||||
|
||||
@ -441,7 +441,7 @@ void AudioStream::InternalWriteFrames(s16* data, u32 num_frames)
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_DebugPrintf("Buffer overrun, chunk dropped");
|
||||
Log_DebugPrint("Buffer overrun, chunk dropped");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -891,7 +891,7 @@ void AudioStream::UpdateStretchTempo()
|
||||
// state vars
|
||||
if (m_stretch_reset >= STRETCH_RESET_THRESHOLD)
|
||||
{
|
||||
Log_VerbosePrintf("___ Stretcher is being reset.");
|
||||
Log_VerbosePrint("___ 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_VerbosePrintf("=== Stretcher is now inactive.");
|
||||
Log_VerbosePrint("=== Stretcher is now inactive.");
|
||||
m_stretch_inactive = true;
|
||||
}
|
||||
}
|
||||
else if (!IsInRange(tempo, 1.0f / INACTIVE_BAD_FACTOR, INACTIVE_BAD_FACTOR))
|
||||
{
|
||||
Log_VerbosePrintf("~~~ Stretcher is now active @ tempo %f.", tempo);
|
||||
Log_VerboseFmt("~~~ 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_VerbosePrintf("buffers: %4u ms (%3.0f%%), tempo: %f, comp: %2.3f, iters: %d, reset:%d",
|
||||
(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);
|
||||
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);
|
||||
|
||||
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_ErrorPrintf("Read of LBA %u failed", m_position_on_disc);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Subchannel read of LBA %u failed", m_position_on_disc);
|
||||
Log_ErrorFmt("Subchannel read of LBA {} failed", m_position_on_disc);
|
||||
Seek(m_position_on_disc);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -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_WarningPrintf("Your cue sheet references an invalid file '%s', but this was found at '%s' instead.",
|
||||
track_filename.c_str(), alternative_filename.c_str());
|
||||
Log_WarningFmt("Your cue sheet references an invalid file '{}', but this was found at '{}' instead.",
|
||||
track_filename, alternative_filename);
|
||||
}
|
||||
}
|
||||
|
||||
if (!track_fp)
|
||||
{
|
||||
Log_ErrorPrintf("Failed to open track filename '%s' (from '%s' and '%s'): %s", track_full_filename.c_str(),
|
||||
track_filename.c_str(), filename, track_error.GetDescription().c_str());
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to open track %u in '%s': track start is out of range (%u vs %" PRIu64 ")", track_num,
|
||||
filename, 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::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_ErrorPrintf("File '%s' contains no tracks", filename);
|
||||
Log_ErrorFmt("File '{}' contains no tracks", filename);
|
||||
Error::SetStringFmt(error, "File '{}' contains no tracks", Path::GetFileName(filename));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -290,7 +290,7 @@ bool CDImageDeviceWin32::Open(const char* filename, Error* error)
|
||||
&bytes_returned, nullptr) ||
|
||||
toc.LastTrack < toc.FirstTrack)
|
||||
{
|
||||
Log_ErrorPrintf("DeviceIoCtl(IOCTL_CDROM_READ_TOC_EX) failed: %08X", GetLastError());
|
||||
Log_ErrorFmt("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_DevPrintf("FirstTrack=%u, LastTrack=%u", toc.FirstTrack, toc.LastTrack);
|
||||
Log_DevFmt("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_DevPrintf(" [%u]: Num=%02X, Address=%u", track_index, track_num, track_address);
|
||||
Log_DevFmt(" [{}]: 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_ErrorPrintf("Invalid TOC, track %u less than %u", track_num, m_tracks.back().track_number);
|
||||
Log_ErrorFmt("Invalid TOC, track {} less than {}", track_num, m_tracks.back().track_number);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -382,32 +382,29 @@ bool CDImageDeviceWin32::Open(const char* filename, Error* error)
|
||||
|
||||
if (m_tracks.empty())
|
||||
{
|
||||
Log_ErrorPrintf("File '%s' contains no tracks", filename);
|
||||
Log_ErrorFmt("File '{}' contains no tracks", filename);
|
||||
Error::SetString(error, fmt::format("File '{}' contains no tracks", filename));
|
||||
return false;
|
||||
}
|
||||
|
||||
m_lba_count = disc_lba;
|
||||
|
||||
Log_DevPrintf("%u tracks, %u indices, %u lbas", static_cast<u32>(m_tracks.size()), static_cast<u32>(m_indices.size()),
|
||||
static_cast<u32>(m_lba_count));
|
||||
Log_DevFmt("{} tracks, {} indices, {} lbas", m_tracks.size(), m_indices.size(), m_lba_count);
|
||||
for (u32 i = 0; i < m_tracks.size(); i++)
|
||||
{
|
||||
Log_DevPrintf(" Track %u: Start %u, length %u, mode %u, control 0x%02X", static_cast<u32>(m_tracks[i].track_number),
|
||||
static_cast<u32>(m_tracks[i].start_lba), static_cast<u32>(m_tracks[i].length),
|
||||
static_cast<u32>(m_tracks[i].mode), static_cast<u32>(m_tracks[i].control.bits));
|
||||
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);
|
||||
}
|
||||
for (u32 i = 0; i < m_indices.size(); i++)
|
||||
{
|
||||
Log_DevPrintf(" Index %u: Track %u, Index %u, Start %u, length %u, file sector size %u, file offset %" PRIu64, i,
|
||||
static_cast<u32>(m_indices[i].track_number), static_cast<u32>(m_indices[i].index_number),
|
||||
static_cast<u32>(m_indices[i].start_lba_on_disc), static_cast<u32>(m_indices[i].length),
|
||||
static_cast<u32>(m_indices[i].file_sector_size), m_indices[i].file_offset);
|
||||
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);
|
||||
}
|
||||
|
||||
if (!DetermineReadMode(try_sptd))
|
||||
{
|
||||
Log_ErrorPrintf("Could not determine read mode");
|
||||
Log_ErrorPrint("Could not determine read mode");
|
||||
Error::SetString(error, "Could not determine read mode");
|
||||
return false;
|
||||
}
|
||||
@ -795,7 +792,7 @@ bool CDImageDeviceLinux::Open(const char* filename, Error* error)
|
||||
{
|
||||
if (track_num < m_tracks.back().track_number)
|
||||
{
|
||||
Log_ErrorPrintf("Invalid TOC, track %u less than %u", track_num, m_tracks.back().track_number);
|
||||
Log_ErrorFmt("Invalid TOC, track {} less than {}", track_num, m_tracks.back().track_number);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -858,7 +855,7 @@ bool CDImageDeviceLinux::Open(const char* filename, Error* error)
|
||||
|
||||
if (m_tracks.empty())
|
||||
{
|
||||
Log_ErrorPrintf("File '%s' contains no tracks", filename);
|
||||
Log_ErrorFmt("File '{}' contains no tracks", filename);
|
||||
Error::SetString(error, fmt::format("File '{}' contains no tracks", filename));
|
||||
return false;
|
||||
}
|
||||
@ -887,20 +884,17 @@ bool CDImageDeviceLinux::Open(const char* filename, Error* error)
|
||||
|
||||
m_lba_count = disc_lba;
|
||||
|
||||
Log_DevPrintf("%u tracks, %u indices, %u lbas", static_cast<u32>(m_tracks.size()), static_cast<u32>(m_indices.size()),
|
||||
static_cast<u32>(m_lba_count));
|
||||
Log_DevFmt("{} tracks, {} indices, {} lbas", m_tracks.size(), m_indices.size(), m_lba_count);
|
||||
for (u32 i = 0; i < m_tracks.size(); i++)
|
||||
{
|
||||
Log_DevPrintf(" Track %u: Start %u, length %u, mode %u, control 0x%02X", static_cast<u32>(m_tracks[i].track_number),
|
||||
static_cast<u32>(m_tracks[i].start_lba), static_cast<u32>(m_tracks[i].length),
|
||||
static_cast<u32>(m_tracks[i].mode), static_cast<u32>(m_tracks[i].control.bits));
|
||||
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);
|
||||
}
|
||||
for (u32 i = 0; i < m_indices.size(); i++)
|
||||
{
|
||||
Log_DevPrintf(" Index %u: Track %u, Index %u, Start %u, length %u, file sector size %u, file offset %" PRIu64, i,
|
||||
static_cast<u32>(m_indices[i].track_number), static_cast<u32>(m_indices[i].index_number),
|
||||
static_cast<u32>(m_indices[i].start_lba_on_disc), static_cast<u32>(m_indices[i].length),
|
||||
static_cast<u32>(m_indices[i].file_sector_size), m_indices[i].file_offset);
|
||||
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);
|
||||
}
|
||||
|
||||
if (!DetermineReadMode(error))
|
||||
@ -1380,7 +1374,7 @@ bool CDImageDeviceMacOS::Open(const char* filename, Error* error)
|
||||
|
||||
if (m_tracks.empty())
|
||||
{
|
||||
Log_ErrorPrintf("File '%s' contains no tracks", filename);
|
||||
Log_ErrorFmt("File '{}' contains no tracks", filename);
|
||||
Error::SetString(error, fmt::format("File '{}' contains no tracks", filename));
|
||||
return false;
|
||||
}
|
||||
@ -1398,20 +1392,17 @@ bool CDImageDeviceMacOS::Open(const char* filename, Error* error)
|
||||
|
||||
m_lba_count = disc_lba;
|
||||
|
||||
Log_DevPrintf("%u tracks, %u indices, %u lbas", static_cast<u32>(m_tracks.size()), static_cast<u32>(m_indices.size()),
|
||||
static_cast<u32>(m_lba_count));
|
||||
Log_DevFmt("{} tracks, {} indices, {} lbas", m_tracks.size(), m_indices.size(), m_lba_count);
|
||||
for (u32 i = 0; i < m_tracks.size(); i++)
|
||||
{
|
||||
Log_DevPrintf(" Track %u: Start %u, length %u, mode %u, control 0x%02X", static_cast<u32>(m_tracks[i].track_number),
|
||||
static_cast<u32>(m_tracks[i].start_lba), static_cast<u32>(m_tracks[i].length),
|
||||
static_cast<u32>(m_tracks[i].mode), static_cast<u32>(m_tracks[i].control.bits));
|
||||
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);
|
||||
}
|
||||
for (u32 i = 0; i < m_indices.size(); i++)
|
||||
{
|
||||
Log_DevPrintf(" Index %u: Track %u, Index %u, Start %u, length %u, file sector size %u, file offset %" PRIu64, i,
|
||||
static_cast<u32>(m_indices[i].track_number), static_cast<u32>(m_indices[i].index_number),
|
||||
static_cast<u32>(m_indices[i].start_lba_on_disc), static_cast<u32>(m_indices[i].length),
|
||||
static_cast<u32>(m_indices[i].file_sector_size), m_indices[i].file_offset);
|
||||
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);
|
||||
}
|
||||
|
||||
if (!DetermineReadMode(error))
|
||||
|
||||
@ -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_ErrorPrintf("Get file size failed: errno %d", errno);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to read/invalid header");
|
||||
Log_ErrorPrint("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_ErrorPrintf("Unexpected EOF after %zu chunks", m_data_map.size());
|
||||
Log_ErrorFmt("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_ErrorPrintf("Unexpected EOF after %zu chunks", m_data_map.size());
|
||||
Log_ErrorFmt("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_ErrorPrintf("Corrupted header after %zu chunks", m_data_map.size());
|
||||
Log_ErrorFmt("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_ErrorPrintf("Out of file bounds after %zu chunks", m_data_map.size());
|
||||
Log_ErrorFmt("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_ErrorPrintf("Out of file bounds after %zu chunks", m_data_map.size());
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to seek to offset %u after %zu chunks", file_offset, m_data_map.size());
|
||||
Log_ErrorFmt("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_ErrorPrintf("No data in image '%s'", filename);
|
||||
Log_ErrorFmt("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_WarningPrintf("ECM image is misaligned with offset %u", disc_offset);
|
||||
Log_WarningFmt("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_DevPrintf("Read path from m3u: '%s'", entry.filename.c_str());
|
||||
Log_DevFmt("Read path from m3u: '{}'", entry.filename);
|
||||
m_entries.push_back(std::move(entry));
|
||||
}
|
||||
|
||||
Log_InfoPrintf("Loaded %zu paths from m3u '%s'", m_entries.size(), path);
|
||||
Log_InfoFmt("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_ErrorPrintf("Failed to load subimage %u (%s)", index, entry.filename.c_str());
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to read mds file '%s'", filename);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Incorrect signature in '%s'", filename);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Invalid session offset in '%s'", filename);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Invalid track count/block offset %u/%u in '%s'", track_count, track_offset, filename);
|
||||
Log_ErrorFmt("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_ErrorPrintf("End of file in '%s' at track %u", filename, track_number);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Unexpected track number 0x%02X in track %u", track.track_number, track_number);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Invalid extra offset %u in track %u", track.extra_offset, track_number);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Track pregap %u is too large for start lba %u", track_pregap, track_start_lba);
|
||||
Log_ErrorFmt("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_ErrorPrintf("File '%s' contains no tracks", filename);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to read LBA %u in index %u", lba, i);
|
||||
Log_ErrorFmt("Failed to read LBA {} in index {}", lba, i);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -298,7 +298,7 @@ bool CDImagePBP::LoadSFOTable()
|
||||
|
||||
if (FileSystem::FSeek64(m_file, abs_key_offset, SEEK_SET) != 0)
|
||||
{
|
||||
Log_ErrorPrintf("Failed seek to key for SFO table entry %zu", i);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to read key string for SFO table entry %zu", i);
|
||||
Log_ErrorFmt("Failed to read key string for SFO table entry {}", i);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (FileSystem::FSeek64(m_file, abs_data_offset, SEEK_SET) != 0)
|
||||
{
|
||||
Log_ErrorPrintf("Failed seek to data for SFO table entry %zu", i);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Unhandled special mode UTF-8 type found in SFO table for entry %zu", i);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to read data string for SFO table entry %zu", i);
|
||||
Log_ErrorFmt("Failed to read data string for SFO table entry {}", i);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -335,9 +335,9 @@ bool CDImagePBP::LoadSFOTable()
|
||||
else if (m_sfo_index_table[i].data_type == 0x0404) // uint32_t
|
||||
{
|
||||
u32 val;
|
||||
if (fread(&val, sizeof(u32), 1, m_file) != 1)
|
||||
if (std::fread(&val, sizeof(u32), 1, m_file) != 1)
|
||||
{
|
||||
Log_ErrorPrintf("Failed to read unsigned data value for SFO table entry %zu", i);
|
||||
Log_ErrorFmt("Failed to read unsigned data value for SFO table entry {}", i);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -345,7 +345,7 @@ bool CDImagePBP::LoadSFOTable()
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorPrintf("Unhandled SFO data type 0x%04X found in SFO table for entry %zu", m_sfo_index_table[i].data_type,
|
||||
Log_ErrorFmt("Unhandled SFO data type 0x{:04X} found in SFO table for entry {}", m_sfo_index_table[i].data_type,
|
||||
i);
|
||||
return false;
|
||||
}
|
||||
@ -476,7 +476,7 @@ bool CDImagePBP::Open(const char* filename, Error* error)
|
||||
// Ignore encrypted files
|
||||
if (disc_table[0] == 0x44475000) // "\0PGD"
|
||||
{
|
||||
Log_ErrorPrintf("Encrypted PBP images are not supported, skipping %s", m_filename.c_str());
|
||||
Log_ErrorFmt("Encrypted PBP images are not supported, skipping %s", m_filename);
|
||||
Error::SetString(error, "Encrypted PBP images are not supported");
|
||||
return false;
|
||||
}
|
||||
@ -492,7 +492,7 @@ bool CDImagePBP::Open(const char* filename, Error* error)
|
||||
|
||||
if (m_disc_offsets.size() < 1)
|
||||
{
|
||||
Log_ErrorPrintf("Invalid number of discs (%u) in multi-disc PBP file", static_cast<u32>(m_disc_offsets.size()));
|
||||
Log_ErrorFmt("Invalid number of discs ({}) in multi-disc PBP file", m_disc_offsets.size());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -509,7 +509,7 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||
{
|
||||
if (index >= m_disc_offsets.size())
|
||||
{
|
||||
Log_ErrorPrintf("File does not contain disc %u", index + 1);
|
||||
Log_ErrorFmt("File does not contain disc {}", index + 1);
|
||||
Error::SetString(error, fmt::format("File does not contain disc {}", index + 1));
|
||||
return false;
|
||||
}
|
||||
@ -545,7 +545,7 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||
|
||||
if (pgd_magic == 0x44475000) // "\0PGD"
|
||||
{
|
||||
Log_ErrorPrintf("Encrypted PBP images are not supported, skipping %s", m_filename.c_str());
|
||||
Log_ErrorFmt("Encrypted PBP images are not supported, skipping {}", m_filename);
|
||||
Error::SetString(error, "Encrypted PBP images are not supported");
|
||||
return false;
|
||||
}
|
||||
@ -623,7 +623,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_WarningPrintf("Mismatched TOC track number, expected %u but got %u", static_cast<u32>(curr_track), track_num);
|
||||
Log_WarningFmt("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,14 +643,14 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||
{
|
||||
if (!is_first_track || is_audio_track)
|
||||
{
|
||||
Log_ErrorPrintf("Invalid TOC entry at index %u, user data (%u) should not start before pregap (%u)",
|
||||
static_cast<u32>(curr_track), userdata_start, pregap_start);
|
||||
Log_ErrorFmt("Invalid TOC entry at index {}, user data ({}) should not start before pregap ({})", curr_track,
|
||||
userdata_start, pregap_start);
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_WarningPrintf(
|
||||
"Invalid TOC entry at index %u, user data (%u) should not start before pregap (%u), assuming not in file.",
|
||||
static_cast<u32>(curr_track), userdata_start, pregap_start);
|
||||
Log_WarningFmt(
|
||||
"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;
|
||||
pregap_frames = userdata_start;
|
||||
pregap_sector_size = 0;
|
||||
@ -701,8 +701,7 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||
{
|
||||
if (userdata_start >= m_lba_count)
|
||||
{
|
||||
Log_ErrorPrintf("Last user data index on disc for TOC entry %u should not be 0 or less in length",
|
||||
static_cast<u32>(curr_track));
|
||||
Log_ErrorFmt("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;
|
||||
@ -716,7 +715,7 @@ bool CDImagePBP::OpenDisc(u32 index, Error* error)
|
||||
|
||||
if (next_track_num != curr_track + 1 || next_track_start < userdata_start)
|
||||
{
|
||||
Log_ErrorPrintf("Unable to calculate user data index length for TOC entry %u", static_cast<u32>(curr_track));
|
||||
Log_ErrorFmt("Unable to calculate user data index length for TOC entry {}", curr_track);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -809,9 +808,9 @@ bool CDImagePBP::DecompressBlock(const BlockInfo& block_info)
|
||||
return false;
|
||||
|
||||
int err = inflate(&m_inflate_stream, Z_FINISH);
|
||||
if (err != Z_STREAM_END)
|
||||
if (err != Z_STREAM_END) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Inflate error %d", err);
|
||||
Log_ErrorFmt("Inflate error {}", err);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -839,15 +838,15 @@ bool CDImagePBP::ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_i
|
||||
|
||||
BlockInfo& bi = m_blockinfo_table[requested_block];
|
||||
|
||||
if (bi.size == 0)
|
||||
if (bi.size == 0) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Invalid block %u requested", requested_block);
|
||||
Log_ErrorFmt("Invalid block {} requested", requested_block);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_current_block != requested_block && !DecompressBlock(bi))
|
||||
if (m_current_block != requested_block && !DecompressBlock(bi)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to decompress block %u", requested_block);
|
||||
Log_ErrorFmt("Failed to decompress block {}", requested_block);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -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_ErrorPrintf("Failed to open '%s'", filename);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to read magic from '%s'", filename);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Unknown PPF magic %08X", magic);
|
||||
Log_ErrorFmt("Unknown PPF magic {:08X}", magic);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -109,9 +109,9 @@ u32 CDImagePPF::ReadFileIDDiz(std::FILE* fp, u32 version)
|
||||
const int lenidx = (version == 2) ? 4 : 2;
|
||||
|
||||
u32 magic;
|
||||
if (std::fseek(fp, -(lenidx + 4), SEEK_END) != 0 || std::fread(&magic, sizeof(magic), 1, fp) != 1)
|
||||
if (std::fseek(fp, -(lenidx + 4), SEEK_END) != 0 || std::fread(&magic, sizeof(magic), 1, fp) != 1) [[unlikely]]
|
||||
{
|
||||
Log_WarningPrintf("Failed to read diz magic");
|
||||
Log_WarningPrint("Failed to read diz magic");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -119,44 +119,45 @@ u32 CDImagePPF::ReadFileIDDiz(std::FILE* fp, u32 version)
|
||||
return 0;
|
||||
|
||||
u32 dlen = 0;
|
||||
if (std::fseek(fp, -lenidx, SEEK_END) != 0 || std::fread(&dlen, lenidx, 1, fp) != 1)
|
||||
if (std::fseek(fp, -lenidx, SEEK_END) != 0 || std::fread(&dlen, lenidx, 1, fp) != 1) [[unlikely]]
|
||||
{
|
||||
Log_WarningPrintf("Failed to read diz length");
|
||||
Log_WarningPrint("Failed to read diz length");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (dlen > static_cast<u32>(std::ftell(fp)))
|
||||
if (dlen > static_cast<u32>(std::ftell(fp))) [[unlikely]]
|
||||
{
|
||||
Log_WarningPrintf("diz length out of range");
|
||||
Log_WarningPrint("diz length out of range");
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string fdiz;
|
||||
fdiz.resize(dlen);
|
||||
if (std::fseek(fp, -(lenidx + 16 + static_cast<int>(dlen)), SEEK_END) != 0 ||
|
||||
std::fread(fdiz.data(), 1, dlen, fp) != dlen)
|
||||
std::fread(fdiz.data(), 1, dlen, fp) != dlen) [[unlikely]]
|
||||
{
|
||||
Log_WarningPrintf("Failed to read fdiz");
|
||||
Log_WarningPrint("Failed to read fdiz");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Log_InfoPrintf("File_Id.diz: %s", fdiz.c_str());
|
||||
Log_InfoFmt("File_Id.diz: %s", fdiz);
|
||||
return dlen;
|
||||
}
|
||||
|
||||
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)
|
||||
if (std::fseek(fp, 6, SEEK_SET) != 0 || std::fread(desc, sizeof(char), DESC_SIZE, fp) != DESC_SIZE) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to read description");
|
||||
Log_ErrorPrint("Failed to read description");
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 filelen;
|
||||
if (std::fseek(fp, 0, SEEK_END) != 0 || (filelen = static_cast<u32>(std::ftell(fp))) == 0 || filelen < 56)
|
||||
[[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Invalid ppf file");
|
||||
Log_ErrorPrint("Invalid ppf file");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -173,53 +174,54 @@ bool CDImagePPF::ReadV1Patch(std::FILE* fp)
|
||||
u32 offset;
|
||||
u8 chunk_size;
|
||||
if (std::fread(&offset, sizeof(offset), 1, fp) != 1 || std::fread(&chunk_size, sizeof(chunk_size), 1, fp) != 1)
|
||||
[[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Incomplete ppf");
|
||||
Log_ErrorPrint("Incomplete ppf");
|
||||
return false;
|
||||
}
|
||||
|
||||
temp.resize(chunk_size);
|
||||
if (std::fread(temp.data(), 1, chunk_size, fp) != chunk_size)
|
||||
if (std::fread(temp.data(), 1, chunk_size, fp) != chunk_size) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to read patch data");
|
||||
Log_ErrorPrint("Failed to read patch data");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!AddPatch(offset, temp.data(), chunk_size))
|
||||
if (!AddPatch(offset, temp.data(), chunk_size)) [[unlikely]]
|
||||
return false;
|
||||
|
||||
count -= sizeof(offset) + sizeof(chunk_size) + chunk_size;
|
||||
}
|
||||
|
||||
Log_InfoPrintf("Loaded %zu replacement sectors from version 1 PPF", m_replacement_map.size());
|
||||
Log_InfoFmt("Loaded {} replacement sectors from version 1 PPF", m_replacement_map.size());
|
||||
return true;
|
||||
}
|
||||
|
||||
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)
|
||||
if (std::fseek(fp, 6, SEEK_SET) != 0 || std::fread(desc, sizeof(char), DESC_SIZE, fp) != DESC_SIZE) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to read description");
|
||||
Log_ErrorPrint("Failed to read description");
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_InfoPrintf("Patch description: %s", desc);
|
||||
Log_InfoFmt("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)
|
||||
if (std::fseek(fp, 56, SEEK_SET) != 0 || std::fread(&origlen, sizeof(origlen), 1, fp) != 1) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to read size");
|
||||
Log_ErrorPrint("Failed to read size");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<u8> temp;
|
||||
temp.resize(BLOCKCHECK_SIZE);
|
||||
if (std::fread(temp.data(), 1, BLOCKCHECK_SIZE, fp) != BLOCKCHECK_SIZE)
|
||||
if (std::fread(temp.data(), 1, BLOCKCHECK_SIZE, fp) != BLOCKCHECK_SIZE) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to read blockcheck data");
|
||||
Log_ErrorPrint("Failed to read blockcheck data");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -232,18 +234,19 @@ 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_WarningPrintf("Blockcheck failed. The patch may not apply correctly.");
|
||||
Log_WarningPrint("Blockcheck failed. The patch may not apply correctly.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_WarningPrintf("Failed to read blockcheck sector %u", blockcheck_src_sector);
|
||||
Log_WarningFmt("Failed to read blockcheck sector {}", blockcheck_src_sector);
|
||||
}
|
||||
}
|
||||
|
||||
u32 filelen;
|
||||
if (std::fseek(fp, 0, SEEK_END) != 0 || (filelen = static_cast<u32>(std::ftell(fp))) == 0 || filelen < 1084)
|
||||
[[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Invalid ppf file");
|
||||
Log_ErrorPrint("Invalid ppf file");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -262,15 +265,16 @@ bool CDImagePPF::ReadV2Patch(std::FILE* fp)
|
||||
u32 offset;
|
||||
u8 chunk_size;
|
||||
if (std::fread(&offset, sizeof(offset), 1, fp) != 1 || std::fread(&chunk_size, sizeof(chunk_size), 1, fp) != 1)
|
||||
[[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Incomplete ppf");
|
||||
Log_ErrorPrint("Incomplete ppf");
|
||||
return false;
|
||||
}
|
||||
|
||||
temp.resize(chunk_size);
|
||||
if (std::fread(temp.data(), 1, chunk_size, fp) != chunk_size)
|
||||
if (std::fread(temp.data(), 1, chunk_size, fp) != chunk_size) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to read patch data");
|
||||
Log_ErrorPrint("Failed to read patch data");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -280,7 +284,7 @@ bool CDImagePPF::ReadV2Patch(std::FILE* fp)
|
||||
count -= sizeof(offset) + sizeof(chunk_size) + chunk_size;
|
||||
}
|
||||
|
||||
Log_InfoPrintf("Loaded %zu replacement sectors from version 2 PPF", m_replacement_map.size());
|
||||
Log_InfoFmt("Loaded {} replacement sectors from version 2 PPF", m_replacement_map.size());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -289,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_ErrorPrintf("Failed to read description");
|
||||
Log_ErrorPrint("Failed to read description");
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_InfoPrintf("Patch description: %s", desc);
|
||||
Log_InfoFmt("Patch description: {}", desc);
|
||||
|
||||
u32 idlen = ReadFileIDDiz(fp, 3);
|
||||
|
||||
@ -303,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_ErrorPrintf("Failed to read headers");
|
||||
Log_ErrorPrint("Failed to read headers");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -315,7 +319,7 @@ bool CDImagePPF::ReadV3Patch(std::FILE* fp)
|
||||
u32 seekpos = (block_check) ? 1084 : 60;
|
||||
if (seekpos >= count)
|
||||
{
|
||||
Log_ErrorPrintf("File is too short");
|
||||
Log_ErrorPrint("File is too short");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -325,7 +329,7 @@ bool CDImagePPF::ReadV3Patch(std::FILE* fp)
|
||||
const u32 extralen = idlen + 18 + 16 + 2;
|
||||
if (count < extralen)
|
||||
{
|
||||
Log_ErrorPrintf("File is too short (diz)");
|
||||
Log_ErrorPrint("File is too short (diz)");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -343,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_ErrorPrintf("Incomplete ppf");
|
||||
Log_ErrorPrint("Incomplete ppf");
|
||||
return false;
|
||||
}
|
||||
|
||||
temp.resize(chunk_size);
|
||||
if (std::fread(temp.data(), 1, chunk_size, fp) != chunk_size)
|
||||
{
|
||||
Log_ErrorPrintf("Failed to read patch data");
|
||||
Log_ErrorPrint("Failed to read patch data");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -360,13 +364,13 @@ bool CDImagePPF::ReadV3Patch(std::FILE* fp)
|
||||
count -= sizeof(offset) + sizeof(chunk_size) + chunk_size;
|
||||
}
|
||||
|
||||
Log_InfoPrintf("Loaded %zu replacement sectors from version 3 PPF", m_replacement_map.size());
|
||||
Log_InfoFmt("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_DebugPrintf("Starting applying patch of %u bytes at at offset %" PRIu64, patch_size, offset);
|
||||
Log_DebugFmt("Starting applying patch of {} bytes at at offset {}", patch_size, offset);
|
||||
|
||||
while (patch_size > 0)
|
||||
{
|
||||
@ -374,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_ErrorPrintf("Sector %u in patch is out of range", sector_index);
|
||||
Log_ErrorFmt("Sector {} in patch is out of range", sector_index);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -388,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_ErrorPrintf("Failed to read sector %u from parent image", sector_index);
|
||||
Log_ErrorFmt("Failed to read sector {} from parent image", sector_index);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -396,7 +400,7 @@ bool CDImagePPF::AddPatch(u64 offset, const u8* patch, u32 patch_size)
|
||||
}
|
||||
|
||||
// patch it!
|
||||
Log_DebugPrintf(" Patching %u bytes at sector %u offset %u", bytes_to_patch, sector_index, sector_offset);
|
||||
Log_DebugFmt(" 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;
|
||||
|
||||
@ -282,7 +282,7 @@ void CubebAudioStream::SetPaused(bool paused)
|
||||
const int rv = paused ? cubeb_stream_stop(stream) : cubeb_stream_start(stream);
|
||||
if (rv != CUBEB_OK)
|
||||
{
|
||||
Log_ErrorPrintf("Could not %s stream: %d", paused ? "pause" : "resume", rv);
|
||||
Log_ErrorFmt("Could not {} stream: {}", paused ? "pause" : "resume", rv);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@ void CueParser::File::SetError(u32 line_number, Error* error, const char* format
|
||||
str.vsprintf(format, ap);
|
||||
va_end(ap);
|
||||
|
||||
Log_ErrorPrintf("Cue parse error at line %u: %s", line_number, str.c_str());
|
||||
Log_ErrorFmt("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_WarningPrintf("Ignoring '%*s' command", static_cast<int>(command.size()), command.data());
|
||||
Log_WarningFmt("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_DebugPrintf("File '%s'", m_current_file->c_str());
|
||||
Log_DebugFmt("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_WarningPrintf("Unknown track flag '%*s'", static_cast<int>(token.size()), token.data());
|
||||
Log_WarningFmt("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_WarningPrintf("Zero pregap and index 0 specified in track %u, ignoring zero pregap", m_current_track->number);
|
||||
Log_WarningFmt("Zero pregap and index 0 specified in track {}, ignoring zero pregap", m_current_track->number);
|
||||
m_current_track->zero_pregap.reset();
|
||||
}
|
||||
|
||||
|
||||
@ -126,7 +126,7 @@ 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_InfoPrintf("D3D Adapter: %s", D3DCommon::GetAdapterName(dxgi_adapter.Get()).c_str());
|
||||
Log_InfoFmt("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));
|
||||
@ -263,12 +263,12 @@ bool D3D11Device::CreateSwapChain()
|
||||
fs_desc.Scaling = fullscreen_mode.Scaling;
|
||||
fs_desc.Windowed = FALSE;
|
||||
|
||||
Log_VerbosePrintf("Creating a %dx%d exclusive fullscreen swap chain", fs_sd_desc.Width, fs_sd_desc.Height);
|
||||
Log_VerboseFmt("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_WarningPrintf("Failed to create fullscreen swap chain, trying windowed.");
|
||||
Log_WarningPrint("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_VerbosePrintf("Creating a %dx%d %s windowed swap chain", swap_chain_desc.Width, swap_chain_desc.Height,
|
||||
m_using_flip_model_swap_chain ? "flip-discard" : "discard");
|
||||
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");
|
||||
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_WarningPrintf("Failed to create a flip-discard swap chain, trying discard.");
|
||||
Log_WarningPrint("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;
|
||||
@ -292,9 +292,9 @@ bool D3D11Device::CreateSwapChain()
|
||||
|
||||
hr = m_dxgi_factory->CreateSwapChainForHwnd(m_device.Get(), window_hwnd, &swap_chain_desc, nullptr, nullptr,
|
||||
m_swap_chain.ReleaseAndGetAddressOf());
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("CreateSwapChainForHwnd failed: 0x%08X", hr);
|
||||
Log_ErrorFmt("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_WarningPrintf("MakeWindowAssociation() to disable ALT+ENTER failed");
|
||||
Log_WarningPrint("MakeWindowAssociation() to disable ALT+ENTER failed");
|
||||
}
|
||||
|
||||
if (!CreateSwapChainRTV())
|
||||
@ -323,9 +323,9 @@ bool D3D11Device::CreateSwapChainRTV()
|
||||
{
|
||||
ComPtr<ID3D11Texture2D> backbuffer;
|
||||
HRESULT hr = m_swap_chain->GetBuffer(0, IID_PPV_ARGS(backbuffer.GetAddressOf()));
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("GetBuffer for RTV failed: 0x%08X", hr);
|
||||
Log_ErrorFmt("GetBuffer for RTV failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -335,9 +335,9 @@ bool D3D11Device::CreateSwapChainRTV()
|
||||
CD3D11_RENDER_TARGET_VIEW_DESC rtv_desc(D3D11_RTV_DIMENSION_TEXTURE2D, backbuffer_desc.Format, 0, 0,
|
||||
backbuffer_desc.ArraySize);
|
||||
hr = m_device->CreateRenderTargetView(backbuffer.Get(), &rtv_desc, m_swap_chain_rtv.ReleaseAndGetAddressOf());
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("CreateRenderTargetView for swap chain failed: 0x%08X", hr);
|
||||
Log_ErrorFmt("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_VerbosePrintf("Swap chain buffer size: %ux%u", m_window_info.surface_width, m_window_info.surface_height);
|
||||
Log_VerboseFmt("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_ErrorPrintf("Failed to create swap chain on updated window");
|
||||
Log_ErrorPrint("Failed to create swap chain on updated window");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -420,8 +420,8 @@ 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))
|
||||
Log_ErrorPrintf("ResizeBuffers() failed: 0x%08X", hr);
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to create vertex/index/uniform buffers.");
|
||||
Log_ErrorPrint("Failed to create vertex/index/uniform buffers.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -776,7 +776,7 @@ void D3D11Device::PopTimestampQuery()
|
||||
|
||||
if (disjoint.Disjoint)
|
||||
{
|
||||
Log_VerbosePrintf("GPU timing disjoint, resetting.");
|
||||
Log_VerbosePrint("GPU timing disjoint, resetting.");
|
||||
m_read_timestamp_query = 0;
|
||||
m_write_timestamp_query = 0;
|
||||
m_waiting_timestamp_queries = 0;
|
||||
|
||||
@ -152,8 +152,8 @@ D3D11Device::ComPtr<ID3D11RasterizerState> D3D11Device::GetRasterizationState(co
|
||||
// desc.MultisampleEnable ???
|
||||
|
||||
HRESULT hr = m_device->CreateRasterizerState(&desc, drs.GetAddressOf());
|
||||
if (FAILED(hr))
|
||||
Log_ErrorPrintf("Failed to create depth state with %08X", hr);
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
Log_ErrorFmt("Failed to create depth state with {:08X}", static_cast<unsigned>(hr));
|
||||
|
||||
m_rasterization_states.emplace(rs.key, drs);
|
||||
return drs;
|
||||
@ -187,8 +187,8 @@ D3D11Device::ComPtr<ID3D11DepthStencilState> D3D11Device::GetDepthState(const GP
|
||||
desc.DepthWriteMask = ds.depth_write ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
|
||||
|
||||
HRESULT hr = m_device->CreateDepthStencilState(&desc, dds.GetAddressOf());
|
||||
if (FAILED(hr))
|
||||
Log_ErrorPrintf("Failed to create depth state with %08X", hr);
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
Log_ErrorFmt("Failed to create depth state with {:08X}", static_cast<unsigned>(hr));
|
||||
|
||||
m_depth_states.emplace(ds.key, dds);
|
||||
return dds;
|
||||
@ -245,8 +245,8 @@ D3D11Device::ComPtr<ID3D11BlendState> D3D11Device::GetBlendState(const GPUPipeli
|
||||
}
|
||||
|
||||
HRESULT hr = m_device->CreateBlendState(&blend_desc, dbs.GetAddressOf());
|
||||
if (FAILED(hr))
|
||||
Log_ErrorPrintf("Failed to create blend state with %08X", hr);
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
Log_ErrorFmt("Failed to create blend state with {:08X}", static_cast<unsigned>(hr));
|
||||
|
||||
m_blend_states.emplace(bs.key, dbs);
|
||||
return dbs;
|
||||
@ -297,8 +297,8 @@ 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))
|
||||
Log_ErrorPrintf("Failed to create input layout with %08X", hr);
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
Log_ErrorFmt("Failed to create input layout with {:08X}", static_cast<unsigned>(hr));
|
||||
|
||||
m_input_layouts.emplace(il, dil);
|
||||
return dil;
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
|
||||
#include "common/align.h"
|
||||
#include "common/assert.h"
|
||||
#include "common/error.h"
|
||||
#include "common/log.h"
|
||||
|
||||
Log_SetChannel(D3D11Device);
|
||||
@ -30,7 +31,7 @@ bool D3D11StreamBuffer::Create(D3D11_BIND_FLAG bind_flags, u32 min_size, u32 max
|
||||
{
|
||||
D3D11_FEATURE_DATA_D3D11_OPTIONS options = {};
|
||||
HRESULT hr = D3D11Device::GetD3DDevice()->CheckFeatureSupport(D3D11_FEATURE_D3D11_OPTIONS, &options, sizeof(options));
|
||||
if (SUCCEEDED(hr))
|
||||
if (SUCCEEDED(hr)) [[likely]]
|
||||
{
|
||||
if (bind_flags & D3D11_BIND_CONSTANT_BUFFER)
|
||||
{
|
||||
@ -54,14 +55,14 @@ bool D3D11StreamBuffer::Create(D3D11_BIND_FLAG bind_flags, u32 min_size, u32 max
|
||||
|
||||
if (!m_use_map_no_overwrite)
|
||||
{
|
||||
Log_WarningPrintf("Unable to use MAP_NO_OVERWRITE on buffer with bind flag %u, this may affect performance. "
|
||||
"Update your driver/operating system.",
|
||||
static_cast<unsigned>(bind_flags));
|
||||
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));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_WarningPrintf("ID3D11Device::CheckFeatureSupport() failed: 0x%08X", hr);
|
||||
Log_WarningFmt("ID3D11Device::CheckFeatureSupport() failed: {}", Error::CreateHResult(hr).GetDescription());
|
||||
m_use_map_no_overwrite = false;
|
||||
}
|
||||
|
||||
@ -69,9 +70,9 @@ bool D3D11StreamBuffer::Create(D3D11_BIND_FLAG bind_flags, u32 min_size, u32 max
|
||||
const CD3D11_BUFFER_DESC desc(create_size, bind_flags, D3D11_USAGE_DYNAMIC, D3D11_CPU_ACCESS_WRITE, 0, 0);
|
||||
ComPtr<ID3D11Buffer> buffer;
|
||||
hr = D3D11Device::GetD3DDevice()->CreateBuffer(&desc, nullptr, &buffer);
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Creating buffer failed: 0x%08X", hr);
|
||||
Log_ErrorFmt("Creating buffer failed: {}", Error::CreateHResult(hr).GetDescription());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -112,9 +113,9 @@ D3D11StreamBuffer::MappingResult D3D11StreamBuffer::Map(ID3D11DeviceContext1* co
|
||||
new_desc.ByteWidth = new_size;
|
||||
|
||||
hr = D3D11Device::GetD3DDevice()->CreateBuffer(&new_desc, nullptr, m_buffer.ReleaseAndGetAddressOf());
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorFmt("Creating buffer failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
Log_ErrorFmt("Creating buffer failed: {}", Error::CreateHResult(hr).GetDescription());
|
||||
Panic("Failed to grow buffer");
|
||||
}
|
||||
|
||||
@ -125,10 +126,10 @@ D3D11StreamBuffer::MappingResult D3D11StreamBuffer::Map(ID3D11DeviceContext1* co
|
||||
D3D11_MAPPED_SUBRESOURCE sr;
|
||||
const D3D11_MAP map_type = (m_position == 0) ? D3D11_MAP_WRITE_DISCARD : D3D11_MAP_WRITE_NO_OVERWRITE;
|
||||
hr = context->Map(m_buffer.Get(), 0, map_type, 0, &sr);
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Map failed: 0x%08X (alignment %u, minsize %u, size %u, position %u, map type %u)", hr, alignment,
|
||||
min_size, m_size, m_position, static_cast<u32>(map_type));
|
||||
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));
|
||||
Panic("Map failed");
|
||||
}
|
||||
|
||||
|
||||
@ -84,9 +84,9 @@ std::unique_ptr<GPUSampler> D3D11Device::CreateSampler(const GPUSampler::Config&
|
||||
|
||||
ComPtr<ID3D11SamplerState> ss;
|
||||
const HRESULT hr = m_device->CreateSamplerState(&desc, ss.GetAddressOf());
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("CreateSamplerState() failed: %08X", hr);
|
||||
Log_ErrorFmt("CreateSamplerState() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -187,9 +187,9 @@ bool D3D11Texture::Map(void** map, u32* map_stride, u32 x, u32 y, u32 width, u32
|
||||
|
||||
D3D11_MAPPED_SUBRESOURCE sr;
|
||||
HRESULT hr = context->Map(m_texture.Get(), srnum, discard ? D3D11_MAP_WRITE_DISCARD : D3D11_MAP_READ_WRITE, 0, &sr);
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Map pixels texture failed: %08X", hr);
|
||||
Log_ErrorFmt("Map pixels texture failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -267,9 +267,10 @@ 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_ErrorPrintf(
|
||||
"Create texture failed: 0x%08X (%ux%u levels:%u samples:%u format:%u bind_flags:%X initial_data:%p)", tex_hr,
|
||||
width, height, levels, samples, static_cast<unsigned>(format), bind_flags, initial_data);
|
||||
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);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -288,9 +289,9 @@ std::unique_ptr<D3D11Texture> D3D11Texture::Create(ID3D11Device* device, u32 wid
|
||||
(desc.ArraySize > 1 ? D3D11_SRV_DIMENSION_TEXTURE2DARRAY : D3D11_SRV_DIMENSION_TEXTURE2D);
|
||||
const CD3D11_SHADER_RESOURCE_VIEW_DESC srv_desc(srv_dimension, fm.srv_format, 0, desc.MipLevels, 0, desc.ArraySize);
|
||||
const HRESULT hr = device->CreateShaderResourceView(texture.Get(), &srv_desc, srv.GetAddressOf());
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Create SRV for texture failed: 0x%08X", hr);
|
||||
Log_ErrorFmt("Create SRV for texture failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@ -303,9 +304,9 @@ std::unique_ptr<D3D11Texture> D3D11Texture::Create(ID3D11Device* device, u32 wid
|
||||
const CD3D11_RENDER_TARGET_VIEW_DESC rtv_desc(rtv_dimension, fm.rtv_format, 0, 0, desc.ArraySize);
|
||||
ComPtr<ID3D11RenderTargetView> rtv;
|
||||
const HRESULT hr = device->CreateRenderTargetView(texture.Get(), &rtv_desc, rtv.GetAddressOf());
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Create RTV for texture failed: 0x%08X", hr);
|
||||
Log_ErrorFmt("Create RTV for texture failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -318,9 +319,9 @@ std::unique_ptr<D3D11Texture> D3D11Texture::Create(ID3D11Device* device, u32 wid
|
||||
const CD3D11_DEPTH_STENCIL_VIEW_DESC dsv_desc(dsv_dimension, fm.dsv_format, 0, 0, desc.ArraySize);
|
||||
ComPtr<ID3D11DepthStencilView> dsv;
|
||||
const HRESULT hr = device->CreateDepthStencilView(texture.Get(), &dsv_desc, dsv.GetAddressOf());
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Create DSV for texture failed: 0x%08X", hr);
|
||||
Log_ErrorFmt("Create DSV for texture failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -351,9 +352,9 @@ bool D3D11TextureBuffer::CreateBuffer()
|
||||
m_size_in_elements);
|
||||
const HRESULT hr =
|
||||
D3D11Device::GetD3DDevice()->CreateShaderResourceView(m_buffer.GetD3DBuffer(), &srv_desc, m_srv.GetAddressOf());
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("CreateShaderResourceView() failed: %08X", hr);
|
||||
Log_ErrorFmt("CreateShaderResourceView() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -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_ErrorPrintf("CreateGraphicsPipelineState() failed: %08X", hr);
|
||||
Log_ErrorFmt("CreateGraphicsPipelineState() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -223,9 +223,9 @@ Microsoft::WRL::ComPtr<ID3D12PipelineState> D3D12::ComputePipelineBuilder::Creat
|
||||
{
|
||||
Microsoft::WRL::ComPtr<ID3D12PipelineState> ps;
|
||||
HRESULT hr = device->CreateComputePipelineState(&m_desc, IID_PPV_ARGS(ps.GetAddressOf()));
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("CreateComputePipelineState() failed: %08X", hr);
|
||||
Log_ErrorFmt("CreateComputePipelineState() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@ -19,9 +19,9 @@ bool D3D12DescriptorHeapManager::Create(ID3D12Device* device, D3D12_DESCRIPTOR_H
|
||||
D3D12_DESCRIPTOR_HEAP_FLAG_NONE, 0u};
|
||||
|
||||
HRESULT hr = device->CreateDescriptorHeap(&desc, IID_PPV_ARGS(m_descriptor_heap.ReleaseAndGetAddressOf()));
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("CreateDescriptorHeap() failed: %08X", hr);
|
||||
Log_ErrorFmt("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_ErrorPrintf("CreateDescriptorHeap() failed: %08X", hr);
|
||||
Log_ErrorFmt("CreateDescriptorHeap() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -87,11 +87,11 @@ D3D12Device::ComPtr<ID3DBlob> D3D12Device::SerializeRootSignature(const D3D12_RO
|
||||
ComPtr<ID3DBlob> error_blob;
|
||||
const HRESULT hr =
|
||||
D3D12SerializeRootSignature(desc, D3D_ROOT_SIGNATURE_VERSION_1, blob.GetAddressOf(), error_blob.GetAddressOf());
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("D3D12SerializeRootSignature() failed: %08X", hr);
|
||||
Log_ErrorFmt("D3D12SerializeRootSignature() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
if (error_blob)
|
||||
Log_ErrorPrintf("%s", error_blob->GetBufferPointer());
|
||||
Log_ErrorPrint(static_cast<const char*>(error_blob->GetBufferPointer()));
|
||||
|
||||
return {};
|
||||
}
|
||||
@ -108,9 +108,9 @@ D3D12Device::ComPtr<ID3D12RootSignature> D3D12Device::CreateRootSignature(const
|
||||
ComPtr<ID3D12RootSignature> rs;
|
||||
const HRESULT hr =
|
||||
m_device->CreateRootSignature(0, blob->GetBufferPointer(), blob->GetBufferSize(), IID_PPV_ARGS(rs.GetAddressOf()));
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("CreateRootSignature() failed: %08X", hr);
|
||||
Log_ErrorFmt("CreateRootSignature() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -142,7 +142,7 @@ bool D3D12Device::CreateDevice(std::string_view adapter, bool threaded_presentat
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorPrintf("Debug layer requested but not available.");
|
||||
Log_ErrorPrint("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_ErrorPrintf("Failed to get lookup adapter by device LUID");
|
||||
Log_ErrorPrint("Failed to get lookup adapter by device LUID");
|
||||
}
|
||||
|
||||
if (m_debug_device)
|
||||
@ -333,7 +333,7 @@ bool D3D12Device::GetPipelineCacheData(DynamicHeapArray<u8>* data)
|
||||
const size_t size = m_pipeline_library->GetSerializedSize();
|
||||
if (size == 0)
|
||||
{
|
||||
Log_WarningPrintf("Empty serialized pipeline state returned.");
|
||||
Log_WarningPrint("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_ErrorPrintf("Serialize() failed with HRESULT %08X", hr);
|
||||
Log_ErrorFmt("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_ErrorPrintf("CreateCommandAllocator() failed: %08X", hr);
|
||||
Log_ErrorFmt("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_ErrorPrintf("CreateCommandList() failed: %08X", hr);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Close() failed: %08X", hr);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to create per frame descriptor allocator");
|
||||
Log_ErrorPrint("Failed to create per frame descriptor allocator");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!res.sampler_allocator.Create(m_device.Get(), MAX_SAMPLERS_PER_FRAME))
|
||||
{
|
||||
Log_ErrorPrintf("Failed to create per frame sampler allocator");
|
||||
Log_ErrorPrint("Failed to create per frame sampler allocator");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -439,7 +439,7 @@ void D3D12Device::MoveToNextCommandList()
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_WarningPrintf("Map() for timestamp query failed: %08X", hr);
|
||||
Log_WarningFmt("Map() for timestamp query failed: {:08X}", static_cast<unsigned>(hr));
|
||||
}
|
||||
}
|
||||
|
||||
@ -549,18 +549,18 @@ void D3D12Device::SubmitCommandList(bool wait_for_completion)
|
||||
if (res.init_list_used)
|
||||
{
|
||||
hr = res.command_lists[0]->Close();
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Closing init command list failed with HRESULT %08X", hr);
|
||||
Log_ErrorFmt("Closing init command list failed with HRESULT {:08X}", static_cast<unsigned>(hr));
|
||||
Panic("TODO cannot continue");
|
||||
}
|
||||
}
|
||||
|
||||
// Close and queue command list.
|
||||
hr = res.command_lists[1]->Close();
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Closing main command list failed with HRESULT %08X", hr);
|
||||
Log_ErrorFmt("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_WarningPrintf("Executing command buffer due to '%s'", reason_str.c_str());
|
||||
Log_WarningFmt("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_ErrorPrintf("CreateQueryHeap() for timestamp failed with %08X", hr);
|
||||
Log_ErrorFmt("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_ErrorPrintf("CreateResource() for timestamp failed with %08X", hr);
|
||||
Log_ErrorFmt("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_ErrorPrintf("GetTimestampFrequency() failed: %08X", hr);
|
||||
Log_ErrorFmt("GetTimestampFrequency() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
m_features.gpu_timing = false;
|
||||
return false;
|
||||
}
|
||||
@ -860,7 +860,7 @@ bool D3D12Device::CreateSwapChain()
|
||||
fs_desc.Scaling = fullscreen_mode.Scaling;
|
||||
fs_desc.Windowed = FALSE;
|
||||
|
||||
Log_VerbosePrintf("Creating a %dx%d exclusive fullscreen swap chain", fs_sd_desc.Width, fs_sd_desc.Height);
|
||||
Log_VerboseFmt("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))
|
||||
@ -873,7 +873,7 @@ bool D3D12Device::CreateSwapChain()
|
||||
|
||||
if (!m_is_exclusive_fullscreen)
|
||||
{
|
||||
Log_VerbosePrintf("Creating a %dx%d windowed swap chain", swap_chain_desc.Width, swap_chain_desc.Height);
|
||||
Log_VerboseFmt("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());
|
||||
}
|
||||
@ -908,7 +908,7 @@ bool D3D12Device::CreateSwapChainRTV()
|
||||
hr = m_swap_chain->GetBuffer(i, IID_PPV_ARGS(backbuffer.GetAddressOf()));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorPrintf("GetBuffer for RTV failed: 0x%08X", hr);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to allocate RTV handle");
|
||||
Log_ErrorPrint("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_VerbosePrintf("Swap chain buffer size: %ux%u", m_window_info.surface_width, m_window_info.surface_height);
|
||||
Log_VerboseFmt("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_ErrorPrintf("Failed to create swap chain on updated window");
|
||||
Log_ErrorPrint("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_ErrorPrintf("ResizeBuffers() failed: 0x%08X", hr);
|
||||
Log_ErrorFmt("ResizeBuffers() failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
|
||||
if (!CreateSwapChainRTV())
|
||||
Panic("Failed to recreate swap chain RTV after resize");
|
||||
|
||||
@ -231,7 +231,7 @@ std::unique_ptr<GPUPipeline> D3D12Device::CreatePipeline(const GPUPipeline::Grap
|
||||
{
|
||||
// E_INVALIDARG = not found.
|
||||
if (hr != E_INVALIDARG)
|
||||
Log_ErrorPrintf("LoadGraphicsPipeline() failed with HRESULT %08X", hr);
|
||||
Log_ErrorFmt("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_ErrorPrintf("StorePipeline() failed with HRESULT %08X", hr);
|
||||
Log_ErrorFmt("StorePipeline() failed with HRESULT {:08X}", static_cast<unsigned>(hr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -36,18 +36,18 @@ bool D3D12StreamBuffer::Create(u32 size)
|
||||
HRESULT hr = D3D12Device::GetInstance().GetAllocator()->CreateResource(
|
||||
&allocationDesc, &resource_desc, D3D12_RESOURCE_STATE_GENERIC_READ, nullptr, allocation.ReleaseAndGetAddressOf(),
|
||||
IID_PPV_ARGS(buffer.GetAddressOf()));
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("CreateResource() failed: %08X", hr);
|
||||
Log_ErrorFmt("CreateResource() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return false;
|
||||
}
|
||||
|
||||
static const D3D12_RANGE read_range = {};
|
||||
u8* host_pointer;
|
||||
hr = buffer->Map(0, &read_range, reinterpret_cast<void**>(&host_pointer));
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Map() failed: %08X", hr);
|
||||
Log_ErrorFmt("Map() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -66,10 +66,10 @@ bool D3D12StreamBuffer::ReserveMemory(u32 num_bytes, u32 alignment)
|
||||
const u32 required_bytes = num_bytes + alignment;
|
||||
|
||||
// Check for sane allocations
|
||||
if (num_bytes > m_size)
|
||||
if (num_bytes > m_size) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Attempting to allocate %u bytes from a %u byte stream buffer", static_cast<u32>(num_bytes),
|
||||
static_cast<u32>(m_size));
|
||||
Log_ErrorFmt("Attempting to allocate {} bytes from a {} byte stream buffer", static_cast<u32>(num_bytes),
|
||||
static_cast<u32>(m_size));
|
||||
Panic("Stream buffer overflow");
|
||||
}
|
||||
|
||||
|
||||
@ -115,11 +115,11 @@ std::unique_ptr<GPUTexture> D3D12Device::CreateTexture(u32 width, u32 height, u3
|
||||
(type == GPUTexture::Type::RenderTarget || type == GPUTexture::Type::DepthStencil) ? &optimized_clear_value :
|
||||
nullptr,
|
||||
allocation.GetAddressOf(), IID_PPV_ARGS(resource.GetAddressOf()));
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
// OOM isn't fatal.
|
||||
if (hr != E_OUTOFMEMORY)
|
||||
Log_ErrorPrintf("Create texture failed: 0x%08X", hr);
|
||||
Log_ErrorFmt("Create texture failed: 0x{:08X}", static_cast<unsigned>(hr));
|
||||
|
||||
return {};
|
||||
}
|
||||
@ -358,17 +358,17 @@ 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))
|
||||
if (FAILED(hr))[[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("CreateResource() failed with %08X", hr);
|
||||
Log_ErrorFmt("CreateResource() failed with {:08X}", static_cast<unsigned>(hr));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void* map_ptr;
|
||||
hr = resource->Map(0, nullptr, &map_ptr);
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Map() failed with %08X", hr);
|
||||
Log_ErrorFmt("Map() failed with {:08X}", static_cast<unsigned>(hr));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -419,9 +419,9 @@ bool D3D12Texture::Update(u32 x, u32 y, u32 width, u32 height, const void* data,
|
||||
{
|
||||
D3D12Device::GetInstance().SubmitCommandList(false, "While waiting for %u bytes in texture upload buffer",
|
||||
required_size);
|
||||
if (!sbuffer.ReserveMemory(required_size, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT))
|
||||
if (!sbuffer.ReserveMemory(required_size, D3D12_TEXTURE_DATA_PLACEMENT_ALIGNMENT)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to reserve texture upload memory (%u bytes).", required_size);
|
||||
Log_ErrorFmt("Failed to reserve texture upload memory ({} bytes).", required_size);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ std::vector<std::string> D3DCommon::GetAdapterNames(IDXGIFactory5* factory)
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorPrintf("IDXGIFactory2::EnumAdapters() returned %08X", hr);
|
||||
Log_ErrorFmt("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_ErrorPrintf("EnumOutputs() failed: %08X", hr);
|
||||
Log_ErrorFmt("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_ErrorPrintf("GetDisplayModeList() failed: %08X", hr);
|
||||
Log_ErrorFmt("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_ErrorPrintf("GetDisplayModeList() (2) failed: %08X", hr);
|
||||
Log_ErrorFmt("GetDisplayModeList() (2) failed: {:08X}", static_cast<unsigned>(hr));
|
||||
return modes;
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ bool D3DCommon::GetRequestedExclusiveFullscreenModeDesc(IDXGIFactory5* factory,
|
||||
{
|
||||
if (!first_output)
|
||||
{
|
||||
Log_ErrorPrintf("No DXGI output found. Can't use exclusive fullscreen.");
|
||||
Log_ErrorPrint("No DXGI output found. Can't use exclusive fullscreen.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -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_ErrorPrintf("Failed to find closest matching mode, hr=%08X", hr);
|
||||
Log_ErrorFmt("Failed to find closest matching mode, hr={:08X}", static_cast<unsigned>(hr));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -268,14 +268,14 @@ Microsoft::WRL::ComPtr<IDXGIAdapter1> D3DCommon::GetAdapterByName(IDXGIFactory5*
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorPrintf("IDXGIFactory2::EnumAdapters() returned %08X");
|
||||
Log_ErrorFmt("IDXGIFactory2::EnumAdapters() returned {:08X}", static_cast<unsigned>(hr));
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string adapter_name = FixupDuplicateAdapterNames(adapter_names, GetAdapterName(adapter.Get()));
|
||||
if (adapter_name == name)
|
||||
{
|
||||
Log_VerbosePrintf("Found adapter '%s'", adapter_name.c_str());
|
||||
Log_VerboseFmt("Found adapter '{}'", adapter_name);
|
||||
return adapter;
|
||||
}
|
||||
|
||||
@ -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_ErrorPrintf("IDXGIFactory2::EnumAdapters() for first adapter returned %08X", hr);
|
||||
Log_ErrorFmt("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_ErrorPrintf("IDXGIAdapter1::GetDesc() returned %08X", hr);
|
||||
Log_ErrorFmt("IDXGIAdapter1::GetDesc() returned {:08X}", static_cast<unsigned>(hr));
|
||||
}
|
||||
|
||||
if (ret.empty())
|
||||
|
||||
@ -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_ErrorPrintf("Failed to load DInput module.");
|
||||
Log_ErrorPrint("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_ErrorPrintf("Failed to get DInput function pointers.");
|
||||
Log_ErrorPrint("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_ErrorPrintf("DirectInput8Create() failed: %08X", hr);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Missing top level window, cannot add DInput devices.");
|
||||
Log_ErrorPrint("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_VerbosePrintf("Enumerated %zu devices", devices.size());
|
||||
Log_VerboseFmt("Enumerated {} devices", devices.size());
|
||||
|
||||
bool changed = false;
|
||||
for (DIDEVICEINSTANCEW inst : devices)
|
||||
@ -139,9 +139,11 @@ bool DInputSource::ReloadDevices()
|
||||
ControllerData cd;
|
||||
cd.guid = inst.guidInstance;
|
||||
HRESULT hr = m_dinput->CreateDevice(inst.guidInstance, cd.device.GetAddressOf(), nullptr);
|
||||
if (FAILED(hr))
|
||||
if (FAILED(hr)) [[unlikely]]
|
||||
{
|
||||
Log_WarningPrintf("Failed to create instance of device [%s, %s]", inst.tszProductName, inst.tszInstanceName);
|
||||
Log_WarningFmt("Failed to create instance of device [{}, {}]",
|
||||
StringUtil::WideStringToUTF8String(inst.tszProductName),
|
||||
StringUtil::WideStringToUTF8String(inst.tszInstanceName));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -177,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_ErrorPrintf("Failed to set cooperative level for '%s'", name.c_str());
|
||||
Log_ErrorFmt("Failed to set cooperative level for '{}'", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_WarningPrintf("Failed to set exclusive mode for '%s'", name.c_str());
|
||||
Log_WarningFmt("Failed to set exclusive mode for '{}'", name);
|
||||
}
|
||||
|
||||
hr = cd.device->SetDataFormat(m_joystick_data_format);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorPrintf("Failed to set data format for '%s'", name.c_str());
|
||||
Log_ErrorFmt("Failed to set data format for '{}'", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
hr = cd.device->Acquire();
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorPrintf("Failed to acquire device '%s'", name.c_str());
|
||||
Log_ErrorFmt("Failed to acquire device '{}'", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -203,7 +205,7 @@ bool DInputSource::AddDevice(ControllerData& cd, const std::string& name)
|
||||
hr = cd.device->GetCapabilities(&caps);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
Log_ErrorPrintf("Failed to get capabilities for '%s'", name.c_str());
|
||||
Log_ErrorFmt("Failed to get capabilities for '{}'", name);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -237,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_WarningPrintf("Polling device '%s' failed: %08X", name.c_str(), hr);
|
||||
Log_WarningFmt("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_WarningPrintf("GetDeviceState() for '%s' failed: %08X", name.c_str(), hr);
|
||||
Log_WarningFmt("GetDeviceState() for '{}' failed: {:08X}", name, static_cast<unsigned>(hr));
|
||||
|
||||
Log_InfoPrintf("%s has %u buttons, %u axes, %u hats", name.c_str(), cd.num_buttons,
|
||||
static_cast<u32>(cd.axis_offsets.size()), cd.num_hats);
|
||||
Log_InfoFmt("{} 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);
|
||||
}
|
||||
@ -276,7 +278,7 @@ void DInputSource::PollEvents()
|
||||
}
|
||||
else if (hr != DI_OK)
|
||||
{
|
||||
Log_WarningPrintf("GetDeviceState() failed: %08X", hr);
|
||||
Log_WarningFmt("GetDeviceState() failed: {:08X}", static_cast<unsigned>(hr));
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -296,7 +296,7 @@ bool GPUDevice::Create(std::string_view adapter, std::string_view shader_cache_p
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_InfoPrintf("Graphics Driver Info:\n%s", GetDriverInfo().c_str());
|
||||
Log_InfoFmt("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_WarningPrintf("Failed to open shader cache. Creating new cache.");
|
||||
Log_WarningPrint("Failed to open shader cache. Creating new cache.");
|
||||
if (!m_shader_cache.Create())
|
||||
Log_ErrorPrintf("Failed to create new shader cache.");
|
||||
Log_ErrorPrint("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_InfoPrintf("Removing old pipeline cache '%s'", pc_filename.c_str());
|
||||
Log_InfoFmt("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_WarningPrintf("Failed to read pipeline cache.");
|
||||
Log_WarningPrint("Failed to read pipeline cache.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -380,13 +380,14 @@ 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_InfoPrintf("Writing %zu bytes to '%s'", data.size(), s_pipeline_cache_path.c_str());
|
||||
Log_InfoFmt("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_ErrorPrintf("Failed to write pipeline cache to '%s'", s_pipeline_cache_path.c_str());
|
||||
Log_ErrorFmt("Failed to write pipeline cache to '{}'", Path::GetFileName(s_pipeline_cache_path));
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_InfoPrintf("Skipping updating pipeline cache '%s' due to no changes.", s_pipeline_cache_path.c_str());
|
||||
Log_InfoFmt("Skipping updating pipeline cache '{}' due to no changes.",
|
||||
Path::GetFileName(s_pipeline_cache_path));
|
||||
}
|
||||
}
|
||||
|
||||
@ -454,7 +455,7 @@ bool GPUDevice::AcquireWindow(bool recreate_window)
|
||||
if (!wi.has_value())
|
||||
return false;
|
||||
|
||||
Log_InfoPrintf("Render window is %ux%u.", wi->surface_width, wi->surface_height);
|
||||
Log_InfoFmt("Render window is {}x{}.", wi->surface_width, wi->surface_height);
|
||||
m_window_info = wi.value();
|
||||
return true;
|
||||
}
|
||||
@ -505,7 +506,7 @@ bool GPUDevice::CreateResources()
|
||||
m_imgui_pipeline = CreatePipeline(plconfig);
|
||||
if (!m_imgui_pipeline)
|
||||
{
|
||||
Log_ErrorPrintf("Failed to compile ImGui pipeline.");
|
||||
Log_ErrorPrint("Failed to compile ImGui pipeline.");
|
||||
return false;
|
||||
}
|
||||
GL_OBJECT_NAME(m_imgui_pipeline, "ImGui Pipeline");
|
||||
@ -665,7 +666,7 @@ std::unique_ptr<GPUShader> GPUDevice::CreateShader(GPUShaderStage stage, std::st
|
||||
if (shader)
|
||||
return shader;
|
||||
|
||||
Log_ErrorPrintf("Failed to create shader from binary (driver changed?). Clearing cache.");
|
||||
Log_ErrorPrint("Failed to create shader from binary (driver changed?). Clearing cache.");
|
||||
m_shader_cache.Clear();
|
||||
}
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// SPDX-FileCopyrightText: 2023 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-FileCopyrightText: 2023-2024 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||
|
||||
#include "gpu_shader_cache.h"
|
||||
@ -8,6 +8,7 @@
|
||||
#include "common/heap_array.h"
|
||||
#include "common/log.h"
|
||||
#include "common/md5_digest.h"
|
||||
#include "common/path.h"
|
||||
|
||||
#include "fmt/format.h"
|
||||
|
||||
@ -97,7 +98,7 @@ void GPUShaderCache::Clear()
|
||||
|
||||
Close();
|
||||
|
||||
Log_WarningPrintf("Clearing shader cache at %s.", m_base_filename.c_str());
|
||||
Log_WarningFmt("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);
|
||||
@ -108,25 +109,25 @@ bool GPUShaderCache::CreateNew(const std::string& index_filename, const std::str
|
||||
{
|
||||
if (FileSystem::FileExists(index_filename.c_str()))
|
||||
{
|
||||
Log_WarningPrintf("Removing existing index file '%s'", index_filename.c_str());
|
||||
Log_WarningFmt("Removing existing index file '{}'", Path::GetFileName(index_filename));
|
||||
FileSystem::DeleteFile(index_filename.c_str());
|
||||
}
|
||||
if (FileSystem::FileExists(blob_filename.c_str()))
|
||||
{
|
||||
Log_WarningPrintf("Removing existing blob file '%s'", blob_filename.c_str());
|
||||
Log_WarningFmt("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)
|
||||
if (!m_index_file) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to open index file '%s' for writing", index_filename.c_str());
|
||||
Log_ErrorFmt("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)
|
||||
if (std::fwrite(&m_version, sizeof(m_version), 1, m_index_file) != 1) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to write version to index file '%s'", index_filename.c_str());
|
||||
Log_ErrorFmt("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());
|
||||
@ -134,9 +135,9 @@ 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)
|
||||
if (!m_blob_file) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to open blob file '%s' for writing", blob_filename.c_str());
|
||||
Log_ErrorFmt("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());
|
||||
@ -155,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_WarningPrintf("Failed to open shader cache index with EACCES, are you running two instances?");
|
||||
Log_WarningPrint("Failed to open shader cache index with EACCES, are you running two instances?");
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -163,18 +164,18 @@ 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)
|
||||
if (std::fread(&file_version, sizeof(file_version), 1, m_index_file) != 1 || file_version != m_version) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Bad file/data version in '%s'", index_filename.c_str());
|
||||
Log_ErrorFmt("Bad file/data version in '{}'", Path::GetFileName(index_filename));
|
||||
std::fclose(m_index_file);
|
||||
m_index_file = nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_blob_file = FileSystem::OpenCFile(blob_filename.c_str(), "a+b");
|
||||
if (!m_blob_file)
|
||||
if (!m_blob_file) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Blob file '%s' is missing", blob_filename.c_str());
|
||||
Log_ErrorFmt("Blob file '{}' is missing", Path::GetFileName(blob_filename));
|
||||
std::fclose(m_index_file);
|
||||
m_index_file = nullptr;
|
||||
return false;
|
||||
@ -187,12 +188,12 @@ bool GPUShaderCache::ReadExisting(const std::string& index_filename, const std::
|
||||
{
|
||||
CacheIndexEntry entry;
|
||||
if (std::fread(&entry, sizeof(entry), 1, m_index_file) != 1 ||
|
||||
(entry.file_offset + entry.compressed_size) > blob_file_size)
|
||||
(entry.file_offset + entry.compressed_size) > blob_file_size) [[unlikely]]
|
||||
{
|
||||
if (std::feof(m_index_file))
|
||||
break;
|
||||
|
||||
Log_ErrorPrintf("Failed to read entry from '%s', corrupt file?", index_filename.c_str());
|
||||
Log_ErrorFmt("Failed to read entry from '{}', corrupt file?", Path::GetFileName(index_filename));
|
||||
m_index.clear();
|
||||
std::fclose(m_blob_file);
|
||||
m_blob_file = nullptr;
|
||||
@ -210,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_DevPrintf("Read %zu entries from '%s'", m_index.size(), index_filename.c_str());
|
||||
Log_DevFmt("Read {} entries from '{}'", m_index.size(), Path::GetFileName(index_filename));
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -257,18 +258,18 @@ bool GPUShaderCache::Lookup(const CacheIndexKey& key, ShaderBinary* binary)
|
||||
DynamicHeapArray<u8> compressed_data(iter->second.compressed_size);
|
||||
|
||||
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)
|
||||
std::fread(compressed_data.data(), iter->second.compressed_size, 1, m_blob_file) != 1) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Read %u byte %s shader from file failed", iter->second.compressed_size,
|
||||
GPUShader::GetStageName(static_cast<GPUShaderStage>(key.shader_type)));
|
||||
Log_ErrorFmt("Read {} byte {} shader from file failed", iter->second.compressed_size,
|
||||
GPUShader::GetStageName(static_cast<GPUShaderStage>(key.shader_type)));
|
||||
return false;
|
||||
}
|
||||
|
||||
const size_t decompress_result =
|
||||
ZSTD_decompress(binary->data(), binary->size(), compressed_data.data(), compressed_data.size());
|
||||
if (ZSTD_isError(decompress_result))
|
||||
if (ZSTD_isError(decompress_result)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to decompress shader: %s", ZSTD_getErrorName(decompress_result));
|
||||
Log_ErrorFmt("Failed to decompress shader: {}", ZSTD_getErrorName(decompress_result));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -279,9 +280,9 @@ bool GPUShaderCache::Insert(const CacheIndexKey& key, const void* data, u32 data
|
||||
{
|
||||
DynamicHeapArray<u8> compress_buffer(ZSTD_compressBound(data_size));
|
||||
const size_t compress_result = ZSTD_compress(compress_buffer.data(), compress_buffer.size(), data, data_size, 0);
|
||||
if (ZSTD_isError(compress_result))
|
||||
if (ZSTD_isError(compress_result)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to compress shader: %s", ZSTD_getErrorName(compress_result));
|
||||
Log_ErrorFmt("Failed to compress shader: {}", ZSTD_getErrorName(compress_result));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -305,16 +306,15 @@ bool GPUShaderCache::Insert(const CacheIndexKey& key, const void* data, u32 data
|
||||
entry.uncompressed_size = idata.uncompressed_size;
|
||||
|
||||
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)
|
||||
std::fwrite(&entry, sizeof(entry), 1, m_index_file) != 1 || std::fflush(m_index_file) != 0) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to write %u byte %s shader blob to file", data_size,
|
||||
GPUShader::GetStageName(static_cast<GPUShaderStage>(key.shader_type)));
|
||||
Log_ErrorFmt("Failed to write {} byte {} shader blob to file", data_size,
|
||||
GPUShader::GetStageName(static_cast<GPUShaderStage>(key.shader_type)));
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_DevPrintf("Cached compressed %s shader: %u -> %u bytes",
|
||||
GPUShader::GetStageName(static_cast<GPUShaderStage>(key.shader_type)), data_size,
|
||||
static_cast<u32>(compress_result));
|
||||
Log_DevFmt("Cached compressed {} shader: {} -> {} bytes",
|
||||
GPUShader::GetStageName(static_cast<GPUShaderStage>(key.shader_type)), data_size, compress_result);
|
||||
m_index.emplace(key, idata);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -190,40 +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_ErrorPrintf("Invalid dimensions: %ux%ux%u %u %u.", width, height, layers, levels, samples);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Texture width (%u) or height (%u) exceeds max texture size (%u).", width, height,
|
||||
max_texture_size);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Texture samples (%u) exceeds max samples (%u).", samples, max_samples);
|
||||
Log_ErrorFmt("Texture samples ({}) exceeds max samples ({}).", samples, max_samples);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (samples > 1 && levels > 1)
|
||||
{
|
||||
Log_ErrorPrintf("Multisampled textures can't have mip levels.");
|
||||
Log_ErrorPrint("Multisampled textures can't have mip levels.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (layers > 1 && type != Type::Texture && type != Type::DynamicTexture)
|
||||
{
|
||||
Log_ErrorPrintf("Texture arrays are not supported on targets.");
|
||||
Log_ErrorPrint("Texture arrays are not supported on targets.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (levels > 1 && type != Type::Texture && type != Type::DynamicTexture)
|
||||
{
|
||||
Log_ErrorPrintf("Mipmaps are not supported on targets.");
|
||||
Log_ErrorPrint("Mipmaps are not supported on targets.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -318,7 +317,7 @@ bool GPUTexture::ConvertTextureDataToRGBA8(u32 width, u32 height, std::vector<u3
|
||||
}
|
||||
|
||||
default:
|
||||
Log_ErrorPrintf("Unknown pixel format %u", static_cast<u32>(format));
|
||||
[[unlikely]] Log_ErrorFmt("Unknown pixel format {}", static_cast<u32>(format));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ bool HTTPDownloaderCurl::StartRequest(HTTPDownloader::Request* request)
|
||||
curl_easy_setopt(req->handle, CURLOPT_POSTFIELDS, request->post_data.c_str());
|
||||
}
|
||||
|
||||
Log_DevPrintf("Started HTTP request for '%s'", req->url.c_str());
|
||||
Log_DevFmt("Started HTTP request for '{}'", req->url);
|
||||
req->state.store(Request::State::Started, std::memory_order_release);
|
||||
req->start_time = Common::Timer::GetCurrentValue();
|
||||
|
||||
|
||||
@ -42,7 +42,7 @@ bool HTTPDownloaderWinHttp::Initialize(std::string user_agent)
|
||||
WINHTTP_FLAG_ASYNC);
|
||||
if (m_hSession == NULL)
|
||||
{
|
||||
Log_ErrorPrintf("WinHttpOpen() failed: %u", GetLastError());
|
||||
Log_ErrorFmt("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_ErrorPrintf("WinHttpSetStatusCallback() failed: %u", GetLastError());
|
||||
Log_ErrorFmt("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_ErrorPrintf("WinHttp async function %p returned error %u", res->dwResult, res->dwError);
|
||||
Log_ErrorFmt("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_DevPrintf("SendRequest complete");
|
||||
Log_DevPrint("SendRequest complete");
|
||||
if (!WinHttpReceiveResponse(hRequest, nullptr))
|
||||
{
|
||||
Log_ErrorPrintf("WinHttpReceiveResponse() failed: %u", GetLastError());
|
||||
Log_ErrorFmt("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_DevPrintf("Headers available");
|
||||
Log_DevPrint("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_ErrorPrintf("WinHttpQueryHeaders() for status code failed: %u", GetLastError());
|
||||
Log_ErrorFmt("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_WarningPrintf("WinHttpQueryHeaders() for content length failed: %u", GetLastError());
|
||||
Log_WarningFmt("WinHttpQueryHeaders() for content length failed: {}", GetLastError());
|
||||
|
||||
req->content_length = 0;
|
||||
}
|
||||
@ -145,14 +145,14 @@ void CALLBACK HTTPDownloaderWinHttp::HTTPStatusCallback(HINTERNET hRequest, DWOR
|
||||
}
|
||||
}
|
||||
|
||||
Log_DevPrintf("Status code %d, content-length is %u", req->status_code, req->content_length);
|
||||
Log_DevFmt("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_ErrorPrintf("WinHttpQueryDataAvailable() failed: %u", GetLastError());
|
||||
Log_ErrorFmt("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_DevPrintf("End of request '%s', %zu bytes received", req->url.c_str(), req->data.size());
|
||||
Log_DevFmt("End of request '{}', {} bytes received", req->url, req->data.size());
|
||||
req->state.store(Request::State::Complete);
|
||||
return;
|
||||
}
|
||||
|
||||
// start the transfer
|
||||
Log_DevPrintf("%u bytes available", bytes_available);
|
||||
Log_DevFmt("{} 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_ErrorPrintf("WinHttpReadData() failed: %u", GetLastError());
|
||||
Log_ErrorFmt("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_DevPrintf("Read of %u complete", dwStatusInformationLength);
|
||||
Log_DevFmt("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_ErrorPrintf("WinHttpQueryDataAvailable() failed: %u", GetLastError());
|
||||
Log_ErrorFmt("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_ErrorPrintf("WinHttpCrackUrl() failed: %u", GetLastError());
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to start HTTP request for '%s': %u", req->url.c_str(), GetLastError());
|
||||
Log_ErrorFmt("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_ErrorPrintf("WinHttpOpenRequest() failed: %u", GetLastError());
|
||||
Log_ErrorFmt("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_ErrorPrintf("WinHttpSendRequest() failed: %u", GetLastError());
|
||||
Log_ErrorFmt("WinHttpSendRequest() failed: {}", GetLastError());
|
||||
req->status_code = HTTP_STATUS_ERROR;
|
||||
req->state.store(Request::State::Complete);
|
||||
}
|
||||
|
||||
Log_DevPrintf("Started HTTP request for '%s'", req->url.c_str());
|
||||
Log_DevFmt("Started HTTP request for '{}'", req->url);
|
||||
req->state = Request::State::Started;
|
||||
req->start_time = Common::Timer::GetCurrentValue();
|
||||
return true;
|
||||
|
||||
@ -219,7 +219,7 @@ bool ImGuiFullscreen::Initialize(const char* placeholder_image_path)
|
||||
s_placeholder_texture = LoadTexture(placeholder_image_path);
|
||||
if (!s_placeholder_texture)
|
||||
{
|
||||
Log_ErrorPrintf("Missing placeholder texture '%s', cannot continue", placeholder_image_path);
|
||||
Log_ErrorFmt("Missing placeholder texture '{}', cannot continue", placeholder_image_path);
|
||||
return 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_InfoPrintf("OSD [%s]: %s", key.c_str(), message.c_str());
|
||||
Log_InfoFmt("OSD [{}]: {}", key, message);
|
||||
else
|
||||
Log_InfoPrintf("OSD: %s", message.c_str());
|
||||
Log_InfoFmt("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_ErrorPrintf("Failed to load software cursor %u image '%s'", index, sc.image_path.c_str());
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to upload %ux%u software cursor %u image '%s'", image.GetWidth(), image.GetHeight(), index,
|
||||
sc.image_path.c_str());
|
||||
Log_ErrorFmt("Failed to upload {}x{} software cursor {} image '{}'", image.GetWidth(), image.GetHeight(), index,
|
||||
sc.image_path);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -114,7 +114,7 @@ bool INISettingsInterface::Save(Error* error /* = nullptr */)
|
||||
}
|
||||
else if (!FileSystem::RenamePath(temp_filename.c_str(), m_filename.c_str(), error))
|
||||
{
|
||||
Log_ErrorPrintf("Failed to rename '%s' to '%s'", temp_filename.c_str(), m_filename.c_str());
|
||||
Error::AddPrefixFmt(error, "Failed to rename '{}' to '{}': ", temp_filename, m_filename);
|
||||
FileSystem::DeleteFile(temp_filename.c_str());
|
||||
return false;
|
||||
}
|
||||
@ -122,7 +122,7 @@ bool INISettingsInterface::Save(Error* error /* = nullptr */)
|
||||
|
||||
if (err != SI_OK)
|
||||
{
|
||||
Log_WarningPrintf("Failed to save settings to '%s'.", m_filename.c_str());
|
||||
Log_WarningFmt("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_ErrorPrintf("Got no values for a key returned from GetAllKeys!");
|
||||
Log_ErrorPrint("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_WarningPrintf("Malformed binding: '%.*s'", static_cast<int>(binding.size()), binding.data());
|
||||
Log_WarningFmt("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_ErrorPrintf("Invalid binding: '%.*s'", static_cast<int>(binding.size()), binding.data());
|
||||
Log_ErrorFmt("Invalid binding: '{}'", binding);
|
||||
ibinding.reset();
|
||||
break;
|
||||
}
|
||||
@ -506,8 +506,7 @@ void InputManager::AddBinding(std::string_view binding, const InputEventHandler&
|
||||
|
||||
if (ibinding->num_keys == MAX_KEYS_PER_BINDING)
|
||||
{
|
||||
Log_ErrorPrintf("Too many chord parts, max is %u (%.*s)", MAX_KEYS_PER_BINDING, static_cast<int>(binding.size()),
|
||||
binding.data());
|
||||
Log_ErrorFmt("Too many chord parts, max is {} ({})", static_cast<unsigned>(MAX_KEYS_PER_BINDING), binding.size());
|
||||
ibinding.reset();
|
||||
break;
|
||||
}
|
||||
@ -862,7 +861,7 @@ void InputManager::AddPadBindings(SettingsInterface& si, const std::string& sect
|
||||
break;
|
||||
|
||||
default:
|
||||
Log_ErrorPrintf("Unhandled binding info type %u", static_cast<u32>(bi.type));
|
||||
Log_ErrorFmt("Unhandled binding info type {}", static_cast<u32>(bi.type));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1379,7 +1378,7 @@ static u32 TryMapGenericMapping(SettingsInterface& si, const std::string& sectio
|
||||
|
||||
if (found_mapping)
|
||||
{
|
||||
Log_InfoPrintf("(MapController) Map %s/%s to '%s'", section.c_str(), bind_name, found_mapping->c_str());
|
||||
Log_InfoFmt("Map {}/{} to '{}'", section, bind_name, *found_mapping);
|
||||
si.SetStringValue(section.c_str(), bind_name, found_mapping->c_str());
|
||||
return 1;
|
||||
}
|
||||
@ -1606,8 +1605,7 @@ void InputManager::LoadMacroButtonConfig(SettingsInterface& si, const std::strin
|
||||
}
|
||||
if (!binding)
|
||||
{
|
||||
Log_DevPrintf("Invalid bind '%.*s' in macro button %u for pad %u", static_cast<int>(button.size()),
|
||||
button.data(), pad, i);
|
||||
Log_DevFmt("Invalid bind '{}' in macro button {} for pad {}", button, pad, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1929,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_ErrorPrintf("(InputManager) Source '%s' failed to initialize.", InputManager::InputSourceToString(type));
|
||||
Log_ErrorFmt("Source '{}' failed to initialize.", InputManager::InputSourceToString(type));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -104,7 +104,7 @@ bool JitCodeBuffer::TryAllocateAt(const void* addr)
|
||||
if (!m_code_ptr)
|
||||
{
|
||||
if (!addr)
|
||||
Log_ErrorPrintf("VirtualAlloc(RWX, %u) for internal buffer failed: %u", m_total_size, GetLastError());
|
||||
Log_ErrorFmt("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_ErrorPrintf("mmap(RWX, %u) for internal buffer failed: %d", m_total_size, errno);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to munmap() incorrectly hinted allocation: %d", errno);
|
||||
Log_ErrorFmt("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_ErrorPrintf("VirtualProtect(RWX) for external buffer failed: %u", GetLastError());
|
||||
Log_ErrorFmt("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_ErrorPrintf("VirtualProtect(NOACCESS) for guard page failed: %u", GetLastError());
|
||||
Log_ErrorFmt("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_ErrorPrintf("mprotect(RWX) for external buffer failed: %d", errno);
|
||||
Log_ErrorFmt("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_ErrorPrintf("mprotect(NONE) for guard page failed: %d", errno);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to free code pointer %p", m_code_ptr);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to free code pointer %p", m_code_ptr);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to restore protection on %p", m_code_ptr);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to restore protection on %p", m_code_ptr);
|
||||
Log_ErrorFmt("Failed to restore protection on %p", static_cast<void*>(m_code_ptr));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -178,7 +178,7 @@ bool MetalDevice::CreateDevice(std::string_view adapter, bool threaded_presentat
|
||||
|
||||
m_device = [device retain];
|
||||
m_queue = [queue retain];
|
||||
Log_InfoPrintf("Metal Device: %s", [[m_device name] UTF8String]);
|
||||
Log_InfoFmt("Metal Device: {}", [[m_device name] UTF8String]);
|
||||
|
||||
SetFeatures(disabled_features);
|
||||
|
||||
@ -469,7 +469,7 @@ bool MetalDevice::UpdateWindow()
|
||||
|
||||
if (m_window_info.type != WindowInfo::Type::Surfaceless && !CreateLayer())
|
||||
{
|
||||
Log_ErrorPrintf("Failed to create layer on updated window");
|
||||
Log_ErrorPrint("Failed to create layer on updated window");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -515,7 +515,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_ErrorPrintf("Failed to create vertex/index/uniform buffers.");
|
||||
Log_ErrorPrint("Failed to create vertex/index/uniform buffers.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -635,7 +635,7 @@ std::unique_ptr<GPUShader> MetalDevice::CreateShaderFromMSL(GPUShaderStage stage
|
||||
id<MTLFunction> function = [library newFunctionWithName:StringViewToNSString(entry_point)];
|
||||
if (!function)
|
||||
{
|
||||
Log_ErrorPrintf("Failed to get main function in compiled library");
|
||||
Log_ErrorPrint("Failed to get main function in compiled library");
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -834,8 +834,8 @@ id<MTLDepthStencilState> MetalDevice::GetDepthState(const GPUPipeline::DepthStat
|
||||
|
||||
id<MTLDepthStencilState> state = [m_device newDepthStencilStateWithDescriptor:desc];
|
||||
m_depth_states.emplace(ds.key, state);
|
||||
if (state == nil)
|
||||
Log_ErrorPrintf("Failed to create depth-stencil state.");
|
||||
if (state == nil) [[unlikely]]
|
||||
Log_ErrorPrint("Failed to create depth-stencil state.");
|
||||
|
||||
return state;
|
||||
}
|
||||
@ -1216,7 +1216,7 @@ std::unique_ptr<GPUTexture> MetalDevice::CreateTexture(u32 width, u32 height, u3
|
||||
id<MTLTexture> tex = [m_device newTextureWithDescriptor:desc];
|
||||
if (tex == nil)
|
||||
{
|
||||
Log_ErrorPrintf("Failed to create %ux%u texture.", width, height);
|
||||
Log_ErrorFmt("Failed to create {}x{} texture.", width, height);
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -1460,7 +1460,7 @@ std::unique_ptr<GPUSampler> MetalDevice::CreateSampler(const GPUSampler::Config&
|
||||
}
|
||||
if (i == std::size(border_color_mapping))
|
||||
{
|
||||
Log_ErrorPrintf("Unsupported border color: %08X", config.border_color.GetValue());
|
||||
Log_ErrorFmt("Unsupported border color: {:08X}", config.border_color.GetValue());
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -1471,7 +1471,7 @@ std::unique_ptr<GPUSampler> MetalDevice::CreateSampler(const GPUSampler::Config&
|
||||
id<MTLSamplerState> ss = [m_device newSamplerStateWithDescriptor:desc];
|
||||
if (ss == nil)
|
||||
{
|
||||
Log_ErrorPrintf("Failed to create sampler state.");
|
||||
Log_ErrorPrint("Failed to create sampler state.");
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -2557,7 +2557,7 @@ void MetalDevice::SubmitCommandBuffer(bool wait_for_completion)
|
||||
|
||||
void MetalDevice::SubmitCommandBufferAndRestartRenderPass(const char* reason)
|
||||
{
|
||||
Log_DevPrintf("Submitting command buffer and restarting render pass due to %s", reason);
|
||||
Log_DevFmt("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_ErrorPrintf("Failed to create buffer.");
|
||||
Log_ErrorPrint("Failed to create buffer.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -61,10 +61,9 @@ bool MetalStreamBuffer::ReserveMemory(u32 num_bytes, u32 alignment)
|
||||
const u32 required_bytes = num_bytes + alignment;
|
||||
|
||||
// Check for sane allocations
|
||||
if (required_bytes > m_size)
|
||||
if (required_bytes > m_size) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Attempting to allocate %u bytes from a %u byte stream buffer", static_cast<u32>(num_bytes),
|
||||
static_cast<u32>(m_size));
|
||||
Log_ErrorFmt("Attempting to allocate {} bytes from a {} byte stream buffer", num_bytes, m_size);
|
||||
Panic("Stream buffer overflow");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -64,16 +64,16 @@ static void DisableBrokenExtensions(const char* gl_vendor, const char* gl_render
|
||||
gl_major_version >= 3 && gl_minor_version >= 2 && major_version > 0))
|
||||
{
|
||||
// r32p0 and beyond seem okay.
|
||||
// Log_VerbosePrintf("Keeping copy_image for driver version '%s'", gl_version);
|
||||
// Log_VerbosePrint("Keeping copy_image for driver version '%s'", gl_version);
|
||||
|
||||
// Framebuffer blits still end up faster.
|
||||
Log_VerbosePrintf("Newer Mali driver detected, disabling GL_{EXT,OES}_copy_image.");
|
||||
Log_VerbosePrint("Newer Mali driver detected, disabling GL_{EXT,OES}_copy_image.");
|
||||
GLAD_GL_EXT_copy_image = 0;
|
||||
GLAD_GL_OES_copy_image = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_VerbosePrintf("Older Mali driver detected, disabling GL_{EXT,OES}_copy_image, disjoint_timer_query.");
|
||||
Log_VerbosePrint("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;
|
||||
@ -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_InfoPrintf("GL_VENDOR: %s", gl_vendor);
|
||||
Log_InfoPrintf("GL_RENDERER: %s", gl_renderer);
|
||||
Log_InfoPrintf("GL_VERSION: %s", gl_version);
|
||||
Log_InfoPrintf("GL_SHADING_LANGUAGE_VERSION: %s", 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);
|
||||
|
||||
DisableBrokenExtensions(gl_vendor, gl_renderer, gl_version);
|
||||
|
||||
|
||||
@ -257,7 +257,7 @@ bool OpenGLContextEGL::ChangeSurface(const WindowInfo& new_wi)
|
||||
|
||||
if (was_current && !eglMakeCurrent(m_display, m_surface, m_surface, m_context))
|
||||
{
|
||||
Log_ErrorPrintf("Failed to make context current again after surface change");
|
||||
Log_ErrorPrint("Failed to make context current again after surface change");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -270,7 +270,7 @@ void OpenGLContextEGL::ResizeSurface(u32 new_surface_width /*= 0*/, u32 new_surf
|
||||
{
|
||||
EGLint surface_width, surface_height;
|
||||
if (eglQuerySurface(m_display, m_surface, EGL_WIDTH, &surface_width) &&
|
||||
eglQuerySurface(m_display, m_surface, EGL_HEIGHT, &surface_height))
|
||||
eglQuerySurface(m_display, m_surface, EGL_HEIGHT, &surface_height)) [[likely]]
|
||||
{
|
||||
m_wi.surface_width = static_cast<u32>(surface_width);
|
||||
m_wi.surface_height = static_cast<u32>(surface_height);
|
||||
@ -278,7 +278,7 @@ void OpenGLContextEGL::ResizeSurface(u32 new_surface_width /*= 0*/, u32 new_surf
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorPrintf("eglQuerySurface() failed: %d", eglGetError());
|
||||
Log_ErrorFmt("eglQuerySurface() failed: 0x{:X}", eglGetError());
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,9 +298,9 @@ bool OpenGLContextEGL::IsCurrent() const
|
||||
|
||||
bool OpenGLContextEGL::MakeCurrent()
|
||||
{
|
||||
if (!eglMakeCurrent(m_display, m_surface, m_surface, m_context))
|
||||
if (!eglMakeCurrent(m_display, m_surface, m_surface, m_context)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("eglMakeCurrent() failed: %d", eglGetError());
|
||||
Log_ErrorFmt("eglMakeCurrent() failed: 0x{:X}", eglGetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -364,7 +364,7 @@ bool OpenGLContextEGL::CreateSurface()
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorPrintf("eglQuerySurface() failed: %d", eglGetError());
|
||||
Log_ErrorFmt("eglQuerySurface() failed: 0x{:X}", eglGetError());
|
||||
}
|
||||
|
||||
m_wi.surface_format = GetSurfaceTextureFormat();
|
||||
@ -383,15 +383,15 @@ bool OpenGLContextEGL::CreatePBufferSurface()
|
||||
};
|
||||
|
||||
m_surface = eglCreatePbufferSurface(m_display, m_config, attrib_list);
|
||||
if (!m_surface)
|
||||
if (!m_surface) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("eglCreatePbufferSurface() failed: %d", eglGetError());
|
||||
Log_ErrorFmt("eglCreatePbufferSurface() failed: {}", eglGetError());
|
||||
return false;
|
||||
}
|
||||
|
||||
m_wi.surface_format = GetSurfaceTextureFormat();
|
||||
|
||||
Log_DevPrintf("Created %ux%u pbuffer surface", width, height);
|
||||
Log_DevFmt("Created {}x{} pbuffer surface", width, height);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -447,7 +447,7 @@ GPUTexture::Format OpenGLContextEGL::GetSurfaceTextureFormat() const
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorPrintf("Unknown surface format: R=%u, G=%u, B=%u, A=%u", red_size, green_size, blue_size, alpha_size);
|
||||
Log_ErrorFmt("Unknown surface format: R={}, G={}, B={}, A={}", red_size, green_size, blue_size, alpha_size);
|
||||
return GPUTexture::Format::RGBA8;
|
||||
}
|
||||
}
|
||||
@ -618,7 +618,7 @@ bool OpenGLContextEGL::CreateContextAndSurface(const Version& version, EGLContex
|
||||
|
||||
if (!CreateSurface())
|
||||
{
|
||||
Log_ErrorPrintf("Failed to create surface for context");
|
||||
Log_ErrorPrint("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_ErrorPrintf("eglMakeCurrent() failed: %d", eglGetError());
|
||||
Log_ErrorFmt("eglMakeCurrent() failed: 0x{:X}", eglGetError());
|
||||
if (m_surface != EGL_NO_SURFACE)
|
||||
{
|
||||
eglDestroySurface(m_display, m_surface);
|
||||
|
||||
@ -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_ErrorPrintf("Failed to create any GL context");
|
||||
Log_ErrorPrint("Failed to create any GL context");
|
||||
m_gl_context.reset();
|
||||
return false;
|
||||
}
|
||||
@ -496,8 +496,8 @@ bool OpenGLDevice::CheckFeatures(FeatureMask disabled_features)
|
||||
|
||||
if (!m_features.pipeline_cache)
|
||||
{
|
||||
Log_WarningPrintf("Your GL driver does not support program binaries. Hopefully it has a built-in cache, otherwise "
|
||||
"startup will be slow due to compiling shaders.");
|
||||
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.");
|
||||
}
|
||||
|
||||
// Mobile drivers prefer textures to not be updated mid-frame.
|
||||
@ -536,7 +536,7 @@ bool OpenGLDevice::UpdateWindow()
|
||||
|
||||
if (!m_gl_context->ChangeSurface(m_window_info))
|
||||
{
|
||||
Log_ErrorPrintf("Failed to change surface");
|
||||
Log_ErrorPrint("Failed to change surface");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -681,16 +681,16 @@ void OpenGLDevice::DestroySurface()
|
||||
|
||||
m_window_info.SetSurfaceless();
|
||||
if (!m_gl_context->ChangeSurface(m_window_info))
|
||||
Log_ErrorPrintf("Failed to switch to surfaceless");
|
||||
Log_ErrorPrint("Failed to switch to surfaceless");
|
||||
}
|
||||
|
||||
bool OpenGLDevice::CreateBuffers()
|
||||
{
|
||||
if (!(m_vertex_buffer = OpenGLStreamBuffer::Create(GL_ARRAY_BUFFER, VERTEX_BUFFER_SIZE)) ||
|
||||
!(m_index_buffer = OpenGLStreamBuffer::Create(GL_ELEMENT_ARRAY_BUFFER, INDEX_BUFFER_SIZE)) ||
|
||||
!(m_uniform_buffer = OpenGLStreamBuffer::Create(GL_UNIFORM_BUFFER, UNIFORM_BUFFER_SIZE)))
|
||||
!(m_uniform_buffer = OpenGLStreamBuffer::Create(GL_UNIFORM_BUFFER, UNIFORM_BUFFER_SIZE))) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to create one or more device buffers.");
|
||||
Log_ErrorPrint("Failed to create one or more device buffers.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -703,8 +703,9 @@ bool OpenGLDevice::CreateBuffers()
|
||||
if (!m_disable_pbo)
|
||||
{
|
||||
if (!(m_texture_stream_buffer = OpenGLStreamBuffer::Create(GL_PIXEL_UNPACK_BUFFER, TEXTURE_STREAM_BUFFER_SIZE)))
|
||||
[[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to create texture stream buffer");
|
||||
Log_ErrorPrint("Failed to create texture stream buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -717,9 +718,9 @@ bool OpenGLDevice::CreateBuffers()
|
||||
GLuint fbos[2];
|
||||
glGetError();
|
||||
glGenFramebuffers(static_cast<GLsizei>(std::size(fbos)), fbos);
|
||||
if (const GLenum err = glGetError(); err != GL_NO_ERROR)
|
||||
if (const GLenum err = glGetError(); err != GL_NO_ERROR) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to create framebuffers: %u", err);
|
||||
Log_ErrorFmt("Failed to create framebuffers: {}", err);
|
||||
return false;
|
||||
}
|
||||
m_read_fbo = fbos[0];
|
||||
@ -838,7 +839,7 @@ void OpenGLDevice::PopTimestampQuery()
|
||||
glGetIntegerv(GL_GPU_DISJOINT_EXT, &disjoint);
|
||||
if (disjoint)
|
||||
{
|
||||
Log_VerbosePrintf("GPU timing disjoint, resetting.");
|
||||
Log_VerbosePrint("GPU timing disjoint, resetting.");
|
||||
if (m_timestamp_query_started)
|
||||
glEndQueryEXT(GL_TIME_ELAPSED);
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com>
|
||||
// SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0)
|
||||
|
||||
#include "opengl_pipeline.h"
|
||||
@ -7,6 +7,7 @@
|
||||
#include "shadergen.h"
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/error.h"
|
||||
#include "common/file_system.h"
|
||||
#include "common/hash_combine.h"
|
||||
#include "common/log.h"
|
||||
@ -109,7 +110,7 @@ bool OpenGLShader::Compile()
|
||||
GLuint shader = glCreateShader(GetGLShaderType(m_stage));
|
||||
if (GLenum err = glGetError(); err != GL_NO_ERROR)
|
||||
{
|
||||
Log_ErrorPrintf("glCreateShader() failed: %u", err);
|
||||
Log_ErrorFmt("glCreateShader() failed: {}", err);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -132,7 +133,7 @@ bool OpenGLShader::Compile()
|
||||
|
||||
if (status == GL_TRUE)
|
||||
{
|
||||
Log_ErrorPrintf("Shader compiled with warnings:\n%s", info_log.c_str());
|
||||
Log_ErrorFmt("Shader compiled with warnings:\n{}", info_log);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -169,7 +170,7 @@ std::unique_ptr<GPUShader> OpenGLDevice::CreateShaderFromSource(GPUShaderStage s
|
||||
{
|
||||
if (std::strcmp(entry_point, "main") != 0)
|
||||
{
|
||||
Log_ErrorPrintf("Entry point must be 'main', but got '%s' instead.", entry_point);
|
||||
Log_ErrorFmt("Entry point must be 'main', but got '{}' instead.", entry_point);
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -264,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_ErrorPrintf("Failed to create program from binary.");
|
||||
Log_ErrorPrint("Failed to create program from binary.");
|
||||
m_program_cache.erase(it);
|
||||
it = m_program_cache.end();
|
||||
DiscardPipelineCache();
|
||||
@ -306,17 +307,17 @@ GLuint OpenGLDevice::CompileProgram(const GPUPipeline::GraphicsConfig& plconfig)
|
||||
OpenGLShader* fragment_shader = static_cast<OpenGLShader*>(plconfig.fragment_shader);
|
||||
OpenGLShader* geometry_shader = static_cast<OpenGLShader*>(plconfig.geometry_shader);
|
||||
if (!vertex_shader || !fragment_shader || !vertex_shader->Compile() || !fragment_shader->Compile() ||
|
||||
(geometry_shader && !geometry_shader->Compile()))
|
||||
(geometry_shader && !geometry_shader->Compile())) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to compile shaders.");
|
||||
Log_ErrorPrint("Failed to compile shaders.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
glGetError();
|
||||
const GLuint program_id = glCreateProgram();
|
||||
if (glGetError() != GL_NO_ERROR)
|
||||
if (glGetError() != GL_NO_ERROR) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to create program object.");
|
||||
Log_ErrorPrint("Failed to create program object.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -372,7 +373,7 @@ GLuint OpenGLDevice::CompileProgram(const GPUPipeline::GraphicsConfig& plconfig)
|
||||
GLint info_log_length = 0;
|
||||
glGetProgramiv(program_id, GL_INFO_LOG_LENGTH, &info_log_length);
|
||||
|
||||
if (status == GL_FALSE || info_log_length > 0)
|
||||
if (status == GL_FALSE || info_log_length > 0) [[unlikely]]
|
||||
{
|
||||
std::string info_log;
|
||||
info_log.resize(info_log_length + 1);
|
||||
@ -380,11 +381,11 @@ GLuint OpenGLDevice::CompileProgram(const GPUPipeline::GraphicsConfig& plconfig)
|
||||
|
||||
if (status == GL_TRUE)
|
||||
{
|
||||
Log_ErrorPrintf("Program linked with warnings:\n%s", info_log.c_str());
|
||||
Log_ErrorFmt("Program linked with warnings:\n{}", info_log.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorPrintf("Program failed to link:\n%s", info_log.c_str());
|
||||
Log_ErrorFmt("Program failed to link:\n{}", info_log.c_str());
|
||||
glDeleteProgram(program_id);
|
||||
return 0;
|
||||
}
|
||||
@ -468,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_ErrorPrintf("Failed to create vertex array object: %u", vao);
|
||||
Log_ErrorFmt("Failed to create vertex array object: {}", err);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -720,7 +721,8 @@ bool OpenGLDevice::ReadPipelineCache(const std::string& filename)
|
||||
{
|
||||
DebugAssert(!m_pipeline_disk_cache_file);
|
||||
|
||||
m_pipeline_disk_cache_file = FileSystem::OpenCFile(filename.c_str(), "r+b");
|
||||
Error error;
|
||||
m_pipeline_disk_cache_file = FileSystem::OpenCFile(filename.c_str(), "r+b", &error);
|
||||
m_pipeline_disk_cache_filename = filename;
|
||||
|
||||
if (!m_pipeline_disk_cache_file)
|
||||
@ -735,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_WarningPrintf("Failed to open shader cache: %d", errno);
|
||||
Log_WarningFmt("Failed to open shader cache: {}", error.GetDescription());
|
||||
m_pipeline_disk_cache_filename = {};
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_WarningPrintf("Disk cache does not exist, creating.");
|
||||
Log_WarningPrint("Disk cache does not exist, creating.");
|
||||
return DiscardPipelineCache();
|
||||
}
|
||||
|
||||
@ -756,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_ErrorPrintf("Failed to read disk cache footer.");
|
||||
Log_ErrorPrint("Failed to read disk cache footer.");
|
||||
return DiscardPipelineCache();
|
||||
}
|
||||
|
||||
@ -771,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_ErrorPrintf("Disk cache does not match expected driver/version.");
|
||||
Log_ErrorPrint("Disk cache does not match expected driver/version.");
|
||||
return DiscardPipelineCache();
|
||||
}
|
||||
|
||||
@ -780,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_ErrorPrintf("Failed to seek to start of index entries.");
|
||||
Log_ErrorPrint("Failed to seek to start of index entries.");
|
||||
return DiscardPipelineCache();
|
||||
}
|
||||
|
||||
@ -791,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_ErrorPrintf("Failed to read disk cache entry.");
|
||||
Log_ErrorPrint("Failed to read disk cache entry.");
|
||||
return DiscardPipelineCache();
|
||||
}
|
||||
|
||||
if (m_program_cache.find(entry.key) != m_program_cache.end())
|
||||
{
|
||||
Log_ErrorPrintf("Duplicate program in disk cache.");
|
||||
Log_ErrorPrint("Duplicate program in disk cache.");
|
||||
return DiscardPipelineCache();
|
||||
}
|
||||
|
||||
@ -811,7 +813,7 @@ bool OpenGLDevice::ReadPipelineCache(const std::string& filename)
|
||||
m_program_cache.emplace(entry.key, pitem);
|
||||
}
|
||||
|
||||
Log_VerbosePrintf("Read %zu programs from disk cache.", m_program_cache.size());
|
||||
Log_VerboseFmt("Read {} programs from disk cache.", m_program_cache.size());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -828,26 +830,26 @@ GLuint OpenGLDevice::CreateProgramFromPipelineCache(const OpenGLPipeline::Progra
|
||||
DynamicHeapArray<u8> compressed_data(it.file_compressed_size);
|
||||
|
||||
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)
|
||||
std::fread(compressed_data.data(), it.file_compressed_size, 1, m_pipeline_disk_cache_file) != 1) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to read program from disk cache.");
|
||||
Log_ErrorPrint("Failed to read program from disk cache.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
const size_t decompress_result =
|
||||
ZSTD_decompress(data.data(), data.size(), compressed_data.data(), compressed_data.size());
|
||||
if (ZSTD_isError(decompress_result))
|
||||
if (ZSTD_isError(decompress_result)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to decompress program from disk cache: %s", ZSTD_getErrorName(decompress_result));
|
||||
Log_ErrorFmt("Failed to decompress program from disk cache: {}", ZSTD_getErrorName(decompress_result));
|
||||
return 0;
|
||||
}
|
||||
compressed_data.deallocate();
|
||||
|
||||
glGetError();
|
||||
GLuint prog = glCreateProgram();
|
||||
if (const GLenum err = glGetError(); err != GL_NO_ERROR)
|
||||
if (const GLenum err = glGetError(); err != GL_NO_ERROR) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to create program object: %u", err);
|
||||
Log_ErrorFmt("Failed to create program object: {}", err);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -855,9 +857,9 @@ GLuint OpenGLDevice::CreateProgramFromPipelineCache(const OpenGLPipeline::Progra
|
||||
|
||||
GLint link_status;
|
||||
glGetProgramiv(prog, GL_LINK_STATUS, &link_status);
|
||||
if (link_status != GL_TRUE)
|
||||
if (link_status != GL_TRUE) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to create GL program from binary: status %d, discarding cache.", link_status);
|
||||
Log_ErrorFmt("Failed to create GL program from binary: status {}, discarding cache.", link_status);
|
||||
glDeleteProgram(prog);
|
||||
return 0;
|
||||
}
|
||||
@ -888,27 +890,27 @@ void OpenGLDevice::AddToPipelineCache(OpenGLPipeline::ProgramCacheItem* it)
|
||||
Log_WarningPrint("glGetProgramBinary() failed");
|
||||
return;
|
||||
}
|
||||
else if (static_cast<size_t>(binary_size) != uncompressed_data.size())
|
||||
else if (static_cast<size_t>(binary_size) != uncompressed_data.size()) [[unlikely]]
|
||||
{
|
||||
Log_WarningPrintf("Size changed from %zu to %d after glGetProgramBinary()", uncompressed_data.size(), binary_size);
|
||||
Log_WarningFmt("Size changed from {} to {} after glGetProgramBinary()", uncompressed_data.size(), binary_size);
|
||||
}
|
||||
|
||||
DynamicHeapArray<u8> compressed_data(ZSTD_compressBound(binary_size));
|
||||
const size_t compress_result =
|
||||
ZSTD_compress(compressed_data.data(), compressed_data.size(), uncompressed_data.data(), binary_size, 0);
|
||||
if (ZSTD_isError(compress_result))
|
||||
if (ZSTD_isError(compress_result)) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to compress program: %s", ZSTD_getErrorName(compress_result));
|
||||
Log_ErrorFmt("Failed to compress program: {}", ZSTD_getErrorName(compress_result));
|
||||
return;
|
||||
}
|
||||
|
||||
Log_DevPrintf("Program binary retrieved and compressed, %zu -> %zu bytes, format %u",
|
||||
static_cast<size_t>(binary_size), compress_result, format);
|
||||
Log_DevFmt("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_ErrorPrintf("Failed to write binary to disk cache.");
|
||||
Log_ErrorPrint("Failed to write binary to disk cache.");
|
||||
}
|
||||
|
||||
it->file_format = format;
|
||||
@ -940,11 +942,12 @@ bool OpenGLDevice::DiscardPipelineCache()
|
||||
if (m_pipeline_disk_cache_file)
|
||||
std::fclose(m_pipeline_disk_cache_file);
|
||||
|
||||
Error error;
|
||||
m_pipeline_disk_cache_data_end = 0;
|
||||
m_pipeline_disk_cache_file = FileSystem::OpenCFile(m_pipeline_disk_cache_filename.c_str(), "w+b");
|
||||
if (!m_pipeline_disk_cache_file)
|
||||
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_ErrorPrintf("Failed to reopen pipeline cache: %d", errno);
|
||||
Log_ErrorFmt("Failed to reopen pipeline cache: {}", error.GetDescription());
|
||||
m_pipeline_disk_cache_filename = {};
|
||||
return false;
|
||||
}
|
||||
@ -964,13 +967,13 @@ void OpenGLDevice::ClosePipelineCache()
|
||||
|
||||
if (!m_pipeline_disk_cache_changed)
|
||||
{
|
||||
Log_VerbosePrintf("Not updating pipeline cache because it has not changed.");
|
||||
Log_VerbosePrint("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)
|
||||
if (FileSystem::FSeek64(m_pipeline_disk_cache_file, m_pipeline_disk_cache_data_end, SEEK_SET) != 0) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to seek to data end.");
|
||||
Log_ErrorPrint("Failed to seek to data end.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -988,9 +991,9 @@ void OpenGLDevice::ClosePipelineCache()
|
||||
entry.compressed_size = it.second.file_compressed_size;
|
||||
entry.uncompressed_size = it.second.file_uncompressed_size;
|
||||
|
||||
if (std::fwrite(&entry, sizeof(entry), 1, m_pipeline_disk_cache_file) != 1)
|
||||
if (std::fwrite(&entry, sizeof(entry), 1, m_pipeline_disk_cache_file) != 1) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Failed to write index entry.");
|
||||
Log_ErrorPrint("Failed to write index entry.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1001,6 +1004,6 @@ void OpenGLDevice::ClosePipelineCache()
|
||||
FillFooter(&footer, m_shader_cache.GetVersion());
|
||||
footer.num_programs = count;
|
||||
|
||||
if (std::fwrite(&footer, sizeof(footer), 1, m_pipeline_disk_cache_file) != 1)
|
||||
Log_ErrorPrintf("Failed to write footer.");
|
||||
if (std::fwrite(&footer, sizeof(footer), 1, m_pipeline_disk_cache_file) != 1) [[unlikely]]
|
||||
Log_ErrorPrint("Failed to write footer.");
|
||||
}
|
||||
|
||||
@ -119,7 +119,7 @@ std::unique_ptr<OpenGLTexture> OpenGLTexture::Create(u32 width, u32 height, u32
|
||||
|
||||
if (layers > 1 && data)
|
||||
{
|
||||
Log_ErrorPrintf("Loading texture array data not currently supported");
|
||||
Log_ErrorPrint("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_ErrorPrintf("Failed to create texture: 0x%X", error);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to create sampler: %u", sampler);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to create texture for buffer: %u", err);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Buffer size of %u not supported, max is %" PRId64, buffer_size, max_ssbo_size);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to create texture for buffer: %u", err);
|
||||
Log_ErrorFmt("Failed to create texture for buffer: 0x{:X}", err);
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ static bool SetScreensaverInhibitMacOS(bool inhibit)
|
||||
if (IOPMAssertionCreateWithName(kIOPMAssertionTypePreventUserIdleDisplaySleep, kIOPMAssertionLevelOn, reason,
|
||||
&s_prevent_idle_assertion) != kIOReturnSuccess)
|
||||
{
|
||||
Log_ErrorPrintf("IOPMAssertionCreateWithName() failed");
|
||||
Log_ErrorPrint("IOPMAssertionCreateWithName() failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ void PlatformMisc::SuspendScreensaver()
|
||||
|
||||
if (!SetScreensaverInhibitMacOS(true))
|
||||
{
|
||||
Log_ErrorPrintf("Failed to suspend screensaver.");
|
||||
Log_ErrorPrint("Failed to suspend screensaver.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ static bool SetScreensaverInhibitDBus(const bool inhibit_requested, const char*
|
||||
ScopedGuard cleanup = [&]() {
|
||||
if (dbus_error_is_set(&error))
|
||||
{
|
||||
Log_ErrorPrintf("SetScreensaverInhibitDBus error: %s", error.message);
|
||||
Log_ErrorFmt("SetScreensaverInhibitDBus error: {}", error.message);
|
||||
dbus_error_free(&error);
|
||||
}
|
||||
if (message)
|
||||
|
||||
@ -21,7 +21,7 @@ static bool SetScreensaverInhibitWin32(bool inhibit)
|
||||
{
|
||||
if (SetThreadExecutionState(ES_CONTINUOUS | (inhibit ? (ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED) : 0)) == NULL)
|
||||
{
|
||||
Log_ErrorPrintf("SetThreadExecutionState() failed: %d", GetLastError());
|
||||
Log_ErrorFmt("SetThreadExecutionState() failed: {}", GetLastError());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ void PlatformMisc::SuspendScreensaver()
|
||||
|
||||
if (!SetScreensaverInhibitWin32(true))
|
||||
{
|
||||
Log_ErrorPrintf("Failed to suspend screensaver.");
|
||||
Log_ErrorPrint("Failed to suspend screensaver.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -499,7 +499,7 @@ void PostProcessing::LoadStages()
|
||||
if (stage_count > 0)
|
||||
{
|
||||
s_timer.Reset();
|
||||
Log_DevPrintf("Loaded %u post-processing stages.", stage_count);
|
||||
Log_DevFmt("Loaded {} post-processing stages.", stage_count);
|
||||
}
|
||||
|
||||
// precompile shaders
|
||||
@ -577,7 +577,7 @@ void PostProcessing::UpdateSettings()
|
||||
if (stage_count > 0)
|
||||
{
|
||||
s_timer.Reset();
|
||||
Log_DevPrintf("Loaded %u post-processing stages.", stage_count);
|
||||
Log_DevFmt("Loaded {} post-processing stages.", stage_count);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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_ErrorPrintf("Failed to compile one or more post-processing shaders, disabling.");
|
||||
Log_ErrorPrint("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_WarningPrintf("Only got %u of %u elements for '%s' in config section %s.", value_vector_size,
|
||||
option.vector_size, option.name.c_str(), section);
|
||||
Log_WarningFmt("Only got {} of {} elements for '{}' in config section %s.", value_vector_size,
|
||||
option.vector_size, option.name, section);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1150,7 +1150,7 @@ bool PostProcessing::ReShadeFXShader::CompilePipeline(GPUTexture::Format format,
|
||||
reshadefx::module mod;
|
||||
if (!CreateModule(width, height, &mod, std::move(fxcode), &error))
|
||||
{
|
||||
Log_ErrorPrintf("Failed to create module for '%s': %s", m_name.c_str(), error.GetDescription().c_str());
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to create passes for '%s': %s", m_name.c_str(), error.GetDescription().c_str());
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to compile function '%s'", name.c_str());
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to create pipeline for pass '%s'", info.name.c_str());
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to create %ux%u texture", t_width, t_height);
|
||||
Log_ErrorFmt("Failed to create {}x{} texture", t_width, t_height);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
@ -254,7 +254,7 @@ void PostProcessing::GLSLShader::LoadOptions()
|
||||
else if (sub == "OptionRangeInteger")
|
||||
current_option.type = ShaderOption::Type::Int;
|
||||
else
|
||||
Log_ErrorPrintf("Invalid option type: '%s'", line_str.c_str());
|
||||
Log_ErrorFmt("Invalid option type: '{}'", line_str);
|
||||
|
||||
continue;
|
||||
}
|
||||
@ -304,7 +304,7 @@ void PostProcessing::GLSLShader::LoadOptions()
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorPrintf("Invalid option key: '%s'", line_str.c_str());
|
||||
Log_ErrorFmt("Invalid option key: '{}'", line_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -580,14 +580,14 @@ bool SDLInputSource::ProcessSDLEvent(const SDL_Event* event)
|
||||
{
|
||||
case SDL_CONTROLLERDEVICEADDED:
|
||||
{
|
||||
Log_InfoPrintf("(SDLInputSource) Controller %d inserted", event->cdevice.which);
|
||||
Log_InfoFmt("Controller {} inserted", event->cdevice.which);
|
||||
OpenDevice(event->cdevice.which, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
case SDL_CONTROLLERDEVICEREMOVED:
|
||||
{
|
||||
Log_InfoPrintf("(SDLInputSource) Controller %d removed", event->cdevice.which);
|
||||
Log_InfoFmt("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_InfoPrintf("(SDLInputSource) Joystick %d inserted", event->jdevice.which);
|
||||
Log_InfoFmt("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_InfoPrintf("(SDLInputSource) Joystick %d removed", event->jdevice.which);
|
||||
Log_InfoFmt("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_ErrorPrintf("(SDLInputSource) Failed to open controller %d", index);
|
||||
Log_ErrorFmt("Failed to open controller {}", index);
|
||||
if (gcontroller)
|
||||
SDL_GameControllerClose(gcontroller);
|
||||
|
||||
@ -712,9 +712,9 @@ 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_WarningPrintf("(SDLInputSource) Controller %d (joystick %d) returned player ID %d, which is invalid or in "
|
||||
"use. Using ID %d instead.",
|
||||
index, joystick_id, player_id, free_player_id);
|
||||
Log_WarningFmt(
|
||||
"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 +722,8 @@ bool SDLInputSource::OpenDevice(int index, bool is_gamecontroller)
|
||||
if (!name)
|
||||
name = "Unknown Device";
|
||||
|
||||
Log_VerbosePrintf("(SDLInputSource) Opened %s %d (instance id %d, player id %d): %s",
|
||||
is_gamecontroller ? "game controller" : "joystick", index, joystick_id, player_id, name);
|
||||
Log_VerboseFmt("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 +749,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_VerbosePrintf("(SDLInputSource) Controller %d has %d axes and %d buttons", player_id, num_axes, num_buttons);
|
||||
Log_VerboseFmt("Controller {} has {} axes and {} buttons", player_id, num_axes, num_buttons);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -758,14 +758,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_VerbosePrintf("(SDLInputSource) Joystick %d has %d axes, %d buttons and %d hats", player_id,
|
||||
SDL_JoystickNumAxes(joystick), SDL_JoystickNumButtons(joystick), num_hats);
|
||||
Log_VerboseFmt("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_VerbosePrintf("(SDLInputSource) Rumble is supported on '%s' via gamecontroller", name);
|
||||
Log_VerboseFmt("Rumble is supported on '{}' via gamecontroller", name);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -784,25 +784,25 @@ bool SDLInputSource::OpenDevice(int index, bool is_gamecontroller)
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorPrintf("(SDLInputSource) Failed to create haptic left/right effect: %s", SDL_GetError());
|
||||
Log_ErrorFmt("Failed to create haptic left/right effect: {}", SDL_GetError());
|
||||
if (SDL_HapticRumbleSupported(haptic) && SDL_HapticRumbleInit(haptic) != 0)
|
||||
{
|
||||
cd.haptic = haptic;
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_ErrorPrintf("(SDLInputSource) No haptic rumble supported: %s", SDL_GetError());
|
||||
Log_ErrorFmt("No haptic rumble supported: {}", SDL_GetError());
|
||||
SDL_HapticClose(haptic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cd.haptic)
|
||||
Log_VerbosePrintf("(SDLInputSource) Rumble is supported on '%s' via haptic", name);
|
||||
Log_VerboseFmt("Rumble is supported on '{}' via haptic", name);
|
||||
}
|
||||
|
||||
if (!cd.haptic && !cd.use_game_controller_rumble)
|
||||
Log_VerbosePrintf("(SDLInputSource) Rumble is not supported on '%s'", name);
|
||||
Log_VerboseFmt("Rumble is not supported on '{}'", name);
|
||||
|
||||
if (player_id >= 0 && static_cast<u32>(player_id) < MAX_LED_COLORS && gcontroller &&
|
||||
SDL_GameControllerHasLED(gcontroller))
|
||||
|
||||
@ -87,8 +87,6 @@ bool StateWrapper::DoMarker(const char* marker)
|
||||
if (m_mode == Mode::Write || file_value.equals(marker))
|
||||
return true;
|
||||
|
||||
Log_ErrorPrintf("Marker mismatch at offset %" PRIu64 ": found '%s' expected '%s'", m_stream->GetPosition(),
|
||||
file_value.c_str(), marker);
|
||||
|
||||
Log_ErrorFmt("Marker mismatch at offset {}: found '{}' expected '{}'", m_stream->GetPosition(), file_value, marker);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ bool VulkanDevice::SelectInstanceExtensions(ExtensionList* extension_list, const
|
||||
|
||||
if (extension_count == 0)
|
||||
{
|
||||
Log_ErrorPrintf("Vulkan: No extensions supported by instance.");
|
||||
Log_ErrorPrint("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_DevPrintf("Enabling extension: %s", name);
|
||||
Log_DevFmt("Enabling extension: {}", name);
|
||||
extension_list->push_back(name);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (required)
|
||||
Log_ErrorPrintf("Vulkan: Missing required extension %s.", name);
|
||||
Log_ErrorFmt("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_WarningPrintf("Vulkan: Debug report requested, but extension is not available.");
|
||||
Log_WarningPrint("Vulkan: Debug report requested, but extension is not available.");
|
||||
|
||||
// Needed for exclusive fullscreen control.
|
||||
SupportsExtension(VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME, false);
|
||||
@ -344,7 +344,7 @@ bool VulkanDevice::SelectDeviceExtensions(ExtensionList* extension_list, bool en
|
||||
|
||||
if (extension_count == 0)
|
||||
{
|
||||
Log_ErrorPrintf("Vulkan: No extensions supported by device.");
|
||||
Log_ErrorPrint("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_DevPrintf("Enabling extension: %s", name);
|
||||
Log_DevFmt("Enabling extension: {}", name);
|
||||
extension_list->push_back(name);
|
||||
}
|
||||
|
||||
@ -370,7 +370,7 @@ bool VulkanDevice::SelectDeviceExtensions(ExtensionList* extension_list, bool en
|
||||
}
|
||||
|
||||
if (required)
|
||||
Log_ErrorPrintf("Vulkan: Missing required extension %s.", name);
|
||||
Log_ErrorFmt("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_InfoPrintf("VK_EXT_full_screen_exclusive is %s",
|
||||
m_optional_extensions.vk_ext_full_screen_exclusive ? "supported" : "NOT supported");
|
||||
Log_InfoFmt("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_ErrorPrintf("No queue families found on specified vulkan physical device.");
|
||||
Log_ErrorPrint("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_DevPrintf("%u vulkan queue families", queue_family_count);
|
||||
Log_DevFmt("{} 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_ErrorPrintf("Vulkan: Failed to find an acceptable graphics queue.");
|
||||
Log_ErrorPrint("Vulkan: Failed to find an acceptable graphics queue.");
|
||||
return false;
|
||||
}
|
||||
if (surface != VK_NULL_HANDLE && m_present_queue_family_index == queue_family_count)
|
||||
{
|
||||
Log_ErrorPrintf("Vulkan: Failed to find an acceptable present queue.");
|
||||
Log_ErrorPrint("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_DevPrintf("GPU timing is %s (TS=%u TS valid bits=%u, TS period=%f)",
|
||||
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);
|
||||
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);
|
||||
|
||||
ProcessDeviceExtensions();
|
||||
return true;
|
||||
@ -783,8 +783,8 @@ bool VulkanDevice::CreateAllocator()
|
||||
|
||||
if (heap_size_limits[type.heapIndex] == VK_WHOLE_SIZE)
|
||||
{
|
||||
Log_WarningPrintf("Disabling allocation from upload heap #%u (%.2f MB) due to debug device.", type.heapIndex,
|
||||
static_cast<float>(heap.size) / 1048576.0f);
|
||||
Log_WarningFmt("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;
|
||||
}
|
||||
@ -1506,7 +1506,7 @@ void VulkanDevice::SubmitCommandBuffer(bool wait_for_completion, const char* rea
|
||||
const std::string reason_str(StringUtil::StdStringFromFormatV(reason, ap));
|
||||
va_end(ap);
|
||||
|
||||
Log_WarningPrintf("Executing command buffer due to '%s'", reason_str.c_str());
|
||||
Log_WarningFmt("Executing command buffer due to '{}'", reason_str);
|
||||
SubmitCommandBuffer(wait_for_completion);
|
||||
}
|
||||
|
||||
@ -1588,23 +1588,23 @@ VKAPI_ATTR VkBool32 VKAPI_CALL DebugMessengerCallback(VkDebugUtilsMessageSeverit
|
||||
{
|
||||
if (severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT)
|
||||
{
|
||||
Log_ErrorPrintf("Vulkan debug report: (%s) %s", pCallbackData->pMessageIdName ? pCallbackData->pMessageIdName : "",
|
||||
pCallbackData->pMessage);
|
||||
Log_ErrorFmt("Vulkan debug report: ({}) {}", pCallbackData->pMessageIdName ? pCallbackData->pMessageIdName : "",
|
||||
pCallbackData->pMessage);
|
||||
}
|
||||
else if (severity & (VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT))
|
||||
{
|
||||
Log_WarningPrintf("Vulkan debug report: (%s) %s",
|
||||
pCallbackData->pMessageIdName ? pCallbackData->pMessageIdName : "", pCallbackData->pMessage);
|
||||
Log_WarningFmt("Vulkan debug report: ({}) {}", pCallbackData->pMessageIdName ? pCallbackData->pMessageIdName : "",
|
||||
pCallbackData->pMessage);
|
||||
}
|
||||
else if (severity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT)
|
||||
{
|
||||
Log_InfoPrintf("Vulkan debug report: (%s) %s", pCallbackData->pMessageIdName ? pCallbackData->pMessageIdName : "",
|
||||
pCallbackData->pMessage);
|
||||
Log_InfoFmt("Vulkan debug report: ({}) {}", pCallbackData->pMessageIdName ? pCallbackData->pMessageIdName : "",
|
||||
pCallbackData->pMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
Log_DevPrintf("Vulkan debug report: (%s) %s", pCallbackData->pMessageIdName ? pCallbackData->pMessageIdName : "",
|
||||
pCallbackData->pMessage);
|
||||
Log_DevFmt("Vulkan debug report: ({}) {}", pCallbackData->pMessageIdName ? pCallbackData->pMessageIdName : "",
|
||||
pCallbackData->pMessage);
|
||||
}
|
||||
|
||||
return VK_FALSE;
|
||||
@ -1957,13 +1957,13 @@ bool VulkanDevice::CreateDevice(std::string_view adapter, bool threaded_presenta
|
||||
return false;
|
||||
}
|
||||
|
||||
Log_ErrorPrintf("Vulkan validation/debug layers requested but are unavailable. Creating non-debug device.");
|
||||
Log_ErrorPrint("Vulkan validation/debug layers requested but are unavailable. Creating non-debug device.");
|
||||
}
|
||||
}
|
||||
|
||||
if (!Vulkan::LoadVulkanInstanceFunctions(m_instance))
|
||||
{
|
||||
Log_ErrorPrintf("Failed to load Vulkan instance functions");
|
||||
Log_ErrorPrint("Failed to load Vulkan instance functions");
|
||||
Error::SetStringView(error, "Failed to load Vulkan instance functions");
|
||||
return false;
|
||||
}
|
||||
@ -2144,33 +2144,33 @@ bool VulkanDevice::ValidatePipelineCacheHeader(const VK_PIPELINE_CACHE_HEADER& h
|
||||
{
|
||||
if (header.header_length < sizeof(VK_PIPELINE_CACHE_HEADER))
|
||||
{
|
||||
Log_ErrorPrintf("Pipeline cache failed validation: Invalid header length");
|
||||
Log_ErrorPrint("Pipeline cache failed validation: Invalid header length");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (header.header_version != VK_PIPELINE_CACHE_HEADER_VERSION_ONE)
|
||||
{
|
||||
Log_ErrorPrintf("Pipeline cache failed validation: Invalid header version");
|
||||
Log_ErrorPrint("Pipeline cache failed validation: Invalid header version");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (header.vendor_id != m_device_properties.vendorID)
|
||||
{
|
||||
Log_ErrorPrintf("Pipeline cache failed validation: Incorrect vendor ID (file: 0x%X, device: 0x%X)",
|
||||
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);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (header.device_id != m_device_properties.deviceID)
|
||||
{
|
||||
Log_ErrorPrintf("Pipeline cache failed validation: Incorrect device ID (file: 0x%X, device: 0x%X)",
|
||||
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);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (std::memcmp(header.uuid, m_device_properties.pipelineCacheUUID, VK_UUID_SIZE) != 0)
|
||||
{
|
||||
Log_ErrorPrintf("Pipeline cache failed validation: Incorrect UUID");
|
||||
Log_ErrorPrint("Pipeline cache failed validation: Incorrect UUID");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2199,7 +2199,7 @@ bool VulkanDevice::ReadPipelineCache(const std::string& filename)
|
||||
{
|
||||
if (data->size() < sizeof(VK_PIPELINE_CACHE_HEADER))
|
||||
{
|
||||
Log_ErrorPrintf("Pipeline cache at '%s' is too small", filename.c_str());
|
||||
Log_ErrorFmt("Pipeline cache at '{}' is too small", Path::GetFileName(filename));
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -2266,14 +2266,14 @@ bool VulkanDevice::UpdateWindow()
|
||||
VkSurfaceKHR surface = VulkanSwapChain::CreateVulkanSurface(m_instance, m_physical_device, &m_window_info);
|
||||
if (surface == VK_NULL_HANDLE)
|
||||
{
|
||||
Log_ErrorPrintf("Failed to create new surface for swap chain");
|
||||
Log_ErrorPrint("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_ErrorPrintf("Failed to create swap chain");
|
||||
Log_ErrorPrint("Failed to create swap chain");
|
||||
VulkanSwapChain::DestroyVulkanSurface(m_instance, &m_window_info, surface);
|
||||
return false;
|
||||
}
|
||||
@ -2302,7 +2302,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_ErrorPrintf("Failed to resize swap chain. Next present will fail.");
|
||||
Log_ErrorPrint("Failed to resize swap chain. Next present will fail.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2405,10 +2405,10 @@ bool VulkanDevice::BeginPresent(bool frame_skip)
|
||||
}
|
||||
else if (res == VK_ERROR_SURFACE_LOST_KHR)
|
||||
{
|
||||
Log_WarningPrintf("Surface lost, attempting to recreate");
|
||||
Log_WarningPrint("Surface lost, attempting to recreate");
|
||||
if (!m_swap_chain->RecreateSurface(m_window_info))
|
||||
{
|
||||
Log_ErrorPrintf("Failed to recreate surface after loss");
|
||||
Log_ErrorPrint("Failed to recreate surface after loss");
|
||||
SubmitCommandBuffer(false);
|
||||
TrimTexturePool();
|
||||
return false;
|
||||
@ -2544,7 +2544,7 @@ bool VulkanDevice::CheckFeatures(FeatureMask disabled_features)
|
||||
m_optional_extensions.vk_ext_rasterization_order_attachment_access;
|
||||
|
||||
if (!m_features.dual_source_blend)
|
||||
Log_WarningPrintf("Vulkan driver is missing dual-source blending. This will have an impact on performance.");
|
||||
Log_WarningPrint("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 +2557,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_InfoPrintf("Max texel buffer elements: %u", max_texel_buffer_elements);
|
||||
Log_InfoFmt("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 +2565,7 @@ bool VulkanDevice::CheckFeatures(FeatureMask disabled_features)
|
||||
#endif
|
||||
|
||||
if (m_features.texture_buffers_emulated_with_ssbo)
|
||||
Log_WarningPrintf("Emulating texture buffers with SSBOs.");
|
||||
Log_WarningPrint("Emulating texture buffers with SSBOs.");
|
||||
|
||||
m_features.geometry_shaders =
|
||||
!(disabled_features & FEATURE_MASK_GEOMETRY_SHADERS) && m_device_features.geometryShader;
|
||||
@ -3069,7 +3069,7 @@ void VulkanDevice::RenderBlankFrame()
|
||||
VkResult res = m_swap_chain->AcquireNextImage();
|
||||
if (res != VK_SUCCESS)
|
||||
{
|
||||
Log_ErrorPrintf("Failed to acquire image for blank frame present");
|
||||
Log_ErrorPrint("Failed to acquire image for blank frame present");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -114,10 +114,9 @@ bool VulkanStreamBuffer::ReserveMemory(u32 num_bytes, u32 alignment)
|
||||
const u32 required_bytes = num_bytes + alignment;
|
||||
|
||||
// Check for sane allocations
|
||||
if (required_bytes > m_size)
|
||||
if (required_bytes > m_size) [[unlikely]]
|
||||
{
|
||||
Log_ErrorPrintf("Attempting to allocate %u bytes from a %u byte stream buffer", static_cast<u32>(num_bytes),
|
||||
static_cast<u32>(m_size));
|
||||
Log_ErrorFmt("Attempting to allocate {} bytes from a {} byte stream buffer", num_bytes, m_size);
|
||||
Panic("Stream buffer overflow");
|
||||
}
|
||||
|
||||
|
||||
@ -147,7 +147,7 @@ std::unique_ptr<VulkanTexture> VulkanTexture::Create(u32 width, u32 height, u32
|
||||
}
|
||||
if (res == VK_ERROR_OUT_OF_DEVICE_MEMORY)
|
||||
{
|
||||
Log_ErrorPrintf("Failed to allocate device memory for %ux%u texture", width, height);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to reserve texture upload memory (%u bytes).", required_size);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Unsupported border color: %08X", config.border_color.GetValue());
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to allocate persistent descriptor set for texture buffer.");
|
||||
Log_ErrorPrint("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_ErrorPrintf("Failed to create buffer view for texture buffer.");
|
||||
Log_ErrorPrint("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_ErrorPrintf("Failed to write header to file");
|
||||
Log_ErrorPrint("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_ErrorPrintf("Failed to re-write header on file, file may be unplayable");
|
||||
Log_ErrorPrint("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_ErrorPrintf("Only wrote %u of %u frames to output file", num_frames_written, num_frames);
|
||||
Log_ErrorFmt("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_ErrorPrintf("(Win32RawInputSource) Failed to register dummy window class");
|
||||
Log_ErrorPrint("Failed to register dummy window class");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CreateDummyWindow())
|
||||
{
|
||||
Log_ErrorPrintf("(Win32RawInputSource) Failed to create dummy window");
|
||||
Log_ErrorPrint("Failed to create dummy window");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!OpenDevices())
|
||||
{
|
||||
Log_ErrorPrintf("(Win32RawInputSource) Failed to open devices");
|
||||
Log_ErrorPrint("Failed to open devices");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ bool Win32RawInputSource::OpenDevices()
|
||||
m_mice.push_back({rid.hDevice, 0u, 0, 0});
|
||||
}
|
||||
|
||||
Log_DevPrintf("(Win32RawInputSource) Found %u keyboards and %zu mice", m_num_keyboards, m_mice.size());
|
||||
Log_DevFmt("Found {} keyboards and {} mice", m_num_keyboards, m_mice.size());
|
||||
|
||||
// Grab all keyboard/mouse input.
|
||||
if (m_num_keyboards > 0)
|
||||
|
||||
@ -198,8 +198,8 @@ private:
|
||||
{
|
||||
char error_string[256] = {};
|
||||
XGetErrorText(display, ee->error_code, error_string, sizeof(error_string));
|
||||
Log_WarningPrintf("X11 Error: %s (Error %u Minor %u Request %u)", error_string, ee->error_code, ee->minor_code,
|
||||
ee->request_code);
|
||||
Log_WarningFmt("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;
|
||||
@ -237,7 +237,7 @@ static std::optional<float> GetRefreshRateFromXRandR(const WindowInfo& wi)
|
||||
}
|
||||
else if (num_monitors > 1)
|
||||
{
|
||||
Log_WarningPrintf("XRRGetMonitors() returned %d monitors, using first", num_monitors);
|
||||
Log_WarningFmt("XRRGetMonitors() returned {} monitors, using first", num_monitors);
|
||||
}
|
||||
|
||||
ScopedGuard mi_guard([mi]() { XRRFreeMonitors(mi); });
|
||||
@ -248,7 +248,7 @@ static std::optional<float> GetRefreshRateFromXRandR(const WindowInfo& wi)
|
||||
}
|
||||
else if (mi->noutput > 1)
|
||||
{
|
||||
Log_WarningPrintf("Monitor has %d outputs, using first", mi->noutput);
|
||||
Log_WarningFmt("Monitor has {} outputs, using first", mi->noutput);
|
||||
}
|
||||
|
||||
XRROutputInfo* oi = XRRGetOutputInfo(display, res, mi->outputs[0]);
|
||||
@ -280,13 +280,13 @@ static std::optional<float> GetRefreshRateFromXRandR(const WindowInfo& wi)
|
||||
}
|
||||
if (!mode)
|
||||
{
|
||||
Log_ErrorPrintf("Failed to look up mode %d (of %d)", static_cast<int>(ci->mode), res->nmode);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Modeline is invalid: %ld/%d/%d", mode->dotClock, mode->hTotal, mode->vTotal);
|
||||
Log_ErrorFmt("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_ErrorPrintf("Failed to load XInput module.");
|
||||
Log_ErrorPrint("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_ErrorPrintf("Failed to get XInput function pointers.");
|
||||
Log_ErrorPrint("Failed to get XInput function pointers.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -227,7 +227,7 @@ void XInputSource::PollEvents()
|
||||
else
|
||||
{
|
||||
if (result != ERROR_DEVICE_NOT_CONNECTED)
|
||||
Log_WarningPrintf("XInputGetState(%u) failed: 0x%08X / 0x%08X", i, result, GetLastError());
|
||||
Log_WarningFmt("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_InfoPrintf("XInput controller %u connected.", index);
|
||||
Log_InfoFmt("XInput controller {} connected.", index);
|
||||
|
||||
XINPUT_CAPABILITIES caps = {};
|
||||
if (m_xinput_get_capabilities(index, 0, &caps) != ERROR_SUCCESS)
|
||||
Log_WarningPrintf("Failed to get XInput capabilities for controller %u", index);
|
||||
Log_WarningFmt("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_InfoPrintf("XInput controller %u disconnected.", index);
|
||||
Log_InfoFmt("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_ErrorPrintf("ZSTD_compressStream2() failed: %u (%s)", static_cast<unsigned>(ZSTD_getErrorCode(ret)),
|
||||
ZSTD_getErrorString(ZSTD_getErrorCode(ret)));
|
||||
Log_ErrorFmt("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_ErrorPrintf("ZSTD_decompressStream() failed: %u (%s)", static_cast<unsigned>(ZSTD_getErrorCode(ret)),
|
||||
ZSTD_getErrorString(ZSTD_getErrorCode(ret)));
|
||||
Log_ErrorFmt("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