fix wrong ppm RGB

main-headless
ink-soul 2024-04-16 13:23:41 +08:00
parent 3d7ff22ec3
commit 57e8516d0c
4 changed files with 15 additions and 11 deletions

View File

@ -174,7 +174,7 @@ public:
VkPipelineMultisampleStateCreateInfo multisampleStateCI{}; VkPipelineMultisampleStateCreateInfo multisampleStateCI{};
multisampleStateCI.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; 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; multisampleStateCI.rasterizationSamples = multiSampleCount;
} }

View File

@ -1662,7 +1662,7 @@ void VulkanExampleBase::setupFrameBuffer()
/* /*
MSAA MSAA
*/ */
VkFormat colorFormat = VK_FORMAT_B8G8R8A8_SRGB;
if (settings.multiSampling) { if (settings.multiSampling) {
// Check if device supports requested sample count for color and depth frame buffer // Check if device supports requested sample count for color and depth frame buffer
//assert((deviceProperties.limits.framebufferColorSampleCounts >= sampleCount) && (deviceProperties.limits.framebufferDepthSampleCounts >= sampleCount)); //assert((deviceProperties.limits.framebufferColorSampleCounts >= sampleCount) && (deviceProperties.limits.framebufferDepthSampleCounts >= sampleCount));

View File

@ -112,7 +112,7 @@ public:
bool paused = false; bool paused = false;
uint32_t lastFPS = 0; uint32_t lastFPS = 0;
VkFormat colorFormat = VK_FORMAT_B8G8R8A8_SRGB; VkFormat colorFormat = VK_FORMAT_R8G8B8A8_SRGB;
struct Signal struct Signal
{ {

View File

@ -1644,13 +1644,13 @@ PlumageRender::PlumageRender()
} }
// Source for the copy is the last rendered swapchain image // 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 // Create the linear tiled destination image to copy to and to read the memory from
VkImageCreateInfo imageCreateCI(vks::initializers::imageCreateInfo()); VkImageCreateInfo imageCreateCI(vks::initializers::imageCreateInfo());
imageCreateCI.imageType = VK_IMAGE_TYPE_2D; imageCreateCI.imageType = VK_IMAGE_TYPE_2D;
// Note that vkCmdBlitImage (if supported) will also do format conversions if the swapchain color format would differ // 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.width = width;
imageCreateCI.extent.height = height; imageCreateCI.extent.height = height;
imageCreateCI.extent.depth = 1; 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 // Note: Not complete, only contains most common and basic BGR surface formats for demonstration purposes
if (!supportsBlit) if (!supportsBlit)
{ {
std::vector<VkFormat> formatsBGR = { VK_FORMAT_B8G8R8A8_SRGB, VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B8G8R8A8_SNORM }; std::vector<VkFormat> formatsBGR = { VK_FORMAT_B8G8R8A8_SRGB, VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B8G8R8A8_SNORM,
colorSwizzle = (std::find(formatsBGR.begin(), formatsBGR.end(), swapChain.colorFormat) != formatsBGR.end()); 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 // ppm binary pixel data
for (uint32_t y = 0; y < height; y++) for (uint32_t y = 0; y < height; y++)
{ {
@ -1812,9 +1814,11 @@ PlumageRender::PlumageRender()
{ {
if (colorSwizzle) if (colorSwizzle)
{ {
file.write((char*)row + 2, 1); file.write((char*)row + 2, 1); // R
file.write((char*)row + 1, 1); file.write((char*)row + 1, 1);// G
file.write((char*)row, 1); //std::cout << row << std::endl;
file.write((char*)row, 1);// B
} }
else else
{ {