mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-24 16:48:18 -05:00
Added ability to specify arbitrary source pitch when uploading textures.
Added reference weldVertices implementation.
This commit is contained in:
parent
2374ea3a15
commit
b584873b50
17 changed files with 356 additions and 221 deletions
|
@ -293,8 +293,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
|
|||
const uint32_t textureSide = 2048;
|
||||
|
||||
bgfx::TextureHandle textureCube =
|
||||
bgfx::createTextureCube(6
|
||||
, textureSide
|
||||
bgfx::createTextureCube(textureSide
|
||||
, 1
|
||||
, bgfx::TextureFormat::BGRA8
|
||||
, BGFX_TEXTURE_MIN_POINT|BGFX_TEXTURE_MAG_POINT|BGFX_TEXTURE_MIP_POINT
|
||||
|
|
|
@ -274,8 +274,7 @@ Atlas::Atlas(uint16_t _textureSize, uint16_t _maxRegionsCount)
|
|||
m_textureBuffer = new uint8_t[ _textureSize * _textureSize * 6 * 4 ];
|
||||
memset(m_textureBuffer, 0, _textureSize * _textureSize * 6 * 4);
|
||||
|
||||
m_textureHandle = bgfx::createTextureCube(6
|
||||
, _textureSize
|
||||
m_textureHandle = bgfx::createTextureCube(_textureSize
|
||||
, 1
|
||||
, bgfx::TextureFormat::BGRA8
|
||||
);
|
||||
|
@ -298,8 +297,7 @@ Atlas::Atlas(uint16_t _textureSize, const uint8_t* _textureBuffer, uint16_t _reg
|
|||
memcpy(m_regions, _regionBuffer, _regionCount * sizeof(AtlasRegion) );
|
||||
memcpy(m_textureBuffer, _textureBuffer, getTextureBufferSize() );
|
||||
|
||||
m_textureHandle = bgfx::createTextureCube(6
|
||||
, _textureSize
|
||||
m_textureHandle = bgfx::createTextureCube(_textureSize
|
||||
, 1
|
||||
, bgfx::TextureFormat::BGRA8
|
||||
, BGFX_TEXTURE_NONE
|
||||
|
|
|
@ -492,7 +492,7 @@ inline void mtxViewFlipHandedness(float* __restrict _dst, const float* __restric
|
|||
_dst[15] = _src[15];
|
||||
}
|
||||
|
||||
inline void calcPlane(float _result[4], float _va[3], float _vb[3], float _vc[3])
|
||||
inline void calcNormal(float _result[3], float _va[3], float _vb[3], float _vc[3])
|
||||
{
|
||||
float ba[3];
|
||||
vec3Sub(ba, _vb, _va);
|
||||
|
@ -503,8 +503,13 @@ inline void calcPlane(float _result[4], float _va[3], float _vb[3], float _vc[3]
|
|||
float baxca[3];
|
||||
vec3Cross(baxca, ba, ca);
|
||||
|
||||
vec3Norm(_result, baxca);
|
||||
}
|
||||
|
||||
inline void calcPlane(float _result[4], float _va[3], float _vb[3], float _vc[3])
|
||||
{
|
||||
float normal[3];
|
||||
vec3Norm(normal, baxca);
|
||||
calcNormal(normal, _va, _vb, _vc);
|
||||
|
||||
_result[0] = normal[0];
|
||||
_result[1] = normal[1];
|
||||
|
|
|
@ -525,6 +525,9 @@ namespace bgfx
|
|||
///
|
||||
void add(Attrib::Enum _attrib, uint8_t _num, AttribType::Enum _type, bool _normalized = false, bool _asInt = false);
|
||||
|
||||
/// Skip _num bytes in vertex stream.
|
||||
void skip(uint8_t _num);
|
||||
|
||||
/// Decode attribute.
|
||||
void decode(Attrib::Enum _attrib, uint8_t& _num, AttribType::Enum& _type, bool& _normalized, bool& _asInt) const;
|
||||
|
||||
|
@ -578,11 +581,12 @@ namespace bgfx
|
|||
///
|
||||
/// @param _width Width of input image (pixels).
|
||||
/// @param _height Height of input image (pixels).
|
||||
/// @param _pitch Pitch of input image (bytes).
|
||||
/// @param _src Source image.
|
||||
/// @param _dst Destination image. Must be the same size as input image.
|
||||
/// _dst might be pointer to the same memory as _src.
|
||||
///
|
||||
void imageSwizzleBgra8(uint32_t _width, uint32_t _height, const void* _src, void* _dst);
|
||||
void imageSwizzleBgra8(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
|
||||
|
||||
/// Downsample RGBA8 image with 2x2 pixel average filter.
|
||||
///
|
||||
|
@ -859,23 +863,45 @@ namespace bgfx
|
|||
|
||||
/// Create Cube texture.
|
||||
///
|
||||
/// @param _sides
|
||||
/// @param _width
|
||||
/// @param _size
|
||||
/// @param _numMips
|
||||
/// @param _format
|
||||
/// @param _flags
|
||||
/// @param _mem
|
||||
///
|
||||
TextureHandle createTextureCube(uint16_t _sides, uint16_t _width, uint8_t _numMips, TextureFormat::Enum _format, uint32_t _flags = BGFX_TEXTURE_NONE, const Memory* _mem = NULL);
|
||||
TextureHandle createTextureCube(uint16_t _size, uint8_t _numMips, TextureFormat::Enum _format, uint32_t _flags = BGFX_TEXTURE_NONE, const Memory* _mem = NULL);
|
||||
|
||||
/// Update 2D texture.
|
||||
void updateTexture2D(TextureHandle _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const Memory* _mem);
|
||||
///
|
||||
/// @param _handle
|
||||
/// @param _mip
|
||||
/// @param _x
|
||||
/// @param _y
|
||||
/// @param _width
|
||||
/// @param _height
|
||||
/// @param _mem
|
||||
/// @param _pitch Pitch of input image (bytes). When _pitch is set to
|
||||
/// UINT16_MAX, it will be calculated internally based on _width.
|
||||
///
|
||||
void updateTexture2D(TextureHandle _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const Memory* _mem, uint16_t _pitch = UINT16_MAX);
|
||||
|
||||
/// Update 3D texture.
|
||||
///
|
||||
/// @param _handle
|
||||
/// @param _mip
|
||||
/// @param _x
|
||||
/// @param _y
|
||||
/// @param _z
|
||||
/// @param _width
|
||||
/// @param _height
|
||||
/// @param _depth
|
||||
/// @param _mem
|
||||
///
|
||||
void updateTexture3D(TextureHandle _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _width, uint16_t _height, uint16_t _depth, const Memory* _mem);
|
||||
|
||||
/// Update Cube texture.
|
||||
///
|
||||
/// @param _handle
|
||||
/// @param _side Cubemap side, where 0 is +X, 1 is -X, 2 is +Y, 3 is
|
||||
/// -Y, 4 is +Z, and 5 is -Z.
|
||||
///
|
||||
|
@ -896,7 +922,16 @@ namespace bgfx
|
|||
/// | +---->+x |
|
||||
/// +----------+
|
||||
///
|
||||
void updateTextureCube(TextureHandle _handle, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const Memory* _mem);
|
||||
/// @param _mip
|
||||
/// @param _x
|
||||
/// @param _y
|
||||
/// @param _width
|
||||
/// @param _height
|
||||
/// @param _mem
|
||||
/// @param _pitch Pitch of input image (bytes). When _pitch is set to
|
||||
/// UINT16_MAX, it will be calculated internally based on _width.
|
||||
///
|
||||
void updateTextureCube(TextureHandle _handle, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const Memory* _mem, uint16_t _pitch = UINT16_MAX);
|
||||
|
||||
/// Destroy texture.
|
||||
void destroyTexture(TextureHandle _handle);
|
||||
|
|
32
src/bgfx.cpp
32
src/bgfx.cpp
|
@ -1113,6 +1113,9 @@ namespace bgfx
|
|||
uint16_t depth;
|
||||
_cmdbuf.read(depth);
|
||||
|
||||
uint16_t pitch;
|
||||
_cmdbuf.read(pitch);
|
||||
|
||||
Memory* mem;
|
||||
_cmdbuf.read(mem);
|
||||
|
||||
|
@ -1127,7 +1130,7 @@ namespace bgfx
|
|||
rendererUpdateTextureBegin(handle, side, mip);
|
||||
}
|
||||
|
||||
rendererUpdateTexture(handle, side, mip, rect, zz, depth, mem);
|
||||
rendererUpdateTexture(handle, side, mip, rect, zz, depth, pitch, mem);
|
||||
|
||||
release(mem);
|
||||
}
|
||||
|
@ -1452,7 +1455,12 @@ namespace bgfx
|
|||
uint8_t mip;
|
||||
_cmdbuf.read(mip);
|
||||
|
||||
_cmdbuf.skip(sizeof(Rect)+sizeof(uint16_t)+sizeof(uint16_t)+sizeof(Memory*) );
|
||||
_cmdbuf.skip(sizeof(Rect)
|
||||
+ sizeof(uint16_t)
|
||||
+ sizeof(uint16_t)
|
||||
+ sizeof(uint16_t)
|
||||
+ sizeof(Memory*)
|
||||
);
|
||||
|
||||
uint32_t key = (handle.idx<<16)
|
||||
| (side<<8)
|
||||
|
@ -1907,7 +1915,7 @@ namespace bgfx
|
|||
return s_ctx->createTexture(mem, _flags, NULL);
|
||||
}
|
||||
|
||||
TextureHandle createTextureCube(uint16_t _sides, uint16_t _width, uint8_t _numMips, TextureFormat::Enum _format, uint32_t _flags, const Memory* _mem)
|
||||
TextureHandle createTextureCube(uint16_t _size, uint8_t _numMips, TextureFormat::Enum _format, uint32_t _flags, const Memory* _mem)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
|
||||
|
@ -1915,7 +1923,7 @@ namespace bgfx
|
|||
if (NULL != _mem)
|
||||
{
|
||||
TextureInfo ti;
|
||||
calcTextureSize(ti, _width, _width, 1, _numMips, _format);
|
||||
calcTextureSize(ti, _size, _size, 1, _numMips, _format);
|
||||
BX_CHECK(ti.storageSize*_sides == _mem->size
|
||||
, "createTextureCube: Texture storage size doesn't match passed memory size (storage size: %d, memory size: %d)"
|
||||
, ti.storageSize*_sides
|
||||
|
@ -1933,9 +1941,9 @@ namespace bgfx
|
|||
|
||||
TextureCreate tc;
|
||||
tc.m_flags = _flags;
|
||||
tc.m_width = _width;
|
||||
tc.m_height = _width;
|
||||
tc.m_sides = _sides;
|
||||
tc.m_width = _size;
|
||||
tc.m_height = _size;
|
||||
tc.m_sides = 6;
|
||||
tc.m_depth = 0;
|
||||
tc.m_numMips = _numMips;
|
||||
tc.m_format = uint8_t(_format);
|
||||
|
@ -1952,7 +1960,7 @@ namespace bgfx
|
|||
s_ctx->destroyTexture(_handle);
|
||||
}
|
||||
|
||||
void updateTexture2D(TextureHandle _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const Memory* _mem)
|
||||
void updateTexture2D(TextureHandle _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const Memory* _mem, uint16_t _pitch)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
BX_CHECK(NULL != _mem, "_mem can't be NULL");
|
||||
|
@ -1963,7 +1971,7 @@ namespace bgfx
|
|||
}
|
||||
else
|
||||
{
|
||||
s_ctx->updateTexture(_handle, 0, _mip, _x, _y, 0, _width, _height, 1, _mem);
|
||||
s_ctx->updateTexture(_handle, 0, _mip, _x, _y, 0, _width, _height, 1, _pitch, _mem);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1979,11 +1987,11 @@ namespace bgfx
|
|||
}
|
||||
else
|
||||
{
|
||||
s_ctx->updateTexture(_handle, 0, _mip, _x, _y, _z, _width, _height, _depth, _mem);
|
||||
s_ctx->updateTexture(_handle, 0, _mip, _x, _y, _z, _width, _height, _depth, UINT16_MAX, _mem);
|
||||
}
|
||||
}
|
||||
|
||||
void updateTextureCube(TextureHandle _handle, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const Memory* _mem)
|
||||
void updateTextureCube(TextureHandle _handle, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const Memory* _mem, uint16_t _pitch)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
BX_CHECK(NULL != _mem, "_mem can't be NULL");
|
||||
|
@ -1995,7 +2003,7 @@ namespace bgfx
|
|||
}
|
||||
else
|
||||
{
|
||||
s_ctx->updateTexture(_handle, _side, _mip, _x, _y, 0, _width, _height, 1, _mem);
|
||||
s_ctx->updateTexture(_handle, _side, _mip, _x, _y, 0, _width, _height, 1, _pitch, _mem);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2192,7 +2192,7 @@ namespace bgfx
|
|||
m_submit->free(_handle);
|
||||
}
|
||||
|
||||
BGFX_API_FUNC(void updateTexture(TextureHandle _handle, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _width, uint16_t _height, uint16_t _depth, const Memory* _mem) )
|
||||
BGFX_API_FUNC(void updateTexture(TextureHandle _handle, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _width, uint16_t _height, uint16_t _depth, uint16_t _pitch, const Memory* _mem) )
|
||||
{
|
||||
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::UpdateTexture);
|
||||
cmdbuf.write(_handle);
|
||||
|
@ -2206,6 +2206,7 @@ namespace bgfx
|
|||
cmdbuf.write(rect);
|
||||
cmdbuf.write(_z);
|
||||
cmdbuf.write(_depth);
|
||||
cmdbuf.write(_pitch);
|
||||
cmdbuf.write(_mem);
|
||||
}
|
||||
|
||||
|
@ -2581,7 +2582,7 @@ namespace bgfx
|
|||
void rendererDestroyProgram(FragmentShaderHandle _handle);
|
||||
void rendererCreateTexture(TextureHandle _handle, Memory* _mem, uint32_t _flags);
|
||||
void rendererUpdateTextureBegin(TextureHandle _handle, uint8_t _side, uint8_t _mip);
|
||||
void rendererUpdateTexture(TextureHandle _handle, uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, const Memory* _mem);
|
||||
void rendererUpdateTexture(TextureHandle _handle, uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem);
|
||||
void rendererUpdateTextureEnd();
|
||||
void rendererDestroyTexture(TextureHandle _handle);
|
||||
void rendererCreateRenderTarget(RenderTargetHandle _handle, uint16_t _width, uint16_t _height, uint32_t _flags, uint32_t _textureFlags);
|
||||
|
|
119
src/image.cpp
119
src/image.cpp
|
@ -198,25 +198,29 @@ namespace bgfx
|
|||
}
|
||||
}
|
||||
|
||||
void imageSwizzleBgra8Ref(uint32_t _width, uint32_t _height, const void* _src, void* _dst)
|
||||
void imageSwizzleBgra8Ref(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst)
|
||||
{
|
||||
const uint8_t* src = (uint8_t*) _src;
|
||||
const uint8_t* next = src + _pitch;
|
||||
uint8_t* dst = (uint8_t*)_dst;
|
||||
|
||||
for (uint32_t xx = 0, num = _width*_height; xx < num; ++xx, src += 4, dst += 4)
|
||||
for (uint32_t yy = 0; yy < _height; ++yy, src = next, next += _pitch)
|
||||
{
|
||||
uint8_t rr = src[0];
|
||||
uint8_t gg = src[1];
|
||||
uint8_t bb = src[2];
|
||||
uint8_t aa = src[3];
|
||||
dst[0] = bb;
|
||||
dst[1] = gg;
|
||||
dst[2] = rr;
|
||||
dst[3] = aa;
|
||||
for (uint32_t xx = 0; xx < _width; ++xx, src += 4, dst += 4)
|
||||
{
|
||||
uint8_t rr = src[0];
|
||||
uint8_t gg = src[1];
|
||||
uint8_t bb = src[2];
|
||||
uint8_t aa = src[3];
|
||||
dst[0] = bb;
|
||||
dst[1] = gg;
|
||||
dst[2] = rr;
|
||||
dst[3] = aa;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void imageSwizzleBgra8(uint32_t _width, uint32_t _height, const void* _src, void* _dst)
|
||||
void imageSwizzleBgra8(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst)
|
||||
{
|
||||
// Test can we do four 4-byte pixels at the time.
|
||||
if (0 != (_width&0x3)
|
||||
|
@ -228,29 +232,33 @@ namespace bgfx
|
|||
BX_WARN(bx::isPtrAligned(_src, 16), "Source %p is not 16-byte aligned.", _src);
|
||||
BX_WARN(bx::isPtrAligned(_dst, 16), "Destination %p is not 16-byte aligned.", _dst);
|
||||
BX_WARN(_width < 4, "Image width must be multiple of 4 (width %d).", _width);
|
||||
imageSwizzleBgra8Ref(_width, _height, _src, _dst);
|
||||
imageSwizzleBgra8Ref(_width, _height, _pitch, _src, _dst);
|
||||
return;
|
||||
}
|
||||
|
||||
const uint32_t dstpitch = _width*4;
|
||||
|
||||
using namespace bx;
|
||||
|
||||
const float4_t mf0f0 = float4_isplat(0xff00ff00);
|
||||
const float4_t m0f0f = float4_isplat(0x00ff00ff);
|
||||
const uint8_t* src = (uint8_t*) _src;
|
||||
const uint8_t* next = src + _pitch;
|
||||
uint8_t* dst = (uint8_t*)_dst;
|
||||
|
||||
for (uint32_t xx = 0, num = dstpitch/16*_height; xx < num; ++xx, src += 16, dst += 16)
|
||||
const uint32_t width = _width/4;
|
||||
|
||||
for (uint32_t yy = 0; yy < _height; ++yy, src = next, next += _pitch)
|
||||
{
|
||||
const float4_t tabgr = float4_ld(src);
|
||||
const float4_t t00ab = float4_srl(tabgr, 16);
|
||||
const float4_t tgr00 = float4_sll(tabgr, 16);
|
||||
const float4_t tgrab = float4_or(t00ab, tgr00);
|
||||
const float4_t ta0g0 = float4_and(tabgr, mf0f0);
|
||||
const float4_t t0r0b = float4_and(tgrab, m0f0f);
|
||||
const float4_t targb = float4_or(ta0g0, t0r0b);
|
||||
float4_st(dst, targb);
|
||||
for (uint32_t xx = 0; xx < width; ++xx, src += 16, dst += 16)
|
||||
{
|
||||
const float4_t tabgr = float4_ld(src);
|
||||
const float4_t t00ab = float4_srl(tabgr, 16);
|
||||
const float4_t tgr00 = float4_sll(tabgr, 16);
|
||||
const float4_t tgrab = float4_or(t00ab, tgr00);
|
||||
const float4_t ta0g0 = float4_and(tabgr, mf0f0);
|
||||
const float4_t t0r0b = float4_and(tgrab, m0f0f);
|
||||
const float4_t targb = float4_or(ta0g0, t0r0b);
|
||||
float4_st(dst, targb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1336,13 +1344,12 @@ namespace bgfx
|
|||
return imageParse(_imageContainer, &reader);
|
||||
}
|
||||
|
||||
void imageDecodeToBgra8(uint8_t* _dst, const uint8_t* _src, uint32_t _width, uint32_t _height, uint8_t _type)
|
||||
void imageDecodeToBgra8(uint8_t* _dst, const uint8_t* _src, uint32_t _width, uint32_t _height, uint32_t _pitch, uint8_t _type)
|
||||
{
|
||||
const uint8_t* src = _src;
|
||||
|
||||
uint32_t width = _width/4;
|
||||
uint32_t width = _width/4;
|
||||
uint32_t height = _height/4;
|
||||
uint32_t pitch = _width*4;
|
||||
|
||||
uint8_t temp[16*4];
|
||||
|
||||
|
@ -1356,11 +1363,11 @@ namespace bgfx
|
|||
decodeBlockDxt1(temp, src);
|
||||
src += 8;
|
||||
|
||||
uint8_t* dst = &_dst[(yy*pitch+xx*4)*4];
|
||||
memcpy(&dst[0*pitch], &temp[ 0], 16);
|
||||
memcpy(&dst[1*pitch], &temp[16], 16);
|
||||
memcpy(&dst[2*pitch], &temp[32], 16);
|
||||
memcpy(&dst[3*pitch], &temp[48], 16);
|
||||
uint8_t* dst = &_dst[(yy*_pitch+xx*4)*4];
|
||||
memcpy(&dst[0*_pitch], &temp[ 0], 16);
|
||||
memcpy(&dst[1*_pitch], &temp[16], 16);
|
||||
memcpy(&dst[2*_pitch], &temp[32], 16);
|
||||
memcpy(&dst[3*_pitch], &temp[48], 16);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1375,11 +1382,11 @@ namespace bgfx
|
|||
decodeBlockDxt(temp, src);
|
||||
src += 8;
|
||||
|
||||
uint8_t* dst = &_dst[(yy*pitch+xx*4)*4];
|
||||
memcpy(&dst[0*pitch], &temp[ 0], 16);
|
||||
memcpy(&dst[1*pitch], &temp[16], 16);
|
||||
memcpy(&dst[2*pitch], &temp[32], 16);
|
||||
memcpy(&dst[3*pitch], &temp[48], 16);
|
||||
uint8_t* dst = &_dst[(yy*_pitch+xx*4)*4];
|
||||
memcpy(&dst[0*_pitch], &temp[ 0], 16);
|
||||
memcpy(&dst[1*_pitch], &temp[16], 16);
|
||||
memcpy(&dst[2*_pitch], &temp[32], 16);
|
||||
memcpy(&dst[3*_pitch], &temp[48], 16);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1394,11 +1401,11 @@ namespace bgfx
|
|||
decodeBlockDxt(temp, src);
|
||||
src += 8;
|
||||
|
||||
uint8_t* dst = &_dst[(yy*pitch+xx*4)*4];
|
||||
memcpy(&dst[0*pitch], &temp[ 0], 16);
|
||||
memcpy(&dst[1*pitch], &temp[16], 16);
|
||||
memcpy(&dst[2*pitch], &temp[32], 16);
|
||||
memcpy(&dst[3*pitch], &temp[48], 16);
|
||||
uint8_t* dst = &_dst[(yy*_pitch+xx*4)*4];
|
||||
memcpy(&dst[0*_pitch], &temp[ 0], 16);
|
||||
memcpy(&dst[1*_pitch], &temp[16], 16);
|
||||
memcpy(&dst[2*_pitch], &temp[32], 16);
|
||||
memcpy(&dst[3*_pitch], &temp[48], 16);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1411,11 +1418,11 @@ namespace bgfx
|
|||
decodeBlockDxt45A(temp, src);
|
||||
src += 8;
|
||||
|
||||
uint8_t* dst = &_dst[(yy*pitch+xx*4)*4];
|
||||
memcpy(&dst[0*pitch], &temp[ 0], 16);
|
||||
memcpy(&dst[1*pitch], &temp[16], 16);
|
||||
memcpy(&dst[2*pitch], &temp[32], 16);
|
||||
memcpy(&dst[3*pitch], &temp[48], 16);
|
||||
uint8_t* dst = &_dst[(yy*_pitch+xx*4)*4];
|
||||
memcpy(&dst[0*_pitch], &temp[ 0], 16);
|
||||
memcpy(&dst[1*_pitch], &temp[16], 16);
|
||||
memcpy(&dst[2*_pitch], &temp[32], 16);
|
||||
memcpy(&dst[3*_pitch], &temp[48], 16);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1439,11 +1446,11 @@ namespace bgfx
|
|||
temp[ii*4+3] = 0;
|
||||
}
|
||||
|
||||
uint8_t* dst = &_dst[(yy*pitch+xx*4)*4];
|
||||
memcpy(&dst[0*pitch], &temp[ 0], 16);
|
||||
memcpy(&dst[1*pitch], &temp[16], 16);
|
||||
memcpy(&dst[2*pitch], &temp[32], 16);
|
||||
memcpy(&dst[3*pitch], &temp[48], 16);
|
||||
uint8_t* dst = &_dst[(yy*_pitch+xx*4)*4];
|
||||
memcpy(&dst[0*_pitch], &temp[ 0], 16);
|
||||
memcpy(&dst[1*_pitch], &temp[16], 16);
|
||||
memcpy(&dst[2*_pitch], &temp[32], 16);
|
||||
memcpy(&dst[3*_pitch], &temp[48], 16);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -1457,11 +1464,11 @@ namespace bgfx
|
|||
decodeBlockEtc12(temp, src);
|
||||
src += 8;
|
||||
|
||||
uint8_t* dst = &_dst[(yy*pitch+xx*4)*4];
|
||||
memcpy(&dst[0*pitch], &temp[ 0], 16);
|
||||
memcpy(&dst[1*pitch], &temp[16], 16);
|
||||
memcpy(&dst[2*pitch], &temp[32], 16);
|
||||
memcpy(&dst[3*pitch], &temp[48], 16);
|
||||
uint8_t* dst = &_dst[(yy*_pitch+xx*4)*4];
|
||||
memcpy(&dst[0*_pitch], &temp[ 0], 16);
|
||||
memcpy(&dst[1*_pitch], &temp[16], 16);
|
||||
memcpy(&dst[2*_pitch], &temp[32], 16);
|
||||
memcpy(&dst[3*_pitch], &temp[48], 16);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace bgfx
|
|||
void imageRgba8Downsample2x2(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
|
||||
|
||||
///
|
||||
void imageSwizzleBgra8(uint32_t _width, uint32_t _height, const void* _src, void* _dst);
|
||||
void imageSwizzleBgra8(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst);
|
||||
|
||||
///
|
||||
void imageWriteTga(bx::WriterI* _writer, uint32_t _width, uint32_t _height, uint32_t _srcPitch, const void* _src, bool _grayscale, bool _yflip);
|
||||
|
@ -64,7 +64,7 @@ namespace bgfx
|
|||
bool imageParse(ImageContainer& _imageContainer, const void* _data, uint32_t _size);
|
||||
|
||||
///
|
||||
void imageDecodeToBgra8(uint8_t* _dst, const uint8_t* _src, uint32_t _width, uint32_t _height, uint8_t _type);
|
||||
void imageDecodeToBgra8(uint8_t* _dst, const uint8_t* _src, uint32_t _width, uint32_t _height, uint32_t _pitch, uint8_t _type);
|
||||
|
||||
///
|
||||
bool imageGetRawData(const ImageContainer& _dds, uint8_t _side, uint8_t _index, const void* _data, uint32_t _size, ImageMip& _mip);
|
||||
|
|
|
@ -1832,7 +1832,7 @@ namespace bgfx
|
|||
;
|
||||
}
|
||||
|
||||
void Texture::update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, const Memory* _mem)
|
||||
void Texture::update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem)
|
||||
{
|
||||
ID3D11DeviceContext* deviceCtx = s_renderCtx->m_deviceCtx;
|
||||
|
||||
|
@ -1844,10 +1844,10 @@ namespace bgfx
|
|||
box.front = _z;
|
||||
box.back = box.front + _depth;
|
||||
|
||||
uint32_t subres = _mip + (_side * m_numMips);
|
||||
|
||||
uint32_t bpp = getBitsPerPixel(TextureFormat::Enum(m_textureFormat) );
|
||||
uint32_t srcpitch = _rect.m_width*bpp/8;
|
||||
const uint32_t subres = _mip + (_side * m_numMips);
|
||||
const uint32_t bpp = getBitsPerPixel(TextureFormat::Enum(m_textureFormat) );
|
||||
const uint32_t rectpitch = _rect.m_width*bpp/8;
|
||||
const uint32_t srcpitch = UINT16_MAX == _pitch ? rectpitch : _pitch;
|
||||
|
||||
const bool convert = m_textureFormat != m_requestedFormat;
|
||||
|
||||
|
@ -1856,8 +1856,8 @@ namespace bgfx
|
|||
|
||||
if (convert)
|
||||
{
|
||||
uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, srcpitch*_rect.m_height);
|
||||
imageDecodeToBgra8(temp, data, _rect.m_width, _rect.m_height, m_requestedFormat);
|
||||
uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, rectpitch*_rect.m_height);
|
||||
imageDecodeToBgra8(temp, data, _rect.m_width, _rect.m_height, srcpitch, m_requestedFormat);
|
||||
data = temp;
|
||||
}
|
||||
|
||||
|
@ -2091,9 +2091,9 @@ namespace bgfx
|
|||
{
|
||||
}
|
||||
|
||||
void Context::rendererUpdateTexture(TextureHandle _handle, uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, const Memory* _mem)
|
||||
void Context::rendererUpdateTexture(TextureHandle _handle, uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem)
|
||||
{
|
||||
s_renderCtx->m_textures[_handle.idx].update(_side, _mip, _rect, _z, _depth, _mem);
|
||||
s_renderCtx->m_textures[_handle.idx].update(_side, _mip, _rect, _z, _depth, _pitch, _mem);
|
||||
}
|
||||
|
||||
void Context::rendererUpdateTextureEnd()
|
||||
|
|
|
@ -1606,7 +1606,7 @@ namespace bgfx
|
|||
uint32_t srcpitch = mipWidth*bpp/8;
|
||||
|
||||
uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, srcpitch*mipHeight);
|
||||
imageDecodeToBgra8(temp, mip.m_data, mip.m_width, mip.m_height, mip.m_format);
|
||||
imageDecodeToBgra8(temp, mip.m_data, mip.m_width, mip.m_height, srcpitch, mip.m_format);
|
||||
|
||||
uint32_t dstpitch = pitch;
|
||||
for (uint32_t yy = 0; yy < height; ++yy)
|
||||
|
@ -1620,7 +1620,7 @@ namespace bgfx
|
|||
}
|
||||
else
|
||||
{
|
||||
imageDecodeToBgra8(bits, mip.m_data, mip.m_width, mip.m_height, mip.m_format);
|
||||
imageDecodeToBgra8(bits, mip.m_data, mip.m_width, mip.m_height, pitch, mip.m_format);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1650,11 +1650,12 @@ namespace bgfx
|
|||
s_renderCtx->m_updateTextureBits = lock(_side, _mip, s_renderCtx->m_updateTexturePitch, slicePitch);
|
||||
}
|
||||
|
||||
void Texture::update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, const Memory* _mem)
|
||||
void Texture::update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem)
|
||||
{
|
||||
uint32_t bpp = getBitsPerPixel(TextureFormat::Enum(m_textureFormat) );
|
||||
uint32_t srcpitch = _rect.m_width*bpp/8;
|
||||
uint32_t dstpitch = s_renderCtx->m_updateTexturePitch;
|
||||
const uint32_t bpp = getBitsPerPixel(TextureFormat::Enum(m_textureFormat) );
|
||||
const uint32_t rectpitch = _rect.m_width*bpp/8;
|
||||
const uint32_t srcpitch = UINT16_MAX == _pitch ? rectpitch : _pitch;
|
||||
const uint32_t dstpitch = s_renderCtx->m_updateTexturePitch;
|
||||
uint8_t* bits = s_renderCtx->m_updateTextureBits + _rect.m_y*dstpitch + _rect.m_x*bpp/8;
|
||||
|
||||
const bool convert = m_textureFormat != m_requestedFormat;
|
||||
|
@ -1664,8 +1665,8 @@ namespace bgfx
|
|||
|
||||
if (convert)
|
||||
{
|
||||
uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, srcpitch*_rect.m_height);
|
||||
imageDecodeToBgra8(temp, data, _rect.m_width, _rect.m_height, m_requestedFormat);
|
||||
uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, rectpitch*_rect.m_height);
|
||||
imageDecodeToBgra8(temp, data, _rect.m_width, _rect.m_height, srcpitch, m_requestedFormat);
|
||||
data = temp;
|
||||
}
|
||||
|
||||
|
@ -2117,9 +2118,9 @@ namespace bgfx
|
|||
s_renderCtx->m_updateTexture->updateBegin(_side, _mip);
|
||||
}
|
||||
|
||||
void Context::rendererUpdateTexture(TextureHandle /*_handle*/, uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, const Memory* _mem)
|
||||
void Context::rendererUpdateTexture(TextureHandle /*_handle*/, uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem)
|
||||
{
|
||||
s_renderCtx->m_updateTexture->update(_side, _mip, _rect, _z, _depth, _mem);
|
||||
s_renderCtx->m_updateTexture->update(_side, _mip, _rect, _z, _depth, _pitch, _mem);
|
||||
}
|
||||
|
||||
void Context::rendererUpdateTextureEnd()
|
||||
|
|
|
@ -317,7 +317,7 @@ namespace bgfx
|
|||
}
|
||||
|
||||
void updateBegin(uint8_t _side, uint8_t _mip);
|
||||
void update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, 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);
|
||||
void updateEnd();
|
||||
void commit(uint8_t _stage, uint32_t _flags = BGFX_SAMPLER_DEFAULT_FLAGS);
|
||||
|
||||
|
|
|
@ -265,6 +265,7 @@ namespace bgfx
|
|||
EXT_texture_swizzle,
|
||||
EXT_texture_type_2_10_10_10_REV,
|
||||
EXT_timer_query,
|
||||
EXT_unpack_subimage,
|
||||
IMG_multisampled_render_to_texture,
|
||||
IMG_read_format,
|
||||
IMG_shader_binary,
|
||||
|
@ -337,6 +338,7 @@ namespace bgfx
|
|||
{ "GL_EXT_texture_swizzle", false, true },
|
||||
{ "GL_EXT_texture_type_2_10_10_10_REV", false, true },
|
||||
{ "GL_EXT_timer_query", false, true },
|
||||
{ "GL_EXT_unpack_subimage", false, true },
|
||||
{ "GL_IMG_multisampled_render_to_texture", false, true },
|
||||
{ "GL_IMG_read_format", false, true },
|
||||
{ "GL_IMG_shader_binary", false, true },
|
||||
|
@ -785,7 +787,7 @@ namespace bgfx
|
|||
|
||||
if (GL_RGBA == m_readPixelsFmt)
|
||||
{
|
||||
imageSwizzleBgra8(width, height, data, data);
|
||||
imageSwizzleBgra8(width, height, width*4, data, data);
|
||||
}
|
||||
|
||||
g_callback->screenShot(_filePath
|
||||
|
@ -1443,13 +1445,13 @@ namespace bgfx
|
|||
|
||||
if (convert)
|
||||
{
|
||||
imageDecodeToBgra8(temp, mip.m_data, mip.m_width, mip.m_height, mip.m_format);
|
||||
imageDecodeToBgra8(temp, mip.m_data, mip.m_width, mip.m_height, mip.m_width*4, mip.m_format);
|
||||
data = temp;
|
||||
}
|
||||
|
||||
if (swizzle)
|
||||
{
|
||||
imageSwizzleBgra8(width, height, data, temp);
|
||||
imageSwizzleBgra8(width, height, mip.m_width*4, data, temp);
|
||||
data = temp;
|
||||
}
|
||||
|
||||
|
@ -1599,26 +1601,40 @@ namespace bgfx
|
|||
}
|
||||
}
|
||||
|
||||
void Texture::update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, const Memory* _mem)
|
||||
void Texture::update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem)
|
||||
{
|
||||
BX_UNUSED(_z, _depth);
|
||||
|
||||
const uint32_t bpp = getBitsPerPixel(TextureFormat::Enum(m_textureFormat) );
|
||||
const uint32_t rectpitch = _rect.m_width*bpp/8;
|
||||
uint32_t srcpitch = UINT16_MAX == _pitch ? rectpitch : _pitch;
|
||||
|
||||
GL_CHECK(glBindTexture(m_target, m_id) );
|
||||
GL_CHECK(glPixelStorei(GL_UNPACK_ALIGNMENT, 1) );
|
||||
|
||||
if (!!BGFX_CONFIG_RENDERER_OPENGL
|
||||
|| s_extension[Extension::EXT_unpack_subimage].m_supported)
|
||||
{
|
||||
GL_CHECK(glPixelStorei(GL_UNPACK_ROW_LENGTH, srcpitch*8/bpp) );
|
||||
}
|
||||
else
|
||||
{
|
||||
BX_CHECK(false, "There is no fallback for GLES2 when GL_EXT_unpack_subimage extension is not available.");
|
||||
}
|
||||
|
||||
GLenum target = GL_TEXTURE_CUBE_MAP == m_target ? GL_TEXTURE_CUBE_MAP_POSITIVE_X : m_target;
|
||||
|
||||
const bool swizzle = GL_RGBA == m_fmt && !s_renderCtx->m_textureSwizzleSupport;
|
||||
const bool convert = m_textureFormat != m_requestedFormat;
|
||||
const bool compressed = TextureFormat::Unknown > m_textureFormat;
|
||||
|
||||
uint32_t width = _rect.m_width;
|
||||
uint32_t height = _rect.m_height;
|
||||
const uint32_t width = _rect.m_width;
|
||||
const uint32_t height = _rect.m_height;
|
||||
|
||||
uint8_t* temp = NULL;
|
||||
if (convert || swizzle)
|
||||
{
|
||||
temp = (uint8_t*)BX_ALLOC(g_allocator, width*height*4);
|
||||
temp = (uint8_t*)BX_ALLOC(g_allocator, rectpitch*height);
|
||||
}
|
||||
|
||||
if (compressed)
|
||||
|
@ -1642,13 +1658,14 @@ namespace bgfx
|
|||
|
||||
if (convert)
|
||||
{
|
||||
imageDecodeToBgra8(temp, data, width, height, m_requestedFormat);
|
||||
imageDecodeToBgra8(temp, data, width, height, srcpitch, m_requestedFormat);
|
||||
data = temp;
|
||||
srcpitch = rectpitch;
|
||||
}
|
||||
|
||||
if (swizzle)
|
||||
{
|
||||
imageSwizzleBgra8(width, height, data, temp);
|
||||
imageSwizzleBgra8(width, height, srcpitch, data, temp);
|
||||
data = temp;
|
||||
}
|
||||
|
||||
|
@ -2636,9 +2653,9 @@ namespace bgfx
|
|||
{
|
||||
}
|
||||
|
||||
void Context::rendererUpdateTexture(TextureHandle _handle, uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, const Memory* _mem)
|
||||
void Context::rendererUpdateTexture(TextureHandle _handle, uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, uint16_t _pitch, const Memory* _mem)
|
||||
{
|
||||
s_renderCtx->m_textures[_handle.idx].update(_side, _mip, _rect, _z, _depth, _mem);
|
||||
s_renderCtx->m_textures[_handle.idx].update(_side, _mip, _rect, _z, _depth, _pitch, _mem);
|
||||
}
|
||||
|
||||
void Context::rendererUpdateTextureEnd()
|
||||
|
|
|
@ -123,138 +123,142 @@ typedef void (*PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC)(GLuint shader, GLsizei b
|
|||
|
||||
#endif // BGFX_CONFIG_RENDERER_OPENGL
|
||||
|
||||
# ifndef GL_LUMINANCE
|
||||
# define GL_LUMINANCE 0x1909
|
||||
# endif // GL_LUMINANCE
|
||||
#ifndef GL_LUMINANCE
|
||||
# define GL_LUMINANCE 0x1909
|
||||
#endif // GL_LUMINANCE
|
||||
|
||||
# ifndef GL_BGRA_EXT
|
||||
# define GL_BGRA_EXT 0x80E1
|
||||
# endif // GL_BGRA_EXT
|
||||
#ifndef GL_BGRA_EXT
|
||||
# define GL_BGRA_EXT 0x80E1
|
||||
#endif // GL_BGRA_EXT
|
||||
|
||||
# ifndef GL_R16F_EXT
|
||||
# define GL_R16F_EXT 0x822D
|
||||
# endif // GL_R16F_EXT
|
||||
#ifndef GL_R16F_EXT
|
||||
# define GL_R16F_EXT 0x822D
|
||||
#endif // GL_R16F_EXT
|
||||
|
||||
# ifndef GL_R32F_EXT
|
||||
# define GL_R32F_EXT 0x822E
|
||||
# endif // GL_R32F_EXT
|
||||
#ifndef GL_R32F_EXT
|
||||
# define GL_R32F_EXT 0x822E
|
||||
#endif // GL_R32F_EXT
|
||||
|
||||
# ifndef GL_RGB10_A2_EXT
|
||||
# define GL_RGB10_A2_EXT 0x8059
|
||||
# endif // GL_RGB10_A2_EXT
|
||||
#ifndef GL_RGB10_A2_EXT
|
||||
# define GL_RGB10_A2_EXT 0x8059
|
||||
#endif // GL_RGB10_A2_EXT
|
||||
|
||||
# ifndef GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
|
||||
# define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
|
||||
# endif // GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
|
||||
#ifndef GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
|
||||
# define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
|
||||
#endif // GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
|
||||
|
||||
# ifndef GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
|
||||
# define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
|
||||
# endif // GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
|
||||
#ifndef GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
|
||||
# define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
|
||||
#endif // GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
|
||||
|
||||
# ifndef GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
|
||||
# define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
|
||||
# endif // GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
|
||||
#ifndef GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
|
||||
# define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
|
||||
#endif // GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
|
||||
|
||||
# ifndef GL_COMPRESSED_LUMINANCE_LATC1_EXT
|
||||
# define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70
|
||||
# endif // GL_COMPRESSED_LUMINANCE_LATC1_EXT
|
||||
#ifndef GL_COMPRESSED_LUMINANCE_LATC1_EXT
|
||||
# define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70
|
||||
#endif // GL_COMPRESSED_LUMINANCE_LATC1_EXT
|
||||
|
||||
# ifndef GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT
|
||||
# define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72
|
||||
# endif // GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT
|
||||
#ifndef GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT
|
||||
# define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72
|
||||
#endif // GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT
|
||||
|
||||
# ifndef GL_COMPRESSED_RED_RGTC1_EXT
|
||||
# define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB
|
||||
# endif // GL_COMPRESSED_RED_RGTC1_EXT
|
||||
#ifndef GL_COMPRESSED_RED_RGTC1_EXT
|
||||
# define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB
|
||||
#endif // GL_COMPRESSED_RED_RGTC1_EXT
|
||||
|
||||
# ifndef GL_COMPRESSED_RED_GREEN_RGTC2_EXT
|
||||
# define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD
|
||||
# endif // GL_COMPRESSED_RED_GREEN_RGTC2_EXT
|
||||
#ifndef GL_COMPRESSED_RED_GREEN_RGTC2_EXT
|
||||
# define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD
|
||||
#endif // GL_COMPRESSED_RED_GREEN_RGTC2_EXT
|
||||
|
||||
# ifndef GL_ETC1_RGB8_OES
|
||||
# define GL_ETC1_RGB8_OES 0x8D64
|
||||
# endif // GL_ETC1_RGB8_OES
|
||||
#ifndef GL_ETC1_RGB8_OES
|
||||
# define GL_ETC1_RGB8_OES 0x8D64
|
||||
#endif // GL_ETC1_RGB8_OES
|
||||
|
||||
# ifndef GL_COMPRESSED_RGB8_ETC2
|
||||
# define GL_COMPRESSED_RGB8_ETC2 0x9274
|
||||
# endif // GL_COMPRESSED_RGB8_ETC2
|
||||
#ifndef GL_COMPRESSED_RGB8_ETC2
|
||||
# define GL_COMPRESSED_RGB8_ETC2 0x9274
|
||||
#endif // GL_COMPRESSED_RGB8_ETC2
|
||||
|
||||
# ifndef GL_COMPRESSED_RGBA8_ETC2_EAC
|
||||
# define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278
|
||||
# endif // GL_COMPRESSED_RGBA8_ETC2_EAC
|
||||
#ifndef GL_COMPRESSED_RGBA8_ETC2_EAC
|
||||
# define GL_COMPRESSED_RGBA8_ETC2_EAC 0x9278
|
||||
#endif // GL_COMPRESSED_RGBA8_ETC2_EAC
|
||||
|
||||
# ifndef GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2
|
||||
# define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276
|
||||
# endif // GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2
|
||||
#ifndef GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2
|
||||
# define GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2 0x9276
|
||||
#endif // GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2
|
||||
|
||||
# ifndef GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
|
||||
# define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
|
||||
# endif // GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
|
||||
#ifndef GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
|
||||
# define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01
|
||||
#endif // GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG
|
||||
|
||||
# ifndef GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
|
||||
# define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
|
||||
# endif // GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
|
||||
#ifndef GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
|
||||
# define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03
|
||||
#endif // GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG
|
||||
|
||||
# ifndef GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG
|
||||
# define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
|
||||
# endif // GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG
|
||||
#ifndef GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG
|
||||
# define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00
|
||||
#endif // GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG
|
||||
|
||||
# ifndef GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
|
||||
# define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
|
||||
# endif // GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
|
||||
#ifndef GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
|
||||
# define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02
|
||||
#endif // GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
|
||||
|
||||
# ifndef GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG
|
||||
# define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137
|
||||
# endif // GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG
|
||||
#ifndef GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG
|
||||
# define GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG 0x9137
|
||||
#endif // GL_COMPRESSED_RGBA_PVRTC_2BPPV2_IMG
|
||||
|
||||
# ifndef GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG
|
||||
# define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138
|
||||
# endif // GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG
|
||||
#ifndef GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG
|
||||
# define GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG 0x9138
|
||||
#endif // GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG
|
||||
|
||||
# ifndef GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE
|
||||
# define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0
|
||||
# endif // GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE
|
||||
#ifndef GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE
|
||||
# define GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE 0x93A0
|
||||
#endif // GL_TRANSLATED_SHADER_SOURCE_LENGTH_ANGLE
|
||||
|
||||
# ifndef GL_TEXTURE_MAX_ANISOTROPY_EXT
|
||||
# define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
|
||||
# endif // GL_TEXTURE_MAX_ANISOTROPY_EXT
|
||||
#ifndef GL_TEXTURE_MAX_ANISOTROPY_EXT
|
||||
# define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
|
||||
#endif // GL_TEXTURE_MAX_ANISOTROPY_EXT
|
||||
|
||||
# ifndef GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
|
||||
# define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
|
||||
# endif // GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
|
||||
#ifndef GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
|
||||
# define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
|
||||
#endif // GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT
|
||||
|
||||
# ifndef GL_VBO_FREE_MEMORY_ATI
|
||||
# define GL_VBO_FREE_MEMORY_ATI 0x87FB
|
||||
# endif // GL_VBO_FREE_MEMORY_ATI
|
||||
#ifndef GL_VBO_FREE_MEMORY_ATI
|
||||
# define GL_VBO_FREE_MEMORY_ATI 0x87FB
|
||||
#endif // GL_VBO_FREE_MEMORY_ATI
|
||||
|
||||
# ifndef GL_TEXTURE_FREE_MEMORY_ATI
|
||||
# define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC
|
||||
# endif // GL_TEXTURE_FREE_MEMORY_ATI
|
||||
#ifndef GL_TEXTURE_FREE_MEMORY_ATI
|
||||
# define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC
|
||||
#endif // GL_TEXTURE_FREE_MEMORY_ATI
|
||||
|
||||
# ifndef GL_RENDERBUFFER_FREE_MEMORY_ATI
|
||||
# define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD
|
||||
# endif // GL_RENDERBUFFER_FREE_MEMORY_ATI
|
||||
#ifndef GL_RENDERBUFFER_FREE_MEMORY_ATI
|
||||
# define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD
|
||||
#endif // GL_RENDERBUFFER_FREE_MEMORY_ATI
|
||||
|
||||
// http://developer.download.nvidia.com/opengl/specs/GL_NVX_gpu_memory_info.txt
|
||||
# ifndef GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
|
||||
# define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047
|
||||
# endif // GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
|
||||
#ifndef GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
|
||||
# define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047
|
||||
#endif // GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX
|
||||
|
||||
# ifndef GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
|
||||
# define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048
|
||||
# endif // GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
|
||||
#ifndef GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
|
||||
# define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048
|
||||
#endif // GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX
|
||||
|
||||
# ifndef GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
|
||||
# define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049
|
||||
# endif // GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
|
||||
#ifndef GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
|
||||
# define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049
|
||||
#endif // GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX
|
||||
|
||||
# ifndef GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
|
||||
# define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A
|
||||
# endif // GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
|
||||
#ifndef GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
|
||||
# define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A
|
||||
#endif // GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX
|
||||
|
||||
# ifndef GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
|
||||
# define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B
|
||||
# endif // GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
|
||||
#ifndef GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
|
||||
# define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B
|
||||
#endif // GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX
|
||||
|
||||
#ifndef GL_UNPACK_ROW_LENGTH
|
||||
# define GL_UNPACK_ROW_LENGTH 0x0CF2
|
||||
#endif // GL_UNPACK_ROW_LENGTH
|
||||
|
||||
#ifndef GL_RGBA16
|
||||
# define GL_RGBA16 0x805B
|
||||
|
@ -566,7 +570,7 @@ namespace bgfx
|
|||
void createColor(uint32_t _colorFormat, uint32_t _width, uint32_t _height, GLenum _min, GLenum _mag);
|
||||
void createDepth(uint32_t _width, uint32_t _height);
|
||||
void destroy();
|
||||
void update(uint8_t _side, uint8_t _mip, const Rect& _rect, uint16_t _z, uint16_t _depth, 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);
|
||||
void setSamplerState(uint32_t _flags);
|
||||
void commit(uint32_t _stage, uint32_t _flags);
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ namespace bgfx
|
|||
{
|
||||
}
|
||||
|
||||
void Context::rendererUpdateTexture(TextureHandle /*_handle*/, uint8_t /*_side*/, uint8_t /*_mip*/, const Rect& /*_rect*/, uint16_t /*_z*/, uint16_t /*_depth*/, const Memory* /*_mem*/)
|
||||
void Context::rendererUpdateTexture(TextureHandle /*_handle*/, uint8_t /*_side*/, uint8_t /*_mip*/, const Rect& /*_rect*/, uint16_t /*_z*/, uint16_t /*_depth*/, uint16_t /*_pitch*/, const Memory* /*_mem*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -102,6 +102,11 @@ namespace bgfx
|
|||
m_stride += (*s_attribTypeSize[m_hash])[_type][_num-1];
|
||||
}
|
||||
|
||||
void VertexDecl::skip(uint8_t _num)
|
||||
{
|
||||
m_stride += _num;
|
||||
}
|
||||
|
||||
void VertexDecl::decode(Attrib::Enum _attrib, uint8_t& _num, AttribType::Enum& _type, bool& _normalized, bool& _asInt) const
|
||||
{
|
||||
uint8_t val = m_attributes[_attrib];
|
||||
|
@ -491,8 +496,53 @@ namespace bgfx
|
|||
return xx*xx + yy*yy + zz*zz;
|
||||
}
|
||||
|
||||
uint16_t weldVerticesRef(uint16_t* _output, const VertexDecl& _decl, const void* _data, uint16_t _num, float _epsilon)
|
||||
{
|
||||
// Brute force slow vertex welding...
|
||||
const float epsilonSq = _epsilon*_epsilon;
|
||||
|
||||
uint32_t numVertices = 0;
|
||||
memset(_output, 0xff, _num*sizeof(uint16_t) );
|
||||
|
||||
for (uint32_t ii = 0; ii < _num; ++ii)
|
||||
{
|
||||
if (UINT16_MAX != _output[ii])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_output[ii] = ii;
|
||||
++numVertices;
|
||||
|
||||
float pos[4];
|
||||
vertexUnpack(pos, bgfx::Attrib::Position, _decl, _data, ii);
|
||||
|
||||
for (uint32_t jj = 0; jj < _num; ++jj)
|
||||
{
|
||||
if (UINT16_MAX != _output[jj])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
float test[4];
|
||||
vertexUnpack(test, bgfx::Attrib::Position, _decl, _data, jj);
|
||||
|
||||
if (sqLength(test, pos) < epsilonSq)
|
||||
{
|
||||
_output[jj] = ii;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return numVertices;
|
||||
}
|
||||
|
||||
uint16_t weldVertices(uint16_t* _output, const VertexDecl& _decl, const void* _data, uint16_t _num, float _epsilon)
|
||||
{
|
||||
#if 1
|
||||
return weldVerticesRef(_output, _decl, _data, _num, _epsilon);
|
||||
#else
|
||||
// This "clever" version doesn't work as expected...
|
||||
const uint32_t hashSize = bx::uint32_nextpow2(_num);
|
||||
const uint32_t hashMask = hashSize-1;
|
||||
const float epsilonSq = _epsilon*_epsilon;
|
||||
|
@ -516,6 +566,7 @@ namespace bgfx
|
|||
{
|
||||
float test[4];
|
||||
vertexUnpack(test, bgfx::Attrib::Position, _decl, _data, _output[offset]);
|
||||
|
||||
if (sqLength(test, pos) < epsilonSq)
|
||||
{
|
||||
_output[ii] = _output[offset];
|
||||
|
@ -533,6 +584,7 @@ namespace bgfx
|
|||
}
|
||||
|
||||
return numVertices;
|
||||
#endif // 0
|
||||
}
|
||||
|
||||
} // namespace bgfx
|
||||
|
|
|
@ -1273,6 +1273,13 @@ uint32_t parseInOut(InOut& _inout, const char* _str, const char* _eol)
|
|||
return hash;
|
||||
}
|
||||
|
||||
// c - compute
|
||||
// d - domain
|
||||
// f - fragment
|
||||
// g - geometry
|
||||
// h - hull
|
||||
// v - vertex
|
||||
//
|
||||
// OpenGL #version Features Direct3D Features Shader Model
|
||||
// 2.1 120 vf 9.0 vf 2.0
|
||||
// 3.0 130
|
||||
|
@ -1281,7 +1288,8 @@ uint32_t parseInOut(InOut& _inout, const char* _str, const char* _eol)
|
|||
// 3.3 330 10.0 vgf 4.0
|
||||
// 4.0 400 vhdgf
|
||||
// 4.1 410
|
||||
// 4.2 420 11.0 vhdgf 5.0
|
||||
// 4.2 420 11.0 vhdgf+c 5.0
|
||||
// 4.3 430 vhdgf+c
|
||||
|
||||
void help(const char* _error = NULL)
|
||||
{
|
||||
|
|
|
@ -130,7 +130,7 @@ int main(int _argc, const char* _argv[])
|
|||
|| height != mip.m_height)
|
||||
{
|
||||
uint8_t* temp = (uint8_t*)realloc(NULL, mip.m_width*mip.m_height*4);
|
||||
imageDecodeToBgra8(temp, mip.m_data, mip.m_width, mip.m_height, mip.m_format);
|
||||
imageDecodeToBgra8(temp, mip.m_data, mip.m_width, mip.m_height, mip.m_width*4, mip.m_format);
|
||||
uint32_t srcpitch = mip.m_width*4;
|
||||
|
||||
for (uint32_t yy = 0; yy < height; ++yy)
|
||||
|
@ -150,7 +150,7 @@ int main(int _argc, const char* _argv[])
|
|||
}
|
||||
else
|
||||
{
|
||||
imageDecodeToBgra8(bits, mip.m_data, mip.m_width, mip.m_height, mip.m_format);
|
||||
imageDecodeToBgra8(bits, mip.m_data, mip.m_width, mip.m_height, mip.m_width*4, mip.m_format);
|
||||
}
|
||||
|
||||
char filePath[256];
|
||||
|
|
Loading…
Reference in a new issue