Added ability to specify arbitrary source pitch when uploading textures.

Added reference weldVertices implementation.
This commit is contained in:
bkaradzic 2013-11-07 22:59:17 -08:00
parent 2374ea3a15
commit b584873b50
17 changed files with 356 additions and 221 deletions

View File

@ -293,8 +293,7 @@ int _main_(int /*_argc*/, char** /*_argv*/)
const uint32_t textureSide = 2048; const uint32_t textureSide = 2048;
bgfx::TextureHandle textureCube = bgfx::TextureHandle textureCube =
bgfx::createTextureCube(6 bgfx::createTextureCube(textureSide
, textureSide
, 1 , 1
, bgfx::TextureFormat::BGRA8 , bgfx::TextureFormat::BGRA8
, BGFX_TEXTURE_MIN_POINT|BGFX_TEXTURE_MAG_POINT|BGFX_TEXTURE_MIP_POINT , BGFX_TEXTURE_MIN_POINT|BGFX_TEXTURE_MAG_POINT|BGFX_TEXTURE_MIP_POINT

View File

@ -274,8 +274,7 @@ Atlas::Atlas(uint16_t _textureSize, uint16_t _maxRegionsCount)
m_textureBuffer = new uint8_t[ _textureSize * _textureSize * 6 * 4 ]; m_textureBuffer = new uint8_t[ _textureSize * _textureSize * 6 * 4 ];
memset(m_textureBuffer, 0, _textureSize * _textureSize * 6 * 4); memset(m_textureBuffer, 0, _textureSize * _textureSize * 6 * 4);
m_textureHandle = bgfx::createTextureCube(6 m_textureHandle = bgfx::createTextureCube(_textureSize
, _textureSize
, 1 , 1
, bgfx::TextureFormat::BGRA8 , 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_regions, _regionBuffer, _regionCount * sizeof(AtlasRegion) );
memcpy(m_textureBuffer, _textureBuffer, getTextureBufferSize() ); memcpy(m_textureBuffer, _textureBuffer, getTextureBufferSize() );
m_textureHandle = bgfx::createTextureCube(6 m_textureHandle = bgfx::createTextureCube(_textureSize
, _textureSize
, 1 , 1
, bgfx::TextureFormat::BGRA8 , bgfx::TextureFormat::BGRA8
, BGFX_TEXTURE_NONE , BGFX_TEXTURE_NONE

View File

@ -492,7 +492,7 @@ inline void mtxViewFlipHandedness(float* __restrict _dst, const float* __restric
_dst[15] = _src[15]; _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]; float ba[3];
vec3Sub(ba, _vb, _va); 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]; float baxca[3];
vec3Cross(baxca, ba, ca); 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]; float normal[3];
vec3Norm(normal, baxca); calcNormal(normal, _va, _vb, _vc);
_result[0] = normal[0]; _result[0] = normal[0];
_result[1] = normal[1]; _result[1] = normal[1];

View File

@ -525,6 +525,9 @@ namespace bgfx
/// ///
void add(Attrib::Enum _attrib, uint8_t _num, AttribType::Enum _type, bool _normalized = false, bool _asInt = false); 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. /// Decode attribute.
void decode(Attrib::Enum _attrib, uint8_t& _num, AttribType::Enum& _type, bool& _normalized, bool& _asInt) const; 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 _width Width of input image (pixels).
/// @param _height Height of input image (pixels). /// @param _height Height of input image (pixels).
/// @param _pitch Pitch of input image (bytes).
/// @param _src Source image. /// @param _src Source image.
/// @param _dst Destination image. Must be the same size as input image. /// @param _dst Destination image. Must be the same size as input image.
/// _dst might be pointer to the same memory as _src. /// _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. /// Downsample RGBA8 image with 2x2 pixel average filter.
/// ///
@ -859,23 +863,45 @@ namespace bgfx
/// Create Cube texture. /// Create Cube texture.
/// ///
/// @param _sides /// @param _size
/// @param _width
/// @param _numMips /// @param _numMips
/// @param _format /// @param _format
/// @param _flags /// @param _flags
/// @param _mem /// @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. /// 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. /// 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); 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. /// Update Cube texture.
/// ///
/// @param _handle
/// @param _side Cubemap side, where 0 is +X, 1 is -X, 2 is +Y, 3 is /// @param _side Cubemap side, where 0 is +X, 1 is -X, 2 is +Y, 3 is
/// -Y, 4 is +Z, and 5 is -Z. /// -Y, 4 is +Z, and 5 is -Z.
/// ///
@ -896,7 +922,16 @@ namespace bgfx
/// | +---->+x | /// | +---->+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. /// Destroy texture.
void destroyTexture(TextureHandle _handle); void destroyTexture(TextureHandle _handle);

View File

@ -1113,6 +1113,9 @@ namespace bgfx
uint16_t depth; uint16_t depth;
_cmdbuf.read(depth); _cmdbuf.read(depth);
uint16_t pitch;
_cmdbuf.read(pitch);
Memory* mem; Memory* mem;
_cmdbuf.read(mem); _cmdbuf.read(mem);
@ -1127,7 +1130,7 @@ namespace bgfx
rendererUpdateTextureBegin(handle, side, mip); rendererUpdateTextureBegin(handle, side, mip);
} }
rendererUpdateTexture(handle, side, mip, rect, zz, depth, mem); rendererUpdateTexture(handle, side, mip, rect, zz, depth, pitch, mem);
release(mem); release(mem);
} }
@ -1452,7 +1455,12 @@ namespace bgfx
uint8_t mip; uint8_t mip;
_cmdbuf.read(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) uint32_t key = (handle.idx<<16)
| (side<<8) | (side<<8)
@ -1907,7 +1915,7 @@ namespace bgfx
return s_ctx->createTexture(mem, _flags, NULL); 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(); BGFX_CHECK_MAIN_THREAD();
@ -1915,7 +1923,7 @@ namespace bgfx
if (NULL != _mem) if (NULL != _mem)
{ {
TextureInfo ti; TextureInfo ti;
calcTextureSize(ti, _width, _width, 1, _numMips, _format); calcTextureSize(ti, _size, _size, 1, _numMips, _format);
BX_CHECK(ti.storageSize*_sides == _mem->size BX_CHECK(ti.storageSize*_sides == _mem->size
, "createTextureCube: Texture storage size doesn't match passed memory size (storage size: %d, memory size: %d)" , "createTextureCube: Texture storage size doesn't match passed memory size (storage size: %d, memory size: %d)"
, ti.storageSize*_sides , ti.storageSize*_sides
@ -1933,9 +1941,9 @@ namespace bgfx
TextureCreate tc; TextureCreate tc;
tc.m_flags = _flags; tc.m_flags = _flags;
tc.m_width = _width; tc.m_width = _size;
tc.m_height = _width; tc.m_height = _size;
tc.m_sides = _sides; tc.m_sides = 6;
tc.m_depth = 0; tc.m_depth = 0;
tc.m_numMips = _numMips; tc.m_numMips = _numMips;
tc.m_format = uint8_t(_format); tc.m_format = uint8_t(_format);
@ -1952,7 +1960,7 @@ namespace bgfx
s_ctx->destroyTexture(_handle); 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(); BGFX_CHECK_MAIN_THREAD();
BX_CHECK(NULL != _mem, "_mem can't be NULL"); BX_CHECK(NULL != _mem, "_mem can't be NULL");
@ -1963,7 +1971,7 @@ namespace bgfx
} }
else 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 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(); BGFX_CHECK_MAIN_THREAD();
BX_CHECK(NULL != _mem, "_mem can't be NULL"); BX_CHECK(NULL != _mem, "_mem can't be NULL");
@ -1995,7 +2003,7 @@ namespace bgfx
} }
else 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);
} }
} }

