Cleanup.
This commit is contained in:
parent
457996d407
commit
df88bc2106
@ -240,6 +240,8 @@ bgfx::TextureHandle loadTexture(bx::FileReaderI* _reader, const char* _filePath,
|
||||
break;
|
||||
|
||||
case LCT_PALETTE:
|
||||
format = bgfx::TextureFormat::R8;
|
||||
bpp = 8;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -3187,7 +3187,7 @@ namespace bgfx
|
||||
_imageContainer.m_height = height;
|
||||
_imageContainer.m_depth = depth;
|
||||
_imageContainer.m_format = format;
|
||||
_imageContainer.m_numLayers = 1;
|
||||
_imageContainer.m_numLayers = uint16_t(bx::uint32_max(numberOfArrayElements, 1) );
|
||||
_imageContainer.m_numMips = uint8_t(bx::uint32_max(numMips, 1) );
|
||||
_imageContainer.m_hasAlpha = hasAlpha;
|
||||
_imageContainer.m_cubeMap = numFaces > 1;
|
||||
@ -3768,7 +3768,7 @@ namespace bgfx
|
||||
}
|
||||
}
|
||||
|
||||
bool imageGetRawData(const ImageContainer& _imageContainer, uint8_t _side, uint8_t _lod, const void* _data, uint32_t _size, ImageMip& _mip)
|
||||
bool imageGetRawData(const ImageContainer& _imageContainer, uint16_t _side, uint8_t _lod, const void* _data, uint32_t _size, ImageMip& _mip)
|
||||
{
|
||||
uint32_t offset = _imageContainer.m_offset;
|
||||
TextureFormat::Enum format = TextureFormat::Enum(_imageContainer.m_format);
|
||||
@ -3795,6 +3795,7 @@ namespace bgfx
|
||||
}
|
||||
|
||||
const uint8_t* data = (const uint8_t*)_data;
|
||||
const uint16_t numSides = _imageContainer.m_numLayers * (_imageContainer.m_cubeMap ? 6 : 1);
|
||||
|
||||
if (_imageContainer.m_ktx)
|
||||
{
|
||||
@ -3814,7 +3815,7 @@ namespace bgfx
|
||||
uint32_t size = width*height*depth*bpp/8;
|
||||
BX_CHECK(size == imageSize, "KTX: Image size mismatch %d (expected %d).", size, imageSize);
|
||||
|
||||
for (uint8_t side = 0, numSides = _imageContainer.m_cubeMap ? 6 : 1; side < numSides; ++side)
|
||||
for (uint16_t side = 0; side < numSides; ++side)
|
||||
{
|
||||
if (side == _side
|
||||
&& lod == _lod)
|
||||
@ -3843,7 +3844,7 @@ namespace bgfx
|
||||
}
|
||||
else
|
||||
{
|
||||
for (uint8_t side = 0, numSides = _imageContainer.m_cubeMap ? 6 : 1; side < numSides; ++side)
|
||||
for (uint16_t side = 0; side < numSides; ++side)
|
||||
{
|
||||
uint32_t width = _imageContainer.m_width;
|
||||
uint32_t height = _imageContainer.m_height;
|
||||
@ -3937,19 +3938,19 @@ namespace bgfx
|
||||
|
||||
int32_t size = 0;
|
||||
size += bx::write(_writer, "\xabKTX 11\xbb\r\n\x1a\n", 12, _err);
|
||||
size += bx::write(_writer, UINT32_C(0x04030201), _err);
|
||||
size += bx::write(_writer, UINT32_C(0), _err); // glType
|
||||
size += bx::write(_writer, UINT32_C(1), _err); // glTypeSize
|
||||
size += bx::write(_writer, UINT32_C(0), _err); // glFormat
|
||||
size += bx::write(_writer, uint32_t(0x04030201), _err);
|
||||
size += bx::write(_writer, uint32_t(0), _err); // glType
|
||||
size += bx::write(_writer, uint32_t(1), _err); // glTypeSize
|
||||
size += bx::write(_writer, uint32_t(0), _err); // glFormat
|
||||
size += bx::write(_writer, tfi.m_internalFmt, _err); // glInternalFormat
|
||||
size += bx::write(_writer, tfi.m_fmt, _err); // glBaseInternalFormat
|
||||
size += bx::write(_writer, _width, _err);
|
||||
size += bx::write(_writer, _height, _err);
|
||||
size += bx::write(_writer, _depth, _err);
|
||||
size += bx::write(_writer, UINT32_C(0), _err); // numberOfArrayElements
|
||||
size += bx::write(_writer, _cubeMap ? UINT32_C(6) : UINT32_C(0), _err);
|
||||
size += bx::write(_writer, uint32_t(0), _err); // numberOfArrayElements
|
||||
size += bx::write(_writer, _cubeMap ? uint32_t(6) : uint32_t(0), _err);
|
||||
size += bx::write(_writer, uint32_t(_numMips), _err);
|
||||
size += bx::write(_writer, UINT32_C(0), _err); // Meta-data size.
|
||||
size += bx::write(_writer, uint32_t(0), _err); // Meta-data size.
|
||||
|
||||
BX_WARN(size == 64, "KTX: Failed to write header size %d (expected: %d).", size, 64);
|
||||
return size;
|
||||
|
@ -373,7 +373,7 @@ namespace bgfx
|
||||
void imageDecodeToRgba32f(bx::AllocatorI* _allocator, void* _dst, const void* _src, uint32_t _width, uint32_t _height, uint32_t _pitch, TextureFormat::Enum _format);
|
||||
|
||||
///
|
||||
bool imageGetRawData(const ImageContainer& _imageContainer, uint8_t _side, uint8_t _index, const void* _data, uint32_t _size, ImageMip& _mip);
|
||||
bool imageGetRawData(const ImageContainer& _imageContainer, uint16_t _side, uint8_t _index, const void* _data, uint32_t _size, ImageMip& _mip);
|
||||
|
||||
} // namespace bgfx
|
||||
|
||||
|
@ -4119,23 +4119,23 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
{
|
||||
for (uint32_t ii = 0; ii < count; ++ii)
|
||||
{
|
||||
uint8_t nameSize;
|
||||
uint8_t nameSize = 0;
|
||||
bx::read(&reader, nameSize);
|
||||
|
||||
char name[256];
|
||||
char name[256] = { '\0' };
|
||||
bx::read(&reader, &name, nameSize);
|
||||
name[nameSize] = '\0';
|
||||
|
||||
uint8_t type;
|
||||
uint8_t type = 0;
|
||||
bx::read(&reader, type);
|
||||
|
||||
uint8_t num;
|
||||
uint8_t num = 0;
|
||||
bx::read(&reader, num);
|
||||
|
||||
uint16_t regIndex;
|
||||
uint16_t regIndex = 0;
|
||||
bx::read(&reader, regIndex);
|
||||
|
||||
uint16_t regCount;
|
||||
uint16_t regCount = 0;
|
||||
bx::read(&reader, regCount);
|
||||
|
||||
const char* kind = "invalid";
|
||||
@ -4213,7 +4213,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
BGFX_FATAL(NULL != m_ptr, bgfx::Fatal::InvalidShader, "Failed to create compute shader.");
|
||||
}
|
||||
|
||||
uint8_t numAttrs;
|
||||
uint8_t numAttrs = 0;
|
||||
bx::read(&reader, numAttrs);
|
||||
|
||||
memset(m_attrMask, 0, sizeof(m_attrMask) );
|
||||
@ -4259,7 +4259,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
const ImageBlockInfo& blockInfo = getBlockInfo(TextureFormat::Enum(imageContainer.m_format) );
|
||||
const uint32_t textureWidth = bx::uint32_max(blockInfo.blockWidth, imageContainer.m_width >>startLod);
|
||||
const uint32_t textureHeight = bx::uint32_max(blockInfo.blockHeight, imageContainer.m_height>>startLod);
|
||||
const uint32_t numLayers = imageContainer.m_numLayers;
|
||||
const uint16_t numLayers = imageContainer.m_numLayers;
|
||||
|
||||
m_flags = _flags;
|
||||
m_width = textureWidth;
|
||||
@ -4285,7 +4285,8 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
|
||||
m_numMips = numMips;
|
||||
|
||||
uint32_t numSrd = numMips*(imageContainer.m_cubeMap ? 6 : 1);
|
||||
const uint16_t numSides = numLayers * (imageContainer.m_cubeMap ? 6 : 1);
|
||||
const uint32_t numSrd = numSides * numMips;
|
||||
D3D11_SUBRESOURCE_DATA* srd = (D3D11_SUBRESOURCE_DATA*)alloca(numSrd*sizeof(D3D11_SUBRESOURCE_DATA) );
|
||||
|
||||
uint32_t kk = 0;
|
||||
@ -4304,7 +4305,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
, swizzle ? " (swizzle BGRA8 -> RGBA8)" : ""
|
||||
);
|
||||
|
||||
for (uint8_t side = 0, numSides = imageContainer.m_cubeMap ? 6 : 1; side < numSides; ++side)
|
||||
for (uint16_t side = 0; side < numSides; ++side)
|
||||
{
|
||||
uint32_t width = textureWidth;
|
||||
uint32_t height = textureHeight;
|
||||
@ -4539,7 +4540,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
&& 0 != kk)
|
||||
{
|
||||
kk = 0;
|
||||
for (uint8_t side = 0, numSides = imageContainer.m_cubeMap ? 6 : 1; side < numSides; ++side)
|
||||
for (uint16_t side = 0; side < numSides; ++side)
|
||||
{
|
||||
for (uint32_t lod = 0, num = numMips; lod < num; ++lod)
|
||||
{
|
||||
@ -4593,7 +4594,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
{
|
||||
layer = _z * (TextureD3D11::TextureCube == m_type ? 6 : 1);
|
||||
box.front = 0;
|
||||
box.back = 1;
|
||||
box.back = 0;
|
||||
}
|
||||
|
||||
const uint32_t subres = _mip + ( (layer + _side) * m_numMips);
|
||||
|
@ -4604,6 +4604,7 @@ BX_TRACE("zoffset %d, depth %d", _zoffset, _depth);
|
||||
uint8_t numMips = imageContainer.m_numMips;
|
||||
const uint8_t startLod = uint8_t(bx::uint32_min(_skip, numMips-1) );
|
||||
numMips -= startLod;
|
||||
const uint16_t numLayers = imageContainer.m_numLayers;
|
||||
uint32_t textureWidth;
|
||||
uint32_t textureHeight;
|
||||
uint32_t textureDepth;
|
||||
@ -4637,7 +4638,7 @@ BX_TRACE("zoffset %d, depth %d", _zoffset, _depth);
|
||||
target = GL_TEXTURE_3D;
|
||||
}
|
||||
|
||||
if (1 < imageContainer.m_numLayers)
|
||||
if (1 < numLayers)
|
||||
{
|
||||
switch (target)
|
||||
{
|
||||
@ -4684,7 +4685,7 @@ BX_TRACE("zoffset %d, depth %d", _zoffset, _depth);
|
||||
, this - s_renderGL->m_textures
|
||||
, getName( (TextureFormat::Enum)m_textureFormat)
|
||||
, getName( (TextureFormat::Enum)m_requestedFormat)
|
||||
, imageContainer.m_numLayers
|
||||
, numLayers
|
||||
, textureWidth
|
||||
, textureHeight
|
||||
, imageContainer.m_cubeMap ? 6 : (1 < imageContainer.m_depth ? imageContainer.m_depth : 0)
|
||||
@ -4705,7 +4706,9 @@ BX_TRACE("zoffset %d, depth %d", _zoffset, _depth);
|
||||
temp = (uint8_t*)BX_ALLOC(g_allocator, textureWidth*textureHeight*4);
|
||||
}
|
||||
|
||||
for (uint8_t side = 0, numSides = imageContainer.m_cubeMap ? 6 : 1; side < numSides; ++side)
|
||||
const uint16_t numSides = numLayers * (imageContainer.m_cubeMap ? 6 : 1);
|
||||
|
||||
for (uint16_t side = 0; side < numSides; ++side)
|
||||
{
|
||||
uint32_t width = textureWidth;
|
||||
uint32_t height = textureHeight;
|
||||
|
Loading…
Reference in New Issue
Block a user