From 31656311d3e5ba3c4aef3f8e40e92427438443e3 Mon Sep 17 00:00:00 2001 From: JackP Date: Wed, 1 Oct 2025 20:02:36 -0700 Subject: [PATCH] Fix compile error caused by trying to assign a value of type vk::ClearColorValue to a variable on type vk::ClearValue. The correct action is to assign the vk::ClearColorValue value to the .color member of the vk::ClearValue variable --- attachments/14_command_buffers.cpp | 2 +- attachments/15_hello_triangle.cpp | 2 +- attachments/16_frames_in_flight.cpp | 2 +- attachments/17_swap_chain_recreation.cpp | 2 +- attachments/18_vertex_input.cpp | 2 +- attachments/19_vertex_buffer.cpp | 2 +- attachments/20_staging_buffer.cpp | 2 +- attachments/21_index_buffer.cpp | 2 +- attachments/22_descriptor_layout.cpp | 2 +- attachments/23_descriptor_sets.cpp | 2 +- attachments/24_texture_image.cpp | 2 +- attachments/25_sampler.cpp | 2 +- attachments/26_texture_mapping.cpp | 2 +- attachments/27_depth_buffering.cpp | 2 +- attachments/28_model_loading.cpp | 2 +- attachments/29_mipmapping.cpp | 2 +- attachments/30_multisampling.cpp | 2 +- attachments/31_compute_shader.cpp | 2 +- attachments/32_ecosystem_utilities.cpp | 2 +- attachments/35_gltf_ktx.cpp | 2 +- attachments/36_multiple_objects.cpp | 2 +- attachments/37_multithreading.cpp | 2 +- attachments/38_ray_tracing.cpp | 2 +- en/03_Drawing_a_triangle/03_Drawing/00_Framebuffers.adoc | 2 +- en/03_Drawing_a_triangle/03_Drawing/01_Command_buffers.adoc | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/attachments/14_command_buffers.cpp b/attachments/14_command_buffers.cpp index 864edec0..ff8e80a9 100644 --- a/attachments/14_command_buffers.cpp +++ b/attachments/14_command_buffers.cpp @@ -365,7 +365,7 @@ class HelloTriangleApplication { vk::PipelineStageFlagBits2::eTopOfPipe, // srcStage vk::PipelineStageFlagBits2::eColorAttachmentOutput // dstStage ); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::RenderingAttachmentInfo attachmentInfo = { .imageView = swapChainImageViews[imageIndex], .imageLayout = vk::ImageLayout::eColorAttachmentOptimal, diff --git a/attachments/15_hello_triangle.cpp b/attachments/15_hello_triangle.cpp index 2e9ebb60..f762560c 100644 --- a/attachments/15_hello_triangle.cpp +++ b/attachments/15_hello_triangle.cpp @@ -375,7 +375,7 @@ class HelloTriangleApplication { vk::PipelineStageFlagBits2::eTopOfPipe, // srcStage vk::PipelineStageFlagBits2::eColorAttachmentOutput // dstStage ); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::RenderingAttachmentInfo attachmentInfo = { .imageView = swapChainImageViews[imageIndex], .imageLayout = vk::ImageLayout::eColorAttachmentOptimal, diff --git a/attachments/16_frames_in_flight.cpp b/attachments/16_frames_in_flight.cpp index 2c129802..1dbb2a19 100644 --- a/attachments/16_frames_in_flight.cpp +++ b/attachments/16_frames_in_flight.cpp @@ -379,7 +379,7 @@ class HelloTriangleApplication { vk::PipelineStageFlagBits2::eTopOfPipe, // srcStage vk::PipelineStageFlagBits2::eColorAttachmentOutput // dstStage ); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::RenderingAttachmentInfo attachmentInfo = { .imageView = swapChainImageViews[imageIndex], .imageLayout = vk::ImageLayout::eColorAttachmentOptimal, diff --git a/attachments/17_swap_chain_recreation.cpp b/attachments/17_swap_chain_recreation.cpp index 7fc4ef75..9291c9d6 100644 --- a/attachments/17_swap_chain_recreation.cpp +++ b/attachments/17_swap_chain_recreation.cpp @@ -407,7 +407,7 @@ class HelloTriangleApplication { vk::PipelineStageFlagBits2::eTopOfPipe, // srcStage vk::PipelineStageFlagBits2::eColorAttachmentOutput // dstStage ); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::RenderingAttachmentInfo attachmentInfo = { .imageView = swapChainImageViews[imageIndex], .imageLayout = vk::ImageLayout::eColorAttachmentOptimal, diff --git a/attachments/18_vertex_input.cpp b/attachments/18_vertex_input.cpp index 010059b4..0b37298d 100644 --- a/attachments/18_vertex_input.cpp +++ b/attachments/18_vertex_input.cpp @@ -424,7 +424,7 @@ class HelloTriangleApplication { vk::PipelineStageFlagBits2::eTopOfPipe, // srcStage vk::PipelineStageFlagBits2::eColorAttachmentOutput // dstStage ); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::RenderingAttachmentInfo attachmentInfo = { .imageView = swapChainImageViews[imageIndex], .imageLayout = vk::ImageLayout::eColorAttachmentOptimal, diff --git a/attachments/19_vertex_buffer.cpp b/attachments/19_vertex_buffer.cpp index d50a5e0c..19b1f9ee 100644 --- a/attachments/19_vertex_buffer.cpp +++ b/attachments/19_vertex_buffer.cpp @@ -455,7 +455,7 @@ class HelloTriangleApplication { vk::PipelineStageFlagBits2::eTopOfPipe, // srcStage vk::PipelineStageFlagBits2::eColorAttachmentOutput // dstStage ); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::RenderingAttachmentInfo attachmentInfo = { .imageView = swapChainImageViews[imageIndex], .imageLayout = vk::ImageLayout::eColorAttachmentOptimal, diff --git a/attachments/20_staging_buffer.cpp b/attachments/20_staging_buffer.cpp index 2b056975..a563c059 100644 --- a/attachments/20_staging_buffer.cpp +++ b/attachments/20_staging_buffer.cpp @@ -474,7 +474,7 @@ class HelloTriangleApplication { vk::PipelineStageFlagBits2::eTopOfPipe, // srcStage vk::PipelineStageFlagBits2::eColorAttachmentOutput // dstStage ); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::RenderingAttachmentInfo attachmentInfo = { .imageView = swapChainImageViews[imageIndex], .imageLayout = vk::ImageLayout::eColorAttachmentOptimal, diff --git a/attachments/21_index_buffer.cpp b/attachments/21_index_buffer.cpp index d727fce9..e9a8ad96 100644 --- a/attachments/21_index_buffer.cpp +++ b/attachments/21_index_buffer.cpp @@ -498,7 +498,7 @@ class HelloTriangleApplication { vk::PipelineStageFlagBits2::eTopOfPipe, // srcStage vk::PipelineStageFlagBits2::eColorAttachmentOutput // dstStage ); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::RenderingAttachmentInfo attachmentInfo = { .imageView = swapChainImageViews[imageIndex], .imageLayout = vk::ImageLayout::eColorAttachmentOptimal, diff --git a/attachments/22_descriptor_layout.cpp b/attachments/22_descriptor_layout.cpp index 4addf1ec..4a3e6b04 100644 --- a/attachments/22_descriptor_layout.cpp +++ b/attachments/22_descriptor_layout.cpp @@ -537,7 +537,7 @@ class HelloTriangleApplication { vk::PipelineStageFlagBits2::eTopOfPipe, // srcStage vk::PipelineStageFlagBits2::eColorAttachmentOutput // dstStage ); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::RenderingAttachmentInfo attachmentInfo = { .imageView = swapChainImageViews[imageIndex], .imageLayout = vk::ImageLayout::eColorAttachmentOptimal, diff --git a/attachments/23_descriptor_sets.cpp b/attachments/23_descriptor_sets.cpp index ed2839b4..5342be60 100644 --- a/attachments/23_descriptor_sets.cpp +++ b/attachments/23_descriptor_sets.cpp @@ -561,7 +561,7 @@ class HelloTriangleApplication { vk::PipelineStageFlagBits2::eTopOfPipe, // srcStage vk::PipelineStageFlagBits2::eColorAttachmentOutput // dstStage ); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::RenderingAttachmentInfo attachmentInfo = { .imageView = swapChainImageViews[imageIndex], .imageLayout = vk::ImageLayout::eColorAttachmentOptimal, diff --git a/attachments/24_texture_image.cpp b/attachments/24_texture_image.cpp index 9773cceb..2c77e661 100644 --- a/attachments/24_texture_image.cpp +++ b/attachments/24_texture_image.cpp @@ -665,7 +665,7 @@ class HelloTriangleApplication { vk::PipelineStageFlagBits2::eTopOfPipe, // srcStage vk::PipelineStageFlagBits2::eColorAttachmentOutput // dstStage ); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::RenderingAttachmentInfo attachmentInfo = { .imageView = swapChainImageViews[imageIndex], .imageLayout = vk::ImageLayout::eColorAttachmentOptimal, diff --git a/attachments/25_sampler.cpp b/attachments/25_sampler.cpp index b2571173..81e3c27e 100644 --- a/attachments/25_sampler.cpp +++ b/attachments/25_sampler.cpp @@ -700,7 +700,7 @@ class HelloTriangleApplication { vk::PipelineStageFlagBits2::eTopOfPipe, // srcStage vk::PipelineStageFlagBits2::eColorAttachmentOutput // dstStage ); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::RenderingAttachmentInfo attachmentInfo = { .imageView = swapChainImageViews[imageIndex], .imageLayout = vk::ImageLayout::eColorAttachmentOptimal, diff --git a/attachments/26_texture_mapping.cpp b/attachments/26_texture_mapping.cpp index 30cda574..37adf1b6 100644 --- a/attachments/26_texture_mapping.cpp +++ b/attachments/26_texture_mapping.cpp @@ -777,7 +777,7 @@ class HelloTriangleApplication { vk::PipelineStageFlagBits2::eTopOfPipe, // srcStage vk::PipelineStageFlagBits2::eColorAttachmentOutput // dstStage ); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::RenderingAttachmentInfo attachmentInfo = { .imageView = swapChainImageViews[imageIndex], .imageLayout = vk::ImageLayout::eColorAttachmentOptimal, diff --git a/attachments/27_depth_buffering.cpp b/attachments/27_depth_buffering.cpp index ebb596a6..513b6311 100644 --- a/attachments/27_depth_buffering.cpp +++ b/attachments/27_depth_buffering.cpp @@ -893,7 +893,7 @@ class HelloTriangleApplication { }; commandBuffers[currentFrame].pipelineBarrier2(depthDependencyInfo); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::ClearValue clearDepth = vk::ClearDepthStencilValue(1.0f, 0); vk::RenderingAttachmentInfo colorAttachmentInfo = { diff --git a/attachments/28_model_loading.cpp b/attachments/28_model_loading.cpp index 5c72ab66..19725974 100644 --- a/attachments/28_model_loading.cpp +++ b/attachments/28_model_loading.cpp @@ -938,7 +938,7 @@ class HelloTriangleApplication { }; commandBuffers[currentFrame].pipelineBarrier2(depthDependencyInfo); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::ClearValue clearDepth = vk::ClearDepthStencilValue(1.0f, 0); vk::RenderingAttachmentInfo colorAttachmentInfo = { diff --git a/attachments/29_mipmapping.cpp b/attachments/29_mipmapping.cpp index 4a0455f0..9042c6be 100644 --- a/attachments/29_mipmapping.cpp +++ b/attachments/29_mipmapping.cpp @@ -1004,7 +1004,7 @@ class HelloTriangleApplication { }; commandBuffers[currentFrame].pipelineBarrier2(depthDependencyInfo); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::ClearValue clearDepth = vk::ClearDepthStencilValue(1.0f, 0); vk::RenderingAttachmentInfo colorAttachmentInfo = { diff --git a/attachments/30_multisampling.cpp b/attachments/30_multisampling.cpp index bd5a4d06..41962dcb 100644 --- a/attachments/30_multisampling.cpp +++ b/attachments/30_multisampling.cpp @@ -1033,7 +1033,7 @@ class HelloTriangleApplication { vk::PipelineStageFlagBits2::eEarlyFragmentTests, vk::ImageAspectFlagBits::eDepth ); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::ClearValue clearDepth = vk::ClearDepthStencilValue(1.0f, 0); // Color attachment (multisampled) with resolve attachment diff --git a/attachments/31_compute_shader.cpp b/attachments/31_compute_shader.cpp index e2ef808a..5d5bc75b 100644 --- a/attachments/31_compute_shader.cpp +++ b/attachments/31_compute_shader.cpp @@ -682,7 +682,7 @@ class ComputeShaderApplication { vk::PipelineStageFlagBits2::eTopOfPipe, // srcStage vk::PipelineStageFlagBits2::eColorAttachmentOutput // dstStage ); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::RenderingAttachmentInfo attachmentInfo = { .imageView = swapChainImageViews[imageIndex], .imageLayout = vk::ImageLayout::eColorAttachmentOptimal, diff --git a/attachments/32_ecosystem_utilities.cpp b/attachments/32_ecosystem_utilities.cpp index ce1747e1..d3c7d285 100644 --- a/attachments/32_ecosystem_utilities.cpp +++ b/attachments/32_ecosystem_utilities.cpp @@ -1270,7 +1270,7 @@ class HelloTriangleApplication { void recordCommandBuffer(uint32_t imageIndex) { commandBuffers[currentFrame].begin({}); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::ClearValue clearDepth = vk::ClearDepthStencilValue(1.0f, 0); std::array clearValues = { clearColor, clearDepth }; diff --git a/attachments/35_gltf_ktx.cpp b/attachments/35_gltf_ktx.cpp index b24c5b8c..5909775c 100644 --- a/attachments/35_gltf_ktx.cpp +++ b/attachments/35_gltf_ktx.cpp @@ -1215,7 +1215,7 @@ class VulkanApplication { }; commandBuffers[currentFrame].pipelineBarrier2(depthDependencyInfo); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::RenderingAttachmentInfo attachmentInfo = { .imageView = *swapChainImageViews[imageIndex], .imageLayout = vk::ImageLayout::eColorAttachmentOptimal, diff --git a/attachments/36_multiple_objects.cpp b/attachments/36_multiple_objects.cpp index dc1ae802..9b5bc292 100644 --- a/attachments/36_multiple_objects.cpp +++ b/attachments/36_multiple_objects.cpp @@ -1304,7 +1304,7 @@ class VulkanApplication { }; commandBuffers[currentFrame].pipelineBarrier2(depthDependencyInfo); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::RenderingAttachmentInfo attachmentInfo = { .imageView = *swapChainImageViews[imageIndex], .imageLayout = vk::ImageLayout::eColorAttachmentOptimal, diff --git a/attachments/37_multithreading.cpp b/attachments/37_multithreading.cpp index 49f1720a..fafc2904 100644 --- a/attachments/37_multithreading.cpp +++ b/attachments/37_multithreading.cpp @@ -933,7 +933,7 @@ class MultithreadedApplication { vk::PipelineStageFlagBits2::eColorAttachmentOutput ); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::RenderingAttachmentInfo attachmentInfo = { .imageView = swapChainImageViews[imageIndex], .imageLayout = vk::ImageLayout::eColorAttachmentOptimal, diff --git a/attachments/38_ray_tracing.cpp b/attachments/38_ray_tracing.cpp index 0c4b6f3e..bf14a22c 100644 --- a/attachments/38_ray_tracing.cpp +++ b/attachments/38_ray_tracing.cpp @@ -1599,7 +1599,7 @@ class HelloTriangleApplication { }; commandBuffers[currentFrame].pipelineBarrier2(depthDependencyInfo); - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::ClearValue clearDepth = vk::ClearDepthStencilValue(1.0f, 0); /* TASK01: Check the setup for dynamic rendering diff --git a/en/03_Drawing_a_triangle/03_Drawing/00_Framebuffers.adoc b/en/03_Drawing_a_triangle/03_Drawing/00_Framebuffers.adoc index 2edcdd07..088b91f2 100644 --- a/en/03_Drawing_a_triangle/03_Drawing/00_Framebuffers.adoc +++ b/en/03_Drawing_a_triangle/03_Drawing/00_Framebuffers.adoc @@ -36,7 +36,7 @@ void recordCommandBuffer(uint32_t imageIndex) { ); // Set up the color attachment - vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); + vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::RenderingAttachmentInfo attachmentInfo = { .imageView = swapChainImageViews[imageIndex], .imageLayout = vk::ImageLayout::eColorAttachmentOptimal, diff --git a/en/03_Drawing_a_triangle/03_Drawing/01_Command_buffers.adoc b/en/03_Drawing_a_triangle/03_Drawing/01_Command_buffers.adoc index 8007e17f..4f625250 100644 --- a/en/03_Drawing_a_triangle/03_Drawing/01_Command_buffers.adoc +++ b/en/03_Drawing_a_triangle/03_Drawing/01_Command_buffers.adoc @@ -227,7 +227,7 @@ First, we transition the image layout to `VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIM [,c++] ---- -vk::ClearValue clearColor = vk::ClearColorValue(0.0f, 0.0f, 0.0f, 1.0f); +vk::ClearValue clearColor = { .color = vk::ClearColorValue{ std::array {0.0f, 0.0f, 0.0f, 1.0f} } }; vk::RenderingAttachmentInfo attachmentInfo = { .imageView = swapChainImageViews[imageIndex], .imageLayout = vk::ImageLayout::eColorAttachmentOptimal,