suppress some warnings

This commit is contained in:
ohyzha
2025-03-05 13:34:48 +02:00
parent efcee95158
commit c5a0c52530
21 changed files with 34 additions and 36 deletions

View File

@@ -42,7 +42,7 @@ int main(int argc, char** argv)
if (shouldExit) return 0; if (shouldExit) return 0;
if (selectedExample >= examples.size()) if (static_cast<size_t>(selectedExample) >= examples.size())
{ {
throw std::runtime_error("Invalid menu selection!"); throw std::runtime_error("Invalid menu selection!");
} }

View File

@@ -39,7 +39,7 @@ namespace OpenVulkano
size_t m_size; // Size of the chunk size_t m_size; // Size of the chunk
size_t m_capacity; // Capacity of the chunk size_t m_capacity; // Capacity of the chunk
size_t m_nextIndex; // Next index to insert std::ptrdiff_t m_nextIndex; // Next index to insert
size_t m_gapCount; // Count of emptied gaps in the chunk size_t m_gapCount; // Count of emptied gaps in the chunk
bool* m_occupiedIndices; // filled gaps array bool* m_occupiedIndices; // filled gaps array
T m_data[0]; // data array T m_data[0]; // data array
@@ -178,11 +178,11 @@ namespace OpenVulkano
} }
} }
std::streamsize GetIteratorIndex() const { return m_chunk->GetRealIndex(m_index); } std::ptrdiff_t GetIteratorIndex() const { return m_chunk->GetRealIndex(m_index); }
private: private:
VectorChunk* m_chunk; VectorChunk* m_chunk;
std::streamsize m_index; std::ptrdiff_t m_index;
}; };
public: public:

View File

