diff options
Diffstat (limited to 'src/core/hw')
| -rw-r--r-- | src/core/hw/gpu.cpp | 41 | ||||
| -rw-r--r-- | src/core/hw/gpu.h | 19 | ||||
| -rw-r--r-- | src/core/hw/hw.cpp | 5 | ||||
| -rw-r--r-- | src/core/hw/ndma.cpp | 5 |
4 files changed, 33 insertions, 37 deletions
diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp index 8709b8eb7..3ad801c63 100644 --- a/src/core/hw/gpu.cpp +++ b/src/core/hw/gpu.cpp @@ -3,14 +3,13 @@ // Refer to the license.txt file included. #include "common/common_types.h" -#include "common/log.h" +#include "core/settings.h" #include "core/core.h" #include "core/mem_map.h" #include "core/hle/hle.h" -#include "core/hle/kernel/thread.h" -#include "core/hle/service/gsp.h" +#include "core/hle/service/gsp_gpu.h" #include "core/hw/gpu.h" @@ -26,14 +25,17 @@ u32 g_cur_line = 0; ///< Current vertical screen line u64 g_last_line_ticks = 0; ///< CPU tick count from last vertical screen line u64 g_last_frame_ticks = 0; ///< CPU tick count from last frame +static u32 kFrameCycles = 0; ///< 268MHz / 60 frames per second +static u32 kFrameTicks = 0; ///< Approximate number of instructions/frame + template <typename T> inline void Read(T &var, const u32 raw_addr) { u32 addr = raw_addr - 0x1EF00000; - int index = addr / 4; + u32 index = addr / 4; // Reads other than u32 are untested, so I'd rather have them abort than silently fail if (index >= Regs::NumIds() || !std::is_same<T,u32>::value) { - ERROR_LOG(GPU, "unknown Read%d @ 0x%08X", sizeof(var) * 8, addr); + ERROR_LOG(GPU, "unknown Read%lu @ 0x%08X", sizeof(var) * 8, addr); return; } @@ -43,15 +45,15 @@ inline void Read(T &var, const u32 raw_addr) { template <typename T> inline void Write(u32 addr, const T data) { addr -= 0x1EF00000; - int index = addr / 4; + u32 index = addr / 4; // Writes other than u32 are untested, so I'd rather have them abort than silently fail if (index >= Regs::NumIds() || !std::is_same<T,u32>::value) { - ERROR_LOG(GPU, "unknown Write%d 0x%08X @ 0x%08X", sizeof(data) * 8, data, addr); + ERROR_LOG(GPU, "unknown Write%lu 0x%08X @ 0x%08X", sizeof(data) * 8, data, addr); return; } - g_regs[index] = data; + g_regs[index] = static_cast<u32>(data); switch (index) { @@ -83,15 +85,15 @@ inline void Write(u32 addr, const T data) { u8* source_pointer = Memory::GetPointer(Memory::PhysicalToVirtualAddress(config.GetPhysicalInputAddress())); u8* dest_pointer = Memory::GetPointer(Memory::PhysicalToVirtualAddress(config.GetPhysicalOutputAddress())); - for (int y = 0; y < config.output_height; ++y) { + for (u32 y = 0; y < config.output_height; ++y) { // TODO: Why does the register seem to hold twice the framebuffer width? - for (int x = 0; x < config.output_width; ++x) { + for (u32 x = 0; x < config.output_width; ++x) { struct { int r, g, b, a; } source_color = { 0, 0, 0, 0 }; switch (config.input_format) { - case Regs::FramebufferFormat::RGBA8: + case Regs::PixelFormat::RGBA8: { // TODO: Most likely got the component order messed up. u8* srcptr = source_pointer + x * 4 + y * config.input_width * 4; @@ -108,7 +110,7 @@ inline void Write(u32 addr, const T data) { } switch (config.output_format) { - /*case Regs::FramebufferFormat::RGBA8: + /*case Regs::PixelFormat::RGBA8: { // TODO: Untested u8* dstptr = (u32*)(dest_pointer + x * 4 + y * config.output_width * 4); @@ -119,7 +121,7 @@ inline void Write(u32 addr, const T data) { break; }*/ - case Regs::FramebufferFormat::RGB8: + case Regs::PixelFormat::RGB8: { // TODO: Most likely got the component order messed up. u8* dstptr = dest_pointer + x * 3 + y * config.output_width * 3; @@ -136,10 +138,10 @@ inline void Write(u32 addr, const T data) { } } - DEBUG_LOG(GPU, "DisplayTriggerTransfer: 0x%08x bytes from 0x%08x(%dx%d)-> 0x%08x(%dx%d), dst format %x", + DEBUG_LOG(GPU, "DisplayTriggerTransfer: 0x%08x bytes from 0x%08x(%ux%u)-> 0x%08x(%ux%u), dst format %x", config.output_height * config.output_width * 4, - config.GetPhysicalInputAddress(), (int)config.input_width, (int)config.input_height, - config.GetPhysicalOutputAddress(), (int)config.output_width, (int)config.output_height, + config.GetPhysicalInputAddress(), config.input_width, config.input_height, + config.GetPhysicalOutputAddress(), config.output_width, config.output_height, config.output_format.Value()); } break; @@ -216,6 +218,9 @@ void Update() { /// Initialize hardware void Init() { + kFrameCycles = 268123480 / Settings::values.gpu_refresh_rate; + kFrameTicks = kFrameCycles / 3; + g_cur_line = 0; g_last_frame_ticks = g_last_line_ticks = Core::g_app_core->GetTicks(); @@ -238,13 +243,13 @@ void Init() { framebuffer_top.width = 240; framebuffer_top.height = 400; framebuffer_top.stride = 3 * 240; - framebuffer_top.color_format = Regs::FramebufferFormat::RGB8; + framebuffer_top.color_format = Regs::PixelFormat::RGB8; framebuffer_top.active_fb = 0; framebuffer_sub.width = 240; framebuffer_sub.height = 320; framebuffer_sub.stride = 3 * 240; - framebuffer_sub.color_format = Regs::FramebufferFormat::RGB8; + framebuffer_sub.color_format = Regs::PixelFormat::RGB8; framebuffer_sub.active_fb = 0; NOTICE_LOG(GPU, "initialized OK"); diff --git a/src/core/hw/gpu.h b/src/core/hw/gpu.h index 7186bfa84..3fa7b9ccf 100644 --- a/src/core/hw/gpu.h +++ b/src/core/hw/gpu.h @@ -11,9 +11,6 @@ namespace GPU { -static const u32 kFrameCycles = 268123480 / 60; ///< 268MHz / 60 frames per second -static const u32 kFrameTicks = kFrameCycles / 3; ///< Approximate number of instructions/frame - // Returns index corresponding to the Regs member labeled by field_name // TODO: Due to Visual studio bug 209229, offsetof does not return constant expressions // when used with array elements (e.g. GPU_REG_INDEX(memory_fill_config[0])). @@ -56,7 +53,7 @@ struct Regs { "Structure size and register block length don't match") #endif - enum class FramebufferFormat : u32 { + enum class PixelFormat : u32 { RGBA8 = 0, RGB8 = 1, RGB565 = 2, @@ -84,9 +81,7 @@ struct Regs { INSERT_PADDING_WORDS(0x10b); - struct { - using Format = Regs::FramebufferFormat; - + struct FramebufferConfig { union { u32 size; @@ -102,7 +97,7 @@ struct Regs { union { u32 format; - BitField< 0, 3, Format> color_format; + BitField< 0, 3, PixelFormat> color_format; }; INSERT_PADDING_WORDS(0x1); @@ -130,8 +125,6 @@ struct Regs { INSERT_PADDING_WORDS(0x169); struct { - using Format = Regs::FramebufferFormat; - u32 input_address; u32 output_address; @@ -161,8 +154,8 @@ struct Regs { u32 flags; BitField< 0, 1, u32> flip_data; // flips input data horizontally (TODO) if true - BitField< 8, 3, Format> input_format; - BitField<12, 3, Format> output_format; + BitField< 8, 3, PixelFormat> input_format; + BitField<12, 3, PixelFormat> output_format; BitField<16, 1, u32> output_tiled; // stores output in a tiled format }; @@ -201,7 +194,7 @@ struct Regs { #undef INSERT_PADDING_WORDS_HELPER2 #undef INSERT_PADDING_WORDS - static inline int NumIds() { + static inline size_t NumIds() { return sizeof(Regs) / sizeof(u32); } diff --git a/src/core/hw/hw.cpp b/src/core/hw/hw.cpp index ed70486e6..33f75c50a 100644 --- a/src/core/hw/hw.cpp +++ b/src/core/hw/hw.cpp @@ -3,7 +3,6 @@ // Refer to the license.txt file included. #include "common/common_types.h" -#include "common/log.h" #include "core/hw/hw.h" #include "core/hw/gpu.h" @@ -51,7 +50,7 @@ inline void Read(T &var, const u32 addr) { break; default: - ERROR_LOG(HW, "unknown Read%d @ 0x%08X", sizeof(var) * 8, addr); + ERROR_LOG(HW, "unknown Read%lu @ 0x%08X", sizeof(var) * 8, addr); } } @@ -69,7 +68,7 @@ inline void Write(u32 addr, const T data) { break; default: - ERROR_LOG(HW, "unknown Write%d 0x%08X @ 0x%08X", sizeof(data) * 8, data, addr); + ERROR_LOG(HW, "unknown Write%lu 0x%08X @ 0x%08X", sizeof(data) * 8, data, addr); } } diff --git a/src/core/hw/ndma.cpp b/src/core/hw/ndma.cpp index f6aa72d16..e29a773f1 100644 --- a/src/core/hw/ndma.cpp +++ b/src/core/hw/ndma.cpp @@ -3,7 +3,6 @@ // Refer to the license.txt file included. #include "common/common_types.h" -#include "common/log.h" #include "core/hw/ndma.h" @@ -11,12 +10,12 @@ namespace NDMA { template <typename T> inline void Read(T &var, const u32 addr) { - ERROR_LOG(NDMA, "unknown Read%d @ 0x%08X", sizeof(var) * 8, addr); + ERROR_LOG(NDMA, "unknown Read%lu @ 0x%08X", sizeof(var) * 8, addr); } template <typename T> inline void Write(u32 addr, const T data) { - ERROR_LOG(NDMA, "unknown Write%d 0x%08X @ 0x%08X", sizeof(data) * 8, data, addr); + ERROR_LOG(NDMA, "unknown Write%lu 0x%08X @ 0x%08X", sizeof(data) * 8, data, addr); } // Explicitly instantiate template functions because we aren't defining this in the header: |
