Various warning fixes

This commit is contained in:
Connor McLaughlin 2021-02-06 19:19:55 +10:00
parent 3c910782ca
commit 701edb335a
28 changed files with 142 additions and 137 deletions

View File

@ -167,27 +167,26 @@ std::size_t Strlcpy(char* dst, const std::string_view& src, std::size_t size)
std::optional<std::vector<u8>> DecodeHex(const std::string_view& in) std::optional<std::vector<u8>> DecodeHex(const std::string_view& in)
{ {
std::vector<u8> data; std::vector<u8> data;
data.reserve(in.size()/2); data.reserve(in.size() / 2);
for (int i = 0; i < in.size()/2; i++) { for (size_t i = 0; i < in.size() / 2; i++)
auto byte = StringUtil::FromChars<u8>(in.substr(i*2, 2), 16); {
if (byte) { std::optional<u8> byte = StringUtil::FromChars<u8>(in.substr(i * 2, 2), 16);
if (byte.has_value())
data.push_back(*byte); data.push_back(*byte);
} else
else {
return std::nullopt; return std::nullopt;
} }
}
return { data }; return {data};
} }
std::string EncodeHex(const u8* data, int length) std::string EncodeHex(const u8* data, int length)
{ {
std::stringstream ss; std::stringstream ss;
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++)
ss << std::hex << std::setfill('0') << std::setw(2) << static_cast<int>(data[i]); ss << std::hex << std::setfill('0') << std::setw(2) << static_cast<int>(data[i]);
}
return ss.str(); return ss.str();
} }

View File

