mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-21 21:17:19 +00:00
[all] added new format version field to frame header
This commit is contained in:
parent
6650e58a4a
commit
b2961c7939
@ -375,6 +375,10 @@ static int frameThread(void * unused)
|
||||
LGMP_STATUS status;
|
||||
PLGMPClientQueue queue;
|
||||
|
||||
uint32_t formatVer = 0;
|
||||
bool formatValid = false;
|
||||
LG_RendererFormat lgrFormat;
|
||||
|
||||
SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH);
|
||||
lgWaitEvent(e_startup, TIMEOUT_INFINITE);
|
||||
if (state.state != APP_STATE_RUNNING)
|
||||
@ -421,8 +425,9 @@ static int frameThread(void * unused)
|
||||
|
||||
KVMFRFrame * frame = (KVMFRFrame *)msg.mem;
|
||||
|
||||
if (!formatValid || frame->formatVer != formatVer)
|
||||
{
|
||||
// setup the renderer format with the frame format details
|
||||
LG_RendererFormat lgrFormat;
|
||||
lgrFormat.type = frame->type;
|
||||
lgrFormat.width = frame->width;
|
||||
lgrFormat.height = frame->height;
|
||||
@ -464,13 +469,17 @@ static int frameThread(void * unused)
|
||||
break;
|
||||
}
|
||||
|
||||
if (frame->width != state.srcSize.x || frame->height != state.srcSize.y)
|
||||
formatValid = true;
|
||||
formatVer = frame->formatVer;
|
||||
}
|
||||
|
||||
if (lgrFormat.width != state.srcSize.x || lgrFormat.height != state.srcSize.y)
|
||||
{
|
||||
state.srcSize.x = frame->width;
|
||||
state.srcSize.y = frame->height;
|
||||
state.srcSize.x = lgrFormat.width;
|
||||
state.srcSize.y = lgrFormat.height;
|
||||
state.haveSrcSize = true;
|
||||
if (params.autoResize)
|
||||
SDL_SetWindowSize(state.window, frame->width, frame->height);
|
||||
SDL_SetWindowSize(state.window, lgrFormat.width, lgrFormat.height);
|
||||
|
||||
updatePositionInfo();
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ typedef enum CursorType
|
||||
CursorType;
|
||||
|
||||
#define KVMFR_MAGIC "KVMFR---"
|
||||
#define KVMFR_VERSION 4
|
||||
#define KVMFR_VERSION 5
|
||||
|
||||
typedef struct KVMFR
|
||||
{
|
||||
@ -75,6 +75,7 @@ KVMFRCursor;
|
||||
|
||||
typedef struct KVMFRFrame
|
||||
{
|
||||
uint32_t formatVer; // the frame format version number
|
||||
FrameType type; // the frame data type
|
||||
uint32_t width; // the width
|
||||
uint32_t height; // the height
|
||||
|
@ -52,6 +52,7 @@ CaptureFormat;
|
||||
|
||||
typedef struct CaptureFrame
|
||||
{
|
||||
unsigned int formatVer;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
unsigned int pitch;
|
||||
|
@ -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;
|
||||
@ -230,6 +232,7 @@ static bool dxgi_init()
|
||||
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);
|
||||
@ -806,6 +810,7 @@ static CaptureResult dxgi_capture()
|
||||
|
||||
// set the state, and signal
|
||||
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,6 +955,7 @@ static CaptureResult dxgi_waitFrame(CaptureFrame * frame)
|
||||
|
||||
tex->state = TEXTURE_STATE_MAPPED;
|
||||
|
||||
frame->formatVer = tex->formatVer;
|
||||
frame->width = this->width;
|
||||
frame->height = this->height;
|
||||
frame->pitch = this->pitch;
|
||||
|
@ -42,9 +42,12 @@ struct iface
|
||||
CapturePostPointerBuffer postPointerBufferFn;
|
||||
LGThread * pointerThread;
|
||||
|
||||
unsigned int maxWidth, maxHeight;
|
||||
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
|
||||
|
@ -188,6 +188,7 @@ static int frameThread(void * opaque)
|
||||
continue;
|
||||
}
|
||||
|
||||
fi->formatVer = frame.formatVer;
|
||||
fi->width = frame.width;
|
||||
fi->height = frame.height;
|
||||
fi->stride = frame.stride;
|
||||
|
19
obs/lg.c
19
obs/lg.c
@ -29,6 +29,7 @@ typedef struct
|
||||
obs_source_t * context;
|
||||
LGState state;
|
||||
char * shmFile;
|
||||
uint32_t formatVer;
|
||||
uint32_t width, height;
|
||||
FrameType type;
|
||||
int bpp;
|
||||
@ -452,20 +453,14 @@ static void lgVideoTick(void * data, float seconds)
|
||||
return;
|
||||
}
|
||||
|
||||
bool updateTexture = false;
|
||||
KVMFRFrame * frame = (KVMFRFrame *)msg.mem;
|
||||
if (this->width != frame->width ||
|
||||
this->height != frame->height ||
|
||||
this->type != frame->type)
|
||||
if (!this->texture || this->formatVer != frame->formatVer)
|
||||
{
|
||||
updateTexture = true;
|
||||
this->formatVer = frame->formatVer;
|
||||
this->width = frame->width;
|
||||
this->height = frame->height;
|
||||
this->type = frame->type;
|
||||
}
|
||||
|
||||
if (!this->texture || updateTexture)
|
||||
{
|
||||
obs_enter_graphics();
|
||||
if (this->texture)
|
||||
{
|
||||
@ -509,6 +504,8 @@ static void lgVideoTick(void * data, float seconds)
|
||||
obs_leave_graphics();
|
||||
}
|
||||
|
||||
if (this->texture)
|
||||
{
|
||||
FrameBuffer * fb = (FrameBuffer *)(((uint8_t*)frame) + frame->offset);
|
||||
framebuffer_read(
|
||||
fb,
|
||||
@ -527,6 +524,12 @@ static void lgVideoTick(void * data, float seconds)
|
||||
gs_texture_unmap(this->texture);
|
||||
gs_texture_map(this->texture, &this->texData, &this->linesize);
|
||||
obs_leave_graphics();
|
||||
}
|
||||
else
|
||||
{
|
||||
lgmpClientMessageDone(this->frameQueue);
|
||||
os_sem_post(this->frameSem);
|
||||
}
|
||||
}
|
||||
|
||||
static void lgVideoRender(void * data, gs_effect_t * effect)
|
||||
|
Loading…
Reference in New Issue
Block a user