1
0
Fork 0

OpenGL: Add scaled resolution support to scissor

This commit is contained in:
Yuri Kunde Schlesner 2016-06-27 22:16:04 -07:00
parent f0b9bc14b6
commit ecf6ecf325
4 changed files with 16 additions and 3 deletions

View File

@ -196,6 +196,14 @@ void RasterizerOpenGL::DrawTriangles() {
(GLint)(rect.bottom + regs.viewport_corner.y * color_surface->res_scale_height), (GLint)(rect.bottom + regs.viewport_corner.y * color_surface->res_scale_height),
(GLsizei)(viewport_width * color_surface->res_scale_width), (GLsizei)(viewport_height * color_surface->res_scale_height)); (GLsizei)(viewport_width * color_surface->res_scale_width), (GLsizei)(viewport_height * color_surface->res_scale_height));
if (uniform_block_data.data.framebuffer_scale[0] != color_surface->res_scale_width ||
uniform_block_data.data.framebuffer_scale[1] != color_surface->res_scale_height) {
uniform_block_data.data.framebuffer_scale[0] = color_surface->res_scale_width;
uniform_block_data.data.framebuffer_scale[1] = color_surface->res_scale_height;
uniform_block_data.dirty = true;
}
// Sync and bind the texture surfaces // Sync and bind the texture surfaces
const auto pica_textures = regs.GetTextures(); const auto pica_textures = regs.GetTextures();
for (unsigned texture_index = 0; texture_index < pica_textures.size(); ++texture_index) { for (unsigned texture_index = 0; texture_index < pica_textures.size(); ++texture_index) {

View File

@ -328,6 +328,7 @@ private:
// the end of a uniform block is included in UNIFORM_BLOCK_DATA_SIZE or not. // the end of a uniform block is included in UNIFORM_BLOCK_DATA_SIZE or not.
// Not following that rule will cause problems on some AMD drivers. // Not following that rule will cause problems on some AMD drivers.
struct UniformData { struct UniformData {
alignas(8) GLvec2 framebuffer_scale;
GLint alphatest_ref; GLint alphatest_ref;
GLfloat depth_scale; GLfloat depth_scale;
GLfloat depth_offset; GLfloat depth_offset;
@ -342,7 +343,7 @@ private:
alignas(16) GLvec4 tev_combiner_buffer_color; alignas(16) GLvec4 tev_combiner_buffer_color;
}; };
static_assert(sizeof(UniformData) == 0x3B0, "The size of the UniformData structure has changed, update the structure in the shader"); static_assert(sizeof(UniformData) == 0x3C0, "The size of the UniformData structure has changed, update the structure in the shader");
static_assert(sizeof(UniformData) < 16384, "UniformData structure must be less than 16kb as per the OpenGL spec"); static_assert(sizeof(UniformData) < 16384, "UniformData structure must be less than 16kb as per the OpenGL spec");
/// Sets the OpenGL shader in accordance with the current PICA register state /// Sets the OpenGL shader in accordance with the current PICA register state

View File

@ -554,6 +554,7 @@ struct LightSrc {
}; };
layout (std140) uniform shader_data { layout (std140) uniform shader_data {
vec2 framebuffer_scale;
int alphatest_ref; int alphatest_ref;
float depth_scale; float depth_scale;
float depth_offset; float depth_offset;
@ -595,8 +596,10 @@ vec4 secondary_fragment_color = vec4(0.0);
if (state.scissor_test_mode == Regs::ScissorMode::Include) if (state.scissor_test_mode == Regs::ScissorMode::Include)
out += "!"; out += "!";
// x2,y2 have +1 added to cover the entire pixel area // x2,y2 have +1 added to cover the entire pixel area
out += "(gl_FragCoord.x >= scissor_x1 && gl_FragCoord.x < scissor_x2 + 1 && " out += "(gl_FragCoord.x >= scissor_x1 * framebuffer_scale.x && "
"gl_FragCoord.y >= scissor_y1 && gl_FragCoord.y < scissor_y2 + 1)) discard;\n"; "gl_FragCoord.y >= scissor_y1 * framebuffer_scale.y && "
"gl_FragCoord.x < (scissor_x2 + 1) * framebuffer_scale.x && "
"gl_FragCoord.y < (scissor_y2 + 1) * framebuffer_scale.y)) discard;\n";
} }
out += "float z_over_w = 1.0 - gl_FragCoord.z * 2.0;\n"; out += "float z_over_w = 1.0 - gl_FragCoord.z * 2.0;\n";

View File

@ -17,6 +17,7 @@
#include "video_core/pica.h" #include "video_core/pica.h"
using GLvec2 = std::array<GLfloat, 2>;
using GLvec3 = std::array<GLfloat, 3>; using GLvec3 = std::array<GLfloat, 3>;
using GLvec4 = std::array<GLfloat, 4>; using GLvec4 = std::array<GLfloat, 4>;