diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.cpp b/rpcs3/Emu/RSX/Common/BufferUtils.cpp index b5eda28331..b53f6f7ca9 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.cpp +++ b/rpcs3/Emu/RSX/Common/BufferUtils.cpp @@ -5,7 +5,7 @@ #define MIN2(x, y) ((x) < (y)) ? (x) : (y) #define MAX2(x, y) ((x) > (y)) ? (x) : (y) -void write_vertex_array_data_to_buffer(void *buffer, u32 first, u32 count, size_t index, const rsx::data_array_format_info &vertex_array_desc) noexcept +void write_vertex_array_data_to_buffer(void *buffer, u32 first, u32 count, size_t index, const rsx::data_array_format_info &vertex_array_desc) { assert(vertex_array_desc.array); @@ -62,7 +62,7 @@ void write_vertex_array_data_to_buffer(void *buffer, u32 first, u32 count, size_ namespace { template -void uploadAsIt(char *dst, u32 address, size_t indexCount, bool is_primitive_restart_enabled, u32 primitive_restart_index, u32 &min_index, u32 &max_index) noexcept +void uploadAsIt(char *dst, u32 address, size_t indexCount, bool is_primitive_restart_enabled, u32 primitive_restart_index, u32 &min_index, u32 &max_index) { for (u32 i = 0; i < indexCount; ++i) { @@ -80,7 +80,7 @@ void uploadAsIt(char *dst, u32 address, size_t indexCount, bool is_primitive_res // FIXME: expanded primitive type may not support primitive restart correctly template -void expandIndexedTriangleFan(char *dst, u32 address, size_t indexCount, bool is_primitive_restart_enabled, u32 primitive_restart_index, u32 &min_index, u32 &max_index) noexcept +void expandIndexedTriangleFan(char *dst, u32 address, size_t indexCount, bool is_primitive_restart_enabled, u32 primitive_restart_index, u32 &min_index, u32 &max_index) { for (unsigned i = 0; i < indexCount - 2; i++) { @@ -117,7 +117,7 @@ void expandIndexedTriangleFan(char *dst, u32 address, size_t indexCount, bool is } template -void expandIndexedQuads(char *dst, u32 address, size_t indexCount, bool is_primitive_restart_enabled, u32 primitive_restart_index, u32 &min_index, u32 &max_index) noexcept +void expandIndexedQuads(char *dst, u32 address, size_t indexCount, bool is_primitive_restart_enabled, u32 primitive_restart_index, u32 &min_index, u32 &max_index) { for (unsigned i = 0; i < indexCount / 4; i++) { @@ -168,7 +168,7 @@ void expandIndexedQuads(char *dst, u32 address, size_t indexCount, bool is_primi } // Only handle quads and triangle fan now -bool is_primitive_native(unsigned m_draw_mode) noexcept +bool is_primitive_native(unsigned m_draw_mode) { switch (m_draw_mode) { @@ -193,7 +193,7 @@ bool is_primitive_native(unsigned m_draw_mode) noexcept * see http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/polygon-triangulation-r3334 */ -size_t get_index_count(unsigned m_draw_mode, unsigned initial_index_count) noexcept +size_t get_index_count(unsigned m_draw_mode, unsigned initial_index_count) { // Index count if (is_primitive_native(m_draw_mode)) @@ -211,7 +211,7 @@ size_t get_index_count(unsigned m_draw_mode, unsigned initial_index_count) noexc } } -size_t get_index_type_size(u32 type) noexcept +size_t get_index_type_size(u32 type) { switch (type) { @@ -221,7 +221,7 @@ size_t get_index_type_size(u32 type) noexcept } } -void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst, unsigned draw_mode, unsigned first, unsigned count) noexcept +void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst, unsigned draw_mode, unsigned first, unsigned count) { unsigned short *typedDst = (unsigned short *)(dst); switch (draw_mode) @@ -251,7 +251,7 @@ void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst, } } -void write_index_array_data_to_buffer(char* dst, unsigned m_draw_mode, unsigned first, unsigned count, unsigned &min_index, unsigned &max_index) noexcept +void write_index_array_data_to_buffer(char* dst, unsigned m_draw_mode, unsigned first, unsigned count, unsigned &min_index, unsigned &max_index) { u32 address = rsx::get_address(rsx::method_registers[NV4097_SET_INDEX_ARRAY_ADDRESS], rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] & 0xf); u32 type = rsx::method_registers[NV4097_SET_INDEX_ARRAY_DMA] >> 4; @@ -306,14 +306,14 @@ void write_index_array_data_to_buffer(char* dst, unsigned m_draw_mode, unsigned } } -void stream_vector(void *dst, u32 x, u32 y, u32 z, u32 w) noexcept +void stream_vector(void *dst, u32 x, u32 y, u32 z, u32 w) { __m128i vector = _mm_set_epi32(w, z, y, x); _mm_stream_si128((__m128i*)dst, vector); } -void stream_vector_from_memory(void *dst, void *src) noexcept +void stream_vector_from_memory(void *dst, void *src) { const __m128i &vector = _mm_loadu_si128((__m128i*)src); _mm_stream_si128((__m128i*)dst, vector); -} \ No newline at end of file +} diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.h b/rpcs3/Emu/RSX/Common/BufferUtils.h index 05186ab7b2..062a7336d8 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.h +++ b/rpcs3/Emu/RSX/Common/BufferUtils.h @@ -15,41 +15,41 @@ struct VertexBufferFormat /** * Write count vertex attributes from index array buffer starting at first, using vertex_array_desc */ -void write_vertex_array_data_to_buffer(void *buffer, u32 first, u32 count, size_t index, const rsx::data_array_format_info &vertex_array_desc) noexcept; +void write_vertex_array_data_to_buffer(void *buffer, u32 first, u32 count, size_t index, const rsx::data_array_format_info &vertex_array_desc); /* * If primitive mode is not supported and need to be emulated (using an index buffer) returns false. */ -bool is_primitive_native(unsigned m_draw_mode) noexcept; +bool is_primitive_native(unsigned m_draw_mode); /** * Returns a fixed index count for emulated primitive, otherwise returns initial_index_count */ -size_t get_index_count(unsigned m_draw_mode, unsigned initial_index_count) noexcept; +size_t get_index_count(unsigned m_draw_mode, unsigned initial_index_count); /** * Returns index type size in byte */ -size_t get_index_type_size(u32 type) noexcept; +size_t get_index_type_size(u32 type); /** * Write count indexes starting at first to dst buffer. * Returns min/max index found during the process. * The function expands index buffer for non native primitive type. */ -void write_index_array_data_to_buffer(char* dst, unsigned m_draw_mode, unsigned first, unsigned count, unsigned &min_index, unsigned &max_index) noexcept; +void write_index_array_data_to_buffer(char* dst, unsigned m_draw_mode, unsigned first, unsigned count, unsigned &min_index, unsigned &max_index); /** * Write index data needed to emulate non indexed non native primitive mode. */ -void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst, unsigned m_draw_mode, unsigned first, unsigned count) noexcept; +void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst, unsigned m_draw_mode, unsigned first, unsigned count); /** * Stream a 128 bits vector to dst. */ -void stream_vector(void *dst, u32 x, u32 y, u32 z, u32 w) noexcept; +void stream_vector(void *dst, u32 x, u32 y, u32 z, u32 w); /** * Stream a 128 bits vector from src to dst. */ -void stream_vector_from_memory(void *dst, void *src) noexcept; +void stream_vector_from_memory(void *dst, void *src); diff --git a/rpcs3/Emu/RSX/Common/ProgramStateCache.h b/rpcs3/Emu/RSX/Common/ProgramStateCache.h index 7a20e3fa3d..2f7bc9263b 100644 --- a/rpcs3/Emu/RSX/Common/ProgramStateCache.h +++ b/rpcs3/Emu/RSX/Common/ProgramStateCache.h @@ -294,7 +294,7 @@ public: clear(); } - const typename BackendTraits::VertexProgramData* get_transform_program(const RSXVertexProgram& rsx_vp) const noexcept + const typename BackendTraits::VertexProgramData* get_transform_program(const RSXVertexProgram& rsx_vp) const { typename binary2VS::const_iterator It = m_cacheVS.find(rsx_vp.data); if (It == m_cacheVS.end()) @@ -302,7 +302,7 @@ public: return &It->second; } - const typename BackendTraits::FragmentProgramData* get_shader_program(const RSXFragmentProgram& rsx_fp) const noexcept + const typename BackendTraits::FragmentProgramData* get_shader_program(const RSXFragmentProgram& rsx_fp) const { typename binary2FS::const_iterator It = m_cacheFS.find(vm::base(rsx_fp.addr)); if (It == m_cacheFS.end()) @@ -353,7 +353,7 @@ public: return result; } - size_t get_fragment_constants_buffer_size(const RSXFragmentProgram *fragmentShader) const noexcept + size_t get_fragment_constants_buffer_size(const RSXFragmentProgram *fragmentShader) const { typename binary2FS::const_iterator It = m_cacheFS.find(vm::base(fragmentShader->addr)); if (It != m_cacheFS.end()) @@ -362,7 +362,7 @@ public: return 0; } - void fill_fragment_constans_buffer(void *buffer, const RSXFragmentProgram *fragment_program) const noexcept + void fill_fragment_constans_buffer(void *buffer, const RSXFragmentProgram *fragment_program) const { typename binary2FS::const_iterator It = m_cacheFS.find(vm::base(fragment_program->addr)); if (It == m_cacheFS.end()) diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.cpp b/rpcs3/Emu/RSX/Common/TextureUtils.cpp index 6ebdeba724..79ee348ee6 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.cpp +++ b/rpcs3/Emu/RSX/Common/TextureUtils.cpp @@ -14,7 +14,7 @@ namespace struct texel_rgba { template - static size_t copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block) noexcept + static size_t copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block) { for (unsigned row = 0; row < row_count; row++) memcpy((char*)dst + row * dst_pitch_in_block * block_size, (char*)src + row * src_pitch_in_block * block_size, width_in_block * block_size); @@ -29,7 +29,7 @@ struct texel_rgba struct texel_16b_swizzled { template - static size_t copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block) noexcept + static size_t copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block) { u16 *castedSrc = static_cast(src), *castedDst = static_cast(dst); @@ -51,7 +51,7 @@ struct texel_16b_swizzled struct texel_rgba_swizzled { template - static size_t copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block) noexcept + static size_t copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block) { u32 *castedSrc, *castedDst; castedSrc = (u32*)src; @@ -70,7 +70,7 @@ struct texel_rgba_swizzled */ struct texel_bc_format { template - static size_t copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block) noexcept + static size_t copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block) { for (unsigned row = 0; row < row_count; row++) memcpy((char*)dst + row * dst_pitch_in_block * block_size, (char*)src + row * width_in_block * block_size, width_in_block * block_size); @@ -83,7 +83,7 @@ struct texel_bc_format { */ struct texel_16b_format { template - static size_t copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block) noexcept + static size_t copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block) { unsigned short *castedDst = (unsigned short *)dst, *castedSrc = (unsigned short *)src; @@ -102,7 +102,7 @@ struct texel_16b_format { */ struct texel_16bX4_format { template - static size_t copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block) noexcept + static size_t copy_mipmap_level(void *dst, void *src, size_t row_count, size_t width_in_block, size_t dst_pitch_in_block, size_t src_pitch_in_block) { unsigned short *casted_dst = (unsigned short *)dst, *casted_src = (unsigned short *)src; for (unsigned row = 0; row < row_count; row++) @@ -123,7 +123,7 @@ struct texel_16bX4_format { * mipmap level (to allow same code for packed/non packed texels) */ template -std::vector copy_texture_data(void *dst, const void *src, size_t widthInBlock, size_t heightInBlock, size_t depth, size_t mipmapCount) noexcept +std::vector copy_texture_data(void *dst, const void *src, size_t widthInBlock, size_t heightInBlock, size_t depth, size_t mipmapCount) { std::vector Result; size_t offsetInDst = 0, offsetInSrc = 0; @@ -157,7 +157,7 @@ std::vector copy_texture_data(void *dst, const void *src, size_ * A texture is stored as an array of blocks, where a block is a pixel for standard texture * but is a structure containing several pixels for compressed format */ -size_t get_texture_block_size(u32 format) noexcept +size_t get_texture_block_size(u32 format) { switch (format) { @@ -191,12 +191,12 @@ size_t get_texture_block_size(u32 format) noexcept case ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN) & CELL_GCM_TEXTURE_COMPRESSED_B8R8_G8R8: case ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN) & CELL_GCM_TEXTURE_COMPRESSED_R8B8_R8G8: default: - LOG_ERROR(RSX, "Unimplemented Texture format : %x", format); + LOG_ERROR(RSX, "Unimplemented Texture format : 0x%x", format); return 0; } } -size_t get_texture_block_edge(u32 format) noexcept +size_t get_texture_block_edge(u32 format) { switch (format) { @@ -230,14 +230,14 @@ size_t get_texture_block_edge(u32 format) noexcept case ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN) & CELL_GCM_TEXTURE_COMPRESSED_B8R8_G8R8: case ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN) & CELL_GCM_TEXTURE_COMPRESSED_R8B8_R8G8: default: - LOG_ERROR(RSX, "Unimplemented Texture format : %x", format); + LOG_ERROR(RSX, "Unimplemented Texture format : 0x%x", format); return 0; } } } -size_t get_placed_texture_storage_size(const rsx::texture &texture, size_t rowPitchAlignement) noexcept +size_t get_placed_texture_storage_size(const rsx::texture &texture, size_t rowPitchAlignement) { size_t w = texture.width(), h = texture.height(); @@ -253,7 +253,7 @@ size_t get_placed_texture_storage_size(const rsx::texture &texture, size_t rowPi return rowPitch * heightInBlocks * (texture.cubemap() ? 6 : 1) * 2; // * 2 for mipmap levels } -std::vector upload_placed_texture(const rsx::texture &texture, size_t rowPitchAlignement, void* textureData) noexcept +std::vector upload_placed_texture(const rsx::texture &texture, size_t rowPitchAlignement, void* textureData) { size_t w = texture.width(), h = texture.height(); size_t depth = texture.depth(); @@ -301,7 +301,7 @@ std::vector upload_placed_texture(const rsx::texture &texture, } } -size_t get_texture_size(const rsx::texture &texture) noexcept +size_t get_texture_size(const rsx::texture &texture) { size_t w = texture.width(), h = texture.height(); @@ -314,7 +314,7 @@ size_t get_texture_size(const rsx::texture &texture) noexcept case ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN) & CELL_GCM_TEXTURE_COMPRESSED_B8R8_G8R8: case ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN) & CELL_GCM_TEXTURE_COMPRESSED_R8B8_R8G8: default: - LOG_ERROR(RSX, "Unimplemented Texture format : %x", format); + LOG_ERROR(RSX, "Unimplemented Texture format : 0x%x", format); return 0; case CELL_GCM_TEXTURE_B8: return w * h; @@ -367,4 +367,4 @@ size_t get_texture_size(const rsx::texture &texture) noexcept case CELL_GCM_TEXTURE_COMPRESSED_R8B8_R8G8: return w * h * 4; } -} \ No newline at end of file +} diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.h b/rpcs3/Emu/RSX/Common/TextureUtils.h index a4fc2240a1..28e1fad5b8 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.h +++ b/rpcs3/Emu/RSX/Common/TextureUtils.h @@ -14,16 +14,16 @@ struct MipmapLevelInfo * Get size to store texture in a linear fashion. * Storage is assumed to use a rowPitchAlignement boundary for every row of texture. */ -size_t get_placed_texture_storage_size(const rsx::texture &texture, size_t rowPitchAlignement) noexcept; +size_t get_placed_texture_storage_size(const rsx::texture &texture, size_t rowPitchAlignement); /** * Write texture data to textureData. * Data are not packed, they are stored per rows using rowPitchAlignement. * Similarly, offset for every mipmaplevel is aligned to rowPitchAlignement boundary. */ -std::vector upload_placed_texture(const rsx::texture &texture, size_t rowPitchAlignement, void* textureData) noexcept; +std::vector upload_placed_texture(const rsx::texture &texture, size_t rowPitchAlignement, void* textureData); /** * Get number of bytes occupied by texture in RSX mem */ -size_t get_texture_size(const rsx::texture &texture) noexcept; \ No newline at end of file +size_t get_texture_size(const rsx::texture &texture); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp index 6a80435df7..126a783b29 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Formats.cpp @@ -6,7 +6,7 @@ #include "Emu/RSX/GCM.h" -D3D12_BLEND_OP get_blend_op(u16 op) noexcept +D3D12_BLEND_OP get_blend_op(u16 op) { switch (op) { @@ -18,12 +18,12 @@ D3D12_BLEND_OP get_blend_op(u16 op) noexcept case CELL_GCM_FUNC_ADD_SIGNED: case CELL_GCM_FUNC_REVERSE_ADD_SIGNED: case CELL_GCM_FUNC_REVERSE_SUBTRACT_SIGNED: - unreachable("Unsupported blend op used %x, please report this to a developer.", op); + break; } - unreachable("Unimplemented blend op used %x, please report this to a developer.", op); + throw EXCEPTION("Invalid or unsupported blend op (0x%x)", op); } -D3D12_BLEND get_blend_factor(u16 factor) noexcept +D3D12_BLEND get_blend_factor(u16 factor) { switch (factor) { @@ -42,12 +42,12 @@ D3D12_BLEND get_blend_factor(u16 factor) noexcept case CELL_GCM_ONE_MINUS_CONSTANT_COLOR: case CELL_GCM_CONSTANT_ALPHA: case CELL_GCM_ONE_MINUS_CONSTANT_ALPHA: - unreachable("Unsupported blend color factor used %x, please report this to a developer.", factor); + break; } - unreachable("Unimplemented blend color factor used %x, please report this to a developer.", factor); + throw EXCEPTION("Invalid or unsupported blend factor (0x%x)", factor); } -D3D12_BLEND get_blend_factor_alpha(u16 factor) noexcept +D3D12_BLEND get_blend_factor_alpha(u16 factor) { switch (factor) { @@ -66,15 +66,15 @@ D3D12_BLEND get_blend_factor_alpha(u16 factor) noexcept case CELL_GCM_ONE_MINUS_CONSTANT_COLOR: case CELL_GCM_CONSTANT_ALPHA: case CELL_GCM_ONE_MINUS_CONSTANT_ALPHA: - unreachable("Unsupported blend alpha factor used %x, please report this to a developer.", factor); + break; } - unreachable("Unimplemented blend alpha factor used %x, please report this to a developer.", factor); + throw EXCEPTION("Invalid or unsupported blend alpha factor (0x%x)", factor); } /** * Convert GCM logic op code to D3D12 one */ -D3D12_LOGIC_OP get_logic_op(u32 op) noexcept +D3D12_LOGIC_OP get_logic_op(u32 op) { switch (op) { @@ -94,13 +94,13 @@ D3D12_LOGIC_OP get_logic_op(u32 op) noexcept case CELL_GCM_OR_INVERTED: return D3D12_LOGIC_OP_OR_INVERTED; case CELL_GCM_NAND: return D3D12_LOGIC_OP_NAND; } - unreachable("Unimplemented logic op used %x, please report this to a developer.", op); + throw EXCEPTION("Invalid logic op (0x%x)", op); } /** * Convert GCM stencil op code to D3D12 one */ -D3D12_STENCIL_OP get_stencil_op(u32 op) noexcept +D3D12_STENCIL_OP get_stencil_op(u32 op) { switch (op) { @@ -113,10 +113,10 @@ D3D12_STENCIL_OP get_stencil_op(u32 op) noexcept case CELL_GCM_INCR_WRAP: return D3D12_STENCIL_OP_INCR; case CELL_GCM_DECR_WRAP: return D3D12_STENCIL_OP_DECR; } - unreachable("Unimplemented stencil op used %x, please report this to a developer.", op); + throw EXCEPTION("Invalid stencil op (0x%x)", op); } -D3D12_COMPARISON_FUNC get_compare_func(u32 op) noexcept +D3D12_COMPARISON_FUNC get_compare_func(u32 op) { switch (op) { @@ -129,12 +129,12 @@ D3D12_COMPARISON_FUNC get_compare_func(u32 op) noexcept case CELL_GCM_GEQUAL: return D3D12_COMPARISON_FUNC_GREATER_EQUAL; case CELL_GCM_ALWAYS: return D3D12_COMPARISON_FUNC_ALWAYS; case CELL_GCM_ZERO: - unreachable("Unsupported compare function used %x, please report this to a developer.", op); + break; } - unreachable("Unimplemented compare function used %x, please report this to a developer.", op); + throw EXCEPTION("Invalid or unsupported compare func (0x%x)", op); } -DXGI_FORMAT get_texture_format(int format) noexcept +DXGI_FORMAT get_texture_format(u8 format) { switch (format) { @@ -167,12 +167,12 @@ DXGI_FORMAT get_texture_format(int format) noexcept case CELL_GCM_TEXTURE_COMPRESSED_HILO_S8: case ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN) & CELL_GCM_TEXTURE_COMPRESSED_B8R8_G8R8: case ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN) & CELL_GCM_TEXTURE_COMPRESSED_R8B8_R8G8: - unreachable("Unsupported texture format used %x, please report this to a developer.", format); + break; } - unreachable("Unimplemented texture format used %x, please report this to a developer.", format); + throw EXCEPTION("Invalid or unsupported texture format (0x%x)", format); } -UINT get_texture_max_aniso(u8 aniso) noexcept +UINT get_texture_max_aniso(u8 aniso) { switch (aniso) { @@ -185,10 +185,10 @@ UINT get_texture_max_aniso(u8 aniso) noexcept case CELL_GCM_TEXTURE_MAX_ANISO_12: return 12; case CELL_GCM_TEXTURE_MAX_ANISO_16: return 16; } - unreachable("Unimplemented texture max aniso used %x, please report this to a developer.", aniso); + throw EXCEPTION("Invalid texture max aniso (0x%x)", aniso); } -D3D12_TEXTURE_ADDRESS_MODE get_texture_wrap_mode(u8 wrap) noexcept +D3D12_TEXTURE_ADDRESS_MODE get_texture_wrap_mode(u8 wrap) { switch (wrap) { @@ -201,12 +201,12 @@ D3D12_TEXTURE_ADDRESS_MODE get_texture_wrap_mode(u8 wrap) noexcept case CELL_GCM_TEXTURE_MIRROR_ONCE_BORDER: return D3D12_TEXTURE_ADDRESS_MODE_MIRROR_ONCE; case CELL_GCM_TEXTURE_MIRROR_ONCE_CLAMP: return D3D12_TEXTURE_ADDRESS_MODE_MIRROR_ONCE; } - unreachable("Unimplemented texture wrap mode used %x, please report this to a developer.", wrap); + throw EXCEPTION("Invalid texture wrap mode (0x%x)", wrap); } namespace { - void get_min_filter(u8 min_filter, D3D12_FILTER_TYPE &min, D3D12_FILTER_TYPE &mip) noexcept + void get_min_filter(u8 min_filter, D3D12_FILTER_TYPE &min, D3D12_FILTER_TYPE &mip) { switch (min_filter) { @@ -239,21 +239,21 @@ namespace mip = D3D12_FILTER_TYPE_POINT; return; } - unreachable("Unimplemented min filter used %x, please report this to a developer.", min_filter); + throw EXCEPTION("Invalid max filter (0x%x)", min_filter); } - D3D12_FILTER_TYPE get_mag_filter(u8 mag_filter) noexcept + D3D12_FILTER_TYPE get_mag_filter(u8 mag_filter) { switch (mag_filter) { case CELL_GCM_TEXTURE_NEAREST: return D3D12_FILTER_TYPE_POINT; case CELL_GCM_TEXTURE_LINEAR: return D3D12_FILTER_TYPE_LINEAR; } - unreachable("Unimplemented mag filter used %x, please report this to a developer.", mag_filter); + throw EXCEPTION("Invalid mag filter (0x%x)", mag_filter); } } -D3D12_FILTER get_texture_filter(u8 min_filter, u8 mag_filter) noexcept +D3D12_FILTER get_texture_filter(u8 min_filter, u8 mag_filter) { D3D12_FILTER_TYPE min, mip; get_min_filter(min_filter, min, mip); @@ -261,7 +261,7 @@ D3D12_FILTER get_texture_filter(u8 min_filter, u8 mag_filter) noexcept return D3D12_ENCODE_BASIC_FILTER(min, mag, mip, D3D12_FILTER_REDUCTION_TYPE_STANDARD); } -D3D12_PRIMITIVE_TOPOLOGY get_primitive_topology(u8 draw_mode) noexcept +D3D12_PRIMITIVE_TOPOLOGY get_primitive_topology(u8 draw_mode) { switch (draw_mode) { @@ -276,10 +276,10 @@ D3D12_PRIMITIVE_TOPOLOGY get_primitive_topology(u8 draw_mode) noexcept case CELL_GCM_PRIMITIVE_QUAD_STRIP: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; case CELL_GCM_PRIMITIVE_POLYGON: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; } - unreachable("Unimplemented draw mode used %x, please report this to a developer.", draw_mode); + throw EXCEPTION("Invalid draw mode (0x%x)", draw_mode); } -D3D12_PRIMITIVE_TOPOLOGY_TYPE get_primitive_topology_type(u8 draw_mode) noexcept +D3D12_PRIMITIVE_TOPOLOGY_TYPE get_primitive_topology_type(u8 draw_mode) { switch (draw_mode) { @@ -293,12 +293,12 @@ D3D12_PRIMITIVE_TOPOLOGY_TYPE get_primitive_topology_type(u8 draw_mode) noexcept case CELL_GCM_PRIMITIVE_QUAD_STRIP: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; case CELL_GCM_PRIMITIVE_POLYGON: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; case CELL_GCM_PRIMITIVE_LINE_LOOP: - unreachable("Unsupported draw mode used %x, please report this to a developer.", draw_mode); + break; } - unreachable("Unimplemented draw mode used %x, please report this to a developer.", draw_mode); + throw EXCEPTION("Invalid or unsupported draw mode (0x%x)", draw_mode); } -DXGI_FORMAT get_color_surface_format(u8 format) noexcept +DXGI_FORMAT get_color_surface_format(u8 format) { switch (format) { @@ -307,71 +307,71 @@ DXGI_FORMAT get_color_surface_format(u8 format) noexcept case CELL_GCM_SURFACE_F_W16Z16Y16X16: return DXGI_FORMAT_R16G16B16A16_FLOAT; case CELL_GCM_SURFACE_F_X32: return DXGI_FORMAT_R32_FLOAT; } - unreachable("Unimplemented color surface format used %x, please report this to a developer.", format); + throw EXCEPTION("Invalid format (0x%x)", format); } -DXGI_FORMAT get_depth_stencil_surface_format(u8 format) noexcept +DXGI_FORMAT get_depth_stencil_surface_format(u8 format) { switch (format) { case CELL_GCM_SURFACE_Z16: return DXGI_FORMAT_D16_UNORM; case CELL_GCM_SURFACE_Z24S8: return DXGI_FORMAT_D24_UNORM_S8_UINT; } - unreachable("Unimplemented depth stencil surface format used %x, please report this to a developer.", format); + throw EXCEPTION("Invalid format (0x%x)", format); } -DXGI_FORMAT get_depth_stencil_surface_clear_format(u8 format) noexcept +DXGI_FORMAT get_depth_stencil_surface_clear_format(u8 format) { switch (format) { case CELL_GCM_SURFACE_Z16: return DXGI_FORMAT_D16_UNORM; case CELL_GCM_SURFACE_Z24S8: return DXGI_FORMAT_D24_UNORM_S8_UINT; } - unreachable("Unimplemented depth stencil surface format used %x, please report this to a developer.", format); + throw EXCEPTION("Invalid format (0x%x)", format); } -DXGI_FORMAT get_depth_stencil_typeless_surface_format(u8 format) noexcept +DXGI_FORMAT get_depth_stencil_typeless_surface_format(u8 format) { switch (format) { case CELL_GCM_SURFACE_Z16: return DXGI_FORMAT_R16_TYPELESS; case CELL_GCM_SURFACE_Z24S8: return DXGI_FORMAT_R24G8_TYPELESS; } - unreachable("Unimplemented depth stencil surface format used %x, please report this to a developer.", format); + throw EXCEPTION("Invalid format (0x%x)", format); } -DXGI_FORMAT get_depth_samplable_surface_format(u8 format) noexcept +DXGI_FORMAT get_depth_samplable_surface_format(u8 format) { switch (format) { case CELL_GCM_SURFACE_Z16: return DXGI_FORMAT_R16_FLOAT; case CELL_GCM_SURFACE_Z24S8: return DXGI_FORMAT_R24_UNORM_X8_TYPELESS; } - unreachable("Unimplemented depth stencil surface format used %x, please report this to a developer.", format); + throw EXCEPTION("Invalid format (0x%x)", format); } -BOOL get_front_face_ccw(u32 set_front_face_value) noexcept +BOOL get_front_face_ccw(u32 ffv) { - switch (set_front_face_value) + switch (ffv) { default: // Disgaea 3 pass some garbage value at startup, this is needed to survive. case CELL_GCM_CW: return FALSE; case CELL_GCM_CCW: return TRUE; } - unreachable("Unimplemented front face value used %x, please report this to a developer.", set_front_face_value); + throw EXCEPTION("Invalid front face value (0x%x)", ffv); } -DXGI_FORMAT get_index_type(u8 index_type) noexcept +DXGI_FORMAT get_index_type(u8 index_type) { switch (index_type) { case CELL_GCM_DRAW_INDEX_ARRAY_TYPE_16: return DXGI_FORMAT_R16_UINT; case CELL_GCM_DRAW_INDEX_ARRAY_TYPE_32: return DXGI_FORMAT_R32_UINT; } - unreachable("Unimplemented index type used %x, please report this to a developer.", index_type); + throw EXCEPTION("Invalid index_type (0x%x)", index_type); } -DXGI_FORMAT get_vertex_attribute_format(u8 type, u8 size) noexcept +DXGI_FORMAT get_vertex_attribute_format(u8 type, u8 size) { switch (type) { @@ -384,7 +384,7 @@ DXGI_FORMAT get_vertex_attribute_format(u8 type, u8 size) noexcept case 3: return DXGI_FORMAT_R16G16B16A16_SNORM; // No 3 channel type case 4: return DXGI_FORMAT_R16G16B16A16_SNORM; } - unreachable("Unimplemented type size used %x, please report this to a developer.", size); + break; } case CELL_GCM_VERTEX_F: { @@ -395,7 +395,7 @@ DXGI_FORMAT get_vertex_attribute_format(u8 type, u8 size) noexcept case 3: return DXGI_FORMAT_R32G32B32_FLOAT; case 4: return DXGI_FORMAT_R32G32B32A32_FLOAT; } - unreachable("Unimplemented type size used %x, please report this to a developer.", size); + break; } case CELL_GCM_VERTEX_SF: { @@ -406,7 +406,7 @@ DXGI_FORMAT get_vertex_attribute_format(u8 type, u8 size) noexcept case 3: return DXGI_FORMAT_R16G16B16A16_FLOAT; // No 3 channel type case 4: return DXGI_FORMAT_R16G16B16A16_FLOAT; } - unreachable("Unimplemented type size used %x, please report this to a developer.", size); + break; } case CELL_GCM_VERTEX_UB: { @@ -417,7 +417,7 @@ DXGI_FORMAT get_vertex_attribute_format(u8 type, u8 size) noexcept case 3: return DXGI_FORMAT_R8G8B8A8_UNORM; // No 3 channel type case 4: return DXGI_FORMAT_R8G8B8A8_UNORM; } - unreachable("Unimplemented type size used %x, please report this to a developer.", size); + break; } case CELL_GCM_VERTEX_S32K: { @@ -428,7 +428,7 @@ DXGI_FORMAT get_vertex_attribute_format(u8 type, u8 size) noexcept case 3: return DXGI_FORMAT_R16G16B16A16_SINT; // No 3 channel type case 4: return DXGI_FORMAT_R16G16B16A16_SINT; } - unreachable("Unimplemented type size used %x, please report this to a developer.", size); + break; } case CELL_GCM_VERTEX_CMP: { @@ -439,7 +439,7 @@ DXGI_FORMAT get_vertex_attribute_format(u8 type, u8 size) noexcept case 3: return DXGI_FORMAT_R32G32B32_FLOAT; case 4: return DXGI_FORMAT_R32G32B32A32_FLOAT; } - unreachable("Unimplemented type size used %x, please report this to a developer.", size); + break; } case CELL_GCM_VERTEX_UB256: { @@ -450,13 +450,14 @@ DXGI_FORMAT get_vertex_attribute_format(u8 type, u8 size) noexcept case 3: return DXGI_FORMAT_R8G8B8A8_UINT; // No 3 channel type case 4: return DXGI_FORMAT_R8G8B8A8_UINT; } - unreachable("Unimplemented type size used %x, please report this to a developer.", size); + break; } } - unreachable("Unimplemented type used %x, please report this to a developer.", size); + + throw EXCEPTION("Invalid or unsupported type or size (type=0x%x, size=0x%x)", type, size); } -D3D12_RECT get_scissor(u32 horizontal, u32 vertical) noexcept +D3D12_RECT get_scissor(u32 horizontal, u32 vertical) { return{ horizontal & 0xFFFF, diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Formats.h b/rpcs3/Emu/RSX/D3D12/D3D12Formats.h index df21fe501a..b293683345 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Formats.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12Formats.h @@ -5,105 +5,105 @@ /** * Convert GCM blend operator code to D3D12 one */ -D3D12_BLEND_OP get_blend_op(u16 op) noexcept; +D3D12_BLEND_OP get_blend_op(u16 op); /** * Convert GCM blend factor code to D3D12 one */ -D3D12_BLEND get_blend_factor(u16 factor) noexcept; +D3D12_BLEND get_blend_factor(u16 factor); /** * Convert GCM blend factor code to D3D12 one for alpha component */ -D3D12_BLEND get_blend_factor_alpha(u16 factor) noexcept; +D3D12_BLEND get_blend_factor_alpha(u16 factor); /** * Convert GCM logic op code to D3D12 one */ -D3D12_LOGIC_OP get_logic_op(u32 op) noexcept; +D3D12_LOGIC_OP get_logic_op(u32 op); /** * Convert GCM stencil op code to D3D12 one */ -D3D12_STENCIL_OP get_stencil_op(u32 op) noexcept; +D3D12_STENCIL_OP get_stencil_op(u32 op); /** * Convert GCM comparison function code to D3D12 one. */ -D3D12_COMPARISON_FUNC get_compare_func(u32 op) noexcept; +D3D12_COMPARISON_FUNC get_compare_func(u32 op); /** * Convert GCM texture format to an equivalent one supported by D3D12. * Destination format may require a byte swap or data conversion. */ -DXGI_FORMAT get_texture_format(int format) noexcept; +DXGI_FORMAT get_texture_format(u8 format); /** * Convert texture aniso value to UINT. */ -UINT get_texture_max_aniso(u8 aniso) noexcept; +UINT get_texture_max_aniso(u8 aniso); /** * Convert texture wrap mode to D3D12_TEXTURE_ADDRESS_MODE */ -D3D12_TEXTURE_ADDRESS_MODE get_texture_wrap_mode(u8 wrap) noexcept; +D3D12_TEXTURE_ADDRESS_MODE get_texture_wrap_mode(u8 wrap); /** * Convert minify and magnify filter to D3D12_FILTER */ -D3D12_FILTER get_texture_filter(u8 min_filter, u8 mag_filter) noexcept; +D3D12_FILTER get_texture_filter(u8 min_filter, u8 mag_filter); /** * Convert draw mode to D3D12_PRIMITIVE_TOPOLOGY */ -D3D12_PRIMITIVE_TOPOLOGY get_primitive_topology(u8 draw_mode) noexcept; +D3D12_PRIMITIVE_TOPOLOGY get_primitive_topology(u8 draw_mode); /** * Convert draw mode to D3D12_PRIMITIVE_TOPOLOGY_TYPE */ -D3D12_PRIMITIVE_TOPOLOGY_TYPE get_primitive_topology_type(u8 draw_mode) noexcept; +D3D12_PRIMITIVE_TOPOLOGY_TYPE get_primitive_topology_type(u8 draw_mode); /** * Convert color surface format to DXGI_FORMAT */ -DXGI_FORMAT get_color_surface_format(u8 format) noexcept; +DXGI_FORMAT get_color_surface_format(u8 format); /** * Convert depth stencil surface format to DXGI_FORMAT */ -DXGI_FORMAT get_depth_stencil_surface_format(u8 format) noexcept; +DXGI_FORMAT get_depth_stencil_surface_format(u8 format); /** *Convert depth stencil surface format to DXGI_FORMAT suited for clear value */ -DXGI_FORMAT get_depth_stencil_surface_clear_format(u8 format) noexcept; +DXGI_FORMAT get_depth_stencil_surface_clear_format(u8 format); /** * Convert depth surface format to a typeless DXGI_FORMAT */ -DXGI_FORMAT get_depth_stencil_typeless_surface_format(u8 format) noexcept; +DXGI_FORMAT get_depth_stencil_typeless_surface_format(u8 format); /** * Convert depth surface format to a DXGI_FORMAT that can be depth sampled */ -DXGI_FORMAT get_depth_samplable_surface_format(u8 format) noexcept; +DXGI_FORMAT get_depth_samplable_surface_format(u8 format); /** * Convert front face value to bool value telling wheter front face is counterclockwise or not */ -BOOL get_front_face_ccw(u32 set_front_face_value) noexcept; +BOOL get_front_face_ccw(u32 set_front_face_value); /** * Convert index type to DXGI_FORMAT */ -DXGI_FORMAT get_index_type(u8 index_type) noexcept; +DXGI_FORMAT get_index_type(u8 index_type); /** * Convert vertex attribute format and size to DXGI_FORMAT */ -DXGI_FORMAT get_vertex_attribute_format(u8 type, u8 size) noexcept; +DXGI_FORMAT get_vertex_attribute_format(u8 type, u8 size); /** * Convert scissor register value to D3D12_RECT */ -D3D12_RECT get_scissor(u32 horizontal, u32 vertical) noexcept; +D3D12_RECT get_scissor(u32 horizontal, u32 vertical); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp index 3596568253..fc2b7874ee 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp @@ -25,15 +25,11 @@ HMODULE D3DCompiler; void loadD3D12FunctionPointers() { - D3D12Module = LoadLibrary(L"d3d12.dll"); - if (!D3D12Module) - unreachable("Failed to load d3d12.dll"); + CHECK_ASSERTION(D3D12Module = LoadLibrary(L"d3d12.dll")); wrapD3D12CreateDevice = (PFN_D3D12_CREATE_DEVICE)GetProcAddress(D3D12Module, "D3D12CreateDevice"); wrapD3D12GetDebugInterface = (PFN_D3D12_GET_DEBUG_INTERFACE)GetProcAddress(D3D12Module, "D3D12GetDebugInterface"); wrapD3D12SerializeRootSignature = (PFN_D3D12_SERIALIZE_ROOT_SIGNATURE)GetProcAddress(D3D12Module, "D3D12SerializeRootSignature"); - D3D11Module = LoadLibrary(L"d3d11.dll"); - if (!D3D11Module) - unreachable("Failed to load d3d11.dll"); + CHECK_ASSERTION(D3D11Module = LoadLibrary(L"d3d11.dll")); wrapD3D11On12CreateDevice = (PFN_D3D11ON12_CREATE_DEVICE)GetProcAddress(D3D11Module, "D3D11On12CreateDevice"); CHECK_ASSERTION(D3DCompiler = LoadLibrary(L"d3dcompiler_47.dll")); wrapD3DCompile = (pD3DCompile)GetProcAddress(D3DCompiler, "D3DCompile"); @@ -100,7 +96,7 @@ D3D12GSRender::D3D12GSRender() gfxHandler = [this](u32 addr) { bool result = invalidate_address(addr); if (result) - LOG_WARNING(RSX, "Reporting Cell writing to %x", addr); + LOG_WARNING(RSX, "Reporting Cell writing to 0x%x", addr); return result; }; if (rpcs3::config.rsx.d3d12.debug_output.value()) @@ -392,7 +388,7 @@ bool is_flip_surface_in_global_memory(u32 color_target) case CELL_GCM_SURFACE_TARGET_NONE: return false; } - unreachable("Wrong color target"); + throw EXCEPTION("Wrong color_target (%u)", color_target); } } diff --git a/rpcs3/Emu/RSX/D3D12/D3D12MemoryHelpers.cpp b/rpcs3/Emu/RSX/D3D12/D3D12MemoryHelpers.cpp index abcd84ad9d..f93320222c 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12MemoryHelpers.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12MemoryHelpers.cpp @@ -4,14 +4,14 @@ #include "D3D12MemoryHelpers.h" -void data_cache::store_and_protect_data(u64 key, u32 start, size_t size, int format, size_t w, size_t h, size_t m, ComPtr data) noexcept +void data_cache::store_and_protect_data(u64 key, u32 start, size_t size, u8 format, size_t w, size_t h, size_t m, ComPtr data) { std::lock_guard lock(m_mut); m_address_to_data[key] = std::make_pair(texture_entry(format, w, h, m), data); protect_data(key, start, size); } -void data_cache::protect_data(u64 key, u32 start, size_t size) noexcept +void data_cache::protect_data(u64 key, u32 start, size_t size) { /// align start to 4096 byte u32 protected_range_start = align(start, 4096); @@ -20,7 +20,7 @@ void data_cache::protect_data(u64 key, u32 start, size_t size) noexcept vm::page_protect(protected_range_start, protected_range_size, 0, 0, vm::page_writable); } -bool data_cache::invalidate_address(u32 addr) noexcept +bool data_cache::invalidate_address(u32 addr) { bool handled = false; auto It = m_protected_ranges.begin(), E = m_protected_ranges.end(); @@ -44,7 +44,7 @@ bool data_cache::invalidate_address(u32 addr) noexcept return handled; } -std::pair > *data_cache::find_data_if_available(u64 key) noexcept +std::pair > *data_cache::find_data_if_available(u64 key) { std::lock_guard lock(m_mut); auto It = m_address_to_data.find(key); @@ -53,7 +53,7 @@ std::pair > *data_cache::find_data_if_avai return &It->second; } -void data_cache::unprotect_all() noexcept +void data_cache::unprotect_all() { std::lock_guard lock(m_mut); for (auto &protectedTexture : m_protected_ranges) @@ -63,7 +63,7 @@ void data_cache::unprotect_all() noexcept } } -ComPtr data_cache::remove_from_cache(u64 key) noexcept +ComPtr data_cache::remove_from_cache(u64 key) { auto result = m_address_to_data[key].second; m_address_to_data.erase(key); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12MemoryHelpers.h b/rpcs3/Emu/RSX/D3D12/D3D12MemoryHelpers.h index 0704ca89ea..a951fe024d 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12MemoryHelpers.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12MemoryHelpers.h @@ -72,7 +72,7 @@ struct data_heap /** * Does alloc cross get position ? */ - bool can_alloc(size_t size) const noexcept + bool can_alloc(size_t size) const { size_t alloc_size = align(size, alignment); if (m_put_pos + alloc_size < m_size) @@ -98,7 +98,7 @@ struct data_heap } } - size_t alloc(size_t size) noexcept + size_t alloc(size_t size) { assert(can_alloc(size)); size_t alloc_size = align(size, alignment); @@ -115,7 +115,7 @@ struct data_heap } } - void release() noexcept + void release() { m_heap->Release(); } @@ -123,7 +123,7 @@ struct data_heap /** * return current putpos - 1 */ - size_t get_current_put_pos_minus_one() const noexcept + size_t get_current_put_pos_minus_one() const { return (m_put_pos - 1 > 0) ? m_put_pos - 1 : m_size - 1; } @@ -131,16 +131,16 @@ struct data_heap struct texture_entry { - int m_format; + u8 m_format; + bool m_is_dirty; size_t m_width; size_t m_height; size_t m_mipmap; - bool m_is_dirty; texture_entry() : m_format(0), m_width(0), m_height(0), m_is_dirty(true) {} - texture_entry(int f, size_t w, size_t h, size_t m) : m_format(f), m_width(w), m_height(h), m_is_dirty(false) + texture_entry(u8 f, size_t w, size_t h, size_t m) : m_format(f), m_width(w), m_height(h), m_is_dirty(false) {} bool operator==(const texture_entry &other) @@ -165,28 +165,28 @@ private: std::unordered_map> > m_address_to_data; // Storage std::list > m_protected_ranges; // address, start of protected range, size of protected range public: - void store_and_protect_data(u64 key, u32 start, size_t size, int format, size_t w, size_t h, size_t m, ComPtr data) noexcept; + void store_and_protect_data(u64 key, u32 start, size_t size, u8 format, size_t w, size_t h, size_t m, ComPtr data); /** * Make memory from start to start + size write protected. * Associate key to this range so that when a write is detected, data at key is marked dirty. */ - void protect_data(u64 key, u32 start, size_t size) noexcept; + void protect_data(u64 key, u32 start, size_t size); /** * Remove all data containing addr from cache, unprotect them. Returns false if no data is modified. */ - bool invalidate_address(u32 addr) noexcept; + bool invalidate_address(u32 addr); - std::pair > *find_data_if_available(u64 key) noexcept; + std::pair > *find_data_if_available(u64 key); - void unprotect_all() noexcept; + void unprotect_all(); /** * Remove data stored at key, and returns a ComPtr owning it. * The caller is responsible for releasing the ComPtr. */ - ComPtr remove_from_cache(u64 key) noexcept; + ComPtr remove_from_cache(u64 key); }; /** diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Overlay.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Overlay.cpp index 0d90ddfc65..7017426392 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Overlay.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Overlay.cpp @@ -24,7 +24,7 @@ ComPtr g_d2d_render_targets[2]; ComPtr g_text_format; ComPtr g_text_brush; -void draw_strings(const D2D1_SIZE_F &rtSize, size_t backbuffer_id, const std::vector &strings) noexcept +void draw_strings(const D2D1_SIZE_F &rtSize, size_t backbuffer_id, const std::vector &strings) { // Acquire our wrapped render target resource for the current back buffer. g_d3d11on12_device->AcquireWrappedResources(g_wrapped_backbuffers[backbuffer_id ].GetAddressOf(), 1); diff --git a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp index 68b7a19019..f14fd532a1 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12RenderTargetSets.cpp @@ -17,7 +17,7 @@ namespace { - UINT get_num_rtt(u8 color_target) noexcept + UINT get_num_rtt(u8 color_target) { switch (color_target) { @@ -28,10 +28,10 @@ namespace case CELL_GCM_SURFACE_TARGET_MRT2: return 3; case CELL_GCM_SURFACE_TARGET_MRT3: return 4; } - unreachable("Wrong color target"); + throw EXCEPTION("Wrong color_target (%d)", color_target); } - std::vector get_rtt_indexes(u8 color_target) noexcept + std::vector get_rtt_indexes(u8 color_target) { switch (color_target) { @@ -42,10 +42,10 @@ namespace case CELL_GCM_SURFACE_TARGET_MRT2: return{ 0, 1, 2 }; case CELL_GCM_SURFACE_TARGET_MRT3: return{ 0, 1, 2, 3 }; } - unreachable("Wrong color target"); + throw EXCEPTION("Wrong color_target (%d)", color_target); } - std::array get_clear_color(u32 clear_color) noexcept + std::array get_clear_color(u32 clear_color) { u8 clear_a = clear_color >> 24; u8 clear_r = clear_color >> 16; @@ -60,7 +60,7 @@ namespace }; } - u8 get_clear_stencil(u32 register_value) noexcept + u8 get_clear_stencil(u32 register_value) { return register_value & 0xff; } diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp index bea41ccce2..299304122d 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Texture.cpp @@ -21,7 +21,7 @@ D3D12_COMPARISON_FUNC get_sampler_compare_func[] = D3D12_COMPARISON_FUNC_ALWAYS }; -D3D12_SAMPLER_DESC get_sampler_desc(const rsx::texture &texture) noexcept +D3D12_SAMPLER_DESC get_sampler_desc(const rsx::texture &texture) { D3D12_SAMPLER_DESC samplerDesc = {}; samplerDesc.Filter = get_texture_filter(texture.min_filter(), texture.mag_filter()); @@ -55,7 +55,7 @@ ComPtr upload_single_texture( size_t depth = texture.depth(); if (texture.cubemap()) depth *= 6; - int format = texture.format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); + const u8 format = texture.format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); DXGI_FORMAT dxgi_format = get_texture_format(format); size_t buffer_size = get_placed_texture_storage_size(texture, 256); @@ -101,7 +101,7 @@ void update_existing_texture( { size_t w = texture.width(), h = texture.height(); - int format = texture.format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); + const u8 format = texture.format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); DXGI_FORMAT dxgi_format = get_texture_format(format); size_t buffer_size = get_placed_texture_storage_size(texture, 256); @@ -168,7 +168,7 @@ void D3D12GSRender::upload_and_bind_textures(ID3D12GraphicsCommandList *command_ const u32 texaddr = rsx::get_address(textures[i].offset(), textures[i].location()); - int format = textures[i].format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); + const u8 format = textures[i].format() & ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN); bool is_swizzled = !(textures[i].format() & CELL_GCM_TEXTURE_LN); ID3D12Resource *vram_texture; @@ -224,7 +224,7 @@ void D3D12GSRender::upload_and_bind_textures(ID3D12GraphicsCommandList *command_ case ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN) & CELL_GCM_TEXTURE_COMPRESSED_B8R8_G8R8: case ~(CELL_GCM_TEXTURE_LN | CELL_GCM_TEXTURE_UN) & CELL_GCM_TEXTURE_COMPRESSED_R8B8_R8G8: default: - LOG_ERROR(RSX, "Unimplemented Texture format : %x", format); + LOG_ERROR(RSX, "Unimplemented Texture format : 0x%x", format); break; case CELL_GCM_TEXTURE_B8: shared_resource_view_desc.Shader4ComponentMapping = D3D12_ENCODE_SHADER_4_COMPONENT_MAPPING( diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Utils.cpp b/rpcs3/Emu/RSX/D3D12/D3D12Utils.cpp index 73afe3c9d2..0d03918da0 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Utils.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12Utils.cpp @@ -262,13 +262,4 @@ void D3D12GSRender::initConvertShader() p.second->Release(); } - -void unreachable_internal() -{ - abort(); - #ifdef LLVM_BUILTIN_UNREACHABLE - LLVM_BUILTIN_UNREACHABLE; - #endif -} - #endif diff --git a/rpcs3/Emu/RSX/D3D12/D3D12Utils.h b/rpcs3/Emu/RSX/D3D12/D3D12Utils.h index d1d1315c58..6dbb54901f 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12Utils.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12Utils.h @@ -8,69 +8,6 @@ #include "Emu/RSX/GCM.h" -// From llvm Compiler.h - -// Need to be set by define -#ifndef __has_builtin -#define __has_builtin(x) 0 -#endif - -/// \macro LLVM_GNUC_PREREQ -/// \brief Extend the default __GNUC_PREREQ even if glibc's features.h isn't -/// available. -#ifndef LLVM_GNUC_PREREQ -# if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) -#define LLVM_GNUC_PREREQ(maj, min, patch) \ - ((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) + __GNUC_PATCHLEVEL__ >= \ - ((maj) << 20) + ((min) << 10) + (patch)) -# elif defined(__GNUC__) && defined(__GNUC_MINOR__) -#define LLVM_GNUC_PREREQ(maj, min, patch) \ - ((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) >= ((maj) << 20) + ((min) << 10)) -#else -#define LLVM_GNUC_PREREQ(maj, min, patch) 0 -#endif -#endif - -#ifdef __GNUC__ -#define LLVM_ATTRIBUTE_NORETURN __attribute__((noreturn)) -#elif defined(_MSC_VER) -#define LLVM_ATTRIBUTE_NORETURN __declspec(noreturn) -#else -#define LLVM_ATTRIBUTE_NORETURN -#endif - -#if __has_builtin(__builtin_unreachable) || LLVM_GNUC_PREREQ(4, 5, 0) -# define LLVM_BUILTIN_UNREACHABLE __builtin_unreachable() -#elif defined(_MSC_VER) -# define LLVM_BUILTIN_UNREACHABLE __assume(false) -#endif - -LLVM_ATTRIBUTE_NORETURN void unreachable_internal(); - -template -void unreachable_internal_verbose(const char *file, unsigned line, const Args &...args) -{ - LOG_ERROR(RSX, "file %s line %d : %s", file, line, fmt::format(args...)); - unreachable_internal(); -} - -/// Marks that the current location is not supposed to be reachable. -/// In !NDEBUG builds, prints the message and location info to stderr. -/// In NDEBUG builds, becomes an optimizer hint that the current location -/// is not supposed to be reachable. On compilers that don't support -/// such hints, prints a reduced message instead. -/// -/// Use this instead of assert(0). It conveys intent more clearly and -/// allows compilers to omit some unnecessary code. -#ifndef NDEBUG -#define unreachable(...) \ - unreachable_internal_verbose(__FILE__, __LINE__, ##__VA_ARGS__) -//#elif defined(LLVM_BUILTIN_UNREACHABLE) -//#define unreachable(msg) LLVM_BUILTIN_UNREACHABLE -#else -#define unreachable(msg) unreachable_internal() -#endif - using namespace Microsoft::WRL; // From DX12 D3D11On12 Sample (MIT Licensed) diff --git a/rpcs3/Emu/RSX/GCM.cpp b/rpcs3/Emu/RSX/GCM.cpp index d7c2ee7244..afb70aaec4 100644 --- a/rpcs3/Emu/RSX/GCM.cpp +++ b/rpcs3/Emu/RSX/GCM.cpp @@ -721,7 +721,7 @@ std::string rsx::get_method_name(const u32 id) // Various parameter pretty printing function namespace { - std::string get_blend_factor(u16 factor) noexcept + std::string get_blend_factor(u16 factor) { switch (factor) { @@ -744,7 +744,7 @@ namespace return "Error"; } - std::string get_blend_op(u16 op) noexcept + std::string get_blend_op(u16 op) { switch (op) { @@ -760,7 +760,7 @@ namespace return "Error"; } - std::string get_logic_op(u32 op) noexcept + std::string get_logic_op(u32 op) { switch (op) { @@ -783,7 +783,7 @@ namespace return "Error"; } - std::string get_compare_func(u32 op) noexcept + std::string get_compare_func(u32 op) { switch (op) { @@ -799,7 +799,7 @@ namespace return "Error"; } - std::string get_primitive_mode(u8 draw_mode) noexcept + std::string get_primitive_mode(u8 draw_mode) { switch (draw_mode) { @@ -817,12 +817,12 @@ namespace return "Error"; } - std::string ptr_to_string(u32 ptr) noexcept + std::string ptr_to_string(u32 ptr) { return fmt::format("0x%08x", ptr); } - std::string dma_mode(u32 arg) noexcept + std::string dma_mode(u32 arg) { switch (arg) { @@ -835,7 +835,7 @@ namespace } - std::string depth_stencil_surface_format(u32 format) noexcept + std::string depth_stencil_surface_format(u32 format) { switch (format) { @@ -845,7 +845,7 @@ namespace return "Error"; } - std::string color_surface_format(u32 format) noexcept + std::string color_surface_format(u32 format) { switch (format) { @@ -867,7 +867,7 @@ namespace return "Error"; } - std::string surface_target(u32 target) noexcept + std::string surface_target(u32 target) { switch (target) { @@ -881,7 +881,7 @@ namespace return "Error"; } - std::string get_clear_color(u32 clear_color) noexcept + std::string get_clear_color(u32 clear_color) { u8 clear_a = clear_color >> 24; u8 clear_r = clear_color >> 16; @@ -890,14 +890,14 @@ namespace return "A = " + std::to_string(clear_a / 255.0f) + " R = " + std::to_string(clear_r / 255.0f) + " G = " + std::to_string(clear_g / 255.0f) + " B = " + std::to_string(clear_b / 255.0f); } - static std::string get_zstencil_clear(u32 zstencil) noexcept + static std::string get_zstencil_clear(u32 zstencil) { u32 depth = zstencil >> 8; u32 stencil = zstencil & 0xff; return "Z = " + std::to_string(depth) + " S = " + std::to_string(stencil); } - std::string get_stencil_op(u32 op) noexcept + std::string get_stencil_op(u32 op) { switch (op) { @@ -912,7 +912,7 @@ namespace return "Error"; } - std::string get_vertex_attribute_format(u8 type) noexcept + std::string get_vertex_attribute_format(u8 type) { switch (type) { @@ -927,7 +927,7 @@ namespace return "Error"; } - std::string unpack_vertex_format(u32 arg) noexcept + std::string unpack_vertex_format(u32 arg) { u32 frequency = arg >> 16; u32 stride = (arg >> 8) & 0xff; @@ -939,7 +939,7 @@ namespace return "Type = " + get_vertex_attribute_format(type) + " size = " + std::to_string(size) + " stride = " + std::to_string(stride) + " frequency = " + std::to_string(frequency); } - std::string index_type(u16 arg) noexcept + std::string index_type(u16 arg) { switch (arg) { @@ -949,22 +949,22 @@ namespace return "Error"; } - std::string transform_constant(size_t index, u32 arg) noexcept + std::string transform_constant(size_t index, u32 arg) { return "Transform constant " + std::to_string(index) + ": " + std::to_string(arg) + "/" + std::to_string((float&)arg); } - std::string texture_offset(size_t index, u32 arg) noexcept + std::string texture_offset(size_t index, u32 arg) { return "Texture " + std::to_string(index) + ": Offset @" + ptr_to_string(arg); } - std::string texture_size(size_t index, u32 arg) noexcept + std::string texture_size(size_t index, u32 arg) { return "Texture " + std::to_string(index) + ": width = " + std::to_string(arg & 0xffff) + " height = " + std::to_string(arg >> 16); } - static std::string get_texture_format_name(u32 format) noexcept + static std::string get_texture_format_name(u32 format) { switch (format) { @@ -999,7 +999,7 @@ namespace return "Error"; } - std::string texture_format(size_t index, u32 arg) noexcept + std::string texture_format(size_t index, u32 arg) { int format = ((arg >> 8) & 0xFF); return "Texture " + std::to_string(index) + ": location = " + ptr_to_string((arg & 0x3) - 1) + @@ -1012,7 +1012,7 @@ namespace " mipmap levels = " + std::to_string((arg >> 16) & 0xFFFF); } - std::string get_texture_wrap_mode(u8 wrap) noexcept + std::string get_texture_wrap_mode(u8 wrap) { switch (wrap) { @@ -1028,7 +1028,7 @@ namespace return "Error"; } - std::string get_zfunc_name(u8 op) noexcept + std::string get_zfunc_name(u8 op) { switch (op) { @@ -1044,7 +1044,7 @@ namespace return "Error"; } - std::string texture_address(size_t index, u32 arg) noexcept + std::string texture_address(size_t index, u32 arg) { return "Texture " + std::to_string(index) + ": wrap_s = " + get_texture_wrap_mode(arg & 0xF) + " wrap_t = " + get_texture_wrap_mode((arg >> 8) & 0xF) + @@ -1056,7 +1056,7 @@ namespace " signed remap = " + std::to_string((arg >> 24) & 0xF); } - std::string get_texture_max_aniso_name(u8 aniso) noexcept + std::string get_texture_max_aniso_name(u8 aniso) { switch (aniso) { @@ -1072,7 +1072,7 @@ namespace return "Error"; } - std::string texture_control0(size_t index, u32 arg) noexcept + std::string texture_control0(size_t index, u32 arg) { std::string result = "Texture " + std::to_string(index); if ((arg >> 31) & 0x1) @@ -1087,26 +1087,26 @@ namespace return result; } - std::string texture_control1(size_t index, u32 arg) noexcept + std::string texture_control1(size_t index, u32 arg) { return "Texture " + std::to_string(index) + " remap = " + std::to_string(arg); } - std::string texture_control3(size_t index, u32 arg) noexcept + std::string texture_control3(size_t index, u32 arg) { return "Texture " + std::to_string(index) + " depth = " + std::to_string(arg >> 20) + " pitch = " + std::to_string(arg & 0xFFFFF); } - std::string texture_border_color(size_t index, u32 arg) noexcept + std::string texture_border_color(size_t index, u32 arg) { return "Texture " + std::to_string(index) + " border color = " + std::to_string(arg); } - std::string texture_filter(size_t index, u32 arg) noexcept + std::string texture_filter(size_t index, u32 arg) { return "Texture " + std::to_string(index) + " filter = " + std::to_string(arg); diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index d48f7af749..3373bc5187 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -1103,7 +1103,7 @@ namespace rsx return "rsx::thread"s; } - void thread::fill_scale_offset_data(void *buffer, bool is_d3d) const noexcept + void thread::fill_scale_offset_data(void *buffer, bool is_d3d) const { int clip_w = rsx::method_registers[NV4097_SET_SURFACE_CLIP_HORIZONTAL] >> 16; int clip_h = rsx::method_registers[NV4097_SET_SURFACE_CLIP_VERTICAL] >> 16; @@ -1134,7 +1134,7 @@ namespace rsx * Fill buffer with vertex program constants. * Buffer must be at least 512 float4 wide. */ - void thread::fill_vertex_program_constants_data(void *buffer) noexcept + void thread::fill_vertex_program_constants_data(void *buffer) { for (const auto &entry : transform_constants) local_transform_constants[entry.first] = entry.second; diff --git a/rpcs3/Emu/RSX/RSXThread.h b/rpcs3/Emu/RSX/RSXThread.h index cd13a6f38f..48cc31b117 100644 --- a/rpcs3/Emu/RSX/RSXThread.h +++ b/rpcs3/Emu/RSX/RSXThread.h @@ -31,7 +31,7 @@ struct frame_capture_data std::vector > command_queue; std::vector draw_calls; - void reset() noexcept + void reset() { command_queue.clear(); draw_calls.clear(); @@ -345,13 +345,13 @@ namespace rsx * Vertex shader's position is to be multiplied by this matrix. * if is_d3d is set, the matrix is modified to use d3d convention. */ - void fill_scale_offset_data(void *buffer, bool is_d3d = true) const noexcept; + void fill_scale_offset_data(void *buffer, bool is_d3d = true) const; /** * Fill buffer with vertex program constants. * Buffer must be at least 512 float4 wide. */ - void fill_vertex_program_constants_data(void *buffer) noexcept; + void fill_vertex_program_constants_data(void *buffer); /** * Copy rtt values to buffer. diff --git a/rpcs3/Loader/ELF64.cpp b/rpcs3/Loader/ELF64.cpp index 36abb1419b..12e043a55e 100644 --- a/rpcs3/Loader/ELF64.cpp +++ b/rpcs3/Loader/ELF64.cpp @@ -132,7 +132,7 @@ namespace loader info.name = std::string(module_info.name, 28); info.rtoc = module_info.toc + segment.begin.addr(); - LOG_WARNING(LOADER, "%s (rtoc=%x):", info.name, info.rtoc); + LOG_WARNING(LOADER, "%s (rtoc=0x%x):", info.name, info.rtoc); sys_prx_library_info_t lib; for (u32 e = module_info.exports_start.addr();