@ -133,8 +133,9 @@ static VkSurfaceKHR CreateDisplaySurface(VkInstance instance, VkPhysicalDevice p
{ {
Log_DevPrintf(" Mode %ux%u @ %u", mode.parameters.visibleRegion.width, mode.parameters.visibleRegion.height, Log_DevPrintf(" Mode %ux%u @ %u", mode.parameters.visibleRegion.width, mode.parameters.visibleRegion.height,
mode.parameters.refreshRate); mode.parameters.refreshRate);
if (!matched_mode && (wi.surface_width == 0 && wi.surface_height == 0) || if (!matched_mode &&
(mode.parameters.visibleRegion.width == wi.surface_width && mode.parameters.visibleRegion.height)) ((wi.surface_width == 0 && wi.surface_height == 0) ||
(mode.parameters.visibleRegion.width == wi.surface_width && mode.parameters.visibleRegion.height)))
{ {
matched_mode = &mode; matched_mode = &mode;
} }

View File

@ -9,7 +9,6 @@
#include "../string_util.h" #include "../string_util.h"
#include "context.h" #include "context.h"
#include "shader_compiler.h" #include "shader_compiler.h"
Log_SetChannel(Vulkan::Util);
namespace Vulkan { namespace Vulkan {
namespace Util { namespace Util {

View File

@ -361,7 +361,7 @@ void UpdateFastmemViews(CPUFastmemMode mode, bool isolate_cache)
u8* page_address = map_address + (i * HOST_PAGE_SIZE); u8* page_address = map_address + (i * HOST_PAGE_SIZE);
if (!m_memory_arena.SetPageProtection(page_address, HOST_PAGE_SIZE, true, false, false)) if (!m_memory_arena.SetPageProtection(page_address, HOST_PAGE_SIZE, true, false, false))
{ {
Log_ErrorPrintf("Failed to write-protect code page at %p"); Log_ErrorPrintf("Failed to write-protect code page at %p", page_address);
return; return;
} }
} }
@ -504,7 +504,7 @@ void SetCodePageFastmemProtection(u32 page_index, bool writable)
if (!m_memory_arena.SetPageProtection(page_address, HOST_PAGE_SIZE, true, writable, false)) if (!m_memory_arena.SetPageProtection(page_address, HOST_PAGE_SIZE, true, writable, false))
{ {
Log_ErrorPrintf("Failed to %s code page %u (0x%08X) @ %p", writable ? "unprotect" : "protect", page_index, Log_ErrorPrintf("Failed to %s code page %u (0x%08X) @ %p", writable ? "unprotect" : "protect", page_index,
page_index * HOST_PAGE_SIZE, page_address); page_index * static_cast<u32>(HOST_PAGE_SIZE), page_address);
} }
} }
@ -1421,8 +1421,6 @@ ALWAYS_INLINE_RELEASE static void WriteICache(VirtualMemoryAddress address, u32
static void WriteCacheControl(u32 value) static void WriteCacheControl(u32 value)
{ {
Log_DevPrintf("Cache control <- 0x%08X", value); Log_DevPrintf("Cache control <- 0x%08X", value);
CacheControl changed_bits{g_state.cache_control.bits ^ value};
g_state.cache_control.bits = value; g_state.cache_control.bits = value;
} }

View File

@ -1234,72 +1234,88 @@ void CheatCode::Apply() const
const u8 f1 = Truncate8((inst2.first & 0xFF000000u) >> 24); const u8 f1 = Truncate8((inst2.first & 0xFF000000u) >> 24);
const u8 f2 = Truncate8((inst2.first & 0x00FF0000u) >> 16); const u8 f2 = Truncate8((inst2.first & 0x00FF0000u) >> 16);
const u8 f3 = Truncate8((inst2.first & 0x0000FF00u) >> 8); const u8 f3 = Truncate8((inst2.first & 0x0000FF00u) >> 8);
const u8 f4 = Truncate8 (inst2.first & 0x000000FFu); const u8 f4 = Truncate8(inst2.first & 0x000000FFu);
const u8 f5 = Truncate8((inst2.value32 & 0xFF000000u) >> 24); const u8 f5 = Truncate8((inst2.value32 & 0xFF000000u) >> 24);
const u8 f6 = Truncate8((inst2.value32 & 0x00FF0000u) >> 16); const u8 f6 = Truncate8((inst2.value32 & 0x00FF0000u) >> 16);
const u8 f7 = Truncate8((inst2.value32 & 0x0000FF00u) >> 8); const u8 f7 = Truncate8((inst2.value32 & 0x0000FF00u) >> 8);
const u8 f8 = Truncate8 (inst2.value32 & 0x000000FFu); const u8 f8 = Truncate8(inst2.value32 & 0x000000FFu);
const u8 f9 = Truncate8((inst3.first & 0xFF000000u) >> 24); const u8 f9 = Truncate8((inst3.first & 0xFF000000u) >> 24);
const u8 f10 = Truncate8((inst3.first & 0x00FF0000u) >> 16); const u8 f10 = Truncate8((inst3.first & 0x00FF0000u) >> 16);
const u8 f11 = Truncate8((inst3.first & 0x0000FF00u) >> 8); const u8 f11 = Truncate8((inst3.first & 0x0000FF00u) >> 8);
const u8 f12 = Truncate8 (inst3.first & 0x000000FFu); const u8 f12 = Truncate8(inst3.first & 0x000000FFu);
const u8 f13 = Truncate8((inst3.value32 & 0xFF000000u) >> 24); const u8 f13 = Truncate8((inst3.value32 & 0xFF000000u) >> 24);
const u8 f14 = Truncate8((inst3.value32 & 0x00FF0000u) >> 16); const u8 f14 = Truncate8((inst3.value32 & 0x00FF0000u) >> 16);
const u8 f15 = Truncate8((inst3.value32 & 0x0000FF00u) >> 8); const u8 f15 = Truncate8((inst3.value32 & 0x0000FF00u) >> 8);
const u8 f16 = Truncate8 (inst3.value32 & 0x000000FFu); const u8 f16 = Truncate8(inst3.value32 & 0x000000FFu);
const u8 r1 = Truncate8((inst4.first & 0xFF000000u) >> 24); const u8 r1 = Truncate8((inst4.first & 0xFF000000u) >> 24);
const u8 r2 = Truncate8((inst4.first & 0x00FF0000u) >> 16); const u8 r2 = Truncate8((inst4.first & 0x00FF0000u) >> 16);
const u8 r3 = Truncate8((inst4.first & 0x0000FF00u) >> 8); const u8 r3 = Truncate8((inst4.first & 0x0000FF00u) >> 8);
const u8 r4 = Truncate8 (inst4.first & 0x000000FFu); const u8 r4 = Truncate8(inst4.first & 0x000000FFu);
const u8 r5 = Truncate8((inst4.value32 & 0xFF000000u) >> 24); const u8 r5 = Truncate8((inst4.value32 & 0xFF000000u) >> 24);
const u8 r6 = Truncate8((inst4.value32 & 0x00FF0000u) >> 16); const u8 r6 = Truncate8((inst4.value32 & 0x00FF0000u) >> 16);
const u8 r7 = Truncate8((inst4.value32 & 0x0000FF00u) >> 8); const u8 r7 = Truncate8((inst4.value32 & 0x0000FF00u) >> 8);
const u8 r8 = Truncate8 (inst4.value32 & 0x000000FFu); const u8 r8 = Truncate8(inst4.value32 & 0x000000FFu);
const u8 r9 = Truncate8((inst5.first & 0xFF000000u) >> 24); const u8 r9 = Truncate8((inst5.first & 0xFF000000u) >> 24);
const u8 r10 = Truncate8((inst5.first & 0x00FF0000u) >> 16); const u8 r10 = Truncate8((inst5.first & 0x00FF0000u) >> 16);
const u8 r11 = Truncate8((inst5.first & 0x0000FF00u) >> 8); const u8 r11 = Truncate8((inst5.first & 0x0000FF00u) >> 8);
const u8 r12 = Truncate8 (inst5.first & 0x000000FFu); const u8 r12 = Truncate8(inst5.first & 0x000000FFu);
const u8 r13 = Truncate8((inst5.value32 & 0xFF000000u) >> 24); const u8 r13 = Truncate8((inst5.value32 & 0xFF000000u) >> 24);
const u8 r14 = Truncate8((inst5.value32 & 0x00FF0000u) >> 16); const u8 r14 = Truncate8((inst5.value32 & 0x00FF0000u) >> 16);
const u8 r15 = Truncate8((inst5.value32 & 0x0000FF00u) >> 8); const u8 r15 = Truncate8((inst5.value32 & 0x0000FF00u) >> 8);
const u8 r16 = Truncate8 (inst5.value32 & 0x000000FFu); const u8 r16 = Truncate8(inst5.value32 & 0x000000FFu);
for (u32 address = minaddress;address<=maxaddress;address+=2) for (u32 address = minaddress; address <= maxaddress; address += 2)
{ {
if ((DoMemoryRead<u8>(address )==f1 || f1 == wildcard) && if ((DoMemoryRead<u8>(address) == f1 || f1 == wildcard) &&
(DoMemoryRead<u8>(address+1 )==f2 || f2 == wildcard) && (DoMemoryRead<u8>(address + 1) == f2 || f2 == wildcard) &&
(DoMemoryRead<u8>(address+2 )==f3 || f3 == wildcard) && (DoMemoryRead<u8>(address + 2) == f3 || f3 == wildcard) &&
(DoMemoryRead<u8>(address+3 )==f4 || f4 == wildcard) && (DoMemoryRead<u8>(address + 3) == f4 || f4 == wildcard) &&
(DoMemoryRead<u8>(address+4 )==f5 || f5 == wildcard) && (DoMemoryRead<u8>(address + 4) == f5 || f5 == wildcard) &&
(DoMemoryRead<u8>(address+5 )==f6 || f6 == wildcard) && (DoMemoryRead<u8>(address + 5) == f6 || f6 == wildcard) &&
(DoMemoryRead<u8>(address+6 )==f7 || f7 == wildcard) && (DoMemoryRead<u8>(address + 6) == f7 || f7 == wildcard) &&
(DoMemoryRead<u8>(address+7 )==f8 || f8 == wildcard) && (DoMemoryRead<u8>(address + 7) == f8 || f8 == wildcard) &&
(DoMemoryRead<u8>(address+8 )==f9 || f9 == wildcard) && (DoMemoryRead<u8>(address + 8) == f9 || f9 == wildcard) &&
(DoMemoryRead<u8>(address+9 )==f10|| f10 == wildcard) && (DoMemoryRead<u8>(address + 9) == f10 || f10 == wildcard) &&
(DoMemoryRead<u8>(address+10)==f11|| f11 == wildcard) && (DoMemoryRead<u8>(address + 10) == f11 || f11 == wildcard) &&
(DoMemoryRead<u8>(address+11)==f12|| f12 == wildcard) && (DoMemoryRead<u8>(address + 11) == f12 || f12 == wildcard) &&
(DoMemoryRead<u8>(address+12)==f13|| f13 == wildcard) && (DoMemoryRead<u8>(address + 12) == f13 || f13 == wildcard) &&
(DoMemoryRead<u8>(address+13)==f14|| f14 == wildcard) && (DoMemoryRead<u8>(address + 13) == f14 || f14 == wildcard) &&
(DoMemoryRead<u8>(address+14)==f15|| f15 == wildcard) && (DoMemoryRead<u8>(address + 14) == f15 || f15 == wildcard) &&
(DoMemoryRead<u8>(address+15)==f16|| f16 == wildcard)) (DoMemoryRead<u8>(address + 15) == f16 || f16 == wildcard))
{ {
if (r1 != wildcard) DoMemoryWrite<u8>(address , r1 ); if (r1 != wildcard)
if (r2 != wildcard) DoMemoryWrite<u8>(address+1 , r2 ); DoMemoryWrite<u8>(address, r1);
if (r3 != wildcard) DoMemoryWrite<u8>(address+2 , r3 ); if (r2 != wildcard)
if (r4 != wildcard) DoMemoryWrite<u8>(address+3 , r4 ); DoMemoryWrite<u8>(address + 1, r2);
if (r5 != wildcard) DoMemoryWrite<u8>(address+4 , r5 ); if (r3 != wildcard)
if (r6 != wildcard) DoMemoryWrite<u8>(address+5 , r6 ); DoMemoryWrite<u8>(address + 2, r3);
if (r7 != wildcard) DoMemoryWrite<u8>(address+6 , r7 ); if (r4 != wildcard)
if (r8 != wildcard) DoMemoryWrite<u8>(address+7 , r8 ); DoMemoryWrite<u8>(address + 3, r4);
if (r9 != wildcard) DoMemoryWrite<u8>(address+8 , r9 ); if (r5 != wildcard)
if (r10 != wildcard) DoMemoryWrite<u8>(address+9 , r10); DoMemoryWrite<u8>(address + 4, r5);
if (r11 != wildcard) DoMemoryWrite<u8>(address+10, r11); if (r6 != wildcard)
if (r12 != wildcard) DoMemoryWrite<u8>(address+11, r12); DoMemoryWrite<u8>(address + 5, r6);
if (r13 != wildcard) DoMemoryWrite<u8>(address+12, r13); if (r7 != wildcard)
if (r14 != wildcard) DoMemoryWrite<u8>(address+13, r14); DoMemoryWrite<u8>(address + 6, r7);
if (r15 != wildcard) DoMemoryWrite<u8>(address+14, r15); if (r8 != wildcard)
if (r16 != wildcard) DoMemoryWrite<u8>(address+15, r16); DoMemoryWrite<u8>(address + 7, r8);
address=address+15; if (r9 != wildcard)
DoMemoryWrite<u8>(address + 8, r9);
if (r10 != wildcard)
DoMemoryWrite<u8>(address + 9, r10);
if (r11 != wildcard)
DoMemoryWrite<u8>(address + 10, r11);
if (r12 != wildcard)
DoMemoryWrite<u8>(address + 11, r12);
if (r13 != wildcard)
DoMemoryWrite<u8>(address + 12, r13);
if (r14 != wildcard)
DoMemoryWrite<u8>(address + 13, r14);
if (r15 != wildcard)
DoMemoryWrite<u8>(address + 14, r15);
if (r16 != wildcard)
DoMemoryWrite<u8>(address + 15, r16);
address = address + 15;
} }
} }
index += 5; index += 5;
@ -1488,7 +1504,7 @@ void CheatCode::Apply() const
} }
else else
{ {
Log_ErrorPrintf("Invalid command in second slide parameter 0x%02hhX", write_type); Log_ErrorPrintf("Invalid command in second slide parameter 0x%02X", static_cast<unsigned>(write_type));
} }
index += 2; index += 2;

View File

@ -788,7 +788,7 @@ void ShutdownFastmem()
Common::PageFaultHandler::HandlerResult MMapPageFaultHandler(void* exception_pc, void* fault_address, bool is_write) Common::PageFaultHandler::HandlerResult MMapPageFaultHandler(void* exception_pc, void* fault_address, bool is_write)
{ {
if (static_cast<u8*>(fault_address) < g_state.fastmem_base || if (static_cast<u8*>(fault_address) < g_state.fastmem_base ||
(static_cast<u8*>(fault_address) - g_state.fastmem_base) >= Bus::FASTMEM_REGION_SIZE) (static_cast<u8*>(fault_address) - g_state.fastmem_base) >= static_cast<ptrdiff_t>(Bus::FASTMEM_REGION_SIZE))
{ {
return Common::PageFaultHandler::HandlerResult::ExecuteNextHandler; return Common::PageFaultHandler::HandlerResult::ExecuteNextHandler;
} }

View File

@ -47,7 +47,6 @@ ALWAYS_INLINE u32 GetICacheFillTagForAddress(VirtualMemoryAddress address)
} }
ALWAYS_INLINE u32 GetICacheTagMaskForAddress(VirtualMemoryAddress address) ALWAYS_INLINE u32 GetICacheTagMaskForAddress(VirtualMemoryAddress address)
{ {
const u32 offset = (address >> 2) & 0x03u;
static const u32 mask[4] = {ICACHE_TAG_ADDRESS_MASK | 1, ICACHE_TAG_ADDRESS_MASK | 2, ICACHE_TAG_ADDRESS_MASK | 4, static const u32 mask[4] = {ICACHE_TAG_ADDRESS_MASK | 1, ICACHE_TAG_ADDRESS_MASK | 2, ICACHE_TAG_ADDRESS_MASK | 4,
ICACHE_TAG_ADDRESS_MASK | 8}; ICACHE_TAG_ADDRESS_MASK | 8};
return mask[(address >> 2) & 0x03u]; return mask[(address >> 2) & 0x03u];

View File

@ -202,11 +202,13 @@ void CodeGenerator::EmitBeginBlock()
// Save the link register, since we'll be calling functions. // Save the link register, since we'll be calling functions.
const bool link_reg_allocated = m_register_cache.AllocateHostReg(30); const bool link_reg_allocated = m_register_cache.AllocateHostReg(30);
DebugAssert(link_reg_allocated); DebugAssert(link_reg_allocated);
UNREFERENCED_VARIABLE(link_reg_allocated);
m_register_cache.AssumeCalleeSavedRegistersAreSaved(); m_register_cache.AssumeCalleeSavedRegistersAreSaved();
// Store the CPU struct pointer. TODO: make this better. // Store the CPU struct pointer. TODO: make this better.
const bool cpu_reg_allocated = m_register_cache.AllocateHostReg(RCPUPTR); const bool cpu_reg_allocated = m_register_cache.AllocateHostReg(RCPUPTR);
DebugAssert(cpu_reg_allocated); DebugAssert(cpu_reg_allocated);
UNREFERENCED_VARIABLE(cpu_reg_allocated);
// If there's loadstore instructions, preload the fastmem base. // If there's loadstore instructions, preload the fastmem base.
if (m_block->contains_loadstore_instructions) if (m_block->contains_loadstore_instructions)

View File

@ -127,7 +127,7 @@ static std::optional<std::string> Cmd$g(const std::string_view& data)
} }
// Pad with dummy data (FP registers stuff). // Pad with dummy data (FP registers stuff).
for (int i = 0; i < NUM_GDB_REGISTERS - REGISTERS.size(); i++) { for (int i = 0; i < NUM_GDB_REGISTERS - static_cast<int>(REGISTERS.size()); i++) {
ss << "00000000"; ss << "00000000";
} }
@ -150,7 +150,7 @@ static std::optional<std::string> Cmd$G(const std::string_view& data)
} }
} }
else { else {
Log_ErrorPrintf("Wrong payload size for 'G' command, expected %d got %d", NUM_GDB_REGISTERS*8, data.size()); Log_ErrorPrintf("Wrong payload size for 'G' command, expected %d got %zu", NUM_GDB_REGISTERS*8, data.size());
} }
return { "" }; return { "" };
@ -291,7 +291,7 @@ std::string ProcessPacket(const std::string_view& data)
// Validate packet. // Validate packet.
auto packet = DeserializePacket(trimmedData); auto packet = DeserializePacket(trimmedData);
if (!packet) { if (!packet) {
Log_ErrorPrintf("Malformed packet '%*s'", trimmedData.size(), trimmedData.data()); Log_ErrorPrintf("Malformed packet '%*s'", static_cast<int>(trimmedData.size()), trimmedData.data());
return "-"; return "-";
} }
@ -311,7 +311,7 @@ std::string ProcessPacket(const std::string_view& data)
} }
if (!processed) { if (!processed) {
Log_WarningPrintf("Failed to process packet '%*s'", trimmedData.size(), trimmedData.data()); Log_WarningPrintf("Failed to process packet '%*s'", static_cast<int>(trimmedData.size()), trimmedData.data());
} }
return reply ? "+"+SerializePacket(*reply) : "+"; return reply ? "+"+SerializePacket(*reply) : "+";
} }

