From 32c204e95f085e4c0f415c500f623756b60143c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Fri, 29 Oct 2021 13:29:49 +0200 Subject: [PATCH] Minor fixes --- include/Nazara/Math/Quaternion.inl | 2 +- include/Nazara/VulkanRenderer/Utils.inl | 5 + .../VulkanRenderer/Wrapper/CommandBuffer.hpp | 4 +- .../VulkanRenderer/Wrapper/CommandBuffer.inl | 10 +- src/Nazara/OpenGLRenderer/OpenGLDevice.cpp | 2 - src/Nazara/Utility/Formats/DDSLoader.cpp | 4 +- src/Nazara/Utility/Formats/MD5AnimLoader.cpp | 10 +- src/Nazara/Utility/Formats/PCXLoader.cpp | 72 +++++++------- src/Nazara/Utility/PixelFormat.cpp | 99 ++++++++++--------- src/Nazara/VulkanRenderer/VulkanTexture.cpp | 4 +- 10 files changed, 108 insertions(+), 104 deletions(-) diff --git a/include/Nazara/Math/Quaternion.inl b/include/Nazara/Math/Quaternion.inl index 6570edbc0..b5b3675b6 100644 --- a/include/Nazara/Math/Quaternion.inl +++ b/include/Nazara/Math/Quaternion.inl @@ -781,7 +781,7 @@ namespace Nz #ifdef NAZARA_DEBUG if (interpolation < T(0.0) || interpolation > T(1.0)) { - NazaraError("Interpolation must be in range [0..1] (Got " + NumberToString(interpolation) + ')'); + NazaraError("Interpolation must be in range [0..1] (Got " + std::to_string(interpolation) + ')'); return Zero(); } #endif diff --git a/include/Nazara/VulkanRenderer/Utils.inl b/include/Nazara/VulkanRenderer/Utils.inl index 0dfbe876f..5c079d85a 100644 --- a/include/Nazara/VulkanRenderer/Utils.inl +++ b/include/Nazara/VulkanRenderer/Utils.inl @@ -249,6 +249,9 @@ namespace Nz { switch (pixelFormat) { + // TODO: Fill this switch + case PixelFormat::BGR8: return VK_FORMAT_B8G8R8_UNORM; + case PixelFormat::BGR8_SRGB: return VK_FORMAT_B8G8R8_SRGB; case PixelFormat::BGRA8: return VK_FORMAT_B8G8R8A8_UNORM; case PixelFormat::BGRA8_SRGB: return VK_FORMAT_B8G8R8A8_SRGB; case PixelFormat::Depth16: return VK_FORMAT_D16_UNORM; @@ -256,6 +259,8 @@ namespace Nz case PixelFormat::Depth24Stencil8: return VK_FORMAT_D24_UNORM_S8_UINT; case PixelFormat::Depth32F: return VK_FORMAT_D32_SFLOAT; case PixelFormat::Depth32FStencil8: return VK_FORMAT_D32_SFLOAT_S8_UINT; + case PixelFormat::RGB8: return VK_FORMAT_R8G8B8_UNORM; + case PixelFormat::RGB8_SRGB: return VK_FORMAT_R8G8B8_SRGB; case PixelFormat::RGBA8: return VK_FORMAT_R8G8B8A8_UNORM; case PixelFormat::RGBA8_SRGB: return VK_FORMAT_R8G8B8A8_SRGB; case PixelFormat::RGBA32F: return VK_FORMAT_R32G32B32A32_SFLOAT; diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp index 10db6a57a..f99b135e6 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.hpp @@ -59,8 +59,8 @@ namespace Nz inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, UInt32 width, UInt32 height, UInt32 depth = 1); inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkImageSubresourceLayers& subresourceLayers, Int32 x, Int32 y, Int32 z, UInt32 width, UInt32 height, UInt32 depth); inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkImageSubresourceLayers& subresourceLayers, UInt32 width, UInt32 height, UInt32 depth = 1); - inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkImageSubresourceLayers& subresourceLayers, const VkBufferImageCopy& region); - inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkImageSubresourceLayers& subresourceLayers, UInt32 regionCount, const VkBufferImageCopy* regions); + inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkBufferImageCopy& region); + inline void CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, UInt32 regionCount, const VkBufferImageCopy* regions); inline void CopyImage(VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, const VkImageCopy& region); inline void CopyImage(VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, UInt32 regionCount, const VkImageCopy* regions); diff --git a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl index 2b98cbb37..31da02182 100644 --- a/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl +++ b/include/Nazara/VulkanRenderer/Wrapper/CommandBuffer.inl @@ -251,7 +251,7 @@ namespace Nz } }; - return CopyBufferToImage(source, target, targetLayout, subresourceLayers, region); + return CopyBufferToImage(source, target, targetLayout, region); } inline void CommandBuffer::CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkImageSubresourceLayers& subresourceLayers, UInt32 width, UInt32 height, UInt32 depth) @@ -269,15 +269,15 @@ namespace Nz } }; - return CopyBufferToImage(source, target, targetLayout, subresourceLayers, region); + return CopyBufferToImage(source, target, targetLayout, region); } - inline void CommandBuffer::CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkImageSubresourceLayers& subresourceLayers, const VkBufferImageCopy& region) + inline void CommandBuffer::CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkBufferImageCopy& region) { - return CopyBufferToImage(source, target, targetLayout, subresourceLayers, 1, ®ion); + return CopyBufferToImage(source, target, targetLayout, 1, ®ion); } - inline void CommandBuffer::CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, const VkImageSubresourceLayers& subresourceLayers, UInt32 regionCount, const VkBufferImageCopy* regions) + inline void CommandBuffer::CopyBufferToImage(VkBuffer source, VkImage target, VkImageLayout targetLayout, UInt32 regionCount, const VkBufferImageCopy* regions) { return m_pool->GetDevice()->vkCmdCopyBufferToImage(m_handle, source, target, targetLayout, regionCount, regions); } diff --git a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp index 332dcc5d6..1e51f5902 100644 --- a/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp +++ b/src/Nazara/OpenGLRenderer/OpenGLDevice.cpp @@ -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; diff --git a/src/Nazara/Utility/Formats/DDSLoader.cpp b/src/Nazara/Utility/Formats/DDSLoader.cpp index 5ff758261..a8a7dcf47 100644 --- a/src/Nazara/Utility/Formats/DDSLoader.cpp +++ b/src/Nazara/Utility/Formats/DDSLoader.cpp @@ -91,7 +91,7 @@ namespace Nz std::shared_ptr image = std::make_shared(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(header.format.bpp), PixelFormatSubType::Unsigned); if (header.format.flags & DDPF_RGB) { diff --git a/src/Nazara/Utility/Formats/MD5AnimLoader.cpp b/src/Nazara/Utility/Formats/MD5AnimLoader.cpp index 9e1014711..9e73edee6 100644 --- a/src/Nazara/Utility/Formats/MD5AnimLoader.cpp +++ b/src/Nazara/Utility/Formats/MD5AnimLoader.cpp @@ -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 = std::make_shared(); @@ -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]; diff --git a/src/Nazara/Utility/Formats/PCXLoader.cpp b/src/Nazara/Utility/Formats/PCXLoader.cpp index e2577a1d5..e8fe2c46b 100644 --- a/src/Nazara/Utility/Formats/PCXLoader.cpp +++ b/src/Nazara/Utility/Formats/PCXLoader.cpp @@ -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(rle_value); + rleCount--; + ptr[c] = static_cast(rleValue); ptr += 3; } } diff --git a/src/Nazara/Utility/PixelFormat.cpp b/src/Nazara/Utility/PixelFormat.cpp index d9ff23298..a5e96f68e 100644 --- a/src/Nazara/Utility/PixelFormat.cpp +++ b/src/Nazara/Utility/PixelFormat.cpp @@ -3,6 +3,7 @@ // For conditions of distribution and use, see copyright notice in Config.hpp #include +#include #include #include #include @@ -635,7 +636,7 @@ namespace Nz { UInt16 l = static_cast(c8to4(start[0])); - *ptr = (l << 12) | (l << 8) | (l << 4) | c8to4(start[1]); + *ptr = (l << 12) | (l << 8) | (l << 4) | c8to4(SafeCast(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(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((pixel & 0x00F0) >> 4)); + *dst++ = c4to8(SafeCast((pixel & 0x0F00) >> 8)); + *dst++ = c4to8(SafeCast((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((pixel & 0x00F0) >> 4)); + *dst++ = c4to8(SafeCast((pixel & 0x0F00) >> 8)); + *dst++ = c4to8(SafeCast((pixel & 0xF000) >> 12)); + *dst++ = c4to8(SafeCast((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((pixel & 0xF000) >> 12)); + UInt16 g = c4to8(SafeCast((pixel & 0x0F00) >> 8)); + UInt16 b = c4to8(SafeCast((pixel & 0x00F0) >> 4)); *dst++ = static_cast(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((pixel & 0xF000) >> 12)); + UInt16 g = c4to8(SafeCast((pixel & 0x0F00) >> 8)); + UInt16 b = c4to8(SafeCast((pixel & 0x00F0) >> 4)); *dst++ = static_cast(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((pixel & 0xF000) >> 12)); + UInt16 g = c4to5(SafeCast((pixel & 0x0F00) >> 8)); + UInt16 b = c4to5(SafeCast((pixel & 0x00F0) >> 4)); + UInt16 a = c4to5(SafeCast((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((pixel & 0xF000) >> 12)); + *dst++ = c4to8(SafeCast((pixel & 0x0F00) >> 8)); + *dst++ = c4to8(SafeCast((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((pixel & 0xF000) >> 12)); + *dst++ = c4to8(SafeCast((pixel & 0x0F00) >> 8)); + *dst++ = c4to8(SafeCast((pixel & 0x00F0) >> 4)); + *dst++ = c4to8(SafeCast((pixel & 0x000F) >> 0)); start += 2; } @@ -859,7 +860,7 @@ namespace Nz SwapBytes(&pixel, sizeof(UInt16)); #endif - *dst++ = static_cast((pixel & 0x1)*0xFF); + *dst++ = SafeCast((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((pixel & 0x003E) >> 1)); + *dst++ = c5to8(SafeCast((pixel & 0x07C0) >> 6)); + *dst++ = c5to8(SafeCast((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((pixel & 0x003E) >> 1)); + *dst++ = c5to8(SafeCast((pixel & 0x07C0) >> 6)); + *dst++ = c5to8(SafeCast((pixel & 0xF800) >> 11)); *dst++ = static_cast((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((pixel & 0xF800) >> 11)); + UInt8 g = c5to8(SafeCast((pixel & 0x07C0) >> 6)); + UInt8 b = c5to8(SafeCast((pixel & 0x003E) >> 1)); *dst++ = static_cast(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((pixel & 0xF800) >> 11)); + UInt8 g = c5to8(SafeCast((pixel & 0x07C0) >> 6)); + UInt8 b = c5to8(SafeCast((pixel & 0x003E) >> 1)); *dst++ = static_cast(r * 0.3f + g * 0.59f + b * 0.11f); *dst++ = static_cast((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((pixel & 0xF800) >> 11)); + *dst++ = c5to8(SafeCast((pixel & 0x07C0) >> 6)); + *dst++ = c5to8(SafeCast((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((pixel & 0xF800) >> 11)); + UInt8 g = c5to4(SafeCast((pixel & 0x07C0) >> 6)); + UInt8 b = c5to4(SafeCast((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((pixel & 0x1)*0xFF); + *dst++ = c5to8(SafeCast((pixel & 0xF800) >> 11)); + *dst++ = c5to8(SafeCast((pixel & 0x07C0) >> 6)); + *dst++ = c5to8(SafeCast((pixel & 0x003E) >> 1)); + *dst++ = SafeCast((pixel & 0x1) * 0xFF); start += 2; } diff --git a/src/Nazara/VulkanRenderer/VulkanTexture.cpp b/src/Nazara/VulkanRenderer/VulkanTexture.cpp index 89c698941..67e06efc9 100644 --- a/src/Nazara/VulkanRenderer/VulkanTexture.cpp +++ b/src/Nazara/VulkanRenderer/VulkanTexture.cpp @@ -313,7 +313,7 @@ namespace Nz 0, subresourceLayers, { // imageOffset - box.x, box.y, box.z + SafeCast(box.x), SafeCast(box.y), SafeCast(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);