I am currently working on some simple tilemap rendering (with instancing). And I thought about checking out some of the GPU features provided. Currently I don’t know why the following occurs, and hoped someone here might have a clue as to what is going and and what I need to change so this works.
First off:
The code works fine when I utilize Vulkan as the backend for rendering. Only when I force "direct3d12" a call to sdl.CreateGPUGraphicsPipeline (SDL_CreateGPUGraphicsPipeline) fails.
The error I get is the HRESULT code of ‘E_INVALIDARG’. Maybe I need to change some things or I am missing some parameters required for the internals - I would have expected a check for this from the side of SDL_gpu and am now on the hunt for a fix.
The code I use is the Odin vendor wrapper (just to make sure I’ve updated Odin and the SDL libraries used / shipped with it).
create_tilemap_pipeline :: proc(device: ^sdl.GPUDevice, window: ^sdl.Window) -> ^sdl.GPUGraphicsPipeline {
vertex_shader := load_shader("TileMap.vert", device, uniform_buffer_count = 1, storage_buffer_count = 1)
defer sdl.ReleaseGPUShader(device, vertex_shader)
fragment_shader := load_shader("TileMap.frag", device, sampler_count = 1)
defer sdl.ReleaseGPUShader(device, fragment_shader)
color_target_description := [1]sdl.GPUColorTargetDescription {
{
format = sdl.GetGPUSwapchainTextureFormat(device, window),
blend_state = {
src_color_blendfactor = .SRC_ALPHA,
dst_color_blendfactor = .ONE_MINUS_SRC_ALPHA,
color_blend_op = .ADD,
src_alpha_blendfactor = .SRC_ALPHA,
dst_alpha_blendfactor = .ONE_MINUS_SRC_ALPHA,
alpha_blend_op = .ADD,
enable_blend = true
}
}
}
pipeline_target_info := sdl.GPUGraphicsPipelineTargetInfo {
color_target_descriptions = raw_data(color_target_description[:]),
num_color_targets = 1
}
pipeline_creation_info := sdl.GPUGraphicsPipelineCreateInfo {
vertex_shader = vertex_shader,
fragment_shader = fragment_shader,
primitive_type = .TRIANGLELIST,
target_info = pipeline_target_info
}
pipeline := sdl.CreateGPUGraphicsPipeline(device, pipeline_creation_info)
return pipeline
}
Maybe someone can help me to identify what piece I am missing. Thank you for help in advance.
PS> Here is the proof it works with vulkan:
Image of the crash (due to pipeline issues):

