mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-01-11 06:43:56 +00:00
[client] egl: provide the texture scale to the desktop shader
If the texture has a post-processing filter that has scaled the texture, the desktop fragment shader needs to know this if it's doing linear scaling.
This commit is contained in:
parent
f7f8060447
commit
6882e5c59f
4 changed files with 23 additions and 6 deletions
|
@ -43,6 +43,7 @@ struct DesktopShader
|
||||||
EGL_Shader * shader;
|
EGL_Shader * shader;
|
||||||
GLint uTransform;
|
GLint uTransform;
|
||||||
GLint uDesktopSize;
|
GLint uDesktopSize;
|
||||||
|
GLint uTextureScale;
|
||||||
GLint uScaleAlgo;
|
GLint uScaleAlgo;
|
||||||
GLint uNVGain;
|
GLint uNVGain;
|
||||||
GLint uCBMode;
|
GLint uCBMode;
|
||||||
|
@ -95,9 +96,10 @@ static bool egl_initDesktopShader(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
shader->uTransform = egl_shaderGetUniform(shader->shader, "transform");
|
shader->uTransform = egl_shaderGetUniform(shader->shader, "transform" );
|
||||||
shader->uDesktopSize = egl_shaderGetUniform(shader->shader, "size" );
|
shader->uDesktopSize = egl_shaderGetUniform(shader->shader, "size" );
|
||||||
shader->uScaleAlgo = egl_shaderGetUniform(shader->shader, "scaleAlgo");
|
shader->uTextureScale = egl_shaderGetUniform(shader->shader, "textureScale");
|
||||||
|
shader->uScaleAlgo = egl_shaderGetUniform(shader->shader, "scaleAlgo" );
|
||||||
shader->uNVGain = egl_shaderGetUniform(shader->shader, "nvGain" );
|
shader->uNVGain = egl_shaderGetUniform(shader->shader, "nvGain" );
|
||||||
shader->uCBMode = egl_shaderGetUniform(shader->shader, "cbMode" );
|
shader->uCBMode = egl_shaderGetUniform(shader->shader, "cbMode" );
|
||||||
|
|
||||||
|
@ -356,6 +358,11 @@ bool egl_desktopRender(EGL_Desktop * desktop, const float x, const float y,
|
||||||
.location = shader->uDesktopSize,
|
.location = shader->uDesktopSize,
|
||||||
.f = { desktop->width, desktop->height },
|
.f = { desktop->width, desktop->height },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.type = EGL_UNIFORM_TYPE_1F,
|
||||||
|
.location = shader->uTextureScale,
|
||||||
|
.f = { egl_textureGetScale(desktop->texture) },
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.type = EGL_UNIFORM_TYPE_M3x2FV,
|
.type = EGL_UNIFORM_TYPE_M3x2FV,
|
||||||
.location = shader->uTransform,
|
.location = shader->uTransform,
|
||||||
|
|
|
@ -12,6 +12,7 @@ uniform sampler2D sampler1;
|
||||||
|
|
||||||
uniform int scaleAlgo;
|
uniform int scaleAlgo;
|
||||||
uniform highp vec2 size;
|
uniform highp vec2 size;
|
||||||
|
uniform highp float textureScale;
|
||||||
|
|
||||||
uniform highp float nvGain;
|
uniform highp float nvGain;
|
||||||
uniform int cbMode;
|
uniform int cbMode;
|
||||||
|
@ -21,7 +22,7 @@ void main()
|
||||||
switch (scaleAlgo)
|
switch (scaleAlgo)
|
||||||
{
|
{
|
||||||
case EGL_SCALE_NEAREST:
|
case EGL_SCALE_NEAREST:
|
||||||
color = texelFetch(sampler1, ivec2(uv * size), 0);
|
color = texelFetch(sampler1, ivec2(uv * size * textureScale), 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EGL_SCALE_LINEAR:
|
case EGL_SCALE_LINEAR:
|
||||||
|
|
|
@ -339,6 +339,7 @@ enum EGL_TexStatus egl_textureAddShader(EGL_Texture * this, EGL_Shader * shader,
|
||||||
glGenTextures(1, &step->tex);
|
glGenTextures(1, &step->tex);
|
||||||
step->shader = shader;
|
step->shader = shader;
|
||||||
step->scale = outputScale;
|
step->scale = outputScale;
|
||||||
|
this->scale = outputScale;
|
||||||
|
|
||||||
if (this->formatValid)
|
if (this->formatValid)
|
||||||
if (!setupRenderStep(this, step))
|
if (!setupRenderStep(this, step))
|
||||||
|
@ -351,3 +352,8 @@ enum EGL_TexStatus egl_textureAddShader(EGL_Texture * this, EGL_Shader * shader,
|
||||||
ll_push(this->render, step);
|
ll_push(this->render, step);
|
||||||
return EGL_TEX_STATUS_OK;
|
return EGL_TEX_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float egl_textureGetScale(EGL_Texture * this)
|
||||||
|
{
|
||||||
|
return this->scale;
|
||||||
|
}
|
||||||
|
|
|
@ -144,6 +144,7 @@ struct EGL_Texture
|
||||||
_Atomic(bool) updated;
|
_Atomic(bool) updated;
|
||||||
bool postProcessed;
|
bool postProcessed;
|
||||||
EGL_Model * model;
|
EGL_Model * model;
|
||||||
|
float scale;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool egl_textureInit(EGL * egl, EGL_Texture ** texture, EGLDisplay * display,
|
bool egl_textureInit(EGL * egl, EGL_Texture ** texture, EGLDisplay * display,
|
||||||
|
@ -168,3 +169,5 @@ enum EGL_TexStatus egl_textureBind(EGL_Texture * texture);
|
||||||
|
|
||||||
enum EGL_TexStatus egl_textureAddShader(EGL_Texture * texture,
|
enum EGL_TexStatus egl_textureAddShader(EGL_Texture * texture,
|
||||||
EGL_Shader * shader, float outputScale);
|
EGL_Shader * shader, float outputScale);
|
||||||
|
|
||||||
|
float egl_textureGetScale(EGL_Texture * texture);
|
||||||
|
|
Loading…
Reference in a new issue