mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
GLES31: Fixed image format test.
This commit is contained in:
parent
6b8964acf7
commit
11868f704a
3 changed files with 57 additions and 32 deletions
|
@ -24,34 +24,36 @@ namespace bgfx { namespace gl
|
|||
|
||||
typedef void (*EGLPROC)(void);
|
||||
|
||||
typedef EGLPROC (EGLAPIENTRY* PFNEGLGETPROCADDRESSPROC)(const char *procname);
|
||||
typedef EGLBoolean (EGLAPIENTRY* PFNEGLSWAPINTERVALPROC)(EGLDisplay dpy, EGLint interval);
|
||||
typedef EGLBoolean (EGLAPIENTRY* PFNEGLMAKECURRENTPROC)(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
|
||||
typedef EGLContext (EGLAPIENTRY* PFNEGLCREATECONTEXTPROC)(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list);
|
||||
typedef EGLSurface (EGLAPIENTRY* PFNEGLCREATEWINDOWSURFACEPROC)(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);
|
||||
typedef EGLBoolean (EGLAPIENTRY* PFNEGLCHOOSECONFIGPROC)(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
|
||||
typedef EGLBoolean (EGLAPIENTRY* PFNEGLINITIALIZEPROC)(EGLDisplay dpy, EGLint *major, EGLint *minor);
|
||||
typedef EGLint (EGLAPIENTRY* PFNEGLGETERRORPROC)(void);
|
||||
typedef EGLDisplay (EGLAPIENTRY* PFNEGLGETDISPLAYPROC)(EGLNativeDisplayType display_id);
|
||||
typedef EGLBoolean (EGLAPIENTRY* PFNEGLTERMINATEPROC)(EGLDisplay dpy);
|
||||
typedef EGLBoolean (EGLAPIENTRY* PFNEGLDESTROYSURFACEPROC)(EGLDisplay dpy, EGLSurface surface);
|
||||
typedef EGLBoolean (EGLAPIENTRY* PFNEGLDESTROYCONTEXTPROC)(EGLDisplay dpy, EGLContext ctx);
|
||||
typedef EGLBoolean (EGLAPIENTRY* PFNEGLSWAPBUFFERSPROC)(EGLDisplay dpy, EGLSurface surface);
|
||||
typedef EGLBoolean (EGLAPIENTRY* PFNEGLCHOOSECONFIGPROC)(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
|
||||
typedef EGLContext (EGLAPIENTRY* PFNEGLCREATECONTEXTPROC)(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list);
|
||||
typedef EGLSurface (EGLAPIENTRY* PFNEGLCREATEWINDOWSURFACEPROC)(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);
|
||||
typedef EGLint (EGLAPIENTRY* PFNEGLGETERRORPROC)(void);
|
||||
typedef EGLDisplay (EGLAPIENTRY* PFNEGLGETDISPLAYPROC)(EGLNativeDisplayType display_id);
|
||||
typedef EGLPROC (EGLAPIENTRY* PFNEGLGETPROCADDRESSPROC)(const char *procname);
|
||||
typedef EGLBoolean (EGLAPIENTRY* PFNEGLINITIALIZEPROC)(EGLDisplay dpy, EGLint *major, EGLint *minor);
|
||||
typedef EGLBoolean (EGLAPIENTRY* PFNEGLMAKECURRENTPROC)(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
|
||||
typedef EGLBoolean (EGLAPIENTRY* PFNEGLDESTROYCONTEXTPROC)(EGLDisplay dpy, EGLContext ctx);
|
||||
typedef EGLBoolean (EGLAPIENTRY* PFNEGLDESTROYSURFACEPROC)(EGLDisplay dpy, EGLSurface surface);
|
||||
typedef const char* (EGLAPIENTRY* PGNEGLQUERYSTRINGPROC)(EGLDisplay dpy, EGLint name);
|
||||
typedef EGLBoolean (EGLAPIENTRY* PFNEGLSWAPBUFFERSPROC)(EGLDisplay dpy, EGLSurface surface);
|
||||
typedef EGLBoolean (EGLAPIENTRY* PFNEGLSWAPINTERVALPROC)(EGLDisplay dpy, EGLint interval);
|
||||
typedef EGLBoolean (EGLAPIENTRY* PFNEGLTERMINATEPROC)(EGLDisplay dpy);
|
||||
|
||||
#define EGL_IMPORT \
|
||||
EGL_IMPORT_FUNC(PFNEGLGETPROCADDRESSPROC, eglGetProcAddress); \
|
||||
EGL_IMPORT_FUNC(PFNEGLSWAPINTERVALPROC, eglSwapInterval); \
|
||||
EGL_IMPORT_FUNC(PFNEGLMAKECURRENTPROC, eglMakeCurrent); \
|
||||
EGL_IMPORT_FUNC(PFNEGLCHOOSECONFIGPROC, eglChooseConfig); \
|
||||
EGL_IMPORT_FUNC(PFNEGLCREATECONTEXTPROC, eglCreateContext); \
|
||||
EGL_IMPORT_FUNC(PFNEGLCREATEWINDOWSURFACEPROC, eglCreateWindowSurface); \
|
||||
EGL_IMPORT_FUNC(PFNEGLCHOOSECONFIGPROC, eglChooseConfig); \
|
||||
EGL_IMPORT_FUNC(PFNEGLINITIALIZEPROC, eglInitialize); \
|
||||
EGL_IMPORT_FUNC(PFNEGLGETERRORPROC, eglGetError); \
|
||||
EGL_IMPORT_FUNC(PFNEGLGETDISPLAYPROC, eglGetDisplay); \
|
||||
EGL_IMPORT_FUNC(PFNEGLTERMINATEPROC, eglTerminate); \
|
||||
EGL_IMPORT_FUNC(PFNEGLDESTROYSURFACEPROC, eglDestroySurface); \
|
||||
EGL_IMPORT_FUNC(PFNEGLGETERRORPROC, eglGetError); \
|
||||
EGL_IMPORT_FUNC(PFNEGLGETPROCADDRESSPROC, eglGetProcAddress); \
|
||||
EGL_IMPORT_FUNC(PFNEGLDESTROYCONTEXTPROC, eglDestroyContext); \
|
||||
EGL_IMPORT_FUNC(PFNEGLSWAPBUFFERSPROC, eglSwapBuffers);
|
||||
EGL_IMPORT_FUNC(PFNEGLDESTROYSURFACEPROC, eglDestroySurface); \
|
||||
EGL_IMPORT_FUNC(PFNEGLINITIALIZEPROC, eglInitialize); \
|
||||
EGL_IMPORT_FUNC(PFNEGLMAKECURRENTPROC, eglMakeCurrent); \
|
||||
EGL_IMPORT_FUNC(PGNEGLQUERYSTRINGPROC, eglQueryString); \
|
||||
EGL_IMPORT_FUNC(PFNEGLSWAPBUFFERSPROC, eglSwapBuffers); \
|
||||
EGL_IMPORT_FUNC(PFNEGLSWAPINTERVALPROC, eglSwapInterval); \
|
||||
EGL_IMPORT_FUNC(PFNEGLTERMINATEPROC, eglTerminate);
|
||||
|
||||
#define EGL_IMPORT_FUNC(_proto, _func) _proto _func
|
||||
EGL_IMPORT
|
||||
|
|
|
@ -1005,14 +1005,14 @@ namespace bgfx { namespace gl
|
|||
GLuint id;
|
||||
GL_CHECK(glGenTextures(1, &id) );
|
||||
GL_CHECK(glBindTexture(GL_TEXTURE_2D, id) );
|
||||
initTestTexture(_format);
|
||||
GL_CHECK(glTexStorage2D(GL_TEXTURE_2D, 1, s_imageFormat[_format], 16, 16) );
|
||||
|
||||
glBindImageTexture(0
|
||||
, id
|
||||
, 0
|
||||
, GL_FALSE
|
||||
, 0
|
||||
, GL_READ_WRITE
|
||||
, GL_WRITE_ONLY
|
||||
, s_imageFormat[_format]
|
||||
);
|
||||
GLenum err = glGetError();
|
||||
|
@ -3539,14 +3539,15 @@ namespace bgfx { namespace gl
|
|||
}
|
||||
}
|
||||
|
||||
bool TextureGL::init(GLenum _target, uint32_t _width, uint32_t _height, uint8_t _format, uint8_t _numMips, uint32_t _flags)
|
||||
bool TextureGL::init(GLenum _target, uint32_t _width, uint32_t _height, uint32_t _depth, uint8_t _format, uint8_t _numMips, uint32_t _flags)
|
||||
{
|
||||
m_target = _target;
|
||||
m_target = _target;
|
||||
m_numMips = _numMips;
|
||||
m_flags = _flags;
|
||||
m_currentFlags = UINT32_MAX;
|
||||
m_width = _width;
|
||||
m_height = _height;
|
||||
m_flags = _flags;
|
||||
m_width = _width;
|
||||
m_height = _height;
|
||||
m_depth = _depth;
|
||||
m_currentFlags = UINT32_MAX;
|
||||
m_requestedFormat = _format;
|
||||
m_textureFormat = _format;
|
||||
|
||||
|
@ -3585,7 +3586,25 @@ namespace bgfx { namespace gl
|
|||
|
||||
if (computeWrite)
|
||||
{
|
||||
GL_CHECK(glTexStorage2D(_target, _numMips, s_textureFormat[m_textureFormat].m_internalFmt, m_width, m_height));
|
||||
if (_target == GL_TEXTURE_3D)
|
||||
{
|
||||
GL_CHECK(glTexStorage3D(_target
|
||||
, _numMips
|
||||
, s_textureFormat[m_textureFormat].m_internalFmt
|
||||
, m_width
|
||||
, m_height
|
||||
, _depth
|
||||
) );
|
||||
}
|
||||
else
|
||||
{
|
||||
GL_CHECK(glTexStorage2D(_target
|
||||
, _numMips
|
||||
, s_textureFormat[m_textureFormat].m_internalFmt
|
||||
, m_width
|
||||
, m_height
|
||||
) );
|
||||
}
|
||||
}
|
||||
|
||||
setSamplerState(_flags);
|
||||
|
@ -3658,10 +3677,12 @@ namespace bgfx { namespace gl
|
|||
numMips -= startLod;
|
||||
uint32_t textureWidth;
|
||||
uint32_t textureHeight;
|
||||
uint32_t textureDepth;
|
||||
{
|
||||
const ImageBlockInfo& ibi = getBlockInfo(TextureFormat::Enum(imageContainer.m_format) );
|
||||
textureWidth = bx::uint32_max(ibi.blockWidth, imageContainer.m_width >>startLod);
|
||||
textureHeight = bx::uint32_max(ibi.blockHeight, imageContainer.m_height>>startLod);
|
||||
textureDepth = imageContainer.m_depth;
|
||||
}
|
||||
|
||||
GLenum target = GL_TEXTURE_2D;
|
||||
|
@ -3677,6 +3698,7 @@ namespace bgfx { namespace gl
|
|||
if (!init(target
|
||||
, textureWidth
|
||||
, textureHeight
|
||||
, textureDepth
|
||||
, imageContainer.m_format
|
||||
, numMips
|
||||
, _flags
|
||||
|
|
|
@ -971,7 +971,7 @@ namespace bgfx { namespace gl
|
|||
{
|
||||
}
|
||||
|
||||
bool init(GLenum _target, uint32_t _width, uint32_t _height, uint8_t _format, uint8_t _numMips, uint32_t _flags);
|
||||
bool init(GLenum _target, uint32_t _width, uint32_t _height, uint32_t _depth, uint8_t _format, uint8_t _numMips, uint32_t _flags);
|
||||
void create(const Memory* _mem, uint32_t _flags, uint8_t _skip);
|
||||
void destroy();
|
||||
void update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem);
|
||||
|
@ -987,6 +987,7 @@ namespace bgfx { namespace gl
|
|||
uint32_t m_currentFlags;
|
||||
uint32_t m_width;
|
||||
uint32_t m_height;
|
||||
uint32_t m_depth;
|
||||
uint8_t m_numMips;
|
||||
uint8_t m_requestedFormat;
|
||||
uint8_t m_textureFormat;
|
||||
|
|
Loading…
Reference in a new issue