From 976647f61736aed211a2258f85cd8078c66ab856 Mon Sep 17 00:00:00 2001 From: AWoloszyn Date: Fri, 9 Sep 2022 15:29:22 -0400 Subject: [PATCH] A bunch of cleanup to make it so the build is warning free. --- .../calibrated_timestamps/main.cpp | 4 +- .../compute_particles/main.cpp | 4 +- .../extended_dynamic_state/main.cpp | 2 +- .../external_buffer/buffer_export.cpp | 3 +- .../external_buffer/buffer_import.cpp | 14 +- .../external_image/image_export.cpp | 3 +- .../external_image/image_import.cpp | 11 +- .../external_memory_host/main.cpp | 3 +- .../many_commandbuffers_cube/main.cpp | 14 +- application_sandbox/memory_budget/main.cpp | 13 +- .../overlapping_frames/main.cpp | 14 +- .../render_depth_attachment/main.cpp | 49 ++-- .../render_input_attachment/main.cpp | 21 +- application_sandbox/render_quad/main.cpp | 44 ++-- application_sandbox/sample_locations/main.cpp | 88 +++---- .../synchronization2_write_timestamp/main.cpp | 4 +- application_sandbox/write_timestamp/main.cpp | 8 +- cmake/build_apk.cmake | 246 +++++++++++------- support/entry/CMakeLists.txt | 6 +- third_party/vk_callback_swapchain | 2 +- vulkan_helpers/vulkan_application.cpp | 8 +- vulkan_helpers/vulkan_texture.h | 24 +- 22 files changed, 318 insertions(+), 267 deletions(-) diff --git a/application_sandbox/calibrated_timestamps/main.cpp b/application_sandbox/calibrated_timestamps/main.cpp index c8cf9633..df701bd3 100644 --- a/application_sandbox/calibrated_timestamps/main.cpp +++ b/application_sandbox/calibrated_timestamps/main.cpp @@ -327,8 +327,8 @@ class CalibratedTimestampsSample data_->allocator()); VkResult result = app()->device()->vkGetCalibratedTimestampsEXT( - app()->device(), time_domains_.size(), timestamp_infos.data(), - timestamps.data(), max_deviation.data()); + app()->device(), static_cast(time_domains_.size()), + timestamp_infos.data(), timestamps.data(), max_deviation.data()); for (uint32_t i = 0; i < timestamp_infos.size(); i++) { app()->GetLogger()->LogInfo( diff --git a/application_sandbox/compute_particles/main.cpp b/application_sandbox/compute_particles/main.cpp index 66818881..0b6e7c34 100644 --- a/application_sandbox/compute_particles/main.cpp +++ b/application_sandbox/compute_particles/main.cpp @@ -678,7 +678,7 @@ class ComputeParticlesSample virtual void Render(vulkan::VkQueue* queue, size_t frame_index, ComputeParticlesFrameData* data) override { - compute_task_.SubmitComputeTask(frame_index, + compute_task_.SubmitComputeTask(static_cast(frame_index), data->render_semaphore_->get_raw_object()); // Get the next buffer that we use for the particle positions. auto* buffer = compute_task_.GetBufferForRender(); @@ -844,7 +844,7 @@ class ComputeParticlesSample VK_STRUCTURE_TYPE_SUBMIT_INFO, // sType nullptr, // pNext 1, // waitSemaphoreCount - &compute_task_.GetSemaphoreForIndex(frame_index) + &compute_task_.GetSemaphoreForIndex(static_cast(frame_index)) ->get_raw_object(), // pWaitSemaphores &waitStageMask, // pWaitDstStageMask, 1, // commandBufferCount diff --git a/application_sandbox/extended_dynamic_state/main.cpp b/application_sandbox/extended_dynamic_state/main.cpp index bd563c79..720645fc 100644 --- a/application_sandbox/extended_dynamic_state/main.cpp +++ b/application_sandbox/extended_dynamic_state/main.cpp @@ -426,7 +426,7 @@ class ExtendedDynamicStateSample VK_STENCIL_OP_KEEP /* passOp */, VK_STENCIL_OP_ZERO /* depthFailOp */, VK_COMPARE_OP_EQUAL /* compareOp */); cmdBuffer->vkCmdSetStencilReference(cmdBuffer, - VK_STENCIL_FACE_FRONT_AND_BACK, 1.0f); + VK_STENCIL_FACE_FRONT_AND_BACK, 1); cmdBuffer->vkCmdDrawIndexed( cmdBuffer, static_cast(extended_dynamic_state_.NumIndices()), 4 /* instanceCount */, 0, 0, 0); diff --git a/application_sandbox/external_buffer/buffer_export.cpp b/application_sandbox/external_buffer/buffer_export.cpp index 1eaa8e94..6e8a7480 100644 --- a/application_sandbox/external_buffer/buffer_export.cpp +++ b/application_sandbox/external_buffer/buffer_export.cpp @@ -181,7 +181,8 @@ int main_entry(const entry::EntryData* data) { DWORD bytes_writen; WriteFile(pipe_handle, client_data_handles.data(), - sizeof(HANDLE) * client_data_handles.size(), &bytes_writen, NULL); + static_cast(sizeof(HANDLE) * client_data_handles.size()), + &bytes_writen, NULL); FlushFileBuffers(pipe_handle); CloseHandle(current_process); diff --git a/application_sandbox/external_buffer/buffer_import.cpp b/application_sandbox/external_buffer/buffer_import.cpp index 73246c1c..d238a2e2 100644 --- a/application_sandbox/external_buffer/buffer_import.cpp +++ b/application_sandbox/external_buffer/buffer_import.cpp @@ -12,19 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include + #include "application_sandbox/sample_application_framework/sample_application.h" +#include "external_buffer.h" +#include "mathfu/matrix.h" +#include "mathfu/vector.h" #include "support/entry/entry.h" #include "vulkan_helpers/buffer_frame_data.h" #include "vulkan_helpers/helper_functions.h" #include "vulkan_helpers/vulkan_application.h" #include "vulkan_helpers/vulkan_model.h" -#include -#include "mathfu/matrix.h" -#include "mathfu/vector.h" - -#include "external_buffer.h" - #ifdef __linux__ #include #include @@ -334,7 +333,8 @@ class CubeSample : public sample_application::Sample { } while (pipe_handle == INVALID_HANDLE_VALUE); DWORD bytes_read; ReadFile(pipe_handle, native_handles.data(), - sizeof(HANDLE) * native_handles.size(), &bytes_read, NULL); + static_cast(sizeof(HANDLE) * native_handles.size()), + &bytes_read, NULL); CloseHandle(pipe_handle); } diff --git a/application_sandbox/external_image/image_export.cpp b/application_sandbox/external_image/image_export.cpp index 0181578f..f7a9f8eb 100644 --- a/application_sandbox/external_image/image_export.cpp +++ b/application_sandbox/external_image/image_export.cpp @@ -577,7 +577,8 @@ int main_entry(const entry::EntryData* data) { DWORD bytes_writen; WriteFile(pipe_handle, client_data_handles.data(), - sizeof(HANDLE) * client_data_handles.size(), &bytes_writen, NULL); + static_cast(sizeof(HANDLE) * client_data_handles.size()), + &bytes_writen, NULL); FlushFileBuffers(pipe_handle); CloseHandle(current_process); diff --git a/application_sandbox/external_image/image_import.cpp b/application_sandbox/external_image/image_import.cpp index 75d2fa27..b027fef6 100644 --- a/application_sandbox/external_image/image_import.cpp +++ b/application_sandbox/external_image/image_import.cpp @@ -12,7 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include + #include "application_sandbox/sample_application_framework/sample_application.h" +#include "mathfu/matrix.h" +#include "mathfu/vector.h" #include "support/entry/entry.h" #include "vulkan_helpers/buffer_frame_data.h" #include "vulkan_helpers/helper_functions.h" @@ -20,10 +24,6 @@ #include "vulkan_helpers/vulkan_model.h" #include "vulkan_helpers/vulkan_texture.h" -#include -#include "mathfu/matrix.h" -#include "mathfu/vector.h" - #ifdef __linux__ #include #include @@ -561,7 +561,8 @@ class TexturedCubeSample } while (pipe_handle == INVALID_HANDLE_VALUE); DWORD bytes_read; ReadFile(pipe_handle, native_handles.data(), - sizeof(HANDLE) * native_handles.size(), &bytes_read, NULL); + static_cast(sizeof(HANDLE) * native_handles.size()), + &bytes_read, NULL); CloseHandle(pipe_handle); } diff --git a/application_sandbox/external_memory_host/main.cpp b/application_sandbox/external_memory_host/main.cpp index 6f355c6a..2cc2924d 100644 --- a/application_sandbox/external_memory_host/main.cpp +++ b/application_sandbox/external_memory_host/main.cpp @@ -146,7 +146,8 @@ class VkBufferExternalMemoryHost { const auto& memory_properties = device_.physical_device_memory_properties(); int idx = -1; - for (idx = 0; idx < memory_properties.memoryTypeCount; idx++) { + for (idx = 0; idx < static_cast(memory_properties.memoryTypeCount); + idx++) { if (memoryTypeBits & (1U << idx)) { break; } diff --git a/application_sandbox/many_commandbuffers_cube/main.cpp b/application_sandbox/many_commandbuffers_cube/main.cpp index 113799b0..bcaed764 100644 --- a/application_sandbox/many_commandbuffers_cube/main.cpp +++ b/application_sandbox/many_commandbuffers_cube/main.cpp @@ -12,17 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include + #include "application_sandbox/sample_application_framework/sample_application.h" +#include "mathfu/matrix.h" +#include "mathfu/vector.h" #include "support/entry/entry.h" #include "vulkan_helpers/buffer_frame_data.h" #include "vulkan_helpers/helper_functions.h" #include "vulkan_helpers/vulkan_application.h" #include "vulkan_helpers/vulkan_model.h" -#include -#include "mathfu/matrix.h" -#include "mathfu/vector.h" - using Mat44 = mathfu::Matrix; using Vector4 = mathfu::Vector; @@ -273,7 +273,7 @@ class ManyCommandbuffersCube auto& cb = frame_data->dummy_command_buffers_[i]; cb->vkResetCommandBuffer(cb, 0); cb->vkBeginCommandBuffer(cb, &sample_application::kBeginCommandBuffer); - cb->vkCmdSetLineWidth(cb, 1.0); + cb->vkCmdSetLineWidth(cb, 1.0f); cb->vkEndCommandBuffer(cb); VkSubmitInfo dummy_submit_info{ VK_STRUCTURE_TYPE_SUBMIT_INFO, // sType @@ -303,8 +303,8 @@ class ManyCommandbuffersCube submit_info_list.push_back(cube_submit_info); app()->render_queue()->vkQueueSubmit( - app()->render_queue(), submit_info_list.size(), submit_info_list.data(), - static_cast(VK_NULL_HANDLE)); + app()->render_queue(), static_cast(submit_info_list.size()), + submit_info_list.data(), static_cast(VK_NULL_HANDLE)); } private: diff --git a/application_sandbox/memory_budget/main.cpp b/application_sandbox/memory_budget/main.cpp index 442105ce..df6d5845 100644 --- a/application_sandbox/memory_budget/main.cpp +++ b/application_sandbox/memory_budget/main.cpp @@ -12,17 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include + #include "application_sandbox/sample_application_framework/sample_application.h" +#include "mathfu/matrix.h" +#include "mathfu/vector.h" #include "support/entry/entry.h" #include "vulkan_helpers/buffer_frame_data.h" #include "vulkan_helpers/helper_functions.h" #include "vulkan_helpers/vulkan_application.h" #include "vulkan_helpers/vulkan_model.h" -#include -#include "mathfu/matrix.h" -#include "mathfu/vector.h" - using Mat44 = mathfu::Matrix; using Vector4 = mathfu::Vector; @@ -158,11 +158,12 @@ class CubeSample : public sample_application::Sample { app()->instance()->vkGetPhysicalDeviceMemoryProperties2( app()->device().physical_device(), &memory_properties); - for (int i = 0; i < memory_properties.memoryProperties.memoryHeapCount; + for (uint32_t i = 0; i < memory_properties.memoryProperties.memoryHeapCount; ++i) { app()->GetLogger()->LogInfo("Heap ", i, ":"); app()->GetLogger()->LogInfo( - "HeapSize: ", memory_properties.memoryProperties.memoryHeaps[i].size); + "HeapSize: ", + memory_properties.memoryProperties.memoryHeaps[i].size); app()->GetLogger()->LogInfo("HeapBudget: ", memory_budget_properties.heapBudget[i]); app()->GetLogger()->LogInfo("HeapUsage: ", diff --git a/application_sandbox/overlapping_frames/main.cpp b/application_sandbox/overlapping_frames/main.cpp index 0e28707a..1773b3dc 100644 --- a/application_sandbox/overlapping_frames/main.cpp +++ b/application_sandbox/overlapping_frames/main.cpp @@ -526,7 +526,8 @@ int main_entry(const entry::EntryData* data) { g_pipeline); ref_buf->vkCmdPushConstants( ref_buf, g_pipeline_layout, VK_SHADER_STAGE_VERTEX_BIT, 0, - sizeof(GeometryPushConstantData), &g_push_constant_data); + static_cast(sizeof(GeometryPushConstantData)), + &g_push_constant_data); ref_buf->vkCmdDraw(ref_buf, 3, 1, 0, 0); ref_buf->vkCmdEndRenderPass(ref_buf); LOG_ASSERT(==, data->logger(), VK_SUCCESS, @@ -558,10 +559,10 @@ int main_entry(const entry::EntryData* data) { // Update push constants std::chrono::steady_clock::time_point current_time_point = std::chrono::steady_clock::now(); - float time_lapse = std::chrono::duration_cast( - current_time_point - start_time_point) - .count(); - g_push_constant_data.time = triangle_speed * time_lapse; + auto time_lapse = std::chrono::duration_cast( + current_time_point - start_time_point) + .count(); + g_push_constant_data.time = triangle_speed * static_cast(time_lapse); // Write command buffer auto& geometry_buf = frame_data[next_frame].gCommandBuffer; @@ -584,7 +585,8 @@ int main_entry(const entry::EntryData* data) { g_pipeline); geo_ref->vkCmdPushConstants( geo_ref, g_pipeline_layout, VK_SHADER_STAGE_VERTEX_BIT, 0, - sizeof(GeometryPushConstantData), &g_push_constant_data); + static_cast(sizeof(GeometryPushConstantData)), + &g_push_constant_data); geo_ref->vkCmdDraw(geo_ref, 3, 1, 0, 0); geo_ref->vkCmdEndRenderPass(geo_ref); LOG_ASSERT(==, data->logger(), VK_SUCCESS, diff --git a/application_sandbox/render_depth_attachment/main.cpp b/application_sandbox/render_depth_attachment/main.cpp index 66d4bac0..a35d2589 100644 --- a/application_sandbox/render_depth_attachment/main.cpp +++ b/application_sandbox/render_depth_attachment/main.cpp @@ -12,18 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include +#include + #include "application_sandbox/sample_application_framework/sample_application.h" +#include "mathfu/matrix.h" +#include "mathfu/vector.h" #include "support/entry/entry.h" #include "vulkan_helpers/buffer_frame_data.h" #include "vulkan_helpers/helper_functions.h" #include "vulkan_helpers/vulkan_application.h" #include "vulkan_helpers/vulkan_model.h" -#include -#include -#include "mathfu/matrix.h" -#include "mathfu/vector.h" - uint32_t populating_attachments_frag[] = #include "intermediate.frag.spv" ; @@ -168,13 +168,13 @@ class RenderQuadSample VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL // finalLayout }; auto i_att_desc = VkAttachmentDescription{ - 0, // flags - VK_FORMAT_D16_UNORM, // format - VK_SAMPLE_COUNT_1_BIT, // samples - VK_ATTACHMENT_LOAD_OP_LOAD, // loadOp - VK_ATTACHMENT_STORE_OP_STORE, // storeOp - VK_ATTACHMENT_LOAD_OP_LOAD, // stencilLoadOp - VK_ATTACHMENT_STORE_OP_STORE, // stencilStoreOp + 0, // flags + VK_FORMAT_D16_UNORM, // format + VK_SAMPLE_COUNT_1_BIT, // samples + VK_ATTACHMENT_LOAD_OP_LOAD, // loadOp + VK_ATTACHMENT_STORE_OP_STORE, // storeOp + VK_ATTACHMENT_LOAD_OP_LOAD, // stencilLoadOp + VK_ATTACHMENT_STORE_OP_STORE, // stencilStoreOp VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL, // initialLayout VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL // finalLayout }; @@ -198,7 +198,7 @@ class RenderQuadSample { o_att_desc, // Color Attachment i_att_desc, // Depth Input Attachment - }, // AttachmentDescriptions + }, // AttachmentDescriptions { subpass_desc, }, // SubpassDescriptions @@ -208,8 +208,8 @@ class RenderQuadSample rendering_output_pipeline_ = containers::make_unique( data_->allocator(), app()->CreateGraphicsPipeline( - pipeline_layout_.get(), - rendering_output_render_pass_.get(), 0)); + pipeline_layout_.get(), + rendering_output_render_pass_.get(), 0)); rendering_output_pipeline_->AddShader(VK_SHADER_STAGE_VERTEX_BIT, "main", pass_through_vert); rendering_output_pipeline_->AddShader(VK_SHADER_STAGE_FRAGMENT_BIT, "main", @@ -245,7 +245,7 @@ class RenderQuadSample { o_att_desc, // Depth Attachment i_att_desc, // Color Input Attachment - }, // AttachmentDescriptions + }, // AttachmentDescriptions { subpass_desc, }, // SubpassDescriptions @@ -267,7 +267,8 @@ class RenderQuadSample populating_attachments_pipeline_->SetScissor(scissor()); populating_attachments_pipeline_->SetViewport(viewport()); populating_attachments_pipeline_->SetSamples(VK_SAMPLE_COUNT_1_BIT); - populating_attachments_pipeline_->DepthStencilState().depthCompareOp = VK_COMPARE_OP_ALWAYS; + populating_attachments_pipeline_->DepthStencilState().depthCompareOp = + VK_COMPARE_OP_ALWAYS; populating_attachments_pipeline_->Commit(); depth_data_ = containers::make_unique>( @@ -330,8 +331,8 @@ class RenderQuadSample *frame_data->trans_dst_img_, // image VK_IMAGE_VIEW_TYPE_2D, // viewType frame_data->trans_dst_img_->format(), // format - {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, - VK_COMPONENT_SWIZZLE_IDENTITY}, + {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, + VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY}, {VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1}}; ::VkImageView raw_trans_dst_view; LOG_ASSERT(==, data_->logger(), VK_SUCCESS, @@ -425,7 +426,8 @@ class RenderQuadSample data_->allocator(), app()->AllocateDescriptorSet({descriptor_set_layout_binding_})); input_attachment_info.imageView = *frame_data->attachment_img_view_; - input_attachment_info.imageLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; + input_attachment_info.imageLayout = + VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; write.dstSet = *frame_data->rendering_output_descriptor_set_; app()->device()->vkUpdateDescriptorSets(app()->device(), 1, &write, 0, nullptr); @@ -480,9 +482,10 @@ class RenderQuadSample // copy from buf to img. The swapchain image must be larger in both // dimensions. LOG_ASSERT(>=, data_->logger(), app()->swapchain().width(), src_data.width); - LOG_ASSERT(>=, data_->logger(), app()->swapchain().height(), src_data.height); - uint32_t copy_width = src_data.width; - uint32_t copy_height = src_data.height; + LOG_ASSERT(>=, data_->logger(), app()->swapchain().height(), + src_data.height); + uint32_t copy_width = static_cast(src_data.width); + uint32_t copy_height = static_cast(src_data.height); VkBufferImageCopy copy_region{ depth_data_->get_offset_for_frame(frame_index), 0, diff --git a/application_sandbox/render_input_attachment/main.cpp b/application_sandbox/render_input_attachment/main.cpp index 0428fa7d..c3f0228b 100644 --- a/application_sandbox/render_input_attachment/main.cpp +++ b/application_sandbox/render_input_attachment/main.cpp @@ -12,18 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include +#include + #include "application_sandbox/sample_application_framework/sample_application.h" +#include "mathfu/matrix.h" +#include "mathfu/vector.h" #include "support/entry/entry.h" #include "vulkan_helpers/buffer_frame_data.h" #include "vulkan_helpers/helper_functions.h" #include "vulkan_helpers/vulkan_application.h" #include "vulkan_helpers/vulkan_model.h" -#include -#include -#include "mathfu/matrix.h" -#include "mathfu/vector.h" - uint32_t populating_attachments_frag[] = #include "intermediate.frag.spv" ; @@ -208,8 +208,8 @@ class RenderQuadSample rendering_output_pipeline_ = containers::make_unique( data_->allocator(), app()->CreateGraphicsPipeline( - pipeline_layout_.get(), - rendering_output_render_pass_.get(), 0)); + pipeline_layout_.get(), + rendering_output_render_pass_.get(), 0)); rendering_output_pipeline_->AddShader(VK_SHADER_STAGE_VERTEX_BIT, "main", pass_through_vert); rendering_output_pipeline_->AddShader(VK_SHADER_STAGE_FRAGMENT_BIT, "main", @@ -470,9 +470,10 @@ class RenderQuadSample // copy from buf to img. The swapchain image must be larger in both // dimensions. LOG_ASSERT(>=, data_->logger(), app()->swapchain().width(), src_data.width); - LOG_ASSERT(>=, data_->logger(), app()->swapchain().height(), src_data.height); - uint32_t copy_width = src_data.width; - uint32_t copy_height = src_data.height; + LOG_ASSERT(>=, data_->logger(), app()->swapchain().height(), + src_data.height); + uint32_t copy_width = static_cast(src_data.width); + uint32_t copy_height = static_cast(src_data.height); VkBufferImageCopy copy_region{ color_data_->get_offset_for_frame(frame_index), 0, diff --git a/application_sandbox/render_quad/main.cpp b/application_sandbox/render_quad/main.cpp index 8f41c387..3d49bf21 100644 --- a/application_sandbox/render_quad/main.cpp +++ b/application_sandbox/render_quad/main.cpp @@ -12,18 +12,18 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include +#include + #include "application_sandbox/sample_application_framework/sample_application.h" +#include "mathfu/matrix.h" +#include "mathfu/vector.h" #include "support/entry/entry.h" #include "vulkan_helpers/buffer_frame_data.h" #include "vulkan_helpers/helper_functions.h" #include "vulkan_helpers/vulkan_application.h" #include "vulkan_helpers/vulkan_model.h" -#include -#include -#include "mathfu/matrix.h" -#include "mathfu/vector.h" - uint32_t fragment_shader[] = #include "render_quad.frag.spv" ; @@ -73,11 +73,11 @@ void populateData(logging::Logger* log, uint8_t* dst, size_t size, } // staging image must have a wider format than the target image to avoid // precision lost. - if (target_pixel_width == 0 ) { - log->LogInfo("Target image format not supported:", target_format); + if (target_pixel_width == 0) { + log->LogInfo("Target image format not supported:", target_format); } if (staging_pixel_width == 0) { - log->LogInfo("Staging image format not supported:", staging_format); + log->LogInfo("Staging image format not supported:", staging_format); } LOG_ASSERT(!=, log, 0, target_pixel_width); LOG_ASSERT(!=, log, 0, staging_pixel_width); @@ -170,7 +170,7 @@ class RenderQuadSample }, // Color Attachment { 0, // flags - VK_FORMAT_R8G8B8A8_UINT, // format + VK_FORMAT_R8G8B8A8_UINT, // format num_samples(), // samples VK_ATTACHMENT_LOAD_OP_LOAD, // loadOp VK_ATTACHMENT_STORE_OP_DONT_CARE, // storeOp @@ -207,9 +207,8 @@ class RenderQuadSample )); pipeline_ = containers::make_unique( - data_->allocator(), - app()->CreateGraphicsPipeline(pipeline_layout_.get(), - render_pass_.get(), 0)); + data_->allocator(), app()->CreateGraphicsPipeline( + pipeline_layout_.get(), render_pass_.get(), 0)); pipeline_->AddShader(VK_SHADER_STAGE_VERTEX_BIT, "main", vertex_shader); pipeline_->AddShader(VK_SHADER_STAGE_FRAGMENT_BIT, "main", fragment_shader); pipeline_->SetTopology(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST); @@ -251,7 +250,7 @@ class RenderQuadSample nullptr, // pNext 0, // flags VK_IMAGE_TYPE_2D, // imageType - VK_FORMAT_R8G8B8A8_UINT, // format + VK_FORMAT_R8G8B8A8_UINT, // format { app()->swapchain().width(), // width app()->swapchain().height(), // height @@ -291,9 +290,8 @@ class RenderQuadSample &raw_color_input_view)); frame_data->color_input_view_ = containers::make_unique( - data_->allocator(), - vulkan::VkImageView(raw_color_input_view, nullptr, - &app()->device())); + data_->allocator(), vulkan::VkImageView(raw_color_input_view, + nullptr, &app()->device())); // depth input view view_info.image = *frame_data->depth_staging_img_; view_info.format = frame_data->depth_staging_img_->format(); @@ -304,9 +302,8 @@ class RenderQuadSample &raw_depth_input_view)); frame_data->depth_input_view_ = containers::make_unique( - data_->allocator(), - vulkan::VkImageView(raw_depth_input_view, nullptr, - &app()->device())); + data_->allocator(), vulkan::VkImageView(raw_depth_input_view, + nullptr, &app()->device())); // Create a framebuffer for rendering VkImageView views[4] = { @@ -433,11 +430,12 @@ class RenderQuadSample // copy from buf to img. The swapchain image must be larger in both // dimensions. LOG_ASSERT(>=, data_->logger(), app()->swapchain().width(), src_data.width); - LOG_ASSERT(>=, data_->logger(), app()->swapchain().height(), src_data.height); - uint32_t copy_width = src_data.width; - uint32_t copy_height = src_data.height; + LOG_ASSERT(>=, data_->logger(), app()->swapchain().height(), + src_data.height); + uint32_t copy_width = static_cast(src_data.width); + uint32_t copy_height = static_cast(src_data.height); VkBufferImageCopy copy_region{ - color_data_->get_offset_for_frame(frame_index), + color_data_->get_offset_for_frame(static_cast(frame_index)), 0, 0, {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1}, diff --git a/application_sandbox/sample_locations/main.cpp b/application_sandbox/sample_locations/main.cpp index a9ab3b3f..0b0e7ea7 100644 --- a/application_sandbox/sample_locations/main.cpp +++ b/application_sandbox/sample_locations/main.cpp @@ -12,17 +12,17 @@ // See the License for the specific language governing permissions and // limitations under the License. +#include + #include "application_sandbox/sample_application_framework/sample_application.h" +#include "mathfu/matrix.h" +#include "mathfu/vector.h" #include "support/entry/entry.h" #include "vulkan_helpers/buffer_frame_data.h" #include "vulkan_helpers/helper_functions.h" #include "vulkan_helpers/vulkan_application.h" #include "vulkan_helpers/vulkan_model.h" -#include -#include "mathfu/matrix.h" -#include "mathfu/vector.h" - using Mat44 = mathfu::Matrix; using Vector4 = mathfu::Vector; @@ -57,41 +57,39 @@ uint32_t mirror_vertex_shader[] = ; /// SAMPLE_LOCATION -static VkSampleLocationEXT sample_locations[4]{ -// { -// 0.6f, // x -// 0.2f // y -// }, -// { -// 0.6f, // x -// 0.5f // y -// }, -// { -// 0.6f, // x -// 0.5f // y -// }, -// { -// 0.6f, // x -// 0.2f // y -// } - - { - 0.0f, // x - 0.0f // y - }, - { - 0.0f, // x - 0.0f // y - }, - { - 0.0f, // x - 0.0f // y - }, - { - 0.0f, // x - 0.0f // y - } -}; +static VkSampleLocationEXT sample_locations[4]{// { + // 0.6f, // x + // 0.2f // y + // }, + // { + // 0.6f, // x + // 0.5f // y + // }, + // { + // 0.6f, // x + // 0.5f // y + // }, + // { + // 0.6f, // x + // 0.2f // y + // } + + { + 0.0f, // x + 0.0f // y + }, + { + 0.0f, // x + 0.0f // y + }, + { + 0.0f, // x + 0.0f // y + }, + { + 0.0f, // x + 0.0f // y + }}; static VkPhysicalDeviceSampleLocationsPropertiesEXT physical_device_sample_locations_properties{ VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLE_LOCATIONS_PROPERTIES_EXT, @@ -213,9 +211,9 @@ class StencilSample : public sample_application::Sample { nullptr, // pNext VK_SAMPLE_COUNT_4_BIT, // sampleLocationsPerPixel physical_device_sample_locations_properties - .maxSampleLocationGridSize, // sampleLocationGridSize - num_samples(), // sampleLocationsCount - sample_locations // pSampleLocations + .maxSampleLocationGridSize, // sampleLocationGridSize + static_cast(num_samples()), // sampleLocationsCount + sample_locations // pSampleLocations }; VkPipelineSampleLocationsStateCreateInfoEXT pipeline_sample_locations{ VK_STRUCTURE_TYPE_PIPELINE_SAMPLE_LOCATIONS_STATE_CREATE_INFO_EXT, @@ -443,9 +441,9 @@ class StencilSample : public sample_application::Sample { nullptr, // pNext VK_SAMPLE_COUNT_4_BIT, // sampleLocationsPerPixel physical_device_sample_locations_properties - .maxSampleLocationGridSize, // sampleLocationGridSize - num_samples(), // sampleLocationsCount - sample_locations // pSampleLocations + .maxSampleLocationGridSize, // sampleLocationGridSize + static_cast(num_samples()), // sampleLocationsCount + sample_locations // pSampleLocations }; VkAttachmentSampleLocationsEXT attachment_sample_locations{ 1, // attachmentIndex; diff --git a/application_sandbox/synchronization2_write_timestamp/main.cpp b/application_sandbox/synchronization2_write_timestamp/main.cpp index d6a4a7da..7fc944c8 100644 --- a/application_sandbox/synchronization2_write_timestamp/main.cpp +++ b/application_sandbox/synchronization2_write_timestamp/main.cpp @@ -210,7 +210,7 @@ class WriteTimestampSample data_->allocator(), app(), num_swapchain_images, VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT); - timestamp_data_->data().value = 0.0; + timestamp_data_->data().value = 0; } virtual void InitializeFrameData( @@ -359,7 +359,7 @@ class WriteTimestampSample cmdBuffer->vkCmdWriteTimestamp2KHR( cmdBuffer, VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT_KHR, *query_pool_, - frame_index); + static_cast(frame_index)); cmdBuffer->vkCmdBeginRenderPass(cmdBuffer, &pass_begin, VK_SUBPASS_CONTENTS_INLINE); diff --git a/application_sandbox/write_timestamp/main.cpp b/application_sandbox/write_timestamp/main.cpp index c18e4bd2..37cb51ba 100644 --- a/application_sandbox/write_timestamp/main.cpp +++ b/application_sandbox/write_timestamp/main.cpp @@ -203,7 +203,7 @@ class WriteTimestampSample data_->allocator(), app(), num_swapchain_images, VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT); - timestamp_data_->data().value = 0.0; + timestamp_data_->data().value = 0; } virtual void InitializeFrameData( @@ -340,9 +340,9 @@ class WriteTimestampSample cmdBuffer->vkCmdResetQueryPool(cmdBuffer, *query_pool_, static_cast(frame_index), 1); - cmdBuffer->vkCmdWriteTimestamp(cmdBuffer, - VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, - *query_pool_, frame_index); + cmdBuffer->vkCmdWriteTimestamp( + cmdBuffer, VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, *query_pool_, + static_cast(frame_index)); cmdBuffer->vkCmdBeginRenderPass(cmdBuffer, &pass_begin, VK_SUBPASS_CONTENTS_INLINE); diff --git a/cmake/build_apk.cmake b/cmake/build_apk.cmake index 89fa90bb..bc4b1866 100644 --- a/cmake/build_apk.cmake +++ b/cmake/build_apk.cmake @@ -4,7 +4,7 @@ # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, @@ -16,9 +16,9 @@ include(CMakeParseArguments) find_package(Python3 COMPONENTS Interpreter) - list(LENGTH CMAKE_CONFIGURATION_TYPES num_elements) -if (num_elements GREATER 1) + +if(num_elements GREATER 1) set(IS_MULTICONFIG ON) SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON) endif() @@ -55,8 +55,8 @@ set(NON_CONFIGURABLE_ANDROID_SOURCES set(CMAKE_GLSL_COMPILER "glslc" CACHE STRING "Which glsl compiler to use") -SET(DEFAULT_WINDOW_WIDTH ${DEFAULT_WINDOW_WIDTH} CACHE INT - "Default window width for platforms that have resizable windows") +SET(DEFAULT_WINDOW_WIDTH "${DEFAULT_WINDOW_WIDTH}" CACHE STRING + "Default window width for platforms that have resizable windows") if(BUILD_APKS) # Use the dummy target to pull down all of our dependencies @@ -74,6 +74,7 @@ if(BUILD_APKS) configure_file(${source}.in ${CMAKE_CURRENT_BINARY_DIR}/dummyapk/${rooted_source} @ONLY) list(APPEND TARGET_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/dummyapk/${rooted_source}) endforeach() + foreach(source ${NON_CONFIGURABLE_ANDROID_SOURCES}) file(RELATIVE_PATH rooted_source ${VulkanTestApplications_SOURCE_DIR}/cmake/android_project_template ${source}) configure_file(${source} ${CMAKE_CURRENT_BINARY_DIR}/dummyapk/${rooted_source} COPYONLY) @@ -87,13 +88,13 @@ if(BUILD_APKS) # dependencies to build with gradle. This is the only place that # should grab anything from the internet. add_custom_command( - OUTPUT ${target_config} - COMMENT "Gathering gradle dependencies" - COMMAND ./gradlew assembleDebug assembleRelease -no-rebuild --gradle-user-home - ${VulkanTestApplications_BINARY_DIR}/.gradle - COMMAND ${CMAKE_COMMAND} -E touch ${target_config} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dummyapk - DEPENDS ${TARGET_SOURCES}) + OUTPUT ${target_config} + COMMENT "Gathering gradle dependencies" + COMMAND ./gradlew assembleDebug assembleRelease -no-rebuild --gradle-user-home + ${VulkanTestApplications_BINARY_DIR}/.gradle + COMMAND ${CMAKE_COMMAND} -E touch ${target_config} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/dummyapk + DEPENDS ${TARGET_SOURCES}) add_custom_target(gradle_config ALL DEPENDS ${target_config}) endif() @@ -104,20 +105,24 @@ macro(gather_deps target) get_target_property(LIBS ${target} LIB_DEPS) get_target_property(SHADERS ${target} LIB_SHADERS) get_target_property(MODELS ${target} LIB_MODELS) - if (SRC) + + if(SRC) list(APPEND SOURCE_DEPS ${SRC}) endif() - if (SHADERS) + + if(SHADERS) foreach(LIB ${SHADERS}) gather_deps(${LIB}) endforeach() endif() - if (MODELS) + + if(MODELS) foreach(LIB ${MODELS}) gather_deps(${LIB}) endforeach() endif() - if (LIBS) + + if(LIBS) foreach(LIB ${LIBS}) gather_deps(${LIB}) endforeach() @@ -128,21 +133,21 @@ endmacro() # Compiles the given GLSL shader through glslc. function(compile_glsl_using_glslc shader output_file) get_filename_component(input_file ${shader} ABSOLUTE) - add_custom_command ( + add_custom_command( OUTPUT ${output_file} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Compiling SPIR-V binary ${shader}" DEPENDS ${shader} ${FILE_DEPS} - ${VulkanTestApplications_SOURCE_DIR}/cmake/generate_cmake_dep.py + ${VulkanTestApplications_SOURCE_DIR}/cmake/generate_cmake_dep.py COMMAND ${CMAKE_GLSL_COMPILER} -mfmt=c -o ${output_file} -c ${input_file} -MD - ${ADDITIONAL_ARGS} + ${ADDITIONAL_ARGS} COMMAND ${Python3_EXECUTABLE} - ${VulkanTestApplications_SOURCE_DIR}/cmake/generate_cmake_dep.py - ${output_file}.d + ${VulkanTestApplications_SOURCE_DIR}/cmake/generate_cmake_dep.py + ${output_file}.d COMMAND ${CMAKE_COMMAND} -E - copy_if_different - ${output_file}.d.cmake.tmp - ${output_file}.d.cmake + copy_if_different + ${output_file}.d.cmake.tmp + ${output_file}.d.cmake ) endfunction(compile_glsl_using_glslc) @@ -151,20 +156,20 @@ endfunction(compile_glsl_using_glslc) function(compile_hlsl_using_glslc shader output_file result) get_filename_component(input_file ${shader} ABSOLUTE) string(REPLACE ".hlsl." ".glslc.hlsl." glslc_hlsl_filename ${output_file}) - add_custom_command ( + add_custom_command( OUTPUT ${glslc_hlsl_filename} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Compiling HLSL to SPIR-V binary using glslc: ${shader}" DEPENDS ${shader} ${FILE_DEPS} - ${VulkanTestApplications_SOURCE_DIR}/cmake/generate_cmake_dep.py + ${VulkanTestApplications_SOURCE_DIR}/cmake/generate_cmake_dep.py COMMAND ${CMAKE_GLSL_COMPILER} -mfmt=c -x hlsl -o ${glslc_hlsl_filename} -c ${input_file} -MD COMMAND ${Python3_EXECUTABLE} - ${VulkanTestApplications_SOURCE_DIR}/cmake/generate_cmake_dep.py - ${glslc_hlsl_filename}.d + ${VulkanTestApplications_SOURCE_DIR}/cmake/generate_cmake_dep.py + ${glslc_hlsl_filename}.d COMMAND ${CMAKE_COMMAND} -E - copy_if_different - ${glslc_hlsl_filename}.d.cmake.tmp - ${glslc_hlsl_filename}.d.cmake + copy_if_different + ${glslc_hlsl_filename}.d.cmake.tmp + ${glslc_hlsl_filename}.d.cmake ) set(${result} ${glslc_hlsl_filename} PARENT_SCOPE) endfunction(compile_hlsl_using_glslc) @@ -174,26 +179,29 @@ endfunction(compile_hlsl_using_glslc) function(compile_hlsl_using_dxc shader output_file result) get_filename_component(input_file ${shader} ABSOLUTE) string(REPLACE ".hlsl." ".dxc.hlsl." dxc_hlsl_filename ${output_file}) - if (NOT CMAKE_DXC_COMPILER) + + if(NOT CMAKE_DXC_COMPILER) # Create an empty .spv file as placeholder so the C++ code compiles. file(WRITE ${dxc_hlsl_filename} "{}") else() # We currently only support fragment shaders and vertex shaders. # TODO: Set the DXC target environment for other shader kinds. - if (${shader} MATCHES ".*\\.frag") + if(${shader} MATCHES ".*\\.frag") set(DXC_TARGET_ENV "ps_6_0") elseif(${shader} MATCHES ".*\\.vert") set(DXC_TARGET_ENV "vs_6_0") endif() - add_custom_command ( - OUTPUT ${dxc_hlsl_filename} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT "Compiling HLSL to SPIR-V binary using DXC: ${shader}" - DEPENDS ${shader} ${FILE_DEPS} ${VulkanTestApplications_SOURCE_DIR}/tools/spirv_c_mfmt.py - COMMAND ${CMAKE_DXC_COMPILER} -spirv -Fo ${dxc_hlsl_filename} -E main -T ${DXC_TARGET_ENV} ${input_file} - COMMAND ${Python3_EXECUTABLE} ${VulkanTestApplications_SOURCE_DIR}/tools/spirv_c_mfmt.py ${dxc_hlsl_filename} --output-file=${dxc_hlsl_filename} - ) + + add_custom_command( + OUTPUT ${dxc_hlsl_filename} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + COMMENT "Compiling HLSL to SPIR-V binary using DXC: ${shader}" + DEPENDS ${shader} ${FILE_DEPS} ${VulkanTestApplications_SOURCE_DIR}/tools/spirv_c_mfmt.py + COMMAND ${CMAKE_DXC_COMPILER} -spirv -Fo ${dxc_hlsl_filename} -E main -T ${DXC_TARGET_ENV} ${input_file} + COMMAND ${Python3_EXECUTABLE} ${VulkanTestApplications_SOURCE_DIR}/tools/spirv_c_mfmt.py ${dxc_hlsl_filename} --output-file=${dxc_hlsl_filename} + ) endif() + set(${result} ${dxc_hlsl_filename} PARENT_SCOPE) endfunction(compile_hlsl_using_dxc) @@ -202,13 +210,13 @@ endfunction(compile_hlsl_using_dxc) # If we are building APKS, then shorten all paths # This is a marco so we can set the variable correctly in the parent scope macro(add_vulkan_subdirectory dir) - - if (NOT ANDROID OR NOT CMAKE_HOST_SYSTEM_NAME STREQUAL Windows) + if(NOT ANDROID OR NOT CMAKE_HOST_SYSTEM_NAME STREQUAL Windows) add_subdirectory(${dir}) else() - if (NOT next_sub_index) + if(NOT next_sub_index) set(next_sub_index 0) endif() + add_subdirectory(${dir} ${next_sub_index}) math(EXPR next_sub_index "${next_sub_index} + 1") endif() @@ -222,76 +230,88 @@ endmacro() function(add_vulkan_executable target) cmake_parse_arguments(EXE "NON_DEFAULT" "" "SOURCES;LIBS;SHADERS;MODELS;ADDITIONAL;TEXTURES;ADDITIONAL_INCLUDES" ${ARGN}) - if (ANDROID) + if(ANDROID) add_library(${target} SHARED ${EXE_SOURCES}) - if (EXE_LIBS) + + if(EXE_LIBS) target_link_libraries(${target} PRIVATE ${EXE_LIBS}) endif() + target_link_libraries(${target} PRIVATE entry) mathfu_configure_flags(${target}) - if (EXE_SHADERS) - foreach (shader ${EXE_SHADERS}) + + if(EXE_SHADERS) + foreach(shader ${EXE_SHADERS}) get_target_property(libdir ${shader} SHADER_LIB_DIR) target_include_directories(${target} PRIVATE ${libdir}) add_dependencies(${target} ${shader}) endforeach() - if (EXE_MODELS) - foreach (model ${EXE_MODELS}) + + if(EXE_MODELS) + foreach(model ${EXE_MODELS}) get_target_property(libdir ${model} MODEL_LIB_DIR) target_include_directories(${target} PRIVATE ${libdir}) add_dependencies(${target} ${model}) endforeach() endif() - if (EXE_TEXTURES) - foreach (texture ${EXE_TEXTURES}) + + if(EXE_TEXTURES) + foreach(texture ${EXE_TEXTURES}) get_target_property(libdir ${texture} TEXTURE_LIB_DIR) target_include_directories(${target} PRIVATE ${libdir}) add_dependencies(${target} ${texture}) endforeach() endif() endif() - elseif (NOT BUILD_APKS) + elseif(NOT BUILD_APKS) set(ADDITIONAL_ARGS) set(ADDITIONAL_ARGS2) - if (EXE_NON_DEFAULT) + + if(EXE_NON_DEFAULT) list(APPEND ADDITIONAL_ARGS EXCLUDE_FROM_ALL) endif() + add_executable(${target} ${ADDITIONAL_ARGS} ${ADDITIONAL_ARGS2} ${EXE_SOURCES} ${EXE_UNPARSED_ARGS}) setup_folders(${target}) target_include_directories(${target} PRIVATE ${VulkanTestApplications_SOURCE_DIR}) mathfu_configure_flags(${target}) - if (EXE_ADDITIONAL_INCLUDES) + + if(EXE_ADDITIONAL_INCLUDES) target_include_directories(${target} PRIVATE ${EXE_ADDITIONAL_INCLUDES}) endif() - if (EXE_LIBS) + + if(EXE_LIBS) target_link_libraries(${target} PRIVATE ${EXE_LIBS}) endif() + target_link_libraries(${target} PRIVATE entry) - if (EXE_MODELS) - foreach (model ${EXE_MODELS}) + + if(EXE_MODELS) + foreach(model ${EXE_MODELS}) get_target_property(libdir ${model} MODEL_LIB_DIR) target_include_directories(${target} PRIVATE ${libdir}) add_dependencies(${target} ${model}) endforeach() endif() - if (EXE_TEXTURES) - foreach (texture ${EXE_TEXTURES}) - get_target_property(libdir ${texture} TEXTURE_LIB_DIR) - target_include_directories(${target} PRIVATE ${libdir}) - add_dependencies(${target} ${texture}) - endforeach() + + if(EXE_TEXTURES) + foreach(texture ${EXE_TEXTURES}) + get_target_property(libdir ${texture} TEXTURE_LIB_DIR) + target_include_directories(${target} PRIVATE ${libdir}) + add_dependencies(${target} ${texture}) + endforeach() endif() - if (EXE_SHADERS) - foreach (shader ${EXE_SHADERS}) + + if(EXE_SHADERS) + foreach(shader ${EXE_SHADERS}) get_target_property(libdir ${shader} SHADER_LIB_DIR) target_include_directories(${target} PRIVATE ${libdir}) add_dependencies(${target} ${shader}) endforeach() endif() else() - set(TARGET_SOURCES) set(ANDROID_TARGET_NAME ${target}) set(${target}_SOURCES ${EXE_SOURCES}) @@ -301,7 +321,7 @@ function(add_vulkan_executable target) set(APK_BUILD_ROOT "${VulkanTestApplications_BINARY_DIR}/${target}-apk/") string(REPLACE "\",\"" " " ANDROID_ABIS_SPACES "${ANDROID_ABIS}") - if (CMAKE_BUILD_TYPE STREQUAL Debug) + if(CMAKE_BUILD_TYPE STREQUAL Debug) set(ANDROID_ADDITIONAL_PARAMS "android:debuggable=\"true\"") list(APPEND CONFIGURABLE_ANDROID_SOURCES ${VulkanTestApplications_SOURCE_DIR}/cmake/android_project_template/app/src/main/jni/Android.mk @@ -313,13 +333,14 @@ function(add_vulkan_executable target) configure_file(${source}.in ${APK_BUILD_ROOT}/${rooted_source} @ONLY) list(APPEND TARGET_SOURCES ${APK_BUILD_ROOT}/${rooted_source}) endforeach() + foreach(source ${NON_CONFIGURABLE_ANDROID_SOURCES}) file(RELATIVE_PATH rooted_source ${VulkanTestApplications_SOURCE_DIR}/cmake/android_project_template ${source}) configure_file(${source} ${APK_BUILD_ROOT}/${rooted_source} COPYONLY) list(APPEND TARGET_SOURCES ${APK_BUILD_ROOT}/${rooted_source}) endforeach() - if (CMAKE_BUILD_TYPE STREQUAL Debug) + if(CMAKE_BUILD_TYPE STREQUAL Debug) set(apk_build_location "${APK_BUILD_ROOT}/app/build/outputs/apk/debug/app-debug.apk") set(ASSEMBLE_COMMAND assembleDebug) else() @@ -331,43 +352,44 @@ function(add_vulkan_executable target) add_custom_target(${target}_sources) set(ABSOLUTE_SOURCES) + foreach(SOURCE ${EXE_SOURCES}) get_filename_component(TEMP ${SOURCE} ABSOLUTE) list(APPEND ABSOLUTE_SOURCES ${TEMP}) endforeach() + set_target_properties(${target}_sources PROPERTIES LIB_SRCS "${ABSOLUTE_SOURCES}") set_target_properties(${target}_sources PROPERTIES LIB_DEPS "${EXE_LIBS}") set_target_properties(${target}_sources PROPERTIES LIB_SHADERS "${EXE_SHADERS}") set_target_properties(${target}_sources PROPERTIES LIB_MODELS "${EXE_MODELS}") - set(SOURCE_DEPS) gather_deps(${target}_sources) gather_deps(entry) # Try not to pollute the user's root gradle directory. # Force our version of gradle to use a gradle cache directory - # that is local to this build. - + # that is local to this build. add_custom_command( OUTPUT ${target_apk} COMMAND ./gradlew --offline ${ASSEMBLE_COMMAND} --gradle-user-home - ${VulkanTestApplications_BINARY_DIR}/.gradle + ${VulkanTestApplications_BINARY_DIR}/.gradle COMMAND ${CMAKE_COMMAND} -E copy ${apk_build_location} ${target_apk} WORKING_DIRECTORY ${APK_BUILD_ROOT} DEPENDS ${SOURCE_DEPS} - ${TARGET_SOURCES} - ${MATHFU_HEADERS} - gradle_config) + ${TARGET_SOURCES} + ${MATHFU_HEADERS} + gradle_config) set(TARGET_DEP ALL) - if (EXE_NON_DEFAULT) + + if(EXE_NON_DEFAULT) set(TARGET_DEP) endif() + add_custom_target(${target} ${TARGET_DEP} DEPENDS ${target_apk}) endif() endfunction(add_vulkan_executable) - # This adds a library. By default this just plugs into # add_library. If BUILD_APKS is true then a custom target is created # and all of the sources are added to it. When an executable @@ -376,9 +398,10 @@ endfunction(add_vulkan_executable) function(_add_vulkan_library target) cmake_parse_arguments(LIB "" "TYPE" "SOURCES;LIBS;SHADERS" ${ARGN}) - if (BUILD_APKS) + if(BUILD_APKS) add_custom_target(${target}) set(ABSOLUTE_SOURCES) + foreach(SOURCE ${LIB_SOURCES}) get_filename_component(TEMP ${SOURCE} ABSOLUTE) list(APPEND ABSOLUTE_SOURCES ${TEMP}) @@ -391,8 +414,9 @@ function(_add_vulkan_library target) setup_folders(${target}) mathfu_configure_flags(${target}) target_link_libraries(${target} PRIVATE ${LIB_LIBS}) - if (EXE_SHADERS) - foreach (shader ${EXE_SHADERS}) + + if(EXE_SHADERS) + foreach(shader ${EXE_SHADERS}) get_target_property(libdir ${shader} SHADER_LIB_DIR) target_include_directories(${target} PRIVATE ${libdir}) add_dependencies(${target} ${shader}) @@ -413,17 +437,21 @@ endfunction(add_vulkan_shared_library) function(add_model_library target) cmake_parse_arguments(LIB "" "TYPE" "SOURCES" ${ARGN}) - if (BUILD_APKS) + + if(BUILD_APKS) add_custom_target(${target}) set(ABSOLUTE_SOURCES) + foreach(SOURCE ${LIB_SOURCES}) get_filename_component(TEMP ${SOURCE} ABSOLUTE) list(APPEND ABSOLUTE_SOURCES ${TEMP}) endforeach() + set_target_properties(${target} PROPERTIES LIB_SRCS "${ABSOLUTE_SOURCES}") set_target_properties(${target} PROPERTIES LIB_DEPS "") else() set(output_files) + foreach(model ${LIB_SOURCES}) get_filename_component(model ${model} ABSOLUTE) file(RELATIVE_PATH rel_pos ${CMAKE_CURRENT_SOURCE_DIR} ${model}) @@ -436,12 +464,13 @@ function(add_model_library target) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Compiling Model ${model}" DEPENDS ${model} - ${VulkanTestApplications_SOURCE_DIR}/cmake/convert_obj_to_c.py + ${VulkanTestApplications_SOURCE_DIR}/cmake/convert_obj_to_c.py COMMAND ${Python3_EXECUTABLE} - ${VulkanTestApplications_SOURCE_DIR}/cmake/convert_obj_to_c.py - ${model} -o ${output_file} + ${VulkanTestApplications_SOURCE_DIR}/cmake/convert_obj_to_c.py + ${model} -o ${output_file} ) endforeach() + add_custom_target(${target} DEPENDS ${output_files}) setup_folders(${target}) @@ -454,15 +483,19 @@ endfunction() function(add_shader_library target) cmake_parse_arguments(LIB "" "" "SOURCES;SHADER_DEPS" ${ARGN}) - if (BUILD_APKS) + + if(BUILD_APKS) add_custom_target(${target}) set(ABSOLUTE_SOURCES) + foreach(SOURCE ${LIB_SOURCES}) get_filename_component(TEMP ${SOURCE} ABSOLUTE) list(APPEND ABSOLUTE_SOURCES ${TEMP}) endforeach() + set_target_properties(${target} PROPERTIES LIB_SRCS "${ABSOLUTE_SOURCES}") - if (LIB_SHADER_DEPS) + + if(LIB_SHADER_DEPS) foreach(SHADER_DEP ${LIB_SHADER_DEPS}) get_filename_component(TEMP ${SHADER_DEP} ABSOLUTE) set_target_properties(${target} PROPERTIES LIB_DEPS "${TEMP}") @@ -472,42 +505,47 @@ function(add_shader_library target) endif() else() set(output_files) + foreach(shader ${LIB_SOURCES}) get_filename_component(suffix ${shader} EXT) - if (${suffix} MATCHES "\\.vert|\\.frag|\\.geom|\\.comp|\\.tesc|\\.tese") + + if(${suffix} MATCHES "\\.vert|\\.frag|\\.geom|\\.comp|\\.tesc|\\.tese") get_filename_component(temp ${shader} ABSOLUTE) file(RELATIVE_PATH rel_pos ${CMAKE_CURRENT_SOURCE_DIR} ${temp}) set(output_file ${CMAKE_CURRENT_BINARY_DIR}/${rel_pos}.spv) get_filename_component(output_file ${output_file} ABSOLUTE) - - if (NOT EXISTS ${output_file}.d.cmake) - execute_process( - COMMAND - ${CMAKE_COMMAND} -E copy - ${VulkanTestApplications_SOURCE_DIR}/cmake/empty_cmake_dep.in.cmake - ${output_file}.d.cmake) + if(NOT EXISTS ${output_file}.d.cmake) + execute_process( + COMMAND + ${CMAKE_COMMAND} -E copy + ${VulkanTestApplications_SOURCE_DIR}/cmake/empty_cmake_dep.in.cmake + ${output_file}.d.cmake) endif() include(${output_file}.d.cmake) set(ADDITIONAL_ARGS "") - if (LIB_SHADER_DEPS) + + if(LIB_SHADER_DEPS) foreach(DEP ${LIB_SHADER_DEPS}) if(NOT TARGET ${DEP}) message(FATAL_ERROR "Could not find dependent shader library ${DEP}") endif() + get_target_property(SRC_DIR ${DEP} SHADER_SOURCE_DIR) + if(NOT SRC_DIR) message(FATAL_ERROR "Could not get shader source dir for ${DEP}") endif() + list(APPEND ADDITIONAL_ARGS "-I${SRC_DIR}") endforeach() endif() get_filename_component(shader_name ${shader} NAME) - if (${shader_name} MATCHES ".*\\.hlsl\\..*") + if(${shader_name} MATCHES ".*\\.hlsl\\..*") # If an HLSL shader is found, compile it using glslc and DXC compile_hlsl_using_dxc(${shader} ${output_file} result) list(APPEND output_files ${result}) @@ -520,6 +558,7 @@ function(add_shader_library target) endif() endif() endforeach() + add_custom_target(${target} DEPENDS ${output_files}) setup_folders(${target}) @@ -535,17 +574,21 @@ endfunction() function(add_texture_library target) cmake_parse_arguments(LIB "" "TYPE" "SOURCES" ${ARGN}) - if (BUILD_APKS) + + if(BUILD_APKS) add_custom_target(${target}) set(ABSOLUTE_SOURCES) + foreach(SOURCE ${LIB_SOURCES}) get_filename_component(TEMP ${SOURCE} ABSOLUTE) list(APPEND ABSOLUTE_SOURCES ${TEMP}) endforeach() + set_target_properties(${target} PROPERTIES LIB_SRCS "${ABSOLUTE_SOURCES}") set_target_properties(${target} PROPERTIES LIB_DEPS "") else() set(output_files) + foreach(texture ${LIB_SOURCES}) get_filename_component(texture ${texture} ABSOLUTE) file(RELATIVE_PATH rel_pos ${CMAKE_CURRENT_SOURCE_DIR} ${texture}) @@ -558,12 +601,13 @@ function(add_texture_library target) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Compiling texture ${texture}" DEPENDS ${texture} - ${VulkanTestApplications_SOURCE_DIR}/cmake/convert_img_to_c.py + ${VulkanTestApplications_SOURCE_DIR}/cmake/convert_img_to_c.py COMMAND ${Python3_EXECUTABLE} - ${VulkanTestApplications_SOURCE_DIR}/cmake/convert_img_to_c.py - ${texture} -o ${output_file} + ${VulkanTestApplications_SOURCE_DIR}/cmake/convert_img_to_c.py + ${texture} -o ${output_file} ) endforeach() + add_custom_target(${target} DEPENDS ${output_files}) setup_folders(${target}) diff --git a/support/entry/CMakeLists.txt b/support/entry/CMakeLists.txt index 4c053579..fc1adad0 100644 --- a/support/entry/CMakeLists.txt +++ b/support/entry/CMakeLists.txt @@ -48,12 +48,12 @@ if (NOT DEFAULT_WINDOW_HEIGHT) set(DEFAULT_WINDOW_HEIGHT 100) endif() -SET(DEFAULT_WINDOW_WIDTH ${DEFAULT_WINDOW_WIDTH} CACHE INT +SET(DEFAULT_WINDOW_WIDTH "${DEFAULT_WINDOW_WIDTH}" CACHE STRING "Default window width for platforms that have resizable windows") -SET(DEFAULT_WINDOW_HEIGHT ${DEFAULT_WINDOW_HEIGHT} CACHE INT +SET(DEFAULT_WINDOW_HEIGHT "${DEFAULT_WINDOW_HEIGHT}" CACHE STRING "Default window height for platforms that have resizable windows") -SET(OUTPUT_FRAME ${OUTPUT_FRAME} CACHE INT "Default output_frame value.") +SET(OUTPUT_FRAME "${OUTPUT_FRAME}" CACHE STRING "Default output_frame value.") SET(OUTPUT_FILE ${OUTPUT_FILE} CACHE STRING "Output file for output_frame.") SET(SHADER_COMPILER ${SHADER_COMPILER} CACHE STRING "Shader language and compiler to use.") diff --git a/third_party/vk_callback_swapchain b/third_party/vk_callback_swapchain index 29586b1b..005603bf 160000 --- a/third_party/vk_callback_swapchain +++ b/third_party/vk_callback_swapchain @@ -1 +1 @@ -Subproject commit 29586b1b2a5124451fa758f662b039fd50070428 +Subproject commit 005603bf65680cc05e77b003548876dcb4858809 diff --git a/vulkan_helpers/vulkan_application.cpp b/vulkan_helpers/vulkan_application.cpp index 2b769db8..fce5db64 100644 --- a/vulkan_helpers/vulkan_application.cpp +++ b/vulkan_helpers/vulkan_application.cpp @@ -485,7 +485,8 @@ VulkanApplication::CreateAndBindImage(const VkImageCreateInfo* create_info, // Otherwise we default to every GPU getting their own allocation if (device_indices == nullptr) { device_indices = &indices[0]; - for (size_t i = 0; i < device_.num_devices(); ++i) { + for (uint32_t i = 0; i < static_cast(device_.num_devices()); + ++i) { indices[i] = i; } } @@ -706,7 +707,8 @@ VulkanApplication::CreateAndBindBuffer(VulkanArena* heap, // Otherwise we default to every GPU getting their own allocation if (device_indices == nullptr) { device_indices = &indices[0]; - for (size_t i = 0; i < device_.num_devices(); ++i) { + for (uint32_t i = 0; i < static_cast(device_.num_devices()); + ++i) { indices[i] = i; } } @@ -901,7 +903,7 @@ VulkanApplication::FillImageLayersData( nullptr, }; BufferPointer src_buffer = CreateAndBindHostBuffer(&buf_create_info); - std::copy_n(data.begin(), data.size(), src_buffer->base_address()); + memcpy(src_buffer->base_address(), data.data(), data.size()); src_buffer->flush(); // Get a command buffer and add commands/barriers to it. diff --git a/vulkan_helpers/vulkan_texture.h b/vulkan_helpers/vulkan_texture.h index 9fccf717..87e30af8 100644 --- a/vulkan_helpers/vulkan_texture.h +++ b/vulkan_helpers/vulkan_texture.h @@ -16,13 +16,13 @@ #ifndef VULKAN_HELPERS_VULKAN_TEXTURE_H_ #define VULKAN_HELPERS_VULKAN_TEXTURE_H_ +#include + #include "support/containers/allocator.h" #include "support/containers/vector.h" #include "support/log/log.h" #include "vulkan_helpers/vulkan_application.h" -#include - namespace vulkan { // TODO(awoloszyn): Handle MIP chains. // TODO(awoloszyn): Handle Arrays. @@ -58,8 +58,7 @@ struct VulkanTexture { VulkanTexture(containers::Allocator* allocator, logging::Logger* logger, const T& t, size_t sparse_binding_block_size = 0u, size_t multiplanar_plane_count = 0u, - size_t downsampled_width = 0u, - size_t downsampled_height = 0u) + size_t downsampled_width = 0u, size_t downsampled_height = 0u) : VulkanTexture(allocator, logger, t.format, t.width, t.height, static_cast(t.data), sizeof(t.data), sparse_binding_block_size, multiplanar_plane_count, @@ -75,8 +74,7 @@ struct VulkanTexture { void InitializeData(vulkan::VulkanApplication* application, vulkan::VkCommandBuffer* cmdBuffer, VkImageUsageFlags usage = VK_IMAGE_USAGE_SAMPLED_BIT, - VkImageCreateFlags flags = 0, - void* pNext = nullptr) { + VkImageCreateFlags flags = 0, void* pNext = nullptr) { VkBufferCreateInfo create_info = { VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO, // sType nullptr, // pNext @@ -112,8 +110,8 @@ struct VulkanTexture { if (sparse_binding_block_size_ > 0u) { image_create_info.flags = image_create_info.flags | VK_IMAGE_CREATE_SPARSE_BINDING_BIT; - sparse_image_ = application->CreateAndBindSparseImage(&image_create_info, - sparse_binding_block_size_); + sparse_image_ = application->CreateAndBindSparseImage( + &image_create_info, sparse_binding_block_size_); } else if (IsFormatMultiplanar(format_)) { VkSamplerYcbcrConversionImageFormatProperties ycbcr_conversion_properties{ VK_STRUCTURE_TYPE_SAMPLER_YCBCR_CONVERSION_IMAGE_FORMAT_PROPERTIES_KHR, @@ -148,8 +146,7 @@ struct VulkanTexture { image_create_info.pNext = &ycbcr_conversion_properties; image_ = application->CreateAndBindMultiPlanarImage(&image_create_info); - } - else { + } else { image_ = application->CreateAndBindImage(&image_create_info); } @@ -234,9 +231,10 @@ struct VulkanTexture { }; (*cmdBuffer) - ->vkCmdCopyBufferToImage(*cmdBuffer, *upload_buffer_, image(), - VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, - multiplanar_plane_count_, copy_params); + ->vkCmdCopyBufferToImage( + *cmdBuffer, *upload_buffer_, image(), + VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, + static_cast(multiplanar_plane_count_), copy_params); } else { VkBufferImageCopy copy_params = { 0, // bufferOffset