@@ -61,9 +61,8 @@ namespace OpenVulkano::Image
PfmImageHeader header = ParseHeader(stream); PfmImageHeader header = ParseHeader(stream);
size_t numChannels = header.isColor ? 3 : 1; size_t numChannels = header.isColor ? 3 : 1;
size_t dataSize = header.width * header.height * numChannels * sizeof(float);
Array<float> data(header.width * header.height * numChannels); Array<float> data(header.width * header.height * numChannels);
size_t rowSize = header.width * numChannels * sizeof(float); size_t rowSize = header.width * numChannels * sizeof(float);
for (int y = header.height - 1; y >= 0; --y) for (int y = header.height - 1; y >= 0; --y)
{ {

View File

@@ -27,7 +27,7 @@ namespace OpenVulkano
uint8_t* dest2 = dest + chromaChannelWidth * chromaChannelHeight; uint8_t* dest2 = dest + chromaChannelWidth * chromaChannelHeight;
for (uint32_t row = 0; row < chromaChannelHeight; row++) for (uint32_t row = 0; row < chromaChannelHeight; row++)
{ {
for (int col = 0; col < chromaChannelWidth; col++, dest++, dest2++, src += 2) for (uint32_t col = 0; col < chromaChannelWidth; col++, dest++, dest2++, src += 2)
{ {
*dest = src[0]; *dest = src[0];
*dest2 = src[1]; *dest2 = src[1];

View File

@@ -67,7 +67,7 @@ namespace OpenVulkano
public: public:
[[nodiscard]] bool GetButton(const InputKey::Keyboard::Key button) const [[nodiscard]] bool GetButton(const InputKey::Keyboard::Key button) const
{ {
return keyState[button] > 0; return keyState[button];
} }
[[nodiscard]] bool GetButtonUp(const InputKey::Keyboard::Key button) const [[nodiscard]] bool GetButtonUp(const InputKey::Keyboard::Key button) const

View File

@@ -51,7 +51,7 @@ namespace OpenVulkano::Math
template<typename T, typename = std::enable_if_t<std::is_integral_v<TYPE>>> template<typename T, typename = std::enable_if_t<std::is_integral_v<TYPE>>>
void Set(Vector4<T> vec4) void Set(Vector4<T> vec4)
{ {
vec4 &= VALUE_BITMASK; static_cast<void>(vec4 &= VALUE_BITMASK);
SetUnchecked(vec4); SetUnchecked(vec4);
} }
#pragma GCC diagnostic pop #pragma GCC diagnostic pop

View File

@@ -63,7 +63,7 @@ namespace
mesh.mTextureCoords[0] = new aiVector3D[geometry->vertexCount]; mesh.mTextureCoords[0] = new aiVector3D[geometry->vertexCount];
} }
for (int i = 0; i < geometry->vertexCount; ++i) for (uint32_t i = 0; i < geometry->vertexCount; ++i)
{ {
const OpenVulkano::Vertex& vertex = geometry->vertices[i]; const OpenVulkano::Vertex& vertex = geometry->vertices[i];
mesh.mVertices[i] = aiVector3D(vertex.position.x, vertex.position.y, vertex.position.z) * scaling; mesh.mVertices[i] = aiVector3D(vertex.position.x, vertex.position.y, vertex.position.z) * scaling;
@@ -78,7 +78,7 @@ namespace
mesh.mFaces = new aiFace[mesh.mNumFaces]; mesh.mFaces = new aiFace[mesh.mNumFaces];
indices = std::make_unique<unsigned int[]>(geometry->indexCount); indices = std::make_unique<unsigned int[]>(geometry->indexCount);
for (unsigned int i = 0; i < geometry->indexCount; ++i) for (uint32_t i = 0; i < geometry->indexCount; ++i)
{ {
indices[i] = geometry->GetIndex(i); indices[i] = geometry->GetIndex(i);
} }

View File

@@ -38,25 +38,25 @@ map_Kd texture.png
objContent.write("\n", 1); objContent.write("\n", 1);
} }
for (int i = 0; i < geometry->vertexCount; ++i) for (uint32_t i = 0; i < geometry->vertexCount; ++i)
{ {
const auto& v = geometry->vertices[i]; const auto& v = geometry->vertices[i];
const std::string content = fmt::format("v {} {} {}\n", v.position.x, v.position.y, v.position.z); const std::string content = fmt::format("v {} {} {}\n", v.position.x, v.position.y, v.position.z);
objContent.write(content.data(), content.size()); objContent.write(content.data(), content.size());
} }
for (int i = 0; i < geometry->vertexCount; ++i) for (uint32_t i = 0; i < geometry->vertexCount; ++i)
{ {
const auto& v = geometry->vertices[i]; const auto& v = geometry->vertices[i];
const std::string content = fmt::format("vn {} {} {}\n", v.normal.x, v.normal.y, v.normal.z); const std::string content = fmt::format("vn {} {} {}\n", v.normal.x, v.normal.y, v.normal.z);
objContent.write(content.data(), content.size()); objContent.write(content.data(), content.size());
} }
for (int i = 0; i < geometry->vertexCount; ++i) for (uint32_t i = 0; i < geometry->vertexCount; ++i)
{ {
const auto& v = geometry->vertices[i]; const auto& v = geometry->vertices[i];
const std::string content = fmt::format("vt {} {}\n", v.textureCoordinates.x, v.textureCoordinates.y); const std::string content = fmt::format("vt {} {}\n", v.textureCoordinates.x, v.textureCoordinates.y);
objContent.write(content.data(), content.size()); objContent.write(content.data(), content.size());
} }
for (int i = 0; i < geometry->indexCount; i += 3) for (uint32_t i = 0; i < geometry->indexCount; i += 3)
{ {
uint32_t i0 = geometry->GetIndex(i + 0) + 1; uint32_t i0 = geometry->GetIndex(i + 0) + 1;
uint32_t i1 = geometry->GetIndex(i + 1) + 1; uint32_t i1 = geometry->GetIndex(i + 1) + 1;

View File

@@ -89,7 +89,7 @@ namespace OpenVulkano::Scene
{ {
return; return;
} }
for (int i = 0; i < vertexCount; i++) for (uint32_t i = 0; i < vertexCount; i++)
{ {
aabb.Grow(vertices[i].position); aabb.Grow(vertices[i].position);
} }

View File

@@ -308,10 +308,10 @@ namespace OpenVulkano::Scene
return result; return result;
} }
Geometry GeometryFactory::MakeArchStrip(float radius, float width, float endRadius, int segments, const Math::Vector4f& color, float endVCoord, bool indexBuffer) Geometry GeometryFactory::MakeArchStrip(float radius, float width, float endRadius, uint32_t segments, const Math::Vector4f& color, float endVCoord, bool indexBuffer)
{ {
Geometry result; Geometry result;
segments = std::max(2, segments); segments = std::max(2u, segments);
result.Init(2 * segments, indexBuffer ? 6 * segments : 0); result.Init(2 * segments, indexBuffer ? 6 * segments : 0);
const float segmentAngle = endRadius / static_cast<float>(segments - 1); const float segmentAngle = endRadius / static_cast<float>(segments - 1);
width /= 2; width /= 2;

View File

@@ -20,6 +20,6 @@ namespace OpenVulkano::Scene
static Geometry MakeTriangle(const Math::Vector3f& p1, const Math::Vector3f& p2, const Math::Vector3f& p3, const Math::Vector4f& color = Math::Vector4f(1)); static Geometry MakeTriangle(const Math::Vector3f& p1, const Math::Vector3f& p2, const Math::Vector3f& p3, const Math::Vector4f& color = Math::Vector4f(1));
static Geometry MakeCylinder(float radius, float height, uint32_t segments, const Math::Vector4f& color = Math::Vector4f(1)); static Geometry MakeCylinder(float radius, float height, uint32_t segments, const Math::Vector4f& color = Math::Vector4f(1));
static Geometry MakePyramid(float baseLength = 1, float height = 1, const Math::Vector4f& color = Math::Vector4f(1)); static Geometry MakePyramid(float baseLength = 1, float height = 1, const Math::Vector4f& color = Math::Vector4f(1));
static Geometry MakeArchStrip(float radius = 1, float width = 0.2, float endRadius = std::numbers::pi, int segments = 16, const Math::Vector4f& color = Math::Vector4f(1), float endVCoord = 1, bool indexBuffer = true); static Geometry MakeArchStrip(float radius = 1, float width = 0.2, float endRadius = std::numbers::pi, uint32_t segments = 16, const Math::Vector4f& color = Math::Vector4f(1), float endVCoord = 1, bool indexBuffer = true);
}; };
} }

View File

@@ -65,7 +65,7 @@ namespace OpenVulkano::Scene
Shader* GetTextShader(const FontAtlasType type, const bool billboard) Shader* GetTextShader(const FontAtlasType type, const bool billboard)
{ {
return &TEXT_SHADERS[static_cast<int>(type) << 1 | billboard]; return &TEXT_SHADERS[(static_cast<int>(type) << 1) + billboard];
} }
} }

