Minor fixes

This commit is contained in:
Jérôme Leclercq
2021-10-29 13:29:49 +02:00
parent 0dbb77de10
commit 32c204e95f
10 changed files with 108 additions and 104 deletions

View File

@@ -49,8 +49,6 @@ namespace Nz
m_deviceInfo.type = RenderDeviceType::Unknown;
const GL::ContextParams& params = m_referenceContext->GetParams();
// Features
if (m_referenceContext->IsExtensionSupported(GL::Extension::TextureFilterAnisotropic))
m_deviceInfo.features.anisotropicFiltering = true;

View File

@@ -91,7 +91,7 @@ namespace Nz
std::shared_ptr<Image> image = std::make_shared<Image>(type, format, width, height, depth, levelCount);
// Read all mipmap levels
for (unsigned int i = 0; i < image->GetLevelCount(); i++)
for (UInt8 i = 0; i < image->GetLevelCount(); i++)
{
std::size_t byteCount = PixelFormatInfo::ComputeSize(format, width, height, depth);
@@ -167,7 +167,7 @@ namespace Nz
{
if (header.format.flags & (DDPF_RGB | DDPF_ALPHA | DDPF_ALPHAPIXELS | DDPF_LUMINANCE))
{
PixelFormatDescription info(PixelFormatContent::ColorRGBA, header.format.bpp, PixelFormatSubType::Unsigned);
PixelFormatDescription info(PixelFormatContent::ColorRGBA, SafeCast<UInt8>(header.format.bpp), PixelFormatSubType::Unsigned);
if (header.format.flags & DDPF_RGB)
{

View File

@@ -39,10 +39,10 @@ namespace Nz
}
const MD5AnimParser::Frame* frames = parser.GetFrames();
std::size_t frameCount = parser.GetFrameCount();
std::size_t frameRate = parser.GetFrameRate();
UInt32 frameCount = parser.GetFrameCount();
UInt32 frameRate = parser.GetFrameRate();
const MD5AnimParser::Joint* joints = parser.GetJoints();
std::size_t jointCount = parser.GetJointCount();
UInt32 jointCount = parser.GetJointCount();
// À ce stade, nous sommes censés avoir assez d'informations pour créer l'animation
std::shared_ptr<Animation> animation = std::make_shared<Animation>();
@@ -62,10 +62,10 @@ namespace Nz
Quaternionf rotationQuat = Quaternionf::RotationBetween(Vector3f::UnitX(), Vector3f::Forward()) *
Quaternionf::RotationBetween(Vector3f::UnitZ(), Vector3f::Up());
for (std::size_t i = 0; i < jointCount; ++i)
for (UInt32 i = 0; i < jointCount; ++i)
{
int parent = joints[i].parent;
for (std::size_t j = 0; j < frameCount; ++j)
for (UInt32 j = 0; j < frameCount; ++j)
{
SequenceJoint& sequenceJoint = sequenceJoints[j*jointCount + i];

View File

@@ -100,8 +100,8 @@ namespace Nz
UInt8* pixels = image->GetPixels();
int rle_value = 0;
unsigned int rle_count = 0;
UInt8 rleValue = 0;
UInt8 rleCount = 0;
switch (bitCount)
{
@@ -115,20 +115,20 @@ namespace Nz
/* decode line number y */
while (bytes--)
{
if (rle_count == 0)
if (rleCount == 0)
{
if (!stream.Read(&rle_value, 1))
if (!stream.Read(&rleValue, 1))
{
NazaraError("Failed to read stream (byte " + NumberToString(stream.GetCursorPos()) + ')');
return nullptr;
}
if (rle_value < 0xc0)
rle_count = 1;
if (rleValue < 0xc0)
rleCount = 1;
else
{
rle_count = rle_value - 0xc0;
if (!stream.Read(&rle_value, 1))
rleCount = rleValue - 0xc0;
if (!stream.Read(&rleValue, 1))
{
NazaraError("Failed to read stream (byte " + NumberToString(stream.GetCursorPos()) + ')');
return nullptr;
@@ -136,11 +136,11 @@ namespace Nz
}
}
rle_count--;
rleCount--;
for (int i = 7; i >= 0; --i)
{
int colorIndex = ((rle_value & (1 << i)) > 0);
int colorIndex = ((rleValue & (1 << i)) > 0);
*ptr++ = header.palette[colorIndex * 3 + 0];
*ptr++ = header.palette[colorIndex * 3 + 1];
@@ -170,20 +170,20 @@ namespace Nz
/* decode line number y */
while (bytes--)
{
if (rle_count == 0)
if (rleCount == 0)
{
if (!stream.Read(&rle_value, 1))
if (!stream.Read(&rleValue, 1))
{
NazaraError("Failed to read stream (byte " + NumberToString(stream.GetCursorPos()) + ')');
return nullptr;
}
if (rle_value < 0xc0)
rle_count = 1;
if (rleValue < 0xc0)
rleCount = 1;
else
{
rle_count = rle_value - 0xc0;
if (!stream.Read(&rle_value, 1))
rleCount = rleValue - 0xc0;
if (!stream.Read(&rleValue, 1))
{
NazaraError("Failed to read stream (byte " + NumberToString(stream.GetCursorPos()) + ')');
return nullptr;
@@ -191,8 +191,8 @@ namespace Nz
}
}
rle_count--;
*(pLine++) = rle_value;
rleCount--;
*(pLine++) = rleValue;
}
/* compute line's color indexes */
@@ -254,20 +254,20 @@ namespace Nz
/* decode line number y */
while (bytes--)
{
if (rle_count == 0)
if (rleCount == 0)
{
if (!stream.Read(&rle_value, 1))
if (!stream.Read(&rleValue, 1))
{
NazaraError("Failed to read stream (byte " + NumberToString(stream.GetCursorPos()) + ')');
return nullptr;
}
if (rle_value < 0xc0)
rle_count = 1;
if (rleValue < 0xc0)
rleCount = 1;
else
{
rle_count = rle_value - 0xc0;
if (!stream.Read(&rle_value, 1))
rleCount = rleValue - 0xc0;
if (!stream.Read(&rleValue, 1))
{
NazaraError("Failed to read stream (byte " + NumberToString(stream.GetCursorPos()) + ')');
return nullptr;
@@ -275,11 +275,11 @@ namespace Nz
}
}
rle_count--;
rleCount--;
*ptr++ = palette[rle_value * 3 + 0];
*ptr++ = palette[rle_value * 3 + 1];
*ptr++ = palette[rle_value * 3 + 2];
*ptr++ = palette[rleValue * 3 + 0];
*ptr++ = palette[rleValue * 3 + 1];
*ptr++ = palette[rleValue * 3 + 2];
}
}
break;
@@ -298,20 +298,20 @@ namespace Nz
/* decode line number y */
while (bytes--)
{
if (rle_count == 0)
if (rleCount == 0)
{
if (!stream.Read(&rle_value, 1))
if (!stream.Read(&rleValue, 1))
{
NazaraError("Failed to read stream (byte " + NumberToString(stream.GetCursorPos()) + ')');
return nullptr;
}
if (rle_value < 0xc0)
rle_count = 1;
if (rleValue < 0xc0)
rleCount = 1;
else
{
rle_count = rle_value - 0xc0;
if (!stream.Read(&rle_value, 1))
rleCount = rleValue - 0xc0;
if (!stream.Read(&rleValue, 1))
{
NazaraError("Failed to read stream (byte " + NumberToString(stream.GetCursorPos()) + ')');
return nullptr;
@@ -319,8 +319,8 @@ namespace Nz
}
}
rle_count--;
ptr[c] = static_cast<UInt8>(rle_value);
rleCount--;
ptr[c] = static_cast<UInt8>(rleValue);
ptr += 3;
}
}

View File

@@ -3,6 +3,7 @@
// For conditions of distribution and use, see copyright notice in Config.hpp
#include <Nazara/Utility/PixelFormat.hpp>
#include <Nazara/Core/Algorithm.hpp>
#include <Nazara/Core/Endianness.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Utility/Debug.hpp>
@@ -635,7 +636,7 @@ namespace Nz
{
UInt16 l = static_cast<UInt16>(c8to4(start[0]));
*ptr = (l << 12) | (l << 8) | (l << 4) | c8to4(start[1]);
*ptr = (l << 12) | (l << 8) | (l << 4) | c8to4(SafeCast<UInt8>(start[1]));
#ifdef NAZARA_BIG_ENDIAN
SwapBytes(ptr, sizeof(UInt16));
@@ -676,7 +677,7 @@ namespace Nz
SwapBytes(&pixel, sizeof(UInt16));
#endif
*dst++ = c4to8(pixel & 0x000F);
*dst++ = c4to8(SafeCast<UInt8>(pixel & 0x000F));
start += 2;
}
@@ -695,9 +696,9 @@ namespace Nz
SwapBytes(&pixel, sizeof(UInt16));
#endif
*dst++ = c4to8((pixel & 0x00F0) >> 4);
*dst++ = c4to8((pixel & 0x0F00) >> 8);
*dst++ = c4to8((pixel & 0xF000) >> 12);
*dst++ = c4to8(SafeCast<UInt8>((pixel & 0x00F0) >> 4));
*dst++ = c4to8(SafeCast<UInt8>((pixel & 0x0F00) >> 8));
*dst++ = c4to8(SafeCast<UInt8>((pixel & 0xF000) >> 12));
start += 2;
}
@@ -716,10 +717,10 @@ namespace Nz
SwapBytes(&pixel, sizeof(UInt16));
#endif
*dst++ = c4to8((pixel & 0x00F0) >> 4);
*dst++ = c4to8((pixel & 0x0F00) >> 8);
*dst++ = c4to8((pixel & 0xF000) >> 12);
*dst++ = c4to8((pixel & 0x000F) >> 0);
*dst++ = c4to8(SafeCast<UInt8>((pixel & 0x00F0) >> 4));
*dst++ = c4to8(SafeCast<UInt8>((pixel & 0x0F00) >> 8));
*dst++ = c4to8(SafeCast<UInt8>((pixel & 0xF000) >> 12));
*dst++ = c4to8(SafeCast<UInt8>((pixel & 0x000F) >> 0));
start += 2;
}
@@ -738,9 +739,9 @@ namespace Nz
SwapBytes(&pixel, sizeof(UInt16));
#endif
UInt16 r = c4to8((pixel & 0xF000) >> 12);
UInt16 g = c4to8((pixel & 0x0F00) >> 8);
UInt16 b = c4to8((pixel & 0x00F0) >> 4);
UInt16 r = c4to8(SafeCast<UInt8>((pixel & 0xF000) >> 12));
UInt16 g = c4to8(SafeCast<UInt8>((pixel & 0x0F00) >> 8));
UInt16 b = c4to8(SafeCast<UInt8>((pixel & 0x00F0) >> 4));
*dst++ = static_cast<UInt8>(r * 0.3f + g * 0.59f + b * 0.11f);
@@ -761,9 +762,9 @@ namespace Nz
SwapBytes(&pixel, sizeof(UInt16));
#endif
UInt16 r = c4to8((pixel & 0xF000) >> 12);
UInt16 g = c4to8((pixel & 0x0F00) >> 8);
UInt16 b = c4to8((pixel & 0x00F0) >> 4);
UInt16 r = c4to8(SafeCast<UInt8>((pixel & 0xF000) >> 12));
UInt16 g = c4to8(SafeCast<UInt8>((pixel & 0x0F00) >> 8));
UInt16 b = c4to8(SafeCast<UInt8>((pixel & 0x00F0) >> 4));
*dst++ = static_cast<UInt8>(r * 0.3f + g * 0.59f + b * 0.11f);
*dst++ = c4to8(pixel & 0x000F);
@@ -786,10 +787,10 @@ namespace Nz
SwapBytes(&pixel, sizeof(UInt16));
#endif
UInt16 r = c4to5((pixel & 0xF000) >> 12);
UInt16 g = c4to5((pixel & 0x0F00) >> 8);
UInt16 b = c4to5((pixel & 0x00F0) >> 4);
UInt16 a = c4to5((pixel & 0x000F) >> 0);
UInt16 r = c4to5(SafeCast<UInt8>((pixel & 0xF000) >> 12));
UInt16 g = c4to5(SafeCast<UInt8>((pixel & 0x0F00) >> 8));
UInt16 b = c4to5(SafeCast<UInt8>((pixel & 0x00F0) >> 4));
UInt16 a = c4to5(SafeCast<UInt8>((pixel & 0x000F) >> 0));
*ptr = (r << 11) | (g << 6) | (b << 1) | ((a > 0x3) ? 1 : 0);
@@ -815,9 +816,9 @@ namespace Nz
SwapBytes(&pixel, sizeof(UInt16));
#endif
*dst++ = c4to8((pixel & 0xF000) >> 12);
*dst++ = c4to8((pixel & 0x0F00) >> 8);
*dst++ = c4to8((pixel & 0x00F0) >> 4);
*dst++ = c4to8(SafeCast<UInt8>((pixel & 0xF000) >> 12));
*dst++ = c4to8(SafeCast<UInt8>((pixel & 0x0F00) >> 8));
*dst++ = c4to8(SafeCast<UInt8>((pixel & 0x00F0) >> 4));
start += 2;
}
@@ -836,10 +837,10 @@ namespace Nz
SwapBytes(&pixel, sizeof(UInt16));
#endif
*dst++ = c4to8((pixel & 0xF000) >> 12);
*dst++ = c4to8((pixel & 0x0F00) >> 8);
*dst++ = c4to8((pixel & 0x00F0) >> 4);
*dst++ = c4to8((pixel & 0x000F) >> 0);
*dst++ = c4to8(SafeCast<UInt8>((pixel & 0xF000) >> 12));
*dst++ = c4to8(SafeCast<UInt8>((pixel & 0x0F00) >> 8));
*dst++ = c4to8(SafeCast<UInt8>((pixel & 0x00F0) >> 4));
*dst++ = c4to8(SafeCast<UInt8>((pixel & 0x000F) >> 0));
start += 2;
}
@@ -859,7 +860,7 @@ namespace Nz
SwapBytes(&pixel, sizeof(UInt16));
#endif
*dst++ = static_cast<UInt8>((pixel & 0x1)*0xFF);
*dst++ = SafeCast<UInt8>((pixel & 0x1) * 0xFF);
start += 2;
}
@@ -878,9 +879,9 @@ namespace Nz
SwapBytes(&pixel, sizeof(UInt16));
#endif
*dst++ = c5to8((pixel & 0x003E) >> 1);
*dst++ = c5to8((pixel & 0x07C0) >> 6);
*dst++ = c5to8((pixel & 0xF800) >> 11);
*dst++ = c5to8(SafeCast<UInt8>((pixel & 0x003E) >> 1));
*dst++ = c5to8(SafeCast<UInt8>((pixel & 0x07C0) >> 6));
*dst++ = c5to8(SafeCast<UInt8>((pixel & 0xF800) >> 11));
start += 2;
}
@@ -899,9 +900,9 @@ namespace Nz
SwapBytes(&pixel, sizeof(UInt16));
#endif
*dst++ = c5to8((pixel & 0x003E) >> 1);
*dst++ = c5to8((pixel & 0x07C0) >> 6);
*dst++ = c5to8((pixel & 0xF800) >> 11);
*dst++ = c5to8(SafeCast<UInt8>((pixel & 0x003E) >> 1));
*dst++ = c5to8(SafeCast<UInt8>((pixel & 0x07C0) >> 6));
*dst++ = c5to8(SafeCast<UInt8>((pixel & 0xF800) >> 11));
*dst++ = static_cast<UInt8>((pixel & 0x1)*0xFF);
start += 2;
@@ -921,9 +922,9 @@ namespace Nz
SwapBytes(&pixel, sizeof(UInt16));
#endif
UInt8 r = c5to8((pixel & 0xF800) >> 11);
UInt8 g = c5to8((pixel & 0x07C0) >> 6);
UInt8 b = c5to8((pixel & 0x003E) >> 1);
UInt8 r = c5to8(SafeCast<UInt8>((pixel & 0xF800) >> 11));
UInt8 g = c5to8(SafeCast<UInt8>((pixel & 0x07C0) >> 6));
UInt8 b = c5to8(SafeCast<UInt8>((pixel & 0x003E) >> 1));
*dst++ = static_cast<UInt8>(r * 0.3f + g * 0.59f + b * 0.11f);
@@ -944,9 +945,9 @@ namespace Nz
SwapBytes(&pixel, sizeof(UInt16));
#endif
UInt8 r = c5to8((pixel & 0xF800) >> 11);
UInt8 g = c5to8((pixel & 0x07C0) >> 6);
UInt8 b = c5to8((pixel & 0x003E) >> 1);
UInt8 r = c5to8(SafeCast<UInt8>((pixel & 0xF800) >> 11));
UInt8 g = c5to8(SafeCast<UInt8>((pixel & 0x07C0) >> 6));
UInt8 b = c5to8(SafeCast<UInt8>((pixel & 0x003E) >> 1));
*dst++ = static_cast<UInt8>(r * 0.3f + g * 0.59f + b * 0.11f);
*dst++ = static_cast<UInt8>((pixel & 0x1)*0xFF);
@@ -968,9 +969,9 @@ namespace Nz
SwapBytes(&pixel, sizeof(UInt16));
#endif
*dst++ = c5to8((pixel & 0xF800) >> 11);
*dst++ = c5to8((pixel & 0x07C0) >> 6);
*dst++ = c5to8((pixel & 0x003E) >> 1);
*dst++ = c5to8(SafeCast<UInt8>((pixel & 0xF800) >> 11));
*dst++ = c5to8(SafeCast<UInt8>((pixel & 0x07C0) >> 6));
*dst++ = c5to8(SafeCast<UInt8>((pixel & 0x003E) >> 1));
start += 2;
}
@@ -990,9 +991,9 @@ namespace Nz
SwapBytes(&pixel, sizeof(UInt16));
#endif
UInt8 r = c5to4((pixel & 0xF800) >> 11);
UInt8 g = c5to4((pixel & 0x07C0) >> 6);
UInt8 b = c5to4((pixel & 0x003E) >> 1);
UInt8 r = c5to4(SafeCast<UInt8>((pixel & 0xF800) >> 11));
UInt8 g = c5to4(SafeCast<UInt8>((pixel & 0x07C0) >> 6));
UInt8 b = c5to4(SafeCast<UInt8>((pixel & 0x003E) >> 1));
*ptr = (r << 12) | (g << 8) | (b << 4) | ((pixel & 0x1)*0x0F);
@@ -1018,10 +1019,10 @@ namespace Nz
SwapBytes(&pixel, sizeof(UInt16));
#endif
*dst++ = c5to8((pixel & 0xF800) >> 11);
*dst++ = c5to8((pixel & 0x07C0) >> 6);
*dst++ = c5to8((pixel & 0x003E) >> 1);
*dst++ = static_cast<UInt8>((pixel & 0x1)*0xFF);
*dst++ = c5to8(SafeCast<UInt8>((pixel & 0xF800) >> 11));
*dst++ = c5to8(SafeCast<UInt8>((pixel & 0x07C0) >> 6));
*dst++ = c5to8(SafeCast<UInt8>((pixel & 0x003E) >> 1));
*dst++ = SafeCast<UInt8>((pixel & 0x1) * 0xFF);
start += 2;
}

View File

@@ -313,7 +313,7 @@ namespace Nz
0,
subresourceLayers,
{ // imageOffset
box.x, box.y, box.z
SafeCast<Int32>(box.x), SafeCast<Int32>(box.y), SafeCast<Int32>(box.z)
},
{ // imageExtent
box.width, box.height, box.depth
@@ -322,7 +322,7 @@ namespace Nz
copyCommandBuffer->SetImageLayout(m_image, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, subresourceRange);
copyCommandBuffer->CopyBufferToImage(stagingBuffer, m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, subresourceLayers, region);
copyCommandBuffer->CopyBufferToImage(stagingBuffer, m_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, region);
copyCommandBuffer->SetImageLayout(m_image, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, subresourceRange);