aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/video_core
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/debug_utils/debug_utils.cpp4
-rw-r--r--src/video_core/debug_utils/debug_utils.h2
-rw-r--r--src/video_core/renderer_base.h2
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp31
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.h11
-rw-r--r--src/video_core/utils.cpp4
-rw-r--r--src/video_core/utils.h20
-rw-r--r--src/video_core/vertex_shader.h2
8 files changed, 55 insertions, 21 deletions
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp
index 22b8e995..275b06b7 100644
--- a/src/video_core/debug_utils/debug_utils.cpp
+++ b/src/video_core/debug_utils/debug_utils.cpp
@@ -318,9 +318,9 @@ void DumpTexture(const Pica::Regs::TextureConfig& texture_config, u8* data) {
return;
#ifndef HAVE_PNG
- return;
+ return;
#else
- if (!data)
+ if (!data)
return;
// Write data to file
diff --git a/src/video_core/debug_utils/debug_utils.h b/src/video_core/debug_utils/debug_utils.h
index 8b1499bf..b1558cfa 100644
--- a/src/video_core/debug_utils/debug_utils.h
+++ b/src/video_core/debug_utils/debug_utils.h
@@ -41,7 +41,7 @@ void DumpShader(const u32* binary_data, u32 binary_size, const u32* swizzle_data
// Utility class to log Pica commands.
struct PicaTrace {
struct Write : public std::pair<u32,u32> {
- Write(u32 id, u32 value) : std::pair<u32,u32>(id, value) {}
+ Write(u32 id, u32 value) : std::pair<u32,u32>(id, value) {}
u32& Id() { return first; }
const u32& Id() const { return first; }
diff --git a/src/video_core/renderer_base.h b/src/video_core/renderer_base.h
index f1dbc9d1..bce402b8 100644
--- a/src/video_core/renderer_base.h
+++ b/src/video_core/renderer_base.h
@@ -25,7 +25,7 @@ public:
/// Swap buffers (render frame)
virtual void SwapBuffers() = 0;
- /**
+ /**
* Set the emulator window to use for renderer
* @param window EmuWindow handle to emulator window to use for rendering
*/
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index 8483f79b..abbb4c2c 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -191,7 +191,8 @@ void RendererOpenGL::DrawSingleScreenRotated(const TextureInfo& texture, float x
* Draws the emulated screens to the emulator window.
*/
void RendererOpenGL::DrawScreens() {
- glViewport(0, 0, resolution_width, resolution_height);
+ auto viewport_extent = GetViewportExtent();
+ glViewport(viewport_extent.left, viewport_extent.top, viewport_extent.GetWidth(), viewport_extent.GetHeight()); // TODO: Or bottom?
glClear(GL_COLOR_BUFFER_BIT);
glUseProgram(program_id);
@@ -228,6 +229,34 @@ void RendererOpenGL::SetWindow(EmuWindow* window) {
render_window = window;
}
+MathUtil::Rectangle<unsigned> RendererOpenGL::GetViewportExtent() {
+ unsigned framebuffer_width;
+ unsigned framebuffer_height;
+ std::tie(framebuffer_width, framebuffer_height) = render_window->GetFramebufferSize();
+
+ float window_aspect_ratio = static_cast<float>(framebuffer_height) / framebuffer_width;
+ float emulation_aspect_ratio = static_cast<float>(resolution_height) / resolution_width;
+
+ MathUtil::Rectangle<unsigned> viewport_extent;
+ if (window_aspect_ratio > emulation_aspect_ratio) {
+ // Window is narrower than the emulation content => apply borders to the top and bottom
+ unsigned viewport_height = emulation_aspect_ratio * framebuffer_width;
+ viewport_extent.left = 0;
+ viewport_extent.top = (framebuffer_height - viewport_height) / 2;
+ viewport_extent.right = viewport_extent.left + framebuffer_width;
+ viewport_extent.bottom = viewport_extent.top + viewport_height;
+ } else {
+ // Otherwise, apply borders to the left and right sides of the window.
+ unsigned viewport_width = framebuffer_height / emulation_aspect_ratio;
+ viewport_extent.left = (framebuffer_width - viewport_width) / 2;
+ viewport_extent.top = 0;
+ viewport_extent.right = viewport_extent.left + viewport_width;
+ viewport_extent.bottom = viewport_extent.top + framebuffer_height;
+ }
+
+ return viewport_extent;
+}
+
/// Initialize the renderer
void RendererOpenGL::Init() {
render_window->MakeCurrent();
diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h
index eed201a9..7fdcec73 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.h
+++ b/src/video_core/renderer_opengl/renderer_opengl.h
@@ -4,13 +4,15 @@
#pragma once
+#include <array>
+
#include "generated/gl_3_2_core.h"
-#include "common/common.h"
+#include "common/math_util.h"
+
#include "core/hw/gpu.h"
-#include "video_core/renderer_base.h"
-#include <array>
+#include "video_core/renderer_base.h"
class EmuWindow;
@@ -52,6 +54,9 @@ private:
static void LoadFBToActiveGLTexture(const GPU::Regs::FramebufferConfig& framebuffer,
const TextureInfo& texture);
+ /// Computes the viewport rectangle
+ MathUtil::Rectangle<unsigned> GetViewportExtent();
+
EmuWindow* render_window; ///< Handle to render window
u32 last_mode; ///< Last render mode
diff --git a/src/video_core/utils.cpp b/src/video_core/utils.cpp
index c1848f92..f1156a49 100644
--- a/src/video_core/utils.cpp
+++ b/src/video_core/utils.cpp
@@ -20,7 +20,7 @@ namespace VideoCore {
void DumpTGA(std::string filename, short width, short height, u8* raw_data) {
TGAHeader hdr = {0, 0, 2, 0, 0, 0, 0, width, height, 24, 0};
FILE* fout = fopen(filename.c_str(), "wb");
-
+
fwrite(&hdr, sizeof(TGAHeader), 1, fout);
for (int y = 0; y < height; y++) {
@@ -30,7 +30,7 @@ void DumpTGA(std::string filename, short width, short height, u8* raw_data) {
putc(raw_data[(3 * (y * width)) + (3 * x) + 2], fout); // r
}
}
-
+
fclose(fout);
}
} // namespace
diff --git a/src/video_core/utils.h b/src/video_core/utils.h
index 9cb3d4d4..21380a90 100644
--- a/src/video_core/utils.h
+++ b/src/video_core/utils.h
@@ -12,24 +12,24 @@ namespace FormatPrecision {
/// Adjust RGBA8 color with RGBA6 precision
static inline u32 rgba8_with_rgba6(u32 src) {
- u32 color = src;
- color &= 0xFCFCFCFC;
- color |= (color >> 6) & 0x03030303;
- return color;
+ u32 color = src;
+ color &= 0xFCFCFCFC;
+ color |= (color >> 6) & 0x03030303;
+ return color;
}
/// Adjust RGBA8 color with RGB565 precision
static inline u32 rgba8_with_rgb565(u32 src) {
- u32 color = (src & 0xF8FCF8);
- color |= (color >> 5) & 0x070007;
- color |= (color >> 6) & 0x000300;
- color |= 0xFF000000;
- return color;
+ u32 color = (src & 0xF8FCF8);
+ color |= (color >> 5) & 0x070007;
+ color |= (color >> 6) & 0x000300;
+ color |= 0xFF000000;
+ return color;
}
/// Adjust Z24 depth value with Z16 precision
static inline u32 z24_with_z16(u32 src) {
- return (src & 0xFFFF00) | (src >> 16);
+ return (src & 0xFFFF00) | (src >> 16);
}
} // namespace
diff --git a/src/video_core/vertex_shader.h b/src/video_core/vertex_shader.h
index 607a8e80..bfb6fb6e 100644
--- a/src/video_core/vertex_shader.h
+++ b/src/video_core/vertex_shader.h
@@ -141,7 +141,7 @@ union Instruction {
return BitFieldType::Value();
else if (GetRegisterType() == Temporary)
return BitFieldType::Value() - 0x10;
- else if (GetRegisterType() == FloatUniform)
+ else // if (GetRegisterType() == FloatUniform)
return BitFieldType::Value() - 0x20;
}