More lint warning fixes

This commit is contained in:
Henrik Rydgård 2024-10-10 10:46:52 +02:00
parent 21c6594961
commit e0c12c9547
22 changed files with 54 additions and 51 deletions

View File

@ -351,7 +351,7 @@ D3D11DrawContext::D3D11DrawContext(ID3D11Device *device, ID3D11DeviceContext *de
const size_t UP_MAX_BYTES = 65536 * 24;
upBuffer_ = CreateBuffer(UP_MAX_BYTES, BufferUsageFlag::DYNAMIC | BufferUsageFlag::VERTEXDATA);
upBuffer_ = D3D11DrawContext::CreateBuffer(UP_MAX_BYTES, BufferUsageFlag::DYNAMIC | BufferUsageFlag::VERTEXDATA);
IDXGIDevice1 *dxgiDevice1 = nullptr;
hr = device_->QueryInterface(__uuidof(IDXGIDevice), reinterpret_cast<void **>(&dxgiDevice1));

View File

@ -385,7 +385,7 @@ private:
void PerformReadback(const GLRStep &pass);
void PerformReadbackImage(const GLRStep &pass);
void fbo_ext_create(const GLRInitStep &step);
void fbo_ext_create(const GLRInitStep &step); // Unused on some platforms
void fbo_bind_fb_target(bool read, GLuint name);
GLenum fbo_get_fb_target(bool read, GLuint **cached);
void fbo_unbind();

View File

@ -245,7 +245,7 @@ private:
};
bool OpenGLShaderModule::Compile(GLRenderManager *render, ShaderLanguage language, const uint8_t *data, size_t dataSize) {
source_ = std::string((const char *)data);
source_ = std::string((const char *)data, dataSize);
// Add the prelude on automatically.
if (glstage_ == GL_FRAGMENT_SHADER || glstage_ == GL_VERTEX_SHADER) {
if (source_.find("#version") == source_.npos) {
@ -646,7 +646,7 @@ OpenGLContext::OpenGLContext(bool canChangeSwapInterval) : renderManager_(frameT
// Note: this is for Intel drivers with GL3+.
// Also on Intel, see https://github.com/hrydgard/ppsspp/issues/10117
// TODO: Remove entirely sometime reasonably far in driver years after 2015.
const std::string ver = GetInfoString(Draw::InfoField::APIVERSION);
const std::string ver = OpenGLContext::GetInfoString(Draw::InfoField::APIVERSION);
int versions[4]{};
if (sscanf(ver.c_str(), "Build %d.%d.%d.%d", &versions[0], &versions[1], &versions[2], &versions[3]) == 4) {
if (HasIntelDualSrcBug(versions)) {
@ -962,7 +962,7 @@ void OpenGLTexture::SetImageData(int x, int y, int z, int width, int height, int
depth_ = depth;
}
if (stride == 0)
if (!stride)
stride = width;
size_t alignment = DataFormatSizeInBytes(format_);

View File

@ -42,7 +42,6 @@ VKAPI_ATTR VkBool32 VKAPI_CALL VulkanDebugUtilsCallback(
VkDebugUtilsMessageTypeFlagsEXT messageType,
const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData,
void *pUserData) {
const VulkanLogOptions *options = (const VulkanLogOptions *)pUserData;
std::ostringstream message;
const char *pMessage = pCallbackData->pMessage;
@ -149,6 +148,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL VulkanDebugUtilsCallback(
std::string msg = message.str();
#ifdef _WIN32
const VulkanLogOptions *options = (const VulkanLogOptions *)pUserData;
OutputDebugStringA(msg.c_str());
if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) {
if (options->breakOnError && System_GetPropertyBool(SYSPROP_DEBUGGER_PRESENT)) {

View File

@ -51,10 +51,10 @@ bool VulkanTexture::CreateDirect(int w, int h, int depth, int numMips, VkFormat
Wipe();
width_ = w;
height_ = h;
depth_ = depth;
numMips_ = numMips;
width_ = (int16_t)w;
height_ = (int16_t)h;
depth_ = (int16_t)depth;
numMips_ = (int16_t)numMips;
format_ = format;
VkImageAspectFlags aspect = IsDepthStencilFormat(format) ? VK_IMAGE_ASPECT_DEPTH_BIT : VK_IMAGE_ASPECT_COLOR_BIT;
@ -86,6 +86,14 @@ bool VulkanTexture::CreateDirect(int w, int h, int depth, int numMips, VkFormat
allocCreateInfo.usage = VMA_MEMORY_USAGE_GPU_ONLY;
VmaAllocationInfo allocInfo{};
VkResult res = vmaCreateImage(vulkan_->Allocator(), &image_create_info, &allocCreateInfo, &image_, &allocation_, &allocInfo);
if (res != VK_SUCCESS) {
ERROR_LOG(Log::G3D, "vmaCreateImage failed: %s. Destroying image.", VulkanResultToString(res));
_dbg_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);
view_ = VK_NULL_HANDLE;
image_ = VK_NULL_HANDLE;
allocation_ = VK_NULL_HANDLE;
return false;
}
// Apply the tag
vulkan_->SetDebugName(image_, VK_OBJECT_TYPE_IMAGE, tag_);

View File

@ -373,6 +373,7 @@ static VulkanLibraryHandle VulkanLoadLibrary(std::string *errorString) {
(std::string(fileRedirectDir.c_str()) + "/").c_str(), nullptr);
if (!lib) {
ERROR_LOG(Log::G3D, "Failed to load custom driver with AdrenoTools ('%s')", g_Config.sCustomDriver.c_str());
*errorString = "Failed to load custom driver";
} else {
INFO_LOG(Log::G3D, "Vulkan library loaded with AdrenoTools ('%s')", g_Config.sCustomDriver.c_str());
}
@ -388,6 +389,9 @@ static VulkanLibraryHandle VulkanLoadLibrary(std::string *errorString) {
break;
}
}
if (!lib) {
*errorString = "No vulkan library found";
}
}
return lib;
#endif
@ -481,7 +485,7 @@ bool VulkanMayBeAvailable() {
#elif defined(VK_USE_PLATFORM_METAL_EXT)
const char * const platformSurfaceExtension = VK_EXT_METAL_SURFACE_EXTENSION_NAME;
#else
const char *platformSurfaceExtension = 0;
const char *platformSurfaceExtension = nullptr;
#endif
if (!localEnumerateInstanceExtensionProperties || !localCreateInstance || !localEnumerate || !localDestroyInstance || !localGetPhysicalDeviceProperties) {

View File

@ -390,7 +390,7 @@ public:
data.blendColor.color = color;
}
void PushConstants(VkPipelineLayout pipelineLayout, VkShaderStageFlags stages, int offset, int size, void *constants) {
void PushConstants(VkShaderStageFlags stages, int offset, int size, void *constants) {
_dbg_assert_(curRenderStep_ && curRenderStep_->stepType == VKRStepType::RENDER);
_dbg_assert_(size + offset < 40);
VkRenderData &data = curRenderStep_->commands.push_uninitialized();

View File

@ -148,7 +148,7 @@ public:
class VKRasterState : public RasterState {
public:
VKRasterState(VulkanContext *vulkan, const RasterStateDesc &desc) {
VKRasterState(const RasterStateDesc &desc) {
cullFace = desc.cull;
frontFace = desc.frontFace;
}
@ -187,7 +187,7 @@ public:
VKShaderModule(ShaderStage stage, const std::string &tag) : stage_(stage), tag_(tag) {
vkstage_ = StageToVulkan(stage);
}
bool Compile(VulkanContext *vulkan, ShaderLanguage language, const uint8_t *data, size_t size);
bool Compile(VulkanContext *vulkan, const uint8_t *data, size_t size);
const std::string &GetSource() const { return source_; }
~VKShaderModule() {
if (module_) {
@ -214,7 +214,7 @@ private:
std::string tag_;
};
bool VKShaderModule::Compile(VulkanContext *vulkan, ShaderLanguage language, const uint8_t *data, size_t size) {
bool VKShaderModule::Compile(VulkanContext *vulkan, const uint8_t *data, size_t size) {
// We'll need this to free it later.
vulkan_ = vulkan;
source_ = (const char *)data;
@ -327,7 +327,7 @@ struct DescriptorSetKey {
class VKTexture : public Texture {
public:
VKTexture(VulkanContext *vulkan, VkCommandBuffer cmd, VulkanPushPool *pushBuffer, const TextureDesc &desc)
VKTexture(VulkanContext *vulkan, const TextureDesc &desc)
: vulkan_(vulkan), mipLevels_(desc.mipLevels) {
format_ = desc.format;
}
@ -757,7 +757,7 @@ SamplerState *VKContext::CreateSamplerState(const SamplerStateDesc &desc) {
}
RasterState *VKContext::CreateRasterState(const RasterStateDesc &desc) {
return new VKRasterState(vulkan_, desc);
return new VKRasterState(desc);
}
void VKContext::BindSamplerStates(int start, int count, SamplerState **state) {
@ -877,8 +877,6 @@ VKContext::VKContext(VulkanContext *vulkan, bool useRenderThread)
: vulkan_(vulkan), renderManager_(vulkan, useRenderThread, frameTimeHistory_) {
shaderLanguageDesc_.Init(GLSL_VULKAN);
VkFormat depthStencilFormat = vulkan->GetDeviceInfo().preferredDepthStencilFormat;
INFO_LOG(Log::G3D, "Determining Vulkan device caps");
caps_.setMaxFrameLatencySupported = true;
@ -1160,7 +1158,6 @@ void VKContext::BindDescriptors(VkBuffer buf, PackedDescriptor descriptors[4]) {
descriptors[0].buffer.offset = 0; // dynamic
descriptors[0].buffer.range = curPipeline_->GetUBOSize();
int numDescs = 1;
for (int i = 0; i < MAX_BOUND_TEXTURES; ++i) {
VkImageView view;
VkSampler sampler;
@ -1252,7 +1249,6 @@ Pipeline *VKContext::CreateGraphicsPipeline(const PipelineDesc &desc, const char
gDesc.pipelineLayout = pipelineLayout_;
VkPipelineRasterizationStateCreateInfo rs{ VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO };
raster->ToVulkan(&gDesc.rs);
if (renderManager_.GetVulkanContext()->GetDeviceFeatures().enabled.provokingVertex.provokingVertexLast) {
@ -1328,7 +1324,7 @@ Texture *VKContext::CreateTexture(const TextureDesc &desc) {
ERROR_LOG(Log::G3D, "Can't create textures before the first frame has started.");
return nullptr;
}
VKTexture *tex = new VKTexture(vulkan_, initCmd, push_, desc);
VKTexture *tex = new VKTexture(vulkan_, desc);
if (tex->Create(initCmd, &renderManager_.PostInitBarrier(), push_, desc)) {
return tex;
} else {
@ -1396,7 +1392,7 @@ BlendState *VKContext::CreateBlendState(const BlendStateDesc &desc) {
// to avoid synchronization issues.
class VKBuffer : public Buffer {
public:
VKBuffer(size_t size, uint32_t flags) : dataSize_(size) {
VKBuffer(size_t size) : dataSize_(size) {
data_ = new uint8_t[size];
}
~VKBuffer() {
@ -1411,7 +1407,7 @@ public:
};
Buffer *VKContext::CreateBuffer(size_t size, uint32_t usageFlags) {
return new VKBuffer(size, usageFlags);
return new VKBuffer(size);
}
void VKContext::UpdateBuffer(Buffer *buffer, const uint8_t *data, size_t offset, size_t size, UpdateBufferFlags flags) {
@ -1451,7 +1447,7 @@ void VKContext::BindNativeTexture(int sampler, void *nativeTexture) {
ShaderModule *VKContext::CreateShaderModule(ShaderStage stage, ShaderLanguage language, const uint8_t *data, size_t size, const char *tag) {
VKShaderModule *shader = new VKShaderModule(stage, tag);
if (shader->Compile(vulkan_, language, data, size)) {
if (shader->Compile(vulkan_, data, size)) {
return shader;
} else {
ERROR_LOG(Log::G3D, "Failed to compile shader %s:\n%s", tag, (const char *)LineNumberString((const char *)data).c_str());

View File

@ -512,13 +512,13 @@ HTTPRequest::HTTPRequest(RequestMethod method, const std::string &url, const std
}
HTTPRequest::~HTTPRequest() {
g_OSD.RemoveProgressBar(url_, Failed() ? false : true, 0.5f);
g_OSD.RemoveProgressBar(url_, !failed_, 0.5f);
_assert_msg_(joined_, "Download destructed without join");
}
void HTTPRequest::Start() {
thread_ = std::thread(std::bind(&HTTPRequest::Do, this));
thread_ = std::thread([this] { Do(); });
}
void HTTPRequest::Join() {

View File

@ -17,7 +17,7 @@ HTTPSRequest::HTTPSRequest(RequestMethod method, const std::string &url, const s
}
HTTPSRequest::~HTTPSRequest() {
Join();
HTTPSRequest::Join();
}
void HTTPSRequest::Start() {
@ -53,7 +53,7 @@ void HTTPSRequest::Join() {
if (!res_ || !req_)
return; // No pending operation.
// Tear down.
if (completed_ && res_) {
if (completed_) {
_dbg_assert_(req_);
naettClose(res_);
naettFree(req_);

View File

@ -37,7 +37,7 @@ TextDrawerAndroid::~TextDrawerAndroid() {
// At worst we leak one ref...
// env_->DeleteGlobalRef(cls_textRenderer);
ClearCache();
ClearFonts();
fontMap_.clear(); // size is precomputed using dpiScale_.
}
bool TextDrawerAndroid::IsReady() const {
@ -58,8 +58,8 @@ uint32_t TextDrawerAndroid::SetFont(const char *fontName, int size, int flags) {
}
// Just chose a factor that looks good, don't know what unit size is in anyway.
AndroidFontEntry entry;
entry.size = (float)(size * 1.4f) / dpiScale_;
AndroidFontEntry entry{};
entry.size = ((float)size * 1.4f) / dpiScale_;
fontMap_[fontHash] = entry;
fontHash_ = fontHash;
return fontHash;

View File

@ -61,7 +61,9 @@ void ScreenManager::switchScreen(Screen *screen) {
WARN_LOG(Log::System, "Switching to a zero screen, this can't be good");
}
if (stack_.empty() || screen != stack_.back().screen) {
screen->setScreenManager(this);
if (screen) {
screen->setScreenManager(this);
}
nextStack_.push_back({ screen, 0 });
}
}

View File

@ -53,7 +53,6 @@ class StringVectorListAdapter : public UIListAdapter {
public:
StringVectorListAdapter(const std::vector<std::string> *items) : items_(items) {}
size_t getCount() const override { return items_->size(); }
void drawItem(int item, int x, int y, int w, int h, bool active) const override;
private:
const std::vector<std::string> *items_;

View File

@ -69,7 +69,7 @@ public:
virtual void SetBG(const Drawable &bg) { bg_ = bg; }
virtual void Clear();
void Clear();
void PersistData(PersistStatus status, std::string anonId, PersistMap &storage) override;
View *GetViewByIndex(int index) { return views_[index]; }
int GetNumSubviews() const { return (int)views_.size(); }

View File

@ -211,7 +211,6 @@ public:
void FlushBGs(); // Gets rid of all BG textures. Also gets rid of bg sounds.
void CancelAll();
void WaitUntilDone(std::shared_ptr<GameInfo> &info);
private:
void Init();

View File

@ -520,8 +520,6 @@ void PromptScreen::CreateViews() {
// Scrolling action menu to the right.
using namespace UI;
Margins actionMenuMargins(0, 100, 15, 0);
root_ = new AnchorLayout();
root_->Add(new TextView(message_, ALIGN_LEFT | FLAG_WRAP_TEXT, false, new AnchorLayoutParams(WRAP_CONTENT, WRAP_CONTENT, 15, 15, 330, 10)))->SetClip(false);

View File

@ -187,8 +187,6 @@ static void MeasureOSDProgressBar(const UIContext &dc, const OnScreenDisplay::En
}
static void RenderOSDProgressBar(UIContext &dc, const OnScreenDisplay::Entry &entry, Bounds bounds, int align, float alpha) {
uint32_t foreGround = whiteAlpha(alpha);
dc.DrawRectDropShadow(bounds, 12.0f, 0.7f * alpha);
uint32_t backgroundColor = colorAlpha(0x806050, alpha);

View File

@ -77,7 +77,7 @@ RatingChoice::RatingChoice(std::string_view captionKey, int *value, LayoutParams
Add(group_);
group_->SetSpacing(0.0f);
SetupChoices();
RatingChoice::SetupChoices();
}
void RatingChoice::Update() {
@ -147,7 +147,7 @@ protected:
CompatRatingChoice::CompatRatingChoice(const char *captionKey, int *value, LayoutParams *layoutParams)
: RatingChoice(captionKey, value, layoutParams) {
SetupChoices();
CompatRatingChoice::SetupChoices();
}
void CompatRatingChoice::SetupChoices() {

View File

@ -14,7 +14,7 @@
#include "UI/OnScreenDisplay.h"
static inline std::string_view DeNull(const char *ptr) {
return ptr ? std::string_view(ptr) : "";
return std::string_view(ptr ? ptr : "");
}
// Compound view, creating a FileChooserChoice inside.
@ -221,9 +221,9 @@ void RetroAchievementsLeaderboardScreen::CreateTabs() {
const rc_client_leaderboard_entry_t &entry = entryList_->entries[i];
char buffer[512];
rc_client_leaderboard_entry_get_user_image_url(&entryList_->entries[i], buffer, sizeof(buffer));
rc_client_leaderboard_entry_get_user_image_url(&entry, buffer, sizeof(buffer));
// Can also show entry.submitted, which is a time_t. And maybe highlight recent ones?
layout->Add(new LeaderboardEntryView(&entryList_->entries[i], is_self));
layout->Add(new LeaderboardEntryView(&entry, is_self));
}
}
}

View File

@ -65,7 +65,7 @@ void TiltAnalogSettingsScreen::CreateViews() {
switch (g_Config.iTiltInputType) {
case TILT_DPAD:
{
PSPDpad *pad = rightSide->Add(new PSPDpad(ImageID("I_DIR_LINE"), "D-pad", ImageID("I_DIR_LINE"), ImageID("I_ARROW"), 1.5f, 1.3f, new AnchorLayoutParams(NONE, NONE, NONE, NONE, true)));
rightSide->Add(new PSPDpad(ImageID("I_DIR_LINE"), "D-pad", ImageID("I_DIR_LINE"), ImageID("I_ARROW"), 1.5f, 1.3f, new AnchorLayoutParams(NONE, NONE, NONE, NONE, true)));
break;
}
case TILT_ACTION_BUTTON:

View File

@ -286,7 +286,6 @@ public:
void Draw(UIContext &dc) override {
float opacity = GamepadGetOpacity();
uint32_t colorBg = colorAlpha(GetButtonColor(), opacity);
uint32_t downBg = colorAlpha(0x00FFFFFF, opacity * 0.5f);
const ImageID stickImage = g_Config.iTouchButtonStyle ? ImageID("I_STICK_LINE") : ImageID("I_STICK");
const ImageID stickBg = g_Config.iTouchButtonStyle ? ImageID("I_STICK_BG_LINE") : ImageID("I_STICK_BG");
@ -379,7 +378,6 @@ bool ControlLayoutView::Touch(const TouchInput &touch) {
if ((touch.flags & TOUCH_MOVE) && pickedControl_ != nullptr) {
if (mode_ == 0) {
const Bounds &controlBounds = pickedControl_->GetBounds();
// Allow placing the control halfway outside the play area.
Bounds validRange = this->GetBounds();
@ -387,7 +385,9 @@ bool ControlLayoutView::Touch(const TouchInput &touch) {
validRange.x = 0.0f;
validRange.y = 0.0f;
// This make cure the controll is all inside the screen (commended out only half)
// TODO: Worth keeping?
// This make sure the control is all inside the screen (commented out only half)
// const Bounds &controlBounds = pickedControl_->GetBounds();
//validRange.x += controlBounds.w * 0.5f;
//validRange.w -= controlBounds.w;
//validRange.y += controlBounds.h * 0.5f;
@ -478,7 +478,6 @@ void ControlLayoutView::CreateViews() {
ImageID shoulderImage = g_Config.iTouchButtonStyle ? ImageID("I_SHOULDER_LINE") : ImageID("I_SHOULDER");
ImageID stickImage = g_Config.iTouchButtonStyle ? ImageID("I_STICK_LINE") : ImageID("I_STICK");
ImageID stickBg = g_Config.iTouchButtonStyle ? ImageID("I_STICK_BG_LINE") : ImageID("I_STICK_BG");
ImageID roundImage = g_Config.iTouchButtonStyle ? ImageID("I_ROUND_LINE") : ImageID("I_ROUND");
auto addDragDropButton = [&](ConfigTouchPos &pos, const char *key, ImageID bgImg, ImageID img) {
DragDropButton *b = nullptr;

View File

@ -291,7 +291,7 @@ OpenSLContext::~OpenSLContext() {
(*outputMixObject)->Destroy(outputMixObject);
outputMixObject = nullptr;
}
AudioRecord_Stop();
OpenSLContext::AudioRecord_Stop();
INFO_LOG(Log::Audio, "OpenSL: Shutdown - deleting engine object");