View File

@ -2192,7 +2192,7 @@ namespace bgfx
m_submit->free(_handle); 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); CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::UpdateTexture);
cmdbuf.write(_handle); cmdbuf.write(_handle);
@ -2206,6 +2206,7 @@ namespace bgfx
cmdbuf.write(rect); cmdbuf.write(rect);
cmdbuf.write(_z); cmdbuf.write(_z);
cmdbuf.write(_depth); cmdbuf.write(_depth);
cmdbuf.write(_pitch);
cmdbuf.write(_mem); cmdbuf.write(_mem);
} }
@ -2581,7 +2582,7 @@ namespace bgfx
void rendererDestroyProgram(FragmentShaderHandle _handle); void rendererDestroyProgram(FragmentShaderHandle _handle);
void rendererCreateTexture(TextureHandle _handle, Memory* _mem, uint32_t _flags); void rendererCreateTexture(TextureHandle _handle, Memory* _mem, uint32_t _flags);
void rendererUpdateTextureBegin(TextureHandle _handle, uint8_t _side, uint8_t _mip); 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 rendererUpdateTextureEnd();
void rendererDestroyTexture(TextureHandle _handle); void rendererDestroyTexture(TextureHandle _handle);
void rendererCreateRenderTarget(RenderTargetHandle _handle, uint16_t _width, uint16_t _height, uint32_t _flags, uint32_t _textureFlags); void rendererCreateRenderTarget(RenderTargetHandle _handle, uint16_t _width, uint16_t _height, uint32_t _flags, uint32_t _textureFlags);

