|
|
@@ -4260,6 +4260,58 @@ namespace bgfx { namespace gl
|
|
|
m_vcref.invalidate(s_renderGL->m_vaoStateCache);
|
|
|
}
|
|
|
|
|
|
+ static void texSubImage(
|
|
|
+ GLenum _target
|
|
|
+ , GLint _level
|
|
|
+ , GLint _xoffset
|
|
|
+ , GLint _yoffset
|
|
|
+ , GLint _zoffset
|
|
|
+ , GLsizei _width
|
|
|
+ , GLsizei _height
|
|
|
+ , GLsizei _depth
|
|
|
+ , GLenum _format
|
|
|
+ , GLenum _type
|
|
|
+ , const GLvoid* _data
|
|
|
+ )
|
|
|
+ {
|
|
|
+ if (_target == GL_TEXTURE_3D
|
|
|
+ || _target == GL_TEXTURE_2D_ARRAY
|
|
|
+ || _target == GL_TEXTURE_CUBE_MAP_ARRAY)
|
|
|
+ {
|
|
|
+ GL_CHECK(glTexSubImage3D(
|
|
|
+ _target
|
|
|
+ , _level
|
|
|
+ , _xoffset
|
|
|
+ , _yoffset
|
|
|
+ , _zoffset
|
|
|
+ , _width
|
|
|
+ , _height
|
|
|
+ , _depth
|
|
|
+ , _format
|
|
|
+ , _type
|
|
|
+ , _data
|
|
|
+ ) );
|
|
|
+ }
|
|
|
+ else if (_target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)
|
|
|
+ {
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ BX_UNUSED(_zoffset, _depth);
|
|
|
+ GL_CHECK(glTexSubImage2D(
|
|
|
+ _target
|
|
|
+ , _level
|
|
|
+ , _xoffset
|
|
|
+ , _yoffset
|
|
|
+ , _width
|
|
|
+ , _height
|
|
|
+ , _format
|
|
|
+ , _type
|
|
|
+ , _data
|
|
|
+ ) );
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
static void texImage(
|
|
|
GLenum _target
|
|
|
, uint32_t _msaaQuality
|
|
|
@@ -4274,9 +4326,7 @@ namespace bgfx { namespace gl
|
|
|
, const GLvoid* _data
|
|
|
)
|
|
|
{
|
|
|
- if (_target == GL_TEXTURE_3D
|
|
|
- || _target == GL_TEXTURE_2D_ARRAY
|
|
|
- || _target == GL_TEXTURE_CUBE_MAP_ARRAY)
|
|
|
+ if (_target == GL_TEXTURE_3D)
|
|
|
{
|
|
|
GL_CHECK(glTexImage3D(
|
|
|
_target
|
|
|
@@ -4291,6 +4341,11 @@ namespace bgfx { namespace gl
|
|
|
, _data
|
|
|
) );
|
|
|
}
|
|
|
+ else if (_target == GL_TEXTURE_2D_ARRAY
|
|
|
+ || _target == GL_TEXTURE_CUBE_MAP_ARRAY)
|
|
|
+ {
|
|
|
+ texSubImage(_target, _level, 0, 0, _depth, _width, _height, 1, _format, _type, _data);
|
|
|
+ }
|
|
|
else if (_target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)
|
|
|
{
|
|
|
}
|
|
|
@@ -4323,7 +4378,7 @@ namespace bgfx { namespace gl
|
|
|
BX_UNUSED(_msaaQuality, _depth, _border, _data);
|
|
|
}
|
|
|
|
|
|
- static void texSubImage(
|
|
|
+ static void compressedTexSubImage(
|
|
|
GLenum _target
|
|
|
, GLint _level
|
|
|
, GLint _xoffset
|
|
|
@@ -4333,17 +4388,13 @@ namespace bgfx { namespace gl
|
|
|
, GLsizei _height
|
|
|
, GLsizei _depth
|
|
|
, GLenum _format
|
|
|
- , GLenum _type
|
|
|
+ , GLsizei _imageSize
|
|
|
, const GLvoid* _data
|
|
|
)
|
|
|
{
|
|
|
- if (_target == GL_TEXTURE_3D
|
|
|
- || _target == GL_TEXTURE_2D_ARRAY
|
|
|
- || _target == GL_TEXTURE_CUBE_MAP_ARRAY)
|
|
|
+ if (_target == GL_TEXTURE_3D)
|
|
|
{
|
|
|
-BX_TRACE("zoffset %d, depth %d", _zoffset, _depth);
|
|
|
-
|
|
|
- GL_CHECK(glTexSubImage3D(
|
|
|
+ GL_CHECK(glCompressedTexSubImage3D(
|
|
|
_target
|
|
|
, _level
|
|
|
, _xoffset
|
|
|
@@ -4353,17 +4404,14 @@ BX_TRACE("zoffset %d, depth %d", _zoffset, _depth);
|
|
|
, _height
|
|
|
, _depth
|
|
|
, _format
|
|
|
- , _type
|
|
|
+ , _imageSize
|
|
|
, _data
|
|
|
) );
|
|
|
}
|
|
|
- else if (_target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)
|
|
|
- {
|
|
|
- }
|
|
|
else
|
|
|
{
|
|
|
BX_UNUSED(_zoffset, _depth);
|
|
|
- GL_CHECK(glTexSubImage2D(
|
|
|
+ GL_CHECK(glCompressedTexSubImage2D(
|
|
|
_target
|
|
|
, _level
|
|
|
, _xoffset
|
|
|
@@ -4371,7 +4419,7 @@ BX_TRACE("zoffset %d, depth %d", _zoffset, _depth);
|
|
|
, _width
|
|
|
, _height
|
|
|
, _format
|
|
|
- , _type
|
|
|
+ , _imageSize
|
|
|
, _data
|
|
|
) );
|
|
|
}
|
|
|
@@ -4389,9 +4437,7 @@ BX_TRACE("zoffset %d, depth %d", _zoffset, _depth);
|
|
|
, const GLvoid* _data
|
|
|
)
|
|
|
{
|
|
|
- if (_target == GL_TEXTURE_3D
|
|
|
- || _target == GL_TEXTURE_2D_ARRAY
|
|
|
- || _target == GL_TEXTURE_CUBE_MAP_ARRAY)
|
|
|
+ if (_target == GL_TEXTURE_3D)
|
|
|
{
|
|
|
GL_CHECK(glCompressedTexImage3D(
|
|
|
_target
|
|
|
@@ -4405,6 +4451,11 @@ BX_TRACE("zoffset %d, depth %d", _zoffset, _depth);
|
|
|
, _data
|
|
|
) );
|
|
|
}
|
|
|
+ else if (_target == GL_TEXTURE_2D_ARRAY
|
|
|
+ || _target == GL_TEXTURE_CUBE_MAP_ARRAY)
|
|
|
+ {
|
|
|
+ compressedTexSubImage(_target, _level, 0, 0, _depth, _width, _height, 1, _internalformat, _imageSize, _data);
|
|
|
+ }
|
|
|
else if (_target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)
|
|
|
{
|
|
|
}
|
|
|
@@ -4424,53 +4475,6 @@ BX_TRACE("zoffset %d, depth %d", _zoffset, _depth);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- static void compressedTexSubImage(
|
|
|
- GLenum _target
|
|
|
- , GLint _level
|
|
|
- , GLint _xoffset
|
|
|
- , GLint _yoffset
|
|
|
- , GLint _zoffset
|
|
|
- , GLsizei _width
|
|
|
- , GLsizei _height
|
|
|
- , GLsizei _depth
|
|
|
- , GLenum _format
|
|
|
- , GLsizei _imageSize
|
|
|
- , const GLvoid* _data
|
|
|
- )
|
|
|
- {
|
|
|
- if (_target == GL_TEXTURE_3D)
|
|
|
- {
|
|
|
- GL_CHECK(glCompressedTexSubImage3D(
|
|
|
- _target
|
|
|
- , _level
|
|
|
- , _xoffset
|
|
|
- , _yoffset
|
|
|
- , _zoffset
|
|
|
- , _width
|
|
|
- , _height
|
|
|
- , _depth
|
|
|
- , _format
|
|
|
- , _imageSize
|
|
|
- , _data
|
|
|
- ) );
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- BX_UNUSED(_zoffset, _depth);
|
|
|
- GL_CHECK(glCompressedTexSubImage2D(
|
|
|
- _target
|
|
|
- , _level
|
|
|
- , _xoffset
|
|
|
- , _yoffset
|
|
|
- , _width
|
|
|
- , _height
|
|
|
- , _format
|
|
|
- , _imageSize
|
|
|
- , _data
|
|
|
- ) );
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
bool TextureGL::init(GLenum _target, uint32_t _width, uint32_t _height, uint32_t _depth, uint8_t _numMips, uint32_t _flags)
|
|
|
{
|
|
|
m_target = _target;
|
|
|
@@ -4483,6 +4487,10 @@ BX_TRACE("zoffset %d, depth %d", _zoffset, _depth);
|
|
|
|
|
|
const bool writeOnly = 0 != (m_flags&BGFX_TEXTURE_RT_WRITE_ONLY);
|
|
|
const bool computeWrite = 0 != (m_flags&BGFX_TEXTURE_COMPUTE_WRITE );
|
|
|
+ const bool textureArray = false
|
|
|
+ || _target == GL_TEXTURE_2D_ARRAY
|
|
|
+ || _target == GL_TEXTURE_CUBE_MAP_ARRAY
|
|
|
+ ;
|
|
|
|
|
|
if (!writeOnly)
|
|
|
{
|
|
|
@@ -4512,6 +4520,17 @@ BX_TRACE("zoffset %d, depth %d", _zoffset, _depth);
|
|
|
m_type = tfiRgba8.m_type;
|
|
|
}
|
|
|
|
|
|
+ if (textureArray)
|
|
|
+ {
|
|
|
+ GL_CHECK(glTexStorage3D(_target
|
|
|
+ , _numMips
|
|
|
+ , s_textureFormat[m_textureFormat].m_internalFmt
|
|
|
+ , m_width
|
|
|
+ , m_height
|
|
|
+ , _depth
|
|
|
+ ) );
|
|
|
+ }
|
|
|
+
|
|
|
if (computeWrite)
|
|
|
{
|
|
|
if (_target == GL_TEXTURE_3D)
|
|
|
@@ -4638,7 +4657,8 @@ BX_TRACE("zoffset %d, depth %d", _zoffset, _depth);
|
|
|
target = GL_TEXTURE_3D;
|
|
|
}
|
|
|
|
|
|
- if (1 < numLayers)
|
|
|
+ const bool textureArray = 1 < numLayers;
|
|
|
+ if (textureArray)
|
|
|
{
|
|
|
switch (target)
|
|
|
{
|
|
|
@@ -4713,6 +4733,10 @@ BX_TRACE("zoffset %d, depth %d", _zoffset, _depth);
|
|
|
uint32_t width = textureWidth;
|
|
|
uint32_t height = textureHeight;
|
|
|
uint32_t depth = imageContainer.m_depth;
|
|
|
+ GLenum imageTarget = imageContainer.m_cubeMap && !textureArray
|
|
|
+ ? target+side
|
|
|
+ : target
|
|
|
+ ;
|
|
|
|
|
|
for (uint8_t lod = 0, num = numMips; lod < num; ++lod)
|
|
|
{
|
|
|
@@ -4720,7 +4744,7 @@ BX_TRACE("zoffset %d, depth %d", _zoffset, _depth);
|
|
|
height = bx::uint32_max(1, height);
|
|
|
depth = 1 < imageContainer.m_depth
|
|
|
? bx::uint32_max(1, depth)
|
|
|
- : imageContainer.m_numLayers
|
|
|
+ : side
|
|
|
;
|
|
|
|
|
|
ImageMip mip;
|
|
|
@@ -4729,7 +4753,7 @@ BX_TRACE("zoffset %d, depth %d", _zoffset, _depth);
|
|
|
if (compressed
|
|
|
&& !convert)
|
|
|
{
|
|
|
- compressedTexImage(target+side
|
|
|
+ compressedTexImage(imageTarget
|
|
|
, lod
|
|
|
, internalFmt
|
|
|
, width
|
|
|
@@ -4756,7 +4780,7 @@ BX_TRACE("zoffset %d, depth %d", _zoffset, _depth);
|
|
|
data = temp;
|
|
|
}
|
|
|
|
|
|
- texImage(target+side
|
|
|
+ texImage(imageTarget
|
|
|
, msaaQuality
|
|
|
, lod
|
|
|
, internalFmt
|
|
|
@@ -4779,7 +4803,7 @@ BX_TRACE("zoffset %d, depth %d", _zoffset, _depth);
|
|
|
* 4*4*getBitsPerPixel(TextureFormat::Enum(m_textureFormat) )/8
|
|
|
;
|
|
|
|
|
|
- compressedTexImage(target+side
|
|
|
+ compressedTexImage(imageTarget
|
|
|
, lod
|
|
|
, internalFmt
|
|
|
, width
|
|
|
@@ -4792,7 +4816,7 @@ BX_TRACE("zoffset %d, depth %d", _zoffset, _depth);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- texImage(target+side
|
|
|
+ texImage(imageTarget
|
|
|
, msaaQuality
|
|
|
, lod
|
|
|
, internalFmt
|