mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-11-13 09:39:33 +01:00
Merge pull request #18800 from hrydgard/last-minute-fixes
Even more checks and fixes
This commit is contained in:
14 files changed
+76
-54
No files matched your search
@@ -8,9 +8,7 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef _DEBUG
|
||||
#include "Common/Log.h"
|
||||
#endif
|
||||
|
||||
template<class T>
|
||||
class FastVec {
|
||||
@@ -19,6 +17,7 @@ public:
|
||||
FastVec(size_t initialCapacity) {
|
||||
capacity_ = initialCapacity;
|
||||
data_ = (T *)malloc(initialCapacity * sizeof(T));
|
||||
_assert_(data_ != nullptr);
|
||||
}
|
||||
~FastVec() { if (data_) free(data_); }
|
||||
|
||||
@@ -157,6 +156,7 @@ private:
|
||||
return;
|
||||
T *oldData = data_;
|
||||
data_ = (T *)malloc(sizeof(T) * newCapacity);
|
||||
_assert_msg_(data_ != nullptr, "%d", (int)newCapacity);
|
||||
if (capacity_ != 0) {
|
||||
memcpy(data_, oldData, sizeof(T) * size_);
|
||||
free(oldData);
|
||||
@@ -165,6 +165,8 @@ private:
|
||||
}
|
||||
|
||||
void ExtendByOne() {
|
||||
// We don't really extend capacity by one though - instead we use
|
||||
// the usual doubling amortization.
|
||||
size_t newCapacity = capacity_ * 2;
|
||||
if (newCapacity < 16) {
|
||||
newCapacity = 16;
|
||||
|
||||
@@ -203,7 +203,6 @@ void GLPushBuffer::Defragment() {
|
||||
info.localMemory = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, int w, int h, int depth, i
|
||||
res = vkCreateImageView(vulkan_->GetDevice(), &view_info, NULL, &view_);
|
||||
if (res != VK_SUCCESS) {
|
||||
ERROR_LOG(G3D, "vkCreateImageView failed: %s. Destroying image.", VulkanResultToString(res));
|
||||
_assert_(res == VK_ERROR_OUT_OF_HOST_MEMORY || res == VK_ERROR_OUT_OF_DEVICE_MEMORY || res == VK_ERROR_TOO_MANY_OBJECTS);
|
||||
_assert_msg_(res == VK_ERROR_OUT_OF_HOST_MEMORY || res == VK_ERROR_OUT_OF_DEVICE_MEMORY || res == VK_ERROR_TOO_MANY_OBJECTS, "%d", (int)res);
|
||||
vmaDestroyImage(vulkan_->Allocator(), image_, allocation_);
|
||||
view_ = VK_NULL_HANDLE;
|
||||
image_ = VK_NULL_HANDLE;
|
||||
@@ -152,7 +152,7 @@ bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, int w, int h, int depth, i
|
||||
view_info.viewType = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
|
||||
res = vkCreateImageView(vulkan_->GetDevice(), &view_info, NULL, &arrayView_);
|
||||
// Assume that if the above view creation succeeded, so will this.
|
||||
_assert_(res == VK_SUCCESS);
|
||||
_assert_msg_(res == VK_SUCCESS, "View creation failed: %d", (int)res);
|
||||
vulkan_->SetDebugName(arrayView_, VK_OBJECT_TYPE_IMAGE_VIEW, tag_);
|
||||
}
|
||||
|
||||
|
||||
@@ -1317,9 +1317,15 @@ void VulkanRenderManager::BlitFramebuffer(VKRFramebuffer *src, VkRect2D srcRect,
|
||||
EndCurRenderStep();
|
||||
|
||||
// Sanity check. Added an assert to try to gather more info.
|
||||
// Got this assert in NPJH50443 FINAL FANTASY TYPE-0, but pretty rare. Moving back to debug assert.
|
||||
if (aspectMask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) {
|
||||
_assert_msg_(src->depth.image != VK_NULL_HANDLE, "%s", src->Tag());
|
||||
_assert_msg_(dst->depth.image != VK_NULL_HANDLE, "%s", dst->Tag());
|
||||
_dbg_assert_msg_(src->depth.image != VK_NULL_HANDLE, "%s", src->Tag());
|
||||
_dbg_assert_msg_(dst->depth.image != VK_NULL_HANDLE, "%s", dst->Tag());
|
||||
|
||||
if (!src->depth.image || !dst->depth.image) {
|
||||
// Something has gone wrong, but let's try to stumble along.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
VKRStep *step = new VKRStep{ VKRStepType::BLIT };
|
||||
|
||||
@@ -144,7 +144,8 @@ bool ScrollView::Touch(const TouchInput &input) {
|
||||
if (orientation_ == ORIENT_VERTICAL) {
|
||||
Bob bob = ComputeBob();
|
||||
float internalY = input.y - bounds_.y;
|
||||
draggingBob_ = internalY >= bob.offset && internalY <= bob.offset + bob.size && input.x >= bounds_.x2() - 20.0f;
|
||||
float bobMargin = 3.0f; // Add some extra margin for the touch.
|
||||
draggingBob_ = internalY >= bob.offset - bobMargin && internalY <= bob.offset + bob.size + bobMargin && input.x >= bounds_.x2() - 20.0f;
|
||||
barDragStart_ = bob.offset;
|
||||
barDragOffset_ = internalY - bob.offset;
|
||||
}
|
||||
@@ -165,11 +166,13 @@ bool ScrollView::Touch(const TouchInput &input) {
|
||||
draggingBob_ = false;
|
||||
}
|
||||
|
||||
// We modify the input2 we send to children, so we can cancel drags if we start scrolling, and stuff like that.
|
||||
TouchInput input2;
|
||||
if (CanScroll()) {
|
||||
if (draggingBob_) {
|
||||
input2 = input;
|
||||
// Skip the gesture, do calculations directly.
|
||||
// Cancel any drags/holds on the children instantly to avoid accidental click-throughs.
|
||||
input2.flags = TOUCH_UP | TOUCH_CANCEL;
|
||||
// Skip the gesture manager, do calculations directly.
|
||||
// Might switch to the gesture later.
|
||||
Bob bob = ComputeBob();
|
||||
float internalY = input.y - bounds_.y;
|
||||
@@ -216,7 +219,7 @@ ScrollView::Bob ScrollView::ComputeBob() const {
|
||||
|
||||
if (ratio < 1.0f && scrollMax > 0.0f) {
|
||||
bob.show = true;
|
||||
bob.thickness = draggingBob_ ? 15.0f : 5.0f;
|
||||
bob.thickness = draggingBob_ ? 15.0f : 6.0f;
|
||||
bob.size = ratio * bounds_.h;
|
||||
bob.offset = (HardClampedScrollPos(scrollPos_) / scrollMax) * (bounds_.h - bob.size);
|
||||
bob.scrollMax = scrollMax;
|
||||
|
||||
+7
-5
@@ -514,11 +514,13 @@ void Choice::Draw(UIContext &dc) {
|
||||
|
||||
if (image_.isValid()) {
|
||||
const AtlasImage *image = dc.Draw()->GetAtlas()->getImage(image_);
|
||||
_dbg_assert_(image);
|
||||
paddingX += image->w + 6;
|
||||
availWidth -= image->w + 6;
|
||||
// TODO: Use scale rotation and flip here as well (DrawImageRotated is always ALIGN_CENTER for now)
|
||||
dc.Draw()->DrawImage(image_, bounds_.x + 6, bounds_.centerY(), 1.0f, style.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
|
||||
if (image) {
|
||||
_dbg_assert_(image);
|
||||
paddingX += image->w + 6;
|
||||
availWidth -= image->w + 6;
|
||||
// TODO: Use scale rotation and flip here as well (DrawImageRotated is always ALIGN_CENTER for now)
|
||||
dc.Draw()->DrawImage(image_, bounds_.x + 6, bounds_.centerY(), 1.0f, style.fgColor, ALIGN_LEFT | ALIGN_VCENTER);
|
||||
}
|
||||
}
|
||||
|
||||
if (centered_) {
|
||||
|
||||
@@ -68,16 +68,16 @@ public:
|
||||
bool IsDisc() const override { return true; }
|
||||
|
||||
private:
|
||||
u32 *index;
|
||||
u8 *readBuffer;
|
||||
u8 *zlibBuffer;
|
||||
u32 zlibBufferFrame;
|
||||
u8 indexShift;
|
||||
u8 blockShift;
|
||||
u32 frameSize;
|
||||
u32 numBlocks;
|
||||
u32 numFrames;
|
||||
int ver_;
|
||||
u32 *index = nullptr;
|
||||
u8 *readBuffer = nullptr;
|
||||
u8 *zlibBuffer = nullptr;
|
||||
u32 zlibBufferFrame = 0;
|
||||
u8 indexShift = 0;
|
||||
u8 blockShift = 0;
|
||||
u32 frameSize = 0;
|
||||
u32 numBlocks = 0;
|
||||
u32 numFrames = 0;
|
||||
int ver_ = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -914,7 +914,10 @@ int Atrac::Analyze(u32 addr, u32 size) {
|
||||
}
|
||||
int checkNumLoops = Memory::Read_U32(first_.addr + offset + 28);
|
||||
if (checkNumLoops != 0 && chunkSize < 36 + 20) {
|
||||
return hleReportError(ME, ATRAC_ERROR_UNKNOWN_FORMAT, "smpl chunk too small for loop (%d)", chunkSize);
|
||||
return hleReportError(ME, ATRAC_ERROR_UNKNOWN_FORMAT, "smpl chunk too small for loop (%d, %d)", checkNumLoops, chunkSize);
|
||||
}
|
||||
if (checkNumLoops < 0) {
|
||||
return hleReportError(ME, ATRAC_ERROR_UNKNOWN_FORMAT, "bad checkNumLoops (%d)", checkNumLoops);
|
||||
}
|
||||
|
||||
loopinfo_.resize(checkNumLoops);
|
||||
|
||||
@@ -219,6 +219,7 @@ void __CtrlSetAnalogXY(int stick, float x, float y)
|
||||
u8 scaledX = clamp_u8((int)ceilf(x * 127.5f + 127.5f));
|
||||
// TODO: We might have too many negations of Y...
|
||||
u8 scaledY = clamp_u8((int)ceilf(-y * 127.5f + 127.5f));
|
||||
|
||||
std::lock_guard<std::mutex> guard(ctrlMutex);
|
||||
ctrlCurrent.analog[stick][CTRL_ANALOG_X] = scaledX;
|
||||
ctrlCurrent.analog[stick][CTRL_ANALOG_Y] = scaledY;
|
||||
|
||||
+1
-1
@@ -332,7 +332,7 @@ public:
|
||||
private:
|
||||
SasReverb reverb_;
|
||||
int grainSize = 0;
|
||||
int16_t mixTemp_[PSP_SAS_MAX_GRAIN * 4 + 2 + 8]; // some extra margin for very high pitches.
|
||||
int16_t mixTemp_[PSP_SAS_MAX_GRAIN * 4 + 2 + 16]; // some extra margin for very high pitches.
|
||||
};
|
||||
|
||||
const char *ADSRCurveModeAsString(SasADSRCurveMode mode);
|
||||
@@ -769,11 +769,12 @@ static bool HasTextDrawer() {
|
||||
return textDrawer != nullptr;
|
||||
}
|
||||
|
||||
static std::string PPGeSanitizeText(const std::string &text) {
|
||||
static std::string PPGeSanitizeText(std::string_view text) {
|
||||
return SanitizeUTF8(text);
|
||||
}
|
||||
|
||||
void PPGeMeasureText(float *w, float *h, const char *text, float scale, int WrapType, int wrapWidth) {
|
||||
_dbg_assert_(text);
|
||||
std::string s = PPGeSanitizeText(text);
|
||||
|
||||
if (HasTextDrawer()) {
|
||||
|
||||
@@ -648,7 +648,7 @@ handleELF:
|
||||
// Alright, let's fetch the PARAM.SFO.
|
||||
if (flags_ & GameInfoFlags::PARAM_SFO) {
|
||||
std::string paramSFOcontents;
|
||||
if (ReadFileToString(&umd, "/PSP_GAME/PARAM.SFO", ¶mSFOcontents, 0)) {
|
||||
if (ReadFileToString(&umd, "/PSP_GAME/PARAM.SFO", ¶mSFOcontents, nullptr)) {
|
||||
std::lock_guard<std::mutex> lock(info_->lock);
|
||||
info_->paramSFO.ReadSFO((const u8 *)paramSFOcontents.data(), paramSFOcontents.size());
|
||||
info_->ParseParamSFO();
|
||||
|
||||
+8
-5
@@ -1057,10 +1057,12 @@ void SettingInfoMessage::Show(const std::string &text, const UI::View *refView)
|
||||
if (refView) {
|
||||
Bounds b = refView->GetBounds();
|
||||
const UI::AnchorLayoutParams *lp = GetLayoutParams()->As<UI::AnchorLayoutParams>();
|
||||
if (cutOffY_ != -1.0f && b.y >= cutOffY_) {
|
||||
ReplaceLayoutParams(new UI::AnchorLayoutParams(lp->width, lp->height, lp->left, 80.0f, lp->right, lp->bottom, lp->center));
|
||||
} else {
|
||||
ReplaceLayoutParams(new UI::AnchorLayoutParams(lp->width, lp->height, lp->left, g_display.dp_yres - 80.0f - 40.0f, lp->right, lp->bottom, lp->center));
|
||||
if (lp) {
|
||||
if (cutOffY_ != -1.0f && b.y >= cutOffY_) {
|
||||
ReplaceLayoutParams(new UI::AnchorLayoutParams(lp->width, lp->height, lp->left, 80.0f, lp->right, lp->bottom, lp->center));
|
||||
} else {
|
||||
ReplaceLayoutParams(new UI::AnchorLayoutParams(lp->width, lp->height, lp->left, g_display.dp_yres - 80.0f - 40.0f, lp->right, lp->bottom, lp->center));
|
||||
}
|
||||
}
|
||||
}
|
||||
text_->SetText(text);
|
||||
@@ -1089,7 +1091,8 @@ void SettingInfoMessage::Draw(UIContext &dc) {
|
||||
dc.FillRect(style.background, bounds_);
|
||||
}
|
||||
|
||||
text_->SetTextColor(whiteAlpha(alpha));
|
||||
uint32_t textColor = colorAlpha(dc.GetTheme().itemStyle.fgColor, alpha);
|
||||
text_->SetTextColor(textColor);
|
||||
ViewGroup::Draw(dc);
|
||||
showing_ = sinceShow <= timeToShow; // Don't consider fade time
|
||||
}
|
||||
|
||||
@@ -46,27 +46,23 @@ import java.util.List;
|
||||
*/
|
||||
public class MogaHack {
|
||||
public static void init(Controller controller, Context context) {
|
||||
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||
controller.init();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
boolean mIsBound = false;
|
||||
java.lang.reflect.Field fIsBound = null;
|
||||
android.content.ServiceConnection mServiceConnection = null;
|
||||
java.lang.reflect.Field fServiceConnection = null;
|
||||
|
||||
try {
|
||||
Class<?> cMogaController = controller.getClass();
|
||||
fIsBound = cMogaController.getDeclaredField("mIsBound");
|
||||
fIsBound.setAccessible(true);
|
||||
mIsBound = fIsBound.getBoolean(controller);
|
||||
fServiceConnection = cMogaController.getDeclaredField("mServiceConnection");
|
||||
fServiceConnection.setAccessible(true);
|
||||
mServiceConnection = (android.content.ServiceConnection) fServiceConnection.get(controller);
|
||||
} catch (NoSuchFieldException e) {
|
||||
Log.e("MogaHack", "MOGA Lollipop Hack NoSuchFieldException (get)", e);
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.e("MogaHack", "MOGA Lollipop Hack IllegalAccessException (get)", e);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.e("MogaHack", "MOGA Lollipop Hack IllegalArgumentException (get)", e);
|
||||
}
|
||||
Class<?> cMogaController = controller.getClass();
|
||||
fIsBound = cMogaController.getDeclaredField("mIsBound");
|
||||
fIsBound.setAccessible(true);
|
||||
mIsBound = fIsBound.getBoolean(controller);
|
||||
fServiceConnection = cMogaController.getDeclaredField("mServiceConnection");
|
||||
fServiceConnection.setAccessible(true);
|
||||
mServiceConnection = (android.content.ServiceConnection) fServiceConnection.get(controller);
|
||||
|
||||
if ((!mIsBound) && (mServiceConnection != null)) {
|
||||
// Convert implicit intent to explicit intent, see http://stackoverflow.com/a/26318757
|
||||
@@ -83,7 +79,7 @@ public class MogaHack {
|
||||
|
||||
// Start the service explicitly
|
||||
context.startService(intent);
|
||||
context.bindService(intent, mServiceConnection, 1);
|
||||
context.bindService(intent, mServiceConnection, Context.BIND_AUTO_CREATE );
|
||||
try {
|
||||
fIsBound.setBoolean(controller, true);
|
||||
} catch (IllegalAccessException e) {
|
||||
@@ -92,8 +88,14 @@ public class MogaHack {
|
||||
Log.e("MogaHack", "MOGA Lollipop Hack IllegalArgumentException (set)", e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
controller.init();
|
||||
} catch (NoSuchFieldException e) {
|
||||
Log.e("MogaHack", "MOGA Lollipop Hack NoSuchFieldException (get)", e);
|
||||
} catch (IllegalAccessException e) {
|
||||
Log.e("MogaHack", "MOGA Lollipop Hack IllegalAccessException (get)", e);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.e("MogaHack", "MOGA Lollipop Hack IllegalArgumentException (get)", e);
|
||||
} catch (Exception e) {
|
||||
Log.e("MogaHack", "MOGA", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user