diff options
| author | comex <comexk@gmail.com> | 2014-11-19 20:25:23 -0500 |
|---|---|---|
| committer | comex <comexk@gmail.com> | 2014-11-19 20:25:23 -0500 |
| commit | fb50cb6d99062069a71db49d56d975df5c6eecb3 (patch) | |
| tree | b0a9615bcaa4d5d4efa65e590ff3b0e500391f6b /Source/Core/VideoBackends/OGL/Render.cpp | |
| parent | dd2c8c49b37360f8b8838ccdb323a84eae00e065 (diff) | |
| parent | c211450b997effa6d91059fb0aaa564892297719 (diff) | |
Merge pull request #1550 from degasus/bbox
OGL: implement bounding box support with ssbo
Diffstat (limited to 'Source/Core/VideoBackends/OGL/Render.cpp')
| -rw-r--r-- | Source/Core/VideoBackends/OGL/Render.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index 2b538f063c..502b7d31af 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -20,6 +20,7 @@ #include "Core/Core.h" #include "Core/Movie.h" +#include "VideoBackends/OGL/BoundingBox.h" #include "VideoBackends/OGL/FramebufferManager.h" #include "VideoBackends/OGL/GLInterfaceBase.h" #include "VideoBackends/OGL/GLUtil.h" @@ -465,6 +466,7 @@ Renderer::Renderer() g_Config.backend_info.bSupportsPrimitiveRestart = !DriverDetails::HasBug(DriverDetails::BUG_PRIMITIVERESTART) && ((GLExtensions::Version() >= 310) || GLExtensions::Supports("GL_NV_primitive_restart")); g_Config.backend_info.bSupportsEarlyZ = GLExtensions::Supports("GL_ARB_shader_image_load_store"); + g_Config.backend_info.bSupportsBBox = GLExtensions::Supports("GL_ARB_shader_storage_buffer_object"); // Desktop OpenGL supports the binding layout if it supports 420pack // OpenGL ES 3.1 supports it implicitly without an extension @@ -1161,6 +1163,52 @@ u32 Renderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) return 0; } +u16 Renderer::BBoxRead(int index) +{ + int swapped_index = index; + if (index >= 2) + swapped_index ^= 1; // swap 2 and 3 for top/bottom + + // Here we get the min/max value of the truncated position of the upscaled and swapped framebuffer. + // So we have to correct them to the unscaled EFB sizes. + int value = BoundingBox::Get(swapped_index); + + if (index < 2) + { + // left/right + value = value * EFB_WIDTH / s_target_width; + } + else + { + // up/down -- we have to swap up and down + value = value * EFB_HEIGHT / s_target_height; + value = EFB_HEIGHT - value - 1; + } + if (index & 1) + value++; // fix max values to describe the outer border + + return value; +} + +void Renderer::BBoxWrite(int index, u16 _value) +{ + int value = _value; // u16 isn't enough to multiply by the efb width + if (index & 1) + value--; + if (index < 2) + { + value = value * s_target_width / EFB_WIDTH; + } + else + { + index ^= 1; // swap 2 and 3 for top/bottom + value = EFB_HEIGHT - value - 1; + value = value * s_target_height / EFB_HEIGHT; + } + + BoundingBox::Set(index, value); +} + void Renderer::SetViewport() { // reversed gxsetviewport(xorig, yorig, width, height, nearz, farz) |