View File

@ -198,12 +198,15 @@ 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* src = (uint8_t*) _src;
const uint8_t* next = src + _pitch;
uint8_t* dst = (uint8_t*)_dst; 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)
{
for (uint32_t xx = 0; xx < _width; ++xx, src += 4, dst += 4)
{ {
uint8_t rr = src[0]; uint8_t rr = src[0];
uint8_t gg = src[1]; uint8_t gg = src[1];
@ -215,8 +218,9 @@ namespace bgfx
dst[3] = aa; 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. // Test can we do four 4-byte pixels at the time.
if (0 != (_width&0x3) if (0 != (_width&0x3)
@ -228,20 +232,23 @@ namespace bgfx
BX_WARN(bx::isPtrAligned(_src, 16), "Source %p is not 16-byte aligned.", _src); 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(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); 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; return;
} }
const uint32_t dstpitch = _width*4;
using namespace bx; using namespace bx;
const float4_t mf0f0 = float4_isplat(0xff00ff00); const float4_t mf0f0 = float4_isplat(0xff00ff00);
const float4_t m0f0f = float4_isplat(0x00ff00ff); const float4_t m0f0f = float4_isplat(0x00ff00ff);
const uint8_t* src = (uint8_t*) _src; const uint8_t* src = (uint8_t*) _src;
const uint8_t* next = src + _pitch;
uint8_t* dst = (uint8_t*)_dst; 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)
{
for (uint32_t xx = 0; xx < width; ++xx, src += 16, dst += 16)
{ {
const float4_t tabgr = float4_ld(src); const float4_t tabgr = float4_ld(src);
const float4_t t00ab = float4_srl(tabgr, 16); const float4_t t00ab = float4_srl(tabgr, 16);
@ -253,6 +260,7 @@ namespace bgfx
float4_st(dst, targb); float4_st(dst, targb);
} }
} }
}
void imageWriteTga(bx::WriterI* _writer, uint32_t _width, uint32_t _height, uint32_t _srcPitch, const void* _src, bool _grayscale, bool _yflip) void imageWriteTga(bx::WriterI* _writer, uint32_t _width, uint32_t _height, uint32_t _srcPitch, const void* _src, bool _grayscale, bool _yflip)
{ {
@ -1336,13 +1344,12 @@ namespace bgfx
return imageParse(_imageContainer, &reader); 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; const uint8_t* src = _src;
uint32_t width = _width/4; uint32_t width = _width/4;
uint32_t height = _height/4; uint32_t height = _height/4;
uint32_t pitch = _width*4;
uint8_t temp[16*4]; uint8_t temp[16*4];
@ -1356,11 +1363,11 @@ namespace bgfx
decodeBlockDxt1(temp, src); decodeBlockDxt1(temp, src);
src += 8; src += 8;
uint8_t* dst = &_dst[(yy*pitch+xx*4)*4]; uint8_t* dst = &_dst[(yy*_pitch+xx*4)*4];
memcpy(&dst[0*pitch], &temp[ 0], 16); memcpy(&dst[0*_pitch], &temp[ 0], 16);
memcpy(&dst[1*pitch], &temp[16], 16); memcpy(&dst[1*_pitch], &temp[16], 16);
memcpy(&dst[2*pitch], &temp[32], 16); memcpy(&dst[2*_pitch], &temp[32], 16);
memcpy(&dst[3*pitch], &temp[48], 16); memcpy(&dst[3*_pitch], &temp[48], 16);
} }
} }
break; break;
@ -1375,11 +1382,11 @@ namespace bgfx
decodeBlockDxt(temp, src); decodeBlockDxt(temp, src);
src += 8; src += 8;
uint8_t* dst = &_dst[(yy*pitch+xx*4)*4]; uint8_t* dst = &_dst[(yy*_pitch+xx*4)*4];
memcpy(&dst[0*pitch], &temp[ 0], 16); memcpy(&dst[0*_pitch], &temp[ 0], 16);
memcpy(&dst[1*pitch], &temp[16], 16); memcpy(&dst[1*_pitch], &temp[16], 16);
memcpy(&dst[2*pitch], &temp[32], 16); memcpy(&dst[2*_pitch], &temp[32], 16);
memcpy(&dst[3*pitch], &temp[48], 16); memcpy(&dst[3*_pitch], &temp[48], 16);
} }
} }
break; break;
@ -1394,11 +1401,11 @@ namespace bgfx
decodeBlockDxt(temp, src); decodeBlockDxt(temp, src);
src += 8; src += 8;
uint8_t* dst = &_dst[(yy*pitch+xx*4)*4]; uint8_t* dst = &_dst[(yy*_pitch+xx*4)*4];
memcpy(&dst[0*pitch], &temp[ 0], 16); memcpy(&dst[0*_pitch], &temp[ 0], 16);
memcpy(&dst[1*pitch], &temp[16], 16); memcpy(&dst[1*_pitch], &temp[16], 16);
memcpy(&dst[2*pitch], &temp[32], 16); memcpy(&dst[2*_pitch], &temp[32], 16);
memcpy(&dst[3*pitch], &temp[48], 16); memcpy(&dst[3*_pitch], &temp[48], 16);
} }
} }
break; break;
@ -1411,11 +1418,11 @@ namespace bgfx
decodeBlockDxt45A(temp, src); decodeBlockDxt45A(temp, src);
src += 8; src += 8;
uint8_t* dst = &_dst[(yy*pitch+xx*4)*4]; uint8_t* dst = &_dst[(yy*_pitch+xx*4)*4];
memcpy(&dst[0*pitch], &temp[ 0], 16); memcpy(&dst[0*_pitch], &temp[ 0], 16);
memcpy(&dst[1*pitch], &temp[16], 16); memcpy(&dst[1*_pitch], &temp[16], 16);
memcpy(&dst[2*pitch], &temp[32], 16); memcpy(&dst[2*_pitch], &temp[32], 16);
memcpy(&dst[3*pitch], &temp[48], 16); memcpy(&dst[3*_pitch], &temp[48], 16);
} }
} }
break; break;
@ -1439,11 +1446,11 @@ namespace bgfx
temp[ii*4+3] = 0; temp[ii*4+3] = 0;
} }
uint8_t* dst = &_dst[(yy*pitch+xx*4)*4]; uint8_t* dst = &_dst[(yy*_pitch+xx*4)*4];
memcpy(&dst[0*pitch], &temp[ 0], 16); memcpy(&dst[0*_pitch], &temp[ 0], 16);
memcpy(&dst[1*pitch], &temp[16], 16); memcpy(&dst[1*_pitch], &temp[16], 16);
memcpy(&dst[2*pitch], &temp[32], 16); memcpy(&dst[2*_pitch], &temp[32], 16);
memcpy(&dst[3*pitch], &temp[48], 16); memcpy(&dst[3*_pitch], &temp[48], 16);
} }
} }
break; break;
@ -1457,11 +1464,11 @@ namespace bgfx
decodeBlockEtc12(temp, src); decodeBlockEtc12(temp, src);
src += 8; src += 8;
uint8_t* dst = &_dst[(yy*pitch+xx*4)*4]; uint8_t* dst = &_dst[(yy*_pitch+xx*4)*4];
memcpy(&dst[0*pitch], &temp[ 0], 16); memcpy(&dst[0*_pitch], &temp[ 0], 16);
memcpy(&dst[1*pitch], &temp[16], 16); memcpy(&dst[1*_pitch], &temp[16], 16);
memcpy(&dst[2*pitch], &temp[32], 16); memcpy(&dst[2*_pitch], &temp[32], 16);
memcpy(&dst[3*pitch], &temp[48], 16); memcpy(&dst[3*_pitch], &temp[48], 16);
} }
} }
break; break;

