mirror of https://github.com/AxioDL/boo.git
Massive fmtlib refactor
This commit is contained in:
parent
b2bf7549f5
commit
deefc8e995
|
@ -22,6 +22,11 @@ static inline ComPtr<T>* ReferenceComPtr(ComPtr<T>& ptr) {
|
|||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
#define FMT_STRING_ALIAS 1
|
||||
#define FMT_ENFORCE_COMPILE_STRING 1
|
||||
#define FMT_USE_GRISU 0
|
||||
#include <fmt/format.h>
|
||||
|
||||
#ifndef ENABLE_BITWISE_ENUM
|
||||
#define ENABLE_BITWISE_ENUM(type) \
|
||||
constexpr type operator|(type a, type b) { \
|
||||
|
|
|
@ -39,7 +39,13 @@ public:
|
|||
|
||||
/* Callbacks */
|
||||
virtual void deviceDisconnected() = 0;
|
||||
virtual void deviceError(const char* error, ...);
|
||||
virtual void vdeviceError(fmt::string_view error, fmt::format_args args);
|
||||
template <typename S, typename... Args, typename Char = fmt::char_t<S>>
|
||||
void deviceError(const S& format, Args&&... args) {
|
||||
vdeviceError(fmt::to_string_view<Char>(format),
|
||||
fmt::basic_format_args<fmt::buffer_context<Char>>(
|
||||
fmt::internal::make_args_checked<Args...>(format, args...)));
|
||||
}
|
||||
virtual void initialCycle() {}
|
||||
virtual void transferCycle() {}
|
||||
virtual void finalCycle() {}
|
||||
|
|
|
@ -41,13 +41,13 @@ private:
|
|||
|
||||
/* Friend methods for platform-listener to find/insert/remove
|
||||
* tokens with type-filtering */
|
||||
inline bool _hasToken(const std::string& path) {
|
||||
bool _hasToken(const std::string& path) {
|
||||
auto preCheck = m_tokens.find(path);
|
||||
if (preCheck != m_tokens.end())
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
inline bool _insertToken(std::unique_ptr<DeviceToken>&& token) {
|
||||
bool _insertToken(std::unique_ptr<DeviceToken>&& token) {
|
||||
if (DeviceSignature::DeviceMatchToken(*token, m_types)) {
|
||||
m_tokensLock.lock();
|
||||
TInsertedDeviceToken inseredTok = m_tokens.insert(std::make_pair(token->getDevicePath(), std::move(token)));
|
||||
|
@ -57,7 +57,7 @@ private:
|
|||
}
|
||||
return false;
|
||||
}
|
||||
inline void _removeToken(const std::string& path) {
|
||||
void _removeToken(const std::string& path) {
|
||||
auto preCheck = m_tokens.find(path);
|
||||
if (preCheck != m_tokens.end()) {
|
||||
DeviceToken& tok = *preCheck->second;
|
||||
|
@ -75,16 +75,16 @@ public:
|
|||
DeviceFinder& m_finder;
|
||||
|
||||
public:
|
||||
inline CDeviceTokensHandle(DeviceFinder& finder) : m_finder(finder) { m_finder.m_tokensLock.lock(); }
|
||||
inline ~CDeviceTokensHandle() { m_finder.m_tokensLock.unlock(); }
|
||||
inline TDeviceTokens::iterator begin() { return m_finder.m_tokens.begin(); }
|
||||
inline TDeviceTokens::iterator end() { return m_finder.m_tokens.end(); }
|
||||
CDeviceTokensHandle(DeviceFinder& finder) : m_finder(finder) { m_finder.m_tokensLock.lock(); }
|
||||
~CDeviceTokensHandle() { m_finder.m_tokensLock.unlock(); }
|
||||
TDeviceTokens::iterator begin() { return m_finder.m_tokens.begin(); }
|
||||
TDeviceTokens::iterator end() { return m_finder.m_tokens.end(); }
|
||||
};
|
||||
|
||||
/* Application must specify its interested device-types */
|
||||
DeviceFinder(std::unordered_set<uint64_t> types) {
|
||||
if (skDevFinder) {
|
||||
fprintf(stderr, "only one instance of CDeviceFinder may be constructed");
|
||||
fmt::print(stderr, fmt("only one instance of CDeviceFinder may be constructed"));
|
||||
abort();
|
||||
}
|
||||
skDevFinder = this;
|
||||
|
@ -104,20 +104,20 @@ public:
|
|||
}
|
||||
|
||||
/* Get interested device-type mask */
|
||||
inline const DeviceSignature::TDeviceSignatureSet& getTypes() const { return m_types; }
|
||||
const DeviceSignature::TDeviceSignatureSet& getTypes() const { return m_types; }
|
||||
|
||||
/* Iterable set of tokens */
|
||||
inline CDeviceTokensHandle getTokens() { return CDeviceTokensHandle(*this); }
|
||||
CDeviceTokensHandle getTokens() { return CDeviceTokensHandle(*this); }
|
||||
|
||||
/* Automatic device scanning */
|
||||
inline bool startScanning() {
|
||||
bool startScanning() {
|
||||
if (!m_listener)
|
||||
m_listener = IHIDListenerNew(*this);
|
||||
if (m_listener)
|
||||
return m_listener->startScanning();
|
||||
return false;
|
||||
}
|
||||
inline bool stopScanning() {
|
||||
bool stopScanning() {
|
||||
if (!m_listener)
|
||||
m_listener = IHIDListenerNew(*this);
|
||||
if (m_listener)
|
||||
|
@ -126,7 +126,7 @@ public:
|
|||
}
|
||||
|
||||
/* Manual device scanning */
|
||||
inline bool scanNow() {
|
||||
bool scanNow() {
|
||||
if (!m_listener)
|
||||
m_listener = IHIDListenerNew(*this);
|
||||
if (m_listener)
|
||||
|
|
|
@ -20,7 +20,7 @@ class DeviceToken {
|
|||
std::shared_ptr<DeviceBase> m_connectedDev;
|
||||
|
||||
friend class DeviceFinder;
|
||||
inline void _deviceClose() {
|
||||
void _deviceClose() {
|
||||
if (m_connectedDev)
|
||||
m_connectedDev->_deviceDisconnected();
|
||||
m_connectedDev = NULL;
|
||||
|
@ -36,8 +36,7 @@ public:
|
|||
, m_productName(other.m_productName)
|
||||
, m_devPath(other.m_devPath)
|
||||
, m_connectedDev(other.m_connectedDev) {}
|
||||
inline DeviceToken(DeviceType devType, unsigned vid, unsigned pid, const char* vname, const char* pname,
|
||||
const char* path)
|
||||
DeviceToken(DeviceType devType, unsigned vid, unsigned pid, const char* vname, const char* pname, const char* path)
|
||||
: m_devType(devType), m_vendorId(vid), m_productId(pid), m_devPath(path), m_connectedDev(NULL) {
|
||||
if (vname)
|
||||
m_vendorName = vname;
|
||||
|
@ -45,21 +44,21 @@ public:
|
|||
m_productName = pname;
|
||||
}
|
||||
|
||||
inline DeviceType getDeviceType() const { return m_devType; }
|
||||
inline unsigned getVendorId() const { return m_vendorId; }
|
||||
inline unsigned getProductId() const { return m_productId; }
|
||||
inline std::string_view getVendorName() const { return m_vendorName; }
|
||||
inline std::string_view getProductName() const { return m_productName; }
|
||||
inline std::string_view getDevicePath() const { return m_devPath; }
|
||||
inline bool isDeviceOpen() const { return (m_connectedDev != NULL); }
|
||||
inline std::shared_ptr<DeviceBase> openAndGetDevice() {
|
||||
DeviceType getDeviceType() const { return m_devType; }
|
||||
unsigned getVendorId() const { return m_vendorId; }
|
||||
unsigned getProductId() const { return m_productId; }
|
||||
std::string_view getVendorName() const { return m_vendorName; }
|
||||
std::string_view getProductName() const { return m_productName; }
|
||||
std::string_view getDevicePath() const { return m_devPath; }
|
||||
bool isDeviceOpen() const { return (m_connectedDev != NULL); }
|
||||
std::shared_ptr<DeviceBase> openAndGetDevice() {
|
||||
if (!m_connectedDev)
|
||||
m_connectedDev = DeviceSignature::DeviceNew(*this);
|
||||
return m_connectedDev;
|
||||
}
|
||||
|
||||
inline bool operator==(const DeviceToken& rhs) const { return m_devPath == rhs.m_devPath; }
|
||||
inline bool operator<(const DeviceToken& rhs) const { return m_devPath < rhs.m_devPath; }
|
||||
bool operator==(const DeviceToken& rhs) const { return m_devPath == rhs.m_devPath; }
|
||||
bool operator<(const DeviceToken& rhs) const { return m_devPath < rhs.m_devPath; }
|
||||
};
|
||||
|
||||
} // namespace boo
|
||||
|
|
|
@ -111,7 +111,7 @@ public:
|
|||
T** storage() const { return (T**)_storage; }
|
||||
LPVOID* operator&() {
|
||||
if (IUnknownVTbl** pointer = _storage) {
|
||||
printf("%p RELEASE %d\n", pointer, (*pointer)->Release(pointer));
|
||||
fmt::print(fmt("0x{:X} RELEASE {}\n"), pointer, (*pointer)->Release(pointer));
|
||||
}
|
||||
return (LPVOID*)&_storage;
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
|||
argSize = sizeof(devId);
|
||||
if (AudioObjectGetPropertyData(kAudioObjectSystemObject, &propertyAddress, sizeof(devName), &devName, &argSize,
|
||||
&devId) != noErr) {
|
||||
Log.report(logvisor::Error, "unable to resolve audio device UID %s, using default",
|
||||
Log.report(logvisor::Error, fmt("unable to resolve audio device UID %s, using default"),
|
||||
CFStringGetCStringPtr(devName, kCFStringEncodingUTF8));
|
||||
argSize = sizeof(devId);
|
||||
propertyAddress.mSelector = kAudioHardwarePropertyDefaultOutputDevice;
|
||||
|
@ -84,7 +84,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
|||
deviceAddress.mSelector = kAudioDevicePropertyDeviceUID;
|
||||
AudioObjectGetPropertyData(devId, &deviceAddress, 0, NULL, &argSize, &m_devName);
|
||||
} else {
|
||||
Log.report(logvisor::Fatal, "unable determine default audio device");
|
||||
Log.report(logvisor::Fatal, fmt("unable determine default audio device"));
|
||||
return {AudioChannelSet::Unknown, 48000.0};
|
||||
}
|
||||
}
|
||||
|
@ -250,9 +250,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
|||
if (!(nameCstr = CFStringGetCStringPtr(namestr.get(), kCFStringEncodingUTF8)))
|
||||
continue;
|
||||
|
||||
char idStr[9];
|
||||
snprintf(idStr, 9, "%08X\n", idNum);
|
||||
ret.push_back(std::make_pair(std::string(idStr), std::string(nameCstr)));
|
||||
ret.push_back(std::make_pair(fmt::format(fmt("{:08X}"), idNum), std::string(nameCstr)));
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -271,9 +269,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
|||
if (MIDIObjectGetIntegerProperty(dev, kMIDIPropertyUniqueID, &idNum))
|
||||
continue;
|
||||
|
||||
char idStr[9];
|
||||
snprintf(idStr, 9, "%08X\n", idNum);
|
||||
if (strcmp(idStr, name))
|
||||
if (fmt::format(fmt("{:08X}"), idNum) != name)
|
||||
continue;
|
||||
|
||||
return dev;
|
||||
|
@ -464,15 +460,15 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
|||
if (!ret)
|
||||
return {};
|
||||
|
||||
char name[256];
|
||||
std::string name;
|
||||
auto appName = APP->getFriendlyName();
|
||||
if (!m_midiInCounter)
|
||||
snprintf(name, 256, "%s MIDI-In", appName.data());
|
||||
name = fmt::format(fmt("{} MIDI-In"), appName);
|
||||
else
|
||||
snprintf(name, 256, "%s MIDI-In %u", appName.data(), m_midiInCounter);
|
||||
name = fmt::format(fmt("{} MIDI-In {}"), appName, m_midiInCounter);
|
||||
m_midiInCounter++;
|
||||
CFPointer<CFStringRef> midiName = CFPointer<CFStringRef>::adopt(
|
||||
CFStringCreateWithCStringNoCopy(nullptr, name, kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
CFStringCreateWithCStringNoCopy(nullptr, name.c_str(), kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
OSStatus stat;
|
||||
if ((stat = MIDIDestinationCreate(m_midiClient, midiName.get(), MIDIReadProc(MIDIReceiveProc),
|
||||
static_cast<IMIDIReceiver*>(ret.get()), &static_cast<MIDIIn&>(*ret).m_midi)))
|
||||
|
@ -489,15 +485,15 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
|||
if (!ret)
|
||||
return {};
|
||||
|
||||
char name[256];
|
||||
std::string name;
|
||||
auto appName = APP->getFriendlyName();
|
||||
if (!m_midiOutCounter)
|
||||
snprintf(name, 256, "%s MIDI-Out", appName.data());
|
||||
name = fmt::format(fmt("{} MIDI-Out"), appName);
|
||||
else
|
||||
snprintf(name, 256, "%s MIDI-Out %u", appName.data(), m_midiOutCounter);
|
||||
name = fmt::format(fmt("{} MIDI-Out {}"), appName, m_midiOutCounter);
|
||||
m_midiOutCounter++;
|
||||
CFPointer<CFStringRef> midiName = CFPointer<CFStringRef>::adopt(
|
||||
CFStringCreateWithCStringNoCopy(nullptr, name, kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
CFStringCreateWithCStringNoCopy(nullptr, name.c_str(), kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
if (MIDISourceCreate(m_midiClient, midiName.get(), &static_cast<MIDIOut&>(*ret).m_midi))
|
||||
ret.reset();
|
||||
|
||||
|
@ -512,15 +508,15 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
|||
if (!ret)
|
||||
return {};
|
||||
|
||||
char name[256];
|
||||
std::string name;
|
||||
auto appName = APP->getFriendlyName();
|
||||
if (!m_midiInCounter)
|
||||
snprintf(name, 256, "%s MIDI-In", appName.data());
|
||||
name = fmt::format(fmt("{} MIDI-In"), appName);
|
||||
else
|
||||
snprintf(name, 256, "%s MIDI-In %u", appName.data(), m_midiInCounter);
|
||||
name = fmt::format(fmt("{} MIDI-In {}"), appName, m_midiInCounter);
|
||||
m_midiInCounter++;
|
||||
CFPointer<CFStringRef> midiName = CFPointer<CFStringRef>::adopt(
|
||||
CFStringCreateWithCStringNoCopy(nullptr, name, kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
CFStringCreateWithCStringNoCopy(nullptr, name.c_str(), kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
if (MIDIDestinationCreate(m_midiClient, midiName.get(), MIDIReadProc(MIDIReceiveProc),
|
||||
static_cast<IMIDIReceiver*>(ret.get()), &static_cast<MIDIInOut&>(*ret).m_midiIn))
|
||||
ret.reset();
|
||||
|
@ -529,12 +525,12 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
|||
return {};
|
||||
|
||||
if (!m_midiOutCounter)
|
||||
snprintf(name, 256, "%s MIDI-Out", appName.data());
|
||||
name = fmt::format(fmt("{} MIDI-Out"), appName);
|
||||
else
|
||||
snprintf(name, 256, "%s MIDI-Out %u", appName.data(), m_midiOutCounter);
|
||||
name = fmt::format(fmt("{} MIDI-Out {}"), appName, m_midiOutCounter);
|
||||
m_midiOutCounter++;
|
||||
midiName = CFPointer<CFStringRef>::adopt(
|
||||
CFStringCreateWithCStringNoCopy(nullptr, name, kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
CFStringCreateWithCStringNoCopy(nullptr, name.c_str(), kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
if (MIDISourceCreate(m_midiClient, midiName.get(), &static_cast<MIDIInOut&>(*ret).m_midiOut))
|
||||
ret.reset();
|
||||
|
||||
|
@ -553,10 +549,9 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
|||
if (!ret)
|
||||
return {};
|
||||
|
||||
char mname[256];
|
||||
snprintf(mname, 256, "Boo MIDI Real In %u", m_midiInCounter++);
|
||||
std::string mname = fmt::format(fmt("Boo MIDI Real In {}"), m_midiInCounter++);
|
||||
CFPointer<CFStringRef> midiName = CFPointer<CFStringRef>::adopt(
|
||||
CFStringCreateWithCStringNoCopy(nullptr, mname, kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
CFStringCreateWithCStringNoCopy(nullptr, mname.c_str(), kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
if (MIDIInputPortCreate(m_midiClient, midiName.get(), MIDIReadProc(MIDIReceiveProc),
|
||||
static_cast<IMIDIReceiver*>(ret.get()), &static_cast<MIDIIn&>(*ret).m_midiPort))
|
||||
ret.reset();
|
||||
|
@ -578,10 +573,9 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
|||
if (!ret)
|
||||
return {};
|
||||
|
||||
char mname[256];
|
||||
snprintf(mname, 256, "Boo MIDI Real Out %u", m_midiOutCounter++);
|
||||
std::string mname = fmt::format(fmt("Boo MIDI Real Out {}"), m_midiOutCounter++);
|
||||
CFPointer<CFStringRef> midiName = CFPointer<CFStringRef>::adopt(
|
||||
CFStringCreateWithCStringNoCopy(nullptr, mname, kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
CFStringCreateWithCStringNoCopy(nullptr, mname.c_str(), kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
if (MIDIOutputPortCreate(m_midiClient, midiName.get(), &static_cast<MIDIOut&>(*ret).m_midiPort))
|
||||
ret.reset();
|
||||
else
|
||||
|
@ -606,10 +600,9 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
|||
if (!ret)
|
||||
return {};
|
||||
|
||||
char mname[256];
|
||||
snprintf(mname, 256, "Boo MIDI Real In %u", m_midiInCounter++);
|
||||
std::string mname = fmt::format(fmt("Boo MIDI Real In {}"), m_midiInCounter++);
|
||||
CFPointer<CFStringRef> midiName = CFPointer<CFStringRef>::adopt(
|
||||
CFStringCreateWithCStringNoCopy(nullptr, mname, kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
CFStringCreateWithCStringNoCopy(nullptr, mname.c_str(), kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
if (MIDIInputPortCreate(m_midiClient, midiName.get(), MIDIReadProc(MIDIReceiveProc),
|
||||
static_cast<IMIDIReceiver*>(ret.get()), &static_cast<MIDIInOut&>(*ret).m_midiPortIn))
|
||||
ret.reset();
|
||||
|
@ -619,9 +612,9 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
|||
if (!ret)
|
||||
return {};
|
||||
|
||||
snprintf(mname, 256, "Boo MIDI Real Out %u", m_midiOutCounter++);
|
||||
mname = fmt::format(fmt("Boo MIDI Real Out {}"), m_midiOutCounter++);
|
||||
midiName = CFPointer<CFStringRef>::adopt(
|
||||
CFStringCreateWithCStringNoCopy(nullptr, mname, kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
CFStringCreateWithCStringNoCopy(nullptr, mname.c_str(), kCFStringEncodingUTF8, kCFAllocatorNull));
|
||||
if (MIDIOutputPortCreate(m_midiClient, midiName.get(), &static_cast<MIDIInOut&>(*ret).m_midiPortOut))
|
||||
ret.reset();
|
||||
else
|
||||
|
@ -661,13 +654,13 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
|||
OSStatus err;
|
||||
if ((err = AudioQueueNewOutput(&desc, AudioQueueOutputCallback(Callback), this, CFRunLoopGetCurrent(),
|
||||
m_runLoopMode.get(), 0, &m_queue))) {
|
||||
Log.report(logvisor::Fatal, "unable to create output audio queue");
|
||||
Log.report(logvisor::Fatal, fmt("unable to create output audio queue"));
|
||||
return;
|
||||
}
|
||||
|
||||
CFStringRef devName = m_devName.get();
|
||||
if ((err = AudioQueueSetProperty(m_queue, kAudioQueueProperty_CurrentDevice, &devName, sizeof(devName)))) {
|
||||
Log.report(logvisor::Fatal, "unable to set current device into audio queue");
|
||||
Log.report(logvisor::Fatal, fmt("unable to set current device into audio queue"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -685,7 +678,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
|||
AudioChannelLayout layout;
|
||||
UInt32 layoutSz = sizeof(layout);
|
||||
if (AudioQueueGetProperty(m_queue, kAudioQueueProperty_ChannelLayout, &layout, &layoutSz)) {
|
||||
Log.report(logvisor::Warning, "unable to get channel layout from audio queue; using count's default");
|
||||
Log.report(logvisor::Warning, fmt("unable to get channel layout from audio queue; using count's default"));
|
||||
switch (m_mixInfo.m_channels) {
|
||||
case AudioChannelSet::Stereo:
|
||||
default:
|
||||
|
@ -766,7 +759,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
|||
chMapOut.m_channels[4] = AudioChannel::FrontCenter;
|
||||
break;
|
||||
default:
|
||||
Log.report(logvisor::Warning, "unknown channel layout %u; using stereo", layout.mChannelLayoutTag);
|
||||
Log.report(logvisor::Warning, fmt("unknown channel layout %u; using stereo"), layout.mChannelLayoutTag);
|
||||
chMapOut.m_channelCount = 2;
|
||||
chMapOut.m_channels[0] = AudioChannel::FrontLeft;
|
||||
chMapOut.m_channels[1] = AudioChannel::FrontRight;
|
||||
|
@ -784,7 +777,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
|||
m_mixInfo.m_periodFrames = m_5msFrames;
|
||||
for (int i = 0; i < AQS_NUM_BUFFERS; ++i)
|
||||
if (AudioQueueAllocateBuffer(m_queue, m_mixInfo.m_periodFrames * chCount * 4, &m_buffers[i])) {
|
||||
Log.report(logvisor::Fatal, "unable to create audio queue buffer");
|
||||
Log.report(logvisor::Fatal, fmt("unable to create audio queue buffer"));
|
||||
AudioQueueDispose(m_queue, false);
|
||||
m_queue = nullptr;
|
||||
return;
|
||||
|
@ -834,7 +827,7 @@ struct AQSAudioVoiceEngine : BaseAudioVoiceEngine {
|
|||
deviceAddress.mSelector = kAudioDevicePropertyDeviceUID;
|
||||
AudioObjectGetPropertyData(defaultDeviceId, &deviceAddress, 0, NULL, &argSize, &m_devName);
|
||||
} else {
|
||||
Log.report(logvisor::Fatal, "unable determine default audio device");
|
||||
Log.report(logvisor::Fatal, fmt("unable determine default audio device"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ template int32_t* AudioSubmix::_getMergeBuf<int32_t>(size_t frames);
|
|||
template float* AudioSubmix::_getMergeBuf<float>(size_t frames);
|
||||
|
||||
template <typename T>
|
||||
static inline T ClampInt(float in) {
|
||||
constexpr T ClampInt(float in) {
|
||||
if (std::is_floating_point<T>()) {
|
||||
return in; // Allow subsequent mixing stages to work with over-saturated values
|
||||
} else {
|
||||
|
|
|
@ -27,7 +27,7 @@ void AudioVoice::_setPitchRatio(double ratio, bool slew) {
|
|||
m_sampleRatio = ratio * m_sampleRateIn / m_sampleRateOut;
|
||||
soxr_error_t err = soxr_set_io_ratio(m_src, m_sampleRatio, slew ? m_head->m_5msFrames : 0);
|
||||
if (err) {
|
||||
Log.report(logvisor::Fatal, "unable to set resampler rate: %s", soxr_strerror(err));
|
||||
Log.report(logvisor::Fatal, fmt("unable to set resampler rate: {}"), soxr_strerror(err));
|
||||
m_setPitchRatio = false;
|
||||
return;
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ void AudioVoiceMono::_resetSampleRate(double sampleRate) {
|
|||
m_src = soxr_create(sampleRate, rateOut, 1, &err, &ioSpec, &qSpec, nullptr);
|
||||
|
||||
if (err) {
|
||||
Log.report(logvisor::Fatal, "unable to create soxr resampler: %s", soxr_strerror(err));
|
||||
Log.report(logvisor::Fatal, fmt("unable to create soxr resampler: {}"), soxr_strerror(err));
|
||||
m_resetSampleRate = false;
|
||||
return;
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ void AudioVoiceStereo::_resetSampleRate(double sampleRate) {
|
|||
m_src = soxr_create(sampleRate, rateOut, 2, &err, &ioSpec, &qSpec, nullptr);
|
||||
|
||||
if (!m_src) {
|
||||
Log.report(logvisor::Fatal, "unable to create soxr resampler: %s", soxr_strerror(err));
|
||||
Log.report(logvisor::Fatal, fmt("unable to create soxr resampler: {}"), soxr_strerror(err));
|
||||
m_resetSampleRate = false;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -45,11 +45,10 @@ struct LinuxMidi : BaseAudioVoiceEngine {
|
|||
|
||||
while (card >= 0) {
|
||||
snd_ctl_t* ctl;
|
||||
char name[32];
|
||||
int device = -1;
|
||||
int status;
|
||||
sprintf(name, "hw:%d", card);
|
||||
if ((status = snd_ctl_open(&ctl, name, 0)) < 0)
|
||||
std::string name = fmt::format(fmt("hw:{}"), card);
|
||||
if ((status = snd_ctl_open(&ctl, name.c_str(), 0)) < 0)
|
||||
continue;
|
||||
|
||||
do {
|
||||
|
@ -57,7 +56,7 @@ struct LinuxMidi : BaseAudioVoiceEngine {
|
|||
if (status < 0)
|
||||
break;
|
||||
if (device >= 0) {
|
||||
sprintf(name + strlen(name), ",%d", device);
|
||||
name += fmt::format(fmt(",{}"), device);
|
||||
auto search = m_openHandles.find(name);
|
||||
if (search != m_openHandles.cend()) {
|
||||
ret.push_back(std::make_pair(name, search->second->description()));
|
||||
|
@ -65,7 +64,7 @@ struct LinuxMidi : BaseAudioVoiceEngine {
|
|||
}
|
||||
|
||||
snd_rawmidi_t* midi;
|
||||
if (!snd_rawmidi_open(&midi, nullptr, name, SND_RAWMIDI_NONBLOCK)) {
|
||||
if (!snd_rawmidi_open(&midi, nullptr, name.c_str(), SND_RAWMIDI_NONBLOCK)) {
|
||||
snd_rawmidi_info(midi, info);
|
||||
ret.push_back(std::make_pair(name, snd_rawmidi_info_get_name(info)));
|
||||
snd_rawmidi_close(midi);
|
||||
|
@ -102,7 +101,7 @@ struct LinuxMidi : BaseAudioVoiceEngine {
|
|||
int rdBytes = snd_rawmidi_read(midi, buf, 512);
|
||||
if (rdBytes < 0) {
|
||||
if (rdBytes != -EINTR) {
|
||||
ALSALog.report(logvisor::Error, "MIDI connection lost");
|
||||
ALSALog.report(logvisor::Error, fmt("MIDI connection lost"));
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
|
|
|
@ -31,7 +31,7 @@ inline T ClampFull(float in) {
|
|||
#endif
|
||||
|
||||
#if USE_LPF
|
||||
static constexpr int FirTaps = 27;
|
||||
constexpr int FirTaps = 27;
|
||||
|
||||
FIRFilter12k::FIRFilter12k(int windowFrames, double sampleRate) {
|
||||
Ipp64f* taps = ippsMalloc_64f(FirTaps);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace boo {
|
||||
|
||||
static inline uint8_t clamp7(uint8_t val) { return std::max(0, std::min(127, int(val))); }
|
||||
constexpr uint8_t clamp7(uint8_t val) { return std::max(0, std::min(127, int(val))); }
|
||||
|
||||
bool MIDIDecoder::_readContinuedValue(std::vector<uint8_t>::const_iterator& it,
|
||||
std::vector<uint8_t>::const_iterator end, uint32_t& valOut) {
|
||||
|
|
|
@ -68,7 +68,7 @@ struct PulseAudioVoiceEngine : LinuxMidi {
|
|||
pa_operation_unref(op);
|
||||
|
||||
if (m_sampleSpec.format == PA_SAMPLE_INVALID) {
|
||||
Log.report(logvisor::Error, "Unable to setup audio stream");
|
||||
Log.report(logvisor::Error, fmt("Unable to setup audio stream"));
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ struct PulseAudioVoiceEngine : LinuxMidi {
|
|||
m_mixInfo.m_bitsPerSample = 32;
|
||||
m_mixInfo.m_periodFrames = m_5msFrames;
|
||||
if (!(m_stream = pa_stream_new(m_ctx, "master", &m_sampleSpec, &m_chanMap))) {
|
||||
Log.report(logvisor::Error, "Unable to pa_stream_new(): %s", pa_strerror(pa_context_errno(m_ctx)));
|
||||
Log.report(logvisor::Error, fmt("Unable to pa_stream_new(): {}"), pa_strerror(pa_context_errno(m_ctx)));
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ struct PulseAudioVoiceEngine : LinuxMidi {
|
|||
if (pa_stream_connect_playback(m_stream, m_sinkName.c_str(), &bufAttr,
|
||||
pa_stream_flags_t(PA_STREAM_START_UNMUTED | PA_STREAM_EARLY_REQUESTS), nullptr,
|
||||
nullptr)) {
|
||||
Log.report(logvisor::Error, "Unable to pa_stream_connect_playback()");
|
||||
Log.report(logvisor::Error, fmt("Unable to pa_stream_connect_playback()"));
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@ -114,18 +114,16 @@ struct PulseAudioVoiceEngine : LinuxMidi {
|
|||
|
||||
PulseAudioVoiceEngine() {
|
||||
if (!(m_mainloop = pa_mainloop_new())) {
|
||||
Log.report(logvisor::Error, "Unable to pa_mainloop_new()");
|
||||
Log.report(logvisor::Error, fmt("Unable to pa_mainloop_new()"));
|
||||
return;
|
||||
}
|
||||
|
||||
pa_mainloop_api* mlApi = pa_mainloop_get_api(m_mainloop);
|
||||
pa_proplist* propList = pa_proplist_new();
|
||||
pa_proplist_sets(propList, PA_PROP_APPLICATION_ICON_NAME, APP->getUniqueName().data());
|
||||
char pidStr[16];
|
||||
snprintf(pidStr, 16, "%d", int(getpid()));
|
||||
pa_proplist_sets(propList, PA_PROP_APPLICATION_PROCESS_ID, pidStr);
|
||||
pa_proplist_sets(propList, PA_PROP_APPLICATION_PROCESS_ID, fmt::format(fmt("{}"), int(getpid())).c_str());
|
||||
if (!(m_ctx = pa_context_new_with_proplist(mlApi, APP->getFriendlyName().data(), propList))) {
|
||||
Log.report(logvisor::Error, "Unable to pa_context_new_with_proplist()");
|
||||
Log.report(logvisor::Error, fmt("Unable to pa_context_new_with_proplist()"));
|
||||
pa_mainloop_free(m_mainloop);
|
||||
m_mainloop = nullptr;
|
||||
return;
|
||||
|
@ -134,7 +132,7 @@ struct PulseAudioVoiceEngine : LinuxMidi {
|
|||
pa_operation* op;
|
||||
|
||||
if (pa_context_connect(m_ctx, nullptr, PA_CONTEXT_NOFLAGS, nullptr)) {
|
||||
Log.report(logvisor::Error, "Unable to pa_context_connect()");
|
||||
Log.report(logvisor::Error, fmt("Unable to pa_context_connect()"));
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
@ -341,17 +339,16 @@ struct PulseAudioVoiceEngine : LinuxMidi {
|
|||
size_t nbytes = writablePeriods * periodSz;
|
||||
if (pa_stream_begin_write(m_stream, &data, &nbytes)) {
|
||||
pa_stream_state_t st = pa_stream_get_state(m_stream);
|
||||
Log.report(logvisor::Error, "Unable to pa_stream_begin_write(): %s %d", pa_strerror(pa_context_errno(m_ctx)), st);
|
||||
Log.report(logvisor::Error, fmt("Unable to pa_stream_begin_write(): {} {}"), pa_strerror(pa_context_errno(m_ctx)), st);
|
||||
_doIterate();
|
||||
return;
|
||||
}
|
||||
|
||||
writablePeriods = nbytes / periodSz;
|
||||
size_t periodSamples = m_mixInfo.m_periodFrames * m_mixInfo.m_channelMap.m_channelCount;
|
||||
_pumpAndMixVoices(m_mixInfo.m_periodFrames * writablePeriods, reinterpret_cast<float*>(data));
|
||||
|
||||
if (pa_stream_write(m_stream, data, nbytes, nullptr, 0, PA_SEEK_RELATIVE))
|
||||
Log.report(logvisor::Error, "Unable to pa_stream_write()");
|
||||
Log.report(logvisor::Error, fmt("Unable to pa_stream_write()"));
|
||||
|
||||
_doIterate();
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine {
|
|||
#if !WINDOWS_STORE
|
||||
if (!m_device) {
|
||||
if (FAILED(m_enumerator->GetDevice(MBSTWCS(m_sinkName.c_str()).c_str(), &m_device))) {
|
||||
Log.report(logvisor::Error, "unable to obtain audio device %s", m_sinkName.c_str());
|
||||
Log.report(logvisor::Error, fmt("unable to obtain audio device %s"), m_sinkName.c_str());
|
||||
m_device.Reset();
|
||||
return;
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine {
|
|||
chMapOut.m_channels[7] = AudioChannel::SideRight;
|
||||
break;
|
||||
default:
|
||||
Log.report(logvisor::Warning, "unknown channel layout %u; using stereo", pwfx->Format.nChannels);
|
||||
Log.report(logvisor::Warning, fmt("unknown channel layout %u; using stereo"), pwfx->Format.nChannels);
|
||||
chMapOut.m_channelCount = 2;
|
||||
chMapOut.m_channels[0] = AudioChannel::FrontLeft;
|
||||
chMapOut.m_channels[1] = AudioChannel::FrontRight;
|
||||
|
@ -468,7 +468,7 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine {
|
|||
bool setCurrentAudioOutput(const char* name) {
|
||||
ComPtr<IMMDevice> newDevice;
|
||||
if (FAILED(m_enumerator->GetDevice(MBSTWCS(name).c_str(), &newDevice))) {
|
||||
Log.report(logvisor::Error, "unable to obtain audio device %s", name);
|
||||
Log.report(logvisor::Error, fmt("unable to obtain audio device %s"), name);
|
||||
return false;
|
||||
}
|
||||
m_device = newDevice;
|
||||
|
@ -514,34 +514,32 @@ struct WASAPIAudioVoiceEngine : BaseAudioVoiceEngine {
|
|||
ret.reserve(numInDevices);
|
||||
|
||||
for (UINT i = 0; i < numInDevices; ++i) {
|
||||
char name[256];
|
||||
snprintf(name, 256, "in%u", i);
|
||||
std::string name = fmt::format(fmt("in{}"), i);
|
||||
|
||||
MIDIINCAPS caps;
|
||||
if (FAILED(midiInGetDevCaps(i, &caps, sizeof(caps))))
|
||||
continue;
|
||||
|
||||
#ifdef UNICODE
|
||||
ret.push_back(std::make_pair(std::string(name), WCSTMBS(caps.szPname)));
|
||||
ret.push_back(std::make_pair(std::move(name), WCSTMBS(caps.szPname)));
|
||||
#else
|
||||
ret.push_back(std::make_pair(std::string(name), std::string(caps.szPname)));
|
||||
ret.push_back(std::make_pair(std::move(name), std::string(caps.szPname)));
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
for (UINT i=0 ; i<numOutDevices ; ++i)
|
||||
{
|
||||
char name[256];
|
||||
snprintf(name, 256, "out%u", i);
|
||||
std::string name = fmt::format(fmt("out{}"), i);
|
||||
|
||||
MIDIOUTCAPS caps;
|
||||
if (FAILED(midiOutGetDevCaps(i, &caps, sizeof(caps))))
|
||||
continue;
|
||||
|
||||
#ifdef UNICODE
|
||||
ret.push_back(std::make_pair(std::string(name), WCSTMBS(caps.szPname)));
|
||||
ret.push_back(std::make_pair(std::move(name), WCSTMBS(caps.szPname)));
|
||||
#else
|
||||
ret.push_back(std::make_pair(std::string(name), std::string(caps.szPname)));
|
||||
ret.push_back(std::make_pair(std::move(name), std::string(caps.szPname)));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -184,7 +184,7 @@ class D3D11TextureS : public GraphicsDataNode<ITextureS> {
|
|||
pxTilePitch = 4;
|
||||
break;
|
||||
default:
|
||||
Log.report(logvisor::Fatal, "unsupported tex format");
|
||||
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
|
||||
}
|
||||
|
||||
CD3D11_TEXTURE2D_DESC desc(pfmt, width, height, 1, mips, D3D11_BIND_SHADER_RESOURCE, D3D11_USAGE_IMMUTABLE);
|
||||
|
@ -237,7 +237,7 @@ class D3D11TextureSA : public GraphicsDataNode<ITextureSA> {
|
|||
pixelFmt = DXGI_FORMAT_R16_UNORM;
|
||||
break;
|
||||
default:
|
||||
Log.report(logvisor::Fatal, "unsupported tex format");
|
||||
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
|
||||
}
|
||||
|
||||
CD3D11_TEXTURE2D_DESC desc(pixelFmt, width, height, layers, mips, D3D11_BIND_SHADER_RESOURCE,
|
||||
|
@ -299,7 +299,7 @@ class D3D11TextureD : public GraphicsDataNode<ITextureD> {
|
|||
m_pxPitch = 2;
|
||||
break;
|
||||
default:
|
||||
Log.report(logvisor::Fatal, "unsupported tex format");
|
||||
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
|
||||
}
|
||||
|
||||
m_cpuSz = width * height * m_pxPitch;
|
||||
|
@ -388,9 +388,9 @@ class D3D11TextureR : public GraphicsDataNode<ITextureR> {
|
|||
, m_colorBindCount(colorBindCount)
|
||||
, m_depthBindCount(depthBindCount) {
|
||||
if (colorBindCount > MAX_BIND_TEXS)
|
||||
Log.report(logvisor::Fatal, "too many color bindings for render texture");
|
||||
Log.report(logvisor::Fatal, fmt("too many color bindings for render texture"));
|
||||
if (depthBindCount > MAX_BIND_TEXS)
|
||||
Log.report(logvisor::Fatal, "too many depth bindings for render texture");
|
||||
Log.report(logvisor::Fatal, fmt("too many depth bindings for render texture"));
|
||||
|
||||
if (samples == 0)
|
||||
m_samples = 1;
|
||||
|
@ -776,7 +776,7 @@ struct D3D11ShaderDataBinding : public GraphicsDataNode<IShaderDataBinding> {
|
|||
for (size_t i = 0; i < ubufCount; ++i) {
|
||||
#ifndef NDEBUG
|
||||
if (ubufOffs[i] % 256)
|
||||
Log.report(logvisor::Fatal, "non-256-byte-aligned uniform-offset %d provided to newShaderDataBinding",
|
||||
Log.report(logvisor::Fatal, fmt("non-256-byte-aligned uniform-offset %d provided to newShaderDataBinding"),
|
||||
int(i));
|
||||
#endif
|
||||
m_ubufFirstConsts[i] = ubufOffs[i] / 16;
|
||||
|
@ -786,7 +786,7 @@ struct D3D11ShaderDataBinding : public GraphicsDataNode<IShaderDataBinding> {
|
|||
for (size_t i = 0; i < ubufCount; ++i) {
|
||||
#ifndef NDEBUG
|
||||
if (!ubufs[i])
|
||||
Log.report(logvisor::Fatal, "null uniform-buffer %d provided to newShaderDataBinding", int(i));
|
||||
Log.report(logvisor::Fatal, fmt("null uniform-buffer %d provided to newShaderDataBinding"), int(i));
|
||||
#endif
|
||||
m_ubufs.push_back(ubufs[i]);
|
||||
}
|
||||
|
@ -1507,7 +1507,7 @@ void D3D11CommandQueue::RenderingWorker(D3D11CommandQueue* self) {
|
|||
if (D3D11TextureR* csource = CmdList.workDoPresent.cast<D3D11TextureR>()) {
|
||||
#ifndef NDEBUG
|
||||
if (!csource->m_colorBindCount)
|
||||
Log.report(logvisor::Fatal, "texture provided to resolveDisplay() must have at least 1 color binding");
|
||||
Log.report(logvisor::Fatal, fmt("texture provided to resolveDisplay() must have at least 1 color binding"));
|
||||
#endif
|
||||
|
||||
if (dataFactory->m_gamma != 1.f) {
|
||||
|
@ -1621,8 +1621,8 @@ std::vector<uint8_t> D3D11DataFactory::CompileHLSL(const char* source, PipelineS
|
|||
ComPtr<ID3DBlob> blobOut;
|
||||
if (FAILED(D3DCompilePROC(source, strlen(source), "Boo HLSL Source", nullptr, nullptr, "main",
|
||||
D3DShaderTypes[int(stage)], BOO_D3DCOMPILE_FLAG, 0, &blobOut, &errBlob))) {
|
||||
printf("%s\n", source);
|
||||
Log.report(logvisor::Fatal, "error compiling shader: %s", errBlob->GetBufferPointer());
|
||||
fmt::print(fmt("{}\n"), source);
|
||||
Log.report(logvisor::Fatal, fmt("error compiling shader: %s"), errBlob->GetBufferPointer());
|
||||
return {};
|
||||
}
|
||||
std::vector<uint8_t> ret(blobOut->GetBufferSize());
|
||||
|
|
|
@ -76,7 +76,7 @@ class GLDataFactoryImpl : public GLDataFactory, public GraphicsDataFactoryHead {
|
|||
void SetupGammaResources() {
|
||||
/* Good enough place for this */
|
||||
if (!glslang::InitializeProcess())
|
||||
Log.report(logvisor::Error, "unable to initialize glslang");
|
||||
Log.report(logvisor::Error, fmt("unable to initialize glslang"));
|
||||
|
||||
if (GLEW_ARB_tessellation_shader) {
|
||||
m_hasTessellation = true;
|
||||
|
@ -320,7 +320,7 @@ class GLTextureS : public GraphicsDataNode<ITextureS> {
|
|||
pxPitch = 1;
|
||||
break;
|
||||
default:
|
||||
Log.report(logvisor::Fatal, "unsupported tex format");
|
||||
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
|
||||
}
|
||||
|
||||
if (compressed) {
|
||||
|
@ -404,7 +404,7 @@ class GLTextureSA : public GraphicsDataNode<ITextureSA> {
|
|||
pxPitch = 2;
|
||||
break;
|
||||
default:
|
||||
Log.report(logvisor::Fatal, "unsupported tex format");
|
||||
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
|
||||
}
|
||||
|
||||
GLenum compType = intFormat == GL_R16 ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE;
|
||||
|
@ -467,7 +467,7 @@ class GLTextureD : public GraphicsDataNode<ITextureD> {
|
|||
pxPitch = 2;
|
||||
break;
|
||||
default:
|
||||
Log.report(logvisor::Fatal, "unsupported tex format");
|
||||
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
|
||||
}
|
||||
m_cpuSz = width * height * pxPitch;
|
||||
m_cpuBuf.reset(new uint8_t[m_cpuSz]);
|
||||
|
@ -710,15 +710,15 @@ class GLShaderStage : public GraphicsDataNode<IShaderStage> {
|
|||
glslang::TShader shader(lang);
|
||||
shader.setStrings(&source, 1);
|
||||
if (!shader.parse(&glslang::DefaultTBuiltInResource, 110, false, messages)) {
|
||||
printf("%s\n", source);
|
||||
Log.report(logvisor::Fatal, "unable to compile shader\n%s", shader.getInfoLog());
|
||||
fmt::print(fmt("{}\n"), source);
|
||||
Log.report(logvisor::Fatal, fmt("unable to compile shader\n{}"), shader.getInfoLog());
|
||||
}
|
||||
|
||||
glslang::TProgram prog;
|
||||
prog.addShader(&shader);
|
||||
if (!prog.link(messages)) {
|
||||
printf("%s\n", source);
|
||||
Log.report(logvisor::Fatal, "unable to link shader program\n%s", prog.getInfoLog());
|
||||
fmt::print(fmt("{}\n"), source);
|
||||
Log.report(logvisor::Fatal, fmt("unable to link shader program\n{}"), prog.getInfoLog());
|
||||
}
|
||||
|
||||
prog.buildReflection();
|
||||
|
@ -729,7 +729,7 @@ class GLShaderStage : public GraphicsDataNode<IShaderStage> {
|
|||
continue;
|
||||
const auto& qual = tp->getQualifier();
|
||||
if (!qual.hasBinding())
|
||||
Log.report(logvisor::Fatal, "shader uniform %s does not have layout binding", prog.getUniformName(i));
|
||||
Log.report(logvisor::Fatal, fmt("shader uniform {} does not have layout binding"), prog.getUniformName(i));
|
||||
m_texNames.emplace_back(std::make_pair(prog.getUniformName(i), qual.layoutBinding - BOO_GLSL_MAX_UNIFORM_COUNT));
|
||||
}
|
||||
count = prog.getNumLiveUniformBlocks();
|
||||
|
@ -738,7 +738,7 @@ class GLShaderStage : public GraphicsDataNode<IShaderStage> {
|
|||
const glslang::TType* tp = prog.getUniformBlockTType(i);
|
||||
const auto& qual = tp->getQualifier();
|
||||
if (!qual.hasBinding())
|
||||
Log.report(logvisor::Fatal, "shader uniform %s does not have layout binding", prog.getUniformBlockName(i));
|
||||
Log.report(logvisor::Fatal, fmt("shader uniform {} does not have layout binding"), prog.getUniformBlockName(i));
|
||||
m_blockNames.emplace_back(std::make_pair(prog.getUniformBlockName(i), qual.layoutBinding));
|
||||
}
|
||||
}
|
||||
|
@ -749,7 +749,7 @@ class GLShaderStage : public GraphicsDataNode<IShaderStage> {
|
|||
|
||||
m_shad = glCreateShader(SHADER_STAGE_TABLE[int(stage)]);
|
||||
if (!m_shad) {
|
||||
Log.report(logvisor::Fatal, "unable to create shader");
|
||||
Log.report(logvisor::Fatal, fmt("unable to create shader"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -762,7 +762,7 @@ class GLShaderStage : public GraphicsDataNode<IShaderStage> {
|
|||
glGetShaderiv(m_shad, GL_INFO_LOG_LENGTH, &logLen);
|
||||
std::unique_ptr<char[]> log(new char[logLen]);
|
||||
glGetShaderInfoLog(m_shad, logLen, nullptr, log.get());
|
||||
Log.report(logvisor::Fatal, "unable to compile source\n%s\n%s\n", log.get(), source);
|
||||
Log.report(logvisor::Fatal, fmt("unable to compile source\n{}\n{}\n"), log.get(), source);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -853,7 +853,7 @@ public:
|
|||
if (!m_prog) {
|
||||
m_prog = glCreateProgram();
|
||||
if (!m_prog) {
|
||||
Log.report(logvisor::Error, "unable to create shader program");
|
||||
Log.report(logvisor::Error, fmt("unable to create shader program"));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -888,7 +888,7 @@ public:
|
|||
glGetProgramiv(m_prog, GL_INFO_LOG_LENGTH, &logLen);
|
||||
std::unique_ptr<char[]> log(new char[logLen]);
|
||||
glGetProgramInfoLog(m_prog, logLen, nullptr, log.get());
|
||||
Log.report(logvisor::Fatal, "unable to link shader program\n%s\n", log.get());
|
||||
Log.report(logvisor::Fatal, fmt("unable to link shader program\n{}\n"), log.get());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -899,12 +899,12 @@ public:
|
|||
for (const auto& name : stage->getBlockNames()) {
|
||||
GLint uniLoc = glGetUniformBlockIndex(m_prog, name.first.c_str());
|
||||
// if (uniLoc < 0)
|
||||
// Log.report(logvisor::Warning, "unable to find uniform block '%s'", uniformBlockNames[i]);
|
||||
// Log.report(logvisor::Warning, fmt("unable to find uniform block '%s'"), uniformBlockNames[i]);
|
||||
m_uniLocs[name.second] = uniLoc;
|
||||
}
|
||||
for (const auto& name : stage->getTexNames()) {
|
||||
GLint texLoc = glGetUniformLocation(m_prog, name.first.c_str());
|
||||
if (texLoc < 0) { /* Log.report(logvisor::Warning, "unable to find sampler variable '%s'", texNames[i]); */
|
||||
if (texLoc < 0) { /* Log.report(logvisor::Warning, fmt("unable to find sampler variable '%s'"), texNames[i]); */
|
||||
} else
|
||||
glUniform1i(texLoc, name.second);
|
||||
}
|
||||
|
@ -975,7 +975,7 @@ ObjToken<IShaderStage> GLDataFactory::Context::newShaderStage(const uint8_t* dat
|
|||
|
||||
if (stage == PipelineStage::Control || stage == PipelineStage::Evaluation) {
|
||||
if (!factory.m_hasTessellation)
|
||||
Log.report(logvisor::Fatal, "Device does not support tessellation shaders");
|
||||
Log.report(logvisor::Fatal, fmt("Device does not support tessellation shaders"));
|
||||
}
|
||||
|
||||
BOO_MSAN_NO_INTERCEPT
|
||||
|
@ -990,9 +990,9 @@ ObjToken<IShaderPipeline> GLDataFactory::Context::newShaderPipeline(
|
|||
|
||||
if (control || evaluation) {
|
||||
if (!factory.m_hasTessellation)
|
||||
Log.report(logvisor::Fatal, "Device does not support tessellation shaders");
|
||||
Log.report(logvisor::Fatal, fmt("Device does not support tessellation shaders"));
|
||||
if (additionalInfo.patchSize > factory.m_maxPatchSize)
|
||||
Log.report(logvisor::Fatal, "Device supports %d patch vertices, %d requested", int(factory.m_maxPatchSize),
|
||||
Log.report(logvisor::Fatal, fmt("Device supports {} patch vertices, {} requested"), int(factory.m_maxPatchSize),
|
||||
int(additionalInfo.patchSize));
|
||||
}
|
||||
|
||||
|
@ -1301,7 +1301,7 @@ struct GLCommandQueue : IGraphicsCommandQueue {
|
|||
std::unique_lock<std::mutex> lk(self->m_initmt);
|
||||
self->m_parent->makeCurrent();
|
||||
const GLubyte* version = glGetString(GL_VERSION);
|
||||
Log.report(logvisor::Info, "OpenGL Version: %s", version);
|
||||
Log.report(logvisor::Info, fmt("OpenGL Version: {}"), version);
|
||||
self->m_parent->postInit();
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
if (GLEW_EXT_texture_filter_anisotropic) {
|
||||
|
@ -1493,7 +1493,7 @@ struct GLCommandQueue : IGraphicsCommandQueue {
|
|||
if (const GLTextureR* tex = cmd.source.cast<GLTextureR>()) {
|
||||
#ifndef NDEBUG
|
||||
if (!tex->m_colorBindCount)
|
||||
Log.report(logvisor::Fatal, "texture provided to resolveDisplay() must have at least 1 color binding");
|
||||
Log.report(logvisor::Fatal, fmt("texture provided to resolveDisplay() must have at least 1 color binding"));
|
||||
#endif
|
||||
if (dataFactory->m_gamma != 1.f) {
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, tex->m_fbo);
|
||||
|
@ -1799,12 +1799,12 @@ GLTextureR::GLTextureR(const ObjToken<BaseGraphicsData>& parent, GLCommandQueue*
|
|||
glGenTextures(2, m_texs);
|
||||
if (colorBindingCount) {
|
||||
if (colorBindingCount > MAX_BIND_TEXS)
|
||||
Log.report(logvisor::Fatal, "too many color bindings for render texture");
|
||||
Log.report(logvisor::Fatal, fmt("too many color bindings for render texture"));
|
||||
glGenTextures(colorBindingCount, m_bindTexs[0]);
|
||||
}
|
||||
if (depthBindingCount) {
|
||||
if (depthBindingCount > MAX_BIND_TEXS)
|
||||
Log.report(logvisor::Fatal, "too many depth bindings for render texture");
|
||||
Log.report(logvisor::Fatal, fmt("too many depth bindings for render texture"));
|
||||
glGenTextures(depthBindingCount, m_bindTexs[1]);
|
||||
}
|
||||
|
||||
|
@ -1918,8 +1918,7 @@ GLShaderDataBinding(const ObjToken<BaseGraphicsData>& d, const ObjToken<IShaderP
|
|||
for (size_t i = 0; i < ubufCount; ++i) {
|
||||
#ifndef NDEBUG
|
||||
if (ubufOffs[i] % 256)
|
||||
Log.report(logvisor::Fatal, "non-256-byte-aligned uniform-offset %d provided to newShaderDataBinding",
|
||||
int(i));
|
||||
Log.report(logvisor::Fatal, fmt("non-256-byte-aligned uniform-offset {} provided to newShaderDataBinding"), int(i));
|
||||
#endif
|
||||
m_ubufOffs.emplace_back(ubufOffs[i], (ubufSizes[i] + 255) & ~255);
|
||||
}
|
||||
|
@ -1928,7 +1927,7 @@ GLShaderDataBinding(const ObjToken<BaseGraphicsData>& d, const ObjToken<IShaderP
|
|||
for (size_t i = 0; i < ubufCount; ++i) {
|
||||
#ifndef NDEBUG
|
||||
if (!ubufs[i])
|
||||
Log.report(logvisor::Fatal, "null uniform-buffer %d provided to newShaderDataBinding", int(i));
|
||||
Log.report(logvisor::Fatal, fmt("null uniform-buffer {} provided to newShaderDataBinding"), int(i));
|
||||
#endif
|
||||
m_ubufs.push_back(ubufs[i]);
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@ static logvisor::Module Log("boo::GLX");
|
|||
|
||||
void GLXExtensionCheck() {
|
||||
if (!GLXEW_SGI_video_sync)
|
||||
Log.report(logvisor::Fatal, "GLX_SGI_video_sync not available");
|
||||
Log.report(logvisor::Fatal, fmt("GLX_SGI_video_sync not available"));
|
||||
if (!GLXEW_EXT_swap_control && !GLXEW_MESA_swap_control && !GLXEW_SGI_swap_control)
|
||||
Log.report(logvisor::Fatal, "swap_control not available");
|
||||
Log.report(logvisor::Fatal, fmt("swap_control not available"));
|
||||
}
|
||||
|
||||
void GLXEnableVSync(Display* disp, GLXWindow drawable) {
|
||||
|
|
|
@ -386,7 +386,7 @@ class MetalTextureD : public GraphicsDataNode<ITextureD> {
|
|||
m_pxPitch = 2;
|
||||
break;
|
||||
default:
|
||||
Log.report(logvisor::Fatal, "unsupported tex format");
|
||||
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -450,9 +450,9 @@ class MetalTextureR : public GraphicsDataNode<ITextureR> {
|
|||
|
||||
void Setup(MetalContext* ctx) {
|
||||
if (m_colorBindCount > MAX_BIND_TEXS)
|
||||
Log.report(logvisor::Fatal, "too many color bindings for render texture");
|
||||
Log.report(logvisor::Fatal, fmt("too many color bindings for render texture"));
|
||||
if (m_depthBindCount > MAX_BIND_TEXS)
|
||||
Log.report(logvisor::Fatal, "too many depth bindings for render texture");
|
||||
Log.report(logvisor::Fatal, fmt("too many depth bindings for render texture"));
|
||||
|
||||
@autoreleasepool {
|
||||
MTLTextureDescriptor* desc =
|
||||
|
@ -903,10 +903,10 @@ class MetalShaderStage : public GraphicsDataNode<IShaderStage> {
|
|||
options:compOpts
|
||||
error:&err];
|
||||
if (!shaderLib)
|
||||
printf("%s\n", data + 1);
|
||||
fmt::print(fmt("{}\n"), data + 1);
|
||||
}
|
||||
if (!shaderLib)
|
||||
Log.report(logvisor::Fatal, "error creating library: %s", [[err localizedDescription] UTF8String]);
|
||||
Log.report(logvisor::Fatal, fmt("error creating library: %s"), [[err localizedDescription] UTF8String]);
|
||||
|
||||
NSString* funcName;
|
||||
switch (stage) {
|
||||
|
@ -1024,7 +1024,7 @@ protected:
|
|||
NSError* err = nullptr;
|
||||
m_state = [ctx->m_dev newRenderPipelineStateWithDescriptor:desc error:&err];
|
||||
if (err)
|
||||
Log.report(logvisor::Fatal, "error making shader pipeline: %s",
|
||||
Log.report(logvisor::Fatal, fmt("error making shader pipeline: %s"),
|
||||
[[err localizedDescription] UTF8String]);
|
||||
|
||||
MTLDepthStencilDescriptor* dsDesc = [MTLDepthStencilDescriptor new];
|
||||
|
@ -1098,7 +1098,7 @@ class MetalTessellationShaderPipeline : public MetalShaderPipeline {
|
|||
m_computeState = [ctx->m_dev newComputePipelineStateWithDescriptor:compDesc options:MTLPipelineOptionNone
|
||||
reflection:nil error:&err];
|
||||
if (err)
|
||||
Log.report(logvisor::Fatal, "error making compute pipeline: %s",
|
||||
Log.report(logvisor::Fatal, fmt("error making compute pipeline: %s"),
|
||||
[[err localizedDescription] UTF8String]);
|
||||
}
|
||||
|
||||
|
@ -1202,7 +1202,7 @@ struct MetalShaderDataBinding : GraphicsDataNode<IShaderDataBinding> {
|
|||
for (size_t i = 0; i < ubufCount; ++i) {
|
||||
#ifndef NDEBUG
|
||||
if (ubufOffs[i] % 256)
|
||||
Log.report(logvisor::Fatal, "non-256-byte-aligned uniform-offset %d provided to newShaderDataBinding",
|
||||
Log.report(logvisor::Fatal, fmt("non-256-byte-aligned uniform-offset %d provided to newShaderDataBinding"),
|
||||
int(i));
|
||||
#endif
|
||||
m_ubufOffs.push_back(ubufOffs[i]);
|
||||
|
@ -1212,7 +1212,7 @@ struct MetalShaderDataBinding : GraphicsDataNode<IShaderDataBinding> {
|
|||
for (size_t i = 0; i < ubufCount; ++i) {
|
||||
#ifndef NDEBUG
|
||||
if (!ubufs[i])
|
||||
Log.report(logvisor::Fatal, "null uniform-buffer %d provided to newShaderDataBinding", int(i));
|
||||
Log.report(logvisor::Fatal, fmt("null uniform-buffer %d provided to newShaderDataBinding"), int(i));
|
||||
#endif
|
||||
m_ubufs.push_back(ubufs[i]);
|
||||
}
|
||||
|
@ -2078,7 +2078,7 @@ void MetalDataFactoryImpl::SetupGammaResources() {
|
|||
NSError* err = nullptr;
|
||||
m_cubeFlipShader = [m_ctx->m_dev newRenderPipelineStateWithDescriptor:desc error:&err];
|
||||
if (err)
|
||||
Log.report(logvisor::Fatal, "error making shader pipeline: %s",
|
||||
Log.report(logvisor::Fatal, fmt("error making shader pipeline: %s"),
|
||||
[[err localizedDescription] UTF8String]);
|
||||
}
|
||||
|
||||
|
|
|
@ -153,24 +153,24 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
static inline void ThrowIfFailed(VkResult res) {
|
||||
static void ThrowIfFailed(VkResult res) {
|
||||
if (res != VK_SUCCESS)
|
||||
Log.report(logvisor::Fatal, "%d\n", res);
|
||||
Log.report(logvisor::Fatal, fmt("{}\n"), res);
|
||||
}
|
||||
|
||||
static VKAPI_ATTR VkBool32 VKAPI_CALL dbgFunc(VkDebugReportFlagsEXT msgFlags, VkDebugReportObjectTypeEXT objType,
|
||||
uint64_t srcObject, size_t location, int32_t msgCode,
|
||||
const char* pLayerPrefix, const char* pMsg, void* pUserData) {
|
||||
if (msgFlags & VK_DEBUG_REPORT_ERROR_BIT_EXT) {
|
||||
Log.report(logvisor::Error, "[%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
|
||||
Log.report(logvisor::Error, fmt("[{}] Code {} : {}"), pLayerPrefix, msgCode, pMsg);
|
||||
} else if (msgFlags & VK_DEBUG_REPORT_WARNING_BIT_EXT) {
|
||||
Log.report(logvisor::Warning, "[%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
|
||||
Log.report(logvisor::Warning, fmt("[{}] Code {} : {}"), pLayerPrefix, msgCode, pMsg);
|
||||
} else if (msgFlags & VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT) {
|
||||
Log.report(logvisor::Warning, "[%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
|
||||
Log.report(logvisor::Warning, fmt("[{}] Code {} : {}"), pLayerPrefix, msgCode, pMsg);
|
||||
} else if (msgFlags & VK_DEBUG_REPORT_INFORMATION_BIT_EXT) {
|
||||
Log.report(logvisor::Info, "[%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
|
||||
Log.report(logvisor::Info, fmt("[{}] Code {} : {}"), pLayerPrefix, msgCode, pMsg);
|
||||
} else if (msgFlags & VK_DEBUG_REPORT_DEBUG_BIT_EXT) {
|
||||
Log.report(logvisor::Info, "[%s] Code %d : %s", pLayerPrefix, msgCode, pMsg);
|
||||
Log.report(logvisor::Info, fmt("[{}] Code {} : {}"), pLayerPrefix, msgCode, pMsg);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -305,7 +305,7 @@ static void demo_check_layers(const std::vector<VulkanContext::LayerProperties>&
|
|||
}
|
||||
}
|
||||
if (!found) {
|
||||
Log.report(logvisor::Fatal, "Cannot find layer: %s", layerNames[i]);
|
||||
Log.report(logvisor::Fatal, fmt("Cannot find layer: {}"), layerNames[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ bool VulkanContext::initVulkan(std::string_view appName, PFN_vkGetInstanceProcAd
|
|||
vk::init_dispatch_table_top(getVkProc);
|
||||
|
||||
if (!glslang::InitializeProcess()) {
|
||||
Log.report(logvisor::Error, "unable to initialize glslang");
|
||||
Log.report(logvisor::Error, fmt("unable to initialize glslang"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -418,8 +418,8 @@ bool VulkanContext::initVulkan(std::string_view appName, PFN_vkGetInstanceProcAd
|
|||
VkResult instRes = vk::CreateInstance(&instInfo, nullptr, &m_instance);
|
||||
if (instRes != VK_SUCCESS) {
|
||||
Log.report(logvisor::Error,
|
||||
"The Vulkan runtime is installed, but there are no supported "
|
||||
"hardware vendor interfaces present");
|
||||
fmt("The Vulkan runtime is installed, but there are no supported "
|
||||
"hardware vendor interfaces present"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -427,12 +427,12 @@ bool VulkanContext::initVulkan(std::string_view appName, PFN_vkGetInstanceProcAd
|
|||
PFN_vkCreateDebugReportCallbackEXT createDebugReportCallback =
|
||||
(PFN_vkCreateDebugReportCallbackEXT)vk::GetInstanceProcAddr(m_instance, "vkCreateDebugReportCallbackEXT");
|
||||
if (!createDebugReportCallback)
|
||||
Log.report(logvisor::Fatal, "GetInstanceProcAddr: Unable to find vkCreateDebugReportCallbackEXT function.");
|
||||
Log.report(logvisor::Fatal, fmt("GetInstanceProcAddr: Unable to find vkCreateDebugReportCallbackEXT function."));
|
||||
|
||||
m_destroyDebugReportCallback =
|
||||
(PFN_vkDestroyDebugReportCallbackEXT)vk::GetInstanceProcAddr(m_instance, "vkDestroyDebugReportCallbackEXT");
|
||||
if (!m_destroyDebugReportCallback)
|
||||
Log.report(logvisor::Fatal, "GetInstanceProcAddr: Unable to find vkDestroyDebugReportCallbackEXT function.");
|
||||
Log.report(logvisor::Fatal, fmt("GetInstanceProcAddr: Unable to find vkDestroyDebugReportCallbackEXT function."));
|
||||
|
||||
VkDebugReportCallbackCreateInfoEXT debugCreateInfo = {};
|
||||
debugCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CREATE_INFO_EXT;
|
||||
|
@ -477,7 +477,7 @@ bool VulkanContext::enumerateDevices() {
|
|||
|
||||
void VulkanContext::initDevice() {
|
||||
if (m_graphicsQueueFamilyIndex == UINT32_MAX)
|
||||
Log.report(logvisor::Fatal, "VulkanContext::m_graphicsQueueFamilyIndex hasn't been initialized");
|
||||
Log.report(logvisor::Fatal, fmt("VulkanContext::m_graphicsQueueFamilyIndex hasn't been initialized"));
|
||||
|
||||
/* create the device and queues */
|
||||
VkDeviceQueueCreateInfo queueInfo = {};
|
||||
|
@ -493,7 +493,7 @@ void VulkanContext::initDevice() {
|
|||
if (m_features.samplerAnisotropy)
|
||||
features.samplerAnisotropy = VK_TRUE;
|
||||
if (!m_features.textureCompressionBC)
|
||||
Log.report(logvisor::Fatal, "Vulkan device does not support DXT-format textures");
|
||||
Log.report(logvisor::Fatal, fmt("Vulkan device does not support DXT-format textures"));
|
||||
features.textureCompressionBC = VK_TRUE;
|
||||
VkShaderStageFlagBits tessellationDescriptorBit = VkShaderStageFlagBits(0);
|
||||
if (m_features.tessellationShader) {
|
||||
|
@ -501,7 +501,7 @@ void VulkanContext::initDevice() {
|
|||
features.tessellationShader = VK_TRUE;
|
||||
}
|
||||
if (!m_features.dualSrcBlend)
|
||||
Log.report(logvisor::Fatal, "Vulkan device does not support dual-source blending");
|
||||
Log.report(logvisor::Fatal, fmt("Vulkan device does not support dual-source blending"));
|
||||
features.dualSrcBlend = VK_TRUE;
|
||||
|
||||
uint32_t extCount = 0;
|
||||
|
@ -635,10 +635,10 @@ void VulkanContext::initDevice() {
|
|||
ThrowIfFailed(vk::CreatePipelineLayout(m_dev, &pipelineLayout, nullptr, &m_pipelinelayout));
|
||||
|
||||
std::string gpuName = m_gpuProps.deviceName;
|
||||
Log.report(logvisor::Info, "Initialized %s", gpuName.c_str());
|
||||
Log.report(logvisor::Info, "Vulkan version %d.%d.%d", m_gpuProps.apiVersion >> 22,
|
||||
Log.report(logvisor::Info, fmt("Initialized {}"), gpuName);
|
||||
Log.report(logvisor::Info, fmt("Vulkan version {}.{}.{}"), m_gpuProps.apiVersion >> 22,
|
||||
(m_gpuProps.apiVersion >> 12) & 0b1111111111, m_gpuProps.apiVersion & 0b111111111111);
|
||||
Log.report(logvisor::Info, "Driver version %d.%d.%d", m_gpuProps.driverVersion >> 22,
|
||||
Log.report(logvisor::Info, fmt("Driver version {}.{}.{}"), m_gpuProps.driverVersion >> 22,
|
||||
(m_gpuProps.driverVersion >> 12) & 0b1111111111, m_gpuProps.driverVersion & 0b111111111111);
|
||||
}
|
||||
|
||||
|
@ -1368,7 +1368,7 @@ class VulkanTextureS : public GraphicsDataNode<ITextureS> {
|
|||
m_pixelPitchDenom = 1;
|
||||
break;
|
||||
default:
|
||||
Log.report(logvisor::Fatal, "unsupported tex format");
|
||||
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
|
||||
}
|
||||
m_vkFmt = pfmt;
|
||||
|
||||
|
@ -1527,7 +1527,7 @@ class VulkanTextureSA : public GraphicsDataNode<ITextureSA> {
|
|||
m_pixelPitchNum = 2;
|
||||
break;
|
||||
default:
|
||||
Log.report(logvisor::Fatal, "unsupported tex format");
|
||||
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
|
||||
}
|
||||
m_vkFmt = pfmt;
|
||||
|
||||
|
@ -1681,7 +1681,7 @@ class VulkanTextureD : public GraphicsDataNode<ITextureD> {
|
|||
m_cpuSz = width * height * 2;
|
||||
break;
|
||||
default:
|
||||
Log.report(logvisor::Fatal, "unsupported tex format");
|
||||
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
|
||||
}
|
||||
m_vkFmt = pfmt;
|
||||
m_stagingBuf.reset(new uint8_t[m_cpuSz]);
|
||||
|
@ -2660,7 +2660,7 @@ struct VulkanShaderDataBinding : GraphicsDataNode<IShaderDataBinding> {
|
|||
for (size_t i = 0; i < ubufCount; ++i) {
|
||||
#ifndef NDEBUG
|
||||
if (ubufOffs[i] % 256)
|
||||
Log.report(logvisor::Fatal, "non-256-byte-aligned uniform-offset %d provided to newShaderDataBinding",
|
||||
Log.report(logvisor::Fatal, fmt("non-256-byte-aligned uniform-offset {} provided to newShaderDataBinding"),
|
||||
int(i));
|
||||
#endif
|
||||
std::array<VkDescriptorBufferInfo, 2> fillArr;
|
||||
|
@ -2672,7 +2672,7 @@ struct VulkanShaderDataBinding : GraphicsDataNode<IShaderDataBinding> {
|
|||
for (size_t i = 0; i < ubufCount; ++i) {
|
||||
#ifndef NDEBUG
|
||||
if (!ubufs[i])
|
||||
Log.report(logvisor::Fatal, "null uniform-buffer %d provided to newShaderDataBinding", int(i));
|
||||
Log.report(logvisor::Fatal, fmt("null uniform-buffer {} provided to newShaderDataBinding"), int(i));
|
||||
#endif
|
||||
m_ubufs.push_back(ubufs[i]);
|
||||
}
|
||||
|
@ -2773,7 +2773,7 @@ struct VulkanShaderDataBinding : GraphicsDataNode<IShaderDataBinding> {
|
|||
void bind(VkCommandBuffer cmdBuf, int b, VkRenderPass rPass = 0) {
|
||||
#ifndef NDEBUG
|
||||
if (!m_committed)
|
||||
Log.report(logvisor::Fatal, "attempted to use uncommitted VulkanShaderDataBinding");
|
||||
Log.report(logvisor::Fatal, fmt("attempted to use uncommitted VulkanShaderDataBinding"));
|
||||
#endif
|
||||
|
||||
/* Ensure resized texture bindings are re-bound */
|
||||
|
@ -3183,7 +3183,7 @@ struct VulkanCommandQueue : IGraphicsCommandQueue {
|
|||
VulkanTextureR* csource = m_resolveDispSource.cast<VulkanTextureR>();
|
||||
#ifndef NDEBUG
|
||||
if (!csource->m_colorBindCount)
|
||||
Log.report(logvisor::Fatal, "texture provided to resolveDisplay() must have at least 1 color binding");
|
||||
Log.report(logvisor::Fatal, fmt("texture provided to resolveDisplay() must have at least 1 color binding"));
|
||||
#endif
|
||||
|
||||
ThrowIfFailed(
|
||||
|
@ -3478,9 +3478,9 @@ VulkanTextureR::VulkanTextureR(const boo::ObjToken<BaseGraphicsData>& parent, Vu
|
|||
, m_colorBindCount(colorBindCount)
|
||||
, m_depthBindCount(depthBindCount) {
|
||||
if (colorBindCount > MAX_BIND_TEXS)
|
||||
Log.report(logvisor::Fatal, "too many color bindings for render texture");
|
||||
Log.report(logvisor::Fatal, fmt("too many color bindings for render texture"));
|
||||
if (depthBindCount > MAX_BIND_TEXS)
|
||||
Log.report(logvisor::Fatal, "too many depth bindings for render texture");
|
||||
Log.report(logvisor::Fatal, fmt("too many depth bindings for render texture"));
|
||||
|
||||
if (m_samplesColor == 0)
|
||||
m_samplesColor = 1;
|
||||
|
@ -3711,7 +3711,7 @@ ObjToken<IShaderStage> VulkanDataFactory::Context::newShaderStage(const uint8_t*
|
|||
|
||||
if (stage == PipelineStage::Control || stage == PipelineStage::Evaluation) {
|
||||
if (!factory.m_ctx->m_features.tessellationShader)
|
||||
Log.report(logvisor::Fatal, "Device does not support tessellation shaders");
|
||||
Log.report(logvisor::Fatal, fmt("Device does not support tessellation shaders"));
|
||||
}
|
||||
|
||||
return {new VulkanShaderStage(m_data, factory.m_ctx, data, size, stage)};
|
||||
|
@ -3725,9 +3725,9 @@ ObjToken<IShaderPipeline> VulkanDataFactory::Context::newShaderPipeline(
|
|||
|
||||
if (control || evaluation) {
|
||||
if (!factory.m_ctx->m_features.tessellationShader)
|
||||
Log.report(logvisor::Fatal, "Device does not support tessellation shaders");
|
||||
Log.report(logvisor::Fatal, fmt("Device does not support tessellation shaders"));
|
||||
if (additionalInfo.patchSize > factory.m_ctx->m_gpuProps.limits.maxTessellationPatchSize)
|
||||
Log.report(logvisor::Fatal, "Device supports %d patch vertices, %d requested",
|
||||
Log.report(logvisor::Fatal, fmt("Device supports {} patch vertices, {} requested"),
|
||||
int(factory.m_ctx->m_gpuProps.limits.maxTessellationPatchSize), int(additionalInfo.patchSize));
|
||||
}
|
||||
|
||||
|
@ -4089,14 +4089,14 @@ std::vector<uint8_t> VulkanDataFactory::CompileGLSL(const char* source, Pipeline
|
|||
glslang::TShader shader(lang);
|
||||
shader.setStrings(&source, 1);
|
||||
if (!shader.parse(&glslang::DefaultTBuiltInResource, 110, false, messages)) {
|
||||
printf("%s\n", source);
|
||||
Log.report(logvisor::Fatal, "unable to compile shader\n%s", shader.getInfoLog());
|
||||
fmt::print(fmt("{}\n"), source);
|
||||
Log.report(logvisor::Fatal, fmt("unable to compile shader\n{}"), shader.getInfoLog());
|
||||
}
|
||||
|
||||
glslang::TProgram prog;
|
||||
prog.addShader(&shader);
|
||||
if (!prog.link(messages)) {
|
||||
Log.report(logvisor::Fatal, "unable to link shader program\n%s", prog.getInfoLog());
|
||||
Log.report(logvisor::Fatal, fmt("unable to link shader program\n{}"), prog.getInfoLog());
|
||||
}
|
||||
|
||||
std::vector<unsigned int> out;
|
||||
|
|
|
@ -312,7 +312,7 @@ class NXTextureS : public GraphicsDataNode<ITextureS> {
|
|||
m_pixelPitchDenom = 2;
|
||||
break;
|
||||
default:
|
||||
Log.report(logvisor::Fatal, "unsupported tex format");
|
||||
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
|
||||
}
|
||||
m_nxFmt = pfmt;
|
||||
|
||||
|
@ -327,7 +327,7 @@ class NXTextureS : public GraphicsDataNode<ITextureS> {
|
|||
texTempl.bind = PIPE_BIND_SAMPLER_VIEW;
|
||||
m_gpuTex = ctx->m_screen->resource_create(ctx->m_screen, &texTempl);
|
||||
if (!m_gpuTex) {
|
||||
Log.report(logvisor::Fatal, "Failed to create texture");
|
||||
Log.report(logvisor::Fatal, fmt("Failed to create texture"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -414,7 +414,7 @@ class NXTextureSA : public GraphicsDataNode<ITextureSA> {
|
|||
m_pixelPitchNum = 2;
|
||||
break;
|
||||
default:
|
||||
Log.report(logvisor::Fatal, "unsupported tex format");
|
||||
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
|
||||
}
|
||||
m_nxFmt = pfmt;
|
||||
|
||||
|
@ -429,7 +429,7 @@ class NXTextureSA : public GraphicsDataNode<ITextureSA> {
|
|||
texTempl.bind = PIPE_BIND_SAMPLER_VIEW;
|
||||
m_gpuTex = ctx->m_screen->resource_create(ctx->m_screen, &texTempl);
|
||||
if (!m_gpuTex) {
|
||||
Log.report(logvisor::Fatal, "Failed to create texture");
|
||||
Log.report(logvisor::Fatal, fmt("Failed to create texture"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -552,7 +552,7 @@ class NXTextureR : public GraphicsDataNode<ITextureR> {
|
|||
texTempl.bind = PIPE_BIND_RENDER_TARGET;
|
||||
m_colorTex = ctx->m_screen->resource_create(ctx->m_screen, &texTempl);
|
||||
if (!m_colorTex) {
|
||||
Log.report(logvisor::Fatal, "Failed to create color target texture");
|
||||
Log.report(logvisor::Fatal, fmt("Failed to create color target texture"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -562,7 +562,7 @@ class NXTextureR : public GraphicsDataNode<ITextureR> {
|
|||
texTempl.bind = PIPE_BIND_DEPTH_STENCIL;
|
||||
m_depthTex = ctx->m_screen->resource_create(ctx->m_screen, &texTempl);
|
||||
if (!m_depthTex) {
|
||||
Log.report(logvisor::Fatal, "Failed to create depth target texture");
|
||||
Log.report(logvisor::Fatal, fmt("Failed to create depth target texture"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -573,7 +573,7 @@ class NXTextureR : public GraphicsDataNode<ITextureR> {
|
|||
texTempl.bind = PIPE_BIND_SAMPLER_VIEW;
|
||||
m_colorBindTex[i] = ctx->m_screen->resource_create(ctx->m_screen, &texTempl);
|
||||
if (!m_colorBindTex[i]) {
|
||||
Log.report(logvisor::Fatal, "Failed to create color bind texture");
|
||||
Log.report(logvisor::Fatal, fmt("Failed to create color bind texture"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -583,7 +583,7 @@ class NXTextureR : public GraphicsDataNode<ITextureR> {
|
|||
texTempl.bind = PIPE_BIND_SAMPLER_VIEW;
|
||||
m_depthBindTex[i] = ctx->m_screen->resource_create(ctx->m_screen, &texTempl);
|
||||
if (!m_depthBindTex[i]) {
|
||||
Log.report(logvisor::Fatal, "Failed to create depth bind texture");
|
||||
Log.report(logvisor::Fatal, fmt("Failed to create depth bind texture"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -598,7 +598,7 @@ class NXTextureR : public GraphicsDataNode<ITextureR> {
|
|||
svTempl.texture = m_colorTex;
|
||||
m_colorView = ctx->m_pctx->create_sampler_view(ctx->m_pctx, m_colorTex, &svTempl);
|
||||
if (!m_colorView) {
|
||||
Log.report(logvisor::Fatal, "Failed to create color sampler view");
|
||||
Log.report(logvisor::Fatal, fmt("Failed to create color sampler view"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -606,7 +606,7 @@ class NXTextureR : public GraphicsDataNode<ITextureR> {
|
|||
svTempl.texture = m_depthTex;
|
||||
m_depthView = ctx->m_pctx->create_sampler_view(ctx->m_pctx, m_depthTex, &svTempl);
|
||||
if (!m_depthView) {
|
||||
Log.report(logvisor::Fatal, "Failed to create depth sampler view");
|
||||
Log.report(logvisor::Fatal, fmt("Failed to create depth sampler view"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -615,7 +615,7 @@ class NXTextureR : public GraphicsDataNode<ITextureR> {
|
|||
svTempl.texture = m_colorBindTex[i];
|
||||
m_colorBindView[i] = ctx->m_pctx->create_sampler_view(ctx->m_pctx, m_colorBindTex[i], &svTempl);
|
||||
if (!m_colorBindView[i]) {
|
||||
Log.report(logvisor::Fatal, "Failed to create color bind sampler view");
|
||||
Log.report(logvisor::Fatal, fmt("Failed to create color bind sampler view"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -625,7 +625,7 @@ class NXTextureR : public GraphicsDataNode<ITextureR> {
|
|||
svTempl.texture = m_depthBindTex[i];
|
||||
m_depthBindView[i] = ctx->m_pctx->create_sampler_view(ctx->m_pctx, m_depthBindTex[i], &svTempl);
|
||||
if (!m_depthBindView[i]) {
|
||||
Log.report(logvisor::Fatal, "Failed to create depth bind sampler view");
|
||||
Log.report(logvisor::Fatal, fmt("Failed to create depth bind sampler view"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -635,14 +635,14 @@ class NXTextureR : public GraphicsDataNode<ITextureR> {
|
|||
surfTempl.format = ColorFormat;
|
||||
m_colorSurface = ctx->m_pctx->create_surface(ctx->m_pctx, m_colorTex, &surfTempl);
|
||||
if (!m_colorSurface) {
|
||||
Log.report(logvisor::Fatal, "Failed to create color surface");
|
||||
Log.report(logvisor::Fatal, fmt("Failed to create color surface"));
|
||||
return;
|
||||
}
|
||||
|
||||
surfTempl.format = DepthFormat;
|
||||
m_depthSurface = ctx->m_pctx->create_surface(ctx->m_pctx, m_depthTex, &surfTempl);
|
||||
if (!m_depthSurface) {
|
||||
Log.report(logvisor::Fatal, "Failed to create depth surface");
|
||||
Log.report(logvisor::Fatal, fmt("Failed to create depth surface"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -658,9 +658,9 @@ class NXTextureR : public GraphicsDataNode<ITextureR> {
|
|||
TextureClampMode clampMode, size_t colorBindCount, size_t depthBindCount)
|
||||
: GraphicsDataNode<ITextureR>(parent), m_ctx(ctx) {
|
||||
if (colorBindCount > MAX_BIND_TEXS)
|
||||
Log.report(logvisor::Fatal, "too many color bindings for render texture");
|
||||
Log.report(logvisor::Fatal, fmt("too many color bindings for render texture"));
|
||||
if (depthBindCount > MAX_BIND_TEXS)
|
||||
Log.report(logvisor::Fatal, "too many depth bindings for render texture");
|
||||
Log.report(logvisor::Fatal, fmt("too many depth bindings for render texture"));
|
||||
|
||||
if (m_samplesColor == 0)
|
||||
m_samplesColor = 1;
|
||||
|
@ -788,7 +788,7 @@ class NXShaderStage : public GraphicsDataNode<IShaderStage> {
|
|||
PipelineStage stage)
|
||||
: GraphicsDataNode<IShaderStage>(parent), m_obj(ctx->m_compiler.compile(SHADER_TYPE_TABLE[int(stage)], (char*)data)) {
|
||||
if (!m_obj)
|
||||
Log.report(logvisor::Fatal, "Shader compile fail:\n%s\n", m_obj.info_log());
|
||||
Log.report(logvisor::Fatal, fmt("Shader compile fail:\n%s\n"), m_obj.info_log());
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -953,7 +953,7 @@ protected:
|
|||
std::string infoLog;
|
||||
m_shader = ctx->m_compiler.link(numStages, stages, &infoLog);
|
||||
if (!m_shader)
|
||||
Log.report(logvisor::Fatal, "Unable to link shader:\n%s\n", infoLog.c_str());
|
||||
Log.report(logvisor::Fatal, fmt("Unable to link shader:\n%s\n"), infoLog.c_str());
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -1076,7 +1076,7 @@ struct NXShaderDataBinding : GraphicsDataNode<IShaderDataBinding> {
|
|||
for (size_t i = 0; i < ubufCount; ++i) {
|
||||
#ifndef NDEBUG
|
||||
if (!ubufs[i])
|
||||
Log.report(logvisor::Fatal, "null uniform-buffer %d provided to newShaderDataBinding", int(i));
|
||||
Log.report(logvisor::Fatal, fmt("null uniform-buffer %d provided to newShaderDataBinding"), int(i));
|
||||
#endif
|
||||
m_ubufs.push_back(ubufs[i]);
|
||||
if (ubufOffs && ubufSizes)
|
||||
|
@ -1134,7 +1134,7 @@ struct NXShaderDataBinding : GraphicsDataNode<IShaderDataBinding> {
|
|||
void bind(int b) {
|
||||
#ifndef NDEBUG
|
||||
if (!m_committed)
|
||||
Log.report(logvisor::Fatal, "attempted to use uncommitted NXShaderDataBinding");
|
||||
Log.report(logvisor::Fatal, fmt("attempted to use uncommitted NXShaderDataBinding"));
|
||||
#endif
|
||||
struct pipe_context* pctx = m_ctx->m_pctx;
|
||||
|
||||
|
@ -1355,7 +1355,7 @@ struct NXCommandQueue : IGraphicsCommandQueue {
|
|||
NXTextureR* csource = m_resolveDispSource.cast<NXTextureR>();
|
||||
#ifndef NDEBUG
|
||||
if (!csource->m_colorBindCount)
|
||||
Log.report(logvisor::Fatal, "texture provided to resolveDisplay() must have at least 1 color binding");
|
||||
Log.report(logvisor::Fatal, fmt("texture provided to resolveDisplay() must have at least 1 color binding"));
|
||||
#endif
|
||||
|
||||
struct pipe_surface* backBuf = m_ctx->m_windowSurfaces[ST_ATTACHMENT_BACK_LEFT];
|
||||
|
@ -1531,7 +1531,7 @@ NXTextureD::NXTextureD(const boo::ObjToken<BaseGraphicsData>& parent, NXCommandQ
|
|||
m_cpuSz = width * height * 2;
|
||||
break;
|
||||
default:
|
||||
Log.report(logvisor::Fatal, "unsupported tex format");
|
||||
Log.report(logvisor::Fatal, fmt("unsupported tex format"));
|
||||
}
|
||||
m_nxFmt = pfmt;
|
||||
m_stagingBuf.reset(new uint8_t[m_cpuSz]);
|
||||
|
@ -1547,7 +1547,7 @@ NXTextureD::NXTextureD(const boo::ObjToken<BaseGraphicsData>& parent, NXCommandQ
|
|||
for (int i = 0; i < 2; ++i) {
|
||||
m_gpuTex[i] = ctx->m_screen->resource_create(ctx->m_screen, &texTempl);
|
||||
if (!m_gpuTex[i]) {
|
||||
Log.report(logvisor::Fatal, "Failed to create texture");
|
||||
Log.report(logvisor::Fatal, fmt("Failed to create texture"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1805,7 +1805,7 @@ bool NXContext::initialize() {
|
|||
printf("Activated console\n\n");
|
||||
m_screen = nouveau_switch_screen_create();
|
||||
if (!m_screen) {
|
||||
Log.report(logvisor::Fatal, "Failed to create nouveau screen");
|
||||
Log.report(logvisor::Fatal, fmt("Failed to create nouveau screen"));
|
||||
return false;
|
||||
}
|
||||
printf("nouveau_switch_screen_create done\n");
|
||||
|
@ -1813,7 +1813,7 @@ bool NXContext::initialize() {
|
|||
|
||||
m_pctx = m_screen->context_create(m_screen, nullptr, 0);
|
||||
if (!m_pctx) {
|
||||
Log.report(logvisor::Fatal, "Failed to create pipe context");
|
||||
Log.report(logvisor::Fatal, fmt("Failed to create pipe context"));
|
||||
m_screen->destroy(m_screen);
|
||||
return false;
|
||||
}
|
||||
|
@ -1822,7 +1822,7 @@ bool NXContext::initialize() {
|
|||
st_config_options opts = {};
|
||||
m_st = st_create_context(API_OPENGL_CORE, m_pctx, nullptr, nullptr, &opts, false);
|
||||
if (!m_st) {
|
||||
Log.report(logvisor::Fatal, "Failed to create st context");
|
||||
Log.report(logvisor::Fatal, fmt("Failed to create st context"));
|
||||
m_screen->destroy(m_screen);
|
||||
return false;
|
||||
}
|
||||
|
@ -1849,7 +1849,7 @@ bool NXContext::initialize() {
|
|||
whandle.stride = gfxGetFramebufferPitch();
|
||||
struct pipe_resource* tex = m_screen->resource_from_handle(m_screen, &texTempl, &whandle, 0);
|
||||
if (!tex) {
|
||||
Log.report(logvisor::Fatal, "Failed to create color target texture");
|
||||
Log.report(logvisor::Fatal, fmt("Failed to create color target texture"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1858,7 +1858,7 @@ bool NXContext::initialize() {
|
|||
surfTempl.format = ColorFormat;
|
||||
m_windowSurfaces[i] = m_pctx->create_surface(m_pctx, tex, &surfTempl);
|
||||
if (!m_windowSurfaces[i]) {
|
||||
Log.report(logvisor::Fatal, "Failed to create color surface");
|
||||
Log.report(logvisor::Fatal, fmt("Failed to create color surface"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,11 +21,8 @@ void DeviceBase::closeDevice() {
|
|||
m_token->_deviceClose();
|
||||
}
|
||||
|
||||
void DeviceBase::deviceError(const char* error, ...) {
|
||||
va_list vl;
|
||||
va_start(vl, error);
|
||||
vfprintf(stderr, error, vl);
|
||||
va_end(vl);
|
||||
void DeviceBase::vdeviceError(fmt::string_view error, fmt::format_args args) {
|
||||
fmt::vprint(error, args);
|
||||
}
|
||||
|
||||
bool DeviceBase::sendUSBInterruptTransfer(const uint8_t* data, size_t length) {
|
||||
|
|
|
@ -13,7 +13,7 @@ DolphinSmashAdapter::DolphinSmashAdapter(DeviceToken* token)
|
|||
|
||||
DolphinSmashAdapter::~DolphinSmashAdapter() {}
|
||||
|
||||
static inline EDolphinControllerType parseType(unsigned char status) {
|
||||
constexpr EDolphinControllerType parseType(unsigned char status) {
|
||||
EDolphinControllerType type =
|
||||
EDolphinControllerType(status) & (EDolphinControllerType::Normal | EDolphinControllerType::Wavebird);
|
||||
switch (type) {
|
||||
|
@ -25,7 +25,7 @@ static inline EDolphinControllerType parseType(unsigned char status) {
|
|||
}
|
||||
}
|
||||
|
||||
static inline EDolphinControllerType parseState(DolphinControllerState* stateOut, uint8_t* payload, bool& rumble) {
|
||||
static EDolphinControllerType parseState(DolphinControllerState* stateOut, uint8_t* payload, bool& rumble) {
|
||||
unsigned char status = payload[0];
|
||||
EDolphinControllerType type = parseType(status);
|
||||
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
#include <memory.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
static inline uint16_t bswap16(uint16_t val) { return _byteswap_ushort(val); }
|
||||
constexpr uint16_t bswap16(uint16_t val) { return _byteswap_ushort(val); }
|
||||
#elif __GNUC__ && !defined(__FreeBSD__)
|
||||
static inline uint16_t bswap16(uint16_t val) { return __builtin_bswap16(val); }
|
||||
constexpr uint16_t bswap16(uint16_t val) { return __builtin_bswap16(val); }
|
||||
#elif !defined(__FreeBSD__)
|
||||
static inline uint16_t bswap16(uint16_t val) { return __builtin_byteswap(val); }
|
||||
constexpr uint16_t bswap16(uint16_t val) { return __builtin_byteswap(val); }
|
||||
#endif
|
||||
|
||||
#ifndef M_PIF
|
||||
|
|
|
@ -76,10 +76,7 @@ class HIDDeviceIOKit : public IHIDDevice {
|
|||
}
|
||||
|
||||
static void _threadProcUSBLL(std::shared_ptr<HIDDeviceIOKit> device) {
|
||||
char thrName[128];
|
||||
snprintf(thrName, 128, "%s Transfer Thread", device->m_token.getProductName().data());
|
||||
pthread_setname_np(thrName);
|
||||
char errStr[256];
|
||||
pthread_setname_np(fmt::format(fmt("{} Transfer Thread"), device->m_token.getProductName()));
|
||||
std::unique_lock<std::mutex> lk(device->m_initMutex);
|
||||
|
||||
/* Get the HID element's parent (USB interrupt transfer-interface) */
|
||||
|
@ -95,9 +92,8 @@ class HIDDeviceIOKit : public IHIDDevice {
|
|||
}
|
||||
}
|
||||
if (!interfaceEntry) {
|
||||
snprintf(errStr, 256, "Unable to find interface for %s@%s\n", device->m_token.getProductName().data(),
|
||||
device->m_devPath.data());
|
||||
device->m_devImp->deviceError(errStr);
|
||||
device->m_devImp->deviceError(fmt::format(fmt("Unable to find interface for {}@{}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath).c_str());
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
return;
|
||||
|
@ -110,9 +106,8 @@ class HIDDeviceIOKit : public IHIDDevice {
|
|||
err = IOCreatePlugInInterfaceForService(interfaceEntry.get(), kIOUSBInterfaceUserClientTypeID,
|
||||
kIOCFPlugInInterfaceID, &iodev, &score);
|
||||
if (err) {
|
||||
snprintf(errStr, 256, "Unable to open %s@%s\n", device->m_token.getProductName().data(),
|
||||
device->m_devPath.data());
|
||||
device->m_devImp->deviceError(errStr);
|
||||
device->m_devImp->deviceError(fmt::format(fmt("Unable to open {}@{}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath).c_str());
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
return;
|
||||
|
@ -122,9 +117,8 @@ class HIDDeviceIOKit : public IHIDDevice {
|
|||
IUnknownPointer<IOUSBInterfaceInterface> intf;
|
||||
err = iodev.As(&intf, kIOUSBInterfaceInterfaceID);
|
||||
if (err) {
|
||||
snprintf(errStr, 256, "Unable to open %s@%s\n", device->m_token.getProductName().data(),
|
||||
device->m_devPath.data());
|
||||
device->m_devImp->deviceError(errStr);
|
||||
device->m_devImp->deviceError(fmt::format(fmt("Unable to open {}@{}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath).c_str());
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
return;
|
||||
|
@ -135,13 +129,11 @@ class HIDDeviceIOKit : public IHIDDevice {
|
|||
err = intf->USBInterfaceOpen(intf.storage());
|
||||
if (err != kIOReturnSuccess) {
|
||||
if (err == kIOReturnExclusiveAccess) {
|
||||
snprintf(errStr, 256, "Unable to open %s@%s: someone else using it\n", device->m_token.getProductName().data(),
|
||||
device->m_devPath.data());
|
||||
device->m_devImp->deviceError(errStr);
|
||||
device->m_devImp->deviceError(fmt::format(fmt("Unable to open {}@{}: someone else using it\n"),
|
||||
device->m_token.getProductName(), device->m_devPath).c_str());
|
||||
} else {
|
||||
snprintf(errStr, 256, "Unable to open %s@%s\n", device->m_token.getProductName().data(),
|
||||
device->m_devPath.data());
|
||||
device->m_devImp->deviceError(errStr);
|
||||
device->m_devImp->deviceError(fmt::format(fmt("Unable to open {}@{}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath).c_str());
|
||||
}
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
|
@ -204,19 +196,15 @@ class HIDDeviceIOKit : public IHIDDevice {
|
|||
}
|
||||
|
||||
static void _threadProcHID(std::shared_ptr<HIDDeviceIOKit> device) {
|
||||
char thrName[128];
|
||||
snprintf(thrName, 128, "%s Transfer Thread", device->m_token.getProductName().data());
|
||||
pthread_setname_np(thrName);
|
||||
char errStr[256];
|
||||
pthread_setname_np(fmt::format(fmt("{} Transfer Thread"), device->m_token.getProductName());
|
||||
std::unique_lock<std::mutex> lk(device->m_initMutex);
|
||||
|
||||
/* Get the HID element's object (HID device interface) */
|
||||
IOObjectPointer<io_service_t> interfaceEntry =
|
||||
IORegistryEntryFromPath(kIOMasterPortDefault, device->m_devPath.data());
|
||||
if (!IOObjectConformsTo(interfaceEntry.get(), "IOHIDDevice")) {
|
||||
snprintf(errStr, 256, "Unable to find interface for %s@%s\n", device->m_token.getProductName().data(),
|
||||
device->m_devPath.data());
|
||||
device->m_devImp->deviceError(errStr);
|
||||
device->m_devImp->deviceError(fmt::format(fmt("Unable to find interface for {}@{}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath);
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
return;
|
||||
|
@ -224,9 +212,8 @@ class HIDDeviceIOKit : public IHIDDevice {
|
|||
|
||||
device->m_hidIntf = IOHIDDeviceCreate(nullptr, interfaceEntry.get());
|
||||
if (!device->m_hidIntf) {
|
||||
snprintf(errStr, 256, "Unable to open %s@%s\n", device->m_token.getProductName().data(),
|
||||
device->m_devPath.data());
|
||||
device->m_devImp->deviceError(errStr);
|
||||
device->m_devImp->deviceError(fmt::format(fmt("Unable to open {}@{}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath).c_str());
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
return;
|
||||
|
@ -236,13 +223,11 @@ class HIDDeviceIOKit : public IHIDDevice {
|
|||
IOReturn err = IOHIDDeviceOpen(device->m_hidIntf.get(), kIOHIDOptionsTypeNone);
|
||||
if (err != kIOReturnSuccess) {
|
||||
if (err == kIOReturnExclusiveAccess) {
|
||||
snprintf(errStr, 256, "Unable to open %s@%s: someone else using it\n", device->m_token.getProductName().data(),
|
||||
device->m_devPath.data());
|
||||
device->m_devImp->deviceError(errStr);
|
||||
device->m_devImp->deviceError(fmt::format(fmt("Unable to open {}@{}: someone else using it\n"),
|
||||
device->m_token.getProductName(), device->m_devPath).c_str());
|
||||
} else {
|
||||
snprintf(errStr, 256, "Unable to open %s@%s\n", device->m_token.getProductName().data(),
|
||||
device->m_devPath.data());
|
||||
device->m_devImp->deviceError(errStr);
|
||||
device->m_devImp->deviceError(fmt::format(fmt("Unable to open {}@{}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath).c_str());
|
||||
}
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
|
@ -304,7 +289,7 @@ public:
|
|||
else if (dType == DeviceType::HID)
|
||||
m_thread = std::thread(_threadProcHID, std::static_pointer_cast<HIDDeviceIOKit>(shared_from_this()));
|
||||
else {
|
||||
fprintf(stderr, "invalid token supplied to device constructor\n");
|
||||
fmt::print(stderr, fmt("invalid token supplied to device constructor\n"));
|
||||
return;
|
||||
}
|
||||
m_initCond.wait(lk);
|
||||
|
|
|
@ -61,7 +61,6 @@ class HIDDeviceUdev final : public IHIDDevice {
|
|||
|
||||
static void _threadProcUSBLL(std::shared_ptr<HIDDeviceUdev> device) {
|
||||
int i;
|
||||
char errStr[256];
|
||||
std::unique_lock<std::mutex> lk(device->m_initMutex);
|
||||
udev_device* udevDev = udev_device_new_from_syspath(GetUdev(), device->m_devPath.data());
|
||||
|
||||
|
@ -69,8 +68,8 @@ class HIDDeviceUdev final : public IHIDDevice {
|
|||
const char* dp = udev_device_get_devnode(udevDev);
|
||||
int fd = open(dp, O_RDWR);
|
||||
if (fd < 0) {
|
||||
snprintf(errStr, 256, "Unable to open %s@%s: %s\n", device->m_token.getProductName().data(), dp, strerror(errno));
|
||||
device->m_devImp->deviceError(errStr);
|
||||
device->m_devImp->deviceError(fmt("Unable to open {}@{}: {}\n"),
|
||||
device->m_token.getProductName(), dp, strerror(errno));
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
udev_device_unref(udevDev);
|
||||
|
@ -142,7 +141,6 @@ class HIDDeviceUdev final : public IHIDDevice {
|
|||
}
|
||||
|
||||
static void _threadProcHID(std::shared_ptr<HIDDeviceUdev> device) {
|
||||
char errStr[256];
|
||||
std::unique_lock<std::mutex> lk(device->m_initMutex);
|
||||
udev_device* udevDev = udev_device_new_from_syspath(GetUdev(), device->m_devPath.data());
|
||||
|
||||
|
@ -150,8 +148,8 @@ class HIDDeviceUdev final : public IHIDDevice {
|
|||
const char* dp = udev_device_get_devnode(udevDev);
|
||||
int fd = open(dp, O_RDWR | O_NONBLOCK);
|
||||
if (fd < 0) {
|
||||
snprintf(errStr, 256, "Unable to open %s@%s: %s\n", device->m_token.getProductName().data(), dp, strerror(errno));
|
||||
device->m_devImp->deviceError(errStr);
|
||||
device->m_devImp->deviceError(fmt("Unable to open {}@{}: {}\n"),
|
||||
device->m_token.getProductName(), dp, strerror(errno));
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
udev_device_unref(udevDev);
|
||||
|
@ -167,9 +165,8 @@ class HIDDeviceUdev final : public IHIDDevice {
|
|||
/* Report descriptor size */
|
||||
int reportDescSize;
|
||||
if (ioctl(fd, HIDIOCGRDESCSIZE, &reportDescSize) == -1) {
|
||||
snprintf(errStr, 256, "Unable to ioctl(HIDIOCGRDESCSIZE) %s@%s: %s\n", device->m_token.getProductName().data(),
|
||||
dp, strerror(errno));
|
||||
device->m_devImp->deviceError(errStr);
|
||||
device->m_devImp->deviceError(fmt("Unable to ioctl(HIDIOCGRDESCSIZE) {}@{}: {}\n"),
|
||||
device->m_token.getProductName(), dp, strerror(errno));
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
@ -178,9 +175,8 @@ class HIDDeviceUdev final : public IHIDDevice {
|
|||
hidraw_report_descriptor reportDesc;
|
||||
reportDesc.size = reportDescSize;
|
||||
if (ioctl(fd, HIDIOCGRDESC, &reportDesc) == -1) {
|
||||
snprintf(errStr, 256, "Unable to ioctl(HIDIOCGRDESC) %s@%s: %s\n", device->m_token.getProductName().data(), dp,
|
||||
strerror(errno));
|
||||
device->m_devImp->deviceError(errStr);
|
||||
device->m_devImp->deviceError(fmt("Unable to ioctl(HIDIOCGRDESC) {}@{}: {}\n"),
|
||||
device->m_token.getProductName(), dp, strerror(errno));
|
||||
close(fd);
|
||||
return;
|
||||
}
|
||||
|
@ -275,7 +271,7 @@ public:
|
|||
else if (dType == DeviceType::HID)
|
||||
m_thread = std::thread(_threadProcHID, std::static_pointer_cast<HIDDeviceUdev>(shared_from_this()));
|
||||
else {
|
||||
fprintf(stderr, "invalid token supplied to device constructor");
|
||||
fmt::print(stderr, fmt("invalid token supplied to device constructor"));
|
||||
abort();
|
||||
}
|
||||
m_initCond.wait(lk);
|
||||
|
|
|
@ -62,7 +62,6 @@ class HIDDeviceWinUSB final : public IHIDDevice {
|
|||
|
||||
static void _threadProcUSBLL(std::shared_ptr<HIDDeviceWinUSB> device) {
|
||||
unsigned i;
|
||||
char errStr[256];
|
||||
std::unique_lock<std::mutex> lk(device->m_initMutex);
|
||||
|
||||
/* POSIX.. who needs it?? -MS */
|
||||
|
@ -70,18 +69,16 @@ class HIDDeviceWinUSB final : public IHIDDevice {
|
|||
CreateFileA(device->m_devPath.data(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ, NULL,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL);
|
||||
if (INVALID_HANDLE_VALUE == device->m_devHandle) {
|
||||
_snprintf(errStr, 256, "Unable to open %s@%s: %d\n", device->m_token.getProductName().data(),
|
||||
device->m_devPath.data(), GetLastError());
|
||||
device->m_devImp->deviceError(errStr);
|
||||
device->m_devImp->deviceError(fmt::format(fmt("Unable to open {}@{}: {}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath, GetLastError()).c_str());
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!WinUsb_Initialize(device->m_devHandle, &device->m_usbHandle)) {
|
||||
_snprintf(errStr, 256, "Unable to open %s@%s: %d\n", device->m_token.getProductName().data(),
|
||||
device->m_devPath.data(), GetLastError());
|
||||
device->m_devImp->deviceError(errStr);
|
||||
device->m_devImp->deviceError(fmt::format(fmt("Unable to open {}@{}: {}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath, GetLastError()).c_str());
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
CloseHandle(device->m_devHandle);
|
||||
|
@ -91,9 +88,8 @@ class HIDDeviceWinUSB final : public IHIDDevice {
|
|||
/* Enumerate device pipes */
|
||||
USB_INTERFACE_DESCRIPTOR ifDesc = {0};
|
||||
if (!WinUsb_QueryInterfaceSettings(device->m_usbHandle, 0, &ifDesc)) {
|
||||
_snprintf(errStr, 256, "Unable to open %s@%s: %d\n", device->m_token.getProductName().data(),
|
||||
device->m_devPath.data(), GetLastError());
|
||||
device->m_devImp->deviceError(errStr);
|
||||
device->m_devImp->deviceError(fmt::format(fmt("Unable to open {}@{}: {}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath, GetLastError()).c_str());
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
CloseHandle(device->m_devHandle);
|
||||
|
@ -149,7 +145,6 @@ class HIDDeviceWinUSB final : public IHIDDevice {
|
|||
PHIDP_PREPARSED_DATA m_preparsedData = nullptr;
|
||||
|
||||
static void _threadProcHID(std::shared_ptr<HIDDeviceWinUSB> device) {
|
||||
char errStr[256];
|
||||
std::unique_lock<std::mutex> lk(device->m_initMutex);
|
||||
|
||||
/* POSIX.. who needs it?? -MS */
|
||||
|
@ -158,18 +153,16 @@ class HIDDeviceWinUSB final : public IHIDDevice {
|
|||
CreateFileA(device->m_devPath.data(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_WRITE | FILE_SHARE_READ, NULL,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL);
|
||||
if (INVALID_HANDLE_VALUE == device->m_hidHandle) {
|
||||
_snprintf(errStr, 256, "Unable to open %s@%s: %d\n", device->m_token.getProductName().data(),
|
||||
device->m_devPath.data(), GetLastError());
|
||||
device->m_devImp->deviceError(errStr);
|
||||
device->m_devImp->deviceError(fmt::format(fmt("Unable to open {}@{}: {}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath, GetLastError()).c_str());
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!HidD_GetPreparsedData(device->m_hidHandle, &device->m_preparsedData)) {
|
||||
_snprintf(errStr, 256, "Unable get preparsed data of %s@%s: %d\n", device->m_token.getProductName().data(),
|
||||
device->m_devPath.data(), GetLastError());
|
||||
device->m_devImp->deviceError(errStr);
|
||||
device->m_devImp->deviceError(fmt::format(fmt("Unable get preparsed data of {}@{}: {}\n"),
|
||||
device->m_token.getProductName(), device->m_devPath, GetLastError()).c_str());
|
||||
lk.unlock();
|
||||
device->m_initCond.notify_one();
|
||||
return;
|
||||
|
@ -237,14 +230,14 @@ class HIDDeviceWinUSB final : public IHIDDevice {
|
|||
}
|
||||
|
||||
if (Error != ERROR_IO_PENDING) {
|
||||
fprintf(stderr, "Write Failed %08X\n", int(Error));
|
||||
fmt::print(stderr, fmt("Write Failed {:08X}\n"), int(Error));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!GetOverlappedResult(m_hidHandle, &Overlapped, &BytesWritten, TRUE)) {
|
||||
DWORD Error = GetLastError();
|
||||
fprintf(stderr, "Write Failed %08X\n", int(Error));
|
||||
fmt::print(stderr, fmt("Write Failed {:08X}\n"), int(Error));
|
||||
return false;
|
||||
}
|
||||
} else if (tp == HIDReportType::Feature) {
|
||||
|
@ -313,7 +306,7 @@ public:
|
|||
m_runningTransferLoop = false;
|
||||
return;
|
||||
} else if (Error != ERROR_IO_PENDING) {
|
||||
fprintf(stderr, "Read Failed: %08X\n", int(Error));
|
||||
fmt::print(stderr, fmt("Read Failed: {:08X}\n"), int(Error));
|
||||
return;
|
||||
} else if (!GetOverlappedResultEx(m_hidHandle, &m_overlapped, &BytesRead, 10, TRUE)) {
|
||||
return;
|
||||
|
|
|
@ -84,14 +84,14 @@ class HIDListenerIOKit : public IHIDListener {
|
|||
err = IOCreatePlugInInterfaceForService(obj.get(), kIOUSBDeviceUserClientTypeID, kIOCFPlugInInterfaceID,
|
||||
&devServ, &score);
|
||||
if (err != kIOReturnSuccess) {
|
||||
fprintf(stderr, "unable to open IOKit plugin interface\n");
|
||||
fmt::print(stderr, fmt("unable to open IOKit plugin interface\n"));
|
||||
continue;
|
||||
}
|
||||
|
||||
IUnknownPointer<IOUSBDeviceInterface182> dev;
|
||||
err = devServ.As(&dev, kIOUSBDeviceInterfaceID182);
|
||||
if (err != kIOReturnSuccess) {
|
||||
fprintf(stderr, "unable to open IOKit device interface\n");
|
||||
fmt::print(stderr, fmt("unable to open IOKit device interface\n"));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -147,14 +147,14 @@ class HIDListenerIOKit : public IHIDListener {
|
|||
err =
|
||||
IOCreatePlugInInterfaceForService(obj.get(), kIOHIDDeviceTypeID, kIOCFPlugInInterfaceID, &devServ, &score);
|
||||
if (err != kIOReturnSuccess) {
|
||||
fprintf(stderr, "unable to open IOKit plugin interface\n");
|
||||
fmt::print(stderr, fmt("unable to open IOKit plugin interface\n"));
|
||||
continue;
|
||||
}
|
||||
|
||||
IUnknownPointer<IOHIDDeviceDeviceInterface> dev;
|
||||
err = devServ.As(&dev, kIOHIDDeviceDeviceInterfaceID);
|
||||
if (err != kIOReturnSuccess) {
|
||||
fprintf(stderr, "unable to open IOKit device interface\n");
|
||||
fmt::print(stderr, fmt("unable to open IOKit device interface\n"));
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -170,7 +170,7 @@ public:
|
|||
/* Setup hotplug events */
|
||||
m_udevMon = udev_monitor_new_from_netlink(GetUdev(), "udev");
|
||||
if (!m_udevMon) {
|
||||
fprintf(stderr, "unable to init udev_monitor");
|
||||
fmt::print(stderr, fmt("unable to init udev_monitor"));
|
||||
abort();
|
||||
}
|
||||
udev_monitor_filter_add_match_subsystem_devtype(m_udevMon, "usb", "usb_device");
|
||||
|
|
|
@ -103,11 +103,11 @@ public:
|
|||
|
||||
m_metalCtx.m_dev = MTLCreateSystemDefaultDevice();
|
||||
if (!m_metalCtx.m_dev)
|
||||
Log.report(logvisor::Fatal, "Unable to create metal device");
|
||||
Log.report(logvisor::Fatal, fmt("Unable to create metal device"));
|
||||
m_metalCtx.m_q = [m_metalCtx.m_dev newCommandQueue];
|
||||
while (![m_metalCtx.m_dev supportsTextureSampleCount:m_metalCtx.m_sampleCount])
|
||||
m_metalCtx.m_sampleCount = flp2(m_metalCtx.m_sampleCount - 1);
|
||||
Log.report(logvisor::Info, "using Metal renderer");
|
||||
Log.report(logvisor::Info, fmt("using Metal renderer"));
|
||||
}
|
||||
|
||||
EPlatformType getPlatformType() const {
|
||||
|
|
|
@ -226,7 +226,7 @@ public:
|
|||
~GraphicsContextCocoaGL()
|
||||
{
|
||||
m_commandQueue->stopRenderer();
|
||||
printf("CONTEXT DESTROYED\n");
|
||||
fmt::print(fmt("CONTEXT DESTROYED\n"));
|
||||
}
|
||||
|
||||
void _setCallback(IWindowCallback* cb)
|
||||
|
@ -256,7 +256,7 @@ public:
|
|||
{
|
||||
m_nsContext = [[GraphicsContextCocoaGLInternal alloc] initWithBooContext:this];
|
||||
if (!m_nsContext)
|
||||
Log.report(logvisor::Fatal, "unable to make new NSOpenGLView");
|
||||
Log.report(logvisor::Fatal, fmt("unable to make new NSOpenGLView"));
|
||||
[(__bridge NSWindow*)(void*)m_parentWindow->getPlatformHandle() setContentView:m_nsContext];
|
||||
CVDisplayLinkCreateWithActiveCGDisplays(&m_dispLink);
|
||||
CVDisplayLinkSetOutputCallback(m_dispLink, (CVDisplayLinkOutputCallback)DLCallback, this);
|
||||
|
@ -292,7 +292,7 @@ public:
|
|||
NSOpenGLPixelFormat* nspf = [[NSOpenGLPixelFormat alloc] initWithAttributes:PF_TABLE[int(m_pf)]];
|
||||
m_mainCtx = [[NSOpenGLContext alloc] initWithFormat:nspf shareContext:[m_nsContext openGLContext]];
|
||||
if (!m_mainCtx)
|
||||
Log.report(logvisor::Fatal, "unable to make main NSOpenGLContext");
|
||||
Log.report(logvisor::Fatal, fmt("unable to make main NSOpenGLContext"));
|
||||
}
|
||||
[m_mainCtx makeCurrentContext];
|
||||
return m_dataFactory.get();
|
||||
|
@ -305,7 +305,7 @@ public:
|
|||
NSOpenGLPixelFormat* nspf = [[NSOpenGLPixelFormat alloc] initWithAttributes:PF_TABLE[int(m_pf)]];
|
||||
m_loadCtx = [[NSOpenGLContext alloc] initWithFormat:nspf shareContext:[m_nsContext openGLContext]];
|
||||
if (!m_loadCtx)
|
||||
Log.report(logvisor::Fatal, "unable to make load NSOpenGLContext");
|
||||
Log.report(logvisor::Fatal, fmt("unable to make load NSOpenGLContext"));
|
||||
}
|
||||
[m_loadCtx makeCurrentContext];
|
||||
return m_dataFactory.get();
|
||||
|
@ -349,7 +349,7 @@ IGraphicsContext* _GraphicsContextCocoaGLNew(IGraphicsContext::EGraphicsAPI api,
|
|||
minor = glVersion[2] - '0';
|
||||
}
|
||||
if (glewInit() != GLEW_OK)
|
||||
Log.report(logvisor::Fatal, "glewInit failed");
|
||||
Log.report(logvisor::Fatal, fmt("glewInit failed"));
|
||||
[NSOpenGLContext clearCurrentContext];
|
||||
if (!glVersion)
|
||||
return NULL;
|
||||
|
@ -412,7 +412,7 @@ public:
|
|||
MetalContext::Window& w = m_metalCtx->m_windows[m_parentWindow];
|
||||
m_nsContext = [[GraphicsContextCocoaMetalInternal alloc] initWithBooContext:this];
|
||||
if (!m_nsContext)
|
||||
Log.report(logvisor::Fatal, "unable to make new NSView for Metal");
|
||||
Log.report(logvisor::Fatal, fmt("unable to make new NSView for Metal"));
|
||||
w.m_metalLayer = (CAMetalLayer*) m_nsContext.layer;
|
||||
[(__bridge NSWindow*) (void*) m_parentWindow->getPlatformHandle() setContentView:m_nsContext];
|
||||
CVDisplayLinkCreateWithActiveCGDisplays(&m_dispLink);
|
||||
|
|
|
@ -74,7 +74,7 @@ public:
|
|||
std::shared_ptr<IWindow> m_window;
|
||||
std::shared_ptr<IWindow> newWindow(std::string_view title) {
|
||||
if (m_window)
|
||||
Log.report(logvisor::Fatal, "Only 1 window allowed on NX");
|
||||
Log.report(logvisor::Fatal, fmt("Only 1 window allowed on NX"));
|
||||
m_window = _WindowNXNew(title, &m_nxCtx);
|
||||
return m_window;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
#if _WIN32_WINNT_WIN10
|
||||
if (!no12) {
|
||||
if (!FindBestD3DCompile())
|
||||
Log.report(logvisor::Fatal, "unable to find D3DCompile_[43-47].dll");
|
||||
Log.report(logvisor::Fatal, fmt("unable to find D3DCompile_[43-47].dll"));
|
||||
|
||||
D3D12SerializeRootSignaturePROC = D3D12SerializeRootSignature;
|
||||
|
||||
|
@ -81,7 +81,7 @@ public:
|
|||
/* Obtain DXGI Factory */
|
||||
HRESULT hr = MyCreateDXGIFactory1(__uuidof(IDXGIFactory2), &m_3dCtx.m_ctx12.m_dxFactory);
|
||||
if (FAILED(hr))
|
||||
Log.report(logvisor::Fatal, "unable to create DXGI factory");
|
||||
Log.report(logvisor::Fatal, fmt("unable to create DXGI factory"));
|
||||
|
||||
/* Adapter */
|
||||
ComPtr<IDXGIAdapter1> ppAdapter;
|
||||
|
@ -106,26 +106,26 @@ public:
|
|||
/* Establish loader objects */
|
||||
if (FAILED(m_3dCtx.m_ctx12.m_dev->CreateCommandAllocator(
|
||||
D3D12_COMMAND_LIST_TYPE_DIRECT, __uuidof(ID3D12CommandAllocator), &m_3dCtx.m_ctx12.m_loadqalloc)))
|
||||
Log.report(logvisor::Fatal, "unable to create loader allocator");
|
||||
Log.report(logvisor::Fatal, fmt("unable to create loader allocator"));
|
||||
|
||||
D3D12_COMMAND_QUEUE_DESC desc = {D3D12_COMMAND_LIST_TYPE_DIRECT, D3D12_COMMAND_QUEUE_PRIORITY_NORMAL,
|
||||
D3D12_COMMAND_QUEUE_FLAG_NONE};
|
||||
if (FAILED(m_3dCtx.m_ctx12.m_dev->CreateCommandQueue(&desc, __uuidof(ID3D12CommandQueue),
|
||||
&m_3dCtx.m_ctx12.m_loadq)))
|
||||
Log.report(logvisor::Fatal, "unable to create loader queue");
|
||||
Log.report(logvisor::Fatal, fmt("unable to create loader queue"));
|
||||
|
||||
if (FAILED(m_3dCtx.m_ctx12.m_dev->CreateFence(0, D3D12_FENCE_FLAG_NONE, __uuidof(ID3D12Fence),
|
||||
&m_3dCtx.m_ctx12.m_loadfence)))
|
||||
Log.report(logvisor::Fatal, "unable to create loader fence");
|
||||
Log.report(logvisor::Fatal, fmt("unable to create loader fence"));
|
||||
|
||||
m_3dCtx.m_ctx12.m_loadfencehandle = CreateEvent(nullptr, FALSE, FALSE, nullptr);
|
||||
|
||||
if (FAILED(m_3dCtx.m_ctx12.m_dev->CreateCommandList(
|
||||
0, D3D12_COMMAND_LIST_TYPE_DIRECT, m_3dCtx.m_ctx12.m_loadqalloc.Get(), nullptr,
|
||||
__uuidof(ID3D12GraphicsCommandList), &m_3dCtx.m_ctx12.m_loadlist)))
|
||||
Log.report(logvisor::Fatal, "unable to create loader list");
|
||||
Log.report(logvisor::Fatal, fmt("unable to create loader list"));
|
||||
|
||||
Log.report(logvisor::Info, "initialized D3D12 renderer");
|
||||
Log.report(logvisor::Info, fmt("initialized D3D12 renderer"));
|
||||
return;
|
||||
} else {
|
||||
/* Some Win10 client HW doesn't support D3D12 (despite being supposedly HW-agnostic) */
|
||||
|
@ -136,7 +136,7 @@ public:
|
|||
#endif
|
||||
{
|
||||
if (!FindBestD3DCompile())
|
||||
Log.report(logvisor::Fatal, "unable to find D3DCompile_[43-47].dll");
|
||||
Log.report(logvisor::Fatal, fmt("unable to find D3DCompile_[43-47].dll"));
|
||||
|
||||
/* Create device proc */
|
||||
PFN_D3D11_CREATE_DEVICE MyD3D11CreateDevice = D3D11CreateDevice;
|
||||
|
@ -147,7 +147,7 @@ public:
|
|||
ComPtr<ID3D11DeviceContext> tempCtx;
|
||||
if (FAILED(MyD3D11CreateDevice(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, D3D11_CREATE_DEVICE_FLAGS, &level, 1,
|
||||
D3D11_SDK_VERSION, &tempDev, nullptr, &tempCtx)))
|
||||
Log.report(logvisor::Fatal, "unable to create D3D11 device");
|
||||
Log.report(logvisor::Fatal, fmt("unable to create D3D11 device"));
|
||||
|
||||
ComPtr<IDXGIDevice2> device;
|
||||
if (FAILED(tempDev.As<ID3D11Device1>(&m_3dCtx.m_ctx11.m_dev)) || !m_3dCtx.m_ctx11.m_dev ||
|
||||
|
@ -173,11 +173,11 @@ public:
|
|||
sampDesc.AddressW = D3D11_TEXTURE_ADDRESS_BORDER;
|
||||
m_3dCtx.m_ctx11.m_dev->CreateSamplerState(&sampDesc, &m_3dCtx.m_ctx11.m_ss[1]);
|
||||
|
||||
Log.report(logvisor::Info, "initialized D3D11 renderer");
|
||||
Log.report(logvisor::Info, fmt("initialized D3D11 renderer"));
|
||||
return;
|
||||
}
|
||||
|
||||
Log.report(logvisor::Fatal, "system doesn't support D3D11 or D3D12");
|
||||
Log.report(logvisor::Fatal, fmt("system doesn't support D3D11 or D3D12"));
|
||||
}
|
||||
|
||||
EPlatformType getPlatformType() const { return EPlatformType::UWP; }
|
||||
|
|
|
@ -96,12 +96,12 @@ public:
|
|||
|
||||
HMODULE dxgilib = LoadLibraryW(L"dxgi.dll");
|
||||
if (!dxgilib)
|
||||
Log.report(logvisor::Fatal, "unable to load dxgi.dll");
|
||||
Log.report(logvisor::Fatal, fmt("unable to load dxgi.dll"));
|
||||
|
||||
typedef HRESULT(WINAPI * CreateDXGIFactory1PROC)(REFIID riid, _COM_Outptr_ void** ppFactory);
|
||||
CreateDXGIFactory1PROC MyCreateDXGIFactory1 = (CreateDXGIFactory1PROC)GetProcAddress(dxgilib, "CreateDXGIFactory1");
|
||||
if (!MyCreateDXGIFactory1)
|
||||
Log.report(logvisor::Fatal, "unable to find CreateDXGIFactory1 in DXGI.dll\n");
|
||||
Log.report(logvisor::Fatal, fmt("unable to find CreateDXGIFactory1 in DXGI.dll\n"));
|
||||
|
||||
bool noD3d = false;
|
||||
#if BOO_HAS_VULKAN
|
||||
|
@ -149,13 +149,13 @@ public:
|
|||
d3d11lib = LoadLibraryW(L"D3D11.dll");
|
||||
if (d3d11lib) {
|
||||
if (!FindBestD3DCompile())
|
||||
Log.report(logvisor::Fatal, "unable to find D3DCompile_[43-47].dll");
|
||||
Log.report(logvisor::Fatal, fmt("unable to find D3DCompile_[43-47].dll"));
|
||||
|
||||
/* Create device proc */
|
||||
PFN_D3D11_CREATE_DEVICE MyD3D11CreateDevice =
|
||||
(PFN_D3D11_CREATE_DEVICE)GetProcAddress(d3d11lib, "D3D11CreateDevice");
|
||||
if (!MyD3D11CreateDevice)
|
||||
Log.report(logvisor::Fatal, "unable to find D3D11CreateDevice in D3D11.dll");
|
||||
Log.report(logvisor::Fatal, fmt("unable to find D3D11CreateDevice in D3D11.dll"));
|
||||
|
||||
/* Create device */
|
||||
D3D_FEATURE_LEVEL level = D3D_FEATURE_LEVEL_11_0;
|
||||
|
@ -163,7 +163,7 @@ public:
|
|||
ComPtr<ID3D11DeviceContext> tempCtx;
|
||||
if (FAILED(MyD3D11CreateDevice(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, D3D11_CREATE_DEVICE_FLAGS, &level, 1,
|
||||
D3D11_SDK_VERSION, &tempDev, nullptr, &tempCtx)))
|
||||
Log.report(logvisor::Fatal, "unable to create D3D11 device");
|
||||
Log.report(logvisor::Fatal, fmt("unable to create D3D11 device"));
|
||||
|
||||
ComPtr<IDXGIDevice2> device;
|
||||
if (FAILED(tempDev.As<ID3D11Device1>(&m_3dCtx.m_ctx11.m_dev)) || !m_3dCtx.m_ctx11.m_dev ||
|
||||
|
@ -214,7 +214,7 @@ public:
|
|||
sampDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_POINT;
|
||||
m_3dCtx.m_ctx11.m_dev->CreateSamplerState(&sampDesc, &m_3dCtx.m_ctx11.m_ss[4]);
|
||||
|
||||
Log.report(logvisor::Info, "initialized D3D11 renderer");
|
||||
Log.report(logvisor::Info, fmt("initialized D3D11 renderer"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -232,9 +232,9 @@ public:
|
|||
/* Obtain DXGI Factory */
|
||||
HRESULT hr = MyCreateDXGIFactory1(__uuidof(IDXGIFactory1), &m_3dCtx.m_vulkanDxFactory);
|
||||
if (FAILED(hr))
|
||||
Log.report(logvisor::Fatal, "unable to create DXGI factory");
|
||||
Log.report(logvisor::Fatal, fmt("unable to create DXGI factory"));
|
||||
|
||||
Log.report(logvisor::Info, "initialized Vulkan renderer");
|
||||
Log.report(logvisor::Info, fmt("initialized Vulkan renderer"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -249,13 +249,13 @@ public:
|
|||
/* Obtain DXGI Factory */
|
||||
HRESULT hr = MyCreateDXGIFactory1(__uuidof(IDXGIFactory1), &m_3dCtx.m_ctxOgl.m_dxFactory);
|
||||
if (FAILED(hr))
|
||||
Log.report(logvisor::Fatal, "unable to create DXGI factory");
|
||||
Log.report(logvisor::Fatal, fmt("unable to create DXGI factory"));
|
||||
|
||||
Log.report(logvisor::Info, "initialized OpenGL renderer");
|
||||
Log.report(logvisor::Info, fmt("initialized OpenGL renderer"));
|
||||
return;
|
||||
}
|
||||
|
||||
Log.report(logvisor::Fatal, "system doesn't support Vulkan, D3D11, or OpenGL");
|
||||
Log.report(logvisor::Fatal, fmt("system doesn't support Vulkan, D3D11, or OpenGL"));
|
||||
}
|
||||
|
||||
EPlatformType getPlatformType() const { return EPlatformType::Win32; }
|
||||
|
@ -429,7 +429,7 @@ public:
|
|||
if (GetCurrentThreadId() != g_mainThreadId) {
|
||||
std::unique_lock<std::mutex> lk(g_nwmt);
|
||||
if (!PostThreadMessageW(g_mainThreadId, WM_USER, WPARAM(&title), 0))
|
||||
Log.report(logvisor::Fatal, "PostThreadMessage error");
|
||||
Log.report(logvisor::Fatal, fmt("PostThreadMessage error"));
|
||||
g_nwcv.wait(lk);
|
||||
std::shared_ptr<IWindow> ret = std::move(m_mwret);
|
||||
m_mwret.reset();
|
||||
|
|
|
@ -80,7 +80,7 @@ public:
|
|||
HRESULT hr =
|
||||
b3dCtx.m_ctx12.m_dxFactory->CreateSwapChainForCoreWindow(cmdQueue, cw, &scDesc, nullptr, &m_swapChain);
|
||||
if (FAILED(hr))
|
||||
Log.report(logvisor::Fatal, "unable to create swap chain");
|
||||
Log.report(logvisor::Fatal, fmt("unable to create swap chain"));
|
||||
|
||||
m_swapChain.As<IDXGISwapChain3>(&w.m_swapChain);
|
||||
ComPtr<ID3D12Resource> fb;
|
||||
|
@ -91,13 +91,13 @@ public:
|
|||
w.height = resDesc.Height;
|
||||
|
||||
if (FAILED(m_swapChain->GetContainingOutput(&m_output)))
|
||||
Log.report(logvisor::Fatal, "unable to get DXGI output");
|
||||
Log.report(logvisor::Fatal, fmt("unable to get DXGI output"));
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
if (FAILED(b3dCtx.m_ctx11.m_dxFactory->CreateSwapChainForCoreWindow(b3dCtx.m_ctx11.m_dev.Get(), cw, &scDesc,
|
||||
nullptr, &m_swapChain)))
|
||||
Log.report(logvisor::Fatal, "unable to create swap chain");
|
||||
Log.report(logvisor::Fatal, fmt("unable to create swap chain"));
|
||||
|
||||
auto insIt = b3dCtx.m_ctx11.m_windows.emplace(std::make_pair(parentWindow, D3D11Context::Window()));
|
||||
D3D11Context::Window& w = insIt.first->second;
|
||||
|
@ -113,7 +113,7 @@ public:
|
|||
m_commandQueue = _NewD3D11CommandQueue(&b3dCtx.m_ctx11, &insIt.first->second, this);
|
||||
|
||||
if (FAILED(m_swapChain->GetContainingOutput(&m_output)))
|
||||
Log.report(logvisor::Fatal, "unable to get DXGI output");
|
||||
Log.report(logvisor::Fatal, fmt("unable to get DXGI output"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ public:
|
|||
scDesc.Format = b3dCtx.m_ctx11.m_fbFormat;
|
||||
if (FAILED(b3dCtx.m_ctx11.m_dxFactory->CreateSwapChainForHwnd(b3dCtx.m_ctx11.m_dev.Get(), hwnd, &scDesc, nullptr,
|
||||
nullptr, &m_swapChain)))
|
||||
Log.report(logvisor::Fatal, "unable to create swap chain");
|
||||
Log.report(logvisor::Fatal, fmt("unable to create swap chain"));
|
||||
b3dCtx.m_ctx11.m_dxFactory->MakeWindowAssociation(hwnd, DXGI_MWA_NO_ALT_ENTER);
|
||||
|
||||
auto insIt = b3dCtx.m_ctx11.m_windows.emplace(std::make_pair(parentWindow, D3D11Context::Window()));
|
||||
|
@ -85,7 +85,7 @@ public:
|
|||
m_commandQueue->startRenderer();
|
||||
|
||||
if (FAILED(m_swapChain->GetContainingOutput(&m_output)))
|
||||
Log.report(logvisor::Fatal, "unable to get DXGI output");
|
||||
Log.report(logvisor::Fatal, fmt("unable to get DXGI output"));
|
||||
}
|
||||
|
||||
~GraphicsContextWin32D3D() { m_3dCtx.m_ctx11.m_windows.erase(m_parentWindow); }
|
||||
|
@ -151,14 +151,14 @@ public:
|
|||
}
|
||||
|
||||
if (!m_output)
|
||||
Log.report(logvisor::Fatal, "unable to find window's IDXGIOutput");
|
||||
Log.report(logvisor::Fatal, fmt("unable to find window's IDXGIOutput"));
|
||||
|
||||
auto insIt = b3dCtx.m_ctxOgl.m_windows.emplace(std::make_pair(parentWindow, OGLContext::Window()));
|
||||
OGLContext::Window& w = insIt.first->second;
|
||||
w.m_hwnd = hwnd;
|
||||
w.m_deviceContext = GetDC(hwnd);
|
||||
if (!w.m_deviceContext)
|
||||
Log.report(logvisor::Fatal, "unable to create window's device context");
|
||||
Log.report(logvisor::Fatal, fmt("unable to create window's device context"));
|
||||
|
||||
if (!m_3dCtx.m_ctxOgl.m_lastContext) {
|
||||
PIXELFORMATDESCRIPTOR pfd = {sizeof(PIXELFORMATDESCRIPTOR),
|
||||
|
@ -195,7 +195,7 @@ public:
|
|||
HGLRC tmpCtx = wglCreateContext(w.m_deviceContext);
|
||||
wglMakeCurrent(w.m_deviceContext, tmpCtx);
|
||||
if (glewInit() != GLEW_OK)
|
||||
Log.report(logvisor::Fatal, "glewInit failed");
|
||||
Log.report(logvisor::Fatal, fmt("glewInit failed"));
|
||||
wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
|
||||
wglChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
|
||||
wglMakeCurrent(w.m_deviceContext, 0);
|
||||
|
@ -238,10 +238,10 @@ public:
|
|||
// w.m_mainContext = wglCreateContext(w.m_deviceContext);
|
||||
w.m_mainContext = wglCreateContextAttribsARB(w.m_deviceContext, 0, ContextAttribs);
|
||||
if (!w.m_mainContext)
|
||||
Log.report(logvisor::Fatal, "unable to create window's main context");
|
||||
Log.report(logvisor::Fatal, fmt("unable to create window's main context"));
|
||||
if (m_3dCtx.m_ctxOgl.m_lastContext)
|
||||
if (!wglShareLists(w.m_mainContext, m_3dCtx.m_ctxOgl.m_lastContext))
|
||||
Log.report(logvisor::Fatal, "unable to share contexts");
|
||||
Log.report(logvisor::Fatal, fmt("unable to share contexts"));
|
||||
m_3dCtx.m_ctxOgl.m_lastContext = w.m_mainContext;
|
||||
|
||||
m_dataFactory = _NewGLDataFactory(this, &b3dCtx.m_ctxOgl.m_glCtx);
|
||||
|
@ -268,13 +268,13 @@ public:
|
|||
void makeCurrent() {
|
||||
OGLContext::Window& w = m_3dCtx.m_ctxOgl.m_windows[m_parentWindow];
|
||||
// if (!wglMakeCurrent(w.m_deviceContext, w.m_mainContext))
|
||||
// Log.report(logvisor::Fatal, "unable to make WGL context current");
|
||||
// Log.report(logvisor::Fatal, fmt("unable to make WGL context current"));
|
||||
|
||||
w.m_renderContext = wglCreateContextAttribsARB(w.m_deviceContext, w.m_mainContext, ContextAttribs);
|
||||
if (!w.m_renderContext)
|
||||
Log.report(logvisor::Fatal, "unable to make new WGL context");
|
||||
Log.report(logvisor::Fatal, fmt("unable to make new WGL context"));
|
||||
if (!wglMakeCurrent(w.m_deviceContext, w.m_renderContext))
|
||||
Log.report(logvisor::Fatal, "unable to make WGL context current");
|
||||
Log.report(logvisor::Fatal, fmt("unable to make WGL context current"));
|
||||
}
|
||||
|
||||
void postInit() {
|
||||
|
@ -284,12 +284,12 @@ public:
|
|||
// wglGetProcAddress("wglCreateContextAttribsARB");
|
||||
// w.m_renderContext = wglCreateContextAttribsARB(w.m_deviceContext, w.m_mainContext, ContextAttribs);
|
||||
// if (!w.m_renderContext)
|
||||
// Log.report(logvisor::Fatal, "unable to make new WGL context");
|
||||
// Log.report(logvisor::Fatal, fmt("unable to make new WGL context"));
|
||||
// if (!wglMakeCurrent(w.m_deviceContext, w.m_renderContext))
|
||||
// Log.report(logvisor::Fatal, "unable to make WGL context current");
|
||||
// Log.report(logvisor::Fatal, fmt("unable to make WGL context current"));
|
||||
|
||||
if (!WGLEW_EXT_swap_control)
|
||||
Log.report(logvisor::Fatal, "WGL_EXT_swap_control not available");
|
||||
Log.report(logvisor::Fatal, fmt("WGL_EXT_swap_control not available"));
|
||||
wglSwapIntervalEXT(1);
|
||||
}
|
||||
|
||||
|
@ -309,10 +309,10 @@ public:
|
|||
if (!m_mainCtx) {
|
||||
m_mainCtx = wglCreateContextAttribsARB(w.m_deviceContext, w.m_mainContext, ContextAttribs);
|
||||
if (!m_mainCtx)
|
||||
Log.report(logvisor::Fatal, "unable to make main WGL context");
|
||||
Log.report(logvisor::Fatal, fmt("unable to make main WGL context"));
|
||||
}
|
||||
if (!wglMakeCurrent(w.m_deviceContext, m_mainCtx))
|
||||
Log.report(logvisor::Fatal, "unable to make main WGL context current");
|
||||
Log.report(logvisor::Fatal, fmt("unable to make main WGL context current"));
|
||||
return m_dataFactory.get();
|
||||
}
|
||||
|
||||
|
@ -323,10 +323,10 @@ public:
|
|||
if (!m_loadCtx) {
|
||||
m_loadCtx = wglCreateContextAttribsARB(w.m_deviceContext, w.m_mainContext, ContextAttribs);
|
||||
if (!m_loadCtx)
|
||||
Log.report(logvisor::Fatal, "unable to make load WGL context");
|
||||
Log.report(logvisor::Fatal, fmt("unable to make load WGL context"));
|
||||
}
|
||||
if (!wglMakeCurrent(w.m_deviceContext, m_loadCtx))
|
||||
Log.report(logvisor::Fatal, "unable to make load WGL context current");
|
||||
Log.report(logvisor::Fatal, fmt("unable to make load WGL context current"));
|
||||
return m_dataFactory.get();
|
||||
}
|
||||
};
|
||||
|
@ -348,7 +348,7 @@ struct GraphicsContextWin32Vulkan : GraphicsContextWin32 {
|
|||
|
||||
static void ThrowIfFailed(VkResult res) {
|
||||
if (res != VK_SUCCESS)
|
||||
Log.report(logvisor::Fatal, "%d\n", res);
|
||||
Log.report(logvisor::Fatal, fmt("%d\n"), res);
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -382,7 +382,7 @@ public:
|
|||
}
|
||||
|
||||
if (!m_output)
|
||||
Log.report(logvisor::Fatal, "unable to find window's IDXGIOutput");
|
||||
Log.report(logvisor::Fatal, fmt("unable to find window's IDXGIOutput"));
|
||||
}
|
||||
|
||||
void destroy() {
|
||||
|
@ -452,18 +452,18 @@ public:
|
|||
/* Generate error if could not find a queue that supports both a graphics
|
||||
* and present */
|
||||
if (m_ctx->m_graphicsQueueFamilyIndex == UINT32_MAX)
|
||||
Log.report(logvisor::Fatal, "Could not find a queue that supports both graphics and present");
|
||||
Log.report(logvisor::Fatal, fmt("Could not find a queue that supports both graphics and present"));
|
||||
|
||||
m_ctx->initDevice();
|
||||
} else {
|
||||
/* Subsequent window, verify present */
|
||||
if (supportsPresent[m_ctx->m_graphicsQueueFamilyIndex] == VK_FALSE)
|
||||
Log.report(logvisor::Fatal, "subsequent surface doesn't support present");
|
||||
Log.report(logvisor::Fatal, fmt("subsequent surface doesn't support present"));
|
||||
}
|
||||
free(supportsPresent);
|
||||
|
||||
if (!vk::GetPhysicalDeviceWin32PresentationSupportKHR(m_ctx->m_gpus[0], m_ctx->m_graphicsQueueFamilyIndex)) {
|
||||
Log.report(logvisor::Fatal, "Win32 doesn't support vulkan present");
|
||||
Log.report(logvisor::Fatal, fmt("Win32 doesn't support vulkan present"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -496,10 +496,10 @@ public:
|
|||
}
|
||||
}
|
||||
} else
|
||||
Log.report(logvisor::Fatal, "no surface formats available for Vulkan swapchain");
|
||||
Log.report(logvisor::Fatal, fmt("no surface formats available for Vulkan swapchain"));
|
||||
|
||||
if (m_format == VK_FORMAT_UNDEFINED)
|
||||
Log.report(logvisor::Fatal, "no UNORM formats available for Vulkan swapchain");
|
||||
Log.report(logvisor::Fatal, fmt("no UNORM formats available for Vulkan swapchain"));
|
||||
|
||||
m_ctx->initSwapChain(*m_windowCtx, m_surface, m_format, m_colorspace);
|
||||
|
||||
|
@ -724,7 +724,7 @@ static HGLOBAL MakeUnicodeCRLF(const char* data, size_t sz) {
|
|||
int32_t ch;
|
||||
int chSz = utf8proc_iterate(reinterpret_cast<const uint8_t*>(data + i), -1, &ch);
|
||||
if (chSz < 0)
|
||||
Log.report(logvisor::Fatal, "invalid UTF-8 char");
|
||||
Log.report(logvisor::Fatal, fmt("invalid UTF-8 char"));
|
||||
if (ch <= 0xffff) {
|
||||
if (ch == '\n' && lastCh != '\r')
|
||||
retSz += 4;
|
||||
|
@ -984,7 +984,7 @@ public:
|
|||
void _immSetOpenStatus(bool open) {
|
||||
if (GetCurrentThreadId() != g_mainThreadId) {
|
||||
if (!PostThreadMessageW(g_mainThreadId, WM_USER + 3, WPARAM(m_imc), LPARAM(open)))
|
||||
Log.report(logvisor::Fatal, "PostThreadMessage error");
|
||||
Log.report(logvisor::Fatal, fmt("PostThreadMessage error"));
|
||||
return;
|
||||
}
|
||||
ImmSetOpenStatus(m_imc, open);
|
||||
|
@ -999,7 +999,7 @@ public:
|
|||
|
||||
if (GetCurrentThreadId() != g_mainThreadId) {
|
||||
if (!PostThreadMessageW(g_mainThreadId, WM_USER + 4, WPARAM(m_imc), LPARAM(&m_cForm)))
|
||||
Log.report(logvisor::Fatal, "PostThreadMessage error");
|
||||
Log.report(logvisor::Fatal, fmt("PostThreadMessage error"));
|
||||
return;
|
||||
}
|
||||
ImmSetCompositionWindow(m_imc, &m_cForm);
|
||||
|
|
|
@ -29,15 +29,13 @@ class ScreenSaverInhibitor {
|
|||
DBusError err = DBUS_ERROR_INIT;
|
||||
if ((msg = dbus_pending_call_steal_reply(m_pending)) &&
|
||||
dbus_message_get_args(msg, &err, DBUS_TYPE_UINT32, &m_cookie, DBUS_TYPE_INVALID)) {
|
||||
Log.report(logvisor::Info, "Screen saver inhibited");
|
||||
Log.report(logvisor::Info, fmt("Screen saver inhibited"));
|
||||
} else {
|
||||
/* Fallback to xdg-screensaver */
|
||||
dbus_error_free(&err);
|
||||
Log.report(logvisor::Info, "Falling back to xdg-screensaver inhibit");
|
||||
Log.report(logvisor::Info, fmt("Falling back to xdg-screensaver inhibit"));
|
||||
if (!fork()) {
|
||||
char win_id[32];
|
||||
snprintf(win_id, 32, "0x%lX", m_wid);
|
||||
execlp("xdg-screensaver", "xdg-screensaver", "suspend", win_id, nullptr);
|
||||
execlp("xdg-screensaver", "xdg-screensaver", "suspend", fmt::format(fmt("0x{:X}"), m_wid).c_str(), nullptr);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
@ -98,18 +96,17 @@ DBusConnection* RegisterDBus(const char* appName, bool& isFirst) {
|
|||
/* connect to the bus and check for errors */
|
||||
DBusConnection* conn = dbus_bus_get(DBUS_BUS_SESSION, &err);
|
||||
if (dbus_error_is_set(&err)) {
|
||||
fprintf(stderr, "DBus Connection Error (%s)\n", err.message);
|
||||
fmt::print(stderr, fmt("DBus Connection Error ({})\n"), err.message);
|
||||
dbus_error_free(&err);
|
||||
}
|
||||
if (NULL == conn)
|
||||
return NULL;
|
||||
|
||||
/* request our name on the bus and check for errors */
|
||||
char busName[256];
|
||||
snprintf(busName, 256, "boo.%s.unique", appName);
|
||||
int ret = dbus_bus_request_name(conn, busName, DBUS_NAME_FLAG_DO_NOT_QUEUE, &err);
|
||||
int ret = dbus_bus_request_name(conn, fmt::format(fmt("boo.{}.unique"), appName).c_str(),
|
||||
DBUS_NAME_FLAG_DO_NOT_QUEUE, &err);
|
||||
if (dbus_error_is_set(&err)) {
|
||||
fprintf(stderr, "DBus Name Error (%s)\n", err.message);
|
||||
fmt::print(stderr, fmt("DBus Name Error ({})\n"), err.message);
|
||||
dbus_error_free(&err);
|
||||
dbus_connection_close(conn);
|
||||
return NULL;
|
||||
|
|
|
@ -236,10 +236,10 @@ public:
|
|||
loadVk();
|
||||
|
||||
if (m_getVkProc)
|
||||
Log.report(logvisor::Info, "using Vulkan renderer");
|
||||
Log.report(logvisor::Info, fmt("using Vulkan renderer"));
|
||||
else
|
||||
#endif
|
||||
Log.report(logvisor::Info, "using OpenGL renderer");
|
||||
Log.report(logvisor::Info, fmt("using OpenGL renderer"));
|
||||
|
||||
#ifndef BOO_MSAN
|
||||
/* DBus single instance registration */
|
||||
|
@ -279,7 +279,7 @@ public:
|
|||
#endif
|
||||
|
||||
if (!XInitThreads()) {
|
||||
Log.report(logvisor::Fatal, "X doesn't support multithreading");
|
||||
Log.report(logvisor::Fatal, fmt("X doesn't support multithreading"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -289,7 +289,7 @@ public:
|
|||
/* Open Xlib Display */
|
||||
m_xDisp = XOpenDisplay(0);
|
||||
if (!m_xDisp) {
|
||||
Log.report(logvisor::Fatal, "Can't open X display");
|
||||
Log.report(logvisor::Fatal, fmt("Can't open X display"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -297,18 +297,18 @@ public:
|
|||
/* Cast Display to XCB connection for vulkan */
|
||||
m_xcbConn = XGetXCBConnection(m_xDisp);
|
||||
if (!m_xcbConn) {
|
||||
Log.report(logvisor::Fatal, "Can't cast Display to XCB connection for Vulkan");
|
||||
Log.report(logvisor::Fatal, fmt("Can't cast Display to XCB connection for Vulkan"));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Configure locale */
|
||||
if (!XSupportsLocale()) {
|
||||
Log.report(logvisor::Fatal, "X does not support locale %s.", setlocale(LC_ALL, nullptr));
|
||||
Log.report(logvisor::Fatal, fmt("X does not support locale {}."), setlocale(LC_ALL, nullptr));
|
||||
return;
|
||||
}
|
||||
if (XSetLocaleModifiers("") == nullptr)
|
||||
Log.report(logvisor::Warning, "Cannot set locale modifiers.");
|
||||
Log.report(logvisor::Warning, fmt("Cannot set locale modifiers."));
|
||||
|
||||
if ((m_xIM = XOpenIM(m_xDisp, nullptr, nullptr, nullptr))) {
|
||||
char** missing_charsets;
|
||||
|
@ -337,7 +337,7 @@ public:
|
|||
}
|
||||
/* if we couldn't support any of them, print an error and exit */
|
||||
if (m_bestStyle == 0) {
|
||||
Log.report(logvisor::Fatal, "interaction style not supported.");
|
||||
Log.report(logvisor::Fatal, fmt("interaction style not supported."));
|
||||
return;
|
||||
}
|
||||
XFree(im_supported_styles);
|
||||
|
|
|
@ -303,7 +303,7 @@ public:
|
|||
int numFBConfigs = 0;
|
||||
fbConfigs = glXGetFBConfigs(display, defaultScreen, &numFBConfigs);
|
||||
if (!fbConfigs || numFBConfigs == 0) {
|
||||
Log.report(logvisor::Fatal, "glXGetFBConfigs failed");
|
||||
Log.report(logvisor::Fatal, fmt("glXGetFBConfigs failed"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -349,7 +349,7 @@ public:
|
|||
XFree(fbConfigs);
|
||||
|
||||
if (!m_fbconfig) {
|
||||
Log.report(logvisor::Fatal, "unable to find suitable pixel format");
|
||||
Log.report(logvisor::Fatal, fmt("unable to find suitable pixel format"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -392,7 +392,7 @@ public:
|
|||
glXCreateContextAttribsARB =
|
||||
(glXCreateContextAttribsARBProc)glXGetProcAddressARB((const GLubyte*)"glXCreateContextAttribsARB");
|
||||
if (!glXCreateContextAttribsARB)
|
||||
Log.report(logvisor::Fatal, "unable to resolve glXCreateContextAttribsARB");
|
||||
Log.report(logvisor::Fatal, fmt("unable to resolve glXCreateContextAttribsARB"));
|
||||
}
|
||||
|
||||
s_glxError = false;
|
||||
|
@ -404,16 +404,16 @@ public:
|
|||
}
|
||||
XSetErrorHandler(oldHandler);
|
||||
if (!m_glxCtx)
|
||||
Log.report(logvisor::Fatal, "unable to make new GLX context");
|
||||
Log.report(logvisor::Fatal, fmt("unable to make new GLX context"));
|
||||
m_glxWindow = glXCreateWindow(m_xDisp, m_fbconfig, m_parentWindow->getPlatformHandle(), nullptr);
|
||||
if (!m_glxWindow)
|
||||
Log.report(logvisor::Fatal, "unable to make new GLX window");
|
||||
Log.report(logvisor::Fatal, fmt("unable to make new GLX window"));
|
||||
_XlibUpdateLastGlxCtx(m_glxCtx);
|
||||
|
||||
if (!glXMakeCurrent(m_xDisp, DefaultRootWindow(m_xDisp), m_glxCtx))
|
||||
Log.report(logvisor::Fatal, "unable to make GLX context current");
|
||||
Log.report(logvisor::Fatal, fmt("unable to make GLX context current"));
|
||||
if (glewInit() != GLEW_OK)
|
||||
Log.report(logvisor::Fatal, "glewInit failed");
|
||||
Log.report(logvisor::Fatal, fmt("glewInit failed"));
|
||||
glXMakeCurrent(m_xDisp, 0, 0);
|
||||
|
||||
XUnlockDisplay(m_xDisp);
|
||||
|
@ -427,7 +427,7 @@ public:
|
|||
void makeCurrent() {
|
||||
XLockDisplay(m_xDisp);
|
||||
if (!glXMakeContextCurrent(m_xDisp, m_glxWindow, m_glxWindow, m_glxCtx))
|
||||
Log.report(logvisor::Fatal, "unable to make GLX context current");
|
||||
Log.report(logvisor::Fatal, fmt("unable to make GLX context current"));
|
||||
XUnlockDisplay(m_xDisp);
|
||||
}
|
||||
|
||||
|
@ -450,10 +450,10 @@ public:
|
|||
m_mainCtx = glXCreateContextAttribsARB(m_xDisp, m_fbconfig, m_glxCtx, true, ContextAttribList[m_attribIdx]);
|
||||
XSetErrorHandler(oldHandler);
|
||||
if (!m_mainCtx)
|
||||
Log.report(logvisor::Fatal, "unable to make main GLX context");
|
||||
Log.report(logvisor::Fatal, fmt("unable to make main GLX context"));
|
||||
}
|
||||
if (!glXMakeContextCurrent(m_xDisp, m_glxWindow, m_glxWindow, m_mainCtx))
|
||||
Log.report(logvisor::Fatal, "unable to make main GLX context current");
|
||||
Log.report(logvisor::Fatal, fmt("unable to make main GLX context current"));
|
||||
XUnlockDisplay(m_xDisp);
|
||||
return getDataFactory();
|
||||
}
|
||||
|
@ -466,10 +466,10 @@ public:
|
|||
m_loadCtx = glXCreateContextAttribsARB(m_xDisp, m_fbconfig, m_glxCtx, true, ContextAttribList[m_attribIdx]);
|
||||
XSetErrorHandler(oldHandler);
|
||||
if (!m_loadCtx)
|
||||
Log.report(logvisor::Fatal, "unable to make load GLX context");
|
||||
Log.report(logvisor::Fatal, fmt("unable to make load GLX context"));
|
||||
}
|
||||
if (!glXMakeContextCurrent(m_xDisp, m_glxWindow, m_glxWindow, m_loadCtx))
|
||||
Log.report(logvisor::Fatal, "unable to make load GLX context current");
|
||||
Log.report(logvisor::Fatal, fmt("unable to make load GLX context current"));
|
||||
XUnlockDisplay(m_xDisp);
|
||||
return getDataFactory();
|
||||
}
|
||||
|
@ -493,7 +493,7 @@ struct GraphicsContextXlibVulkan : GraphicsContextXlib {
|
|||
|
||||
static void ThrowIfFailed(VkResult res) {
|
||||
if (res != VK_SUCCESS)
|
||||
Log.report(logvisor::Fatal, "%d\n", res);
|
||||
Log.report(logvisor::Fatal, fmt("{}\n"), res);
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -577,19 +577,19 @@ public:
|
|||
/* Generate error if could not find a queue that supports both a graphics
|
||||
* and present */
|
||||
if (m_ctx->m_graphicsQueueFamilyIndex == UINT32_MAX)
|
||||
Log.report(logvisor::Fatal, "Could not find a queue that supports both graphics and present");
|
||||
Log.report(logvisor::Fatal, fmt("Could not find a queue that supports both graphics and present"));
|
||||
|
||||
m_ctx->initDevice();
|
||||
} else {
|
||||
/* Subsequent window, verify present */
|
||||
if (supportsPresent[m_ctx->m_graphicsQueueFamilyIndex] == VK_FALSE)
|
||||
Log.report(logvisor::Fatal, "subsequent surface doesn't support present");
|
||||
Log.report(logvisor::Fatal, fmt("subsequent surface doesn't support present"));
|
||||
}
|
||||
free(supportsPresent);
|
||||
|
||||
if (!vk::GetPhysicalDeviceXcbPresentationSupportKHR(m_ctx->m_gpus[0], m_ctx->m_graphicsQueueFamilyIndex, m_xcbConn,
|
||||
m_visualid)) {
|
||||
Log.report(logvisor::Fatal, "XCB visual doesn't support vulkan present");
|
||||
Log.report(logvisor::Fatal, fmt("XCB visual doesn't support vulkan present"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -623,10 +623,10 @@ public:
|
|||
}
|
||||
}
|
||||
} else
|
||||
Log.report(logvisor::Fatal, "no surface formats available for Vulkan swapchain");
|
||||
Log.report(logvisor::Fatal, fmt("no surface formats available for Vulkan swapchain"));
|
||||
|
||||
if (m_format == VK_FORMAT_UNDEFINED)
|
||||
Log.report(logvisor::Fatal, "no UNORM formats available for Vulkan swapchain");
|
||||
Log.report(logvisor::Fatal, fmt("no UNORM formats available for Vulkan swapchain"));
|
||||
|
||||
m_ctx->initSwapChain(*m_windowCtx, m_surface, m_format, m_colorspace);
|
||||
|
||||
|
@ -1179,13 +1179,13 @@ public:
|
|||
|
||||
if (XGetWindowProperty(m_xDisp, m_windowId, S_ATOMS->m_clipdata, 0, 32, false, AnyPropertyType, &type,
|
||||
&format, &nitems, &rem, &data)) {
|
||||
Log.report(logvisor::Fatal, "Clipboard allocation failed");
|
||||
Log.report(logvisor::Fatal, fmt("Clipboard allocation failed"));
|
||||
XUnlockDisplay(m_xDisp);
|
||||
return {};
|
||||
}
|
||||
|
||||
if (rem != 0) {
|
||||
Log.report(logvisor::Fatal, "partial clipboard read");
|
||||
Log.report(logvisor::Fatal, fmt("partial clipboard read"));
|
||||
XUnlockDisplay(m_xDisp);
|
||||
return {};
|
||||
}
|
||||
|
@ -1603,7 +1603,7 @@ public:
|
|||
getWindowFrame(m_wrect.location[0], m_wrect.location[1], m_wrect.size[0], m_wrect.size[1]);
|
||||
switch (event->xgeneric.evtype) {
|
||||
case XI_Motion: {
|
||||
fprintf(stderr, "motion\n");
|
||||
fmt::print(stderr, fmt("motion\n"));
|
||||
|
||||
XIDeviceEvent* ev = (XIDeviceEvent*)event;
|
||||
if (m_lastInputID != ev->deviceid)
|
||||
|
|
2
logvisor
2
logvisor
|
@ -1 +1 @@
|
|||
Subproject commit a0ef17d895ba655ade171f76a984663639a1d390
|
||||
Subproject commit 3bedd268e86fa8c4e83eb5dd45755732a32acdcd
|
Loading…
Reference in New Issue