[client] egl: replace monolithic EGLTexture with modular version

The way things were handled in EGLTexture is not only very hard to
follow, but broken. This change set breaks up EGLTexture into a modular
design making it easier to implement the various versions.

Note that DMABUF is currently broken and needs to be re-implemented.
This commit is contained in:
Geoffrey McRae
2021-08-02 23:37:33 +10:00
parent e23144aecd
commit 13d9c84dc9
19 changed files with 910 additions and 583 deletions

View File

@@ -24,34 +24,121 @@
#include "shader.h"
#include "common/framebuffer.h"
#include "util.h"
#include <EGL/egl.h>
#include <EGL/eglext.h>
typedef struct EGL_Texture EGL_Texture;
struct EGL_TextureOps;
enum EGL_PixelFormat
typedef struct EGL_Texture
{
const struct EGL_TextureOps * ops;
// needed for dmabuf
size_t size;
}
EGL_Texture;
typedef enum EGL_TexType
{
EGL_TEXTYPE_BUFFER,
EGL_TEXTYPE_FRAMEBUFFER,
EGL_TEXTYPE_DMABUF
}
EGL_TexType;
typedef enum EGL_PixelFormat
{
EGL_PF_RGBA,
EGL_PF_BGRA,
EGL_PF_RGBA10,
EGL_PF_RGBA16F,
EGL_PF_YUV420
};
EGL_PF_RGBA16F
}
EGL_PixelFormat;
enum EGL_TexStatus
typedef enum EGL_TexStatus
{
EGL_TEX_STATUS_NOTREADY,
EGL_TEX_STATUS_OK,
EGL_TEX_STATUS_ERROR
};
}
EGL_TexStatus;
bool egl_texture_init(EGL_Texture ** texture, EGLDisplay * display);
typedef struct EGL_TexSetup
{
/* the pixel format of the texture */
EGL_PixelFormat pixFmt;
/* the width of the texture in pixels */
size_t width;
/* the height of the texture in pixels */
size_t height;
/* the stide of the texture in bytes */
size_t stride;
}
EGL_TexSetup;
typedef struct EGL_TexUpdate
{
/* the type of this update */
EGL_TexType type;
union
{
/* EGL_TEXTURE_BUFFER */
const uint8_t * buffer;
/* EGL_TEXTURE_FRAMEBUFFER */
const FrameBuffer * frame;
/* EGL_TEXTURE_DMABUF */
int dmaFD;
};
}
EGL_TexUpdate;
typedef struct EGL_TextureOps
{
/* allocate & initialize an EGL_Texture */
bool (*init)(EGL_Texture ** texture, EGLDisplay * display);
/* free the EGL_Texture */
void (*free)(EGL_Texture * texture);
/* setup/reconfigure the texture format */
bool (*setup)(EGL_Texture * texture, const EGL_TexSetup * setup);
/* update the texture */
bool (*update)(EGL_Texture * texture, const EGL_TexUpdate * update);
/* called from a background job to prepare the texture for use before bind */
enum EGL_TexStatus (*process)(EGL_Texture * texture);
/* bind the texture for use */
enum EGL_TexStatus (*bind)(EGL_Texture * texture);
}
EGL_TextureOps;
bool egl_texture_init(EGL_Texture ** texture, EGLDisplay * display,
EGL_TexType type, bool streaming);
void egl_texture_free(EGL_Texture ** tex);
bool egl_texture_setup (EGL_Texture * texture, enum EGL_PixelFormat pixfmt, size_t width, size_t height, size_t stride, bool streaming, bool useDMA);
bool egl_texture_update (EGL_Texture * texture, const uint8_t * buffer);
bool egl_texture_update_from_frame(EGL_Texture * texture, const FrameBuffer * frame);
bool egl_texture_update_from_dma (EGL_Texture * texture, const FrameBuffer * frmame, const int dmaFd);
bool egl_texture_setup(EGL_Texture * texture, enum EGL_PixelFormat pixFmt,
size_t width, size_t height, size_t stride);
bool egl_texture_update (EGL_Texture * texture, const uint8_t * buffer);
bool egl_texture_update_from_frame(EGL_Texture * texture,
const FrameBuffer * frame);
bool egl_texture_update_from_dma(EGL_Texture * texture,
const FrameBuffer * frame, const int dmaFd);
enum EGL_TexStatus egl_texture_process(EGL_Texture * texture);
enum EGL_TexStatus egl_texture_bind (EGL_Texture * texture);
int egl_texture_count (EGL_Texture * texture);
enum EGL_TexStatus egl_texture_bind(EGL_Texture * texture);
int egl_texture_count(EGL_Texture * texture);