mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-14 01:58:25 +00:00
[all] add initial support for RGB24-bpp support
This commit is contained in:
parent
dcde981a17
commit
86e8e99107
@ -340,8 +340,12 @@ bool egl_desktopSetup(EGL_Desktop * desktop, const LG_RendererFormat format)
|
|||||||
pixFmt = EGL_PF_RGBA16F;
|
pixFmt = EGL_PF_RGBA16F;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FRAME_TYPE_BGR:
|
case FRAME_TYPE_BGR_32:
|
||||||
pixFmt = EGL_PF_BGR;
|
pixFmt = EGL_PF_BGR_32;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FRAME_TYPE_RGB_24:
|
||||||
|
pixFmt = EGL_PF_BGR_24;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -38,7 +38,8 @@ typedef enum EGL_PixelFormat
|
|||||||
EGL_PF_BGRA,
|
EGL_PF_BGRA,
|
||||||
EGL_PF_RGBA10,
|
EGL_PF_RGBA10,
|
||||||
EGL_PF_RGBA16F,
|
EGL_PF_RGBA16F,
|
||||||
EGL_PF_BGR
|
EGL_PF_BGR_32,
|
||||||
|
EGL_PF_RGB_24
|
||||||
}
|
}
|
||||||
EGL_PixelFormat;
|
EGL_PixelFormat;
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ static bool egl_filterBGRtoBGRASetup(EGL_Filter * filter,
|
|||||||
{
|
{
|
||||||
EGL_FilterBGRtoBGRA * this = UPCAST(EGL_FilterBGRtoBGRA, filter);
|
EGL_FilterBGRtoBGRA * this = UPCAST(EGL_FilterBGRtoBGRA, filter);
|
||||||
|
|
||||||
if (pixFmt != EGL_PF_BGR)
|
if (pixFmt != EGL_PF_BGR_32 || pixFmt != EGL_PF_RGB_24)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (this->useDMA != useDMA)
|
if (this->useDMA != useDMA)
|
||||||
|
@ -109,7 +109,7 @@ static bool egl_texFBUpdate(EGL_Texture * texture, const EGL_TexUpdate * update)
|
|||||||
update->rectCount * sizeof(FrameDamageRect));
|
update->rectCount * sizeof(FrameDamageRect));
|
||||||
damage->count += update->rectCount;
|
damage->count += update->rectCount;
|
||||||
|
|
||||||
if (texture->format.pixFmt == EGL_PF_BGR)
|
if (texture->format.pixFmt == EGL_PF_BGR_32)
|
||||||
{
|
{
|
||||||
FrameDamageRect scaledDamageRects[damage->count];
|
FrameDamageRect scaledDamageRects[damage->count];
|
||||||
for (int i = 0; i < damage->count; i++)
|
for (int i = 0; i < damage->count; i++)
|
||||||
|
@ -34,7 +34,8 @@ bool egl_texUtilGetFormat(const EGL_TexSetup * setup, EGL_TexFormat * fmt)
|
|||||||
{
|
{
|
||||||
//EGL has no support for 24-bit formats, so we stuff it into a 32-bit
|
//EGL has no support for 24-bit formats, so we stuff it into a 32-bit
|
||||||
//texture to unpack with a shader later
|
//texture to unpack with a shader later
|
||||||
case EGL_PF_BGR:
|
case EGL_PF_BGR_32:
|
||||||
|
case EGL_PF_RGB_24:
|
||||||
// fallthrough
|
// fallthrough
|
||||||
|
|
||||||
case EGL_PF_BGRA:
|
case EGL_PF_BGRA:
|
||||||
|
@ -787,7 +787,13 @@ static enum ConfigStatus configure(struct Inst * this)
|
|||||||
this->dataFormat = GL_HALF_FLOAT;
|
this->dataFormat = GL_HALF_FLOAT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FRAME_TYPE_BGR:
|
case FRAME_TYPE_RGB_24:
|
||||||
|
this->intFormat = GL_RGB8;
|
||||||
|
this->vboFormat = GL_RGB;
|
||||||
|
this->dataFormat = GL_UNSIGNED_BYTE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FRAME_TYPE_BGR_32:
|
||||||
this->intFormat = GL_RGB8;
|
this->intFormat = GL_RGB8;
|
||||||
this->vboFormat = GL_BGR;
|
this->vboFormat = GL_BGR;
|
||||||
this->dataFormat = GL_UNSIGNED_BYTE;
|
this->dataFormat = GL_UNSIGNED_BYTE;
|
||||||
|
@ -681,7 +681,8 @@ int main_frameThread(void * unused)
|
|||||||
lgrFormat.bpp = 64;
|
lgrFormat.bpp = 64;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FRAME_TYPE_BGR:
|
case FRAME_TYPE_BGR_32:
|
||||||
|
case FRAME_TYPE_RGB_24:
|
||||||
lgrFormat.bpp = 24;
|
lgrFormat.bpp = 24;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -55,7 +55,8 @@ typedef enum FrameType
|
|||||||
FRAME_TYPE_RGBA , // RGBA interleaved: R,G,B,A 32bpp
|
FRAME_TYPE_RGBA , // RGBA interleaved: R,G,B,A 32bpp
|
||||||
FRAME_TYPE_RGBA10 , // RGBA interleaved: R,G,B,A 10,10,10,2 bpp
|
FRAME_TYPE_RGBA10 , // RGBA interleaved: R,G,B,A 10,10,10,2 bpp
|
||||||
FRAME_TYPE_RGBA16F , // RGBA interleaved: R,G,B,A 16,16,16,16 bpp float
|
FRAME_TYPE_RGBA16F , // RGBA interleaved: R,G,B,A 16,16,16,16 bpp float
|
||||||
FRAME_TYPE_BGR , // BGR (DO NOT COMMIT THIS)
|
FRAME_TYPE_BGR_32 , // BGR 24-bpp in 32bpp
|
||||||
|
FRAME_TYPE_RGB_24 , // RGB 24-bpp
|
||||||
FRAME_TYPE_MAX , // sentinel value
|
FRAME_TYPE_MAX , // sentinel value
|
||||||
}
|
}
|
||||||
FrameType;
|
FrameType;
|
||||||
|
@ -48,7 +48,8 @@ typedef enum CaptureFormat
|
|||||||
CAPTURE_FMT_RGBA ,
|
CAPTURE_FMT_RGBA ,
|
||||||
CAPTURE_FMT_RGBA10 ,
|
CAPTURE_FMT_RGBA10 ,
|
||||||
CAPTURE_FMT_RGBA16F,
|
CAPTURE_FMT_RGBA16F,
|
||||||
CAPTURE_FMT_BGR ,
|
CAPTURE_FMT_BGR_32 ,
|
||||||
|
CAPTURE_FMT_RGB_24 ,
|
||||||
|
|
||||||
// pointer formats
|
// pointer formats
|
||||||
CAPTURE_FMT_COLOR ,
|
CAPTURE_FMT_COLOR ,
|
||||||
|
@ -1170,15 +1170,12 @@ static CaptureResult dxgi_capture(void)
|
|||||||
this->dxgiFormat = DXGI_FORMAT_R16G16B16A16_FLOAT;
|
this->dxgiFormat = DXGI_FORMAT_R16G16B16A16_FLOAT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAPTURE_FMT_BGR:
|
case CAPTURE_FMT_BGR_32:
|
||||||
this->bpp = 4;
|
this->bpp = 4;
|
||||||
this->dxgiFormat = DXGI_FORMAT_B8G8R8A8_UNORM;
|
this->dxgiFormat = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAPTURE_FMT_COLOR :
|
default:
|
||||||
case CAPTURE_FMT_MONO :
|
|
||||||
case CAPTURE_FMT_MASKED:
|
|
||||||
case CAPTURE_FMT_MAX :
|
|
||||||
DEBUG_ERROR("Unsupported input format");
|
DEBUG_ERROR("Unsupported input format");
|
||||||
result = CAPTURE_RESULT_ERROR;
|
result = CAPTURE_RESULT_ERROR;
|
||||||
goto exit;
|
goto exit;
|
||||||
@ -1247,7 +1244,7 @@ static CaptureResult dxgi_capture(void)
|
|||||||
FrameDamageRect rect = tex->texDamageRects[i];
|
FrameDamageRect rect = tex->texDamageRects[i];
|
||||||
|
|
||||||
// correct the damage rect for BGR packed data
|
// correct the damage rect for BGR packed data
|
||||||
if (this->outputFormat == CAPTURE_FMT_BGR)
|
if (this->outputFormat == CAPTURE_FMT_BGR_32)
|
||||||
{
|
{
|
||||||
rect.x = (rect.x * 3 ) / 4; // round down
|
rect.x = (rect.x * 3 ) / 4; // round down
|
||||||
rect.width = (rect.width * 3 + 3) / 4; // round up
|
rect.width = (rect.width * 3 + 3) / 4; // round up
|
||||||
@ -1445,7 +1442,7 @@ static CaptureResult dxgi_getFrame(FrameBuffer * frame, int frameIndex)
|
|||||||
tex->damageRectsCount * sizeof(*tex->damageRects));
|
tex->damageRectsCount * sizeof(*tex->damageRects));
|
||||||
damage->count += tex->damageRectsCount;
|
damage->count += tex->damageRectsCount;
|
||||||
|
|
||||||
if (this->outputFormat == CAPTURE_FMT_BGR)
|
if (this->outputFormat == CAPTURE_FMT_BGR_32)
|
||||||
{
|
{
|
||||||
FrameDamageRect scaledDamageRects[damage->count];
|
FrameDamageRect scaledDamageRects[damage->count];
|
||||||
for (int i = 0; i < ARRAYSIZE(scaledDamageRects); i++) {
|
for (int i = 0; i < ARRAYSIZE(scaledDamageRects); i++) {
|
||||||
|
@ -88,7 +88,7 @@ static bool downsample_configure(void * opaque,
|
|||||||
bool result = false;
|
bool result = false;
|
||||||
DownsampleInst * inst = (DownsampleInst *)opaque;
|
DownsampleInst * inst = (DownsampleInst *)opaque;
|
||||||
|
|
||||||
if (*format == CAPTURE_FMT_BGR)
|
if (*format == CAPTURE_FMT_BGR_32)
|
||||||
this.disabled = true;
|
this.disabled = true;
|
||||||
|
|
||||||
if (this.disabled)
|
if (this.disabled)
|
||||||
|
@ -192,7 +192,7 @@ static bool rgb24_configure(void * opaque,
|
|||||||
|
|
||||||
*cols = this.width;
|
*cols = this.width;
|
||||||
*rows = this.height;
|
*rows = this.height;
|
||||||
*format = CAPTURE_FMT_BGR;
|
*format = CAPTURE_FMT_BGR_32;
|
||||||
|
|
||||||
comRef_toGlobal(inst->tex , tex );
|
comRef_toGlobal(inst->tex , tex );
|
||||||
comRef_toGlobal(inst->target, target );
|
comRef_toGlobal(inst->target, target );
|
||||||
|
@ -338,7 +338,7 @@ DXGI_FORMAT getDXGIFormat(CaptureFormat format)
|
|||||||
case CAPTURE_FMT_RGBA16F:
|
case CAPTURE_FMT_RGBA16F:
|
||||||
return DXGI_FORMAT_R16G16B16A16_FLOAT;
|
return DXGI_FORMAT_R16G16B16A16_FLOAT;
|
||||||
|
|
||||||
case CAPTURE_FMT_BGR:
|
case CAPTURE_FMT_BGR_32:
|
||||||
return DXGI_FORMAT_B8G8R8A8_UNORM;
|
return DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -60,6 +60,7 @@ struct iface
|
|||||||
|
|
||||||
bool seperateCursor;
|
bool seperateCursor;
|
||||||
bool dwmFlush;
|
bool dwmFlush;
|
||||||
|
bool noHDR;
|
||||||
CaptureGetPointerBuffer getPointerBufferFn;
|
CaptureGetPointerBuffer getPointerBufferFn;
|
||||||
CapturePostPointerBuffer postPointerBufferFn;
|
CapturePostPointerBuffer postPointerBufferFn;
|
||||||
LGThread * pointerThread;
|
LGThread * pointerThread;
|
||||||
@ -70,10 +71,12 @@ struct iface
|
|||||||
bool resChanged, scale;
|
bool resChanged, scale;
|
||||||
unsigned int targetWidth, targetHeight;
|
unsigned int targetWidth, targetHeight;
|
||||||
|
|
||||||
unsigned int formatVer;
|
unsigned int formatVer;
|
||||||
unsigned int grabWidth, grabHeight, grabStride;
|
unsigned int grabWidth, grabHeight, grabStride;
|
||||||
unsigned int shmStride;
|
unsigned int bpp;
|
||||||
bool isHDR;
|
CaptureFormat format;
|
||||||
|
unsigned int shmStride;
|
||||||
|
bool isHDR;
|
||||||
|
|
||||||
uint8_t * frameBuffer;
|
uint8_t * frameBuffer;
|
||||||
uint8_t * diffMap;
|
uint8_t * diffMap;
|
||||||
@ -166,6 +169,13 @@ static void nvfbc_initOptions(void)
|
|||||||
.type = OPTION_TYPE_BOOL,
|
.type = OPTION_TYPE_BOOL,
|
||||||
.value.x_bool = false
|
.value.x_bool = false
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.module = "nvfbc",
|
||||||
|
.name = "noHDR",
|
||||||
|
.description = "Capture HDR content as SDR",
|
||||||
|
.type = OPTION_TYPE_BOOL,
|
||||||
|
.value.x_bool = true
|
||||||
|
},
|
||||||
{0}
|
{0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -183,6 +193,7 @@ static bool nvfbc_create(
|
|||||||
|
|
||||||
this->seperateCursor = option_get_bool("nvfbc", "decoupleCursor");
|
this->seperateCursor = option_get_bool("nvfbc", "decoupleCursor");
|
||||||
this->dwmFlush = option_get_bool("nvfbc", "dwmFlush" );
|
this->dwmFlush = option_get_bool("nvfbc", "dwmFlush" );
|
||||||
|
this->noHDR = option_get_bool("nvfbc", "noHDR" );
|
||||||
this->getPointerBufferFn = getPointerBufferFn;
|
this->getPointerBufferFn = getPointerBufferFn;
|
||||||
this->postPointerBufferFn = postPointerBufferFn;
|
this->postPointerBufferFn = postPointerBufferFn;
|
||||||
|
|
||||||
@ -303,10 +314,13 @@ static bool nvfbc_init(void)
|
|||||||
getDesktopSize(&this->width, &this->height);
|
getDesktopSize(&this->width, &this->height);
|
||||||
updateScale();
|
updateScale();
|
||||||
|
|
||||||
|
this->bpp = this->noHDR ? 3 : 4;
|
||||||
|
this->format = this->noHDR ? CAPTURE_FMT_RGB_24 : CAPTURE_FMT_RGBA10;
|
||||||
|
|
||||||
HANDLE event;
|
HANDLE event;
|
||||||
if (!NvFBCToSysSetup(
|
if (!NvFBCToSysSetup(
|
||||||
this->nvfbc,
|
this->nvfbc,
|
||||||
BUFFER_FMT_ARGB10,
|
this->noHDR ? BUFFER_FMT_RGB : BUFFER_FMT_ARGB10,
|
||||||
!this->seperateCursor,
|
!this->seperateCursor,
|
||||||
this->seperateCursor,
|
this->seperateCursor,
|
||||||
true,
|
true,
|
||||||
@ -655,7 +669,7 @@ static CaptureResult nvfbc_waitFrame(CaptureFrame * frame,
|
|||||||
++this->formatVer;
|
++this->formatVer;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned int maxHeight = maxFrameSize / (this->shmStride * 4);
|
const unsigned int maxHeight = maxFrameSize / (this->shmStride * this->bpp);
|
||||||
this->dataHeight = min(maxHeight, this->grabHeight);
|
this->dataHeight = min(maxHeight, this->grabHeight);
|
||||||
|
|
||||||
frame->formatVer = this->formatVer;
|
frame->formatVer = this->formatVer;
|
||||||
@ -666,15 +680,15 @@ static CaptureResult nvfbc_waitFrame(CaptureFrame * frame,
|
|||||||
frame->dataWidth = this->grabWidth;
|
frame->dataWidth = this->grabWidth;
|
||||||
frame->dataHeight = this->dataHeight;
|
frame->dataHeight = this->dataHeight;
|
||||||
frame->truncated = maxHeight < this->grabHeight;
|
frame->truncated = maxHeight < this->grabHeight;
|
||||||
frame->pitch = this->shmStride * 4;
|
frame->pitch = this->shmStride * this->bpp;
|
||||||
frame->stride = this->shmStride;
|
frame->stride = this->shmStride;
|
||||||
frame->rotation = CAPTURE_ROT_0;
|
frame->rotation = CAPTURE_ROT_0;
|
||||||
|
|
||||||
updateDamageRects(frame);
|
updateDamageRects(frame);
|
||||||
|
|
||||||
frame->format = CAPTURE_FMT_RGBA10;
|
frame->format = this->format;
|
||||||
frame->hdr = this->grabInfo.bIsHDR;
|
frame->hdr = this->grabInfo.bIsHDR;
|
||||||
frame->hdrPQ = true;
|
frame->hdrPQ = this->grabInfo.bIsHDR;
|
||||||
|
|
||||||
return CAPTURE_RESULT_OK;
|
return CAPTURE_RESULT_OK;
|
||||||
}
|
}
|
||||||
@ -705,16 +719,19 @@ static CaptureResult nvfbc_getFrame(FrameBuffer * frame, int frameIndex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned int x2 = x;
|
unsigned int x2 = x;
|
||||||
while (x2 < w && ((!wasFresh && info->diffMap[y * w + x2]) || this->diffMap[y * w + x2]))
|
while (x2 < w && ((!wasFresh && info->diffMap[y * w + x2]) ||
|
||||||
|
this->diffMap[y * w + x2]))
|
||||||
++x2;
|
++x2;
|
||||||
|
|
||||||
unsigned int width = (min(x2 << this->diffShift, this->grabWidth) - (x << this->diffShift)) * 4;
|
unsigned int width = (min(x2 << this->diffShift, this->grabWidth) -
|
||||||
rectCopyUnaligned(frameData, this->frameBuffer, ystart, yend, x << (2 + this->diffShift),
|
(x << this->diffShift)) * this->bpp;
|
||||||
this->shmStride * 4, this->grabStride * 4, width);
|
rectCopyUnaligned(frameData, this->frameBuffer, ystart, yend,
|
||||||
|
x << (2 + this->diffShift), this->shmStride * this->bpp,
|
||||||
|
this->grabStride * this->bpp, width);
|
||||||
|
|
||||||
x = x2;
|
x = x2;
|
||||||
}
|
}
|
||||||
framebuffer_set_write_ptr(frame, yend * this->shmStride * 4);
|
framebuffer_set_write_ptr(frame, yend * this->shmStride * this->bpp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (this->grabStride != this->shmStride)
|
else if (this->grabStride != this->shmStride)
|
||||||
@ -722,16 +739,17 @@ static CaptureResult nvfbc_getFrame(FrameBuffer * frame, int frameIndex)
|
|||||||
for (int y = 0; y < this->dataHeight; y += 64)
|
for (int y = 0; y < this->dataHeight; y += 64)
|
||||||
{
|
{
|
||||||
int yend = min(this->dataHeight, y + 128);
|
int yend = min(this->dataHeight, y + 128);
|
||||||
rectCopyUnaligned(frameData, this->frameBuffer, y, yend, 0, this->shmStride * 4,
|
rectCopyUnaligned(frameData, this->frameBuffer, y, yend, 0,
|
||||||
this->grabStride * 4, this->grabWidth * 4);
|
this->shmStride * this->bpp, this->grabStride * this->bpp,
|
||||||
framebuffer_set_write_ptr(frame, yend * this->shmStride * 4);
|
this->grabWidth * this->bpp);
|
||||||
|
framebuffer_set_write_ptr(frame, yend * this->shmStride * this->bpp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
framebuffer_write(
|
framebuffer_write(
|
||||||
frame,
|
frame,
|
||||||
this->frameBuffer,
|
this->frameBuffer,
|
||||||
this->dataHeight * this->grabInfo.dwBufferWidth * 4
|
this->dataHeight * this->grabInfo.dwBufferWidth * this->bpp
|
||||||
);
|
);
|
||||||
|
|
||||||
for (int i = 0; i < LGMP_Q_FRAME_LEN; ++i)
|
for (int i = 0; i < LGMP_Q_FRAME_LEN; ++i)
|
||||||
|
@ -267,8 +267,12 @@ static bool sendFrame(void)
|
|||||||
flags |= FRAME_FLAG_HDR;
|
flags |= FRAME_FLAG_HDR;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAPTURE_FMT_BGR:
|
case CAPTURE_FMT_BGR_32:
|
||||||
fi->type = FRAME_TYPE_BGR;
|
fi->type = FRAME_TYPE_BGR_32;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CAPTURE_FMT_RGB_24:
|
||||||
|
fi->type = FRAME_TYPE_RGB_24;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user