View File

@ -52,7 +52,7 @@ namespace bgfx
void imageRgba8Downsample2x2(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst); 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); 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); 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); bool imageGetRawData(const ImageContainer& _dds, uint8_t _side, uint8_t _index, const void* _data, uint32_t _size, ImageMip& _mip);

View File

@ -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; ID3D11DeviceContext* deviceCtx = s_renderCtx->m_deviceCtx;
@ -1844,10 +1844,10 @@ namespace bgfx
box.front = _z; box.front = _z;
box.back = box.front + _depth; box.back = box.front + _depth;
uint32_t subres = _mip + (_side * m_numMips); const uint32_t subres = _mip + (_side * m_numMips);
const uint32_t bpp = getBitsPerPixel(TextureFormat::Enum(m_textureFormat) );
uint32_t bpp = getBitsPerPixel(TextureFormat::Enum(m_textureFormat) ); const uint32_t rectpitch = _rect.m_width*bpp/8;
uint32_t srcpitch = _rect.m_width*bpp/8; const uint32_t srcpitch = UINT16_MAX == _pitch ? rectpitch : _pitch;
const bool convert = m_textureFormat != m_requestedFormat; const bool convert = m_textureFormat != m_requestedFormat;
@ -1856,8 +1856,8 @@ namespace bgfx
if (convert) if (convert)
{ {
uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, srcpitch*_rect.m_height); uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, rectpitch*_rect.m_height);
imageDecodeToBgra8(temp, data, _rect.m_width, _rect.m_height, m_requestedFormat); imageDecodeToBgra8(temp, data, _rect.m_width, _rect.m_height, srcpitch, m_requestedFormat);
data = temp; 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() void Context::rendererUpdateTextureEnd()

