2021-06-06 01:26:18 +00:00
|
|
|
/**
|
|
|
|
* Looking Glass
|
2021-08-04 09:48:32 +00:00
|
|
|
* Copyright © 2017-2021 The Looking Glass Authors
|
2021-06-06 01:26:18 +00:00
|
|
|
* https://looking-glass.io
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the Free
|
|
|
|
* Software Foundation; either version 2 of the License, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc., 59
|
|
|
|
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
2018-12-12 10:41:51 +00:00
|
|
|
|
|
|
|
#include "desktop.h"
|
2019-04-11 01:12:59 +00:00
|
|
|
#include "common/debug.h"
|
2019-05-23 06:32:18 +00:00
|
|
|
#include "common/option.h"
|
2020-01-17 03:35:08 +00:00
|
|
|
#include "common/locking.h"
|
2021-08-09 04:08:10 +00:00
|
|
|
#include "common/array.h"
|
2018-12-12 10:41:51 +00:00
|
|
|
|
2021-01-25 15:33:28 +00:00
|
|
|
#include "app.h"
|
2018-12-12 10:41:51 +00:00
|
|
|
#include "texture.h"
|
|
|
|
#include "shader.h"
|
2021-08-03 00:45:47 +00:00
|
|
|
#include "desktop_rects.h"
|
2021-08-06 07:48:07 +00:00
|
|
|
#include "cimgui.h"
|
2018-12-12 10:41:51 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2019-03-28 03:59:54 +00:00
|
|
|
// these headers are auto generated by cmake
|
|
|
|
#include "desktop.vert.h"
|
|
|
|
#include "desktop_rgb.frag.h"
|
2021-02-22 04:56:51 +00:00
|
|
|
#include "desktop_rgb.def.h"
|
2021-02-21 00:50:59 +00:00
|
|
|
|
2021-08-09 12:42:51 +00:00
|
|
|
#include "basic.vert.h"
|
|
|
|
#include "ffx_cas.frag.h"
|
|
|
|
|
2019-05-22 01:36:18 +00:00
|
|
|
struct DesktopShader
|
2018-12-12 10:41:51 +00:00
|
|
|
{
|
2019-05-22 01:36:18 +00:00
|
|
|
EGL_Shader * shader;
|
2021-08-03 00:45:47 +00:00
|
|
|
GLint uTransform;
|
2019-04-19 01:23:51 +00:00
|
|
|
GLint uDesktopSize;
|
2021-08-09 08:22:28 +00:00
|
|
|
GLint uTextureScale;
|
2021-02-21 00:50:59 +00:00
|
|
|
GLint uScaleAlgo;
|
2021-08-09 04:08:10 +00:00
|
|
|
GLint uNVGain;
|
2020-11-08 19:59:54 +00:00
|
|
|
GLint uCBMode;
|
2019-05-22 01:36:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct EGL_Desktop
|
|
|
|
{
|
2021-08-09 04:08:10 +00:00
|
|
|
EGL * egl;
|
2020-10-29 15:32:25 +00:00
|
|
|
EGLDisplay * display;
|
2020-05-21 01:44:56 +00:00
|
|
|
|
2019-05-22 01:36:18 +00:00
|
|
|
EGL_Texture * texture;
|
2021-08-09 04:08:10 +00:00
|
|
|
struct DesktopShader shader;
|
2021-08-03 00:45:47 +00:00
|
|
|
EGL_DesktopRects * mesh;
|
2021-08-09 04:08:10 +00:00
|
|
|
CountedBuffer * matrix;
|
2019-05-22 01:36:18 +00:00
|
|
|
|
2020-05-21 01:44:56 +00:00
|
|
|
// internals
|
2021-01-15 01:40:59 +00:00
|
|
|
int width, height;
|
|
|
|
LG_RendererRotate rotate;
|
2020-05-21 01:44:56 +00:00
|
|
|
|
2021-02-22 04:56:51 +00:00
|
|
|
// scale algorithm
|
|
|
|
int scaleAlgo;
|
|
|
|
|
2019-03-28 13:15:14 +00:00
|
|
|
// night vision
|
2021-01-25 15:33:28 +00:00
|
|
|
int nvMax;
|
|
|
|
int nvGain;
|
2020-11-08 19:59:54 +00:00
|
|
|
|
|
|
|
// colorblind mode
|
2021-01-25 15:33:28 +00:00
|
|
|
int cbMode;
|
2021-08-07 23:49:55 +00:00
|
|
|
|
|
|
|
bool useDMA;
|
|
|
|
LG_RendererFormat format;
|
2021-08-09 12:42:51 +00:00
|
|
|
|
|
|
|
EGL_Shader * ffxCAS;
|
|
|
|
bool enableCAS;
|
|
|
|
PostProcessHandle ffxCASHandle;
|
2018-12-12 10:41:51 +00:00
|
|
|
};
|
|
|
|
|
2019-03-28 13:15:14 +00:00
|
|
|
// forwards
|
2021-01-25 15:51:03 +00:00
|
|
|
void egl_desktop_toggle_nv(int key, void * opaque);
|
2019-03-28 13:15:14 +00:00
|
|
|
|
2021-08-09 04:08:10 +00:00
|
|
|
static bool egl_initDesktopShader(
|
2019-05-22 01:36:18 +00:00
|
|
|
struct DesktopShader * shader,
|
|
|
|
const char * vertex_code , size_t vertex_size,
|
|
|
|
const char * fragment_code, size_t fragment_size
|
|
|
|
)
|
|
|
|
{
|
2021-08-08 07:16:10 +00:00
|
|
|
if (!egl_shaderInit(&shader->shader))
|
2019-05-22 01:36:18 +00:00
|
|
|
return false;
|
|
|
|
|
2021-08-08 07:16:10 +00:00
|
|
|
if (!egl_shaderCompile(shader->shader,
|
2019-05-22 01:36:18 +00:00
|
|
|
vertex_code , vertex_size,
|
|
|
|
fragment_code, fragment_size))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-08-09 08:22:28 +00:00
|
|
|
shader->uTransform = egl_shaderGetUniform(shader->shader, "transform" );
|
|
|
|
shader->uDesktopSize = egl_shaderGetUniform(shader->shader, "size" );
|
|
|
|
shader->uTextureScale = egl_shaderGetUniform(shader->shader, "textureScale");
|
|
|
|
shader->uScaleAlgo = egl_shaderGetUniform(shader->shader, "scaleAlgo" );
|
|
|
|
shader->uNVGain = egl_shaderGetUniform(shader->shader, "nvGain" );
|
|
|
|
shader->uCBMode = egl_shaderGetUniform(shader->shader, "cbMode" );
|
2019-05-22 01:36:18 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-08-09 12:42:51 +00:00
|
|
|
static void setupFilters(EGL_Desktop * desktop)
|
|
|
|
{
|
|
|
|
desktop->ffxCASHandle =
|
|
|
|
egl_textureAddFilter(desktop->texture, desktop->ffxCAS, 1.0f, false);
|
|
|
|
}
|
|
|
|
|
2021-08-09 14:48:41 +00:00
|
|
|
bool egl_desktopInit(EGL * egl, EGL_Desktop ** desktop_, EGLDisplay * display,
|
2021-08-09 04:08:10 +00:00
|
|
|
bool useDMA, int maxRects)
|
2018-12-12 10:41:51 +00:00
|
|
|
{
|
2021-08-09 14:48:41 +00:00
|
|
|
EGL_Desktop * desktop = (EGL_Desktop *)calloc(1, sizeof(EGL_Desktop));
|
|
|
|
if (!desktop)
|
2018-12-12 10:41:51 +00:00
|
|
|
{
|
|
|
|
DEBUG_ERROR("Failed to malloc EGL_Desktop");
|
|
|
|
return false;
|
|
|
|
}
|
2021-08-09 14:48:41 +00:00
|
|
|
*desktop_ = desktop;
|
2018-12-12 10:41:51 +00:00
|
|
|
|
2021-08-09 14:48:41 +00:00
|
|
|
desktop->egl = egl;
|
|
|
|
desktop->display = display;
|
2018-12-12 10:41:51 +00:00
|
|
|
|
2021-08-09 14:48:41 +00:00
|
|
|
if (!egl_textureInit(egl, &desktop->texture, display,
|
2021-08-02 13:37:33 +00:00
|
|
|
useDMA ? EGL_TEXTYPE_DMABUF : EGL_TEXTYPE_FRAMEBUFFER, true))
|
2018-12-12 10:41:51 +00:00
|
|
|
{
|
|
|
|
DEBUG_ERROR("Failed to initialize the desktop texture");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-08-09 04:08:10 +00:00
|
|
|
if (!egl_initDesktopShader(
|
2021-08-09 14:48:41 +00:00
|
|
|
&desktop->shader,
|
2019-05-22 01:36:18 +00:00
|
|
|
b_shader_desktop_vert , b_shader_desktop_vert_size,
|
|
|
|
b_shader_desktop_rgb_frag, b_shader_desktop_rgb_frag_size))
|
2018-12-12 10:41:51 +00:00
|
|
|
{
|
|
|
|
DEBUG_ERROR("Failed to initialize the generic desktop shader");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-08-09 14:48:41 +00:00
|
|
|
if (!egl_desktopRectsInit(&desktop->mesh, maxRects))
|
2018-12-12 10:41:51 +00:00
|
|
|
{
|
2021-08-03 00:45:47 +00:00
|
|
|
DEBUG_ERROR("Failed to initialize the desktop mesh");
|
2018-12-12 10:41:51 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-08-09 14:48:41 +00:00
|
|
|
desktop->matrix = countedBufferNew(6 * sizeof(GLfloat));
|
|
|
|
if (!desktop->matrix)
|
2021-08-09 04:08:10 +00:00
|
|
|
{
|
|
|
|
DEBUG_ERROR("Failed to allocate the desktop matrix buffer");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-08-09 14:48:41 +00:00
|
|
|
app_registerKeybind(KEY_N, egl_desktop_toggle_nv, desktop,
|
|
|
|
"Toggle night vision mode");
|
2019-03-28 13:15:14 +00:00
|
|
|
|
2021-08-09 14:48:41 +00:00
|
|
|
desktop->nvMax = option_get_int("egl", "nvGainMax");
|
|
|
|
desktop->nvGain = option_get_int("egl", "nvGain" );
|
|
|
|
desktop->cbMode = option_get_int("egl", "cbMode" );
|
|
|
|
desktop->scaleAlgo = option_get_int("egl", "scale" );
|
|
|
|
desktop->useDMA = useDMA;
|
2019-05-23 06:32:18 +00:00
|
|
|
|
2021-08-09 14:48:41 +00:00
|
|
|
egl_shaderInit(&desktop->ffxCAS);
|
|
|
|
egl_shaderCompile(desktop->ffxCAS,
|
2021-08-09 12:42:51 +00:00
|
|
|
b_shader_basic_vert , b_shader_basic_vert_size,
|
|
|
|
b_shader_ffx_cas_frag, b_shader_ffx_cas_frag_size);
|
|
|
|
|
2021-08-09 14:48:41 +00:00
|
|
|
setupFilters(desktop);
|
2021-08-09 12:42:51 +00:00
|
|
|
|
2018-12-12 10:41:51 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-01-25 15:51:03 +00:00
|
|
|
void egl_desktop_toggle_nv(int key, void * opaque)
|
2019-03-28 13:15:14 +00:00
|
|
|
{
|
|
|
|
EGL_Desktop * desktop = (EGL_Desktop *)opaque;
|
2019-05-23 06:32:18 +00:00
|
|
|
if (desktop->nvGain++ == desktop->nvMax)
|
2019-03-28 13:15:14 +00:00
|
|
|
desktop->nvGain = 0;
|
2019-03-30 01:26:06 +00:00
|
|
|
|
2019-03-30 13:08:52 +00:00
|
|
|
if (desktop->nvGain == 0) app_alert(LG_ALERT_INFO, "NV Disabled");
|
|
|
|
else if (desktop->nvGain == 1) app_alert(LG_ALERT_INFO, "NV Enabled");
|
|
|
|
else app_alert(LG_ALERT_INFO, "NV Gain + %d", desktop->nvGain - 1);
|
2021-08-07 22:41:08 +00:00
|
|
|
|
|
|
|
app_invalidateWindow(true);
|
2019-03-28 13:15:14 +00:00
|
|
|
}
|
|
|
|
|
2021-08-08 07:16:10 +00:00
|
|
|
bool egl_desktopScaleValidate(struct Option * opt, const char ** error)
|
2021-02-22 05:03:50 +00:00
|
|
|
{
|
|
|
|
if (opt->value.x_int >= 0 && opt->value.x_int < EGL_SCALE_MAX)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
*error = "Invalid scale algorithm number";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-08-08 07:16:10 +00:00
|
|
|
void egl_desktopFree(EGL_Desktop ** desktop)
|
2018-12-12 10:41:51 +00:00
|
|
|
{
|
|
|
|
if (!*desktop)
|
|
|
|
return;
|
|
|
|
|
2021-08-09 04:08:10 +00:00
|
|
|
egl_textureFree (&(*desktop)->texture );
|
|
|
|
egl_shaderFree (&(*desktop)->shader.shader);
|
|
|
|
egl_desktopRectsFree(&(*desktop)->mesh );
|
|
|
|
countedBufferRelease(&(*desktop)->matrix );
|
2021-08-09 12:42:51 +00:00
|
|
|
egl_shaderFree(&(*desktop)->ffxCAS);
|
2018-12-12 10:41:51 +00:00
|
|
|
|
|
|
|
free(*desktop);
|
|
|
|
*desktop = NULL;
|
|
|
|
}
|
|
|
|
|
2021-08-06 07:48:07 +00:00
|
|
|
static const char * algorithmNames[EGL_SCALE_MAX] = {
|
|
|
|
[EGL_SCALE_AUTO] = "Automatic (downscale: linear, upscale: nearest)",
|
|
|
|
[EGL_SCALE_NEAREST] = "Nearest",
|
|
|
|
[EGL_SCALE_LINEAR] = "Linear",
|
|
|
|
};
|
|
|
|
|
2021-08-08 07:16:10 +00:00
|
|
|
void egl_desktopConfigUI(EGL_Desktop * desktop)
|
2021-08-06 07:48:07 +00:00
|
|
|
{
|
|
|
|
igText("Scale algorithm:");
|
|
|
|
igPushItemWidth(igGetWindowWidth() - igGetStyle()->WindowPadding.x * 2);
|
|
|
|
if (igBeginCombo("##scale", algorithmNames[desktop->scaleAlgo], 0))
|
|
|
|
{
|
|
|
|
for (int i = 0; i < EGL_SCALE_MAX; ++i)
|
|
|
|
{
|
|
|
|
bool selected = i == desktop->scaleAlgo;
|
|
|
|
if (igSelectableBool(algorithmNames[i], selected, 0, (ImVec2) { 0.0f, 0.0f }))
|
|
|
|
desktop->scaleAlgo = i;
|
|
|
|
if (selected)
|
|
|
|
igSetItemDefaultFocus();
|
|
|
|
}
|
|
|
|
igEndCombo();
|
|
|
|
}
|
|
|
|
igPopItemWidth();
|
2021-08-07 10:31:05 +00:00
|
|
|
|
|
|
|
igText("Night vision mode:");
|
|
|
|
igSameLine(0.0f, -1.0f);
|
|
|
|
igPushItemWidth(igGetWindowWidth() - igGetCursorPosX() - igGetStyle()->WindowPadding.x);
|
|
|
|
|
|
|
|
const char * format;
|
|
|
|
switch (desktop->nvGain)
|
|
|
|
{
|
|
|
|
case 0: format = "off"; break;
|
|
|
|
case 1: format = "on"; break;
|
|
|
|
default: format = "gain: %d";
|
|
|
|
}
|
|
|
|
igSliderInt("##nvgain", &desktop->nvGain, 0, desktop->nvMax, format, 0);
|
|
|
|
igPopItemWidth();
|
2021-08-09 12:42:51 +00:00
|
|
|
|
|
|
|
bool cas = desktop->enableCAS;
|
|
|
|
igCheckbox("AMD FidelityFX CAS", &cas);
|
|
|
|
if (cas != desktop->enableCAS)
|
|
|
|
{
|
|
|
|
desktop->enableCAS = cas;
|
|
|
|
egl_textureEnableFilter(desktop->ffxCASHandle, cas);
|
|
|
|
}
|
2021-08-06 07:48:07 +00:00
|
|
|
}
|
|
|
|
|
2021-08-08 07:16:10 +00:00
|
|
|
bool egl_desktopSetup(EGL_Desktop * desktop, const LG_RendererFormat format)
|
2018-12-12 10:41:51 +00:00
|
|
|
{
|
2021-08-07 23:49:55 +00:00
|
|
|
memcpy(&desktop->format, &format, sizeof(LG_RendererFormat));
|
|
|
|
|
2020-10-12 08:43:29 +00:00
|
|
|
enum EGL_PixelFormat pixFmt;
|
|
|
|
switch(format.type)
|
2018-12-12 10:41:51 +00:00
|
|
|
{
|
2020-10-12 08:43:29 +00:00
|
|
|
case FRAME_TYPE_BGRA:
|
|
|
|
pixFmt = EGL_PF_BGRA;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FRAME_TYPE_RGBA:
|
|
|
|
pixFmt = EGL_PF_RGBA;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FRAME_TYPE_RGBA10:
|
|
|
|
pixFmt = EGL_PF_RGBA10;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FRAME_TYPE_RGBA16F:
|
|
|
|
pixFmt = EGL_PF_RGBA16F;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
DEBUG_ERROR("Unsupported frame format");
|
2020-05-21 01:44:56 +00:00
|
|
|
return false;
|
2018-12-12 10:41:51 +00:00
|
|
|
}
|
|
|
|
|
2020-10-12 08:43:29 +00:00
|
|
|
desktop->width = format.width;
|
|
|
|
desktop->height = format.height;
|
|
|
|
|
2021-08-08 07:16:10 +00:00
|
|
|
if (!egl_textureSetup(
|
2020-10-12 08:43:29 +00:00
|
|
|
desktop->texture,
|
|
|
|
pixFmt,
|
|
|
|
format.width,
|
|
|
|
format.height,
|
2021-08-02 13:37:33 +00:00
|
|
|
format.pitch
|
2020-10-12 08:43:29 +00:00
|
|
|
))
|
|
|
|
{
|
|
|
|
DEBUG_ERROR("Failed to setup the desktop texture");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-08-07 06:10:30 +00:00
|
|
|
bool egl_desktop_update(EGL_Desktop * desktop, const FrameBuffer * frame, int dmaFd,
|
|
|
|
const FrameDamageRect * damageRects, int damageRectsCount)
|
2020-10-12 08:43:29 +00:00
|
|
|
{
|
2021-08-07 23:49:55 +00:00
|
|
|
if (desktop->useDMA && dmaFd >= 0)
|
2020-10-29 15:32:25 +00:00
|
|
|
{
|
2021-08-08 07:16:10 +00:00
|
|
|
if (egl_textureUpdateFromDMA(desktop->texture, frame, dmaFd))
|
2021-08-07 23:49:55 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
DEBUG_WARN("DMA update failed, disabling DMABUF imports");
|
|
|
|
desktop->useDMA = false;
|
|
|
|
|
2021-08-08 07:52:13 +00:00
|
|
|
egl_textureFree(&desktop->texture);
|
2021-08-09 04:08:10 +00:00
|
|
|
if (!egl_textureInit(desktop->egl, &desktop->texture, desktop->display,
|
|
|
|
EGL_TEXTYPE_FRAMEBUFFER, true))
|
2021-08-07 23:49:55 +00:00
|
|
|
{
|
|
|
|
DEBUG_ERROR("Failed to initialize the desktop texture");
|
2020-10-29 15:32:25 +00:00
|
|
|
return false;
|
2021-08-07 23:49:55 +00:00
|
|
|
}
|
|
|
|
|
2021-08-09 12:42:51 +00:00
|
|
|
setupFilters(desktop);
|
|
|
|
|
2021-08-08 07:16:10 +00:00
|
|
|
if (!egl_desktopSetup(desktop, desktop->format))
|
2020-10-29 15:32:25 +00:00
|
|
|
return false;
|
|
|
|
}
|
2020-05-21 01:44:56 +00:00
|
|
|
|
2021-08-08 07:16:10 +00:00
|
|
|
return egl_textureUpdateFromFrame(desktop->texture, frame, damageRects, damageRectsCount);
|
2018-12-12 10:41:51 +00:00
|
|
|
}
|
|
|
|
|
2021-08-08 07:16:10 +00:00
|
|
|
bool egl_desktopRender(EGL_Desktop * desktop, const float x, const float y,
|
2021-02-21 00:50:59 +00:00
|
|
|
const float scaleX, const float scaleY, enum EGL_DesktopScaleType scaleType,
|
2021-08-03 00:45:47 +00:00
|
|
|
LG_RendererRotate rotate, const struct DamageRects * rects)
|
2018-12-12 10:41:51 +00:00
|
|
|
{
|
2021-08-02 13:37:33 +00:00
|
|
|
enum EGL_TexStatus status;
|
2021-08-08 07:16:10 +00:00
|
|
|
if ((status = egl_textureProcess(desktop->texture)) != EGL_TEX_STATUS_OK)
|
2021-08-02 13:37:33 +00:00
|
|
|
{
|
|
|
|
if (status != EGL_TEX_STATUS_NOTREADY)
|
|
|
|
DEBUG_ERROR("Failed to process the desktop texture");
|
|
|
|
}
|
|
|
|
|
2021-02-22 04:56:51 +00:00
|
|
|
int scaleAlgo = EGL_SCALE_NEAREST;
|
2021-02-21 00:50:59 +00:00
|
|
|
|
2021-02-22 04:56:51 +00:00
|
|
|
switch (desktop->scaleAlgo)
|
2021-01-18 17:26:59 +00:00
|
|
|
{
|
2021-02-22 04:56:51 +00:00
|
|
|
case EGL_SCALE_AUTO:
|
|
|
|
switch (scaleType)
|
|
|
|
{
|
|
|
|
case EGL_DESKTOP_NOSCALE:
|
|
|
|
case EGL_DESKTOP_UPSCALE:
|
|
|
|
scaleAlgo = EGL_SCALE_NEAREST;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EGL_DESKTOP_DOWNSCALE:
|
|
|
|
scaleAlgo = EGL_SCALE_LINEAR;
|
|
|
|
break;
|
|
|
|
}
|
2021-02-21 00:50:59 +00:00
|
|
|
break;
|
|
|
|
|
2021-02-22 04:56:51 +00:00
|
|
|
default:
|
|
|
|
scaleAlgo = desktop->scaleAlgo;
|
2021-01-18 17:26:59 +00:00
|
|
|
}
|
|
|
|
|
2021-08-09 04:08:10 +00:00
|
|
|
egl_desktopRectsMatrix((float *)desktop->matrix->data,
|
|
|
|
desktop->width, desktop->height, x, y, scaleX, scaleY, rotate);
|
2021-08-03 00:45:47 +00:00
|
|
|
egl_desktopRectsUpdate(desktop->mesh, rects, desktop->width, desktop->height);
|
|
|
|
|
2021-08-09 04:08:10 +00:00
|
|
|
egl_textureBind(desktop->texture);
|
2019-04-19 01:23:51 +00:00
|
|
|
|
2021-08-09 04:08:10 +00:00
|
|
|
const struct DesktopShader * shader = &desktop->shader;
|
|
|
|
EGL_Uniform uniforms[] =
|
2019-03-28 13:15:14 +00:00
|
|
|
{
|
2021-08-09 04:08:10 +00:00
|
|
|
{
|
|
|
|
.type = EGL_UNIFORM_TYPE_1I,
|
|
|
|
.location = shader->uScaleAlgo,
|
|
|
|
.i = { scaleAlgo },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.type = EGL_UNIFORM_TYPE_2F,
|
|
|
|
.location = shader->uDesktopSize,
|
|
|
|
.f = { desktop->width, desktop->height },
|
|
|
|
},
|
2021-08-09 08:22:28 +00:00
|
|
|
{
|
|
|
|
.type = EGL_UNIFORM_TYPE_1F,
|
|
|
|
.location = shader->uTextureScale,
|
|
|
|
.f = { egl_textureGetScale(desktop->texture) },
|
|
|
|
},
|
2021-08-09 04:08:10 +00:00
|
|
|
{
|
|
|
|
.type = EGL_UNIFORM_TYPE_M3x2FV,
|
|
|
|
.location = shader->uTransform,
|
|
|
|
.m.transpose = GL_FALSE,
|
|
|
|
.m.v = desktop->matrix
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.type = EGL_UNIFORM_TYPE_1F,
|
|
|
|
.location = shader->uNVGain,
|
|
|
|
.f = { (float)desktop->nvGain }
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.type = EGL_UNIFORM_TYPE_1I,
|
|
|
|
.location = shader->uCBMode,
|
|
|
|
.f = { desktop->cbMode }
|
|
|
|
}
|
|
|
|
};
|
2021-08-03 00:45:47 +00:00
|
|
|
|
2021-08-09 04:08:10 +00:00
|
|
|
egl_shaderSetUniforms(shader->shader, uniforms, ARRAY_LENGTH(uniforms));
|
|
|
|
egl_shaderUse(shader->shader);
|
2021-08-03 00:45:47 +00:00
|
|
|
egl_desktopRectsRender(desktop->mesh);
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
2019-06-12 12:36:00 +00:00
|
|
|
return true;
|
2020-01-17 03:35:08 +00:00
|
|
|
}
|