Fixes some clang-tidy warnings, remove fpermissive
This commit is contained in:
parent
f213d3d548
commit
b61eb98648
5 changed files with 55 additions and 46 deletions
|
@ -1,11 +1,6 @@
|
|||
macro(set_engine_properties target)
|
||||
target_compile_features(${target} PUBLIC cxx_std_17)
|
||||
set_target_properties(${target} PROPERTIES CXX_EXTENSIONS OFF)
|
||||
|
||||
if(ENABLE_MACOS OR ENABLE_LINUX)
|
||||
target_compile_options(${target} PUBLIC
|
||||
-fpermissive) # ew but required for now TODO: remove and test!
|
||||
endif()
|
||||
|
||||
if(ENABLE_MACOS)
|
||||
target_compile_definitions(${target} PUBLIC PLATFORM_MACOS)
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace ImGui {
|
|||
ImGui::ProgressBar(progress_saturated, ImVec2(0.0f, 0.0f), buf);
|
||||
|
||||
ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
|
||||
ImGui::Text(label);
|
||||
ImGui::Text("%s", label);
|
||||
}
|
||||
|
||||
inline bool DragQuat(const char* label, Quaternion* quat) {
|
||||
|
|
|
@ -94,6 +94,8 @@ void engine::quit() {
|
|||
bool engine::is_quitting() const {
|
||||
if(!windows.empty())
|
||||
return windows[0]->quit_requested;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void engine::prepare_quit() {
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
struct NativeSurface {
|
||||
int identifier = -1;
|
||||
|
||||
void* windowNativeHandle;
|
||||
uint32_t surfaceWidth = -1, surfaceHeight = -1;
|
||||
|
||||
std::vector<VkSemaphore> imageAvailableSemaphores;
|
||||
|
@ -36,28 +35,28 @@ class GFXVulkanPipeline;
|
|||
|
||||
class GFXVulkan : public GFX {
|
||||
public:
|
||||
bool is_supported() { return true; }
|
||||
bool is_supported() override { return true; }
|
||||
ShaderLanguage accepted_shader_language() override { return ShaderLanguage::SPIRV; }
|
||||
GFXContext required_context() { return GFXContext::Vulkan; }
|
||||
GFXContext required_context() override { return GFXContext::Vulkan; }
|
||||
const char* get_name() override;
|
||||
|
||||
bool supports_feature(const GFXFeature feature) override;
|
||||
bool supports_feature(GFXFeature feature) override;
|
||||
|
||||
bool initialize(const GFXCreateInfo& info) override;
|
||||
|
||||
void initialize_view(void* native_handle, const int identifier, const uint32_t width, const uint32_t height) override;
|
||||
void recreate_view(const int identifier, const uint32_t width, const uint32_t height) override;
|
||||
void initialize_view(void* native_handle, int identifier, uint32_t width, uint32_t height) override;
|
||||
void recreate_view(int identifier, uint32_t width, uint32_t height) override;
|
||||
|
||||
// buffer operations
|
||||
GFXBuffer* create_buffer(void* data, const GFXSize size, const bool dynamic_data, const GFXBufferUsage usage) override;
|
||||
void copy_buffer(GFXBuffer* buffer, void* data, const GFXSize offset, const GFXSize size) override;
|
||||
GFXBuffer* create_buffer(void* data, GFXSize size, bool dynamic_data, GFXBufferUsage usage) override;
|
||||
void copy_buffer(GFXBuffer* buffer, void* data, GFXSize offset, GFXSize size) override;
|
||||
|
||||
void* get_buffer_contents(GFXBuffer* buffer) override;
|
||||
void release_buffer_contents(GFXBuffer* buffer, void* handle) override;
|
||||
|
||||
// texture operations
|
||||
GFXTexture* create_texture(const GFXTextureCreateInfo& info) override;
|
||||
void copy_texture(GFXTexture* texture, void* data, const GFXSize size) override;
|
||||
void copy_texture(GFXTexture* texture, void* data, GFXSize size) override;
|
||||
void copy_texture(GFXTexture* from, GFXTexture* to) override;
|
||||
void copy_texture(GFXTexture* from, GFXBuffer* to) override;
|
||||
|
||||
|
@ -75,11 +74,11 @@ public:
|
|||
GFXPipeline* create_compute_pipeline(const GFXComputePipelineCreateInfo& info) override;
|
||||
|
||||
// misc operations
|
||||
GFXSize get_alignment(const GFXSize size) override;
|
||||
GFXSize get_alignment(GFXSize size) override;
|
||||
|
||||
GFXCommandBuffer* acquire_command_buffer(bool for_presentation_use = false) override;
|
||||
GFXCommandBuffer* acquire_command_buffer(bool for_presentation_use) override;
|
||||
|
||||
void submit(GFXCommandBuffer* command_buffer, const int identifier) override;
|
||||
void submit(GFXCommandBuffer* command_buffer, int identifier) override;
|
||||
|
||||
private:
|
||||
void createInstance(std::vector<const char*> layers, std::vector<const char*> extensions);
|
||||
|
@ -104,7 +103,7 @@ private:
|
|||
VkImageLayout newLayout,
|
||||
VkPipelineStageFlags src_stage_mask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
|
||||
VkPipelineStageFlags dst_stage_mask = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT);
|
||||
VkShaderModule createShaderModule(const uint32_t* code, const int length);
|
||||
VkShaderModule createShaderModule(const uint32_t* code, int length);
|
||||
VkCommandBuffer beginSingleTimeCommands();
|
||||
void endSingleTimeCommands(VkCommandBuffer commandBuffer);
|
||||
|
||||
|
|
|
@ -76,6 +76,8 @@ VkFormat toVkFormat(GFXVertexFormat format) {
|
|||
|
||||
VkBlendFactor toVkFactor(GFXBlendFactor factor) {
|
||||
switch (factor) {
|
||||
case GFXBlendFactor::Zero:
|
||||
return VK_BLEND_FACTOR_ZERO;
|
||||
case GFXBlendFactor::One:
|
||||
return VK_BLEND_FACTOR_ONE;
|
||||
case GFXBlendFactor::OneMinusSrcAlpha:
|
||||
|
@ -84,6 +86,12 @@ VkBlendFactor toVkFactor(GFXBlendFactor factor) {
|
|||
return VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR;
|
||||
case GFXBlendFactor::SrcAlpha:
|
||||
return VK_BLEND_FACTOR_SRC_ALPHA;
|
||||
case GFXBlendFactor::DstAlpha:
|
||||
return VK_BLEND_FACTOR_DST_ALPHA;
|
||||
case GFXBlendFactor::SrcColor:
|
||||
return VK_BLEND_FACTOR_SRC_COLOR;
|
||||
case GFXBlendFactor::DstColor:
|
||||
return VK_BLEND_FACTOR_DST_COLOR;
|
||||
}
|
||||
|
||||
return VK_BLEND_FACTOR_ONE;
|
||||
|
@ -223,11 +231,10 @@ bool GFXVulkan::initialize(const GFXCreateInfo& info) {
|
|||
void GFXVulkan::initialize_view(void* native_handle, const int identifier, const uint32_t width, const uint32_t height) {
|
||||
vkDeviceWaitIdle(device);
|
||||
|
||||
NativeSurface* surface = new NativeSurface();
|
||||
auto surface = new NativeSurface();
|
||||
surface->identifier = identifier;
|
||||
surface->surfaceWidth = width;
|
||||
surface->surfaceHeight = height;
|
||||
surface->windowNativeHandle = native_handle;
|
||||
|
||||
createSwapchain(surface);
|
||||
createSyncPrimitives(surface);
|
||||
|
@ -253,7 +260,7 @@ void GFXVulkan::recreate_view(const int identifier, const uint32_t width, const
|
|||
}
|
||||
|
||||
GFXBuffer* GFXVulkan::create_buffer(void *data, const GFXSize size, const bool dynamic_data, const GFXBufferUsage usage) {
|
||||
GFXVulkanBuffer* buffer = new GFXVulkanBuffer();
|
||||
auto buffer = new GFXVulkanBuffer();
|
||||
|
||||
vkDeviceWaitIdle(device);
|
||||
|
||||
|
@ -301,7 +308,7 @@ GFXBuffer* GFXVulkan::create_buffer(void *data, const GFXSize size, const bool d
|
|||
}
|
||||
|
||||
void GFXVulkan::copy_buffer(GFXBuffer* buffer, void* data, GFXSize offset, GFXSize size) {
|
||||
GFXVulkanBuffer* vulkanBuffer = (GFXVulkanBuffer*)buffer;
|
||||
auto vulkanBuffer = (GFXVulkanBuffer*)buffer;
|
||||
|
||||
void* mapped_data = nullptr;
|
||||
vkMapMemory(device, vulkanBuffer->memory, offset, vulkanBuffer->size - offset, 0, &mapped_data);
|
||||
|
@ -321,7 +328,7 @@ void GFXVulkan::copy_buffer(GFXBuffer* buffer, void* data, GFXSize offset, GFXSi
|
|||
}
|
||||
|
||||
void* GFXVulkan::get_buffer_contents(GFXBuffer* buffer) {
|
||||
GFXVulkanBuffer* vulkanBuffer = (GFXVulkanBuffer*)buffer;
|
||||
auto vulkanBuffer = (GFXVulkanBuffer*)buffer;
|
||||
|
||||
void* mapped_data;
|
||||
vkMapMemory(device, vulkanBuffer->memory, 0, VK_WHOLE_SIZE, 0, &mapped_data);
|
||||
|
@ -330,7 +337,7 @@ void* GFXVulkan::get_buffer_contents(GFXBuffer* buffer) {
|
|||
}
|
||||
|
||||
void GFXVulkan::release_buffer_contents(GFXBuffer* buffer, void* handle) {
|
||||
GFXVulkanBuffer* vulkanBuffer = (GFXVulkanBuffer*)buffer;
|
||||
auto vulkanBuffer = (GFXVulkanBuffer*)buffer;
|
||||
|
||||
VkMappedMemoryRange range = {};
|
||||
range.sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE;
|
||||
|
@ -343,7 +350,7 @@ void GFXVulkan::release_buffer_contents(GFXBuffer* buffer, void* handle) {
|
|||
}
|
||||
|
||||
GFXTexture* GFXVulkan::create_texture(const GFXTextureCreateInfo& info) {
|
||||
GFXVulkanTexture* texture = new GFXVulkanTexture();
|
||||
auto texture = new GFXVulkanTexture();
|
||||
|
||||
vkDeviceWaitIdle(device);
|
||||
|
||||
|
@ -508,7 +515,7 @@ GFXTexture* GFXVulkan::create_texture(const GFXTextureCreateInfo& info) {
|
|||
}
|
||||
|
||||
void GFXVulkan::copy_texture(GFXTexture* texture, void* data, GFXSize size) {
|
||||
GFXVulkanTexture* vulkanTexture = (GFXVulkanTexture*)texture;
|
||||
auto vulkanTexture = (GFXVulkanTexture*)texture;
|
||||
|
||||
vkDeviceWaitIdle(device);
|
||||
|
||||
|
@ -577,8 +584,8 @@ void GFXVulkan::copy_texture(GFXTexture* from, GFXTexture* to) {
|
|||
}
|
||||
|
||||
void GFXVulkan::copy_texture(GFXTexture* from, GFXBuffer* to) {
|
||||
GFXVulkanTexture* vulkanTexture = (GFXVulkanTexture*)from;
|
||||
GFXVulkanBuffer* vulkanBuffer = (GFXVulkanBuffer*)to;
|
||||
auto vulkanTexture = (GFXVulkanTexture*)from;
|
||||
auto vulkanBuffer = (GFXVulkanBuffer*)to;
|
||||
|
||||
VkCommandBuffer commandBuffer = beginSingleTimeCommands();
|
||||
|
||||
|
@ -599,7 +606,7 @@ void GFXVulkan::copy_texture(GFXTexture* from, GFXBuffer* to) {
|
|||
}
|
||||
|
||||
GFXSampler* GFXVulkan::create_sampler(const GFXSamplerCreateInfo& info) {
|
||||
GFXVulkanSampler* sampler = new GFXVulkanSampler();
|
||||
auto sampler = new GFXVulkanSampler();
|
||||
|
||||
const VkSamplerAddressMode samplerMode = toSamplerMode(info.samplingMode);
|
||||
|
||||
|
@ -623,15 +630,15 @@ GFXSampler* GFXVulkan::create_sampler(const GFXSamplerCreateInfo& info) {
|
|||
}
|
||||
|
||||
GFXFramebuffer* GFXVulkan::create_framebuffer(const GFXFramebufferCreateInfo& info) {
|
||||
GFXVulkanFramebuffer* framebuffer = new GFXVulkanFramebuffer();
|
||||
auto framebuffer = new GFXVulkanFramebuffer();
|
||||
|
||||
vkDeviceWaitIdle(device);
|
||||
|
||||
GFXVulkanRenderPass* renderPass = (GFXVulkanRenderPass*)info.render_pass;
|
||||
auto renderPass = (GFXVulkanRenderPass*)info.render_pass;
|
||||
|
||||
std::vector<VkImageView> attachments;
|
||||
for (auto& attachment : info.attachments) {
|
||||
GFXVulkanTexture* texture = (GFXVulkanTexture*)attachment;
|
||||
auto texture = (GFXVulkanTexture*)attachment;
|
||||
attachments.push_back(texture->view);
|
||||
|
||||
VkImageLayout expectedLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
|
@ -667,7 +674,7 @@ GFXFramebuffer* GFXVulkan::create_framebuffer(const GFXFramebufferCreateInfo& in
|
|||
}
|
||||
|
||||
GFXRenderPass* GFXVulkan::create_render_pass(const GFXRenderPassCreateInfo& info) {
|
||||
GFXVulkanRenderPass* renderPass = new GFXVulkanRenderPass();
|
||||
auto renderPass = new GFXVulkanRenderPass();
|
||||
|
||||
vkDeviceWaitIdle(device);
|
||||
|
||||
|
@ -756,7 +763,7 @@ GFXRenderPass* GFXVulkan::create_render_pass(const GFXRenderPassCreateInfo& info
|
|||
}
|
||||
|
||||
GFXPipeline* GFXVulkan::create_graphics_pipeline(const GFXGraphicsPipelineCreateInfo& info) {
|
||||
GFXVulkanPipeline* pipeline = new GFXVulkanPipeline();
|
||||
auto pipeline = new GFXVulkanPipeline();
|
||||
|
||||
vkDeviceWaitIdle(device);
|
||||
|
||||
|
@ -929,6 +936,8 @@ GFXPipeline* GFXVulkan::create_graphics_pipeline(const GFXGraphicsPipelineCreate
|
|||
case GFXDepthMode::Greater:
|
||||
depthStencil.depthCompareOp = VK_COMPARE_OP_GREATER;
|
||||
break;
|
||||
case GFXDepthMode::None:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -982,6 +991,8 @@ GFXPipeline* GFXVulkan::create_graphics_pipeline(const GFXGraphicsPipelineCreate
|
|||
case GFXBindingType::Sampler:
|
||||
descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER;
|
||||
break;
|
||||
case GFXBindingType::PushConstant:
|
||||
break;
|
||||
}
|
||||
|
||||
VkDescriptorSetLayoutBinding layoutBinding = {};
|
||||
|
@ -1045,7 +1056,7 @@ GFXPipeline* GFXVulkan::create_graphics_pipeline(const GFXGraphicsPipelineCreate
|
|||
}
|
||||
|
||||
GFXPipeline* GFXVulkan::create_compute_pipeline(const GFXComputePipelineCreateInfo& info) {
|
||||
GFXVulkanPipeline* pipeline = new GFXVulkanPipeline();
|
||||
auto pipeline = new GFXVulkanPipeline();
|
||||
|
||||
vkDeviceWaitIdle(device);
|
||||
|
||||
|
@ -1117,6 +1128,8 @@ GFXPipeline* GFXVulkan::create_compute_pipeline(const GFXComputePipelineCreateIn
|
|||
case GFXBindingType::Sampler:
|
||||
descriptorType = VK_DESCRIPTOR_TYPE_SAMPLER;
|
||||
break;
|
||||
case GFXBindingType::PushConstant:
|
||||
break;
|
||||
}
|
||||
|
||||
VkDescriptorSetLayoutBinding layoutBinding = {};
|
||||
|
@ -1170,7 +1183,7 @@ GFXSize GFXVulkan::get_alignment(GFXSize size) {
|
|||
}
|
||||
|
||||
GFXCommandBuffer* GFXVulkan::acquire_command_buffer(bool for_presentation_use) {
|
||||
GFXVulkanCommandBuffer* cmdbuf = new GFXVulkanCommandBuffer();
|
||||
auto cmdbuf = new GFXVulkanCommandBuffer();
|
||||
|
||||
if(!for_presentation_use) {
|
||||
VkCommandBufferAllocateInfo info = {};
|
||||
|
@ -1203,7 +1216,7 @@ void GFXVulkan::submit(GFXCommandBuffer* command_buffer, const int identifier) {
|
|||
|
||||
VkCommandBuffer cmd = VK_NULL_HANDLE;
|
||||
|
||||
GFXVulkanCommandBuffer* cmdbuf = (GFXVulkanCommandBuffer*)command_buffer;
|
||||
auto cmdbuf = (GFXVulkanCommandBuffer*)command_buffer;
|
||||
if(cmdbuf->handle != VK_NULL_HANDLE)
|
||||
cmd = cmdbuf->handle;
|
||||
else if(current_surface != nullptr)
|
||||
|
@ -1252,8 +1265,8 @@ void GFXVulkan::submit(GFXCommandBuffer* command_buffer, const int identifier) {
|
|||
vkCmdEndRenderPass(cmd);
|
||||
}
|
||||
|
||||
GFXVulkanRenderPass* renderPass = (GFXVulkanRenderPass*)command.data.set_render_pass.render_pass;
|
||||
GFXVulkanFramebuffer* framebuffer = (GFXVulkanFramebuffer*)command.data.set_render_pass.framebuffer;
|
||||
auto renderPass = (GFXVulkanRenderPass*)command.data.set_render_pass.render_pass;
|
||||
auto framebuffer = (GFXVulkanFramebuffer*)command.data.set_render_pass.framebuffer;
|
||||
|
||||
if (renderPass != nullptr) {
|
||||
currentRenderPass = renderPass->handle;
|
||||
|
@ -1423,8 +1436,8 @@ void GFXVulkan::submit(GFXCommandBuffer* command_buffer, const int identifier) {
|
|||
break;
|
||||
case GFXCommandType::CopyTexture:
|
||||
{
|
||||
GFXVulkanTexture* src = (GFXVulkanTexture*)command.data.copy_texture.src;
|
||||
GFXVulkanTexture* dst = (GFXVulkanTexture*)command.data.copy_texture.dst;
|
||||
auto src = (GFXVulkanTexture*)command.data.copy_texture.src;
|
||||
auto dst = (GFXVulkanTexture*)command.data.copy_texture.dst;
|
||||
|
||||
const int slice_offset = command.data.copy_texture.to_slice + command.data.copy_texture.to_layer * 6;
|
||||
|
||||
|
@ -1528,7 +1541,7 @@ void GFXVulkan::submit(GFXCommandBuffer* command_buffer, const int identifier) {
|
|||
break;
|
||||
case GFXCommandType::GenerateMipmaps:
|
||||
{
|
||||
auto texture = static_cast<GFXVulkanTexture*>(command.data.generate_mipmaps.texture);
|
||||
auto texture = dynamic_cast<GFXVulkanTexture*>(command.data.generate_mipmaps.texture);
|
||||
|
||||
for(int l = 0; l < texture->range.layerCount; l++) {
|
||||
int mip_width = texture->width;
|
||||
|
@ -2089,7 +2102,7 @@ void GFXVulkan::cacheDescriptorState(GFXVulkanPipeline* pipeline, VkDescriptorSe
|
|||
// update set
|
||||
for (auto [i, buffer] : utility::enumerate(boundShaderBuffers)) {
|
||||
if (buffer.buffer != nullptr) {
|
||||
GFXVulkanBuffer* vulkanBuffer = (GFXVulkanBuffer*)buffer.buffer;
|
||||
auto vulkanBuffer = (GFXVulkanBuffer*)buffer.buffer;
|
||||
|
||||
VkDescriptorBufferInfo bufferInfo = {};
|
||||
bufferInfo.buffer = vulkanBuffer->handle; // will this break?
|
||||
|
@ -2110,7 +2123,7 @@ void GFXVulkan::cacheDescriptorState(GFXVulkanPipeline* pipeline, VkDescriptorSe
|
|||
|
||||
for (auto [i, texture] : utility::enumerate(boundTextures)) {
|
||||
if (texture != nullptr) {
|
||||
GFXVulkanTexture* vulkanTexture = (GFXVulkanTexture*) texture;
|
||||
auto vulkanTexture = (GFXVulkanTexture*) texture;
|
||||
|
||||
VkDescriptorImageInfo imageInfo = {};
|
||||
imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
|
||||
|
@ -2146,7 +2159,7 @@ void GFXVulkan::cacheDescriptorState(GFXVulkanPipeline* pipeline, VkDescriptorSe
|
|||
|
||||
for (auto [i, sampler] : utility::enumerate(boundSamplers)) {
|
||||
if (sampler != nullptr) {
|
||||
GFXVulkanSampler* vulkanSampler = (GFXVulkanSampler*) sampler;
|
||||
auto vulkanSampler = (GFXVulkanSampler*) sampler;
|
||||
|
||||
VkDescriptorImageInfo imageInfo = {};
|
||||
imageInfo.sampler = vulkanSampler->sampler;
|
||||
|
|
Reference in a new issue