From 7f5a81c47fb84d3696c5aaffd3d4a630d225bf75 Mon Sep 17 00:00:00 2001 From: Nicolas Adenis-Lamarre Date: Thu, 16 Dec 2021 12:37:41 +0000 Subject: [PATCH] convert textures to rgba for vulkan Signed-off-by: Nicolas Adenis-Lamarre --- src/overlay.frag | 2 +- src/vulkan.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/overlay.frag b/src/overlay.frag index dc6bb007d88..313a8880410 100644 --- a/src/overlay.frag +++ b/src/overlay.frag @@ -10,5 +10,5 @@ layout(location = 0) in struct{ void main() { - fColor = In.Color * vec4(1, 1, 1, texture(sTexture, In.UV.st).r); + fColor = In.Color * texture(sTexture, In.UV.st); } diff --git a/src/vulkan.cpp b/src/vulkan.cpp index 42142222cb1..48855b279ab 100644 --- a/src/vulkan.cpp +++ b/src/vulkan.cpp @@ -685,16 +685,16 @@ static void check_fonts(struct swapchain_data* data) create_fonts(instance_data->params, data->sw_stats.font1, data->sw_stats.font_text); unsigned char* pixels; int width, height; - io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height); + io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); // wait for rendering to complete, if any device_data->vtable.DeviceWaitIdle(device_data->device); shutdown_swapchain_font(data); if (desc_set) - create_image(data, desc_set, width, height, VK_FORMAT_R8_UNORM, data->font_image, data->font_mem, data->font_image_view); + create_image(data, desc_set, width, height, VK_FORMAT_R8G8B8A8_SRGB, data->font_image, data->font_mem, data->font_image_view); else - desc_set = create_image_with_desc(data, width, height, VK_FORMAT_R8_UNORM, data->font_image, data->font_mem, data->font_image_view); + desc_set = create_image_with_desc(data, width, height, VK_FORMAT_R8G8B8A8_SRGB, data->font_image, data->font_mem, data->font_image_view); io.Fonts->SetTexID((ImTextureID)desc_set); data->font_uploaded = false; @@ -717,8 +717,8 @@ static void ensure_swapchain_fonts(struct swapchain_data *data, ImGuiIO& io = ImGui::GetIO(); unsigned char* pixels; int width, height; - io.Fonts->GetTexDataAsAlpha8(&pixels, &width, &height); - size_t upload_size = width * height * 1 * sizeof(char); + io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height); + size_t upload_size = width * height * 4 * sizeof(char); upload_image_data(device_data, command_buffer, pixels, upload_size, width, height, data->upload_font_buffer, data->upload_font_buffer_mem, data->font_image); }