Skip to content

Commit

Permalink
Cleaned up some warnings on linux/clang (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
nadult authored Oct 18, 2024
1 parent 859dc8c commit 22acd02
Show file tree
Hide file tree
Showing 21 changed files with 58 additions and 22 deletions.
7 changes: 6 additions & 1 deletion src/gfx/shader_reflection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@

#include "../extern/spirv-reflect/spirv_reflect.h"

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-field-initializers"

extern "C" {
#include "../extern/spirv-reflect/spirv_reflect.c"
}

#pragma clang diagnostic pop

#include "fwk/gfx/shader_reflection.h"

#include "fwk/enum_map.h"
Expand Down Expand Up @@ -40,4 +45,4 @@ void ShaderReflectionModule::free() {
m_module.reset();
}
}
}
}
2 changes: 2 additions & 0 deletions src/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include "../extern/imgui/backends/imgui_impl_vulkan.cpp"

#pragma clang diagnostic ignored "-Wmissing-field-initializers"

namespace fwk {

Gui *Gui::s_instance = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/perf/thread_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static unsigned long long getClock() {
}

void ThreadContext::resolveGpuScopes(i64 frame_id, CSpan<Pair<uint, u64>> sample_gpu_times) {
vector<Pair<int, u64>> sample_stack;
vector<Pair<uint, u64>> sample_stack;

Span<PSample> samples;
for(auto &frame : m_frames)
Expand Down
2 changes: 1 addition & 1 deletion src/tests/vector_perf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ FWK_NO_INLINE int testSparseVector() {

int val = 0;
int num_values = 0, num_iters = 0;
double val_time, total_time;
double val_time [[maybe_unused]], total_time;
{
auto time = getTime();
for(int n = 0; n < 1000; n++) {
Expand Down
4 changes: 2 additions & 2 deletions src/tests/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ bool mainLoop(VulkanWindow &window, void *ctx_) {
auto &cmds = ctx.device->cmdQueue();
if(auto uints = cmds.retrieve<u32>(*ctx.download_id)) {
uint count = uints[0];
bool is_valid = count == uints.size() - 1 && allOf(subSpan(uints, 2), uints[1]);
bool is_valid = count == uint(uints.size() - 1) && allOf(subSpan(uints, 2), uints[1]);
last_message = format("Compute result: %%\n", uints[1], is_valid ? "" : " (invalid)");
if(!is_valid)
num_invalid++;
Expand Down Expand Up @@ -285,4 +285,4 @@ int main(int argc, char **argv) {
return 1;
}
return *result;
}
}
4 changes: 2 additions & 2 deletions src/tools/model_viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ Ex<> exMain(int argc, char **argv) {
auto window_flags = VWindowFlag::resizable | VWindowFlag::centered | VWindowFlag::allow_hidpi |
VWindowFlag::sleep_when_minimized;
VSwapChainSetup swap_chain_setup;
swap_chain_setup.preferred_formats = {{VK_FORMAT_B8G8R8A8_UNORM}};
swap_chain_setup.preferred_formats = {VK_FORMAT_B8G8R8A8_UNORM};
swap_chain_setup.preferred_present_mode = VPresentMode::immediate;
swap_chain_setup.usage =
VImageUsage::color_att | VImageUsage::storage | VImageUsage::transfer_dst;
Expand Down Expand Up @@ -529,4 +529,4 @@ int main(int argc, char **argv) {
return 1;
}
return 0;
}
}
4 changes: 3 additions & 1 deletion src/vulkan/vulkan_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "fwk/vulkan/vulkan_internal.h"
#include "fwk/vulkan/vulkan_memory_manager.h"

#pragma clang diagnostic ignored "-Wmissing-field-initializers"

namespace fwk {

VulkanBuffer::VulkanBuffer(VkBuffer handle, VObjectId id, VMemoryBlock memory_block,
Expand Down Expand Up @@ -53,4 +55,4 @@ Ex<PVBuffer> VulkanBuffer::createAndUpload(VulkanDevice &device, CSpan<char> dat
EXPECT(device.cmdQueue().upload(out, data));
return out;
}
}
}
8 changes: 5 additions & 3 deletions src/vulkan/vulkan_command_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "fwk/vulkan/vulkan_memory_manager.h"
#include "fwk/vulkan/vulkan_pipeline.h"

#pragma clang diagnostic ignored "-Wmissing-field-initializers"

// TODO: add function for clearing labeled downloads

namespace fwk {
Expand Down Expand Up @@ -169,7 +171,7 @@ CSpan<u64> VulkanCommandQueue::getQueryResults(u64 frame_index) const {
frame_indices[m_swap_index] -= num_swap_frames;

for(int i : intRange(num_swap_frames))
if(frame_index == frame_indices[i]) {
if(i64(frame_index) == frame_indices[i]) {
uint idx = (i + m_swap_index) % num_swap_frames;
return m_frames[idx].query_results;
}
Expand Down Expand Up @@ -444,7 +446,7 @@ uint VulkanCommandQueue::timestampQuery() {
PASSERT(m_status == Status::frame_running);
auto &frame = m_frames[m_swap_index];
uint index = frame.query_count++;
uint pool_id = index >> query_pool_shift;
int pool_id = int(index >> query_pool_shift);
if(pool_id >= frame.query_pools.size()) {
VkQueryPoolCreateInfo ci{VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO};
ci.queryCount = query_pool_size;
Expand Down Expand Up @@ -472,7 +474,7 @@ void VulkanCommandQueue::perfTimestampQuery(uint sample_id) {
Ex<VBufferSpan<char>> VulkanCommandQueue::upload(VBufferSpan<char> dst, CSpan<char> src) {
if(src.empty())
return dst;
DASSERT_LE(src.size(), dst.size());
DASSERT_LE(u32(src.size()), dst.size());

auto &mem_mgr = m_device.memory();
auto mem_block = dst.buffer()->memoryBlock();
Expand Down
4 changes: 3 additions & 1 deletion src/vulkan/vulkan_descriptor_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
// ShaderControl ? Board ? Input / InputLayout ?
// ShaderInput, ShaderInputLayout ?

#pragma clang diagnostic ignored "-Wmissing-field-initializers"

namespace fwk {

VulkanDescriptorManager::VulkanDescriptorManager(VkDevice device) : m_device_handle(device) {
Expand Down Expand Up @@ -160,4 +162,4 @@ void VulkanDescriptorManager::allocSets(VkDescriptorPool pool, VkDescriptorSetLa
FWK_VK_CALL(vkAllocateDescriptorSets, m_device_handle, &ai, &out[i]);
}
}
}
}
2 changes: 2 additions & 0 deletions src/vulkan/vulkan_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#include "fwk/vulkan/vulkan_swap_chain.h"
#include "fwk/vulkan/vulkan_window.h"

#pragma clang diagnostic ignored "-Wmissing-field-initializers"

// TODO: add option to hook an error handler which in case of (for example) out of memory error
// it can try to reclaim some memory by clearing the caches
// TODO: more concise form of descriptor declarations
Expand Down
4 changes: 3 additions & 1 deletion src/vulkan/vulkan_framebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "fwk/vulkan/vulkan_image.h"
#include "fwk/vulkan/vulkan_internal.h"

#pragma clang diagnostic ignored "-Wmissing-field-initializers"

namespace fwk {

VulkanFramebuffer::VulkanFramebuffer(VkFramebuffer handle, VObjectId id)
Expand Down Expand Up @@ -52,4 +54,4 @@ u32 VulkanFramebuffer::hashConfig(CSpan<PVImageView> colors, PVImageView depth)
out = combineHash(fwk::hash(u64(depth.get())), out);
return out;
}
}
}
4 changes: 3 additions & 1 deletion src/vulkan/vulkan_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "fwk/vulkan/vulkan_internal.h"
#include "fwk/vulkan/vulkan_memory_manager.h"

#pragma clang diagnostic ignored "-Wmissing-field-initializers"

namespace fwk {

VImageDimensions::VImageDimensions(int3 size, uint num_mip_levels, uint num_samples)
Expand Down Expand Up @@ -229,4 +231,4 @@ PVImageView VulkanImageView::create(VDeviceRef device, PVImage image) {
return out;
}

}
}
2 changes: 2 additions & 0 deletions src/vulkan/vulkan_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include "fwk/vulkan/vulkan_internal.h"
#include "fwk/vulkan/vulkan_storage.h"

#pragma clang diagnostic ignored "-Wmissing-field-initializers"

namespace fwk {

vector<VQueueFamilyId> VulkanPhysicalDeviceInfo::findQueues(VQueueCaps caps) const {
Expand Down
4 changes: 3 additions & 1 deletion src/vulkan/vulkan_internal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#include "fwk/vulkan/vulkan_internal.h"

#pragma clang diagnostic ignored "-Wmissing-field-initializers"

namespace fwk {

// -------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -150,4 +152,4 @@ void fatalVkError(const char *file, int line, VkResult result, const char *funct
auto message = makeVkMessage(function_name, result);
fwk::fatalError(file, line, "%s", message.c_str());
}
}
}
6 changes: 4 additions & 2 deletions src/vulkan/vulkan_memory_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#include "fwk/vulkan/vulkan_instance.h"
#include "fwk/vulkan/vulkan_internal.h"

#pragma clang diagnostic ignored "-Wmissing-field-initializers"

namespace fwk {

static Ex<VkDeviceMemory> allocDeviceMemory(VkDevice device_handle, u32 size, uint type_index,
Expand Down Expand Up @@ -323,7 +325,7 @@ u64 VulkanMemoryManager::slabAlloc(u64 size, uint zone_index, void *domain_ptr)
allocDeviceMemory(domain.device_handle, size, domain.type_index, domain.device_address);
if(!result)
return 0;
DASSERT(zone_index == domain.slab_memory.size());
DASSERT(zone_index == uint(domain.slab_memory.size()));
domain.slab_memory.emplace_back(*result, nullptr, u32(size));

return size;
Expand Down Expand Up @@ -382,4 +384,4 @@ void VulkanMemoryManager::validate() const {
domain.slab_alloc->verifySlabs().check();
}
}
}
}
4 changes: 3 additions & 1 deletion src/vulkan/vulkan_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "fwk/vulkan/vulkan_ray_tracing.h"
#include "fwk/vulkan/vulkan_shader.h"

#pragma clang diagnostic ignored "-Wmissing-field-initializers"

namespace fwk {

vector<VDescriptorBindingInfo> VDescriptorBindingInfo::merge(CSpan<VDescriptorBindingInfo> lhs,
Expand Down Expand Up @@ -551,4 +553,4 @@ Ex<PVPipeline> VulkanPipeline::create(VDeviceRef device, const VComputePipelineS
out->m_bind_point = VBindPoint::compute;
return out;
}
}
}
4 changes: 3 additions & 1 deletion src/vulkan/vulkan_ray_tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "fwk/vulkan/vulkan_internal.h"
#include "fwk/vulkan/vulkan_memory_manager.h"

#pragma clang diagnostic ignored "-Wmissing-field-initializers"

namespace fwk {

VulkanAccelStruct::VulkanAccelStruct(VkAccelerationStructureKHR handle, VObjectId id,
Expand Down Expand Up @@ -192,4 +194,4 @@ VkDeviceAddress VulkanAccelStruct::deviceAddress() const {
address_info.accelerationStructure = handle();
return vkGetAccelerationStructureDeviceAddressKHR(deviceHandle(), &address_info);
}
}
}
4 changes: 3 additions & 1 deletion src/vulkan/vulkan_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "fwk/vulkan/vulkan_internal.h"
#include "fwk/vulkan/vulkan_pipeline.h"

#pragma clang diagnostic ignored "-Wmissing-field-initializers"

namespace fwk {

Ex<vector<VDescriptorBindingInfo>> getBindings(CSpan<char> bytecode, VShaderStage &out_stage) {
Expand Down Expand Up @@ -110,4 +112,4 @@ Ex<vector<PVShaderModule>> VulkanShaderModule::compile(ShaderCompiler &compiler,

return out;
}
}
}
6 changes: 4 additions & 2 deletions src/vulkan/vulkan_swap_chain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include "fwk/vulkan/vulkan_internal.h"
#include "fwk/vulkan/vulkan_window.h"

#pragma clang diagnostic ignored "-Wmissing-field-initializers"

namespace fwk {

VulkanSwapChain::VulkanSwapChain(VkSwapchainKHR handle, VObjectId id, VWindowRef window,
Expand Down Expand Up @@ -180,7 +182,7 @@ Ex<VkSemaphore> VulkanSwapChain::acquireImage() {

m_status = Status::image_acquired;
m_semaphore_index++;
if(m_semaphore_index >= m_semaphores.size())
if(m_semaphore_index >= uint(m_semaphores.size()))
m_semaphore_index = 0;
return semaphore;
}
Expand Down Expand Up @@ -209,4 +211,4 @@ Ex<bool> VulkanSwapChain::presentImage(VkSemaphore wait_sem) {
m_status = Status::ready;
return true;
}
}
}
2 changes: 2 additions & 0 deletions src/vulkan/vulkan_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <atomic>
#include <memory.h>

#pragma clang diagnostic ignored "-Wmissing-field-initializers"

namespace fwk {

static std::atomic<unsigned> sdl_init_counter;
Expand Down
1 change: 1 addition & 0 deletions todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ CAŁY CZAS TO ROBISZ :(


Problemy:
- Why VBufferSpan has sizes as u32? Is this a mistake or by design?
- natstepfilter
- remove min_size from Span<>
- disable/remove backtraces?
Expand Down

0 comments on commit 22acd02

Please sign in to comment.