mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-23 06:11:46 +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;
|
||||
GLint uTransform;
|
||||
GLint uDesktopSize;
|
||||
GLint uTextureScale;
|
||||
GLint uScaleAlgo;
|
||||
GLint uNVGain;
|
||||
GLint uCBMode;
|
||||
|
@ -95,11 +96,12 @@ static bool egl_initDesktopShader(
|
|||
return false;
|
||||
}
|
||||
|
||||
shader->uTransform = egl_shaderGetUniform(shader->shader, "transform");
|
||||
shader->uDesktopSize = egl_shaderGetUniform(shader->shader, "size" );
|
||||
shader->uScaleAlgo = egl_shaderGetUniform(shader->shader, "scaleAlgo");
|
||||
shader->uNVGain = egl_shaderGetUniform(shader->shader, "nvGain" );
|
||||
shader->uCBMode = egl_shaderGetUniform(shader->shader, "cbMode" );
|
||||
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" );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -356,6 +358,11 @@ bool egl_desktopRender(EGL_Desktop * desktop, const float x, const float y,
|
|||
.location = shader->uDesktopSize,
|
||||
.f = { desktop->width, desktop->height },
|
||||
},
|
||||
{
|
||||
.type = EGL_UNIFORM_TYPE_1F,
|
||||
.location = shader->uTextureScale,
|
||||
.f = { egl_textureGetScale(desktop->texture) },
|
||||
},
|
||||
{
|
||||
.type = EGL_UNIFORM_TYPE_M3x2FV,
|
||||
.location = shader->uTransform,
|
||||
|
|
|
@ -12,6 +12,7 @@ uniform sampler2D sampler1;
|
|||
|
||||
uniform int scaleAlgo;
|
||||
uniform highp vec2 size;
|
||||
uniform highp float textureScale;
|
||||
|
||||
uniform highp float nvGain;
|
||||
uniform int cbMode;
|
||||
|
@ -21,7 +22,7 @@ void main()
|
|||
switch (scaleAlgo)
|
||||
{
|
||||
case EGL_SCALE_NEAREST:
|
||||
color = texelFetch(sampler1, ivec2(uv * size), 0);
|
||||
color = texelFetch(sampler1, ivec2(uv * size * textureScale), 0);
|
||||
break;
|
||||
|
||||
case EGL_SCALE_LINEAR:
|
||||
|
|
|
@ -339,6 +339,7 @@ enum EGL_TexStatus egl_textureAddShader(EGL_Texture * this, EGL_Shader * shader,
|
|||
glGenTextures(1, &step->tex);
|
||||
step->shader = shader;
|
||||
step->scale = outputScale;
|
||||
this->scale = outputScale;
|
||||
|
||||
if (this->formatValid)
|
||||
if (!setupRenderStep(this, step))
|
||||
|
@ -351,3 +352,8 @@ enum EGL_TexStatus egl_textureAddShader(EGL_Texture * this, EGL_Shader * shader,
|
|||
ll_push(this->render, step);
|
||||
return EGL_TEX_STATUS_OK;
|
||||
}
|
||||
|
||||
float egl_textureGetScale(EGL_Texture * this)
|
||||
{
|
||||
return this->scale;
|
||||
}
|
||||
|
|
|
@ -144,6 +144,7 @@ struct EGL_Texture
|
|||
_Atomic(bool) updated;
|
||||
bool postProcessed;
|
||||
EGL_Model * model;
|
||||
float scale;
|
||||
};
|
||||
|
||||
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,
|
||||
EGL_Shader * shader, float outputScale);
|
||||
|
||||
float egl_textureGetScale(EGL_Texture * texture);
|
||||
|
|
Loading…
Reference in a new issue