View File

@ -1606,7 +1606,7 @@ namespace bgfx
uint32_t srcpitch = mipWidth*bpp/8; uint32_t srcpitch = mipWidth*bpp/8;
uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, srcpitch*mipHeight); 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; uint32_t dstpitch = pitch;
for (uint32_t yy = 0; yy < height; ++yy) for (uint32_t yy = 0; yy < height; ++yy)
@ -1620,7 +1620,7 @@ namespace bgfx
} }
else 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 else
@ -1650,11 +1650,12 @@ namespace bgfx
s_renderCtx->m_updateTextureBits = lock(_side, _mip, s_renderCtx->m_updateTexturePitch, slicePitch); 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) ); const uint32_t bpp = getBitsPerPixel(TextureFormat::Enum(m_textureFormat) );
uint32_t srcpitch = _rect.m_width*bpp/8; const uint32_t rectpitch = _rect.m_width*bpp/8;
uint32_t dstpitch = s_renderCtx->m_updateTexturePitch; 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; uint8_t* bits = s_renderCtx->m_updateTextureBits + _rect.m_y*dstpitch + _rect.m_x*bpp/8;
const bool convert = m_textureFormat != m_requestedFormat; const bool convert = m_textureFormat != m_requestedFormat;
@ -1664,8 +1665,8 @@ namespace bgfx
if (convert) if (convert)
{ {
uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, srcpitch*_rect.m_height); uint8_t* temp = (uint8_t*)BX_ALLOC(g_allocator, rectpitch*_rect.m_height);
imageDecodeToBgra8(temp, data, _rect.m_width, _rect.m_height, m_requestedFormat); imageDecodeToBgra8(temp, data, _rect.m_width, _rect.m_height, srcpitch, m_requestedFormat);
data = temp; data = temp;
} }
@ -2117,9 +2118,9 @@ namespace bgfx
s_renderCtx->m_updateTexture->updateBegin(_side, _mip); 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() void Context::rendererUpdateTextureEnd()

