10 SDL_GPUShader* vertexShader,
11 SDL_GPUShader* fragmentShader
21 SDL_GPUVertexInputRate inputRate
23 bufferDescs_.emplace_back(SDL_GPUVertexBufferDescription {
24 .slot = slot, .pitch = stride, .input_rate = inputRate
33 SDL_GPUVertexElementFormat format
35 vertexAttribs_.emplace_back(SDL_GPUVertexAttribute {
37 .buffer_slot = bufferSlot,
46 SDL_GPUColorTargetDescription colorDesc {.format = format};
47 colorTargetDescs_.push_back(colorDesc);
57 if (colorTargetDescs_.empty()) {
58 std::cerr <<
"Warning: no color target specified during pipeline creation"
62 SDL_GPUVertexInputState vertexState {
63 .vertex_buffer_descriptions = bufferDescs_.data(),
64 .num_vertex_buffers =
static_cast<Uint32
>(bufferDescs_.size()),
65 .vertex_attributes = vertexAttribs_.data(),
66 .num_vertex_attributes =
static_cast<Uint32
>(vertexAttribs_.size())
68 SDL_GPURasterizerState rasterizerState {
69 .cull_mode = cullMode_, .front_face = frontFace_
71 SDL_GPUGraphicsPipelineCreateInfo info {
73 .fragment_shader = fs_,
74 .vertex_input_state = vertexState,
75 .primitive_type = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST,
76 .rasterizer_state = rasterizerState,
78 {.color_target_descriptions = colorTargetDescs_.data(),
79 .num_color_targets =
static_cast<Uint32
>(colorTargetDescs_.size())}
81 if (
auto pl = SDL_CreateGPUGraphicsPipeline(device, &info)) {
84 throw std::runtime_error(SDL_GetError());