View File

@ -153,6 +153,7 @@ void GPUBackend::PushCommand(GPUBackendCommand* cmd)
{ {
const u32 new_write_ptr = m_command_fifo_write_ptr.fetch_add(cmd->size) + cmd->size; const u32 new_write_ptr = m_command_fifo_write_ptr.fetch_add(cmd->size) + cmd->size;
DebugAssert(new_write_ptr <= COMMAND_QUEUE_SIZE); DebugAssert(new_write_ptr <= COMMAND_QUEUE_SIZE);
UNREFERENCED_VARIABLE(new_write_ptr);
if (GetPendingCommandSize() >= THRESHOLD_TO_WAKE_GPU) if (GetPendingCommandSize() >= THRESHOLD_TO_WAKE_GPU)
WakeGPUThread(); WakeGPUThread();
} }

View File

@ -341,8 +341,8 @@ void GPU_HW_OpenGL::SetCapabilities(HostDisplay* host_display)
if (GLAD_GL_VERSION_4_3 || GLAD_GL_ES_VERSION_3_1 || GLAD_GL_ARB_shader_storage_buffer_object) if (GLAD_GL_VERSION_4_3 || GLAD_GL_ES_VERSION_3_1 || GLAD_GL_ARB_shader_storage_buffer_object)
glGetInteger64v(GL_MAX_SHADER_STORAGE_BLOCK_SIZE, &max_ssbo_size); glGetInteger64v(GL_MAX_SHADER_STORAGE_BLOCK_SIZE, &max_ssbo_size);
Log_InfoPrintf("Max shader storage buffer size: %lld", max_ssbo_size); Log_InfoPrintf("Max shader storage buffer size: %" PRId64, max_ssbo_size);
m_use_ssbo_for_vram_writes = (max_ssbo_size >= (VRAM_WIDTH * VRAM_HEIGHT * sizeof(u16))); m_use_ssbo_for_vram_writes = (max_ssbo_size >= static_cast<GLint64>(VRAM_WIDTH * VRAM_HEIGHT * sizeof(u16)));
if (m_use_ssbo_for_vram_writes) if (m_use_ssbo_for_vram_writes)
{ {
Log_InfoPrintf("Using shader storage buffers for VRAM writes."); Log_InfoPrintf("Using shader storage buffers for VRAM writes.");
@ -399,9 +399,8 @@ bool GPU_HW_OpenGL::CreateFramebuffer()
!m_vram_encoding_texture.Create(VRAM_WIDTH, VRAM_HEIGHT, 1, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, nullptr, !m_vram_encoding_texture.Create(VRAM_WIDTH, VRAM_HEIGHT, 1, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, nullptr,
false) || false) ||
!m_vram_encoding_texture.CreateFramebuffer() || !m_vram_encoding_texture.CreateFramebuffer() ||
!m_display_texture.Create(GPU_MAX_DISPLAY_WIDTH * m_resolution_scale, !m_display_texture.Create(GPU_MAX_DISPLAY_WIDTH * m_resolution_scale, GPU_MAX_DISPLAY_HEIGHT * m_resolution_scale,
GPU_MAX_DISPLAY_HEIGHT * m_resolution_scale, 1, GL_RGBA8, GL_RGBA, 1, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, nullptr, false) ||
GL_UNSIGNED_BYTE, nullptr, false) ||
!m_display_texture.CreateFramebuffer()) !m_display_texture.CreateFramebuffer())
{ {
return false; return false;

View File

@ -8,7 +8,7 @@ GPU_HW_ShaderGen::GPU_HW_ShaderGen(HostDisplay::RenderAPI render_api, u32 resolu
GPUTextureFilter texture_filtering, bool uv_limits, bool pgxp_depth, GPUTextureFilter texture_filtering, bool uv_limits, bool pgxp_depth,
bool supports_dual_source_blend) bool supports_dual_source_blend)
: ShaderGen(render_api, supports_dual_source_blend), m_resolution_scale(resolution_scale), : ShaderGen(render_api, supports_dual_source_blend), m_resolution_scale(resolution_scale),
m_multisamples(multisamples), m_true_color(true_color), m_per_sample_shading(per_sample_shading), m_multisamples(multisamples), m_per_sample_shading(per_sample_shading), m_true_color(true_color),
m_scaled_dithering(scaled_dithering), m_texture_filter(texture_filtering), m_uv_limits(uv_limits), m_scaled_dithering(scaled_dithering), m_texture_filter(texture_filtering), m_uv_limits(uv_limits),
m_pgxp_depth(pgxp_depth) m_pgxp_depth(pgxp_depth)
{ {
@ -1343,7 +1343,7 @@ std::string GPU_HW_ShaderGen::GenerateAdaptiveDownsampleMipFragmentShader(bool f
WriteHeader(ss); WriteHeader(ss);
WriteCommonFunctions(ss); WriteCommonFunctions(ss);
DeclareTexture(ss, "samp0", 0, false); DeclareTexture(ss, "samp0", 0, false);
DeclareUniformBuffer(ss, { "float2 u_uv_min", "float2 u_uv_max", "float2 u_rcp_resolution" }, true); DeclareUniformBuffer(ss, {"float2 u_uv_min", "float2 u_uv_max", "float2 u_rcp_resolution"}, true);
DefineMacro(ss, "FIRST_PASS", first_pass); DefineMacro(ss, "FIRST_PASS", first_pass);
// mipmap_energy.glsl ported from parallel-rsx. // mipmap_energy.glsl ported from parallel-rsx.
@ -1402,7 +1402,8 @@ std::string GPU_HW_ShaderGen::GenerateAdaptiveDownsampleBlurFragmentShader()
WriteHeader(ss); WriteHeader(ss);
WriteCommonFunctions(ss); WriteCommonFunctions(ss);
DeclareTexture(ss, "samp0", 0, false); DeclareTexture(ss, "samp0", 0, false);
DeclareUniformBuffer(ss, {"float2 u_uv_min", "float2 u_uv_max", "float2 u_rcp_resolution", "float sample_level"}, true); DeclareUniformBuffer(ss, {"float2 u_uv_min", "float2 u_uv_max", "float2 u_rcp_resolution", "float sample_level"},
true);
// mipmap_blur.glsl ported from parallel-rsx. // mipmap_blur.glsl ported from parallel-rsx.
DeclareFragmentEntryPoint(ss, 0, 1, {}, false, 1, false, false, false, false); DeclareFragmentEntryPoint(ss, 0, 1, {}, false, 1, false, false, false, false);

View File

@ -582,7 +582,6 @@ void GPU_SW::DispatchRenderCommand()
} }
const GPURenderCommand rc{m_render_command.bits}; const GPURenderCommand rc{m_render_command.bits};
const bool dithering_enable = rc.IsDitheringEnabled() && m_GPUSTAT.dither_enable;
switch (rc.primitive) switch (rc.primitive)
{ {

View File

@ -44,7 +44,6 @@ void GPU_SW_Backend::DrawPolygon(const GPUBackendDrawPolygonCommand* cmd)
void GPU_SW_Backend::DrawRectangle(const GPUBackendDrawRectangleCommand* cmd) void GPU_SW_Backend::DrawRectangle(const GPUBackendDrawRectangleCommand* cmd)
{ {
const GPURenderCommand rc{cmd->rc.bits}; const GPURenderCommand rc{cmd->rc.bits};
const bool dithering_enable = rc.IsDitheringEnabled() && cmd->draw_mode.dither_enable;
const DrawRectangleFunction DrawFunction = const DrawRectangleFunction DrawFunction =
GetDrawRectangleFunction(rc.texture_enable, rc.raw_texture_enable, rc.transparency_enable); GetDrawRectangleFunction(rc.texture_enable, rc.raw_texture_enable, rc.transparency_enable);
@ -68,9 +67,9 @@ constexpr GPU_SW_Backend::DitherLUT GPU_SW_Backend::ComputeDitherLUT()
{ {
for (u32 j = 0; j < DITHER_MATRIX_SIZE; j++) for (u32 j = 0; j < DITHER_MATRIX_SIZE; j++)
{ {
for (s32 value = 0; value < DITHER_LUT_SIZE; value++) for (u32 value = 0; value < DITHER_LUT_SIZE; value++)
{ {
const s32 dithered_value = (value + DITHER_MATRIX[i][j]) >> 3; const s32 dithered_value = (static_cast<s32>(value) + DITHER_MATRIX[i][j]) >> 3;
lut[i][j][value] = static_cast<u8>((dithered_value < 0) ? 0 : ((dithered_value > 31) ? 31 : dithered_value)); lut[i][j][value] = static_cast<u8>((dithered_value < 0) ? 0 : ((dithered_value > 31) ? 31 : dithered_value));
} }
} }

View File

@ -13,8 +13,6 @@ enum : u32
VRAM_HEIGHT_MASK = VRAM_HEIGHT - 1, VRAM_HEIGHT_MASK = VRAM_HEIGHT - 1,
TEXTURE_PAGE_WIDTH = 256, TEXTURE_PAGE_WIDTH = 256,
TEXTURE_PAGE_HEIGHT = 256, TEXTURE_PAGE_HEIGHT = 256,
MAX_PRIMITIVE_WIDTH = 1024,
MAX_PRIMITIVE_HEIGHT = 512,
// In interlaced modes, we can exceed the 512 height of VRAM, up to 576 in PAL games. // In interlaced modes, we can exceed the 512 height of VRAM, up to 576 in PAL games.
GPU_MAX_DISPLAY_WIDTH = 720, GPU_MAX_DISPLAY_WIDTH = 720,
@ -23,6 +21,12 @@ enum : u32
DITHER_MATRIX_SIZE = 4 DITHER_MATRIX_SIZE = 4
}; };
enum : s32
{
MAX_PRIMITIVE_WIDTH = 1024,
MAX_PRIMITIVE_HEIGHT = 512,
};
enum class GPUPrimitive : u8 enum class GPUPrimitive : u8
{ {
Reserved = 0, Reserved = 0,

View File

@ -183,8 +183,8 @@ void HostDisplay::CalculateDrawRect(s32 window_width, s32 window_height, float*
{ {
switch (m_display_alignment) switch (m_display_alignment)
{ {
case Alignment::LeftOrTop: case Alignment::RightOrBottom:
*out_top_padding = 0.0f; *out_top_padding = std::max<float>(static_cast<float>(window_height) - (display_height * scale), 0.0f);
break; break;
case Alignment::Center: case Alignment::Center:
@ -192,8 +192,9 @@ void HostDisplay::CalculateDrawRect(s32 window_width, s32 window_height, float*
std::max<float>((static_cast<float>(window_height) - (display_height * scale)) / 2.0f, 0.0f); std::max<float>((static_cast<float>(window_height) - (display_height * scale)) / 2.0f, 0.0f);
break; break;
case Alignment::RightOrBottom: case Alignment::LeftOrTop:
*out_top_padding = std::max<float>(static_cast<float>(window_height) - (display_height * scale), 0.0f); default:
*out_top_padding = 0.0f;
break; break;
} }
} }
@ -209,8 +210,8 @@ void HostDisplay::CalculateDrawRect(s32 window_width, s32 window_height, float*
{ {
switch (m_display_alignment) switch (m_display_alignment)
{ {
case Alignment::LeftOrTop: case Alignment::RightOrBottom:
*out_left_padding = 0.0f; *out_left_padding = std::max<float>(static_cast<float>(window_width) - (display_width * scale), 0.0f);
break; break;
case Alignment::Center: case Alignment::Center:
@ -218,8 +219,9 @@ void HostDisplay::CalculateDrawRect(s32 window_width, s32 window_height, float*
std::max<float>((static_cast<float>(window_width) - (display_width * scale)) / 2.0f, 0.0f); std::max<float>((static_cast<float>(window_width) - (display_width * scale)) / 2.0f, 0.0f);
break; break;
case Alignment::RightOrBottom: case Alignment::LeftOrTop:
*out_left_padding = std::max<float>(static_cast<float>(window_width) - (display_width * scale), 0.0f); default:
*out_left_padding = 0.0f;
break; break;
} }
} }

View File

@ -514,10 +514,6 @@ DiscRegion GetRegionForExe(const char* path)
if (!fp) if (!fp)
return DiscRegion::Other; return DiscRegion::Other;
std::fseek(fp.get(), 0, SEEK_END);
const u32 file_size = static_cast<u32>(std::ftell(fp.get()));
std::fseek(fp.get(), 0, SEEK_SET);
BIOS::PSEXEHeader header; BIOS::PSEXEHeader header;
if (std::fread(&header, sizeof(header), 1, fp.get()) != 1) if (std::fread(&header, sizeof(header), 1, fp.get()) != 1)
return DiscRegion::Other; return DiscRegion::Other;
@ -2086,7 +2082,7 @@ bool SaveRewindState()
s_rewind_states.push_back(std::move(mss)); s_rewind_states.push_back(std::move(mss));
Log_DevPrintf("Saved rewind state (%llu bytes, took %.4f ms)", s_rewind_states.back().state_stream->GetSize(), Log_DevPrintf("Saved rewind state (%" PRIu64 " bytes, took %.4f ms)", s_rewind_states.back().state_stream->GetSize(),
save_timer.GetTimeMilliseconds()); save_timer.GetTimeMilliseconds());
return true; return true;

View File

@ -371,8 +371,8 @@ bool DoState(StateWrapper& sw)
TimingEvent::TimingEvent(std::string name, TickCount period, TickCount interval, TimingEventCallback callback, TimingEvent::TimingEvent(std::string name, TickCount period, TickCount interval, TimingEventCallback callback,
void* callback_param) void* callback_param)
: m_downcount(interval), m_time_since_last_run(0), m_period(period), m_interval(interval), m_callback(callback), : m_callback(callback), m_callback_param(callback_param), m_downcount(interval), m_time_since_last_run(0),
m_callback_param(callback_param), m_name(std::move(name)), m_active(false) m_period(period), m_interval(interval), m_name(std::move(name))
{ {
} }

View File

@ -67,7 +67,7 @@ public:
TickCount m_time_since_last_run; TickCount m_time_since_last_run;
TickCount m_period; TickCount m_period;
TickCount m_interval; TickCount m_interval;
bool m_active; bool m_active = false;
std::string m_name; std::string m_name;
}; };

View File

@ -150,7 +150,7 @@ void DRMHostInterface::PollEvDevKeyboards()
const bool pressed = (ev.value == 1); const bool pressed = (ev.value == 1);
const HostKeyCode code = static_cast<HostKeyCode>(ev.code); const HostKeyCode code = static_cast<HostKeyCode>(ev.code);
if (code >= 0 && code < countof(ImGuiIO::KeysDown)) if (static_cast<unsigned>(code) < countof(ImGuiIO::KeysDown))
ImGui::GetIO().KeysDown[code] = pressed; ImGui::GetIO().KeysDown[code] = pressed;
HandleHostKeyEvent(code, pressed); HandleHostKeyEvent(code, pressed);

View File

@ -9,7 +9,6 @@ static void addBooleanTweakOption(QtHostInterface* host_interface, QTableWidget*
std::string section, std::string key, bool default_value) std::string section, std::string key, bool default_value)
{ {
const int row = table->rowCount(); const int row = table->rowCount();
const bool current_value = host_interface->GetBoolSettingValue(section.c_str(), key.c_str(), default_value);
table->insertRow(row); table->insertRow(row);
@ -35,7 +34,6 @@ static void addIntRangeTweakOption(QtHostInterface* host_interface, QTableWidget
int default_value) int default_value)
{ {
const int row = table->rowCount(); const int row = table->rowCount();
const bool current_value = host_interface->GetBoolSettingValue(section.c_str(), key.c_str(), default_value);
table->insertRow(row); table->insertRow(row);

View File

@ -1,10 +1,8 @@
#include "audiosettingswidget.h" #include "audiosettingswidget.h"
#include "common/audio_stream.h" #include "common/audio_stream.h"
#include "common/log.h"
#include "settingsdialog.h" #include "settingsdialog.h"
#include "settingwidgetbinder.h" #include "settingwidgetbinder.h"
#include <cmath> #include <cmath>
Log_SetChannel(AudioSettingsWidget);
AudioSettingsWidget::AudioSettingsWidget(QtHostInterface* host_interface, QWidget* parent, SettingsDialog* dialog) AudioSettingsWidget::AudioSettingsWidget(QtHostInterface* host_interface, QWidget* parent, SettingsDialog* dialog)
: QWidget(parent), m_host_interface(host_interface) : QWidget(parent), m_host_interface(host_interface)

View File

@ -2,7 +2,7 @@
#include <QtWidgets/QMessageBox> #include <QtWidgets/QMessageBox>
CheatCodeEditorDialog::CheatCodeEditorDialog(const QStringList& group_names, CheatCode* code, QWidget* parent) CheatCodeEditorDialog::CheatCodeEditorDialog(const QStringList& group_names, CheatCode* code, QWidget* parent)
: m_code(code), QDialog(parent) : QDialog(parent), m_code(code)
{ {
m_ui.setupUi(this); m_ui.setupUi(this);
setupAdditionalUi(group_names); setupAdditionalUi(group_names);

View File

@ -1,5 +1,4 @@
#include "debuggermodels.h" #include "debuggermodels.h"
#include "common/log.h"
#include "core/cpu_core.h" #include "core/cpu_core.h"
#include "core/cpu_core_private.h" #include "core/cpu_core_private.h"
#include "core/cpu_disasm.h" #include "core/cpu_disasm.h"
@ -7,7 +6,6 @@
#include <QtGui/QIcon> #include <QtGui/QIcon>
#include <QtGui/QPalette> #include <QtGui/QPalette>
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
Log_SetChannel(DebuggerModels);
static constexpr int NUM_COLUMNS = 5; static constexpr int NUM_COLUMNS = 5;
static constexpr int STACK_RANGE = 128; static constexpr int STACK_RANGE = 128;

View File

@ -949,7 +949,6 @@ bool CommonHostInterface::EnumerateOSDMessages(std::function<bool(const std::str
if (m_osd_messages.empty()) if (m_osd_messages.empty())
return true; return true;
bool result = true;
auto iter = m_osd_messages.begin(); auto iter = m_osd_messages.begin();
while (iter != m_osd_messages.end()) while (iter != m_osd_messages.end())
{ {

View File

@ -36,11 +36,6 @@ static const ImWchar* s_font_glyph_range = nullptr;
static u32 s_menu_button_index = 0; static u32 s_menu_button_index = 0;
static ImRect PadRect(const ImRect& r, float padding)
{
return ImRect(ImVec2(r.Min.x + padding, r.Min.y + padding), ImVec2(r.Max.x - padding, r.Max.y - padding));
}
void SetFontFilename(const char* filename) void SetFontFilename(const char* filename)
{ {
if (filename) if (filename)
@ -330,7 +325,11 @@ static bool MenuButtonFrame(const char* str_id, bool enabled, float height, bool
{ {
ImGuiWindow* window = ImGui::GetCurrentWindow(); ImGuiWindow* window = ImGui::GetCurrentWindow();
if (window->SkipItems) if (window->SkipItems)
{
*visible = false;
*hovered = false;
return false; return false;
}
ImVec2 pos, size; ImVec2 pos, size;
GetMenuButtonFrameBounds(height, &pos, &size); GetMenuButtonFrameBounds(height, &pos, &size);
@ -774,7 +773,8 @@ bool EnumChoiceButtonImpl(const char* title, const char* summary, s32* value_poi
ChoiceDialogOptions options; ChoiceDialogOptions options;
options.reserve(count); options.reserve(count);
for (u32 i = 0; i < count; i++) for (u32 i = 0; i < count; i++)
options.emplace_back(to_display_name_function(static_cast<s32>(i), opaque), *value_pointer == i); options.emplace_back(to_display_name_function(static_cast<s32>(i), opaque),
static_cast<u32>(*value_pointer) == i);
OpenChoiceDialog(title, false, std::move(options), [](s32 index, const std::string& title, bool checked) { OpenChoiceDialog(title, false, std::move(options), [](s32 index, const std::string& title, bool checked) {
if (index >= 0) if (index >= 0)
s_enum_choice_button_value = index; s_enum_choice_button_value = index;
@ -1063,7 +1063,6 @@ void DrawChoiceDialog()
bool is_open = (ImGui::GetNavInputAmount(ImGuiNavInput_Cancel, ImGuiInputReadMode_Pressed) < 1.0f); bool is_open = (ImGui::GetNavInputAmount(ImGuiNavInput_Cancel, ImGuiInputReadMode_Pressed) < 1.0f);
s32 choice = -1; s32 choice = -1;
bool choice_checked = false;
if (ImGui::BeginPopupModal(s_choice_dialog_title.c_str(), &is_open, if (ImGui::BeginPopupModal(s_choice_dialog_title.c_str(), &is_open,
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove)) ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove))

View File

@ -946,8 +946,6 @@ void OpenGLHostDisplay::ApplyPostProcessingChain(GLuint final_target, s32 final_
s32 texture_height, s32 texture_view_x, s32 texture_view_y, s32 texture_height, s32 texture_view_x, s32 texture_view_y,
s32 texture_view_width, s32 texture_view_height) s32 texture_view_width, s32 texture_view_height)
{ {
static constexpr std::array<float, 4> clear_color = {0.0f, 0.0f, 0.0f, 1.0f};
if (!CheckPostProcessingRenderTargets(GetWindowWidth(), GetWindowHeight())) if (!CheckPostProcessingRenderTargets(GetWindowWidth(), GetWindowHeight()))
{ {
RenderDisplay(final_left, GetWindowHeight() - final_top - final_height, final_width, final_height, texture_handle, RenderDisplay(final_left, GetWindowHeight() - final_top - final_height, final_width, final_height, texture_handle,

View File

@ -594,7 +594,7 @@ bool SDLControllerInterface::BindControllerHatToButton(int controller_index, int
return false; return false;
// We need 4 entries per hat_number // We need 4 entries per hat_number
if (it->hat_button_mapping.size() < hat_number + 1) if (static_cast<int>(it->hat_button_mapping.size()) < hat_number + 1)
it->hat_button_mapping.resize(hat_number + 1); it->hat_button_mapping.resize(hat_number + 1);
it->hat_button_mapping[hat_number][index] = std::move(callback); it->hat_button_mapping[hat_number][index] = std::move(callback);