View File

@ -317,7 +317,7 @@ namespace bgfx
} }
void updateBegin(uint8_t _side, uint8_t _mip); 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 updateEnd();
void commit(uint8_t _stage, uint32_t _flags = BGFX_SAMPLER_DEFAULT_FLAGS); void commit(uint8_t _stage, uint32_t _flags = BGFX_SAMPLER_DEFAULT_FLAGS);

View File

@ -265,6 +265,7 @@ namespace bgfx
EXT_texture_swizzle, EXT_texture_swizzle,
EXT_texture_type_2_10_10_10_REV, EXT_texture_type_2_10_10_10_REV,
EXT_timer_query, EXT_timer_query,
EXT_unpack_subimage,
IMG_multisampled_render_to_texture, IMG_multisampled_render_to_texture,
IMG_read_format, IMG_read_format,
IMG_shader_binary, IMG_shader_binary,
@ -337,6 +338,7 @@ namespace bgfx
{ "GL_EXT_texture_swizzle", false, true }, { "GL_EXT_texture_swizzle", false, true },
{ "GL_EXT_texture_type_2_10_10_10_REV", false, true }, { "GL_EXT_texture_type_2_10_10_10_REV", false, true },
{ "GL_EXT_timer_query", false, true }, { "GL_EXT_timer_query", false, true },
{ "GL_EXT_unpack_subimage", false, true },
{ "GL_IMG_multisampled_render_to_texture", false, true }, { "GL_IMG_multisampled_render_to_texture", false, true },
{ "GL_IMG_read_format", false, true }, { "GL_IMG_read_format", false, true },
{ "GL_IMG_shader_binary", false, true }, { "GL_IMG_shader_binary", false, true },
@ -785,7 +787,7 @@ namespace bgfx
if (GL_RGBA == m_readPixelsFmt) if (GL_RGBA == m_readPixelsFmt)
{ {
imageSwizzleBgra8(width, height, data, data); imageSwizzleBgra8(width, height, width*4, data, data);
} }
g_callback->screenShot(_filePath g_callback->screenShot(_filePath
@ -1443,13 +1445,13 @@ namespace bgfx
if (convert) 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; data = temp;
} }
if (swizzle) if (swizzle)
{ {
imageSwizzleBgra8(width, height, data, temp); imageSwizzleBgra8(width, height, mip.m_width*4, data, temp);
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); 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(glBindTexture(m_target, m_id) );
GL_CHECK(glPixelStorei(GL_UNPACK_ALIGNMENT, 1) ); 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; 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 swizzle = GL_RGBA == m_fmt && !s_renderCtx->m_textureSwizzleSupport;
const bool convert = m_textureFormat != m_requestedFormat; const bool convert = m_textureFormat != m_requestedFormat;
const bool compressed = TextureFormat::Unknown > m_textureFormat; const bool compressed = TextureFormat::Unknown > m_textureFormat;
uint32_t width = _rect.m_width; const uint32_t width = _rect.m_width;
uint32_t height = _rect.m_height; const uint32_t height = _rect.m_height;
uint8_t* temp = NULL; uint8_t* temp = NULL;
if (convert || swizzle) if (convert || swizzle)
{ {
temp = (uint8_t*)BX_ALLOC(g_allocator, width*height*4); temp = (uint8_t*)BX_ALLOC(g_allocator, rectpitch*height);
} }
if (compressed) if (compressed)
@ -1642,13 +1658,14 @@ namespace bgfx
if (convert) if (convert)
{ {
imageDecodeToBgra8(temp, data, width, height, m_requestedFormat); imageDecodeToBgra8(temp, data, width, height, srcpitch, m_requestedFormat);
data = temp; data = temp;
srcpitch = rectpitch;
} }
if (swizzle) if (swizzle)
{ {
imageSwizzleBgra8(width, height, data, temp); imageSwizzleBgra8(width, height, srcpitch, data, temp);
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() void Context::rendererUpdateTextureEnd()

View File

@ -256,6 +256,10 @@ typedef void (*PFNGLGETTRANSLATEDSHADERSOURCEANGLEPROC)(GLuint shader, GLsizei b
# define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B # define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B
#endif // GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX #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 #ifndef GL_RGBA16
# define GL_RGBA16 0x805B # define GL_RGBA16 0x805B
#endif // GL_RGBA16 #endif // GL_RGBA16
@ -566,7 +570,7 @@ namespace bgfx
void createColor(uint32_t _colorFormat, uint32_t _width, uint32_t _height, GLenum _min, GLenum _mag); void createColor(uint32_t _colorFormat, uint32_t _width, uint32_t _height, GLenum _min, GLenum _mag);
void createDepth(uint32_t _width, uint32_t _height); void createDepth(uint32_t _width, uint32_t _height);
void destroy(); 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 setSamplerState(uint32_t _flags);
void commit(uint32_t _stage, uint32_t _flags); void commit(uint32_t _stage, uint32_t _flags);

View File

@ -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*/)
{ {
} }

View File

@ -102,6 +102,11 @@ namespace bgfx
m_stride += (*s_attribTypeSize[m_hash])[_type][_num-1]; 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 void VertexDecl::decode(Attrib::Enum _attrib, uint8_t& _num, AttribType::Enum& _type, bool& _normalized, bool& _asInt) const
{ {
uint8_t val = m_attributes[_attrib]; uint8_t val = m_attributes[_attrib];
@ -491,8 +496,53 @@ namespace bgfx
return xx*xx + yy*yy + zz*zz; 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) 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 hashSize = bx::uint32_nextpow2(_num);
const uint32_t hashMask = hashSize-1; const uint32_t hashMask = hashSize-1;
const float epsilonSq = _epsilon*_epsilon; const float epsilonSq = _epsilon*_epsilon;
@ -516,6 +566,7 @@ namespace bgfx
{ {
float test[4]; float test[4];
vertexUnpack(test, bgfx::Attrib::Position, _decl, _data, _output[offset]); vertexUnpack(test, bgfx::Attrib::Position, _decl, _data, _output[offset]);
if (sqLength(test, pos) < epsilonSq) if (sqLength(test, pos) < epsilonSq)
{ {
_output[ii] = _output[offset]; _output[ii] = _output[offset];
@ -533,6 +584,7 @@ namespace bgfx
} }
return numVertices; return numVertices;
#endif // 0
} }
} // namespace bgfx } // namespace bgfx

View File

@ -1273,6 +1273,13 @@ uint32_t parseInOut(InOut& _inout, const char* _str, const char* _eol)
return hash; return hash;
} }
// c - compute
// d - domain
// f - fragment
// g - geometry
// h - hull
// v - vertex
//
// OpenGL #version Features Direct3D Features Shader Model // OpenGL #version Features Direct3D Features Shader Model
// 2.1 120 vf 9.0 vf 2.0 // 2.1 120 vf 9.0 vf 2.0
// 3.0 130 // 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 // 3.3 330 10.0 vgf 4.0
// 4.0 400 vhdgf // 4.0 400 vhdgf
// 4.1 410 // 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) void help(const char* _error = NULL)
{ {

View File

@ -130,7 +130,7 @@ int main(int _argc, const char* _argv[])
|| height != mip.m_height) || height != mip.m_height)
{ {
uint8_t* temp = (uint8_t*)realloc(NULL, mip.m_width*mip.m_height*4); 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; uint32_t srcpitch = mip.m_width*4;
for (uint32_t yy = 0; yy < height; ++yy) for (uint32_t yy = 0; yy < height; ++yy)
@ -150,7 +150,7 @@ int main(int _argc, const char* _argv[])
} }
else 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]; char filePath[256];