From a3d82ef5d90b02a256087edf9c0124b51b059c18 Mon Sep 17 00:00:00 2001 From: Subv Date: Wed, 20 Jun 2018 11:39:10 -0500 Subject: [PATCH] Build: Fixed some MSVC warnings in various parts of the code. --- src/core/file_sys/partition_filesystem.cpp | 6 +++--- src/core/file_sys/partition_filesystem.h | 6 +++--- src/core/hle/kernel/svc.cpp | 4 ++-- src/core/hle/service/audio/audren_u.cpp | 2 +- src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp | 3 ++- src/video_core/engines/maxwell_3d.cpp | 5 +++-- src/video_core/engines/shader_bytecode.h | 4 ++-- src/video_core/renderer_opengl/gl_rasterizer.cpp | 4 ++-- src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 2 +- src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 2 +- src/video_core/renderer_opengl/gl_shader_manager.cpp | 4 ++-- src/video_core/renderer_opengl/gl_state.cpp | 4 ++-- 12 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/core/file_sys/partition_filesystem.cpp b/src/core/file_sys/partition_filesystem.cpp index 808254ecc8..86a01a5eba 100644 --- a/src/core/file_sys/partition_filesystem.cpp +++ b/src/core/file_sys/partition_filesystem.cpp @@ -73,21 +73,21 @@ u32 PartitionFilesystem::GetNumEntries() const { return pfs_header.num_entries; } -u64 PartitionFilesystem::GetEntryOffset(int index) const { +u64 PartitionFilesystem::GetEntryOffset(u32 index) const { if (index > GetNumEntries()) return 0; return content_offset + pfs_entries[index].fs_entry.offset; } -u64 PartitionFilesystem::GetEntrySize(int index) const { +u64 PartitionFilesystem::GetEntrySize(u32 index) const { if (index > GetNumEntries()) return 0; return pfs_entries[index].fs_entry.size; } -std::string PartitionFilesystem::GetEntryName(int index) const { +std::string PartitionFilesystem::GetEntryName(u32 index) const { if (index > GetNumEntries()) return ""; diff --git a/src/core/file_sys/partition_filesystem.h b/src/core/file_sys/partition_filesystem.h index 573c90057f..65cf572f42 100644 --- a/src/core/file_sys/partition_filesystem.h +++ b/src/core/file_sys/partition_filesystem.h @@ -27,9 +27,9 @@ public: Loader::ResultStatus Load(const std::vector& file_data, size_t offset = 0); u32 GetNumEntries() const; - u64 GetEntryOffset(int index) const; - u64 GetEntrySize(int index) const; - std::string GetEntryName(int index) const; + u64 GetEntryOffset(u32 index) const; + u64 GetEntrySize(u32 index) const; + std::string GetEntryName(u32 index) const; u64 GetFileOffset(const std::string& name) const; u64 GetFileSize(const std::string& name) const; diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 097416e9e2..69ba7b7774 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -749,7 +749,7 @@ static ResultCode SetThreadCoreMask(Handle thread_handle, u32 core, u64 mask) { ASSERT(thread->owner_process->ideal_processor != THREADPROCESSORID_DEFAULT); // Set the target CPU to the one specified in the process' exheader. core = thread->owner_process->ideal_processor; - mask = 1 << core; + mask = 1ull << core; } if (mask == 0) { @@ -766,7 +766,7 @@ static ResultCode SetThreadCoreMask(Handle thread_handle, u32 core, u64 mask) { } // Error out if the input core isn't enabled in the input mask. - if (core < Core::NUM_CPU_CORES && (mask & (1 << core)) == 0) { + if (core < Core::NUM_CPU_CORES && (mask & (1ull << core)) == 0) { return ResultCode(ErrorModule::Kernel, ErrCodes::InvalidCombination); } diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index 6e8002bc9d..c7653f6542 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp @@ -328,7 +328,7 @@ bool AudRenU::IsFeatureSupported(AudioFeatures feature, u32_le revision) const { u32_be version_num = (revision - Common::MakeMagic('R', 'E', 'V', '0')); // Byte swap switch (feature) { case AudioFeatures::Splitter: - return version_num >= 2; + return version_num >= 2u; default: return false; } diff --git a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp index 79aab87f96..ed7b6dc036 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_gpu.cpp @@ -121,8 +121,9 @@ u32 nvhost_gpu::AllocateObjectContext(const std::vector& input, std::vector< } u32 nvhost_gpu::SubmitGPFIFO(const std::vector& input, std::vector& output) { - if (input.size() < sizeof(IoctlSubmitGpfifo)) + if (input.size() < sizeof(IoctlSubmitGpfifo)) { UNIMPLEMENTED(); + } IoctlSubmitGpfifo params{}; std::memcpy(¶ms, input.data(), sizeof(IoctlSubmitGpfifo)); NGLOG_WARNING(Service_NVDRV, "(STUBBED) called, gpfifo={:X}, num_entries={:X}, flags={:X}", diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 86e9dc998c..93c43c8cbc 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp @@ -328,8 +328,9 @@ std::vector Maxwell3D::GetStageTextures(Regs::ShaderSt Texture::FullTextureInfo tex_info{}; // TODO(Subv): Use the shader to determine which textures are actually accessed. - tex_info.index = (current_texture - tex_info_buffer.address - TextureInfoOffset) / - sizeof(Texture::TextureHandle); + tex_info.index = + static_cast(current_texture - tex_info_buffer.address - TextureInfoOffset) / + sizeof(Texture::TextureHandle); // Load the TIC data. if (tex_handle.tic_id != 0) { diff --git a/src/video_core/engines/shader_bytecode.h b/src/video_core/engines/shader_bytecode.h index 5ff861b04c..cb4db06792 100644 --- a/src/video_core/engines/shader_bytecode.h +++ b/src/video_core/engines/shader_bytecode.h @@ -372,7 +372,7 @@ union Instruction { BitField<31, 4, u64> component_mask; bool IsComponentEnabled(size_t component) const { - return ((1 << component) & component_mask) != 0; + return ((1ull << component) & component_mask) != 0; } } tex; @@ -391,7 +391,7 @@ union Instruction { ASSERT(component_mask_selector < mask.size()); - return ((1 << component) & mask[component_mask_selector]) != 0; + return ((1ull << component) & mask[component_mask_selector]) != 0; } } texs; diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 833ff82737..3ba20f9787 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -633,7 +633,7 @@ u32 RasterizerOpenGL::SetupConstBuffers(Maxwell::ShaderStage stage, GLuint progr state.Apply(); - return current_bindpoint + entries.size(); + return current_bindpoint + static_cast(entries.size()); } u32 RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, GLuint program, u32 current_unit, @@ -679,7 +679,7 @@ u32 RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, GLuint program, state.Apply(); - return current_unit + entries.size(); + return current_unit + static_cast(entries.size()); } void RasterizerOpenGL::BindFramebufferSurfaces(const Surface& color_surface, diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index b2a61024e4..61d670dcbf 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -575,7 +575,7 @@ void CachedSurface::UploadGLTexture(const MathUtil::Rectangle& rect, GLuint glCompressedTexImage2D(GL_TEXTURE_2D, 0, tuple.internal_format, static_cast(rect.GetWidth() * GetCompresssionFactor()), static_cast(rect.GetHeight() * GetCompresssionFactor()), 0, - size, &gl_buffer[buffer_offset]); + static_cast(size), &gl_buffer[buffer_offset]); } else { glTexSubImage2D(GL_TEXTURE_2D, 0, x0, y0, static_cast(rect.GetWidth()), static_cast(rect.GetHeight()), tuple.format, tuple.type, diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index fc80d4b292..65fed77eff 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -535,7 +535,7 @@ private: */ void SetRegister(const Register& reg, u64 elem, const std::string& value, u64 dest_num_components, u64 value_num_components, u64 dest_elem) { - std::string dest = GetRegister(reg, dest_elem); + std::string dest = GetRegister(reg, static_cast(dest_elem)); if (dest_num_components > 1) { dest += GetSwizzle(elem); } diff --git a/src/video_core/renderer_opengl/gl_shader_manager.cpp b/src/video_core/renderer_opengl/gl_shader_manager.cpp index 7c00beb33a..d7167b2989 100644 --- a/src/video_core/renderer_opengl/gl_shader_manager.cpp +++ b/src/video_core/renderer_opengl/gl_shader_manager.cpp @@ -38,8 +38,8 @@ void MaxwellUniformData::SetFromRegs(const Maxwell3D::State::ShaderStageInfo& sh const auto& regs = Core::System().GetInstance().GPU().Maxwell3D().regs; // TODO(bunnei): Support more than one viewport - viewport_flip[0] = regs.viewport_transform[0].scale_x < 0.0 ? -1.0 : 1.0; - viewport_flip[1] = regs.viewport_transform[0].scale_y < 0.0 ? -1.0 : 1.0; + viewport_flip[0] = regs.viewport_transform[0].scale_x < 0.0 ? -1.0f : 1.0f; + viewport_flip[1] = regs.viewport_transform[0].scale_y < 0.0 ? -1.0f : 1.0f; } } // namespace GLShader diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp index 44f0c8a010..1f1e48425b 100644 --- a/src/video_core/renderer_opengl/gl_state.cpp +++ b/src/video_core/renderer_opengl/gl_state.cpp @@ -196,13 +196,13 @@ void OpenGLState::Apply() const { } // Textures - for (size_t i = 0; i < std::size(texture_units); ++i) { + for (int i = 0; i < std::size(texture_units); ++i) { if (texture_units[i].texture_2d != cur_state.texture_units[i].texture_2d) { glActiveTexture(TextureUnits::MaxwellTexture(i).Enum()); glBindTexture(GL_TEXTURE_2D, texture_units[i].texture_2d); } if (texture_units[i].sampler != cur_state.texture_units[i].sampler) { - glBindSampler(i, texture_units[i].sampler); + glBindSampler(static_cast(i), texture_units[i].sampler); } // Update the texture swizzle if (texture_units[i].swizzle.r != cur_state.texture_units[i].swizzle.r ||