View File

@@ -52,7 +52,7 @@ namespace OpenVulkano::Scene
if (m_mesh->indexCount != 0) if (m_mesh->indexCount != 0)
{ {
assert(m_mesh->indexCount % 3 == 0 && "Topology is TRIANGLE_LIST but index count is not divisible by 3"); assert(m_mesh->indexCount % 3 == 0 && "Topology is TRIANGLE_LIST but index count is not divisible by 3");
for (int i = 0; i < m_mesh->indexCount; i += 3) for (uint32_t i = 0; i < m_mesh->indexCount; i += 3)
{ {
if (m_mesh->indexType == VertexIndexType::UINT16) if (m_mesh->indexType == VertexIndexType::UINT16)
{ {
@@ -79,7 +79,7 @@ namespace OpenVulkano::Scene
else else
{ {
assert(m_mesh->indexCount % 3 == 0 && "Topology is TRIANGLE_LIST but vertex count is not divisible by 3"); assert(m_mesh->indexCount % 3 == 0 && "Topology is TRIANGLE_LIST but vertex count is not divisible by 3");
for (int i = 0; i < m_mesh->vertexCount; i += 3) for (uint32_t i = 0; i < m_mesh->vertexCount; i += 3)
{ {
if (auto hit = ray.IntersectTriangle(m_mesh->vertices[i].position, if (auto hit = ray.IntersectTriangle(m_mesh->vertices[i].position,
m_mesh->vertices[i + 1].position, m_mesh->vertices[i + 1].position,

View File

@@ -148,7 +148,7 @@ namespace OpenVulkano::Scene
{ {
char* baseAddress = static_cast<char*>(m_atlasData->GetTexture()->textureBuffer) char* baseAddress = static_cast<char*>(m_atlasData->GetTexture()->textureBuffer)
+ glyph.firstGlyphByteInAtlas; + glyph.firstGlyphByteInAtlas;
for (int row = 0; row < slot->bitmap.rows; row++) for (unsigned int row = 0; row < slot->bitmap.rows; row++)
{ {
std::memcpy(baseAddress - row * m_atlasData->GetTexture()->resolution.x, std::memcpy(baseAddress - row * m_atlasData->GetTexture()->resolution.x,
&slot->bitmap.buffer[row * slot->bitmap.pitch], slot->bitmap.width); &slot->bitmap.buffer[row * slot->bitmap.pitch], slot->bitmap.width);
@@ -181,9 +181,9 @@ namespace OpenVulkano::Scene
{ {
// RGB RGB RGB // RGB RGB RGB
assert(bitmap.width % 3 == 0); assert(bitmap.width % 3 == 0);
for (int row = 0; row < bitmap.rows; row++) for (unsigned int row = 0; row < bitmap.rows; row++)
{ {
for (int col = 0, atlasPos = 0; col < bitmap.width; col += 3, atlasPos += 4) for (unsigned int col = 0, atlasPos = 0; col < bitmap.width; col += 3, atlasPos += 4)
{ {
const size_t bitmapPos = row * bitmap.pitch + col; const size_t bitmapPos = row * bitmap.pitch + col;
const size_t texturePos = (glyph.firstGlyphByteInAtlas - row * tex->resolution.x * m_channelsCount) + atlasPos; const size_t texturePos = (glyph.firstGlyphByteInAtlas - row * tex->resolution.x * m_channelsCount) + atlasPos;
@@ -200,9 +200,9 @@ namespace OpenVulkano::Scene
// GGG // GGG
// BBB // BBB
assert(bitmap.rows % 3 == 0); assert(bitmap.rows % 3 == 0);
for (int row = 0; row < bitmap.rows; row += 3) for (unsigned int row = 0; row < bitmap.rows; row += 3)
{ {
for (int col = 0; col < bitmap.width; col++) for (unsigned int col = 0; col < bitmap.width; col++)
{ {
const size_t bitmapPos = col + (bitmap.pitch * row); const size_t bitmapPos = col + (bitmap.pitch * row);
const size_t texturePos = (glyph.firstGlyphByteInAtlas + col * m_channelsCount) const size_t texturePos = (glyph.firstGlyphByteInAtlas + col * m_channelsCount)

View File

@@ -124,7 +124,7 @@ namespace OpenVulkano::Scene
// store RGB as RGBA // store RGB as RGBA
const msdfgen::BitmapConstRef<msdfgen::byte, 3> storage = generator.atlasStorage(); const msdfgen::BitmapConstRef<msdfgen::byte, 3> storage = generator.atlasStorage();
msdfgen::byte* data = static_cast<msdfgen::byte*>(m_atlasData->GetTexture()->textureBuffer); msdfgen::byte* data = static_cast<msdfgen::byte*>(m_atlasData->GetTexture()->textureBuffer);
for (size_t srcPos = 0, dstPos = 0; srcPos < width * height * 3; srcPos += 3, dstPos += 4) for (size_t srcPos = 0, dstPos = 0; srcPos < static_cast<size_t>(width * height * 3); srcPos += 3, dstPos += 4)
{ {
data[dstPos] = storage.pixels[srcPos]; data[dstPos] = storage.pixels[srcPos];
data[dstPos + 1] = storage.pixels[srcPos + 1]; data[dstPos + 1] = storage.pixels[srcPos + 1];

View File

@@ -35,7 +35,7 @@ namespace OpenVulkano::Scene::UI
m_frames.m_values.push_back(newFrameTime); m_frames.m_values.push_back(newFrameTime);
while(m_frames.m_values.size() > m_windowSize) while(static_cast<int>(m_frames.m_values.size()) > m_windowSize)
{ {
float poppedFrameTime = m_frames.m_values.front(); float poppedFrameTime = m_frames.m_values.front();
m_frames.m_values.pop_front(); m_frames.m_values.pop_front();
@@ -51,7 +51,7 @@ namespace OpenVulkano::Scene::UI
} }
m_ramUsed.m_values.push_back(static_cast<float>(SystemInfo::GetAppRamUsed())); m_ramUsed.m_values.push_back(static_cast<float>(SystemInfo::GetAppRamUsed()));
while(m_ramUsed.m_values.size() > m_windowSize) while(static_cast<int>(m_ramUsed.m_values.size()) > m_windowSize)
m_ramUsed.m_values.pop_front(); m_ramUsed.m_values.pop_front();
m_ramUsed.m_maxValue = SystemInfo::GetAppRamMax(); m_ramUsed.m_maxValue = SystemInfo::GetAppRamMax();

View File

@@ -23,7 +23,7 @@ namespace OpenVulkano::Vulkan
void AddQueueFamily(const uint32_t queueFamilyIndex, const std::vector<float>& priorities) void AddQueueFamily(const uint32_t queueFamilyIndex, const std::vector<float>& priorities)
{ {
prioritiesVector.push_back(priorities); prioritiesVector.push_back(priorities);
createInfos.emplace_back(vk::DeviceQueueCreateFlags(), queueFamilyIndex, priorities.size(), prioritiesVector[prioritiesVector.size()-1].data()); createInfos.emplace_back(vk::DeviceQueueCreateFlags(), queueFamilyIndex, static_cast<uint32_t>(priorities.size()), prioritiesVector[prioritiesVector.size()-1].data());
} }
void AddQueueFamily(uint32_t queueFamilyIndex, uint32_t count = 1) void AddQueueFamily(uint32_t queueFamilyIndex, uint32_t count = 1)

View File

@@ -67,7 +67,7 @@ namespace OpenVulkano::Vulkan
std::vector<vk::SubpassDescription> subPasses; std::vector<vk::SubpassDescription> subPasses;
subPasses.emplace_back(vk::SubpassDescriptionFlags(), vk::PipelineBindPoint::eGraphics, 0, nullptr, subPasses.emplace_back(vk::SubpassDescriptionFlags(), vk::PipelineBindPoint::eGraphics, 0, nullptr,
colorAttachmentReferences.size(), colorAttachmentReferences.data(), nullptr, depthReference, 0, nullptr); static_cast<uint32_t>(colorAttachmentReferences.size()), colorAttachmentReferences.data(), nullptr, depthReference, 0, nullptr);
std::vector<vk::SubpassDependency> subPassDependencies; std::vector<vk::SubpassDependency> subPassDependencies;
subPassDependencies.emplace_back(0, VK_SUBPASS_EXTERNAL, vk::PipelineStageFlagBits::eColorAttachmentOutput, subPassDependencies.emplace_back(0, VK_SUBPASS_EXTERNAL, vk::PipelineStageFlagBits::eColorAttachmentOutput,
vk::PipelineStageFlagBits::eBottomOfPipe, vk::AccessFlagBits::eColorAttachmentRead | vk::AccessFlagBits::eColorAttachmentWrite, vk::PipelineStageFlagBits::eBottomOfPipe, vk::AccessFlagBits::eColorAttachmentRead | vk::AccessFlagBits::eColorAttachmentWrite,

View File

@@ -34,7 +34,7 @@ namespace OpenVulkano::Vulkan
throw std::runtime_error("The provided window is not compatible with Vulkan."); throw std::runtime_error("The provided window is not compatible with Vulkan.");
} }
context.Init(graphicsAppManager, vulkanWindow); context.Init(graphicsAppManager, vulkanWindow);
for (int i = 0; i < context.swapChain.GetImageCount(); i++) for (uint32_t i = 0; i < context.swapChain.GetImageCount(); i++)
{ {
waitSemaphores.emplace_back(); waitSemaphores.emplace_back();
vk::Semaphore sema = context.device->device.createSemaphore({}); vk::Semaphore sema = context.device->device.createSemaphore({});

View File

@@ -245,7 +245,7 @@ TEST_CASE("Iterator constructor", "[Array]")
char data[] = "Hello world"; char data[] = "Hello world";
Array<char> arr(data, data + sizeof(data)); Array<char> arr(data, data + sizeof(data));
REQUIRE(arr.Data() != data); REQUIRE(arr.Data() != data);
for (int i = 0; i < sizeof(data); i++) for (size_t i = 0; i < sizeof(data); i++)
{ {
REQUIRE(data[i] == arr[i]); REQUIRE(data[i] == arr[i]);
} }
@@ -254,7 +254,7 @@ TEST_CASE("Iterator constructor", "[Array]")
{ {
Array<int> arr = { 1, 2, 3, 4, 5 }; Array<int> arr = { 1, 2, 3, 4, 5 };
Array<double> arr2(arr.begin(), arr.end()); Array<double> arr2(arr.begin(), arr.end());
for (int i = 0; i < arr.Size(); i++) for (size_t i = 0; i < arr.Size(); i++)
{ {
REQUIRE(arr[i] == arr2[i]); REQUIRE(arr[i] == arr2[i]);
} }

View File

@@ -42,7 +42,6 @@ TEST_CASE("RaySphereIntersection")
// this returns just closest point // this returns just closest point
if (auto opt = ray.IntersectSphere(Vector3f(0), 1)) if (auto opt = ray.IntersectSphere(Vector3f(0), 1))
{ {
opt->GetDistance();
REQUIRE(opt.value() == h1); REQUIRE(opt.value() == h1);
} }
} }