GLES31: Fixed image format test.

This commit is contained in:
Branimir Karadžić 2015-05-18 20:24:37 -07:00
parent 6b8964acf7
commit 11868f704a
3 changed files with 57 additions and 32 deletions

View file

@ -24,34 +24,36 @@ namespace bgfx { namespace gl
typedef void (*EGLPROC)(void); typedef void (*EGLPROC)(void);
typedef EGLPROC (EGLAPIENTRY* PFNEGLGETPROCADDRESSPROC)(const char *procname); typedef EGLBoolean (EGLAPIENTRY* PFNEGLCHOOSECONFIGPROC)(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
typedef EGLBoolean (EGLAPIENTRY* PFNEGLSWAPINTERVALPROC)(EGLDisplay dpy, EGLint interval); typedef EGLContext (EGLAPIENTRY* PFNEGLCREATECONTEXTPROC)(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list);
typedef EGLBoolean (EGLAPIENTRY* PFNEGLMAKECURRENTPROC)(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx); typedef EGLSurface (EGLAPIENTRY* PFNEGLCREATEWINDOWSURFACEPROC)(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list);
typedef EGLContext (EGLAPIENTRY* PFNEGLCREATECONTEXTPROC)(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint *attrib_list); typedef EGLint (EGLAPIENTRY* PFNEGLGETERRORPROC)(void);
typedef EGLSurface (EGLAPIENTRY* PFNEGLCREATEWINDOWSURFACEPROC)(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint *attrib_list); typedef EGLDisplay (EGLAPIENTRY* PFNEGLGETDISPLAYPROC)(EGLNativeDisplayType display_id);
typedef EGLBoolean (EGLAPIENTRY* PFNEGLCHOOSECONFIGPROC)(EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config); typedef EGLPROC (EGLAPIENTRY* PFNEGLGETPROCADDRESSPROC)(const char *procname);
typedef EGLBoolean (EGLAPIENTRY* PFNEGLINITIALIZEPROC)(EGLDisplay dpy, EGLint *major, EGLint *minor); typedef EGLBoolean (EGLAPIENTRY* PFNEGLINITIALIZEPROC)(EGLDisplay dpy, EGLint *major, EGLint *minor);
typedef EGLint (EGLAPIENTRY* PFNEGLGETERRORPROC)(void); typedef EGLBoolean (EGLAPIENTRY* PFNEGLMAKECURRENTPROC)(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
typedef EGLDisplay (EGLAPIENTRY* PFNEGLGETDISPLAYPROC)(EGLNativeDisplayType display_id); typedef EGLBoolean (EGLAPIENTRY* PFNEGLDESTROYCONTEXTPROC)(EGLDisplay dpy, EGLContext ctx);
typedef EGLBoolean (EGLAPIENTRY* PFNEGLTERMINATEPROC)(EGLDisplay dpy); typedef EGLBoolean (EGLAPIENTRY* PFNEGLDESTROYSURFACEPROC)(EGLDisplay dpy, EGLSurface surface);
typedef EGLBoolean (EGLAPIENTRY* PFNEGLDESTROYSURFACEPROC)(EGLDisplay dpy, EGLSurface surface); typedef const char* (EGLAPIENTRY* PGNEGLQUERYSTRINGPROC)(EGLDisplay dpy, EGLint name);
typedef EGLBoolean (EGLAPIENTRY* PFNEGLDESTROYCONTEXTPROC)(EGLDisplay dpy, EGLContext ctx); typedef EGLBoolean (EGLAPIENTRY* PFNEGLSWAPBUFFERSPROC)(EGLDisplay dpy, EGLSurface surface);
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 \ #define EGL_IMPORT \
EGL_IMPORT_FUNC(PFNEGLGETPROCADDRESSPROC, eglGetProcAddress); \ EGL_IMPORT_FUNC(PFNEGLCHOOSECONFIGPROC, eglChooseConfig); \
EGL_IMPORT_FUNC(PFNEGLSWAPINTERVALPROC, eglSwapInterval); \
EGL_IMPORT_FUNC(PFNEGLMAKECURRENTPROC, eglMakeCurrent); \
EGL_IMPORT_FUNC(PFNEGLCREATECONTEXTPROC, eglCreateContext); \ EGL_IMPORT_FUNC(PFNEGLCREATECONTEXTPROC, eglCreateContext); \
EGL_IMPORT_FUNC(PFNEGLCREATEWINDOWSURFACEPROC, eglCreateWindowSurface); \ 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(PFNEGLGETDISPLAYPROC, eglGetDisplay); \
EGL_IMPORT_FUNC(PFNEGLTERMINATEPROC, eglTerminate); \ EGL_IMPORT_FUNC(PFNEGLGETERRORPROC, eglGetError); \
EGL_IMPORT_FUNC(PFNEGLDESTROYSURFACEPROC, eglDestroySurface); \ EGL_IMPORT_FUNC(PFNEGLGETPROCADDRESSPROC, eglGetProcAddress); \
EGL_IMPORT_FUNC(PFNEGLDESTROYCONTEXTPROC, eglDestroyContext); \ 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 #define EGL_IMPORT_FUNC(_proto, _func) _proto _func
EGL_IMPORT EGL_IMPORT

View file

@ -1005,14 +1005,14 @@ namespace bgfx { namespace gl
GLuint id; GLuint id;
GL_CHECK(glGenTextures(1, &id) ); GL_CHECK(glGenTextures(1, &id) );
GL_CHECK(glBindTexture(GL_TEXTURE_2D, id) ); GL_CHECK(glBindTexture(GL_TEXTURE_2D, id) );
initTestTexture(_format); GL_CHECK(glTexStorage2D(GL_TEXTURE_2D, 1, s_imageFormat[_format], 16, 16) );
glBindImageTexture(0 glBindImageTexture(0
, id , id
, 0 , 0
, GL_FALSE , GL_FALSE
, 0 , 0
, GL_READ_WRITE , GL_WRITE_ONLY
, s_imageFormat[_format] , s_imageFormat[_format]
); );
GLenum err = glGetError(); 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_numMips = _numMips;
m_flags = _flags; m_flags = _flags;
m_currentFlags = UINT32_MAX; m_width = _width;
m_width = _width; m_height = _height;
m_height = _height; m_depth = _depth;
m_currentFlags = UINT32_MAX;
m_requestedFormat = _format; m_requestedFormat = _format;
m_textureFormat = _format; m_textureFormat = _format;
@ -3585,7 +3586,25 @@ namespace bgfx { namespace gl
if (computeWrite) 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); setSamplerState(_flags);
@ -3658,10 +3677,12 @@ namespace bgfx { namespace gl
numMips -= startLod; numMips -= startLod;
uint32_t textureWidth; uint32_t textureWidth;
uint32_t textureHeight; uint32_t textureHeight;
uint32_t textureDepth;
{ {
const ImageBlockInfo& ibi = getBlockInfo(TextureFormat::Enum(imageContainer.m_format) ); const ImageBlockInfo& ibi = getBlockInfo(TextureFormat::Enum(imageContainer.m_format) );
textureWidth = bx::uint32_max(ibi.blockWidth, imageContainer.m_width >>startLod); textureWidth = bx::uint32_max(ibi.blockWidth, imageContainer.m_width >>startLod);
textureHeight = bx::uint32_max(ibi.blockHeight, imageContainer.m_height>>startLod); textureHeight = bx::uint32_max(ibi.blockHeight, imageContainer.m_height>>startLod);
textureDepth = imageContainer.m_depth;
} }
GLenum target = GL_TEXTURE_2D; GLenum target = GL_TEXTURE_2D;
@ -3677,6 +3698,7 @@ namespace bgfx { namespace gl
if (!init(target if (!init(target
, textureWidth , textureWidth
, textureHeight , textureHeight
, textureDepth
, imageContainer.m_format , imageContainer.m_format
, numMips , numMips
, _flags , _flags

View file

@ -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 create(const Memory* _mem, uint32_t _flags, uint8_t _skip);
void destroy(); 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); 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_currentFlags;
uint32_t m_width; uint32_t m_width;
uint32_t m_height; uint32_t m_height;
uint32_t m_depth;
uint8_t m_numMips; uint8_t m_numMips;
uint8_t m_requestedFormat; uint8_t m_requestedFormat;
uint8_t m_textureFormat; uint8_t m_textureFormat;