From a1f59deafe0faf27f8947ab1cc5286d4af508293 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 19 Mar 2017 07:44:02 -0700 Subject: [PATCH] Fix some type narrowing warnings and typos. --- Common/Vulkan/VulkanMemory.cpp | 8 ++++---- Common/Vulkan/VulkanMemory.h | 2 +- Core/Config.cpp | 2 -- Core/FileLoaders/RamCachingFileLoader.cpp | 8 ++++---- GPU/Common/ShaderTranslation.cpp | 2 +- GPU/Directx9/PixelShaderGeneratorDX9.cpp | 2 +- Windows/DSoundStream.cpp | 3 +-- 7 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Common/Vulkan/VulkanMemory.cpp b/Common/Vulkan/VulkanMemory.cpp index 1dbbf65168..8dfadddae0 100644 --- a/Common/Vulkan/VulkanMemory.cpp +++ b/Common/Vulkan/VulkanMemory.cpp @@ -143,8 +143,8 @@ size_t VulkanDeviceAllocator::Allocate(const VkMemoryRequirements &reqs, VkDevic return ALLOCATE_FAILED; } - size_t align = reqs.alignment <= SLAB_GRAIN_SIZE ? 1 : (reqs.alignment >> SLAB_GRAIN_SHIFT); - size_t blocks = (reqs.size + SLAB_GRAIN_SIZE - 1) >> SLAB_GRAIN_SHIFT; + size_t align = reqs.alignment <= SLAB_GRAIN_SIZE ? 1 : (size_t)(reqs.alignment >> SLAB_GRAIN_SHIFT); + size_t blocks = (size_t)((reqs.size + SLAB_GRAIN_SIZE - 1) >> SLAB_GRAIN_SHIFT); const size_t numSlabs = slabs_.size(); for (size_t i = 0; i < numSlabs; ++i) { @@ -298,7 +298,7 @@ void VulkanDeviceAllocator::ExecuteFree(FreeInfo *userdata) { delete userdata; } -bool VulkanDeviceAllocator::AllocateSlab(size_t minBytes) { +bool VulkanDeviceAllocator::AllocateSlab(VkDeviceSize minBytes) { assert(!destroyed_); if (!slabs_.empty() && minSlabSize_ < maxSlabSize_) { // We're allocating an additional slab, so rachet up its size. @@ -325,7 +325,7 @@ bool VulkanDeviceAllocator::AllocateSlab(size_t minBytes) { slabs_.resize(slabs_.size() + 1); Slab &slab = slabs_[slabs_.size() - 1]; slab.deviceMemory = deviceMemory; - slab.usage.resize(alloc.allocationSize >> SLAB_GRAIN_SHIFT); + slab.usage.resize((size_t)(alloc.allocationSize >> SLAB_GRAIN_SHIFT)); return true; } diff --git a/Common/Vulkan/VulkanMemory.h b/Common/Vulkan/VulkanMemory.h index a11be58f93..a24a6c04f4 100644 --- a/Common/Vulkan/VulkanMemory.h +++ b/Common/Vulkan/VulkanMemory.h @@ -188,7 +188,7 @@ private: freeInfo->allocator->ExecuteFree(freeInfo); } - bool AllocateSlab(size_t minBytes); + bool AllocateSlab(VkDeviceSize minBytes); bool AllocateFromSlab(Slab &slab, size_t &start, size_t blocks); void Decimate(); void ExecuteFree(FreeInfo *userdata); diff --git a/Core/Config.cpp b/Core/Config.cpp index 2b9fa35e9b..fc198df165 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -469,10 +469,8 @@ static ConfigSetting graphicsSettings[] = { ReportedConfigSetting("AutoFrameSkip", &g_Config.bAutoFrameSkip, false, true, true), ConfigSetting("FrameRate", &g_Config.iFpsLimit, 0, true, true), ConfigSetting("FrameSkipUnthrottle", &g_Config.bFrameSkipUnthrottle, &DefaultFrameskipUnthrottle, true, false), -#ifdef _WIN32 #if defined(USING_WIN_UI) ConfigSetting("RestartRequired", &g_Config.bRestartRequired, false, false), -#endif #endif ReportedConfigSetting("ForceMaxEmulatedFPS", &g_Config.iForceMaxEmulatedFPS, 60, true, true), diff --git a/Core/FileLoaders/RamCachingFileLoader.cpp b/Core/FileLoaders/RamCachingFileLoader.cpp index 0b856eb402..91a3e9d61e 100644 --- a/Core/FileLoaders/RamCachingFileLoader.cpp +++ b/Core/FileLoaders/RamCachingFileLoader.cpp @@ -160,7 +160,7 @@ size_t RamCachingFileLoader::ReadFromCache(s64 pos, size_t bytes, void *data) { std::lock_guard guard(blocksMutex_); for (s64 i = cacheStartPos; i <= cacheEndPos; ++i) { - if (blocks_[i] == 0) { + if (blocks_[(size_t)i] == 0) { return readSize; } @@ -186,7 +186,7 @@ void RamCachingFileLoader::SaveIntoCache(s64 pos, size_t bytes, Flags flags) { { std::lock_guard guard(blocksMutex_); for (s64 i = cacheStartPos; i <= cacheEndPos; ++i) { - if (blocks_[i] == 0) { + if (blocks_[(size_t)i] == 0) { ++blocksToRead; if (blocksToRead >= MAX_BLOCKS_PER_READ) { break; @@ -208,8 +208,8 @@ void RamCachingFileLoader::SaveIntoCache(s64 pos, size_t bytes, Flags flags) { // In case they were simultaneously read. u32 blocksRead = 0; for (size_t i = 0; i < blocksActuallyRead; ++i) { - if (blocks_[cacheStartPos + i] == 0) { - blocks_[cacheStartPos + i] = 1; + if (blocks_[(size_t)cacheStartPos + i] == 0) { + blocks_[(size_t)cacheStartPos + i] = 1; ++blocksRead; } } diff --git a/GPU/Common/ShaderTranslation.cpp b/GPU/Common/ShaderTranslation.cpp index 5a0e9027ab..fa153c3b14 100644 --- a/GPU/Common/ShaderTranslation.cpp +++ b/GPU/Common/ShaderTranslation.cpp @@ -119,7 +119,7 @@ static const Builtin replacements[] = { static const char *cbufferDecl = R"( cbuffer data : register(b0) { float2 u_texelDelta; - float2 u_pixelDelta; + float2 u_pixelDelta; float4 u_time; }; )"; diff --git a/GPU/Directx9/PixelShaderGeneratorDX9.cpp b/GPU/Directx9/PixelShaderGeneratorDX9.cpp index a38a40999a..5a26ba0755 100644 --- a/GPU/Directx9/PixelShaderGeneratorDX9.cpp +++ b/GPU/Directx9/PixelShaderGeneratorDX9.cpp @@ -117,7 +117,7 @@ bool GenerateFragmentShaderHLSL(const ShaderID &id, char *buffer, ShaderLanguage if (enableAlphaTest) { if (lang == HLSL_D3D11) { - WRITE(p, "int roundAndScaleTo255i(float x) { return uint(floor(x * 255.0f + 0.5f)); }\n"); + WRITE(p, "int roundAndScaleTo255i(float x) { return int(floor(x * 255.0f + 0.5f)); }\n"); } else { // D3D11 level 9 gets to take this path. WRITE(p, "float roundAndScaleTo255f(float x) { return floor(x * 255.0f + 0.5f); }\n"); diff --git a/Windows/DSoundStream.cpp b/Windows/DSoundStream.cpp index 60b000f32e..d7bb534fc9 100644 --- a/Windows/DSoundStream.cpp +++ b/Windows/DSoundStream.cpp @@ -8,7 +8,6 @@ #include "Core/Reporting.h" #include "Core/Util/AudioFormat.h" #include "Windows/W32Util/Misc.h" -#include "Common/OSVersion.h" #include "dsoundstream.h" @@ -477,4 +476,4 @@ WindowsAudioBackend *CreateAudioBackend(AudioBackendType type) { } else { return new DSoundAudioBackend(); } -} \ No newline at end of file +}