Permalink
Browse files

Merge branch 'Stable' of https://github.com/Tinob/Ishiiruka

2 parents 6f025eb + 0e5990b commit ce994a2cea882bf4d145df87554e43314331cf9a @HannesMann HannesMann committed Jul 22, 2017
@@ -31,8 +31,10 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#pragma once
#include <atomic>
+#include <functional>
#include <memory>
#include <vector>
+
#include "Common/Thread.h"
namespace Common
@@ -695,7 +695,7 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
float clear_color[4] = { 0.f, 0.f, 0.f, 1.f };
D3D::current_command_list->ClearRenderTargetView(D3D::GetBackBuffer()->GetRTV(), clear_color, 0, nullptr);
// Copy the framebuffer to screen.
- const TargetSize dst_size = { m_target_width, m_target_height };
+ const TargetSize dst_size = { m_backbuffer_width, m_backbuffer_height };
DrawFrame(target_rc, rc, xfb_addr, xfb_source_list, xfb_count, D3D::GetBackBuffer(), dst_size, fb_width, fb_stride, fb_height, gamma);
// Dump frames
@@ -112,7 +112,7 @@ void VideoBackend::InitBackendInfo()
g_Config.backend_info.bSupportsDepthClamp = true;
g_Config.backend_info.bSupportsMultithreading = true;
g_Config.backend_info.bSupportsValidationLayer = true;
- g_Config.backend_info.bSupportsReversedDepthRange = false;
+ g_Config.backend_info.bSupportsReversedDepthRange = true;
g_Config.backend_info.bSupportsInternalResolutionFrameDumps = true;
g_Config.backend_info.bSupportsAsyncShaderCompilation = true;
IDXGIFactory* factory;
@@ -209,7 +209,7 @@ void Renderer::Create3DVisionTexture(u32 width, u32 height)
LPNVSTEREOIMAGEHEADER header = (LPNVSTEREOIMAGEHEADER)((u8*)sysData.pSysMem + height * sysData.SysMemPitch);
header->dwSignature = NVSTEREO_IMAGE_SIGNATURE;
header->dwWidth = width * 2;
- header->dwHeight = height + 1;
+ header->dwHeight = height;
header->dwBPP = 32;
header->dwFlags = 0;
m_3d_vision_texture = D3DTexture2D::Create(width * 2, height + 1, D3D11_BIND_RENDER_TARGET, D3D11_USAGE_DEFAULT, DXGI_FORMAT_R8G8B8A8_UNORM, 1, 1, &sysData);
@@ -704,7 +704,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co
D3D::context->ClearRenderTargetView(D3D::GetBackBuffer()->GetRTV(), ClearColor);
// Copy the framebuffer to screen.
- const TargetSize dst_size = { m_target_width, m_target_height };
+ const TargetSize dst_size = { m_backbuffer_width, m_backbuffer_height };
DrawFrame(targetRc, rc, xfbAddr, xfbSourceList, xfbCount, D3D::GetBackBuffer(), dst_size, fbWidth, fbStride, fbHeight, Gamma);
// Dump frames
@@ -1232,11 +1232,11 @@ void Renderer::BlitScreen(TargetRectangle dst_rect, TargetRectangle src_rect, Ta
leftRc.bottom = dst_rect.bottom;
TargetRectangle rightRc;
- rightRc.left = dst_rect.left + m_backbuffer_width;
- rightRc.right = dst_rect.right + m_backbuffer_width;
+ rightRc.left = dst_rect.left + dst_size.width;
+ rightRc.right = dst_rect.right + dst_size.width;
rightRc.top = dst_rect.top;
rightRc.bottom = dst_rect.bottom;
- TargetSize side_size = { dst_size.width * 2, dst_size .height};
+ TargetSize side_size = { dst_size.width * 2, dst_size.height + 1};
// Render to staging texture which is double the width of the backbuffer
m_post_processor->BlitScreen(leftRc, side_size, reinterpret_cast<uintptr_t>(m_3d_vision_texture),
src_rect, src_size, reinterpret_cast<uintptr_t>(src_texture), reinterpret_cast<uintptr_t>(depth_texture), 0, Gamma);
@@ -66,7 +66,7 @@ std::string VideoBackend::GetName() const
std::string VideoBackend::GetDisplayName() const
{
- return "Direct3D11";
+ return "Direct3D 11";
}
void VideoBackend::InitBackendInfo()
@@ -105,7 +105,7 @@ void VideoBackend::InitBackendInfo()
g_Config.backend_info.bSupportsDepthClamp = true;
g_Config.backend_info.bSupportsMultithreading = false;
g_Config.backend_info.bSupportsValidationLayer = false;
- g_Config.backend_info.bSupportsReversedDepthRange = false;
+ g_Config.backend_info.bSupportsReversedDepthRange = true;
g_Config.backend_info.bSupportsInternalResolutionFrameDumps = true;
g_Config.backend_info.bSupportsAsyncShaderCompilation = true;
IDXGIFactory* factory;
@@ -65,7 +65,7 @@ std::string VideoBackend::GetName() const
std::string VideoBackend::GetDisplayName() const
{
- return "Direct3D9";
+ return "Direct3D 9";
}
void VideoBackend::InitBackendInfo()
@@ -1431,7 +1431,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
std::swap(flipped_trc.top, flipped_trc.bottom);
// Copy the framebuffer to screen.
- const TargetSize dst_size = {m_target_width, m_target_height};
+ const TargetSize dst_size = {m_backbuffer_width, m_backbuffer_height};
DrawFrame(flipped_trc, rc, xfbAddr, xfbSourceList, xfbCount, 0, dst_size, fbWidth, fbStride, fbHeight, Gamma);
// The FlushFrameDump call here is necessary even after frame dumping is stopped.
@@ -128,29 +128,32 @@ void Write32BitSwizzler(char*& p, u32 format)
WRITE(p, " sampleUv = sampleUv / " I_COLORS"[0].zw;\n");
}
-void WriteSampleColor(char*& p, const char* colorComp, const char* dest, int xoffset, const EFBCopyFormat& format)
+void WriteSampleColor(char*& p, const char* colorComp, const char* dest, int xoffset, const EFBCopyFormat& format, bool depth = false)
{
WRITE(p, " %s = tex2D(samp0, sampleUv + float2(%d.0f * (" I_COLORS "[0].x / " I_COLORS "[0].z), 0.0f)).%s;\n",
dest, xoffset, colorComp);
-
- // Truncate 8-bits to 5/6-bits per channel.
- switch (format.efb_format)
+ if (!depth)
{
- case PEControl::RGBA6_Z24:
- WRITE(p, " %s = floor(%s * 63.0) / 63.0;\n", dest, dest);
- break;
-
- case PEControl::RGB565_Z16:
- WRITE(
- p,
- " %s = floor(%s * float4(31.0, 63.0, 31.0, 1.0).%s) / float4(31.0, 63.0, 31.0, 1.0).%s;\n",
- dest, dest, colorComp, colorComp);
- break;
+ // Truncate 8-bits to 5/6-bits per channel.
+ switch (format.efb_format)
+ {
+ case PEControl::RGBA6_Z24:
+ WRITE(p, " %s = floor(%s * 63.0) / 63.0;\n", dest, dest);
+ break;
+
+ case PEControl::RGB565_Z16:
+ WRITE(
+ p,
+ " %s = floor(%s * float4(31.0, 63.0, 31.0, 1.0).%s) / float4(31.0, 63.0, 31.0, 1.0).%s;\n",
+ dest, dest, colorComp, colorComp);
+ break;
+ }
+
+ // Alpha channel is set to 1 in the copy if the EFB does not have an alpha channel.
+ if (std::strchr(colorComp, 'a') && !EFBFormatHasAlpha(format.efb_format))
+ WRITE(p, " %s.a = 1.0;\n", dest);
}
-
- // Alpha channel is set to 1 in the copy if the EFB does not have an alpha channel.
- if (std::strchr(colorComp, 'a') && !EFBFormatHasAlpha(format.efb_format))
- WRITE(p, " %s.a = 1.0;\n", dest);
+
}
void WriteColorToIntensity(char*& p, const char* src, const char* dest)
@@ -485,19 +488,19 @@ void WriteZ8Encoder(char* p, const char* multiplier,const EFBCopyFormat& format)
WRITE(p, " float depth;\n");
- WriteSampleColor(p, "b", "depth", 0, format);
+ WriteSampleColor(p, "b", "depth", 0, format, true);
WRITE(p, " depth = 1.0f - depth;\n");
WRITE(p, "ocol0.b = frac(depth * %s);\n", multiplier);
- WriteSampleColor(p, "b", "depth", 1, format);
+ WriteSampleColor(p, "b", "depth", 1, format, true);
WRITE(p, " depth = 1.0f - depth;\n");
WRITE(p, "ocol0.g = frac(depth * %s);\n", multiplier);
- WriteSampleColor(p, "b", "depth", 2, format);
+ WriteSampleColor(p, "b", "depth", 2, format, true);
WRITE(p, " depth = 1.0f - depth;\n");
WRITE(p, "ocol0.r = frac(depth * %s);\n", multiplier);
- WriteSampleColor(p, "b", "depth", 3, format);
+ WriteSampleColor(p, "b", "depth", 3, format, true);
WRITE(p, " depth = 1.0f - depth;\n");
WRITE(p, "ocol0.a = frac(depth * %s);\n", multiplier);
@@ -513,7 +516,7 @@ void WriteZ16Encoder(char* p, const EFBCopyFormat& format)
// byte order is reversed
- WriteSampleColor(p, "b", "depth", 0, format);
+ WriteSampleColor(p, "b", "depth", 0, format, true);
WRITE(p, " depth = 1.0f - depth;\n");
WRITE(p, " depth *= 16777215.0f;\n");
WRITE(p, " expanded.r = floor(depth / (256.0f * 256.0f));\n");
@@ -523,7 +526,7 @@ void WriteZ16Encoder(char* p, const EFBCopyFormat& format)
WRITE(p, " ocol0.b = expanded.g / 255.0f;\n");
WRITE(p, " ocol0.g = expanded.r / 255.0f;\n");
- WriteSampleColor(p, "b", "depth", 1, format);
+ WriteSampleColor(p, "b", "depth", 1, format, true);
WRITE(p, " depth = 1.0f - depth;\n");
WRITE(p, " depth *= 16777215.0f;\n");
WRITE(p, " expanded.r = floor(depth / (256.0f * 256.0f));\n");
@@ -545,7 +548,7 @@ void WriteZ16LEncoder(char* p, const EFBCopyFormat& format)
// byte order is reversed
- WriteSampleColor(p, "b", "depth", 0, format);
+ WriteSampleColor(p, "b", "depth", 0, format, true);
WRITE(p, " depth = 1.0f - depth;\n");
WRITE(p, " depth *= 16777215.0f;\n");
WRITE(p, " expanded.r = floor(depth / (256.0f * 256.0f));\n");
@@ -557,7 +560,7 @@ void WriteZ16LEncoder(char* p, const EFBCopyFormat& format)
WRITE(p, " ocol0.b = expanded.b / 255.0f;\n");
WRITE(p, " ocol0.g = expanded.g / 255.0f;\n");
- WriteSampleColor(p, "b", "depth", 1, format);
+ WriteSampleColor(p, "b", "depth", 1, format, true);
WRITE(p, " depth = 1.0f - depth;\n");
WRITE(p, " depth *= 16777215.0f;\n");
WRITE(p, " expanded.r = floor(depth / (256.0f * 256.0f));\n");
@@ -583,9 +586,9 @@ void WriteZ24Encoder(char* p, const EFBCopyFormat& format)
WRITE(p, " float3 expanded0;\n");
WRITE(p, " float3 expanded1;\n");
- WriteSampleColor(p, "b", "depth0", 0, format);
+ WriteSampleColor(p, "b", "depth0", 0, format, true);
WRITE(p, " depth0 = 1.0f - depth0;\n");
- WriteSampleColor(p, "b", "depth1", 1, format);
+ WriteSampleColor(p, "b", "depth1", 1, format, true);
WRITE(p, " depth1 = 1.0f - depth1;\n");
for (int i = 0; i < 2; i++)
@@ -22,11 +22,6 @@
static char text[16384];
static bool IntensityConstantAdded = false;
-static bool EFBFormatHasAlpha(u32 format)
-{
- return format == PEControl::RGBA6_Z24;
-}
-
namespace TextureConversionShader
{
@@ -41,6 +36,25 @@ static void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType)
else
WRITE(p, "uniform int4 position;\n");
+ // Alpha channel in the copy is set to 1 the EFB format does not have an alpha channel.
+ WRITE(p, "float4 RGBA8ToRGB8(float4 src)\n");
+ WRITE(p, "{\n");
+ WRITE(p, " return float4(src.xyz, 1.0);\n");
+ WRITE(p, "}\n");
+
+ WRITE(p, "float4 RGBA8ToRGBA6(float4 src)\n");
+ WRITE(p, "{\n");
+ WRITE(p, " int4 val = int4(src * 255.0) >> 2;\n");
+ WRITE(p, " return float4(val) / 63.0;\n");
+ WRITE(p, "}\n");
+
+ WRITE(p, "float4 RGBA8ToRGB565(float4 src)\n");
+ WRITE(p, "{\n");
+ WRITE(p, " int4 val = int4(src * 255.0);\n");
+ WRITE(p, " val = int4(val.r >> 3, val.g >> 2, val.b >> 3, 1);\n");
+ WRITE(p, " return float4(val) / float4(31.0, 63.0, 31.0, 1.0);\n");
+ WRITE(p, "}\n");
+
int blkW = TexDecoder_GetBlockWidthInTexels(format);
int blkH = TexDecoder_GetBlockHeightInTexels(format);
int samples = GetEncodedSampleCount(format);
@@ -115,42 +129,43 @@ static void WriteSwizzler(char*& p, u32 format, API_TYPE ApiType)
static void WriteSampleColor(char*& p, const char* colorComp, const char* dest, int xoffset,
API_TYPE ApiType, const EFBCopyFormat& format, bool depth = false)
{
- if (ApiType == API_OPENGL || ApiType == API_VULKAN)
+ WRITE(p, " %s = ", dest);
+
+ if (!depth)
{
- WRITE(p, " %s = texture(samp0, float3(uv0 + float2(%d, 0) * sample_offset, 0.0)).%s;\n", dest,
- xoffset, colorComp);
+ switch (format.efb_format)
+ {
+ case PEControl::RGB8_Z24:
+ WRITE(p, "RGBA8ToRGB8(");
+ break;
+ case PEControl::RGBA6_Z24:
+ WRITE(p, "RGBA8ToRGBA6(");
+ break;
+ case PEControl::RGB565_Z16:
+ WRITE(p, "RGBA8ToRGB565(");
+ break;
+ default:
+ WRITE(p, "(");
+ break;
+ }
}
else
{
- WRITE(p, " %s = Tex0.Sample(samp0, float3(uv0 + float2(%d, 0) * sample_offset, 0.0)).%s;\n",
- dest, xoffset, colorComp);
+ // Handle D3D depth inversion.
+ if (ApiType == API_D3D11 || ApiType == API_VULKAN)
+ WRITE(p, "1.0 - (");
+ else
+ WRITE(p, "(");
}
- if (ApiType == API_D3D11 || ApiType == API_VULKAN)
+ if (ApiType == API_OPENGL || ApiType == API_VULKAN)
{
- // Handle D3D depth inversion.
- if (depth)
- WRITE(p, " %s = 1.0 - %s;\n", dest, dest);
+ WRITE(p, "texture(samp0, float3(uv0 + float2(%d, 0) * sample_offset, 0.0))).%s;\n", xoffset, colorComp);
}
-
- // Truncate 8-bits to 5/6-bits per channel.
- switch (format.efb_format)
+ else
{
- case PEControl::RGBA6_Z24:
- WRITE(p, " %s = floor(%s * 63.0) / 63.0;\n", dest, dest);
- break;
-
- case PEControl::RGB565_Z16:
- WRITE(
- p,
- " %s = floor(%s * float4(31.0, 63.0, 31.0, 1.0).%s) / float4(31.0, 63.0, 31.0, 1.0).%s;\n",
- dest, dest, colorComp, colorComp);
- break;
+ WRITE(p, "Tex0.Sample(samp0, float3(uv0 + float2(%d, 0) * sample_offset, 0.0))).%s;\n", xoffset, colorComp);
}
-
- // Alpha channel is set to 1 in the copy if the EFB does not have an alpha channel.
- if (std::strchr(colorComp, 'a') && !EFBFormatHasAlpha(format.efb_format))
- WRITE(p, " %s.a = 1.0;\n", dest);
}
static void WriteColorToIntensity(char*& p, const char* src, const char* dest)
@@ -30,7 +30,6 @@
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "Common/CommonFuncs.h"
-#include "Common/ThreadPool.h"
#include "Common/CPUDetect.h"
#include "Common/Intrinsics.h"
#include "VideoCommon/VideoConfig.h"
@@ -210,7 +210,7 @@ void VertexManagerBase::DoFlush()
VertexShaderManager::SetConstants();
// Track some stats used elsewhere by the anamorphic widescreen heuristic.
- if (!SConfig::GetInstance().bWii)
+ if (!SConfig::GetInstance().bWii && xfmem.projection.type == GX_PERSPECTIVE)
{
float* rawProjection = xfmem.projection.rawProjection;
bool viewport_is_4_3 = AspectIs4_3(xfmem.viewport.wd, xfmem.viewport.ht);

0 comments on commit ce994a2

Please sign in to comment.