diff --git a/base/ui.hpp b/base/ui.hpp index fe4340c..7cbbd48 100644 --- a/base/ui.hpp +++ b/base/ui.hpp @@ -174,7 +174,7 @@ public: VkPipelineMultisampleStateCreateInfo multisampleStateCI{}; multisampleStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; - if (multiSampleCount > VK_SAMPLE_COUNT_1_BIT) { + if (multiSampleCount >= VK_SAMPLE_COUNT_1_BIT) { multisampleStateCI.rasterizationSamples = multiSampleCount; } diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index 15711e4..b724e79 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -1662,7 +1662,7 @@ void VulkanExampleBase::setupFrameBuffer() /* MSAA */ - VkFormat colorFormat = VK_FORMAT_B8G8R8A8_SRGB; + if (settings.multiSampling) { // Check if device supports requested sample count for color and depth frame buffer //assert((deviceProperties.limits.framebufferColorSampleCounts >= sampleCount) && (deviceProperties.limits.framebufferDepthSampleCounts >= sampleCount)); diff --git a/base/vulkanexamplebase.h b/base/vulkanexamplebase.h index 38a1d17..b903434 100644 --- a/base/vulkanexamplebase.h +++ b/base/vulkanexamplebase.h @@ -112,7 +112,7 @@ public: bool paused = false; uint32_t lastFPS = 0; - VkFormat colorFormat = VK_FORMAT_B8G8R8A8_SRGB; + VkFormat colorFormat = VK_FORMAT_R8G8B8A8_SRGB; struct Signal { diff --git a/src/render/render.cpp b/src/render/render.cpp index bfbc0d1..e9c0f13 100644 --- a/src/render/render.cpp +++ b/src/render/render.cpp @@ -1644,13 +1644,13 @@ PlumageRender::PlumageRender() } // Source for the copy is the last rendered swapchain image - VkImage srcImage = swapChain.images[currentBuffer]; - + //VkImage srcImage = swapChain.images[currentBuffer]; + VkImage srcImage = colorAttachment.image; // Create the linear tiled destination image to copy to and to read the memory from VkImageCreateInfo imageCreateCI(vks::initializers::imageCreateInfo()); imageCreateCI.imageType = VK_IMAGE_TYPE_2D; // Note that vkCmdBlitImage (if supported) will also do format conversions if the swapchain color format would differ - imageCreateCI.format = VK_FORMAT_R8G8B8A8_UNORM; + imageCreateCI.format = colorFormat; imageCreateCI.extent.width = width; imageCreateCI.extent.height = height; imageCreateCI.extent.depth = 1; @@ -1801,9 +1801,11 @@ PlumageRender::PlumageRender() // Note: Not complete, only contains most common and basic BGR surface formats for demonstration purposes if (!supportsBlit) { - std::vector formatsBGR = { VK_FORMAT_B8G8R8A8_SRGB, VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B8G8R8A8_SNORM }; - colorSwizzle = (std::find(formatsBGR.begin(), formatsBGR.end(), swapChain.colorFormat) != formatsBGR.end()); + std::vector formatsBGR = { VK_FORMAT_B8G8R8A8_SRGB, VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B8G8R8A8_SNORM, + VK_FORMAT_B8G8R8_SRGB, VK_FORMAT_B8G8R8_UNORM, VK_FORMAT_B8G8R8_SNORM }; + colorSwizzle = (std::find(formatsBGR.begin(), formatsBGR.end(), colorFormat) != formatsBGR.end()); } + // ppm binary pixel data for (uint32_t y = 0; y < height; y++) { @@ -1812,9 +1814,11 @@ PlumageRender::PlumageRender() { if (colorSwizzle) { - file.write((char*)row + 2, 1); - file.write((char*)row + 1, 1); - file.write((char*)row, 1); + file.write((char*)row + 2, 1); // R + file.write((char*)row + 1, 1);// G + //std::cout << row << std::endl; + file.write((char*)row, 1);// B + } else {