Port UI icon textures from OpenGL to Vulkan, fix loading screen clear values

Replace all glGenTextures/glTexImage2D calls in UI code with Vulkan texture
uploads via new VkContext::uploadImGuiTexture() helper. This fixes segfaults
from calling OpenGL functions without a GL context (null GLEW function pointers).

- Add uploadImGuiTexture() to VkContext with staging buffer upload pattern
- Convert game_screen, inventory_screen, spellbook_screen, talent_screen
  from GLuint/GL calls to VkDescriptorSet/Vulkan uploads
- Fix loading_screen clearValueCount (was 1, needs 2 or 3 for MSAA)
This commit is contained in:
Kelsi 2026-02-22 03:32:08 -08:00
parent b1a9d231c7
commit 325254dfcb
11 changed files with 314 additions and 136 deletions

View file

@ -76,6 +76,12 @@ public:
void setMsaaSamples(VkSampleCountFlagBits samples);
VkSampleCountFlagBits getMaxUsableSampleCount() const;
// UI texture upload: creates a Vulkan texture from RGBA data and returns
// a VkDescriptorSet suitable for use as ImTextureID.
// The caller does NOT need to free the result — resources are tracked and
// cleaned up when the VkContext is destroyed.
VkDescriptorSet uploadImGuiTexture(const uint8_t* rgba, int width, int height);
private:
bool createInstance(SDL_Window* window);
bool createSurface(SDL_Window* window);
@ -144,6 +150,17 @@ private:
VkRenderPass imguiRenderPass = VK_NULL_HANDLE;
VkDescriptorPool imguiDescriptorPool = VK_NULL_HANDLE;
// Shared sampler for UI textures (created on first uploadImGuiTexture call)
VkSampler uiTextureSampler_ = VK_NULL_HANDLE;
// Tracked UI textures for cleanup
struct UiTexture {
VkImage image;
VkDeviceMemory memory;
VkImageView view;
};
std::vector<UiTexture> uiTextures_;
#ifndef NDEBUG
bool enableValidation = true;
#else