diff --git a/host/platform/Windows/capture/D12/backend.h b/host/platform/Windows/capture/D12/backend.h index dbbd7025..c951977b 100644 --- a/host/platform/Windows/capture/D12/backend.h +++ b/host/platform/Windows/capture/D12/backend.h @@ -66,9 +66,10 @@ struct D12Backend struct D12FetchDesc { - CaptureRotation rotation; - RECT * dirtyRects; - unsigned nbDirtyRects; + CaptureRotation rotation; + RECT * dirtyRects; + unsigned nbDirtyRects; + DXGI_COLOR_SPACE_TYPE colorSpace; }; static inline bool d12_backendCreate(const D12Backend * backend, diff --git a/host/platform/Windows/capture/D12/backend/dd.c b/host/platform/Windows/capture/D12/backend/dd.c index 2041b8f5..d6b5eb40 100644 --- a/host/platform/Windows/capture/D12/backend/dd.c +++ b/host/platform/Windows/capture/D12/backend/dd.c @@ -67,6 +67,7 @@ typedef struct DDInstance ID3D11DeviceContext4 ** context; IDXGIOutputDuplication ** dup; CaptureRotation rotation; + DXGI_COLOR_SPACE_TYPE colorSpace; bool release; DDCacheInfo cache[CACHE_SIZE]; @@ -284,6 +285,17 @@ static bool d12_dd_init( break; } + comRef_defineLocal(IDXGIOutput6, output6); + hr = IDXGIOutput_QueryInterface(output, &IID_IDXGIOutput6, (void **)output6); + if (FAILED(hr)) + this->colorSpace = DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709; + else + { + DXGI_OUTPUT_DESC1 desc1; + IDXGIOutput6_GetDesc1(*output6, &desc1); + this->colorSpace = desc1.ColorSpace; + } + ID3D12Device3_AddRef(device); comRef_toGlobal(this->d12device, &device ); comRef_toGlobal(this->device , d11device5 ); @@ -451,6 +463,7 @@ static ID3D12Resource * d12_dd_fetch(D12Backend * instance, desc->dirtyRects = this->current->dirtyRects; desc->nbDirtyRects = this->current->nbDirtyRects; desc->rotation = this->rotation; + desc->colorSpace = this->colorSpace; ID3D12Resource_AddRef(*this->current->d12Res); return *this->current->d12Res; diff --git a/host/platform/Windows/capture/D12/d12.c b/host/platform/Windows/capture/D12/d12.c index 348f53dd..560c4bdd 100644 --- a/host/platform/Windows/capture/D12/d12.c +++ b/host/platform/Windows/capture/D12/d12.c @@ -499,7 +499,8 @@ static CaptureResult d12_waitFrame(unsigned frameBufferIndex, frame->stride = layout.Footprint.RowPitch / 4; frame->format = this->allowRGB24 ? CAPTURE_FMT_BGR_32 : CAPTURE_FMT_BGRA; - frame->hdr = false; + frame->hdr = desc.colorSpace == + DXGI_COLOR_SPACE_RGB_FULL_G2084_NONE_P2020; frame->hdrPQ = false; frame->rotation = desc.rotation; @@ -565,8 +566,10 @@ static CaptureResult d12_getFrame(unsigned frameBufferIndex, if (result != CAPTURE_RESULT_OK) goto exit; + const bool isSDR = desc.colorSpace == DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709; + ID3D12Resource * next = *src; - if (this->allowRGB24) + if (this->allowRGB24 && isSDR) { next = d12_effectRun( this->effectRGB24, *this->device, *this->computeCommand.gfxList, next, @@ -671,7 +674,7 @@ static CaptureResult d12_getFrame(unsigned frameBufferIndex, } // execute the compute commands - if (this->allowRGB24) + if (this->allowRGB24 && isSDR) { d12_commandGroupExecute(*this->computeQueue, &this->computeCommand); @@ -691,7 +694,7 @@ static CaptureResult d12_getFrame(unsigned frameBufferIndex, this->dstFormat.Height * this->pitch); // reset the command queues - if (this->allowRGB24) + if (this->allowRGB24 && isSDR) if (!d12_commandGroupReset(&this->computeCommand)) goto exit;