Skip to content

Commit

Permalink
Merge pull request #18194 from hrydgard/minor-stuff-again
Browse files Browse the repository at this point in the history
Cleanups and comment clarifications
  • Loading branch information
hrydgard authored Sep 22, 2023
2 parents e7c0b41 + 81f47ca commit c2406ae
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 17 deletions.
8 changes: 4 additions & 4 deletions Common/Data/Format/IniFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ std::string* Section::GetLine(const char* key, std::string* valueOut, std::strin
if (!strcasecmp(lineKey.c_str(), key))
return &line;
}
return 0;
return nullptr;
}

const std::string* Section::GetLine(const char* key, std::string* valueOut, std::string* commentOut) const
Expand All @@ -186,7 +186,7 @@ const std::string* Section::GetLine(const char* key, std::string* valueOut, std:
if (!strcasecmp(lineKey.c_str(), key))
return &line;
}
return 0;
return nullptr;
}

void Section::Set(const char* key, uint32_t newValue) {
Expand Down Expand Up @@ -423,14 +423,14 @@ const Section* IniFile::GetSection(const char* sectionName) const {
for (const auto &iter : sections)
if (!strcasecmp(iter->name().c_str(), sectionName))
return iter.get();
return nullptr ;
return nullptr;
}

Section* IniFile::GetSection(const char* sectionName) {
for (const auto &iter : sections)
if (!strcasecmp(iter->name().c_str(), sectionName))
return iter.get();
return 0;
return nullptr;
}

Section* IniFile::GetOrCreateSection(const char* sectionName) {
Expand Down
4 changes: 2 additions & 2 deletions Common/File/DirListing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ bool GetFilesInDir(const Path &directory, std::vector<FileInfo> *files, const ch
std::string tmp;
while (*filter) {
if (*filter == ':') {
filters.insert(std::move(tmp));
filters.insert(tmp);
tmp.clear();
} else {
tmp.push_back(*filter);
}
filter++;
}
if (!tmp.empty())
filters.insert(std::move(tmp));
filters.insert(tmp);
}

#if PPSSPP_PLATFORM(WINDOWS)
Expand Down
2 changes: 1 addition & 1 deletion Common/GPU/Vulkan/VulkanLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ static void VulkanFreeLibrary(VulkanLibraryHandle &h) {
}

void VulkanSetAvailable(bool available) {
INFO_LOG(G3D, "Forcing Vulkan availability to true");
INFO_LOG(G3D, "Setting Vulkan availability to true");
g_vulkanAvailabilityChecked = true;
g_vulkanMayBeAvailable = available;
}
Expand Down
4 changes: 2 additions & 2 deletions Core/Util/PPGeDraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ static void PPGeResetCurrentText() {
// Draws some text using the one font we have in the atlas.
void PPGeDrawCurrentText(u32 color) {
// If the atlas is larger than 512x512, need to use windows into it.
bool useTextureWindow = g_Config.bSoftwareRendering && atlasWidth > 512 || atlasHeight > 512;
bool useTextureWindow = g_Config.bSoftwareRendering && (atlasWidth > 512 || atlasHeight > 512);
uint32_t texturePosX = 0;
uint32_t texturePosY = 0;

Expand Down Expand Up @@ -855,7 +855,7 @@ void PPGeDrawCurrentText(u32 color) {

int wantedPosX = (int)floorf(c.sx * textureMaxPosX);
int wantedPosY = (int)floorf(c.sy * textureMaxPosY);
if (useTextureWindow && wantedPosX != texturePosX || wantedPosY != texturePosY) {
if (useTextureWindow && (wantedPosX != texturePosX || wantedPosY != texturePosY)) {
EndVertexDataAndDraw(GE_PRIM_RECTANGLES);

uint32_t offset = atlasWidth * wantedPosY * 256 + wantedPosX * 256;
Expand Down
24 changes: 18 additions & 6 deletions GPU/Common/SoftwareTransformCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,10 +686,17 @@ void SoftwareTransform::CalcCullParams(float &minZValue, float &maxZValue) {
std::swap(minZValue, maxZValue);
}

static void ReportExpandOverflow(const char *primName, int vertexCount, int indexSpaceLeft) {
ERROR_LOG_REPORT_ONCE(expandoverflow, G3D, "%s expansion overflow: vertexCount=%d (left: %d)", primName, vertexCount, indexSpaceLeft);
}

// indsOffset is in indices, so half what the byte offset would be.
// indexBufferSize is also in indices, not bytes.
bool SoftwareTransform::ExpandRectangles(int vertexCount, int &maxIndex, u16 *inds, int &indsOffset, int indexBufferSize, const TransformedVertex *transformed, TransformedVertex *transformedExpanded, int &numTrans, bool throughmode) {
// Before we start, do a sanity check - does the output fit?
if ((vertexCount / 2) * 6 > indexBufferSize - indsOffset) {
// Won't fit, kill the draw.
// Won't fit, report and kill the draw.
ReportExpandOverflow("rects", vertexCount, indexBufferSize - indsOffset);
return false;
}

Expand All @@ -698,7 +705,7 @@ bool SoftwareTransform::ExpandRectangles(int vertexCount, int &maxIndex, u16 *in
numTrans = 0;
TransformedVertex *trans = &transformedExpanded[0];

const u16 *indsIn = (const u16 *)(inds + indsOffset);
const u16 *indsIn = inds + indsOffset;
int newIndsOffset = indsOffset + vertexCount;
u16 *indsOut = inds + newIndsOffset;

Expand Down Expand Up @@ -756,10 +763,13 @@ bool SoftwareTransform::ExpandRectangles(int vertexCount, int &maxIndex, u16 *in
return true;
}

// indsOffset is in indices, so half what the byte offset would be.
// indexBufferSize is also in indices, not bytes.
bool SoftwareTransform::ExpandLines(int vertexCount, int &maxIndex, u16 *inds, int &indsOffset, int indexBufferSize, const TransformedVertex *transformed, TransformedVertex *transformedExpanded, int &numTrans, bool throughmode) {
// Before we start, do a sanity check - does the output fit?
if ((vertexCount / 2) * 6 > indexBufferSize - indsOffset) {
// Won't fit, kill the draw.
// Won't fit, report and kill the draw.
ReportExpandOverflow("lines", vertexCount, indexBufferSize - indsOffset);
return false;
}

Expand All @@ -768,8 +778,7 @@ bool SoftwareTransform::ExpandLines(int vertexCount, int &maxIndex, u16 *inds, i
numTrans = 0;
TransformedVertex *trans = &transformedExpanded[0];


const u16 *indsIn = (const u16 *)(inds + indsOffset);
const u16 *indsIn = inds + indsOffset;
int newIndsOffset = indsOffset + vertexCount;
u16 *indsOut = inds + newIndsOffset;

Expand Down Expand Up @@ -888,10 +897,13 @@ bool SoftwareTransform::ExpandLines(int vertexCount, int &maxIndex, u16 *inds, i
return true;
}

// indsOffset is in indices, so half what the byte offset would be.
// indexBufferSize is also in indices, not bytes.
bool SoftwareTransform::ExpandPoints(int vertexCount, int &maxIndex, u16 *inds, int &indsOffset, int indexBufferSize, const TransformedVertex *transformed, TransformedVertex *transformedExpanded, int &numTrans, bool throughmode) {
// Before we start, do a sanity check - does the output fit?
if (vertexCount * 6 > indexBufferSize - indsOffset) {
// Won't fit, kill the draw.
// Won't fit, report and kill the draw.
ReportExpandOverflow("points", vertexCount, indexBufferSize - indsOffset);
return false;
}

Expand Down
1 change: 1 addition & 0 deletions GPU/GLES/ShaderManagerGLES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ LinkedShader::LinkedShader(GLRenderManager *render, VShaderID VSID, Shader *vs,
: render_(render), useHWTransform_(useHWTransform) {
PROFILE_THIS_SCOPE("shaderlink");

_assert_(render);
_assert_(vs);
_assert_(fs);

Expand Down
2 changes: 2 additions & 0 deletions UI/OnScreenDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,8 @@ void OnScreenMessagesView::Draw(UIContext &dc) {
// Save the location of the popup, for easy dismissal.
dismissZones.push_back(ClickZone{ (int)j, b });
break;
default:
break;
}
break;
}
Expand Down
6 changes: 4 additions & 2 deletions android/src/org/ppsspp/ppsspp/NativeActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ public abstract class NativeActivity extends Activity {
// Allows us to skip a lot of initialization on secondary calls to onCreate.
private static boolean initialized = false;

// False to use C++ EGL, queried from C++ after NativeApp.init.
// False to use Vulkan, queried from C++ after NativeApp.init.
private static boolean javaGL = true;

// Graphics and audio interfaces for EGL (javaGL = false)
// Graphics and audio interfaces for Vulkan (javaGL = false)
private NativeSurfaceView mSurfaceView;
private Surface mSurface;
private Thread mRenderLoopThread = null;
Expand Down Expand Up @@ -724,6 +724,7 @@ private synchronized void joinRenderLoopThread() {
mRenderLoopThread = null;
} catch (InterruptedException e) {
e.printStackTrace();
mRenderLoopThread = null;
}
}
}
Expand Down Expand Up @@ -766,6 +767,7 @@ protected void onDestroy() {
} else {
mSurfaceView.onDestroy();
mSurfaceView = null;
mSurface = null;
}

// Probably vain attempt to help the garbage collector...
Expand Down

0 comments on commit c2406ae

Please sign in to comment.