Graphics Pipeline with SDL_GPU fails to initialize
15:36 10 Dec 2025

I am using C++ and SDL3 on Windows using an Intel Integrated GPU to make a Game. I am trying to initialize a Graphics Pipeline to render a triangle, however i have been having problems with the Initialization.

I have been getting this Error:

ERROR: Could not create graphics pipeline state! Error Code: Unknown Error (0x80004005)
ERROR: Could not create graphics pipeline state! Error Code: Unknown Error (0x80004005)
ERROR: Could not create graphics pipeline state! Error Code: Unknown Error (0x80004005)
ERROR: Could not create graphics pipeline state! Error Code: Unknown Error (0x80004005)
ERROR: Could not create graphics pipeline state! Error Code: Unknown Error (0x80004005)
ERROR: Could not create graphics pipeline state! Error Code: Unknown Error (0x80004005)
Failed to create pipeline: Could not create graphics pipeline state! Error Code: Unknown Error (0x80004005)

Here are relevant Pieces of my Code to the initialization of the Graphics Pipeline:

#include 
#include 
#include "include/game.hpp"

SDL_GPUBuffer* vertex_buf = nullptr;

void Game::init(const char* title, int width, int height, bool fullscreen) {
    isrunning = false;

    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
        std::cerr << "Failed to initialize SDL. Reason: " << SDL_GetError() << std::endl;
        return;
    }

    if (!(window = SDL_CreateWindow(title, width, height, SDL_WINDOW_RESIZABLE | (fullscreen ? SDL_WINDOW_FULLSCREEN : 0)))) {
        SDL_Quit(); 
        std::cerr << "Failed to create Window. Reason: " << SDL_GetError() << std::endl;
        return;
    }

    if (!(gpu_device = SDL_CreateGPUDevice(SDL_GPU_SHADERFORMAT_DXBC, true, "direct3d12"))) {
        SDL_DestroyWindow(window);
        SDL_Quit();
        std::cerr << "Failed to create GPU Device. Reason: " << SDL_GetError() << std::endl;
        return;
    }

    if (!SDL_ClaimWindowForGPUDevice(gpu_device, window)) {
        SDL_DestroyGPUDevice(gpu_device);
        SDL_DestroyWindow(window);
        SDL_Quit();
        std::cerr << "Failed to create GPU Device. Reason: " << SDL_GetError() << std::endl;
        return;
    }

    float vertices[] = {
        0.0f,  0.5f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f,
        0.5f, -0.5f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f,
        -0.5f, -0.5f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f
    };

    SDL_GPUBufferCreateInfo createInfo = {};
    createInfo.usage = SDL_GPU_BUFFERUSAGE_VERTEX;
    createInfo.size = sizeof(vertices);
    vertex_buf = SDL_CreateGPUBuffer(gpu_device, &createInfo);

    SDL_GPUTransferBufferCreateInfo transCreateInfo = {};
    transCreateInfo.usage = SDL_GPU_TRANSFERBUFFERUSAGE_UPLOAD;
    transCreateInfo.size = sizeof(vertices);
    SDL_GPUTransferBuffer* transBuf = SDL_CreateGPUTransferBuffer(gpu_device, &transCreateInfo);

    void* data = SDL_MapGPUTransferBuffer(gpu_device, transBuf, false);
    memcpy(data, vertices, sizeof(vertices));
    SDL_UnmapGPUTransferBuffer(gpu_device, transBuf);

    SDL_GPUCommandBuffer* cmdbuf = SDL_AcquireGPUCommandBuffer(gpu_device);

    SDL_GPUCopyPass* copyPass = SDL_BeginGPUCopyPass(cmdbuf);

    SDL_GPUTransferBufferLocation transBufLoc = {};
    transBufLoc.transfer_buffer = transBuf;
    transBufLoc.offset = 0;

    SDL_GPUBufferRegion bufReg = {};
    bufReg.buffer = vertex_buf;
    bufReg.offset = 0;
    bufReg.size = sizeof(vertices);

    SDL_UploadToGPUBuffer(copyPass, &transBufLoc, &bufReg, false);

    SDL_EndGPUCopyPass(copyPass);
    SDL_SubmitGPUCommandBuffer(cmdbuf);

    SDL_ReleaseGPUTransferBuffer(gpu_device, transBuf);

    vertex_shader = loadShader("build/shaders/vertex.dxbc", SDL_GPU_SHADERSTAGE_VERTEX);
    if (!vertex_shader) {
        std::cerr << "Failed to find Vertex Shader. Reason: " << SDL_GetError() << std::endl;
        return;
    }

    fragment_shader = loadShader("build/shaders/pixel.dxbc", SDL_GPU_SHADERSTAGE_FRAGMENT);
    if (!fragment_shader) {
        std::cerr << "Failed to find Fragment Shader. Reason: " << SDL_GetError() << std::endl;
        return;
    }

    SDL_GPUVertexAttribute vertexAttributes[2] = {};
    vertexAttributes[0].location = 0;
    vertexAttributes[0].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT3;
    vertexAttributes[0].offset = 0;
    vertexAttributes[0].buffer_slot = 0;

    vertexAttributes[1].location = 1;
    vertexAttributes[1].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT4;
    vertexAttributes[1].offset = 12;
    vertexAttributes[1].buffer_slot = 0;

    SDL_GPUVertexBufferDescription vertexBufferDesc = {};
    vertexBufferDesc.slot = 0;
    vertexBufferDesc.pitch = 28;
    vertexBufferDesc.input_rate = SDL_GPU_VERTEXINPUTRATE_VERTEX;
    vertexBufferDesc.instance_step_rate = 0;

    SDL_GPUVertexInputState vertexInputState = {};
    vertexInputState.vertex_attributes = vertexAttributes;
    vertexInputState.num_vertex_attributes = 2;
    vertexInputState.vertex_buffer_descriptions = &vertexBufferDesc;
    vertexInputState.num_vertex_buffers = 1;

    SDL_GPURasterizerState rasterizerState = {};
    rasterizerState.fill_mode = SDL_GPU_FILLMODE_FILL;
    rasterizerState.cull_mode = SDL_GPU_CULLMODE_NONE;
    rasterizerState.front_face = SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE;

    SDL_GPUMultisampleState multisampleState = {};
    multisampleState.sample_count = SDL_GPU_SAMPLECOUNT_1;

    SDL_GPUColorTargetBlendState blendState = {};
    blendState.src_color_blendfactor = SDL_GPU_BLENDFACTOR_ONE;
    blendState.dst_color_blendfactor = SDL_GPU_BLENDFACTOR_ZERO;
    blendState.color_blend_op = SDL_GPU_BLENDOP_ADD;
    blendState.src_alpha_blendfactor = SDL_GPU_BLENDFACTOR_ONE;
    blendState.dst_alpha_blendfactor = SDL_GPU_BLENDFACTOR_ZERO;
    blendState.alpha_blend_op = SDL_GPU_BLENDOP_ADD;
    blendState.color_write_mask = 0xF;

    SDL_GPUColorTargetDescription colorTarget = {};
    colorTarget.format = SDL_GetGPUSwapchainTextureFormat(gpu_device, window);
    colorTarget.blend_state = blendState;
    
    SDL_GPUDepthStencilState depthStencilState = {};
    depthStencilState.compare_op = SDL_GPU_COMPAREOP_ALWAYS;
    depthStencilState.enable_depth_test = false;
    depthStencilState.enable_depth_write = false;
    depthStencilState.enable_stencil_test = false;

    SDL_GPUGraphicsPipelineCreateInfo pipelineInfo = {};
    pipelineInfo.vertex_shader = vertex_shader;
    pipelineInfo.fragment_shader = fragment_shader;
    pipelineInfo.vertex_input_state = vertexInputState;
    pipelineInfo.primitive_type = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST;
    pipelineInfo.rasterizer_state = rasterizerState;
    pipelineInfo.multisample_state = multisampleState;
    pipelineInfo.target_info.num_color_targets = 1;
    pipelineInfo.target_info.color_target_descriptions = &colorTarget;
    pipelineInfo.props = 0;

    pipelineInfo.depth_stencil_state = depthStencilState;

    graphics_pipeline = SDL_CreateGPUGraphicsPipeline(gpu_device, &pipelineInfo);
    if (!graphics_pipeline) {
        std::cerr << "Failed to create pipeline: " << SDL_GetError() << std::endl;
        return;
    }

    isrunning = true;
}

