From 6cb036d35fb5a21c21297570b828e81a5aa2bb60 Mon Sep 17 00:00:00 2001 From: DH Date: Wed, 7 Oct 2015 19:02:10 +0300 Subject: [PATCH] Fix for gcc/clang build --- Utilities/types.h | 108 ++++++++++++++------------ rpcs3/Emu/RSX/Common/BufferUtils.cpp | 4 +- rpcs3/Emu/RSX/Common/BufferUtils.h | 4 +- rpcs3/Emu/RSX/Common/TextureUtils.cpp | 4 +- rpcs3/Emu/RSX/Common/TextureUtils.h | 4 +- rpcs3/Emu/RSX/GCM.h | 10 +-- rpcs3/Emu/RSX/GL/gl_helpers.h | 2 +- rpcs3/Emu/RSX/RSXThread.cpp | 52 ++++++------- rpcs3/Emu/System.h | 6 +- 9 files changed, 108 insertions(+), 86 deletions(-) diff --git a/Utilities/types.h b/Utilities/types.h index 9b526253ba..d509e3ad76 100644 --- a/Utilities/types.h +++ b/Utilities/types.h @@ -56,45 +56,47 @@ struct size2_base { T width, height; - /* - size2_base() : width{}, height{} + constexpr size2_base() : width{}, height{} { } - size2_base(T width, T height) : width{ width }, height{ height } + constexpr size2_base(T width, T height) : width{ width }, height{ height } + { + } + + constexpr size2_base(const size2_base& rhs) : width{ rhs.width }, height{ rhs.height } { } - */ - size2_base operator -(const size2_base& rhs) const + constexpr size2_base operator -(const size2_base& rhs) const { return{ width - rhs.width, height - rhs.height }; } - size2_base operator -(T rhs) const + constexpr size2_base operator -(T rhs) const { return{ width - rhs, height - rhs }; } - size2_base operator +(const size2_base& rhs) const + constexpr size2_base operator +(const size2_base& rhs) const { return{ width + rhs.width, height + rhs.height }; } - size2_base operator +(T rhs) const + constexpr size2_base operator +(T rhs) const { return{ width + rhs, height + rhs }; } - size2_base operator /(const size2_base& rhs) const + constexpr size2_base operator /(const size2_base& rhs) const { return{ width / rhs.width, height / rhs.height }; } - size2_base operator /(T rhs) const + constexpr size2_base operator /(T rhs) const { return{ width / rhs, height / rhs }; } - size2_base operator *(const size2_base& rhs) const + constexpr size2_base operator *(const size2_base& rhs) const { return{ width * rhs.width, height * rhs.height }; } - size2_base operator *(T rhs) const + constexpr size2_base operator *(T rhs) const { return{ width * rhs, height * rhs }; } @@ -148,18 +150,18 @@ struct size2_base return *this; } - bool operator == (const size2_base& rhs) const + constexpr bool operator == (const size2_base& rhs) const { return width == rhs.width && height == rhs.height; } - bool operator != (const size2_base& rhs) const + constexpr bool operator != (const size2_base& rhs) const { return width != rhs.width || height != rhs.height; } template - operator size2_base() const + constexpr operator size2_base() const { return{ (NT)width, (NT)height }; } @@ -285,84 +287,87 @@ template struct position2_base { T x, y; - /* - position2_base() : x{}, y{} + + constexpr position2_base() : x{}, y{} { } - position2_base(T x, T y) : x{ x }, y{ y } + constexpr position2_base(T x, T y) : x{ x }, y{ y } { } - */ - bool operator >(const position2_base& rhs) const + constexpr position2_base(const position2_base& rhs) : x{ rhs.x }, y{ rhs.y } + { + } + + constexpr bool operator >(const position2_base& rhs) const { return x > rhs.x && y > rhs.y; } - bool operator >(T rhs) const + constexpr bool operator >(T rhs) const { return x > rhs && y > rhs; } - bool operator <(const position2_base& rhs) const + constexpr bool operator <(const position2_base& rhs) const { return x < rhs.x && y < rhs.y; } - bool operator <(T rhs) const + constexpr bool operator <(T rhs) const { return x < rhs && y < rhs; } - bool operator >=(const position2_base& rhs) const + constexpr bool operator >=(const position2_base& rhs) const { return x >= rhs.x && y >= rhs.y; } - bool operator >=(T rhs) const + constexpr bool operator >=(T rhs) const { return x >= rhs && y >= rhs; } - bool operator <=(const position2_base& rhs) const + constexpr bool operator <=(const position2_base& rhs) const { return x <= rhs.x && y <= rhs.y; } - bool operator <=(T rhs) const + constexpr bool operator <=(T rhs) const { return x <= rhs && y <= rhs; } - position2_base operator -(const position2_base& rhs) const + constexpr position2_base operator -(const position2_base& rhs) const { return{ x - rhs.x, y - rhs.y }; } - position2_base operator -(T rhs) const + constexpr position2_base operator -(T rhs) const { return{ x - rhs, y - rhs }; } - position2_base operator +(const position2_base& rhs) const + constexpr position2_base operator +(const position2_base& rhs) const { return{ x + rhs.x, y + rhs.y }; } - position2_base operator +(T rhs) const + constexpr position2_base operator +(T rhs) const { return{ x + rhs, y + rhs }; } template - position2_base operator *(RhsT rhs) const + constexpr position2_base operator *(RhsT rhs) const { return{ T(x * rhs), T(y * rhs) }; } - position2_base operator *(const position2_base& rhs) const + constexpr position2_base operator *(const position2_base& rhs) const { return{ T(x * rhs.x), T(y * rhs.y) }; } template - position2_base operator /(RhsT rhs) const + constexpr position2_base operator /(RhsT rhs) const { return{ x / rhs, y / rhs }; } - position2_base operator /(const position2_base& rhs) const + constexpr position2_base operator /(const position2_base& rhs) const { return{ x / rhs.x, y / rhs.y }; } - position2_base operator /(const size2_base& rhs) const + constexpr position2_base operator /(const size2_base& rhs) const { return{ x / rhs.width, y / rhs.height }; } @@ -393,59 +398,59 @@ struct position2_base } template - position2_base& operator *=(RhsT rhs) const + position2_base& operator *=(RhsT rhs) { x *= rhs; y *= rhs; return *this; } - position2_base& operator *=(const position2_base& rhs) const + position2_base& operator *=(const position2_base& rhs) { x *= rhs.x; y *= rhs.y; return *this; } template - position2_base& operator /=(RhsT rhs) const + position2_base& operator /=(RhsT rhs) { x /= rhs; y /= rhs; return *this; } - position2_base& operator /=(const position2_base& rhs) const + position2_base& operator /=(const position2_base& rhs) { x /= rhs.x; y /= rhs.y; return *this; } - bool operator ==(const position2_base& rhs) const + constexpr bool operator ==(const position2_base& rhs) const { return x == rhs.x && y == rhs.y; } - bool operator ==(T rhs) const + constexpr bool operator ==(T rhs) const { return x == rhs && y == rhs; } - bool operator !=(const position2_base& rhs) const + constexpr bool operator !=(const position2_base& rhs) const { return !(*this == rhs); } - bool operator !=(T rhs) const + constexpr bool operator !=(T rhs) const { return !(*this == rhs); } template - operator position2_base() const + constexpr operator position2_base() const { return{ (NT)x, (NT)y }; } - double distance(const position2_base& to) + double distance(const position2_base& to) const { return std::sqrt(double((x - to.x) * (x - to.x) + (y - to.y) * (y - to.y))); } @@ -646,12 +651,19 @@ struct coord_base struct { T width, height; }; }; - constexpr coord_base() : x{}, y{}, position{}, width{}, height{}, size{} + constexpr coord_base() : position{}, size{} +#ifdef _MSC_VER + //compiler error + , x{}, y{}, width{}, height{} +#endif { } constexpr coord_base(const position_base& position, const size2_base& size) - : x{ position.x }, y{ position.y }, position{ position }, width{ size.width }, height{ size.height }, size{ size } + : position{ position }, size{ size } +#ifdef _MSC_VER + , x{ position.x }, y{ position.y }, width{ size.width }, height{ size.height } +#endif { } diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.cpp b/rpcs3/Emu/RSX/Common/BufferUtils.cpp index 934b109264..73479dcd2b 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.cpp +++ b/rpcs3/Emu/RSX/Common/BufferUtils.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" +#ifdef DX12_SUPPORT #include "BufferUtils.h" @@ -243,4 +244,5 @@ void uploadIndexData(unsigned m_draw_mode, unsigned index_type, void* indexBuffe return; } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/rpcs3/Emu/RSX/Common/BufferUtils.h b/rpcs3/Emu/RSX/Common/BufferUtils.h index bdb46b22c4..5da0935a27 100644 --- a/rpcs3/Emu/RSX/Common/BufferUtils.h +++ b/rpcs3/Emu/RSX/Common/BufferUtils.h @@ -1,3 +1,4 @@ +#ifdef DX12_SUPPORT #pragma once #include #include "Emu/Memory/vm.h" @@ -37,4 +38,5 @@ size_t getIndexCount(unsigned m_draw_mode, unsigned initial_index_count); /* * Write index information to bufferMap */ -void uploadIndexData(unsigned m_draw_mode, unsigned index_type, void* indexBuffer, void* bufferMap, unsigned element_count); \ No newline at end of file +void uploadIndexData(unsigned m_draw_mode, unsigned index_type, void* indexBuffer, void* bufferMap, unsigned element_count); +#endif \ No newline at end of file diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.cpp b/rpcs3/Emu/RSX/Common/TextureUtils.cpp index 6d6cf383f8..71e5b61a1e 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.cpp +++ b/rpcs3/Emu/RSX/Common/TextureUtils.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" +#ifdef DX12_SUPPORT #include "Emu/Memory/vm.h" #include "TextureUtils.h" #include "../RSXThread.h" @@ -541,4 +542,5 @@ std::vector uploadPlacedTexture(const RSXTexture &texture, size return writeTexelsGeneric((char*)pixels, (char*)textureData, w, h, blockSizeInByte, texture.GetMipmap()); } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.h b/rpcs3/Emu/RSX/Common/TextureUtils.h index 4ed2981bfd..afbe88b704 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.h +++ b/rpcs3/Emu/RSX/Common/TextureUtils.h @@ -1,4 +1,5 @@ #pragma once +#ifdef DX12_SUPPORT #include "../RSXTexture.h" #include @@ -21,4 +22,5 @@ size_t getPlacedTextureStorageSpace(const rsx::texture &texture, size_t rowPitch * Data are not packed, they are stored per rows using rowPitchAlignement. * Similarly, offset for every mipmaplevel is aligned to rowPitchAlignement boundary. */ -std::vector uploadPlacedTexture(const rsx::texture &texture, size_t rowPitchAlignement, void* textureData); \ No newline at end of file +std::vector uploadPlacedTexture(const rsx::texture &texture, size_t rowPitchAlignement, void* textureData); +#endif \ No newline at end of file diff --git a/rpcs3/Emu/RSX/GCM.h b/rpcs3/Emu/RSX/GCM.h index 20a21b590b..c726b8635f 100644 --- a/rpcs3/Emu/RSX/GCM.h +++ b/rpcs3/Emu/RSX/GCM.h @@ -903,9 +903,9 @@ enum Method namespace rsx { template - static std::array make_command(u32 start_register, T... values) + static auto make_command(u32 start_register, T... values) -> std::array { - return{ (start_register << 2) | (sizeof...(values) << 18), values... }; + return{ (start_register << 2) | u32(sizeof...(values) << 18), u32(values)... }; } static u32 make_jump(u32 offset) @@ -916,14 +916,12 @@ namespace rsx template static size_t make_command(vm::ps3::ptr &dst, u32 start_register, T... values) { - auto commands = make_command(start_register, values...); - - for (u32 command : commands) + for (u32 command : { (start_register << 2) | u32(sizeof...(values) << 18), u32(values)... }) { *dst++ = command; } - return commands.size(); + return sizeof...(values) + 1; } template diff --git a/rpcs3/Emu/RSX/GL/gl_helpers.h b/rpcs3/Emu/RSX/GL/gl_helpers.h index 997f498910..a63a873c88 100644 --- a/rpcs3/Emu/RSX/GL/gl_helpers.h +++ b/rpcs3/Emu/RSX/GL/gl_helpers.h @@ -796,7 +796,7 @@ namespace gl clamp_to_edge = GL_CLAMP_TO_EDGE, clamp_to_border = GL_CLAMP_TO_BORDER, mirror_clamp = GL_MIRROR_CLAMP_EXT, - mirror_clamp_to_edge = GL_MIRROR_CLAMP_TO_EDGE, + //mirror_clamp_to_edge = GL_MIRROR_CLAMP_TO_EDGE, mirror_clamp_to_border = GL_MIRROR_CLAMP_TO_BORDER_EXT }; diff --git a/rpcs3/Emu/RSX/RSXThread.cpp b/rpcs3/Emu/RSX/RSXThread.cpp index 607883c720..eacc8d4950 100644 --- a/rpcs3/Emu/RSX/RSXThread.cpp +++ b/rpcs3/Emu/RSX/RSXThread.cpp @@ -39,12 +39,12 @@ namespace rsx namespace nv406e { - __forceinline void set_reference(thread* rsx, u32 arg) + force_inline void set_reference(thread* rsx, u32 arg) { rsx->ctrl->ref.exchange(arg); } - __forceinline void semaphore_acquire(thread* rsx, u32 arg) + force_inline void semaphore_acquire(thread* rsx, u32 arg) { //TODO: dma while (vm::read32(rsx->label_addr + method_registers[NV406E_SEMAPHORE_OFFSET]) != arg) @@ -56,7 +56,7 @@ namespace rsx } } - __forceinline void semaphore_release(thread* rsx, u32 arg) + force_inline void semaphore_release(thread* rsx, u32 arg) { //TODO: dma vm::write32(rsx->label_addr + method_registers[NV406E_SEMAPHORE_OFFSET], arg); @@ -65,13 +65,13 @@ namespace rsx namespace nv4097 { - __forceinline void texture_read_semaphore_release(thread* rsx, u32 arg) + force_inline void texture_read_semaphore_release(thread* rsx, u32 arg) { //TODO: dma vm::write32(rsx->label_addr + method_registers[NV4097_SET_SEMAPHORE_OFFSET], arg); } - __forceinline void back_end_write_semaphore_release(thread* rsx, u32 arg) + force_inline void back_end_write_semaphore_release(thread* rsx, u32 arg) { //TODO: dma vm::write32(rsx->label_addr + method_registers[NV4097_SET_SEMAPHORE_OFFSET], @@ -80,7 +80,7 @@ namespace rsx //fire only when all data passed to rsx cmd buffer template - __forceinline void set_vertex_data_impl(thread* rsx, u32 arg) + force_inline void set_vertex_data_impl(thread* rsx, u32 arg) { static const size_t element_size = (count * sizeof(type)); static const size_t element_size_in_words = element_size / sizeof(u32); @@ -105,56 +105,56 @@ namespace rsx } template - __forceinline void set_vertex_data4ub_m(thread* rsx, u32 arg) + force_inline void set_vertex_data4ub_m(thread* rsx, u32 arg) { set_vertex_data_impl(rsx, arg); } template - __forceinline void set_vertex_data1f_m(thread* rsx, u32 arg) + force_inline void set_vertex_data1f_m(thread* rsx, u32 arg) { set_vertex_data_impl(rsx, arg); } template - __forceinline void set_vertex_data2f_m(thread* rsx, u32 arg) + force_inline void set_vertex_data2f_m(thread* rsx, u32 arg) { set_vertex_data_impl(rsx, arg); } template - __forceinline void set_vertex_data3f_m(thread* rsx, u32 arg) + force_inline void set_vertex_data3f_m(thread* rsx, u32 arg) { set_vertex_data_impl(rsx, arg); } template - __forceinline void set_vertex_data4f_m(thread* rsx, u32 arg) + force_inline void set_vertex_data4f_m(thread* rsx, u32 arg) { set_vertex_data_impl(rsx, arg); } template - __forceinline void set_vertex_data2s_m(thread* rsx, u32 arg) + force_inline void set_vertex_data2s_m(thread* rsx, u32 arg) { set_vertex_data_impl(rsx, arg); } template - __forceinline void set_vertex_data4s_m(thread* rsx, u32 arg) + force_inline void set_vertex_data4s_m(thread* rsx, u32 arg) { set_vertex_data_impl(rsx, arg); } template - __forceinline void set_vertex_data_array_format(thread* rsx, u32 arg) + force_inline void set_vertex_data_array_format(thread* rsx, u32 arg) { auto& info = rsx->vertex_arrays_info[index]; info.unpack(arg); info.array = info.size > 0; } - __forceinline void draw_arrays(thread* rsx, u32 arg) + force_inline void draw_arrays(thread* rsx, u32 arg) { u32 first = arg & 0xffffff; u32 count = (arg >> 24) + 1; @@ -162,7 +162,7 @@ namespace rsx rsx->load_vertex_data(first, count); } - __forceinline void draw_index_array(thread* rsx, u32 arg) + force_inline void draw_index_array(thread* rsx, u32 arg) { u32 first = arg & 0xffffff; u32 count = (arg >> 24) + 1; @@ -172,7 +172,7 @@ namespace rsx } template - __forceinline void set_transform_constant(thread* rsxthr, u32 arg) + force_inline void set_transform_constant(thread* rsxthr, u32 arg) { u32& load = method_registers[NV4097_SET_TRANSFORM_CONSTANT_LOAD]; @@ -183,7 +183,7 @@ namespace rsx } template - __forceinline void set_transform_program(thread* rsx, u32 arg) + force_inline void set_transform_program(thread* rsx, u32 arg) { u32& load = method_registers[NV4097_SET_TRANSFORM_PROGRAM_LOAD]; @@ -193,7 +193,7 @@ namespace rsx memcpy(rsx->transform_program + load++ * count, method_registers + NV4097_SET_TRANSFORM_PROGRAM + index * count, size); } - __forceinline void set_begin_end(thread* rsx, u32 arg) + force_inline void set_begin_end(thread* rsx, u32 arg) { if (arg) { @@ -241,7 +241,7 @@ namespace rsx rsx->vertex_draw_count = 0; } - __forceinline void get_report(thread* rsx, u32 arg) + force_inline void get_report(thread* rsx, u32 arg) { u8 type = arg >> 24; u32 offset = arg & 0xffffff; @@ -271,7 +271,7 @@ namespace rsx //result->padding = 0; } - __forceinline void clear_report_value(thread* rsx, u32 arg) + force_inline void clear_report_value(thread* rsx, u32 arg) { switch (arg) { @@ -291,7 +291,7 @@ namespace rsx namespace nv308a { template - __forceinline void color(u32 arg) + force_inline void color(u32 arg) { u32 point = method_registers[NV308A_POINT]; u16 x = point; @@ -309,7 +309,7 @@ namespace rsx namespace nv3089 { - __forceinline void image_in(u32 arg) + force_inline void image_in(u32 arg) { const u16 width = method_registers[NV3089_IMAGE_IN_SIZE]; const u16 height = method_registers[NV3089_IMAGE_IN_SIZE] >> 16; @@ -487,7 +487,7 @@ namespace rsx namespace nv0039 { - __forceinline void buffer_notify(u32 arg) + force_inline void buffer_notify(u32 arg) { const u32 inPitch = method_registers[NV0039_PITCH_IN]; const u32 outPitch = method_registers[NV0039_PITCH_OUT]; @@ -561,13 +561,13 @@ namespace rsx using rsx_impl_method_t = void(*)(u32); template - __forceinline static void call_impl_func(thread *rsx, u32 arg) + force_inline static void call_impl_func(thread *rsx, u32 arg) { impl_func(rsx, arg); } template - __forceinline static void call_impl_func(thread *rsx, u32 arg) + force_inline static void call_impl_func(thread *rsx, u32 arg) { impl_func(arg); } diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index 0c3b730a08..81e2799a4d 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -3,6 +3,10 @@ #include "Loader/Loader.h" #include "DbgCommand.h" +//just for frame_type +//TODO: provide better way +#include "Emu/RSX/GSRender.h" + struct EmuCallbacks { std::function)> call_after; @@ -11,7 +15,7 @@ struct EmuCallbacks std::function()> get_kb_handler; std::function()> get_mouse_handler; std::function()> get_pad_handler; - std::function(enum class frame_type)> get_gs_frame; + std::function(frame_type)> get_gs_frame; std::function()> get_msg_dialog; std::function()> get_save_dialog; };