From 6bf8dde5f480c1e9cfe6f86dbfc216d53fe4526b Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Sat, 30 Nov 2024 15:08:30 -0800 Subject: [PATCH] Fix MSVC build errors/warnings --- src/niagara.cpp | 8 ++++---- src/scene.cpp | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/niagara.cpp b/src/niagara.cpp index 9ad7f68..e8c67ea 100644 --- a/src/niagara.cpp +++ b/src/niagara.cpp @@ -251,7 +251,7 @@ void buildBLAS(VkDevice device, const std::vector& meshes, const Buffer& v } assert(i > start); // guaranteed as scratchBuffer.size >= maxScratchSize - vkCmdBuildAccelerationStructuresKHR(commandBuffer, i - start, &buildInfos[start], &buildRangePtrs[start]); + vkCmdBuildAccelerationStructuresKHR(commandBuffer, uint32_t(i - start), &buildInfos[start], &buildRangePtrs[start]); start = i; pipelineBarrier(commandBuffer, 0, 1, &scratchBarrier, 0, nullptr); @@ -568,7 +568,7 @@ int main(int argc, const char** argv) VkSampler depthSampler = createSampler(device, VK_FILTER_LINEAR, VK_SAMPLER_MIPMAP_MODE_NEAREST, VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE, VK_SAMPLER_REDUCTION_MODE_MIN); assert(depthSampler); - const size_t gbufferCount = 2; + static const size_t gbufferCount = 2; const VkFormat gbufferFormats[gbufferCount] = { VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_A2B10G10R10_UNORM_PACK32, @@ -762,7 +762,7 @@ int main(int argc, const char** argv) printf("Loaded %d textures in %.2f sec\n", int(images.size()), glfwGetTime() - imageTimer); - uint32_t descriptorCount = texturePaths.size() + 1; + uint32_t descriptorCount = uint32_t(texturePaths.size() + 1); std::pair textureSet = createDescriptorArray(device, textureSetLayout, descriptorCount); for (size_t i = 0; i < texturePaths.size(); ++i) @@ -774,7 +774,7 @@ int main(int argc, const char** argv) VkWriteDescriptorSet write = { VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET }; write.dstSet = textureSet.second; write.dstBinding = 0; - write.dstArrayElement = i + 1; + write.dstArrayElement = uint32_t(i + 1); write.descriptorCount = 1; write.descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; write.pImageInfo = &imageInfo; diff --git a/src/scene.cpp b/src/scene.cpp index 7b3a2ae..6163f91 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -419,21 +419,21 @@ bool loadScene(Geometry& geometry, std::vector& draws, std::vectorpbr_metallic_roughness.base_color_texture.texture - ? 1 + cgltf_texture_index(data, material->pbr_metallic_roughness.base_color_texture.texture) + ? 1 + int(cgltf_texture_index(data, material->pbr_metallic_roughness.base_color_texture.texture)) : material && material->pbr_specular_glossiness.diffuse_texture.texture - ? 1 + cgltf_texture_index(data, material->pbr_specular_glossiness.diffuse_texture.texture) + ? 1 + int(cgltf_texture_index(data, material->pbr_specular_glossiness.diffuse_texture.texture)) : 0; draw.normalTexture = material && material->normal_texture.texture - ? 1 + cgltf_texture_index(data, material->normal_texture.texture) + ? 1 + int(cgltf_texture_index(data, material->normal_texture.texture)) : 0; draw.specularTexture = material && material->pbr_specular_glossiness.specular_glossiness_texture.texture - ? 1 + cgltf_texture_index(data, material->pbr_specular_glossiness.specular_glossiness_texture.texture) + ? 1 + int(cgltf_texture_index(data, material->pbr_specular_glossiness.specular_glossiness_texture.texture)) : 0; draw.emissiveTexture = material && material->emissive_texture.texture - ? 1 + cgltf_texture_index(data, material->emissive_texture.texture) + ? 1 + int(cgltf_texture_index(data, material->emissive_texture.texture)) : 0; if (material && material->alpha_mode != cgltf_alpha_mode_opaque)