SDL Vulkan(MoltenVK) Blank Screen

Hi all, I recently tried to switch from GLFW to SDL for my game engine. I managed to get everything compiling, but for some reason the screen is pink. I get no errors (from SDL or vulkan) and the game is running in the background according to print statements, but the screen is just pink. I have tried everything I can think of to fix this and nothing is working. Here are all of the places where I’m using SDL.

Window::Window(unsigned int width, unsigned int height, std::string &title)
        Logger::LogString("Failed to init SDL");
        Logger::LogString("SDL Initialized!");

    uint32_t flags = 0;

    SDL_DisplayMode displayMode;
    SDL_GetCurrentDisplayMode(0, &displayMode);

    mWidth = width;
    mHeight = height;

    mWindow = SDL_CreateWindow(title.c_str(), 0, 0, mWidth, mHeight, flags);

    if(mWindow == NULL)
        Logger::LogString("Failed to create window!");
      Logger::LogString("Successfully created window!");

void VulkanRenderer::CreateSurface()
    if (SDL_Vulkan_CreateSurface(mWindow->GetSDLWindow(), mInstance, &mSurface) != SDL_TRUE)
        throw std::runtime_error("failed to create window surface!");

    Logger::LogString("Created the surface");

std::vector<const char*> VulkanRenderer::GetRequiredExtensions() 
    uint32_t sdlExtensionCount = 0;
    SDL_Vulkan_GetInstanceExtensions(mWindow->GetSDLWindow() ,&sdlExtensionCount, nullptr);
    std::vector<const char *> extensions;
    if (mEnableValidationLayers)
    int additionalExtensions = extensions.size();
    extensions.resize(additionalExtensions + sdlExtensionCount);
    SDL_Vulkan_GetInstanceExtensions(mWindow->GetSDLWindow() ,&sdlExtensionCount, + additionalExtensions);

    return extensions;

PFN_vkCreateDebugReportCallbackEXT SDL2_vkCreateDebugReportCallbackEXT = nullptr;
void VulkanRenderer::CreateDebug()
    SDL2_vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)SDL_Vulkan_GetVkGetInstanceProcAddr();

    VkDebugReportCallbackCreateInfoEXT debugCallbackCreateInfo = {};
    debugCallbackCreateInfo.pfnCallback = VulkanReportFunc;

    SDL2_vkCreateDebugReportCallbackEXT(mInstance, &debugCallbackCreateInfo, 0, &debugCallback);

This is what the window looks like.

I was wondering if there was some kind of SDL function that I needed to call to update the window, but when I added a call to SDL_UpdateWindowSurface() I got an error that the surface was invalid. I’m not sure if this means that function doesn’t apply to the type of surface I created, or if the surface was somehow created wrong.

When I try to run on windows the screen is black, on macOS the screen is pink.

Any help is greatly appreciated!

You definitely don’t need to be calling SDL_UpdateWindowSurface(), as that’s only valid if you’re using SDL’s software 2D drawing (which you aren’t).

As to the rest, I remember there being more to it when I used SDL + Vulkan.

Is the Vulkan validation layer telling you anything?

This helped me figure it out. I thought I had validation layers on, but I did not. They were warning me about something completely unrelated to SDL. Thanks so much!

1 Like