Warning fixes

This commit is contained in:
Henrik Rydgård 2024-11-04 11:46:55 +01:00
parent 8f615d3da5
commit a8a1d29c8c
20 changed files with 311 additions and 278 deletions

View File

@ -77,7 +77,7 @@ bool VulkanTexture::CreateDirect(int w, int h, int depth, int numMips, VkFormat
image_create_info.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
}
// The graphics debugger always "needs" TRANSFER_SRC but in practice doesn't matter -
// The graphics debugger always "needs" TRANSFER_SRC but in practice doesn't matter -
// unless validation is on. So let's only force it on when being validated, for now.
if (vulkan_->GetFlags() & VULKAN_FLAG_VALIDATE) {
image_create_info.usage |= VK_IMAGE_USAGE_TRANSFER_SRC_BIT;
@ -104,7 +104,7 @@ bool VulkanTexture::CreateDirect(int w, int h, int depth, int numMips, VkFormat
if (initialLayout != VK_IMAGE_LAYOUT_UNDEFINED && initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED) {
VkPipelineStageFlags dstStage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
VkAccessFlagBits dstAccessFlags;
VkAccessFlagBits dstAccessFlags{}; // Fix false positive compiler warning.
switch (initialLayout) {
case VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL:
dstStage = VK_PIPELINE_STAGE_TRANSFER_BIT;

View File

@ -33,10 +33,6 @@ struct Category {
};
struct CategoryFrame {
CategoryFrame() {
memset(time_taken, 0, sizeof(time_taken));
memset(count, 0, sizeof(count));
}
float time_taken[MAX_CATEGORIES];
int count[MAX_CATEGORIES];
};
@ -71,7 +67,7 @@ void internal_profiler_init() {
profiler.parentCategory[i][j] = -1;
}
}
history = new CategoryFrame[HISTORY_SIZE * MAX_THREADS];
history = new CategoryFrame[HISTORY_SIZE * MAX_THREADS]();
}
static int internal_profiler_find_thread() {

View File

@ -98,7 +98,6 @@ bool IsFocusMovementEnabled() {
void LayoutViewHierarchy(const UIContext &dc, ViewGroup *root, bool ignoreInsets) {
_assert_(root);
_assert_(&dc);
Bounds rootBounds = ignoreInsets ? dc.GetBounds() : dc.GetLayoutBounds();

View File

@ -43,7 +43,7 @@ void WebSocketBroadcastConfigGet(DebuggerRequest & req) {
json.pushDict("disallowed");
for (const auto[name, status] : disallowed_config) {
for (const auto &[name, status] : disallowed_config) {
if (status)
json.writeBool(name, true);
}
@ -97,7 +97,7 @@ void WebSocketBroadcastConfigSet(DebuggerRequest & req) {
json.pushDict("disallowed");
for (const auto[name, status] : disallowed_config) {
for (const auto &[name, status] : disallowed_config) {
if (status)
json.writeBool(name, true);
}

View File

@ -585,7 +585,8 @@ int SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveD
INFO_LOG(Log::sceUtility,"Saving file with size %u in %s",saveSize,filePath.c_str());
// copy back save name in request
strncpy(param->saveName, saveDirName.c_str(), 20);
// TODO: Trailing null?
strncpy(param->saveName, saveDirName.c_str(), sizeof(param->saveName));
if (!fileName.empty()) {
if (!WritePSPFile(filePath, data_, saveSize)) {
@ -593,7 +594,7 @@ int SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveD
delete[] cryptedData;
return SCE_UTILITY_SAVEDATA_ERROR_SAVE_MS_NOSPACE;
}
}
}
delete[] cryptedData;
}
@ -702,7 +703,7 @@ int SavedataParam::LoadSaveData(SceUtilitySavedataParam *param, const std::strin
saveSize = (int)readSize;
// copy back save name in request
strncpy(param->saveName, saveDirName.c_str(), 20);
strncpy(param->saveName, saveDirName.c_str(), sizeof(param->saveName));
int prevCryptMode = GetSaveCryptMode(param, saveDirName);
bool isCrypted = prevCryptMode != 0 && secureMode;
@ -848,9 +849,9 @@ bool SavedataParam::LoadSFO(SceUtilitySavedataParam *param, const std::string& d
std::shared_ptr<ParamSFOData> sfoFile = LoadCachedSFO(sfopath);
if (sfoFile) {
// copy back info in request
strncpy(param->sfoParam.title, sfoFile->GetValueString("TITLE").c_str(), 128);
strncpy(param->sfoParam.savedataTitle, sfoFile->GetValueString("SAVEDATA_TITLE").c_str(), 128);
strncpy(param->sfoParam.detail, sfoFile->GetValueString("SAVEDATA_DETAIL").c_str(), 1024);
strncpy(param->sfoParam.title, sfoFile->GetValueString("TITLE").c_str(), sizeof(param->sfoParam.title));
strncpy(param->sfoParam.savedataTitle, sfoFile->GetValueString("SAVEDATA_TITLE").c_str(), sizeof(param->sfoParam.savedataTitle));
strncpy(param->sfoParam.detail, sfoFile->GetValueString("SAVEDATA_DETAIL").c_str(), sizeof(param->sfoParam.detail));
param->sfoParam.parentalLevel = sfoFile->GetValueInt("PARENTAL_LEVEL");
return true;
}
@ -1550,7 +1551,7 @@ int SavedataParam::SetPspParam(SceUtilitySavedataParam *param)
if (saveDataListCount > 0 && WouldHaveMultiSaveName(param)) {
hasMultipleFileName = true;
saveDataList = new SaveFileInfo[saveDataListCount];
// get and stock file info for each file
int realCount = 0;
for (int i = 0; i < saveDataListCount; i++) {
@ -1562,7 +1563,7 @@ int SavedataParam::SetPspParam(SceUtilitySavedataParam *param)
for (auto it = allSaves.begin(); it != allSaves.end(); ++it) {
if (it->name.compare(0, gameName.length(), gameName) == 0) {
std::string saveName = it->name.substr(gameName.length());
if (IsInSaveDataList(saveName, realCount)) // Already in SaveDataList, skip...
continue;
@ -1604,7 +1605,7 @@ int SavedataParam::SetPspParam(SceUtilitySavedataParam *param)
saveNameListDataCount = realCount;
}
}
// Load info on only save
// Load info on only save
if (!hasMultipleFileName) {
saveNameListData = 0;

View File

@ -55,8 +55,8 @@ bool PBPReader::GetSubFile(PBPSubFile file, std::vector<u8> *out) const {
const size_t expected = GetSubFileSize(file);
// This is only used to get the PARAM.SFO, so let's have a strict 256MB file size limit for sanity.
if (expected > 256 * 1024 * 1024) {
// This is only used to get the PARAM.SFO, so let's have a strict 128MB file size limit for sanity.
if (expected > 128 * 1024 * 1024) {
ERROR_LOG(Log::Loader, "Bad subfile size: %d", (int)expected);
return false;
}
@ -69,6 +69,7 @@ bool PBPReader::GetSubFile(PBPSubFile file, std::vector<u8> *out) const {
ERROR_LOG(Log::Loader, "PBP file read truncated: %d -> %d", (int)expected, (int)bytes);
if (bytes < expected) {
out->resize(bytes);
// should we still return true here?
}
}
return true;
@ -82,8 +83,8 @@ bool PBPReader::GetSubFileAsString(PBPSubFile file, std::string *out) const {
const size_t expected = GetSubFileSize(file);
// This is only used to get the PNG, AT3 etc, so let's have a strict 256MB file size limit for sanity.
if (expected > 256 * 1024 * 1024) {
// This is only used to get the PNG, AT3 etc, so let's have a strict 128MB file size limit for sanity.
if (expected > 128 * 1024 * 1024) {
ERROR_LOG(Log::Loader, "Bad subfile size: %d", (int)expected);
return false;
}

View File

@ -95,7 +95,7 @@ static const db_crosslink default_crosslinks[] = {
// Blood Bowl
{ "ULES01230", "ULUS10516" },
// Bomberman
// Bomberman
{ "ULJM05034", "ULUS10121" },
{ "ULES00469", "ULUS10121" },
{ "ULJM05316", "ULUS10121" },
@ -150,7 +150,7 @@ static const db_crosslink default_crosslinks[] = {
// Gundam VS Gundam - Next Plus
{ "ULJS00250", "NPJH50107" },
{ "ULJS19048", "NPJH50107" },
// Hatsune Miku - Project Diva Extend
{ "NPJH50465", "ULJM05933" },
@ -169,7 +169,7 @@ static const db_crosslink default_crosslinks[] = {
// Metal Gear Solid - Peace Walker
{ "ULES01372", "NPJH50045" },
{ "ULUS10509", "NPJH50045" },
// Metal Gear Solid - Portable Ops
{ "ULES00645", "ULUS10202" },
{ "ULJM05193", "ULUS10202" },
@ -213,7 +213,7 @@ static const db_crosslink default_crosslinks[] = {
// Pangya! - Fantasy Golf
{ "ULJM05440", "ULUS10438" },
{ "ULKS46164", "ULUS10438" },
// PRO Evolution Soccer 2012
{ "ULES01540", "ULUS10586" },
{ "ULES01541", "ULUS10586" },
@ -265,7 +265,7 @@ static const db_crosslink default_crosslinks[] = {
// Soul Calibur - Broken Destiny
{ "ULES01298", "ULUS10457" },
{ "ULJS00202", "ULUS10457" },
// Split Second - Velocity
{ "ULES01402", "ULUS10513" },
{ "ULJM05812", "ULUS10513" },
@ -277,7 +277,7 @@ static const db_crosslink default_crosslinks[] = {
// Taiko no Tatsujin Portable DX"
{ "ULJS00383", "NPJH50426" },
// Tekken 6
{ "ULES01376", "ULUS10466" },
{ "NPJH50184", "ULUS10466" },
@ -307,7 +307,7 @@ static const db_crosslink default_crosslinks[] = {
// Worms Open Warfare
{ "ULES00268", "ULUS10065" },
// Worms Open Warfare 2
{ "ULES00819", "ULUS10260" },
@ -1404,9 +1404,9 @@ void game_product_override(SceNetAdhocctlProductCode * product)
// Destroy Prepare SQL Statement
sqlite3_finalize(statement);
}*/
db_productid unkproduct;
db_productid unkproduct{};
strncpy(unkproduct.id, productid, sizeof(unkproduct.id));
strncpy(unkproduct.name, productid, sizeof(productid));
strncpy(unkproduct.name, productid, sizeof(productid)); // suspicious! should be sizeof(unkproduct.name)?
productids.push_back(unkproduct); //productids[productids.size()] = unkproduct;
// Log Addition
INFO_LOG(Log::sceNet, "AdhocServer: Added Unknown Product ID %s to Database", productid);

View File

@ -95,9 +95,20 @@ static u32 convertYCbCrToABGR(int y, int cb, int cr) {
int b = y + cb + (cb >> 1) + (cb >> 2) + (cb >> 6);
// check rgb value.
if (r > 0xFF) r = 0xFF; if(r < 0) r = 0;
if (g > 0xFF) g = 0xFF; if(g < 0) g = 0;
if (b > 0xFF) b = 0xFF; if(b < 0) b = 0;
if (r > 0xFF)
r = 0xFF;
else if (r < 0)
r = 0;
if (g > 0xFF)
g = 0xFF;
else if (g < 0)
g = 0;
if (b > 0xFF)
b = 0xFF;
else if (b < 0)
b = 0;
return (b << 16) | (g << 8) | (r << 0);
}
@ -246,7 +257,7 @@ static int sceJpegMJpegCsc(u32 imageAddr, u32 yCbCrAddr, int widthHeight, int bu
int usec = 0;
int result = JpegMJpegCsc(imageAddr, yCbCrAddr, widthHeight, bufferWidth, usec);
int width = (widthHeight >> 16) & 0xFFF;
int height = widthHeight & 0xFFF;
if (result >= 0)
@ -385,10 +396,10 @@ static int JpegGetOutputInfo(u32 jpegAddr, int jpegSize, u32 colourInfoAddr) {
}
free(jpegBuf);
// Buffer to store info about the color space in use.
// - Bits 24 to 32 (Always empty): 0x00
// - Bits 16 to 24 (Color mode): 0x00 (Unknown), 0x01 (Greyscale) or 0x02 (YCbCr)
// - Bits 16 to 24 (Color mode): 0x00 (Unknown), 0x01 (Greyscale) or 0x02 (YCbCr)
// - Bits 8 to 16 (Vertical chroma subsampling value): 0x00, 0x01 or 0x02
// - Bits 0 to 8 (Horizontal chroma subsampling value): 0x00, 0x01 or 0x02
if (Memory::IsValidAddress(colourInfoAddr)) {
@ -434,9 +445,20 @@ static u32 convertRGBToYCbCr(u32 rgb) {
int cr = 0.499f * r - 0.418f * g - 0.0813f * b + 128.0f;
// check yCbCr value
if ( y > 0xFF) y = 0xFF; if ( y < 0) y = 0;
if (cb > 0xFF) cb = 0xFF; if (cb < 0) cb = 0;
if (cr > 0xFF) cr = 0xFF; if (cr < 0) cr = 0;
if (y > 0xFF)
y = 0xFF;
else if ( y < 0)
y = 0;
if (cb > 0xFF)
cb = 0xFF;
else if (cb < 0)
cb = 0;
if (cr > 0xFF)
cr = 0xFF;
else if (cr < 0)
cr = 0;
return (y << 16) | (cb << 8) | cr;
}
@ -543,7 +565,7 @@ static int sceJpegDecodeMJpegYCbCr(u32 jpegAddr, int jpegSize, u32 yCbCrAddr, in
return hleLogError(Log::ME, SCE_KERNEL_ERROR_PRIV_REQUIRED, "invalid output address");
if (!Memory::IsValidRange(jpegAddr, jpegSize))
return hleLogError(Log::ME, ERROR_JPEG_INVALID_VALUE, "invalid jpeg address");
int usec = 300;
int result = JpegDecodeMJpegYCbCr(jpegAddr, jpegSize, yCbCrAddr, yCbCrSize, usec);
return hleDelayResult(result, "jpeg decode", usec);
@ -554,7 +576,7 @@ static int sceJpegDecodeMJpegYCbCrSuccessively(u32 jpegAddr, int jpegSize, u32 y
return hleLogError(Log::ME, SCE_KERNEL_ERROR_PRIV_REQUIRED, "invalid jpeg address");
if ((yCbCrAddr | yCbCrSize | (yCbCrAddr + yCbCrSize)) & 0x80000000)
return hleLogError(Log::ME, SCE_KERNEL_ERROR_PRIV_REQUIRED, "invalid output address");
// Do as same way as sceJpegDecodeMJpegYCbCr() but with smaller block size
int usec = 300;
int result = JpegDecodeMJpegYCbCr(jpegAddr, jpegSize, yCbCrAddr, yCbCrSize, usec);

View File

@ -112,7 +112,7 @@ static void sceKernelCpuResumeIntr(u32 enable)
static int sceKernelIsCpuIntrEnable()
{
u32 retVal = __InterruptsEnabled();
u32 retVal = __InterruptsEnabled();
DEBUG_LOG(Log::sceIntc, "%i=sceKernelIsCpuIntrEnable()", retVal);
return retVal;
}
@ -688,7 +688,7 @@ const HLEFunction Kernel_Library[] =
{0X4AC57943, &WrapI_I<sceKernelRegisterExitCallback>, "sceKernelRegisterExitCallback", 'i', "i" },
};
static u32 sysclib_memcpy(u32 dst, u32 src, u32 size) {
static u32 sysclib_memcpy(u32 dst, u32 src, u32 size) {
if (Memory::IsValidRange(dst, size) && Memory::IsValidRange(src, size)) {
memcpy(Memory::GetPointerWriteUnchecked(dst), Memory::GetPointerUnchecked(src), size);
}
@ -700,6 +700,8 @@ static u32 sysclib_memcpy(u32 dst, u32 src, u32 size) {
static u32 sysclib_strcat(u32 dst, u32 src) {
ERROR_LOG(Log::sceKernel, "Untested sysclib_strcat(dest=%08x, src=%08x)", dst, src);
// TODO: Compiler gives a nonsensical warning here, but it's possible that dst and src could overlap.
// Check and error out?
if (Memory::IsValidNullTerminatedString(dst) && Memory::IsValidNullTerminatedString(src)) {
strcat((char *)Memory::GetPointerWriteUnchecked(dst), (const char *)Memory::GetPointerUnchecked(src));
}
@ -964,7 +966,7 @@ static u32 sysclib_strncpy(u32 dest, u32 src, u32 size) {
return hleLogSuccessX(Log::sceKernel, dest);
}
static u32 sysclib_strtol(u32 strPtr, u32 endPtrPtr, int base) {
static u32 sysclib_strtol(u32 strPtr, u32 endPtrPtr, int base) {
if (!Memory::IsValidNullTerminatedString(strPtr)) {
return hleLogError(Log::sceKernel, 0, "invalid address");
}

View File

@ -94,7 +94,7 @@ static const s64 UNKNOWN_TIMESTAMP = -1;
static const int MPEG_HEADER_BUFFER_MINIMUM_SIZE = 2048;
// For PMP media
static u32 pmp_videoSource = 0; //pointer to the video source (SceMpegLLi structure)
static u32 pmp_videoSource = 0; //pointer to the video source (SceMpegLLi structure)
static int pmp_nBlocks = 0; //number of blocks received in the last sceMpegBasePESpacketCopy call
#ifdef USE_FFMPEG
static std::list<AVFrame*> pmp_queue; //list of pmp video frames have been decoded and will be played
@ -106,7 +106,7 @@ static bool pmp_oldStateLoaded = false; // for dostate
static int ringbufferPutPacketsAdded = 0;
static bool useRingbufferPutCallbackMulti = true;
#ifdef USE_FFMPEG
#ifdef USE_FFMPEG
extern "C" {
#include "libavformat/avformat.h"
@ -165,7 +165,7 @@ struct AvcContext {
int avcFrameStatus;
};
struct StreamInfo {
struct StreamInfo {
int type;
int num;
int sid;
@ -270,7 +270,7 @@ static std::map<u32, MpegContext *> mpegMap;
static MpegContext *getMpegCtx(u32 mpegAddr) {
if (!Memory::IsValidAddress(mpegAddr))
return nullptr;
u32 mpeg = Memory::Read_U32(mpegAddr);
auto found = mpegMap.find(mpeg);
if (found == mpegMap.end())
@ -425,7 +425,7 @@ void __MpegDoState(PointerWrap &p) {
ringbufferPutPacketsAdded = 0;
} else {
Do(p, ringbufferPutPacketsAdded);
}
}
if (s < 4) {
mpegLibCrc = 0;
}
@ -718,7 +718,7 @@ static int sceMpegRegistStream(u32 mpeg, u32 streamType, u32 streamNum)
case MPEG_DATA_STREAM:
ctx->dataRegistered = true;
break;
default :
default :
DEBUG_LOG(Log::ME, "sceMpegRegistStream(%i) : unknown stream type", streamType);
break;
}
@ -775,7 +775,7 @@ static int sceMpegFreeAvcEsBuf(u32 mpeg, int esBuf)
return 0;
}
// check the existence of pmp media context
// check the existence of pmp media context
static bool isContextExist(u32 ctxAddr){
for (auto it = pmp_ContextList.begin(); it != pmp_ContextList.end(); ++it){
if (*it == ctxAddr){
@ -798,7 +798,7 @@ static bool InitPmp(MpegContext * ctx){
// wanted output pixel format
// reference values for pix_fmt:
// GE_CMODE_16BIT_BGR5650 <--> AV_PIX_FMT_BGR565LE
// GE_CMODE_16BIT_BGR5650 <--> AV_PIX_FMT_BGR565LE
// GE_CMODE_16BIT_ABGR5551 <--> AV_PIX_FMT_BGR555LE;
// GE_CMODE_16BIT_ABGR4444 <--> AV_PIX_FMT_BGR444LE;
// GE_CMODE_32BIT_ABGR8888 <--> AV_PIX_FMT_RGBA;
@ -860,14 +860,14 @@ static bool InitPmp(MpegContext * ctx){
}
// This class H264Frames is used for collecting small pieces of frames into larger frames for ffmpeg to decode
// Basically, this will avoid incomplete frame decoding issue and improve much better the video quality.
// Basically, this will avoid incomplete frame decoding issue and improve much better the video quality.
class H264Frames{
public:
int size;
u8* stream;
H264Frames() :size(0), stream(NULL){};
H264Frames(u8* str, int sz) :size(sz){
stream = new u8[size];
memcpy(stream, str, size);
@ -886,7 +886,7 @@ public:
stream = NULL;
}
};
void add(const H264Frames *p) {
add(p->stream, p->size);
};
@ -970,7 +970,7 @@ static bool decodePmpVideo(PSPPointer<SceMpegRingBuffer> ringbuffer, u32 pmpctxA
AVFrame* pFrameRGB = mediaengine->m_pFrameRGB;
auto pCodecCtx = mediaengine->m_pCodecCtxs[0];
// pmpframes could be destroied when close a video to load another one
// pmpframes could be destroied when close a video to load another one
if (!pmpframes)
pmpframes = new H264Frames;
@ -1050,7 +1050,7 @@ static bool decodePmpVideo(PSPPointer<SceMpegRingBuffer> ringbuffer, u32 pmpctxA
ERROR_LOG(Log::ME, "sws_scale: Error while converting %d", swsRet);
return false;
}
// free sws context
// free sws context
sws_freeContext(img_convert_ctx);
// update timestamp
@ -1079,7 +1079,7 @@ static bool decodePmpVideo(PSPPointer<SceMpegRingBuffer> ringbuffer, u32 pmpctxA
av_free_packet(&packet);
#endif
pmpframes->~H264Frames();
// must reset pmp_VideoSource address to zero after decoding.
// must reset pmp_VideoSource address to zero after decoding.
pmp_videoSource = 0;
return true;
}
@ -1143,13 +1143,13 @@ static u32 sceMpegAvcDecode(u32 mpeg, u32 auAddr, u32 frameWidth, u32 bufferAddr
SceMpegAu avcAu;
avcAu.read(auAddr);
auto ringbuffer = PSPPointer<SceMpegRingBuffer>::Create(ctx->mpegRingbufferAddr);
if (!ringbuffer.IsValid()) {
ERROR_LOG(Log::ME, "Bogus mpegringbufferaddr");
return -1;
}
u32 buffer = Memory::Read_U32(bufferAddr);
u32 init = Memory::Read_U32(initAddr);
DEBUG_LOG(Log::ME, "video: bufferAddr = %08x, *buffer = %08x, *init = %08x", bufferAddr, buffer, init);
@ -1180,7 +1180,7 @@ static u32 sceMpegAvcDecode(u32 mpeg, u32 auAddr, u32 frameWidth, u32 bufferAddr
gpu->PerformWriteFormattedFromMemory(buffer, bufferSize, frameWidth, (GEBufferFormat)ctx->videoPixelMode);
ctx->avc.avcFrameStatus = 1;
ctx->videoFrameCount++;
// free front frame
hleDelayResult(0, "pmp video decode", 30);
pmp_queue.pop_front();
@ -1214,7 +1214,7 @@ static u32 sceMpegAvcDecode(u32 mpeg, u32 auAddr, u32 frameWidth, u32 bufferAddr
Memory::Write_U32(1, initAddr);
}
else {
// Save the current frame's status to initAddr
// Save the current frame's status to initAddr
Memory::Write_U32(ctx->avc.avcFrameStatus, initAddr);
}
ctx->avc.avcDecodeResult = MPEG_AVC_DECODE_SUCCESS;
@ -1273,7 +1273,7 @@ static u32 sceMpegUnRegistStream(u32 mpeg, int streamUid)
case MPEG_DATA_STREAM:
ctx->dataRegistered = false;
break;
default :
default :
DEBUG_LOG(Log::ME, "sceMpegUnRegistStream(%i) : unknown streamID ", streamUid);
break;
}
@ -1386,7 +1386,7 @@ static int sceMpegAvcDecodeYCbCr(u32 mpeg, u32 auAddr, u32 bufferAddr, u32 initA
// Sunday Vs Magazine Shuuketsu! Choujou Daikessen expect, issue #11060
Memory::Write_U32(1, initAddr);
}
else {
else {
// Save the current frame's status to initAddr
Memory::Write_U32(ctx->avc.avcFrameStatus, initAddr);
}
@ -1642,7 +1642,7 @@ static int sceMpegGetAvcAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr)
ERROR_LOG_REPORT(Log::ME, "sceMpegGetAvcAu(%08x, %08x, %08x, %08x): invalid ringbuffer address", mpeg, streamId, auAddr, attrAddr);
return -1;
}
if (PSP_CoreParameter().compat.flags().MpegAvcWarmUp) {
if (ctx->mpegwarmUp == 0) {
DEBUG_LOG(Log::ME, "sceMpegGetAvcAu(%08x, %08x, %08x, %08x): warming up", mpeg, streamId, auAddr, attrAddr);
@ -1701,7 +1701,7 @@ static int sceMpegGetAvcAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr)
// The avcau struct may have been modified by mediaengine, write it back.
avcAu.write(auAddr);
// Jeanne d'Arc return 00000000 as attrAddr here and cause WriteToHardware error
// Jeanne d'Arc return 00000000 as attrAddr here and cause WriteToHardware error
if (Memory::IsValidAddress(attrAddr)) {
Memory::Write_U32(1, attrAddr);
}
@ -1775,7 +1775,7 @@ static int sceMpegGetAtracAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr)
int result = 0;
atracAu.pts = ctx->mediaengine->getAudioTimeStamp() + ctx->mpegFirstTimestamp;
if (ctx->mediaengine->IsVideoEnd()) {
INFO_LOG(Log::ME, "video end reach. pts: %i dts: %i", (int)atracAu.pts, (int)ctx->mediaengine->getLastTimeStamp());
ringbuffer->packetsAvail = 0;
@ -1796,7 +1796,7 @@ static int sceMpegGetAtracAu(u32 mpeg, u32 streamId, u32 auAddr, u32 attrAddr)
atracAu.write(auAddr);
// 3rd birthday return 00000000 as attrAddr here and cause WriteToHardware error
// 3rd birthday return 00000000 as attrAddr here and cause WriteToHardware error
if (Memory::IsValidAddress(attrAddr)) {
Memory::Write_U32(0, attrAddr);
}
@ -2167,19 +2167,31 @@ static u32 convertABGRToYCbCr(u32 abgr) {
u8 r = (abgr >> 0) & 0xFF;
u8 g = (abgr >> 8) & 0xFF;
u8 b = (abgr >> 16) & 0xFF;
int y = 0.299f * r + 0.587f * g + 0.114f * b + 0;
int cb = -0.169f * r - 0.331f * g + 0.499f * b + 128.0f;
int cr = 0.499f * r - 0.418f * g - 0.0813f * b + 128.0f;
int y = 0.299f * r + 0.587f * g + 0.114f * b + 0.0f;
int cb = -0.169f * r - 0.331f * g + 0.499f * b + 128.0f;
int cr = 0.499f * r - 0.418f * g - 0.0813f * b + 128.0f;
// check yCbCr value
if ( y > 0xFF) y = 0xFF; if ( y < 0) y = 0;
if (cb > 0xFF) cb = 0xFF; if (cb < 0) cb = 0;
if (cr > 0xFF) cr = 0xFF; if (cr < 0) cr = 0;
if (y > 0xFF)
y = 0xFF;
else if ( y < 0)
y = 0;
if (cb > 0xFF)
cb = 0xFF;
else if (cb < 0)
cb = 0;
if (cr > 0xFF)
cr = 0xFF;
else if (cr < 0)
cr = 0;
return (y << 16) | (cb << 8) | cr;
}
// bufferOutputAddr is checked in the caller.
// TODO: This is really slow!
static int __MpegAvcConvertToYuv420(const void *data, u32 bufferOutputAddr, int width, int height) {
u32 *imageBuffer = (u32*)data;
int sizeY = width * height;
@ -2202,7 +2214,7 @@ static int __MpegAvcConvertToYuv420(const void *data, u32 bufferOutputAddr, int
u32 yCbCr1 = convertABGRToYCbCr(abgr1);
u32 yCbCr2 = convertABGRToYCbCr(abgr2);
u32 yCbCr3 = convertABGRToYCbCr(abgr3);
Y[width * (y + 0) + x + 0] = (yCbCr0 >> 16) & 0xFF;
Y[width * (y + 0) + x + 1] = (yCbCr1 >> 16) & 0xFF;
Y[width * (y + 1) + x + 0] = (yCbCr2 >> 16) & 0xFF;
@ -2443,7 +2455,7 @@ static u32 sceMpegBasePESpacketCopy(u32 p)
}
++lli;
}
DEBUG_LOG(Log::ME, "sceMpegBasePESpacketCopy(%08x), received %d block(s)", pmp_videoSource, pmp_nBlocks);
return 0;
}

File diff suppressed because it is too large Load Diff

View File

@ -49,7 +49,7 @@ typedef std::vector<MIPSAnalyst::AnalyzedFunction> FunctionsVector;
static FunctionsVector functions;
std::recursive_mutex functions_lock;
// One function can appear in multiple copies in memory, and they will all have
// One function can appear in multiple copies in memory, and they will all have
// the same hash and should all be replaced if possible.
static std::unordered_multimap<u64, MIPSAnalyst::AnalyzedFunction *> hashToFunction;
@ -741,7 +741,7 @@ namespace MIPSAnalyst {
return results;
}
void Reset() {
std::lock_guard<std::recursive_mutex> guard(functions_lock);
functions.clear();
@ -1425,8 +1425,7 @@ skip:
}
MipsOpcodeInfo GetOpcodeInfo(DebugInterface* cpu, u32 address) {
MipsOpcodeInfo info;
memset(&info, 0, sizeof(info));
MipsOpcodeInfo info{};
if (!Memory::IsValidAddress(address)) {
info.opcodeAddress = address;

View File

@ -968,27 +968,27 @@ uint32_t vrnd_generate(uint32_t *rcx) {
// Lookup tables.
// Note: these are never unloaded, and stay till program termination.
static uint32_t (*vfpu_sin_lut8192)=nullptr;
static int8_t (*vfpu_sin_lut_delta)[2]=nullptr;
static int16_t (*vfpu_sin_lut_interval_delta)=nullptr;
static uint8_t (*vfpu_sin_lut_exceptions)=nullptr;
static uint32_t *vfpu_sin_lut8192 = nullptr;
static int8_t (*vfpu_sin_lut_delta)[2] = nullptr;
static int16_t *vfpu_sin_lut_interval_delta = nullptr;
static uint8_t *vfpu_sin_lut_exceptions = nullptr;
static int8_t (*vfpu_sqrt_lut)[2]=nullptr;
static int8_t (*vfpu_sqrt_lut)[2] = nullptr;
static int8_t (*vfpu_rsqrt_lut)[2]=nullptr;
static int8_t (*vfpu_rsqrt_lut)[2] = nullptr;
static uint32_t (*vfpu_exp2_lut65536)=nullptr;
static uint8_t (*vfpu_exp2_lut)[2]=nullptr;
static uint32_t *vfpu_exp2_lut65536 = nullptr;
static uint8_t (*vfpu_exp2_lut)[2] = nullptr;
static uint32_t (*vfpu_log2_lut65536)=nullptr;
static uint32_t (*vfpu_log2_lut65536_quadratic)=nullptr;
static uint8_t (*vfpu_log2_lut)[131072][2]=nullptr;
static uint32_t *vfpu_log2_lut65536 = nullptr;
static uint32_t *vfpu_log2_lut65536_quadratic = nullptr;
static uint8_t (*vfpu_log2_lut)[131072][2] = nullptr;
static int32_t (*vfpu_asin_lut65536)[3]=nullptr;
static uint64_t (*vfpu_asin_lut_deltas)=nullptr;
static uint16_t (*vfpu_asin_lut_indices)=nullptr;
static int32_t (*vfpu_asin_lut65536)[3] = nullptr;
static uint64_t *vfpu_asin_lut_deltas = nullptr;
static uint16_t *vfpu_asin_lut_indices = nullptr;
static int8_t (*vfpu_rcp_lut)[2]=nullptr;
static int8_t (*vfpu_rcp_lut)[2] = nullptr;
template<typename T>
static inline bool load_vfpu_table(T *&ptr, const char *filename, size_t expected_size) {
@ -1553,20 +1553,20 @@ float vfpu_rcp(float x) {
void InitVFPU() {
#if 0
// Load all in advance.
LOAD_TABLE(vfpu_asin_lut65536 , 1536);
LOAD_TABLE(vfpu_asin_lut_deltas , 517448);
LOAD_TABLE(vfpu_asin_lut_indices , 798916);
LOAD_TABLE(vfpu_exp2_lut65536 , 512);
LOAD_TABLE(vfpu_exp2_lut , 262144);
LOAD_TABLE(vfpu_log2_lut65536 , 516);
LOAD_TABLE(vfpu_log2_lut65536_quadratic, 512);
LOAD_TABLE(vfpu_log2_lut , 2097152);
LOAD_TABLE(vfpu_rcp_lut , 262144);
LOAD_TABLE(vfpu_rsqrt_lut , 262144);
LOAD_TABLE(vfpu_sin_lut8192 , 4100);
LOAD_TABLE(vfpu_sin_lut_delta , 262144);
LOAD_TABLE(vfpu_sin_lut_exceptions , 86938);
LOAD_TABLE(vfpu_sin_lut_interval_delta , 131074);
LOAD_TABLE(vfpu_sqrt_lut , 262144);
LOAD_TABLE(vfpu_asin_lut65536 , 1536);
LOAD_TABLE(vfpu_asin_lut_deltas , 517448);
LOAD_TABLE(vfpu_asin_lut_indices , 798916);
LOAD_TABLE(vfpu_exp2_lut65536 , 512);
LOAD_TABLE(vfpu_exp2_lut , 262144);
LOAD_TABLE(vfpu_log2_lut65536 , 516);
LOAD_TABLE(vfpu_log2_lut65536_quadratic, 512);
LOAD_TABLE(vfpu_log2_lut , 2097152);
LOAD_TABLE(vfpu_rcp_lut , 262144);
LOAD_TABLE(vfpu_rsqrt_lut , 262144);
LOAD_TABLE(vfpu_sin_lut8192 , 4100);
LOAD_TABLE(vfpu_sin_lut_delta , 262144);
LOAD_TABLE(vfpu_sin_lut_exceptions , 86938);
LOAD_TABLE(vfpu_sin_lut_interval_delta , 131074);
LOAD_TABLE(vfpu_sqrt_lut , 262144);
#endif
}

View File

@ -71,6 +71,7 @@ void GPRRegCache::Start(MIPSState *mipsState, MIPSComp::JitState *js, MIPSComp::
xregs[i].dirty = false;
xregs[i].allocLocked = false;
}
// This is OK because all the types in reg (like OpArgs) can tolerate being memsetted.
memset(regs, 0, sizeof(regs));
OpArg base = GetDefaultLocation(MIPS_REG_ZERO);
for (int i = 0; i < 32; i++) {

View File

@ -903,7 +903,7 @@ void FramebufferManagerCommon::CopyToColorFromOverlappingFramebuffers(VirtualFra
gpuStats.numReinterpretCopies++;
}
if (pipeline) {
tookActions = true;
// OK we have the pipeline, now just do the blit.
@ -2090,10 +2090,10 @@ bool FramebufferManagerCommon::NotifyFramebufferCopy(u32 src, u32 dst, int size,
// For now fill in these old variables from the candidates to reduce the initial diff.
VirtualFramebuffer *dstBuffer = nullptr;
VirtualFramebuffer *srcBuffer = nullptr;
int srcY;
int srcH;
int dstY;
int dstH;
int srcY = 0;
int srcH = 0;
int dstY = 0;
int dstH = 0;
const CopyCandidate *bestSrc = GetBestCopyCandidate(srcCandidates, src, channel);
if (bestSrc) {
@ -3500,7 +3500,7 @@ void FramebufferManagerCommon::BlitFramebuffer(VirtualFramebuffer *dst, int dstX
const bool xOverlap = src == dst && srcX2 > dstX1 && srcX1 < dstX2;
const bool yOverlap = src == dst && srcY2 > dstY1 && srcY1 < dstY2;
if (sameSize && srcInsideBounds && dstInsideBounds && !(xOverlap && yOverlap)) {
draw_->CopyFramebufferImage(src->fbo, 0, srcX1, srcY1, 0, dst->fbo, 0, dstX1, dstY1, 0, dstX2 - dstX1, dstY2 - dstY1, 1,
draw_->CopyFramebufferImage(src->fbo, 0, srcX1, srcY1, 0, dst->fbo, 0, dstX1, dstY1, 0, dstX2 - dstX1, dstY2 - dstY1, 1,
channel == RASTER_COLOR ? Draw::FB_COLOR_BIT : Draw::FB_DEPTH_BIT, tag);
return;
}

View File

@ -91,7 +91,7 @@ void CalculateDisplayOutputRect(FRect *rc, float origW, float origH, const FRect
// Automatically set aspect ratio to match the display, IF the rotation matches the output display ratio! Otherwise, just
// sets standard aspect ratio because actually stretching will just look silly.
bool globalRotated = g_display.rotation == DisplayRotation::ROTATE_90 || g_display.rotation == DisplayRotation::ROTATE_270;
if (rotated == g_display.dp_yres > g_display.dp_xres) {
if (rotated == (g_display.dp_yres > g_display.dp_xres)) {
origRatio = frameRatio;
} else {
origRatio *= aspectRatioAdjust;

View File

@ -464,7 +464,7 @@ void TextureReplacer::ParseReduceHashRange(const std::string& key, const std::st
return;
}
float rhashvalue;
float rhashvalue = 0.0f;
if (!TryParse(valueParts[0], &rhashvalue)) {
ERROR_LOG(Log::G3D, "Ignoring invalid reducehashrange %s = %s, value format is 0.5", key.c_str(), value.c_str());
return;

View File

@ -263,7 +263,7 @@ static void SetColorUniform3Alpha255(GLRenderManager *render, GLint *uniform, u3
(float)((color & 0xFF) >> 0),
(float)((color & 0xFF00) >> 8),
(float)((color & 0xFF0000) >> 16),
(float)alpha
(float)alpha
};
render->SetUniformF(uniform, 4, col);
}
@ -389,7 +389,7 @@ void LinkedShader::UpdateUniforms(const ShaderID &vsid, bool useBufferedRenderin
dirtyUniforms = 0;
// Analyze scene
bool is2D, flatScreen;
bool is2D = false, flatScreen = false; // These are only initialized to avoid a compiler warning.
if (gstate_c.Use(GPU_USE_VIRTUAL_REALITY)) {
is2D = Is2DVRObject(gstate.projMatrix, gstate.isModeThrough());
flatScreen = IsFlatVRScene();

View File

@ -502,7 +502,7 @@ u32 GPUCommon::UpdateStall(int listid, u32 newstall) {
return SCE_KERNEL_ERROR_ALREADY;
dl.stall = newstall & 0x0FFFFFFF;
ProcessDLQueue();
return 0;
@ -1697,7 +1697,7 @@ void GPUCommon::DoBlockTransfer(u32 skipDrawReason) {
bool dstWraps = Memory::IsVRAMAddress(dstBasePtr) && !dstValid;
char tag[128];
size_t tagSize;
size_t tagSize = 0;
// Tell the framebuffer manager to take action if possible. If it does the entire thing, let's just return.
if (!framebufferManager_ || !framebufferManager_->NotifyBlockTransferBefore(dstBasePtr, dstStride, dstX, dstY, srcBasePtr, srcStride, srcX, srcY, width, height, bpp, skipDrawReason)) {

View File

@ -174,7 +174,7 @@ void SamplerJitCache::Flush() {
NearestFunc SamplerJitCache::GetByID(const SamplerID &id, size_t key, BinManager *binner) {
std::unique_lock<std::mutex> guard(jitCacheLock);
NearestFunc func;
if (cache_.Get(key, &func)) {
return func;
@ -357,7 +357,7 @@ inline static Nearest4 SOFTRAST_CALL SampleNearest(const int u[N], const int v[N
res.v[i] = RGBA4444ToRGBA8888(*(const u16 *)src);
}
return res;
case GE_TFMT_5551:
for (int i = 0; i < N; ++i) {
const u8 *src = srcptr + GetPixelDataOffset<16>(texbufw, u[i], v[i], samplerID.swizzle);
@ -494,7 +494,7 @@ Vec4IntResult SOFTRAST_CALL GetTextureFunctionOutput(Vec4IntArg prim_color_in, V
const Vec4<int> texcolor = texcolor_in;
Vec3<int> out_rgb;
int out_a;
int out_a = 0;
bool rgba = samplerID.useTextureAlpha;