SDL_GPUShader* Game::loadShader(const char* path, SDL_GPUShaderStage stage) {
    size_t code_size = 0;
    Uint8* code = static_cast(SDL_LoadFile(path, &code_size));

    if (!code) {
        return NULL;
    }

    SDL_GPUShaderCreateInfo shaderInfo = {
        .code_size = code_size,
        .code = code,
        .entrypoint = "main",
        .format = SDL_GPU_SHADERFORMAT_DXBC,
        .stage = stage
    };

    SDL_GPUShader* shader = SDL_CreateGPUShader(gpu_device, &shaderInfo);
    SDL_free(code);

    return shader;
}

And my entire Header:

#ifndef GAME_HPP
#define GAME_HPP
#include 
#include 
#include 

class Game {
    public:
        Game();
        ~Game();

        void init(const char* title, int width, int height, bool fullscreen);
        SDL_GPUShader* loadShader(const char* path, SDL_GPUShaderStage stage);

        void handleEvents();
        void update();
        void render();
        void clean();

        bool running() { return isrunning; }
    private:
        int cnt = 0;
        bool isrunning;
        SDL_Window* window;
        SDL_GPUDevice* gpu_device;
        SDL_GPUGraphicsPipeline* graphics_pipeline;
        SDL_GPUShader* vertex_shader;
        SDL_GPUShader* fragment_shader;
};

#endif

I have tried to find examples to SDL_GPU and I am still not quite sure of where the issue is located, so i'll appreciate any Help!

c++ sdl sdl-3