Merge pull request #19530 from hrydgard/even-more-misc-fixes

Even more misc fixes: Beaterator, sharp bilinear, remove back button
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2024-10-16 10:21:54 +02:00
commit ae640f88de
10 files changed
+111 -94

No files matched your search

+6 -6
View File
@@ -403,7 +403,7 @@ u32 SymbolMap::GetNextSymbolAddress(u32 address, SymbolType symmask) {
std::string SymbolMap::GetDescription(unsigned int address) {
std::lock_guard<std::recursive_mutex> guard(lock_);
const char* labelName = NULL;
const char *labelName = nullptr;
u32 funcStart = GetFunctionStart(address);
if (funcStart != INVALID_ADDRESS) {
@@ -414,11 +414,11 @@ std::string SymbolMap::GetDescription(unsigned int address) {
labelName = GetLabelName(dataStart);
}
if (labelName != NULL)
if (labelName)
return labelName;
char descriptionTemp[256];
sprintf(descriptionTemp, "(%08x)", address);
char descriptionTemp[32];
snprintf(descriptionTemp, sizeof(descriptionTemp), "(%08x)", address);
return descriptionTemp;
}
@@ -435,7 +435,7 @@ std::vector<SymbolEntry> SymbolMap::GetAllSymbols(SymbolType symmask) {
entry.address = it->first;
entry.size = GetFunctionSize(entry.address);
const char* name = GetLabelName(entry.address);
if (name != NULL)
if (name)
entry.name = name;
result.push_back(entry);
}
@@ -448,7 +448,7 @@ std::vector<SymbolEntry> SymbolMap::GetAllSymbols(SymbolType symmask) {
entry.address = it->first;
entry.size = GetDataSize(entry.address);
const char* name = GetLabelName(entry.address);
if (name != NULL)
if (name)
entry.name = name;
result.push_back(entry);
}
+1 -1
View File
@@ -58,7 +58,7 @@ public:
const char *GetTypeName() override { return GetStaticTypeName(); }
static const char *GetStaticTypeName() { return "EventFlag"; }
void GetQuickInfo(char *ptr, int size) override {
sprintf(ptr, "init=%08x cur=%08x numwait=%i",
snprintf(ptr, size, "init=%08x cur=%08x numwait=%i",
nef.initPattern,
nef.currentPattern,
nef.numWaitThreads);
+3 -5
View File
@@ -275,10 +275,8 @@ public:
const char *GetName() override { return nm.name; }
const char *GetTypeName() override { return GetStaticTypeName(); }
static const char *GetStaticTypeName() { return "Module"; }
void GetQuickInfo(char *ptr, int size) override
{
// ignore size
sprintf(ptr, "%sname=%s gp=%08x entry=%08x",
void GetQuickInfo(char *ptr, int size) override {
snprintf(ptr, size, "%sname=%s gp=%08x entry=%08x",
isFake ? "faked " : "",
nm.name,
nm.gp_value,
@@ -394,7 +392,7 @@ public:
// Add the symbol to the symbol map for debugging.
char temp[256];
sprintf(temp,"zz_%s", GetFuncName(func.moduleName, func.nid));
snprintf(temp, sizeof(temp), "zz_%s", GetFuncName(func.moduleName, func.nid));
g_symbolMap->AddFunction(temp,func.stubAddr,8);
// Keep track and actually hook it up if possible.
+4 -4
View File
@@ -140,7 +140,7 @@ public:
static const char *GetStaticTypeName() { return "CallBack"; }
void GetQuickInfo(char *ptr, int size) override {
sprintf(ptr, "thread=%i, argument= %08x",
snprintf(ptr, size, "thread=%i, argument= %08x",
//hackAddress,
nc.threadId,
nc.commonArgument);
@@ -378,7 +378,7 @@ public:
const char *GetTypeName() override { return GetStaticTypeName(); }
static const char *GetStaticTypeName() { return "Thread"; }
void GetQuickInfo(char *ptr, int size) override {
sprintf(ptr, "pc= %08x sp= %08x %s %s %s %s %s %s (wt=%i wid=%i wv= %08x )",
snprintf(ptr, size, "pc= %08x sp= %08x %s %s %s %s %s %s (wt=%i wid=%i wv= %08x )",
context.pc, context.r[MIPS_REG_SP],
(nt.status & THREADSTATUS_RUNNING) ? "RUN" : "",
(nt.status & THREADSTATUS_READY) ? "READY" : "",
@@ -1699,7 +1699,7 @@ static void __ReportThreadQueueEmpty() {
idleThread0->GetQuickInfo(idleDescription0, sizeof(idleDescription0));
idleStatus0 = idleThread0->nt.status;
} else {
sprintf(idleDescription0, "DELETED");
truncate_cpy(idleDescription0, "DELETED");
}
char idleDescription1[256];
@@ -1708,7 +1708,7 @@ static void __ReportThreadQueueEmpty() {
idleThread1->GetQuickInfo(idleDescription1, sizeof(idleDescription1));
idleStatus1 = idleThread1->nt.status;
} else {
sprintf(idleDescription1, "DELETED");
truncate_cpy(idleDescription1, "DELETED");
}
ERROR_LOG_REPORT_ONCE(threadqueueempty, Log::sceKernel, "Failed to reschedule: out of threads on queue (%d, %d)", idleStatus0, idleStatus1);
+35 -56
View File
@@ -76,7 +76,7 @@ static void __MicBlockingResume(u64 userdata, int cyclesLate) {
CoreTiming::ScheduleEvent(usToCycles(waitTimeus), eventMicBlockingResume, userdata);
}
} else {
for (u32 i = 0; i < waitingThread.needSize; i++) {
for (int i = 0; i < waitingThread.needSize; i++) {
if (Memory::IsValidAddress(waitingThread.addr + i)) {
Memory::Write_U8(i & 0xFF, waitingThread.addr + i);
}
@@ -159,7 +159,7 @@ void __UsbMicDoState(PointerWrap &p) {
}
}
QueueBuf::QueueBuf(u32 size) : available(0), end(0), capacity(size) {
QueueBuf::QueueBuf(int size) : available(0), end(0), capacity(size) {
buf_ = new u8[size];
}
@@ -167,32 +167,12 @@ QueueBuf::~QueueBuf() {
delete[] buf_;
}
QueueBuf::QueueBuf(const QueueBuf &buf) {
buf_ = new u8[buf.capacity];
memcpy(buf_, buf.buf_, buf.capacity);
available = buf.available;
end = buf.end;
capacity = buf.capacity;
}
QueueBuf& QueueBuf::operator=(const QueueBuf &buf) {
if (capacity < buf.capacity) {
resize(buf.capacity);
}
std::unique_lock<std::mutex> lock(mutex);
memcpy(buf_, buf.buf_, buf.capacity);
available = buf.available;
end = buf.end;
lock.unlock();
return *this;
}
u32 QueueBuf::push(u8 *buf, u32 size) {
u32 addedSize = 0;
int QueueBuf::push(const u8 *buf, int size) {
int addedSize = 0;
// This will overwrite the old data if the size prepare to add more than remaining size.
std::unique_lock<std::recursive_mutex> lock(mutex);
if (size > capacity)
resize(size);
// This will overwrite the old data if the size prepare to add more than remaining size.
std::unique_lock<std::mutex> lock(mutex);
while (end + size > capacity) {
memcpy(buf_ + end, buf + addedSize, capacity - end);
addedSize += capacity - end;
@@ -207,29 +187,33 @@ u32 QueueBuf::push(u8 *buf, u32 size) {
return addedSize;
}
u32 QueueBuf::pop(u8 *buf, u32 size) {
u32 ret = 0;
int QueueBuf::pop(u8 *buf, int size) {
if (size == 0) {
return 0;
}
int ret = 0;
std::unique_lock<std::recursive_mutex> lock(mutex);
if (getAvailableSize() < size)
size = getAvailableSize();
ret = size;
std::unique_lock<std::mutex> lock(mutex);
if (getStartPos() + size <= capacity) {
memcpy(buf, buf_ + getStartPos(), size);
int startPos = getStartPos();
if (startPos + size <= capacity) {
memcpy(buf, buf_ + startPos, size);
} else {
memcpy(buf, buf_ + getStartPos(), capacity - getStartPos());
memcpy(buf + capacity - getStartPos(), buf_, size - (capacity - getStartPos()));
memcpy(buf, buf_ + startPos, capacity - startPos);
memcpy(buf + capacity - startPos, buf_, size - (capacity - startPos));
}
available -= size;
lock.unlock();
return ret;
}
void QueueBuf::resize(u32 newSize) {
void QueueBuf::resize(int newSize) {
if (capacity >= newSize) {
return;
}
u32 availableSize = getAvailableSize();
int availableSize = getAvailableSize();
u8 *oldbuf = buf_;
buf_ = new u8[newSize];
@@ -241,21 +225,17 @@ void QueueBuf::resize(u32 newSize) {
}
void QueueBuf::flush() {
std::unique_lock<std::mutex> lock(mutex);
std::unique_lock<std::recursive_mutex> lock(mutex);
available = 0;
end = 0;
lock.unlock();
}
u32 QueueBuf::getAvailableSize() {
return available;
}
u32 QueueBuf::getRemainingSize() {
int QueueBuf::getRemainingSize() const {
return capacity - getAvailableSize();
}
u32 QueueBuf::getStartPos() {
int QueueBuf::getStartPos() const {
return end >= available ? end - available : capacity - available + end;
}
@@ -293,7 +273,7 @@ static int sceUsbMicInput(u32 maxSamples, u32 sampleRate, u32 bufAddr) {
return -1;
}
ERROR_LOG(Log::HLE, "UNTEST sceUsbMicInput: maxSamples: %d, samplerate: %d, bufAddr: %08x", maxSamples, sampleRate, bufAddr);
WARN_LOG(Log::HLE, "UNTEST sceUsbMicInput: maxSamples: %d, samplerate: %d, bufAddr: %08x", maxSamples, sampleRate, bufAddr);
if (maxSamples <= 0 || (maxSamples & 0x3F) != 0) {
return SCE_USBMIC_ERROR_INVALID_MAX_SAMPLES;
}
@@ -304,6 +284,7 @@ static int sceUsbMicInput(u32 maxSamples, u32 sampleRate, u32 bufAddr) {
return __MicInput(maxSamples, sampleRate, bufAddr, USBMIC, false);
}
static int sceUsbMicGetInputLength() {
int ret = Microphone::getReadMicDataLength() / 2;
ERROR_LOG(Log::HLE, "UNTEST sceUsbMicGetInputLength(ret: %d)", ret);
@@ -317,7 +298,8 @@ static int sceUsbMicInputInit(int unknown1, int inputVolume, int unknown2) {
static int sceUsbMicWaitInputEnd() {
ERROR_LOG(Log::HLE, "UNIMPL sceUsbMicWaitInputEnd");
return 0;
// Hack: Just task switch so other threads get to do work. Helps Beaterator (although recording does not appear to work correctly).
return hleDelayResult(0, "MicWait", 100);
}
int Microphone::startMic(void *param) {
@@ -364,24 +346,24 @@ bool Microphone::isNeedInput() {
return ::isNeedInput;
}
u32 Microphone::numNeedSamples() {
int Microphone::numNeedSamples() {
return ::numNeedSamples;
}
u32 Microphone::availableAudioBufSize() {
int Microphone::availableAudioBufSize() {
return audioBuf->getAvailableSize();
}
u32 Microphone::getReadMicDataLength() {
int Microphone::getReadMicDataLength() {
return ::readMicDataLength;
}
int Microphone::addAudioData(u8 *buf, u32 size) {
int Microphone::addAudioData(u8 *buf, int size) {
if (!audioBuf)
return 0;
audioBuf->push(buf, size);
u32 addSize = std::min(audioBuf->getAvailableSize(), numNeedSamples() * 2 - getReadMicDataLength());
int addSize = std::min(audioBuf->getAvailableSize(), numNeedSamples() * 2 - getReadMicDataLength());
if (Memory::IsValidRange(curTargetAddr + readMicDataLength, addSize)) {
getAudioData(Memory::GetPointerWriteUnchecked(curTargetAddr + readMicDataLength), addSize);
NotifyMemInfo(MemBlockFlags::WRITE, curTargetAddr + readMicDataLength, addSize, "MicAddAudioData");
@@ -391,10 +373,9 @@ int Microphone::addAudioData(u8 *buf, u32 size) {
return size;
}
u32 Microphone::getAudioData(u8 *buf, u32 size) {
int Microphone::getAudioData(u8 *buf, int size) {
if(audioBuf)
return audioBuf->pop(buf, size);
return 0;
}
@@ -423,7 +404,7 @@ u32 __MicInput(u32 maxSamples, u32 sampleRate, u32 bufAddr, MICTYPE type, bool b
curSampleRate = sampleRate;
curChannels = 1;
curTargetAddr = bufAddr;
u32 size = maxSamples << 1;
int size = maxSamples << 1;
if (!audioBuf) {
audioBuf = new QueueBuf(size);
} else {
@@ -460,8 +441,7 @@ u32 __MicInput(u32 maxSamples, u32 sampleRate, u32 bufAddr, MICTYPE type, bool b
return type == CAMERAMIC ? size : maxSamples;
}
const HLEFunction sceUsbMic[] =
{
const HLEFunction sceUsbMic[] = {
{0x06128E42, &WrapI_V<sceUsbMicPollInputEnd>, "sceUsbMicPollInputEnd", 'i', "" },
{0x2E6DCDCD, &WrapI_UUU<sceUsbMicInputBlocking>, "sceUsbMicInputBlocking", 'i', "xxx" },
{0x45310F07, &WrapI_U<sceUsbMicInputInitEx>, "sceUsbMicInputInitEx", 'i', "x" },
@@ -471,7 +451,6 @@ const HLEFunction sceUsbMic[] =
{0xF899001C, &WrapI_V<sceUsbMicWaitInputEnd>, "sceUsbMicWaitInputEnd", 'i', "" },
};
void Register_sceUsbMic()
{
void Register_sceUsbMic() {
RegisterModule("sceUsbMic", ARRAY_SIZE(sceUsbMic), sceUsbMic);
}
+23 -21
View File
@@ -35,35 +35,38 @@ enum MICTYPE {
struct MicWaitInfo {
SceUID threadID;
u32 addr;
u32 needSize;
int needSize;
u32 sampleRate;
};
class QueueBuf {
public:
QueueBuf(u32 size);
QueueBuf(int size);
~QueueBuf();
QueueBuf(const QueueBuf &buf);
QueueBuf& operator=(const QueueBuf &buf);
QueueBuf(const QueueBuf &buf) = delete;
QueueBuf& operator=(const QueueBuf &buf) = delete;
u32 push(u8 *buf, u32 size);
u32 pop(u8 *buf, u32 size);
void resize(u32 newSize);
int push(const u8 *buf, int size);
int pop(u8 *buf, int size);
void resize(int newSize);
void flush();
u32 getAvailableSize();
u32 getRemainingSize();
u32 getStartPos();
u32 getCapacity() const {
int getAvailableSize() const {
return available;
}
int getRemainingSize() const;
int getStartPos() const;
int getCapacity() const {
return capacity;
}
private:
u32 available;
u32 end;
u32 capacity;
int available = 0;
int end = 0;
int capacity; // set in constructor
u8 *buf_;
std::mutex mutex;
// TODO: Turn back to a regular mutex, will take some refactoring.
std::recursive_mutex mutex;
};
namespace Microphone {
@@ -71,13 +74,12 @@ namespace Microphone {
int stopMic();
bool isHaveDevice();
bool isMicStarted();
u32 numNeedSamples();
u32 availableAudioBufSize();
u32 getReadMicDataLength();
int numNeedSamples();
int availableAudioBufSize();
int getReadMicDataLength();
int addAudioData(u8 *buf, u32 size);
u32 getAudioData(u8 *buf, u32 size);
int addAudioData(u8 *buf, int size);
int getAudioData(u8 *buf, int size);
void flushAudioData();
std::vector<std::string> getDeviceList();
-1
View File
@@ -112,7 +112,6 @@ void InstallZipScreen::CreateViews() {
installChoice_ = rightColumnItems->Add(new Choice(iz->T("Install")));
installChoice_->OnClick.Handle(this, &InstallZipScreen::OnInstall);
backChoice_ = rightColumnItems->Add(new Choice(di->T("Back")));
showDeleteCheckbox = true;
} else if (zipFileInfo_.contents == ZipFileContents::SAVE_DATA) {
+5
View File
@@ -243,3 +243,8 @@ SettingDefaultValue1=0.4
SettingMaxValue1=0.8
SettingMinValue1=0.3
SettingStep1=0.05
[UpscaleSharpBilinear]
Name=Sharp Bilinear Upscaler
Fragment=upscale_sharp_bilinear.fsh
Vertex=upscale_sharp_bilinear.vsh
OutputResolution=True
+25
View File
@@ -0,0 +1,25 @@
#ifdef GL_ES
#extension GL_OES_standard_derivatives : enable
precision mediump float;
precision mediump int;
#endif
uniform sampler2D sampler0;
varying vec2 v_position;
uniform vec2 u_texelDelta; // (1.0 / bufferWidth, 1.0 / bufferHeight)
uniform vec2 u_pixelDelta; // (1.0 / targetWidth, 1.0 / targetHeight)
// Returns pixel sharpened to nearest pixel boundary.
vec2 sharpSample(vec4 texSize, vec2 coord) {
vec2 boxSize = clamp(fwidth(coord) * texSize.zw, 1e-5, 1.0);
coord = coord * texSize.zw - 0.5 * boxSize;
vec2 txOffset = smoothstep(vec2(1.0) - boxSize, vec2(1.0), fract(coord));
return (floor(coord) + 0.5 + txOffset) * texSize.xy;
}
void main() {
vec2 sharpPos = sharpSample(vec4(u_texelDelta, 1.0 / u_texelDelta), v_position);
vec4 color = texture2D(sampler0, sharpPos);
gl_FragColor = color;
}
@@ -0,0 +1,9 @@
attribute vec4 a_position;
attribute vec2 a_texcoord0;
varying vec2 v_position;
void main() {
gl_Position = a_position;
v_position = a_texcoord0;
}