diff --git a/src/common/bitfield.h b/src/common/bitfield.h index fe1449fe..ae96748c 100644 --- a/src/common/bitfield.h +++ b/src/common/bitfield.h @@ -11,8 +11,6 @@ template struct BitField { - static_assert(!std::is_same_v || BitCount == 1, "Boolean bitfields should only be 1 bit"); - // We have to delete the copy assignment operator otherwise we can't use this class in anonymous structs/unions. BitField& operator=(const BitField& rhs) = delete; diff --git a/src/common/cd_image.h b/src/common/cd_image.h index 92e12cd2..cbd065d6 100644 --- a/src/common/cd_image.h +++ b/src/common/cd_image.h @@ -179,7 +179,6 @@ public: return *this; } }; - static_assert(sizeof(SubChannelQ) == SUBCHANNEL_BYTES_PER_FRAME, "SubChannelQ is correct size"); struct Track { diff --git a/src/common/cd_image_mds.cpp b/src/common/cd_image_mds.cpp index 7f312f01..99ca6b92 100644 --- a/src/common/cd_image_mds.cpp +++ b/src/common/cd_image_mds.cpp @@ -1,4 +1,3 @@ -#include "assert.h" #include "cd_image.h" #include "cd_subchannel_replacement.h" #include "error.h" @@ -26,7 +25,6 @@ struct TrackEntry u32 track_offset_in_mdf; u8 unk5[36]; }; -static_assert(sizeof(TrackEntry) == 0x50, "TrackEntry is 0x50 bytes"); #pragma pack(pop) class CDImageMds : public CDImage diff --git a/src/common/cd_xa.h b/src/common/cd_xa.h index 3e996d16..aaa18ca5 100644 --- a/src/common/cd_xa.h +++ b/src/common/cd_xa.h @@ -62,9 +62,8 @@ union XA_ADPCMBlockHeader u8 GetFilter() const { return filter; } }; -static_assert(sizeof(XA_ADPCMBlockHeader) == 1, "XA-ADPCM block header is one byte"); // Decodes XA-ADPCM samples in an audio sector. Stereo samples are interleaved with left first. void DecodeADPCMSector(const void* data, s16* samples, s32* last_samples); -} // namespace CDXA \ No newline at end of file +} // namespace CDXA diff --git a/src/common/dimensional_array.h b/src/common/dimensional_array.h index 9a936137..4499a5a5 100644 --- a/src/common/dimensional_array.h +++ b/src/common/dimensional_array.h @@ -64,7 +64,6 @@ template struct DimensionalArrayExplicitRank : public GetArrayImplType { static constexpr std::size_t rank = rank_param; - static_assert(rank > 0, "Attempted to create dimensional array with rank less than 1"); using ArrayImplType = GetArrayImplType; using ArrayImplType::ArrayImplType; diff --git a/src/common/gl/stream_buffer.cpp b/src/common/gl/stream_buffer.cpp index fd0fe81a..79a18112 100644 --- a/src/common/gl/stream_buffer.cpp +++ b/src/common/gl/stream_buffer.cpp @@ -282,19 +282,7 @@ std::unique_ptr StreamBuffer::Create(GLenum target, u32 size) return buf; } - // BufferSubData is slower on all drivers except NVIDIA... -#if 0 - const char* vendor = reinterpret_cast(glGetString(GL_VENDOR)); - if (std::strcmp(vendor, "ARM") == 0 || std::strcmp(vendor, "Qualcomm") == 0) - { - // Mali and Adreno drivers can't do sub-buffer tracking... - return detail::BufferDataStreamBuffer::Create(target, size); - } - - return detail::BufferSubDataStreamBuffer::Create(target, size); -#else return detail::BufferDataStreamBuffer::Create(target, size); -#endif } } // namespace GL diff --git a/src/common/iso_reader.h b/src/common/iso_reader.h index 21ac0f08..823d7670 100644 --- a/src/common/iso_reader.h +++ b/src/common/iso_reader.h @@ -23,7 +23,6 @@ public: char standard_identifier[5]; u8 version; }; - static_assert(sizeof(ISOVolumeDescriptorHeader) == 7); struct ISOBootRecord { @@ -32,7 +31,6 @@ public: char boot_identifier[32]; u8 data[1977]; }; - static_assert(sizeof(ISOBootRecord) == 2048); struct ISOPVDDateTime { @@ -45,7 +43,6 @@ public: char milliseconds[2]; s8 gmt_offset; }; - static_assert(sizeof(ISOPVDDateTime) == 17); struct ISOPrimaryVolumeDescriptor { @@ -86,7 +83,6 @@ public: u8 application_used[512]; u8 reserved[653]; }; - static_assert(sizeof(ISOPrimaryVolumeDescriptor) == 2048); struct ISODirectoryEntryDateTime { @@ -152,4 +148,4 @@ private: u32 m_track_number; ISOPrimaryVolumeDescriptor m_pvd = {}; -}; \ No newline at end of file +}; diff --git a/src/common/page_fault_handler.cpp b/src/common/page_fault_handler.cpp index e3a1fda3..c5142023 100644 --- a/src/common/page_fault_handler.cpp +++ b/src/common/page_fault_handler.cpp @@ -143,7 +143,6 @@ struct UnwindHandler }; static constexpr size_t UNWIND_HANDLER_ALLOC_SIZE = 4096; -static_assert(sizeof(UnwindHandler) <= UNWIND_HANDLER_ALLOC_SIZE); static EXCEPTION_DISPOSITION UnwindExceptionHandler(PEXCEPTION_RECORD ExceptionRecord, ULONG64 EstablisherFrame, PCONTEXT ContextRecord, PDISPATCHER_CONTEXT DispatcherContext) diff --git a/src/common/pbp_types.h b/src/common/pbp_types.h index 7ab01e03..de89922d 100644 --- a/src/common/pbp_types.h +++ b/src/common/pbp_types.h @@ -40,7 +40,6 @@ struct PBPHeader }; }; }; -static_assert(sizeof(PBPHeader) == 0x28); struct SFOHeader { @@ -50,7 +49,6 @@ struct SFOHeader u32 data_table_offset; // Relative to start of SFOHeader, 0x00000100 expected u32 num_table_entries; // 0x00000009 }; -static_assert(sizeof(SFOHeader) == 0x14); struct SFOIndexTableEntry { @@ -60,7 +58,6 @@ struct SFOIndexTableEntry u32 data_total_size; // Size of data field in bytes, data_total_size >= data_size u32 data_offset; // Relative to data_table_offset }; -static_assert(sizeof(SFOIndexTableEntry) == 0x10); using SFOIndexTable = std::vector; using SFOTableDataValue = std::variant; @@ -74,7 +71,6 @@ struct BlockTableEntry u8 checksum[0x10]; u64 padding; }; -static_assert(sizeof(BlockTableEntry) == 0x20); struct TOCEntry { @@ -92,18 +88,6 @@ struct TOCEntry u8 zero; Timecode userdata_start; }; -static_assert(sizeof(TOCEntry) == 0x0A); - -#if 0 -struct AudioTrackTableEntry -{ - u32 block_offset; - u32 block_size; - u32 block_padding; - u32 block_checksum; -}; -static_assert(sizeof(CDDATrackTableEntry) == 0x10); -#endif #pragma pack(pop) diff --git a/src/common/types.h b/src/common/types.h index 2478a17f..d5c947d4 100644 --- a/src/common/types.h +++ b/src/common/types.h @@ -181,7 +181,6 @@ ALWAYS_INLINE constexpr bool ConvertToBool(TValue value) template ALWAYS_INLINE bool ConvertToBoolUnchecked(TValue value) { - // static_assert(sizeof(uint8) == sizeof(bool)); bool ret; std::memcpy(&ret, &value, sizeof(bool)); return ret; diff --git a/src/core/bios.h b/src/core/bios.h index ffeffbf4..beaabc97 100644 --- a/src/core/bios.h +++ b/src/core/bios.h @@ -52,7 +52,6 @@ struct PSEXEHeader u32 reserved[5]; // 0x038-0x04B char marker[0x7B4]; // 0x04C-0x7FF }; -static_assert(sizeof(PSEXEHeader) == 0x800); #pragma pack(pop) Hash GetHash(const Image& image); diff --git a/src/core/bus.cpp b/src/core/bus.cpp index 1b584739..8f85f889 100644 --- a/src/core/bus.cpp +++ b/src/core/bus.cpp @@ -1399,17 +1399,11 @@ bool FetchInstruction() { case 0x00: // KUSEG 0M-512M case 0x04: // KSEG0 - physical memory cached - { -#if 0 - DoInstructionRead(address, &g_state.next_instruction.bits); -#else if (CompareICacheTag(address)) g_state.next_instruction.bits = ReadICache(address); else g_state.next_instruction.bits = FillICache(address); -#endif - } - break; + break; case 0x05: // KSEG1 - physical memory uncached { @@ -1750,13 +1744,6 @@ void* GetDirectWriteMemoryPointer(VirtualMemoryAddress address, MemoryAccessSize return nullptr; const PhysicalMemoryAddress paddr = address & PHYSICAL_MEMORY_ADDRESS_MASK; - -#if 0 - // Not enabled until we can protect code regions. - if (paddr < RAM_MIRROR_END) - return &g_ram[paddr & RAM_MASK]; -#endif - if ((paddr & DCACHE_LOCATION_MASK) == DCACHE_LOCATION) return &g_state.dcache[paddr & DCACHE_OFFSET_MASK]; diff --git a/src/core/cdrom.cpp b/src/core/cdrom.cpp index 4a0851a1..faf6a8fa 100644 --- a/src/core/cdrom.cpp +++ b/src/core/cdrom.cpp @@ -2387,7 +2387,6 @@ static s16 GetPeakVolume(const u8* raw_sector, u8 channel) static constexpr u32 NUM_SAMPLES = CDImage::RAW_SECTOR_SIZE / sizeof(s16); #if defined(CPU_X64) - static_assert(Common::IsAlignedPow2(NUM_SAMPLES, 8)); const u8* current_ptr = raw_sector; __m128i v_peak = _mm_set1_epi16(0); for (u32 i = 0; i < NUM_SAMPLES; i += 8) diff --git a/src/core/cheats.cpp b/src/core/cheats.cpp index 7f866af2..0b19f436 100644 --- a/src/core/cheats.cpp +++ b/src/core/cheats.cpp @@ -1,6 +1,5 @@ #include "cheats.h" #include "bus.h" -#include "common/assert.h" #include "common/byte_stream.h" #include "common/log.h" #include "common/string.h" @@ -42,9 +41,6 @@ template static T DoMemoryRead(VirtualMemoryAddress address) { using UnsignedType = typename std::make_unsigned_t; - static_assert(std::is_same_v || std::is_same_v || - std::is_same_v); - T result; if constexpr (std::is_same_v) return CPU::SafeReadMemoryByte(address, &result) ? result : static_cast(0); @@ -58,9 +54,6 @@ template static void DoMemoryWrite(PhysicalMemoryAddress address, T value) { using UnsignedType = typename std::make_unsigned_t; - static_assert(std::is_same_v || std::is_same_v || - std::is_same_v); - if constexpr (std::is_same_v) CPU::SafeWriteMemoryByte(address, value); else if constexpr (std::is_same_v) diff --git a/src/core/cpu_code_cache.cpp b/src/core/cpu_code_cache.cpp index 7b469120..88ba3dd1 100644 --- a/src/core/cpu_code_cache.cpp +++ b/src/core/cpu_code_cache.cpp @@ -404,28 +404,7 @@ void ExecuteRecompiler() g_using_interpreter = false; g_state.frame_done = false; -#if 0 - while (!g_state.frame_done) - { - if (HasPendingInterrupt()) - { - SafeReadInstruction(g_state.regs.pc, &g_state.next_instruction.bits); - DispatchInterrupt(); - } - - TimingEvents::UpdateCPUDowncount(); - - while (g_state.pending_ticks < g_state.downcount) - { - const u32 pc = g_state.regs.pc; - s_single_block_asm_dispatcher(s_fast_map[pc >> 16][pc >> 2]); - } - - TimingEvents::RunEvents(); - } -#else s_asm_dispatcher(); -#endif // in case we switch to interpreter... g_state.regs.npc = g_state.regs.pc; @@ -603,11 +582,6 @@ bool CompileBlock(CodeBlock* block) bool is_branch_delay_slot = false; bool is_load_delay_slot = false; -#if 0 - if (pc == 0x0005aa90) - __debugbreak(); -#endif - block->icache_line_count = 0; block->uncached_fetch_ticks = 0; block->contains_double_branches = false; diff --git a/src/core/cpu_recompiler_code_generator.cpp b/src/core/cpu_recompiler_code_generator.cpp index 8b038efd..ec9c8f51 100644 --- a/src/core/cpu_recompiler_code_generator.cpp +++ b/src/core/cpu_recompiler_code_generator.cpp @@ -931,10 +931,6 @@ void CodeGenerator::BlockPrologue() EmitStoreCPUStructField(offsetof(State, exception_raised), Value::FromConstantU8(0)); -#if 0 - EmitFunctionCall(nullptr, &Thunks::LogPC, Value::FromConstantU32(m_pc)); -#endif - if (m_block->uncached_fetch_ticks > 0 || m_block->icache_line_count > 0) EmitICacheCheckAndUpdate(); diff --git a/src/core/cpu_recompiler_code_generator_aarch32.cpp b/src/core/cpu_recompiler_code_generator_aarch32.cpp index d4a03987..160b4607 100644 --- a/src/core/cpu_recompiler_code_generator_aarch32.cpp +++ b/src/core/cpu_recompiler_code_generator_aarch32.cpp @@ -1,5 +1,4 @@ #include "common/align.h" -#include "common/assert.h" #include "common/log.h" #include "cpu_core.h" #include "cpu_core_private.h" @@ -224,12 +223,6 @@ void CodeGenerator::FinalizeBlock(CodeBlock::HostCodePointer* out_host_code, u32 m_code_buffer->GetFreeCodeSpace(), a32::A32); m_far_emitter = CodeEmitter(static_cast(m_code_buffer->GetFreeFarCodePointer()), m_code_buffer->GetFreeFarCodeSpace(), a32::A32); - -#if 0 - a32::PrintDisassembler dis(std::cout, 0); - dis.SetCodeAddress(reinterpret_cast(*out_host_code)); - dis.DisassembleA32Buffer(reinterpret_cast(*out_host_code), *out_host_code_size); -#endif } void CodeGenerator::EmitSignExtend(HostReg to_reg, RegSize to_size, HostReg from_reg, RegSize from_size) @@ -1666,8 +1659,6 @@ void CodeGenerator::EmitICacheCheckAndUpdate() void CodeGenerator::EmitStallUntilGTEComplete() { - static_assert(offsetof(State, pending_ticks) + sizeof(u32) == offsetof(State, gte_completion_tick)); - m_emit->ldr(GetHostReg32(RARG1), a32::MemOperand(GetCPUPtrReg(), offsetof(State, pending_ticks))); m_emit->ldr(GetHostReg32(RARG2), a32::MemOperand(GetCPUPtrReg(), offsetof(State, gte_completion_tick))); diff --git a/src/core/cpu_recompiler_code_generator_aarch64.cpp b/src/core/cpu_recompiler_code_generator_aarch64.cpp index 633a48b7..8aef24eb 100644 --- a/src/core/cpu_recompiler_code_generator_aarch64.cpp +++ b/src/core/cpu_recompiler_code_generator_aarch64.cpp @@ -1,5 +1,4 @@ #include "common/align.h" -#include "common/assert.h" #include "common/log.h" #include "cpu_core.h" #include "cpu_core_private.h" @@ -1832,7 +1831,6 @@ void CodeGenerator::EmitICacheCheckAndUpdate() void CodeGenerator::EmitStallUntilGTEComplete() { - static_assert(offsetof(State, pending_ticks) + sizeof(u32) == offsetof(State, gte_completion_tick)); m_emit->ldp(GetHostReg32(RARG1), GetHostReg32(RARG2), a64::MemOperand(GetCPUPtrReg(), offsetof(State, pending_ticks))); diff --git a/src/core/cpu_recompiler_code_generator_generic.cpp b/src/core/cpu_recompiler_code_generator_generic.cpp index 86c0806c..23d679cf 100644 --- a/src/core/cpu_recompiler_code_generator_generic.cpp +++ b/src/core/cpu_recompiler_code_generator_generic.cpp @@ -131,86 +131,4 @@ void CodeGenerator::EmitStoreGuestMemory(const CodeBlockInstruction& cbi, const } } -#if 0 // Not used - -void CodeGenerator::EmitICacheCheckAndUpdate() -{ - Value temp = m_register_cache.AllocateScratch(RegSize_32); - - if (GetSegmentForAddress(m_pc) >= Segment::KSEG1) - { - EmitLoadCPUStructField(temp.GetHostRegister(), RegSize_32, offsetof(State, pending_ticks)); - EmitAdd(temp.GetHostRegister(), temp.GetHostRegister(), - Value::FromConstantU32(static_cast(m_block->uncached_fetch_ticks)), false); - EmitStoreCPUStructField(offsetof(State, pending_ticks), temp); - } - else - { - // cached path - Value temp2 = m_register_cache.AllocateScratch(RegSize_32); - - m_register_cache.InhibitAllocation(); - - VirtualMemoryAddress current_pc = m_pc & ICACHE_TAG_ADDRESS_MASK; - for (u32 i = 0; i < m_block->icache_line_count; i++, current_pc += ICACHE_LINE_SIZE) - { - const VirtualMemoryAddress tag = GetICacheTagForAddress(current_pc); - const TickCount fill_ticks = GetICacheFillTicks(current_pc); - if (fill_ticks <= 0) - continue; - - const u32 line = GetICacheLine(current_pc); - const u32 offset = offsetof(State, icache_tags) + (line * sizeof(u32)); - LabelType cache_hit; - - EmitLoadCPUStructField(temp.GetHostRegister(), RegSize_32, offset); - EmitCopyValue(temp2.GetHostRegister(), Value::FromConstantU32(current_pc)); - EmitCmp(temp2.GetHostRegister(), temp); - EmitConditionalBranch(Condition::Equal, false, temp.GetHostRegister(), temp2, &cache_hit); - - EmitLoadCPUStructField(temp.GetHostRegister(), RegSize_32, offsetof(State, pending_ticks)); - EmitStoreCPUStructField(offset, temp2); - EmitAdd(temp.GetHostRegister(), temp.GetHostRegister(), Value::FromConstantU32(static_cast(fill_ticks)), - false); - EmitStoreCPUStructField(offsetof(State, pending_ticks), temp); - EmitBindLabel(&cache_hit); - } - - m_register_cache.UninhibitAllocation(); - } -} - -#endif - -#if 0 // Not Used - -void CodeGenerator::EmitStallUntilGTEComplete() -{ - Value pending_ticks = m_register_cache.AllocateScratch(RegSize_32); - Value gte_completion_tick = m_register_cache.AllocateScratch(RegSize_32); - EmitLoadCPUStructField(pending_ticks.GetHostRegister(), RegSize_32, offsetof(State, pending_ticks)); - EmitLoadCPUStructField(gte_completion_tick.GetHostRegister(), RegSize_32, offsetof(State, gte_completion_tick)); - - // commit cycles here, should always be nonzero - if (m_delayed_cycles_add > 0) - { - EmitAdd(pending_ticks.GetHostRegister(), pending_ticks.GetHostRegister(), - Value::FromConstantU32(m_delayed_cycles_add), false); - m_delayed_cycles_add = 0; - } - - LabelType gte_done; - EmitSub(gte_completion_tick.GetHostRegister(), gte_completion_tick.GetHostRegister(), pending_ticks, true); - EmitConditionalBranch(Condition::Below, false, >e_done); - - // add stall ticks - EmitAdd(pending_ticks.GetHostRegister(), pending_ticks.GetHostRegister(), gte_completion_tick, false); - - // store new ticks - EmitBindLabel(>e_done); - EmitStoreCPUStructField(offsetof(State, pending_ticks), pending_ticks); -} - -#endif - } // namespace CPU::Recompiler diff --git a/src/core/gpu.cpp b/src/core/gpu.cpp index 64c7c86f..74f1ae6e 100644 --- a/src/core/gpu.cpp +++ b/src/core/gpu.cpp @@ -769,13 +769,6 @@ void GPU::UpdateCRTCTickEvent() ticks_until_event = std::min(ticks_until_event, std::max(ticks_until_irq, 0)); } -#if 0 - const TickCount ticks_until_hblank = - (m_crtc_state.current_tick_in_scanline >= m_crtc_state.horizontal_display_end) ? - (m_crtc_state.horizontal_total - m_crtc_state.current_tick_in_scanline + m_crtc_state.horizontal_display_end) : - (m_crtc_state.horizontal_display_end - m_crtc_state.current_tick_in_scanline); -#endif - m_crtc_tick_event->Schedule(CRTCTicksToSystemTicks(ticks_until_event, m_crtc_state.fractional_ticks)); } diff --git a/src/core/gpu_hw.h b/src/core/gpu_hw.h index 1dd658d2..43cb200f 100644 --- a/src/core/gpu_hw.h +++ b/src/core/gpu_hw.h @@ -49,7 +49,6 @@ protected: MAX_VERTICES_FOR_RECTANGLE = 6 * (((MAX_PRIMITIVE_WIDTH + (TEXTURE_PAGE_WIDTH - 1)) / TEXTURE_PAGE_WIDTH) + 1u) * (((MAX_PRIMITIVE_HEIGHT + (TEXTURE_PAGE_HEIGHT - 1)) / TEXTURE_PAGE_HEIGHT) + 1u) }; - static_assert(VRAM_UPDATE_TEXTURE_BUFFER_SIZE >= VRAM_WIDTH * VRAM_HEIGHT * sizeof(u16)); struct BatchVertex { diff --git a/src/core/gte_types.h b/src/core/gte_types.h index 32198fc6..74635ff9 100644 --- a/src/core/gte_types.h +++ b/src/core/gte_types.h @@ -122,7 +122,6 @@ union Regs }; #pragma pack(pop) }; -static_assert(sizeof(Regs) == (sizeof(u32) * NUM_REGS)); union Instruction { diff --git a/src/core/save_state_version.h b/src/core/save_state_version.h index 803f853b..11074c51 100644 --- a/src/core/save_state_version.h +++ b/src/core/save_state_version.h @@ -5,8 +5,6 @@ static constexpr u32 SAVE_STATE_MAGIC = 0x43435544; static constexpr u32 SAVE_STATE_VERSION = 55; static constexpr u32 SAVE_STATE_MINIMUM_VERSION = 42; -static_assert(SAVE_STATE_VERSION >= SAVE_STATE_MINIMUM_VERSION); - #pragma pack(push, 4) struct SAVE_STATE_HEADER { diff --git a/src/core/settings.cpp b/src/core/settings.cpp index c9e9dd81..4b8d3ec1 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -1,5 +1,4 @@ #include "settings.h" -#include "common/assert.h" #include "common/make_array.h" #include "common/string_util.h" #include "host_display.h" @@ -627,11 +626,6 @@ const char* Settings::GetControllerTypeName(ControllerType type) static std::array s_memory_card_type_names = { {"None", "Shared", "PerGame", "PerGameTitle", "PerGameFileTitle", "NonPersistent", "Libretro"}}; -// these need to be performed as static assert - if e set the std::array size according to MemoryCardType::Count then -// it will just null-fill unspecified items and we could still have issues with the descriptions not matching the enum. -// (todo: generally these enum-to-string things are better implemented as lambda switch statements) -static_assert(s_memory_card_type_names.size() == (intmax_t)MemoryCardType::Count); - std::optional Settings::ParseMemoryCardTypeName(const char* str) { int index = 0;