mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-22 13:52:57 +00:00
[host] dxgi: fix HDR content downsampling
This commit is contained in:
parent
561c45bcb9
commit
09b6fee360
4 changed files with 49 additions and 15 deletions
|
@ -739,28 +739,29 @@ static bool dxgi_init(void)
|
|||
if (!initVertexShader())
|
||||
goto fail;
|
||||
|
||||
if (!ppInit(&DXGIPP_Downsample,
|
||||
this->backend != ©BackendD3D11 && !this->hdr))
|
||||
{
|
||||
DEBUG_ERROR("Failed to intiailize the downsample post processor");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
// if HDR add the SDRWhiteLevel post processor to correct the output
|
||||
bool shareable = this->backend != ©BackendD3D11;
|
||||
if (this->hdr)
|
||||
{
|
||||
if (!ppInit(&DXGIPP_SDRWhiteLevel, this->backend != ©BackendD3D11))
|
||||
//HDR content needs to be corrected and converted to HDR10
|
||||
if (!ppInit(&DXGIPP_SDRWhiteLevel, shareable))
|
||||
{
|
||||
DEBUG_ERROR("Failed to initialize the SDRWhiteLevel post processor");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
//Downsampling must happen before conversion to RGB24
|
||||
if (!ppInit(&DXGIPP_Downsample, shareable))
|
||||
{
|
||||
// only support DX11 for this atm
|
||||
if (this->backend == ©BackendD3D11)
|
||||
if (!ppInit(&DXGIPP_RGB24, false))
|
||||
DEBUG_WARN("Failed to initialize the RGB24 post processor");
|
||||
DEBUG_ERROR("Failed to intiailize the downsample post processor");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
//If not HDR, pack to RGB24
|
||||
if (!this->hdr)
|
||||
{
|
||||
if (!ppInit(&DXGIPP_RGB24, shareable))
|
||||
DEBUG_WARN("Failed to initialize the RGB24 post processor");
|
||||
}
|
||||
|
||||
for (int i = 0; i < LGMP_Q_FRAME_LEN; ++i)
|
||||
|
|
|
@ -171,7 +171,7 @@ static bool downsample_configure(void * opaque,
|
|||
.SampleDesc.Count = 1,
|
||||
.SampleDesc.Quality = 0,
|
||||
.Usage = D3D11_USAGE_DEFAULT,
|
||||
.Format = DXGI_FORMAT_B8G8R8A8_UNORM,
|
||||
.Format = getDXGIFormat(*format),
|
||||
.BindFlags = D3D11_BIND_RENDER_TARGET |
|
||||
D3D11_BIND_SHADER_RESOURCE,
|
||||
.CPUAccessFlags = 0,
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include "util.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
#include <d3d11.h>
|
||||
|
@ -320,3 +321,30 @@ float getSDRWhiteLevel(const DISPLAYCONFIG_PATH_INFO * displayPathInfo)
|
|||
|
||||
return nits;
|
||||
}
|
||||
|
||||
DXGI_FORMAT getDXGIFormat(CaptureFormat format)
|
||||
{
|
||||
switch(format)
|
||||
{
|
||||
case CAPTURE_FMT_RGBA:
|
||||
return DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
|
||||
case CAPTURE_FMT_BGRA:
|
||||
return DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
|
||||
case CAPTURE_FMT_RGBA10:
|
||||
return DXGI_FORMAT_R10G10B10A2_UNORM;
|
||||
|
||||
case CAPTURE_FMT_RGBA16F:
|
||||
return DXGI_FORMAT_R16G16B16A16_FLOAT;
|
||||
|
||||
case CAPTURE_FMT_BGR:
|
||||
return DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
DEBUG_ASSERT("Invalid capture format for DXGI");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -19,8 +19,11 @@
|
|||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include <d3dcommon.h>
|
||||
#include <dxgi.h>
|
||||
|
||||
#include "interface/capture.h"
|
||||
|
||||
const char * getDXGIFormatStr(DXGI_FORMAT format);
|
||||
const char * getDXGIColorSpaceTypeStr(DXGI_COLOR_SPACE_TYPE type);
|
||||
|
||||
|
@ -30,3 +33,5 @@ bool compileShader(ID3DBlob ** dst, const char * entry, const char * target,
|
|||
bool getDisplayPathInfo(HMONITOR monitor, DISPLAYCONFIG_PATH_INFO * info);
|
||||
|
||||
float getSDRWhiteLevel(const DISPLAYCONFIG_PATH_INFO * displayPathInfo);
|
||||
|
||||
DXGI_FORMAT getDXGIFormat(CaptureFormat format);
|
||||
|
|
Loading…
Reference in a new issue