72 FLINT_ENGINE_ERROR(
"Pipeline: Invalid shader provided");
78 SDL_GPUVertexBufferDescription vertexBinding = {};
79 vertexBinding.slot = 0;
81 vertexBinding.input_rate = SDL_GPU_VERTEXINPUTRATE_VERTEX;
83 SDL_GPUVertexAttribute vertexAttributes[2] = {};
84 vertexAttributes[0].location = 0;
85 vertexAttributes[0].buffer_slot = 0;
86 vertexAttributes[0].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2;
87 vertexAttributes[0].offset = 0;
89 vertexAttributes[1].location = 1;
90 vertexAttributes[1].buffer_slot = 0;
91 vertexAttributes[1].format = SDL_GPU_VERTEXELEMENTFORMAT_FLOAT2;
92 vertexAttributes[1].offset =
sizeof(float) * 2;
94 SDL_GPUVertexInputState vertexInputState = {};
95 vertexInputState.num_vertex_buffers = 1;
96 vertexInputState.vertex_buffer_descriptions = &vertexBinding;
97 vertexInputState.num_vertex_attributes = 2;
98 vertexInputState.vertex_attributes = vertexAttributes;
100 SDL_GPUGraphicsPipelineCreateInfo pipelineInfo{};
103 pipelineInfo.vertex_input_state = vertexInputState;
104 pipelineInfo.primitive_type = SDL_GPU_PRIMITIVETYPE_TRIANGLELIST;
106 pipelineInfo.rasterizer_state.cull_mode = config.cullMode;
107 pipelineInfo.rasterizer_state.fill_mode = config.fillMode;
108 pipelineInfo.rasterizer_state.front_face = SDL_GPU_FRONTFACE_COUNTER_CLOCKWISE;
110 pipelineInfo.depth_stencil_state.enable_depth_test = config.enableDepthTest;
111 pipelineInfo.depth_stencil_state.enable_depth_write = config.enableDepthWrite;
113 SDL_GPUColorTargetDescription colorTarget = {};
114 colorTarget.format = config.colorFormat;
115 colorTarget.blend_state.enable_blend = config.enableBlending;
116 colorTarget.blend_state.src_color_blendfactor = config.srcColorBlend;
117 colorTarget.blend_state.dst_color_blendfactor = config.dstColorBlend;
118 colorTarget.blend_state.color_blend_op = SDL_GPU_BLENDOP_ADD;
119 colorTarget.blend_state.src_alpha_blendfactor = config.srcAlphaBlend;
120 colorTarget.blend_state.dst_alpha_blendfactor = config.dstAlphaBlend;
121 colorTarget.blend_state.alpha_blend_op = SDL_GPU_BLENDOP_ADD;
122 colorTarget.blend_state.color_write_mask = 0xF;
124 pipelineInfo.target_info.num_color_targets = 1;
125 pipelineInfo.target_info.color_target_descriptions = &colorTarget;
126 pipelineInfo.target_info.depth_stencil_format = SDL_GPU_TEXTUREFORMAT_INVALID;
132 m_pipeline = SDL_CreateGPUGraphicsPipeline(m_device, &pipelineInfo);
134 FLINT_ENGINE_ERROR(
"Failed to create graphics pipeline: {}", SDL_GetError());