From b2ef931772745ec034959c036344a7e5e9ab6fa5 Mon Sep 17 00:00:00 2001
From: Romain TISSERAND <romain.tisserand@gmail.com>
Date: Mon, 12 Oct 2020 13:15:21 +0200
Subject: [PATCH] Minor gpu_sw optimizations and warning fixes

---
 src/core/gpu_sw.cpp | 8 ++++----
 src/core/gpu_sw.h   | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/core/gpu_sw.cpp b/src/core/gpu_sw.cpp
index e60efee1a..561aa2afe 100644
--- a/src/core/gpu_sw.cpp
+++ b/src/core/gpu_sw.cpp
@@ -269,8 +269,8 @@ void GPU_SW::DispatchRenderCommand()
       const u32 texcoord_and_palette = rc.texture_enable ? FifoPop() : 0;
       const auto [texcoord_x, texcoord_y] = UnpackTexcoord(Truncate16(texcoord_and_palette));
 
-      s32 width;
-      s32 height;
+      u32 width;
+      u32 height;
       switch (rc.rectangle_size)
       {
         case DrawRectangleSize::R1x1:
@@ -288,8 +288,8 @@ void GPU_SW::DispatchRenderCommand()
         default:
         {
           const u32 width_and_height = FifoPop();
-          width = static_cast<s32>(width_and_height & VRAM_WIDTH_MASK);
-          height = static_cast<s32>((width_and_height >> 16) & VRAM_HEIGHT_MASK);
+          width = static_cast<u32>(width_and_height & VRAM_WIDTH_MASK);
+          height = static_cast<u32>((width_and_height >> 16) & VRAM_HEIGHT_MASK);
 
           if (width >= MAX_PRIMITIVE_WIDTH || height >= MAX_PRIMITIVE_HEIGHT)
           {
diff --git a/src/core/gpu_sw.h b/src/core/gpu_sw.h
index 08f2e242a..d59148487 100644
--- a/src/core/gpu_sw.h
+++ b/src/core/gpu_sw.h
@@ -17,10 +17,10 @@ public:
   bool Initialize(HostDisplay* host_display) override;
   void Reset() override;
 
-  u16 GetPixel(u32 x, u32 y) const { return m_vram[VRAM_WIDTH * y + x]; }
-  const u16* GetPixelPtr(u32 x, u32 y) const { return &m_vram[VRAM_WIDTH * y + x]; }
-  u16* GetPixelPtr(u32 x, u32 y) { return &m_vram[VRAM_WIDTH * y + x]; }
-  void SetPixel(u32 x, u32 y, u16 value) { m_vram[VRAM_WIDTH * y + x] = value; }
+  ALWAYS_INLINE_RELEASE u16 GetPixel(const u32 x, const u32 y) const { return m_vram[VRAM_WIDTH * y + x]; }
+  ALWAYS_INLINE_RELEASE const u16* GetPixelPtr(const u32 x, const u32 y) const { return &m_vram[VRAM_WIDTH * y + x]; }
+  ALWAYS_INLINE_RELEASE u16* GetPixelPtr(const u32 x, const u32 y) { return &m_vram[VRAM_WIDTH * y + x]; }
+  ALWAYS_INLINE_RELEASE void SetPixel(const u32 x, const u32 y, const u16 value) { m_vram[VRAM_WIDTH * y + x] = value; }
 
   // this is actually (31 * 255) >> 4) == 494, but to simplify addressing we use the next power of two (512)
   static constexpr u32 DITHER_LUT_SIZE = 512;