From 3a64f9b96ceaa16a9f32e4d2ca1cc0ad75a66e27 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Fri, 17 Nov 2017 15:24:01 +1100 Subject: [PATCH] [host] Use ARGB instead of RGB for performance This is counter intuative as it consumes more RAM, but performance is improved on the client as video hardware doesn't work in RGB but BGRA. --- host/Capture/DXGI.cpp | 10 +++++----- host/Capture/NvFBC.cpp | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/host/Capture/DXGI.cpp b/host/Capture/DXGI.cpp index e9b558b1..23cbbb9b 100644 --- a/host/Capture/DXGI.cpp +++ b/host/Capture/DXGI.cpp @@ -20,7 +20,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA using namespace Capture; #include "common\debug.h" -#include "Util.h" +#include "common\memcpySSE.h" DXGI::DXGI() : m_options(NULL), @@ -219,7 +219,7 @@ FrameType DXGI::GetFrameType() if (!m_initialized) return FRAME_TYPE_INVALID; - return FRAME_TYPE_RGB; + return FRAME_TYPE_ARGB; } FrameComp DXGI::GetFrameCompression() @@ -235,7 +235,7 @@ size_t DXGI::GetMaxFrameSize() if (!m_initialized) return 0; - return (m_width * m_height * 3) + 4; + return (m_width * m_height * 4); } bool DXGI::GrabFrame(FrameInfo & frame) @@ -347,7 +347,7 @@ bool DXGI::GrabFrame(FrameInfo & frame) m_width = desc.Width; m_height = desc.Height; - const int pitch = m_width * 3; + const int pitch = m_width * 4; frame.width = desc.Width; frame.height = desc.Height; @@ -418,7 +418,7 @@ bool DXGI::GrabFrame(FrameInfo & frame) } } - Util::BGRAtoRGB(rect.pBits, m_height * m_width, (uint8_t *)frame.buffer); + memcpySSE(frame.buffer, rect.pBits, frame.outSize); status = surface->Unmap(); if (FAILED(status)) diff --git a/host/Capture/NvFBC.cpp b/host/Capture/NvFBC.cpp index b337f636..66f797e2 100644 --- a/host/Capture/NvFBC.cpp +++ b/host/Capture/NvFBC.cpp @@ -135,7 +135,7 @@ bool NvFBC::Initialize(CaptureOptions * options) NVFBC_TOSYS_SETUP_PARAMS setupParams; ZeroMemory(&setupParams, sizeof(NVFBC_TOSYS_SETUP_PARAMS)); setupParams.dwVersion = NVFBC_TOSYS_SETUP_PARAMS_VER; - setupParams.eMode = NVFBC_TOSYS_RGB; + setupParams.eMode = NVFBC_TOSYS_ARGB; setupParams.bWithHWCursor = TRUE; setupParams.bDiffMap = FALSE; setupParams.ppBuffer = (void **)&m_frameBuffer; @@ -198,7 +198,7 @@ FrameType NvFBC::GetFrameType() if (!m_initialized) return FRAME_TYPE_INVALID; - return FRAME_TYPE_RGB; + return FRAME_TYPE_ARGB; } FrameComp NvFBC::GetFrameCompression() @@ -214,7 +214,7 @@ size_t NvFBC::GetMaxFrameSize() if (!m_initialized) return false; - return m_maxCaptureWidth * m_maxCaptureHeight * 3; + return m_maxCaptureWidth * m_maxCaptureHeight * 4; } bool NvFBC::GrabFrame(struct FrameInfo & frame) @@ -246,21 +246,21 @@ bool NvFBC::GrabFrame(struct FrameInfo & frame) { const unsigned int realHeight = min(m_grabInfo.dwHeight, (unsigned int)(desktop.bottom - desktop.top)); const unsigned int realWidth = min(m_grabInfo.dwWidth , (unsigned int)(desktop.right - desktop.left)); - dataWidth = realWidth * 3; + dataWidth = realWidth * 4; dataOffset = (((m_grabInfo.dwHeight - realHeight) >> 1) * m_grabInfo.dwBufferWidth + - ((m_grabInfo.dwWidth - realWidth ) >> 1)) * 3; + ((m_grabInfo.dwWidth - realWidth ) >> 1)) * 4; frame.width = realWidth; frame.height = realHeight; } frame.stride = frame.width; - frame.outSize = frame.width * frame.height * 3; + frame.outSize = frame.width * frame.height * 4; uint8_t *src = (uint8_t *)m_frameBuffer + dataOffset; uint8_t *dst = (uint8_t *)frame.buffer; - for(unsigned int y = 0; y < frame.height; ++y, dst += dataWidth, src += m_grabInfo.dwBufferWidth * 3) + for(unsigned int y = 0; y < frame.height; ++y, dst += dataWidth, src += m_grabInfo.dwBufferWidth * 4) memcpySSE(dst, src, dataWidth); return true;