[all] added new format version field to frame header

This commit is contained in:
Geoffrey McRae
2020-10-12 18:52:37 +11:00
parent 6650e58a4a
commit b2961c7939
7 changed files with 126 additions and 89 deletions

View File

@@ -57,6 +57,7 @@ enum TextureState
typedef struct Texture
{
unsigned int formatVer;
volatile enum TextureState state;
ID3D11Texture2D * tex;
D3D11_MAPPED_SUBRESOURCE map;
@@ -91,6 +92,7 @@ struct iface
CapturePostPointerBuffer postPointerBufferFn;
LGEvent * frameEvent;
unsigned int formatVer;
unsigned int width;
unsigned int height;
unsigned int pitch;
@@ -227,9 +229,10 @@ static bool dxgi_init()
HRESULT status;
DXGI_OUTPUT_DESC outputDesc;
this->stop = false;
this->texRIndex = 0;
this->texWIndex = 0;
this->stop = false;
this->texRIndex = 0;
this->texWIndex = 0;
this->formatVer = 0;
atomic_store(&this->texReady, 0);
lgResetEvent(this->frameEvent);
@@ -386,6 +389,7 @@ static bool dxgi_init()
IDXGIAdapter1_GetDesc1(this->adapter, &adapterDesc);
this->width = outputDesc.DesktopCoordinates.right - outputDesc.DesktopCoordinates.left;
this->height = outputDesc.DesktopCoordinates.bottom - outputDesc.DesktopCoordinates.top;
++this->formatVer;
DEBUG_INFO("Device Descripion: %ls" , adapterDesc.Description);
DEBUG_INFO("Device Vendor ID : 0x%x" , adapterDesc.VendorId);
@@ -805,7 +809,8 @@ static CaptureResult dxgi_capture()
ID3D11Texture2D_Release(src);
// set the state, and signal
tex->state = TEXTURE_STATE_PENDING_MAP;
tex->state = TEXTURE_STATE_PENDING_MAP;
tex->formatVer = this->formatVer;
if (atomic_fetch_add_explicit(&this->texReady, 1, memory_order_relaxed) == 0)
lgSignalEvent(this->frameEvent);
@@ -950,11 +955,12 @@ static CaptureResult dxgi_waitFrame(CaptureFrame * frame)
tex->state = TEXTURE_STATE_MAPPED;
frame->width = this->width;
frame->height = this->height;
frame->pitch = this->pitch;
frame->stride = this->stride;
frame->format = this->format;
frame->formatVer = tex->formatVer;
frame->width = this->width;
frame->height = this->height;
frame->pitch = this->pitch;
frame->stride = this->stride;
frame->format = this->format;
atomic_fetch_sub_explicit(&this->texReady, 1, memory_order_release);
return CAPTURE_RESULT_OK;

View File

@@ -42,8 +42,11 @@ struct iface
CapturePostPointerBuffer postPointerBufferFn;
LGThread * pointerThread;
unsigned int maxWidth, maxHeight;
unsigned int width , height;
unsigned int maxWidth , maxHeight;
unsigned int width , height;
unsigned int formatVer;
unsigned int grabWidth, grabHeight, grabStride;
uint8_t * frameBuffer;
uint8_t * diffMap;
@@ -195,6 +198,7 @@ static bool nvfbc_init()
return false;
}
++this->formatVer;
return true;
}
@@ -284,10 +288,22 @@ static CaptureResult nvfbc_waitFrame(CaptureFrame * frame)
if (this->stop)
return CAPTURE_RESULT_REINIT;
frame->width = this->grabInfo.dwWidth;
frame->height = this->grabInfo.dwHeight;
frame->pitch = this->grabInfo.dwBufferWidth * 4;
frame->stride = this->grabInfo.dwBufferWidth;
if (
this->grabInfo.dwWidth != this->grabWidth ||
this->grabInfo.dwHeight != this->grabHeight ||
this->grabInfo.dwBufferWidth != this->grabStride)
{
this->grabWidth = this->grabInfo.dwWidth;
this->grabHeight = this->grabInfo.dwHeight;
this->grabStride = this->grabInfo.dwBufferWidth;
++this->formatVer;
}
frame->formatVer = this->formatVer;
frame->width = this->grabWidth;
frame->height = this->grabHeight;
frame->pitch = this->grabStride * 4;
frame->stride = this->grabStride;
#if 0
//NvFBC never sets bIsHDR so instead we check for any data in the alpha channel