Fixing 1px offset in tiles.

This commit is contained in:
Ben Vanik 2015-03-21 22:52:35 -07:00
parent fa58eaa317
commit 2401bb7d03
3 changed files with 8 additions and 9 deletions

View File

@ -52,7 +52,6 @@ struct VertexData { \n\
const std::string vs_source = header +
"\n\
layout(location = 0) uniform vec4 src_uv; \n\
layout(location = 1) uniform vec4 dest_rect; \n\
out gl_PerVertex { \n\
vec4 gl_Position; \n\
float gl_PointSize; \n\
@ -229,7 +228,8 @@ void Blitter::Draw(GLuint src_texture, Rect2D src_rect, Rect2D dest_rect,
break;
}
glViewport(dest_rect.x, dest_rect.y, dest_rect.width, dest_rect.height);
glViewportIndexedf(0, GLfloat(dest_rect.x), GLfloat(dest_rect.y),
GLfloat(dest_rect.width), GLfloat(dest_rect.height));
// TODO(benvanik): avoid this?
GLint src_texture_width;
@ -242,8 +242,6 @@ void Blitter::Draw(GLuint src_texture, Rect2D src_rect, Rect2D dest_rect,
src_rect.y / float(src_texture_height),
src_rect.width / float(src_texture_width),
src_rect.height / float(src_texture_height));
glProgramUniform4f(vertex_program_, 1, float(dest_rect.x), float(dest_rect.y),
float(dest_rect.width), float(dest_rect.height));
// Useful for seeing the entire framebuffer/etc:
// glProgramUniform4f(vertex_program_, 0, 0.0f, 0.0f, 1.0f, 1.0f);

View File

@ -2669,22 +2669,22 @@ bool CommandProcessor::IssueCopy() {
assert_true(fetch->size == 6);
const uint8_t* vertex_addr = membase_ + (fetch->address << 2);
trace_writer_.WriteMemoryRead(fetch->address << 2, fetch->size * 4);
int32_t dest_min_x = int32_t(std::ceilf(std::min(
int32_t dest_min_x = int32_t((std::min(
std::min(
GpuSwap(poly::load<float>(vertex_addr + 0), Endian(fetch->endian)),
GpuSwap(poly::load<float>(vertex_addr + 8), Endian(fetch->endian))),
GpuSwap(poly::load<float>(vertex_addr + 16), Endian(fetch->endian)))));
int32_t dest_max_x = int32_t(std::ceilf(std::max(
int32_t dest_max_x = int32_t((std::max(
std::max(
GpuSwap(poly::load<float>(vertex_addr + 0), Endian(fetch->endian)),
GpuSwap(poly::load<float>(vertex_addr + 8), Endian(fetch->endian))),
GpuSwap(poly::load<float>(vertex_addr + 16), Endian(fetch->endian)))));
int32_t dest_min_y = int32_t(std::ceilf(std::min(
int32_t dest_min_y = int32_t((std::min(
std::min(
GpuSwap(poly::load<float>(vertex_addr + 4), Endian(fetch->endian)),
GpuSwap(poly::load<float>(vertex_addr + 12), Endian(fetch->endian))),
GpuSwap(poly::load<float>(vertex_addr + 20), Endian(fetch->endian)))));
int32_t dest_max_y = int32_t(std::ceilf(std::max(
int32_t dest_max_y = int32_t((std::max(
std::max(
GpuSwap(poly::load<float>(vertex_addr + 4), Endian(fetch->endian)),
GpuSwap(poly::load<float>(vertex_addr + 12), Endian(fetch->endian))),

View File

@ -46,6 +46,7 @@ std::string GL4Shader::GetHeader() {
"#extension GL_ARB_shader_draw_parameters : require\n"
"#extension GL_ARB_shader_storage_buffer_object : require\n"
"#extension GL_ARB_shading_language_420pack : require\n"
"#extension GL_ARB_fragment_coord_conventions : require\n"
"#define FLT_MAX 3.402823466e+38\n"
"precision highp float;\n"
"precision highp int;\n"
@ -247,7 +248,7 @@ bool GL4Shader::PreparePixelShader(
std::string source =
GetHeader() +
"layout(origin_upper_left) in vec4 gl_FragCoord;\n"
"layout(origin_upper_left, pixel_center_integer) in vec4 gl_FragCoord;\n"
"layout(location = 0) flat in uint draw_id;\n"
"layout(location = 1) in VertexData vtx;\n"
"layout(location = 0) out vec4 oC[4];\n"