mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-04 06:12:04 +00:00
[client] egl: stop aliasing damage tracking layouts
Pass damage rectangle arrays and counts explicitly to the EGL mesh updater instead of casting DesktopDamage to DamageRects.
This commit is contained in:
@@ -169,7 +169,7 @@ bool egl_damageRender(EGL_Damage * damage, LG_RendererRotate rotate, const struc
|
|||||||
egl_shaderUse(damage->shader);
|
egl_shaderUse(damage->shader);
|
||||||
|
|
||||||
if (data && data->count != 0)
|
if (data && data->count != 0)
|
||||||
egl_desktopRectsUpdate(damage->mesh, (const struct DamageRects *) data,
|
egl_desktopRectsUpdate(damage->mesh, data->rects, data->count,
|
||||||
damage->width, damage->height);
|
damage->width, damage->height);
|
||||||
|
|
||||||
egl_desktopRectsRender(damage->mesh);
|
egl_desktopRectsRender(damage->mesh);
|
||||||
|
|||||||
@@ -508,7 +508,9 @@ bool egl_desktopRender(EGL_Desktop * desktop, unsigned int outputWidth,
|
|||||||
|
|
||||||
egl_desktopRectsMatrix(desktop->matrix,
|
egl_desktopRectsMatrix(desktop->matrix,
|
||||||
width, height, x, y, scaleX, scaleY, rotate);
|
width, height, x, y, scaleX, scaleY, rotate);
|
||||||
egl_desktopRectsUpdate(desktop->mesh, rects, width, height);
|
egl_desktopRectsUpdate(desktop->mesh,
|
||||||
|
rects ? rects->rects : NULL, rects ? rects->count : -1,
|
||||||
|
width, height);
|
||||||
|
|
||||||
const bool hdr = desktop->hdr && !desktop->useSpice;
|
const bool hdr = desktop->hdr && !desktop->useSpice;
|
||||||
uint32_t hdrPeak = 0;
|
uint32_t hdrPeak = 0;
|
||||||
@@ -539,7 +541,7 @@ bool egl_desktopRender(EGL_Desktop * desktop, unsigned int outputWidth,
|
|||||||
{
|
{
|
||||||
/* The filter output may have changed everywhere, but this only applies
|
/* The filter output may have changed everywhere, but this only applies
|
||||||
* to the render that actually evaluated the filter. */
|
* to the render that actually evaluated the filter. */
|
||||||
egl_desktopRectsUpdate(desktop->mesh, NULL, width, height);
|
egl_desktopRectsUpdate(desktop->mesh, NULL, -1, width, height);
|
||||||
*fullFrame = true;
|
*fullFrame = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,18 +107,18 @@ inline static void rectToVertices(GLfloat * vertex, const FrameDamageRect * rect
|
|||||||
vertex[7] = rect->y + rect->height;
|
vertex[7] = rect->y + rect->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
void egl_desktopRectsUpdate(EGL_DesktopRects * rects, const struct DamageRects * data,
|
void egl_desktopRectsUpdate(EGL_DesktopRects * rects,
|
||||||
int width, int height)
|
const FrameDamageRect * data, int count, int width, int height)
|
||||||
{
|
{
|
||||||
if (data && data->count == 0)
|
if (count == 0)
|
||||||
{
|
{
|
||||||
rects->count = 0;
|
rects->count = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int count = (!data || data->count < 0 ? 1 : data->count) * 8;
|
const int vertexCount = (count < 0 ? 1 : count) * 8;
|
||||||
GLfloat vertices[count];
|
GLfloat vertices[vertexCount];
|
||||||
if (!data || data->count < 0)
|
if (count < 0)
|
||||||
{
|
{
|
||||||
FrameDamageRect full = {
|
FrameDamageRect full = {
|
||||||
.x = 0, .y = 0, .width = width, .height = height,
|
.x = 0, .y = 0, .width = width, .height = height,
|
||||||
@@ -128,36 +128,37 @@ void egl_desktopRectsUpdate(EGL_DesktopRects * rects, const struct DamageRects *
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rects->count = data->count;
|
rects->count = count;
|
||||||
DEBUG_ASSERT(rects->count <= rects->maxCount);
|
DEBUG_ASSERT(rects->count <= rects->maxCount);
|
||||||
|
|
||||||
for (int i = 0; i < rects->count; ++i)
|
for (int i = 0; i < rects->count; ++i)
|
||||||
rectToVertices(vertices + i * 8, data->rects + i);
|
rectToVertices(vertices + i * 8, data + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if the value actually changed and needs updating
|
// check if the value actually changed and needs updating
|
||||||
if (count == rects->lastVerticesCount &&
|
if (vertexCount == rects->lastVerticesCount &&
|
||||||
memcmp(rects->lastVertices, vertices, sizeof(GLfloat) * count) == 0)
|
memcmp(rects->lastVertices, vertices,
|
||||||
|
sizeof(GLfloat) * vertexCount) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// ensure the local storage is large enough
|
// ensure the local storage is large enough
|
||||||
if (count > rects->lastVerticesSize)
|
if (vertexCount > rects->lastVerticesSize)
|
||||||
{
|
{
|
||||||
if (rects->lastVertices)
|
if (rects->lastVertices)
|
||||||
free(rects->lastVertices);
|
free(rects->lastVertices);
|
||||||
|
|
||||||
rects->lastVertices = malloc(sizeof(GLfloat) * count);
|
rects->lastVertices = malloc(sizeof(GLfloat) * vertexCount);
|
||||||
if (!rects->lastVertices)
|
if (!rects->lastVertices)
|
||||||
{
|
{
|
||||||
DEBUG_ERROR("out of memory");
|
DEBUG_ERROR("out of memory");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
rects->lastVerticesSize = count;
|
rects->lastVerticesSize = vertexCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy the last value for later comparison
|
// copy the last value for later comparison
|
||||||
rects->lastVerticesCount = count;
|
rects->lastVerticesCount = vertexCount;
|
||||||
memcpy(rects->lastVertices, vertices, sizeof(GLfloat) * count);
|
memcpy(rects->lastVertices, vertices, sizeof(GLfloat) * vertexCount);
|
||||||
|
|
||||||
egl_stateBindBuffer(GL_ARRAY_BUFFER, rects->buffers[0]);
|
egl_stateBindBuffer(GL_ARRAY_BUFFER, rects->buffers[0]);
|
||||||
glBufferSubData(GL_ARRAY_BUFFER, 0, rects->count * 8 * sizeof(GLfloat), vertices);
|
glBufferSubData(GL_ARRAY_BUFFER, 0, rects->count * 8 * sizeof(GLfloat), vertices);
|
||||||
|
|||||||
@@ -48,6 +48,6 @@ void egl_screenToDesktopMatrix(double matrix[6], int frameWidth, int frameHeight
|
|||||||
bool egl_screenToDesktop(struct FrameDamageRect * output, const double matrix[6],
|
bool egl_screenToDesktop(struct FrameDamageRect * output, const double matrix[6],
|
||||||
const struct Rect * rect, int width, int height);
|
const struct Rect * rect, int width, int height);
|
||||||
|
|
||||||
void egl_desktopRectsUpdate(EGL_DesktopRects * rects, const struct DamageRects * data,
|
void egl_desktopRectsUpdate(EGL_DesktopRects * rects,
|
||||||
int width, int height);
|
const FrameDamageRect * data, int count, int width, int height);
|
||||||
void egl_desktopRectsRender(EGL_DesktopRects * rects);
|
void egl_desktopRectsRender(EGL_DesktopRects * rects);
|
||||||
@@ -906,13 +906,15 @@ bool egl_postProcessRun(EGL_PostProcess * this, EGL_Texture * tex,
|
|||||||
}
|
}
|
||||||
|
|
||||||
rects = this->rects;
|
rects = this->rects;
|
||||||
egl_desktopRectsUpdate(rects, NULL, desktopWidth, desktopHeight);
|
egl_desktopRectsUpdate(
|
||||||
|
rects, NULL, -1, desktopWidth, desktopHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->config.fullFrame)
|
if (this->config.fullFrame)
|
||||||
{
|
{
|
||||||
rects = this->rects;
|
rects = this->rects;
|
||||||
egl_desktopRectsUpdate(rects, NULL, desktopWidth, desktopHeight);
|
egl_desktopRectsUpdate(
|
||||||
|
rects, NULL, -1, desktopWidth, desktopHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
EGL_FilterRects filterRects = {
|
EGL_FilterRects filterRects = {
|
||||||
|
|||||||
Reference in New Issue
Block a user