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-09-23 05:48:44 +00:00
|
|
|
|
2018-12-12 05:39:04 +00:00
|
|
|
#include "texture.h"
|
2018-09-23 05:48:44 +00:00
|
|
|
|
2021-08-02 13:37:33 +00:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <assert.h>
|
2021-08-08 07:31:52 +00:00
|
|
|
#include <string.h>
|
2021-08-02 13:37:33 +00:00
|
|
|
#include "shader.h"
|
|
|
|
#include "common/framebuffer.h"
|
2021-08-09 04:08:10 +00:00
|
|
|
#include "common/debug.h"
|
2021-05-02 14:48:36 +00:00
|
|
|
|
2021-08-02 13:37:33 +00:00
|
|
|
#include <EGL/egl.h>
|
|
|
|
#include <EGL/eglext.h>
|
2020-05-29 05:48:59 +00:00
|
|
|
|
2021-08-02 13:37:33 +00:00
|
|
|
#include "texture_buffer.h"
|
2020-05-22 07:47:19 +00:00
|
|
|
|
2021-08-02 13:37:33 +00:00
|
|
|
extern const EGL_TextureOps EGL_TextureBuffer;
|
|
|
|
extern const EGL_TextureOps EGL_TextureBufferStream;
|
|
|
|
extern const EGL_TextureOps EGL_TextureFrameBuffer;
|
|
|
|
extern const EGL_TextureOps EGL_TextureDMABUF;
|
2020-05-29 05:48:59 +00:00
|
|
|
|
2021-08-09 04:08:10 +00:00
|
|
|
typedef struct RenderStep
|
|
|
|
{
|
2021-08-09 21:50:39 +00:00
|
|
|
EGL_Texture *owner;
|
|
|
|
|
2021-08-09 12:42:51 +00:00
|
|
|
bool enabled;
|
2021-08-09 04:08:10 +00:00
|
|
|
GLuint fb;
|
|
|
|
GLuint tex;
|
|
|
|
EGL_Shader * shader;
|
2021-08-09 07:48:07 +00:00
|
|
|
float scale;
|
|
|
|
|
|
|
|
unsigned int width, height;
|
2021-08-09 12:02:07 +00:00
|
|
|
|
|
|
|
GLint uInRes;
|
|
|
|
GLint uOutRes;
|
2021-08-09 04:08:10 +00:00
|
|
|
}
|
|
|
|
RenderStep;
|
|
|
|
|
|
|
|
bool egl_textureInit(EGL * egl, EGL_Texture ** texture_,
|
|
|
|
EGLDisplay * display, EGL_TexType type, bool streaming)
|
2018-09-23 05:48:44 +00:00
|
|
|
{
|
2021-08-02 13:37:33 +00:00
|
|
|
const EGL_TextureOps * ops;
|
2020-05-29 06:54:25 +00:00
|
|
|
|
2021-08-02 13:37:33 +00:00
|
|
|
switch(type)
|
2018-09-23 10:45:20 +00:00
|
|
|
{
|
2021-08-02 13:37:33 +00:00
|
|
|
case EGL_TEXTYPE_BUFFER:
|
|
|
|
ops = streaming ? &EGL_TextureBufferStream : &EGL_TextureBuffer;
|
2018-12-04 10:23:28 +00:00
|
|
|
break;
|
|
|
|
|
2021-08-02 13:37:33 +00:00
|
|
|
case EGL_TEXTYPE_FRAMEBUFFER:
|
|
|
|
assert(streaming);
|
|
|
|
ops = &EGL_TextureFrameBuffer;
|
2018-12-04 10:23:28 +00:00
|
|
|
break;
|
|
|
|
|
2021-08-02 13:37:33 +00:00
|
|
|
case EGL_TEXTYPE_DMABUF:
|
|
|
|
assert(streaming);
|
|
|
|
ops = &EGL_TextureDMABUF;
|
2020-10-11 08:22:31 +00:00
|
|
|
break;
|
|
|
|
|
2018-09-23 10:45:20 +00:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2021-08-09 04:08:10 +00:00
|
|
|
*texture_ = NULL;
|
|
|
|
if (!ops->init(texture_, display))
|
2021-08-02 13:37:33 +00:00
|
|
|
return false;
|
2020-05-21 01:44:56 +00:00
|
|
|
|
2021-08-09 04:08:10 +00:00
|
|
|
EGL_Texture * this = *texture_;
|
|
|
|
memcpy(&this->ops, ops, sizeof(*ops));
|
|
|
|
this->egl = egl;
|
|
|
|
|
|
|
|
glGenSamplers(1, &this->sampler);
|
|
|
|
glSamplerParameteri(this->sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
|
|
glSamplerParameteri(this->sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
|
|
glSamplerParameteri(this->sampler, GL_TEXTURE_WRAP_S , GL_CLAMP_TO_EDGE);
|
|
|
|
glSamplerParameteri(this->sampler, GL_TEXTURE_WRAP_T , GL_CLAMP_TO_EDGE);
|
|
|
|
|
2021-08-09 08:27:10 +00:00
|
|
|
this->scale = 1.0f;
|
2018-09-23 05:48:44 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-08-08 07:52:13 +00:00
|
|
|
void egl_textureFree(EGL_Texture ** tex)
|
2020-05-19 12:42:55 +00:00
|
|
|
{
|
2021-08-09 04:08:10 +00:00
|
|
|
EGL_Texture * this = *tex;
|
|
|
|
|
|
|
|
if (this->render)
|
|
|
|
{
|
|
|
|
RenderStep * step;
|
|
|
|
while(ll_shift(this->render, (void **)&step))
|
|
|
|
{
|
|
|
|
if (step->fb)
|
|
|
|
glDeleteFramebuffers(1, &step->fb);
|
|
|
|
|
|
|
|
glDeleteTextures(1, &step->tex);
|
|
|
|
free(step);
|
|
|
|
}
|
|
|
|
ll_free(this->render);
|
|
|
|
egl_modelFree(&this->model);
|
2021-08-09 08:28:52 +00:00
|
|
|
ringbuffer_free(&this->textures);
|
2021-08-09 12:02:07 +00:00
|
|
|
free(this->bindData);
|
2021-08-09 04:08:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
glDeleteSamplers(1, &this->sampler);
|
|
|
|
|
|
|
|
this->ops.free(this);
|
2021-08-02 13:37:33 +00:00
|
|
|
*tex = NULL;
|
2020-05-19 12:42:55 +00:00
|
|
|
}
|
|
|
|
|
2021-08-09 04:08:10 +00:00
|
|
|
bool setupRenderStep(EGL_Texture * this, RenderStep * step)
|
|
|
|
{
|
2021-08-09 07:48:07 +00:00
|
|
|
step->width = this->format.width * step->scale;
|
|
|
|
step->height = this->format.height * step->scale;
|
|
|
|
|
2021-08-09 04:08:10 +00:00
|
|
|
glBindTexture(GL_TEXTURE_2D, step->tex);
|
|
|
|
glTexImage2D(GL_TEXTURE_2D,
|
|
|
|
0,
|
|
|
|
this->format.intFormat,
|
2021-08-09 07:48:07 +00:00
|
|
|
step->width,
|
|
|
|
step->height,
|
2021-08-09 04:08:10 +00:00
|
|
|
0,
|
|
|
|
this->format.format,
|
|
|
|
this->format.dataType,
|
|
|
|
NULL);
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool egl_textureSetup(EGL_Texture * this, enum EGL_PixelFormat pixFmt,
|
2021-08-02 13:37:33 +00:00
|
|
|
size_t width, size_t height, size_t stride)
|
2018-09-23 05:48:44 +00:00
|
|
|
{
|
2021-08-02 13:37:33 +00:00
|
|
|
const struct EGL_TexSetup setup =
|
|
|
|
{
|
|
|
|
.pixFmt = pixFmt,
|
|
|
|
.width = width,
|
|
|
|
.height = height,
|
|
|
|
.stride = stride
|
|
|
|
};
|
2021-08-09 04:08:10 +00:00
|
|
|
this->size = height * stride;
|
|
|
|
|
|
|
|
if (!egl_texUtilGetFormat(&setup, &this->format))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
this->formatValid = true;
|
|
|
|
|
|
|
|
/* reconfigure any intermediate render steps */
|
|
|
|
if (this->render)
|
|
|
|
{
|
|
|
|
RenderStep * step;
|
|
|
|
for(ll_reset(this->render); ll_walk(this->render, (void **)&step); )
|
|
|
|
if (!setupRenderStep(this, step))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return this->ops.setup(this, &setup);
|
2018-09-23 05:48:44 +00:00
|
|
|
}
|
|
|
|
|
2021-08-09 04:08:10 +00:00
|
|
|
bool egl_textureUpdate(EGL_Texture * this, const uint8_t * buffer)
|
2019-10-01 13:17:20 +00:00
|
|
|
{
|
2021-08-02 13:37:33 +00:00
|
|
|
const struct EGL_TexUpdate update =
|
2020-05-19 12:42:55 +00:00
|
|
|
{
|
2021-08-02 13:37:33 +00:00
|
|
|
.type = EGL_TEXTYPE_BUFFER,
|
|
|
|
.buffer = buffer
|
|
|
|
};
|
2021-08-09 04:08:10 +00:00
|
|
|
|
|
|
|
if (this->ops.update(this, &update))
|
|
|
|
{
|
|
|
|
atomic_store(&this->updated, true);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2019-10-01 13:17:20 +00:00
|
|
|
}
|
|
|
|
|
2021-08-09 04:08:10 +00:00
|
|
|
bool egl_textureUpdateFromFrame(EGL_Texture * this,
|
2021-08-07 06:10:30 +00:00
|
|
|
const FrameBuffer * frame, const FrameDamageRect * damageRects,
|
|
|
|
int damageRectsCount)
|
2020-10-29 15:32:25 +00:00
|
|
|
{
|
2021-08-02 13:37:33 +00:00
|
|
|
const struct EGL_TexUpdate update =
|
2020-10-29 15:32:25 +00:00
|
|
|
{
|
2021-08-07 06:10:30 +00:00
|
|
|
.type = EGL_TEXTYPE_FRAMEBUFFER,
|
|
|
|
.frame = frame,
|
|
|
|
.rects = damageRects,
|
|
|
|
.rectCount = damageRectsCount,
|
2021-08-02 13:37:33 +00:00
|
|
|
};
|
2021-08-09 04:08:10 +00:00
|
|
|
|
|
|
|
if (this->ops.update(this, &update))
|
|
|
|
{
|
|
|
|
atomic_store(&this->updated, true);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2021-08-02 13:37:33 +00:00
|
|
|
}
|
2020-10-29 15:32:25 +00:00
|
|
|
|
2021-08-09 04:08:10 +00:00
|
|
|
bool egl_textureUpdateFromDMA(EGL_Texture * this,
|
2021-08-02 13:37:33 +00:00
|
|
|
const FrameBuffer * frame, const int dmaFd)
|
|
|
|
{
|
|
|
|
const struct EGL_TexUpdate update =
|
2020-12-31 01:58:40 +00:00
|
|
|
{
|
2021-08-02 13:37:33 +00:00
|
|
|
.type = EGL_TEXTYPE_DMABUF,
|
|
|
|
.dmaFD = dmaFd
|
|
|
|
};
|
2020-10-29 15:32:25 +00:00
|
|
|
|
|
|
|
/* wait for completion */
|
2021-08-09 04:08:10 +00:00
|
|
|
framebuffer_wait(frame, this->size);
|
2020-10-29 15:32:25 +00:00
|
|
|
|
2021-08-09 04:08:10 +00:00
|
|
|
if (this->ops.update(this, &update))
|
|
|
|
{
|
|
|
|
atomic_store(&this->updated, true);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2020-10-29 15:32:25 +00:00
|
|
|
}
|
|
|
|
|
2021-08-09 04:08:10 +00:00
|
|
|
enum EGL_TexStatus egl_textureProcess(EGL_Texture * this)
|
2018-09-23 05:48:44 +00:00
|
|
|
{
|
2021-08-09 04:08:10 +00:00
|
|
|
EGL_TexStatus status;
|
|
|
|
if ((status = this->ops.process(this)) == EGL_TEX_STATUS_OK)
|
|
|
|
{
|
|
|
|
if (atomic_exchange(&this->updated, false))
|
|
|
|
this->postProcessed = false;
|
|
|
|
}
|
|
|
|
return status;
|
2019-06-12 12:36:00 +00:00
|
|
|
}
|
|
|
|
|
2021-08-09 12:02:07 +00:00
|
|
|
typedef struct BindInfo
|
|
|
|
{
|
|
|
|
GLuint tex;
|
|
|
|
unsigned int width;
|
|
|
|
unsigned int height;
|
|
|
|
}
|
|
|
|
BindInfo;
|
|
|
|
|
|
|
|
typedef struct BindData
|
|
|
|
{
|
|
|
|
GLuint sampler;
|
2021-08-09 20:04:07 +00:00
|
|
|
GLuint dimensions[];
|
2021-08-09 12:02:07 +00:00
|
|
|
}
|
|
|
|
BindData;
|
|
|
|
|
2021-08-09 04:08:10 +00:00
|
|
|
static bool rbBindTexture(int index, void * value, void * udata)
|
2019-06-12 12:36:00 +00:00
|
|
|
{
|
2021-08-09 12:02:07 +00:00
|
|
|
BindInfo * bi = (BindInfo *)value;
|
|
|
|
BindData * bd = (BindData *)udata;
|
2021-08-09 04:08:10 +00:00
|
|
|
|
|
|
|
glActiveTexture(GL_TEXTURE0 + index);
|
2021-08-09 12:02:07 +00:00
|
|
|
glBindTexture(GL_TEXTURE_2D, bi->tex);
|
|
|
|
glBindSampler(0, bd->sampler);
|
|
|
|
bd->dimensions[index * 2 + 0] = bi->width;
|
|
|
|
bd->dimensions[index * 2 + 1] = bi->height;
|
2021-08-09 04:08:10 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum EGL_TexStatus egl_textureBind(EGL_Texture * this)
|
|
|
|
{
|
|
|
|
GLuint tex;
|
|
|
|
EGL_TexStatus status;
|
|
|
|
|
|
|
|
if (!this->render)
|
|
|
|
{
|
|
|
|
if ((status = this->ops.get(this, &tex)) != EGL_TEX_STATUS_OK)
|
|
|
|
return status;
|
|
|
|
|
|
|
|
glActiveTexture(GL_TEXTURE0);
|
|
|
|
glBindTexture(GL_TEXTURE_2D, tex);
|
|
|
|
glBindSampler(0, this->sampler);
|
|
|
|
return EGL_TEX_STATUS_OK;
|
|
|
|
}
|
|
|
|
|
2021-08-09 12:02:07 +00:00
|
|
|
if (this->bindDataSize < ll_count(this->render))
|
|
|
|
{
|
|
|
|
free(this->bindData);
|
|
|
|
|
|
|
|
BindData * bd = (BindData *)calloc(1, sizeof(struct BindData) +
|
2021-08-09 23:41:56 +00:00
|
|
|
sizeof(bd->dimensions[0]) * (ll_count(this->render)+1) * 2);
|
2021-08-09 12:02:07 +00:00
|
|
|
bd->sampler = this->sampler;
|
|
|
|
|
|
|
|
this->bindData = bd;
|
|
|
|
this->bindDataSize = ll_count(this->render);
|
|
|
|
}
|
|
|
|
|
|
|
|
BindData * bd = (BindData *)this->bindData;
|
2021-08-09 04:08:10 +00:00
|
|
|
RenderStep * step;
|
|
|
|
|
|
|
|
/* if the postProcessing has not yet been done */
|
|
|
|
if (!this->postProcessed)
|
|
|
|
{
|
2021-08-09 12:42:51 +00:00
|
|
|
ringbuffer_reset(this->textures);
|
|
|
|
|
2021-08-09 04:08:10 +00:00
|
|
|
if ((status = this->ops.get(this, &tex)) != EGL_TEX_STATUS_OK)
|
|
|
|
return status;
|
|
|
|
|
2021-08-09 12:02:07 +00:00
|
|
|
ringbuffer_push(this->textures, &(BindInfo) {
|
|
|
|
.tex = tex,
|
|
|
|
.width = this->format.width,
|
|
|
|
.height = this->format.height
|
|
|
|
});
|
|
|
|
|
|
|
|
ringbuffer_forEach(this->textures, rbBindTexture, bd, true);
|
2021-08-09 04:08:10 +00:00
|
|
|
|
2021-08-09 12:42:51 +00:00
|
|
|
bool cleanup = false;
|
2021-08-09 04:08:10 +00:00
|
|
|
for(ll_reset(this->render); ll_walk(this->render, (void **)&step); )
|
|
|
|
{
|
2021-08-09 12:42:51 +00:00
|
|
|
if (!step->enabled)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
cleanup = true;
|
|
|
|
|
2021-08-09 04:08:10 +00:00
|
|
|
/* create the framebuffer here as it must be in the same gl context as
|
|
|
|
* it's usage */
|
|
|
|
if (!step->fb)
|
|
|
|
{
|
|
|
|
glGenFramebuffers(1, &step->fb);
|
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, step->fb);
|
|
|
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
|
|
|
GL_TEXTURE_2D, step->tex, 0);
|
|
|
|
glDrawBuffers(1, &(GLenum){GL_COLOR_ATTACHMENT0});
|
|
|
|
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
|
|
|
{
|
|
|
|
DEBUG_ERROR("Failed to setup the shader framebuffer");
|
|
|
|
return EGL_TEX_STATUS_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, step->fb);
|
|
|
|
|
2021-08-09 07:48:07 +00:00
|
|
|
glViewport(0, 0, step->width, step->height);
|
2021-08-09 12:02:07 +00:00
|
|
|
|
|
|
|
/* use the shader (also configures it's set uniforms) */
|
2021-08-09 04:08:10 +00:00
|
|
|
egl_shaderUse(step->shader);
|
2021-08-09 12:02:07 +00:00
|
|
|
|
|
|
|
/* set the size uniforms */
|
|
|
|
glUniform2uiv(step->uInRes,
|
|
|
|
ringbuffer_getCount(this->textures), bd->dimensions);
|
|
|
|
glUniform2ui(step->uOutRes, step->width, step->height);
|
|
|
|
|
|
|
|
/* render the scene */
|
2021-08-09 04:08:10 +00:00
|
|
|
egl_modelRender(this->model);
|
|
|
|
|
2021-08-09 12:02:07 +00:00
|
|
|
/* push the details into the ringbuffer for the next pass */
|
|
|
|
ringbuffer_push(this->textures, &(BindInfo) {
|
|
|
|
.tex = step->tex,
|
|
|
|
.width = step->width,
|
|
|
|
.height = step->height
|
|
|
|
});
|
|
|
|
|
|
|
|
/* bind the textures for the next pass */
|
|
|
|
ringbuffer_forEach(this->textures, rbBindTexture, bd, true);
|
2021-08-09 04:08:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* restore the state and the viewport */
|
2021-08-09 12:42:51 +00:00
|
|
|
if (cleanup)
|
|
|
|
{
|
|
|
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
|
|
|
glUseProgram(0);
|
|
|
|
egl_resetViewport(this->egl);
|
|
|
|
}
|
2021-08-09 04:08:10 +00:00
|
|
|
|
|
|
|
this->postProcessed = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* bind the last texture */
|
2021-08-09 12:42:51 +00:00
|
|
|
BindInfo * bi = (BindInfo *)ringBuffer_getLastValue(this->textures);
|
2021-08-09 04:08:10 +00:00
|
|
|
glActiveTexture(GL_TEXTURE0);
|
2021-08-09 12:42:51 +00:00
|
|
|
glBindTexture(GL_TEXTURE_2D, bi->tex);
|
2021-08-09 04:08:10 +00:00
|
|
|
glBindSampler(0, this->sampler);
|
|
|
|
}
|
|
|
|
|
|
|
|
return EGL_TEX_STATUS_OK;
|
|
|
|
}
|
|
|
|
|
2021-08-09 12:42:51 +00:00
|
|
|
PostProcessHandle egl_textureAddFilter(EGL_Texture * this, EGL_Shader * shader,
|
|
|
|
float outputScale, bool enabled)
|
2021-08-09 04:08:10 +00:00
|
|
|
{
|
|
|
|
if (!this->render)
|
|
|
|
{
|
|
|
|
this->render = ll_new();
|
|
|
|
egl_modelInit(&this->model);
|
|
|
|
egl_modelSetDefault(this->model, false);
|
2021-08-09 12:02:07 +00:00
|
|
|
this->textures = ringbuffer_new(8, sizeof(BindInfo));
|
2021-08-09 04:08:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RenderStep * step = calloc(1, sizeof(*step));
|
|
|
|
glGenTextures(1, &step->tex);
|
2021-08-09 21:50:39 +00:00
|
|
|
step->owner = this;
|
2021-08-09 12:02:07 +00:00
|
|
|
step->shader = shader;
|
|
|
|
step->scale = outputScale;
|
|
|
|
step->uInRes = egl_shaderGetUniform(shader, "uInRes" );
|
|
|
|
step->uOutRes = egl_shaderGetUniform(shader, "uOutRes");
|
2021-08-09 12:42:51 +00:00
|
|
|
step->enabled = enabled;
|
2021-08-09 12:02:07 +00:00
|
|
|
|
|
|
|
this->scale = outputScale;
|
2021-08-09 04:08:10 +00:00
|
|
|
|
|
|
|
if (this->formatValid)
|
|
|
|
if (!setupRenderStep(this, step))
|
|
|
|
{
|
|
|
|
glDeleteTextures(1, &step->tex);
|
|
|
|
free(step);
|
2021-08-09 12:42:51 +00:00
|
|
|
return NULL;
|
2021-08-09 04:08:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ll_push(this->render, step);
|
2021-08-09 12:42:51 +00:00
|
|
|
return (PostProcessHandle)step;
|
|
|
|
}
|
|
|
|
|
|
|
|
void egl_textureEnableFilter(PostProcessHandle * handle, bool enable)
|
|
|
|
{
|
|
|
|
RenderStep * step = (RenderStep *)handle;
|
2021-08-09 21:50:39 +00:00
|
|
|
if (step->enabled == enable)
|
|
|
|
return;
|
|
|
|
|
2021-08-09 12:42:51 +00:00
|
|
|
step->enabled = enable;
|
2021-08-09 21:50:39 +00:00
|
|
|
egl_textureInvalidate(step->owner);
|
|
|
|
}
|
|
|
|
|
|
|
|
void egl_textureInvalidate(EGL_Texture * texture)
|
|
|
|
{
|
|
|
|
texture->postProcessed = false;
|
2020-04-14 03:27:07 +00:00
|
|
|
}
|
2021-08-09 08:22:28 +00:00
|
|
|
|
|
|
|
float egl_textureGetScale(EGL_Texture * this)
|
|
|
|
{
|
|
|
|
return this->scale;
|
|
|
|
}
|