1/*  Part of the SDL3 pack for SWI-Prolog.
    2
    3    SDL_gpu.h — GPU device, command buffers, render passes, shaders,
    4    pipelines, buffers, textures, and draw commands.
    5
    6    @see https://wiki.libsdl.org/SDL3/SDL_gpu
    7*/
    8
    9:- module(sdl_gpu, [
   10    sdl_creategpudevice/4, sdl_destroygpudevice/1,
   11    sdl_claimwindowforgpudevice/2,
   12    sdl_releasewindowfromgpudevice/2,
   13    sdl_acquiregpucommandbuffer/2,
   14    sdl_submitgpucommandbuffer/1,
   15    sdl_cancelgpucommandbuffer/1,
   16    sdl_acquiregpuswapchaintexture/5,
   17    sdl_waitandacquiregpuswapchaintexture/5,
   18    sdl_begingpurenderpass/4,
   19    sdl_endgpurenderpass/1,
   20    sdl_creategputexture/3,
   21    sdl_releasegputexture/1,
   22    sdl_creategpushader/3,
   23    sdl_releasegpushader/1,
   24    sdl_creategpugraphicspipeline/3,
   25    sdl_releasegpugraphicspipeline/1,
   26    sdl_creategpubuffer/4,
   27    sdl_releasegpubuffer/1,
   28    sdl_creategputransferbuffer/4,
   29    sdl_releasegputransferbuffer/1,
   30    sdl_mapgputransferbuffer/3,
   31    sdl_unmapgputransferbuffer/1,
   32    sdl_begingpucopypass/2,
   33    sdl_endgpucopypass/1,
   34    sdl_uploadtogpubuffer/4,
   35    sdl_bindgpugraphicspipeline/2,
   36    sdl_bindgpuvertexbuffers/3,
   37    sdl_bindgpuindexbuffer/3,
   38    sdl_drawgpuindexedprimitives/6,
   39    sdl_drawgpuprimitives/5,
   40    sdl_gpu_index_element_size/2,
   41    sdl_gpu_buffer_usage/2,
   42    sdl_gpu_transfer_buffer_usage/2,
   43    sdl_gpu_load_op/2,
   44    sdl_gpu_store_op/2,
   45    sdl_gpu_texture_type/2,
   46    sdl_gpu_texture_format/2,
   47    sdl_gpu_texture_usage/2,
   48    sdl_gpu_sample_count/2,
   49    sdl_gpu_shader_format/2,
   50    sdl_gpu_shader_stage/2,
   51    sdl_gpu_primitive_type/2,
   52    sdl_gpu_fill_mode/2,
   53    sdl_gpu_cull_mode/2,
   54    sdl_gpu_front_face/2,
   55    sdl_gpu_compare_op/2,
   56    sdl_gpu_stencil_op/2,
   57    sdl_gpu_blend_op/2,
   58    sdl_gpu_blend_factor/2,
   59    sdl_gpu_vertex_input_rate/2,
   60    sdl_gpu_vertex_element_format/2,
   61    sdl_gpu_color_component/2,
   62    sdl_getnumgpudrivers/1, sdl_getgpudriver/2,
   63    make_color_target/2, default_color_target/1, is_color_target/1,
   64    make_depth_stencil_target/2, default_depth_stencil_target/1, is_depth_stencil_target/1,
   65    make_gpu_texture_create_info/2, default_gpu_texture_create_info/1, is_gpu_texture_create_info/1,
   66    make_gpu_shader_create_info/2, default_gpu_shader_create_info/1, is_gpu_shader_create_info/1,
   67    make_vertex_buffer_description/2, default_vertex_buffer_description/1, is_vertex_buffer_description/1,
   68    make_vertex_attribute/2, default_vertex_attribute/1, is_vertex_attribute/1,
   69    make_stencil_op_state/2, default_stencil_op_state/1, is_stencil_op_state/1,
   70    make_color_target_blend_state/2, default_color_target_blend_state/1, is_color_target_blend_state/1,
   71    make_color_target_description/2, default_color_target_description/1, is_color_target_description/1,
   72    make_vertex_input_state/2, default_vertex_input_state/1, is_vertex_input_state/1,
   73    make_rasterizer_state/2, default_rasterizer_state/1, is_rasterizer_state/1,
   74    make_multisample_state/2, default_multisample_state/1, is_multisample_state/1,
   75    make_depth_stencil_state/2, default_depth_stencil_state/1, is_depth_stencil_state/1,
   76    make_target_info/2, default_target_info/1, is_target_info/1,
   77    make_gpu_graphics_pipeline_create_info/2, default_gpu_graphics_pipeline_create_info/1, is_gpu_graphics_pipeline_create_info/1,
   78    make_buffer_binding/2, default_buffer_binding/1, is_buffer_binding/1,
   79    make_transfer_buffer_location/2, default_transfer_buffer_location/1, is_transfer_buffer_location/1,
   80    make_buffer_region/2, default_buffer_region/1, is_buffer_region/1
   81]).   82
   83:- use_module(library(sdl/foreign)).   84:- reexport(library(sdl/foreign), [
   85    sdl_getnumgpudrivers/1, sdl_getgpudriver/2
   86]).   87:- use_module(library(sdl/video)). % for sdl_window_blob type
   88:- use_module(library(record)).   89
   90error:has_type(sdl_gpu_device_blob, X) :- blob(X, sdl_gpu_device_blob).
   91error:has_type(sdl_gpu_cmdbuf_blob, X) :- blob(X, sdl_gpu_cmdbuf_blob).
   92error:has_type(sdl_gpu_swapchain_texture_blob, X) :- blob(X, sdl_gpu_swapchain_texture_blob).
   93error:has_type(sdl_gpu_renderpass_blob, X) :- blob(X, sdl_gpu_renderpass_blob).
   94error:has_type(sdl_gpu_texture_blob, X) :- blob(X, sdl_gpu_texture_blob).
   95error:has_type(sdl_gpu_shader_blob, X) :- blob(X, sdl_gpu_shader_blob).
   96error:has_type(sdl_gpu_pipeline_blob, X) :- blob(X, sdl_gpu_pipeline_blob).
   97error:has_type(sdl_gpu_buffer_blob, X) :- blob(X, sdl_gpu_buffer_blob).
   98error:has_type(sdl_gpu_transfer_buffer_blob, X) :- blob(X, sdl_gpu_transfer_buffer_blob).
   99error:has_type(sdl_gpu_copypass_blob, X) :- blob(X, sdl_gpu_copypass_blob).
  100error:has_type(sdl_gpu_index_element_size, X) :- sdl_gpu_index_element_size(X, _).
  101% sdl_gpu_texture accepts either a swapchain texture blob or a regular GPU
  102% texture blob.  Used as a field type in color_target and depth_stencil_target
  103% records.
  104error:has_type(sdl_gpu_texture, X) :-
  105   (  blob(X, sdl_gpu_swapchain_texture_blob)
  106   ;  blob(X, sdl_gpu_texture_blob)
  107   ).
  108% fcolor(R,G,B,A) — maps to SDL_FColor.  Fields are numbers (int or float);
  109% the C++ layer converts via as_float().
  110error:has_type(fcolor, X) :-
  111   nonvar(X),
  112   compound_name_arity(X, fcolor, 4),
  113   arg(1, X, R), is_of_type(number, R),
  114   arg(2, X, G), is_of_type(number, G),
  115   arg(3, X, B), is_of_type(number, B),
  116   arg(4, X, A), is_of_type(number, A).
  117error:has_type(sdl_gpu_load_op, X) :- sdl_gpu_load_op(X, _).
  118error:has_type(sdl_gpu_store_op, X) :- sdl_gpu_store_op(X, _).
  119error:has_type(sdl_gpu_texture_type, X) :- sdl_gpu_texture_type(X, _).
  120error:has_type(sdl_gpu_texture_format, X) :- sdl_gpu_texture_format(X, _).
  121error:has_type(sdl_gpu_texture_usage, X) :- sdl_gpu_texture_usage(X, _).
  122error:has_type(sdl_gpu_sample_count, X) :- sdl_gpu_sample_count(X, _).
  123error:has_type(sdl_gpu_shader_stage, X) :- sdl_gpu_shader_stage(X, _).
  124error:has_type(sdl_gpu_primitive_type, X) :- sdl_gpu_primitive_type(X, _).
  125error:has_type(sdl_gpu_fill_mode, X) :- sdl_gpu_fill_mode(X, _).
  126error:has_type(sdl_gpu_cull_mode, X) :- sdl_gpu_cull_mode(X, _).
  127error:has_type(sdl_gpu_front_face, X) :- sdl_gpu_front_face(X, _).
  128error:has_type(sdl_gpu_compare_op, X) :- sdl_gpu_compare_op(X, _).
  129error:has_type(sdl_gpu_stencil_op, X) :- sdl_gpu_stencil_op(X, _).
  130error:has_type(sdl_gpu_blend_op, X) :- sdl_gpu_blend_op(X, _).
  131error:has_type(sdl_gpu_blend_factor, X) :- sdl_gpu_blend_factor(X, _).
  132error:has_type(sdl_gpu_vertex_input_rate, X) :- sdl_gpu_vertex_input_rate(X, _).
  133error:has_type(sdl_gpu_vertex_element_format, X) :- sdl_gpu_vertex_element_format(X, _).
  134error:has_type(sdl_gpu_color_component, X) :- sdl_gpu_color_component(X, _).
  135error:has_type(sdl_gpu_buffer_usage, X) :- sdl_gpu_buffer_usage(X, _).
  136error:has_type(sdl_gpu_transfer_buffer_usage, X) :- sdl_gpu_transfer_buffer_usage(X, _).
  137error:has_type(sdl_init_flag,   X) :- sdl_init_flag(X, _).
  138error:has_type(sdl_window_flag, X) :- sdl_window_flag(X, _).
  139error:has_type(sdl_windowpos,   X) :- ( atom(X) -> sdl_windowpos(X, _) ; integer(X) ).
  140error:has_type(sdl_pixel_format, X) :- sdl_pixel_format(X, _).
  141error:has_type(sdl_texture_access, X) :- sdl_texture_access(X, _).
  142error:has_type(sdl_gpu_shader_format, X) :- sdl_gpu_shader_format(X, _).
  143error:has_type(sdl_gpu_driver, X) :- sdl_gpu_driver(X).
  144
  145prolog:error_message(type_error(sdl_gpu_device_blob, Culprit)) -->
  146   [ 'sdl_gpu_device_blob, found ~q'-[Culprit] ].
  147prolog:error_message(type_error(sdl_gpu_cmdbuf_blob, Culprit)) -->
  148   [ 'sdl_gpu_cmdbuf_blob, found ~q'-[Culprit] ].
  149prolog:error_message(type_error(sdl_gpu_swapchain_texture_blob, Culprit)) -->
  150   [ 'sdl_gpu_swapchain_texture_blob, found ~q'-[Culprit] ].
  151prolog:error_message(type_error(sdl_gpu_renderpass_blob, Culprit)) -->
  152   [ 'sdl_gpu_renderpass_blob, found ~q'-[Culprit] ].
  153prolog:error_message(type_error(sdl_gpu_texture_blob, Culprit)) -->
  154   [ 'sdl_gpu_texture_blob, found ~q'-[Culprit] ].
  155prolog:error_message(type_error(sdl_gpu_shader_blob, Culprit)) -->
  156   [ 'sdl_gpu_shader_blob, found ~q'-[Culprit] ].
  157prolog:error_message(type_error(sdl_gpu_pipeline_blob, Culprit)) -->
  158   [ 'sdl_gpu_pipeline_blob, found ~q'-[Culprit] ].
  159prolog:error_message(type_error(sdl_gpu_buffer_blob, Culprit)) -->
  160   [ 'sdl_gpu_buffer_blob, found ~q'-[Culprit] ].
  161prolog:error_message(type_error(sdl_gpu_transfer_buffer_blob, Culprit)) -->
  162   [ 'sdl_gpu_transfer_buffer_blob, found ~q'-[Culprit] ].
  163prolog:error_message(type_error(sdl_gpu_copypass_blob, Culprit)) -->
  164   [ 'sdl_gpu_copypass_blob, found ~q'-[Culprit] ].
  165prolog:error_message(type_error(transfer_buffer_location, Culprit)) -->
  166   [ 'transfer_buffer_location (record transfer_buffer_location/2), found ~q'-[Culprit] ].
  167prolog:error_message(type_error(buffer_region, Culprit)) -->
  168   [ 'buffer_region (record buffer_region/3), found ~q'-[Culprit] ].
  169prolog:error_message(type_error(buffer_binding, Culprit)) -->
  170   [ 'buffer_binding (record buffer_binding/2), found ~q'-[Culprit] ].
  171prolog:error_message(type_error(sdl_gpu_index_element_size, Culprit)) -->
  172   { findall(F, sdl_gpu_index_element_size(F, _), Fs) },
  173   [ 'sdl_gpu_index_element_size (one of ~q), found ~q'-[Fs, Culprit] ].
  174prolog:error_message(type_error(sdl_gpu_texture, Culprit)) -->
  175   [ 'sdl_gpu_texture (swapchain or regular texture blob), found ~q'-[Culprit] ].
  176prolog:error_message(type_error(fcolor, Culprit)) -->
  177   [ 'fcolor (fcolor(R,G,B,A) with numeric fields), found ~q'-[Culprit] ].
  178prolog:error_message(type_error(sdl_gpu_load_op, Culprit)) -->
  179   { findall(F, sdl_gpu_load_op(F, _), Fs) },
  180   [ 'sdl_gpu_load_op (one of ~q), found ~q'-[Fs, Culprit] ].
  181prolog:error_message(type_error(sdl_gpu_store_op, Culprit)) -->
  182   { findall(F, sdl_gpu_store_op(F, _), Fs) },
  183   [ 'sdl_gpu_store_op (one of ~q), found ~q'-[Fs, Culprit] ].
  184prolog:error_message(type_error(sdl_gpu_texture_type, Culprit)) -->
  185   { findall(F, sdl_gpu_texture_type(F, _), Fs) },
  186   [ 'sdl_gpu_texture_type (one of ~q), found ~q'-[Fs, Culprit] ].
  187prolog:error_message(type_error(sdl_gpu_texture_format, Culprit)) -->
  188   [ 'sdl_gpu_texture_format (one of 105 format atoms), found ~q'-[Culprit] ].
  189prolog:error_message(type_error(sdl_gpu_texture_usage, Culprit)) -->
  190   { findall(F, sdl_gpu_texture_usage(F, _), Fs) },
  191   [ 'sdl_gpu_texture_usage (one of ~q), found ~q'-[Fs, Culprit] ].
  192prolog:error_message(type_error(sdl_gpu_sample_count, Culprit)) -->
  193   { findall(F, sdl_gpu_sample_count(F, _), Fs) },
  194   [ 'sdl_gpu_sample_count (one of ~q), found ~q'-[Fs, Culprit] ].
  195prolog:error_message(type_error(sdl_gpu_shader_stage, Culprit)) -->
  196   { findall(F, sdl_gpu_shader_stage(F, _), Fs) },
  197   [ 'sdl_gpu_shader_stage (one of ~q), found ~q'-[Fs, Culprit] ].
  198prolog:error_message(type_error(sdl_gpu_primitive_type, Culprit)) -->
  199   { findall(F, sdl_gpu_primitive_type(F, _), Fs) },
  200   [ 'sdl_gpu_primitive_type (one of ~q), found ~q'-[Fs, Culprit] ].
  201prolog:error_message(type_error(sdl_gpu_fill_mode, Culprit)) -->
  202   { findall(F, sdl_gpu_fill_mode(F, _), Fs) },
  203   [ 'sdl_gpu_fill_mode (one of ~q), found ~q'-[Fs, Culprit] ].
  204prolog:error_message(type_error(sdl_gpu_cull_mode, Culprit)) -->
  205   { findall(F, sdl_gpu_cull_mode(F, _), Fs) },
  206   [ 'sdl_gpu_cull_mode (one of ~q), found ~q'-[Fs, Culprit] ].
  207prolog:error_message(type_error(sdl_gpu_front_face, Culprit)) -->
  208   { findall(F, sdl_gpu_front_face(F, _), Fs) },
  209   [ 'sdl_gpu_front_face (one of ~q), found ~q'-[Fs, Culprit] ].
  210prolog:error_message(type_error(sdl_gpu_compare_op, Culprit)) -->
  211   { findall(F, sdl_gpu_compare_op(F, _), Fs) },
  212   [ 'sdl_gpu_compare_op (one of ~q), found ~q'-[Fs, Culprit] ].
  213prolog:error_message(type_error(sdl_gpu_stencil_op, Culprit)) -->
  214   { findall(F, sdl_gpu_stencil_op(F, _), Fs) },
  215   [ 'sdl_gpu_stencil_op (one of ~q), found ~q'-[Fs, Culprit] ].
  216prolog:error_message(type_error(sdl_gpu_blend_op, Culprit)) -->
  217   { findall(F, sdl_gpu_blend_op(F, _), Fs) },
  218   [ 'sdl_gpu_blend_op (one of ~q), found ~q'-[Fs, Culprit] ].
  219prolog:error_message(type_error(sdl_gpu_blend_factor, Culprit)) -->
  220   { findall(F, sdl_gpu_blend_factor(F, _), Fs) },
  221   [ 'sdl_gpu_blend_factor (one of ~q), found ~q'-[Fs, Culprit] ].
  222prolog:error_message(type_error(sdl_gpu_vertex_input_rate, Culprit)) -->
  223   { findall(F, sdl_gpu_vertex_input_rate(F, _), Fs) },
  224   [ 'sdl_gpu_vertex_input_rate (one of ~q), found ~q'-[Fs, Culprit] ].
  225prolog:error_message(type_error(sdl_gpu_vertex_element_format, Culprit)) -->
  226   { findall(F, sdl_gpu_vertex_element_format(F, _), Fs) },
  227   [ 'sdl_gpu_vertex_element_format (one of ~q), found ~q'-[Fs, Culprit] ].
  228prolog:error_message(type_error(sdl_gpu_color_component, Culprit)) -->
  229   { findall(F, sdl_gpu_color_component(F, _), Fs) },
  230   [ 'sdl_gpu_color_component (one of ~q), found ~q'-[Fs, Culprit] ].
  231prolog:error_message(type_error(sdl_gpu_buffer_usage, Culprit)) -->
  232   { findall(F, sdl_gpu_buffer_usage(F, _), Fs) },
  233   [ 'sdl_gpu_buffer_usage (one of ~q), found ~q'-[Fs, Culprit] ].
  234prolog:error_message(type_error(sdl_gpu_transfer_buffer_usage, Culprit)) -->
  235   { findall(F, sdl_gpu_transfer_buffer_usage(F, _), Fs) },
  236   [ 'sdl_gpu_transfer_buffer_usage (one of ~q), found ~q'-[Fs, Culprit] ].
  237prolog:error_message(type_error(sdl_gpu_color_target, Culprit)) -->
  238   [ 'sdl_gpu_color_target (record color_target/11), found ~q'-[Culprit] ].
  239prolog:error_message(type_error(sdl_gpu_depth_stencil_target, Culprit)) -->
  240   [ 'sdl_gpu_depth_stencil_target (record depth_stencil_target/10), found ~q'-[Culprit] ].
  241prolog:error_message(type_error(sdl_gpu_texture_create_info, Culprit)) -->
  242   [ 'sdl_gpu_texture_create_info (record gpu_texture_create_info/8), found ~q'-[Culprit] ].
  243prolog:error_message(type_error(sdl_gpu_shader_format, Culprit)) -->
  244   { findall(F, sdl_gpu_shader_format(F, _), Fs) },
  245   [ 'sdl_gpu_shader_format (one of ~q), found ~q'-[Fs, Culprit] ].
  246prolog:error_message(type_error(sdl_gpu_driver, Culprit)) -->
  247   { findall(F, gpu_driver_(F), Fs) },
  248   [ 'sdl_gpu_driver (one of ~q), found ~q'-[Fs, Culprit] ].
  249
  250user:portray(Device) :-
  251   blob(Device, sdl_gpu_device_blob), !,
  252   sdl_gpu_device_blob_portray(current_output, Device).
  253user:portray(CmdBuf) :-
  254   blob(CmdBuf, sdl_gpu_cmdbuf_blob), !,
  255   sdl_gpu_cmdbuf_blob_portray(current_output, CmdBuf).
  256user:portray(Texture) :-
  257   blob(Texture, sdl_gpu_swapchain_texture_blob), !,
  258   sdl_gpu_swapchain_texture_blob_portray(current_output, Texture).
  259user:portray(RenderPass) :-
  260   blob(RenderPass, sdl_gpu_renderpass_blob), !,
  261   sdl_gpu_renderpass_blob_portray(current_output, RenderPass).
  262user:portray(Texture) :-
  263   blob(Texture, sdl_gpu_texture_blob), !,
  264   sdl_gpu_texture_blob_portray(current_output, Texture).
  265user:portray(Shader) :-
  266   blob(Shader, sdl_gpu_shader_blob), !,
  267   sdl_gpu_shader_blob_portray(current_output, Shader).
  268user:portray(Pipeline) :-
  269   blob(Pipeline, sdl_gpu_pipeline_blob), !,
  270   sdl_gpu_pipeline_blob_portray(current_output, Pipeline).
  271user:portray(Buffer) :-
  272   blob(Buffer, sdl_gpu_buffer_blob), !,
  273   sdl_gpu_buffer_blob_portray(current_output, Buffer).
  274user:portray(TransferBuffer) :-
  275   blob(TransferBuffer, sdl_gpu_transfer_buffer_blob), !,
  276   sdl_gpu_transfer_buffer_blob_portray(current_output, TransferBuffer).
  277user:portray(CopyPass) :-
  278   blob(CopyPass, sdl_gpu_copypass_blob), !,
  279   sdl_gpu_copypass_blob_portray(current_output, CopyPass).
 sdl_gpu_shader_format(?Format:atom, ?Value:integer) is nondet
Shader backend bytecode formats. A list of these atoms is passed to sdl_creategpudevice/4 so SDL can pick a backend supporting at least one of them. The private atom means no format is requested; it is not a sdl_gpu_shader_format and is handled separately by sdl_creategpudevice.
See also
- https://wiki.libsdl.org/SDL3/SDL_GPUShaderFormat
  298sdl_gpu_shader_format(private,  0x00000001).
  299sdl_gpu_shader_format(spirv,     0x00000002).
  300sdl_gpu_shader_format(dxbc,      0x00000004).
  301sdl_gpu_shader_format(dxil,      0x00000008).
  302sdl_gpu_shader_format(msl,      0x00000010).
  303sdl_gpu_shader_format(metallib, 0x00000020).
  304
  305% --- SDL_gpu: driver names --------------------------------------------------
  306% SDL_gpu's compiled-in backends are enumerated at runtime via
  307% SDL_GetNumGPUDrivers / SDL_GetGPUDriver.  On a Linux build only `vulkan`
  308% is available; on Windows `vulkan` and `direct3d12`; on macOS `vulkan`
  309% and `metal`.  The atom `null` represents a NULL driver name (SDL chooses
  310% the best backend); it is not a sdl_gpu_driver and is handled separately by
  311% sdl_creategpudevice.  Driver names are atoms throughout the Prolog API;
  312% they are translated to raw C strings only inside the foreign predicate at
  313% the SDL call boundary.
 sdl_getgpudriver(+Index:integer, -Name:atom) is det
Returns the name of the compiled-in GPU driver at Index (e.g. vulkan, direct3d12, metal). Index ranges from 0 to sdl_getnumgpudrivers - 1; an out-of-range index throws an error.
See also
- https://wiki.libsdl.org/SDL3/SDL_GetGPUDriver
  323% Internal nondeterministic enumerator over compiled-in driver atoms.
  324% Used by sdl_gpu_driver/1 (membership check) and the error-message hook
  325% (listing valid atoms).  Not exported.
  326gpu_driver_(Name) :-
  327   sdl_getnumgpudrivers(Count),
  328   Last is Count - 1,
  329   between(0, Last, Index),
  330   sdl_getgpudriver(Index, Name).
  331
  332% Deterministic type-check helper: succeeds once iff Name is an atom
  333% matching a GPU driver compiled into this SDL build.  Not exported.
  334sdl_gpu_driver(Name) :-
  335   findall(D, gpu_driver_(D), Ds),
  336   memberchk(Name, Ds).
  337
  338% --- SDL_gpu: create / destroy device ---------------------------------------
  339% Creates a GPU device.  ShaderFormats is a list of sdl_gpu_shader_format
  340% atoms (OR-ed together) selecting the backend shader bytecode formats the
  341% application is prepared to supply; SDL picks a backend that supports at
  342% least one.  Debug enables the GPU validation layer.  Name is the atom
  343% `null` (use the default driver) or a sdl_gpu_driver atom.  The returned
  344% device owns no parent: it is the root handle from which windows and
  345% resources are claimed/created.
 sdl_creategpudevice(-Device:blob, +ShaderFormats:list(sdl_gpu_shader_format), +Debug:boolean, +Name:oneof([null]);sdl_gpu_driver) is det
Creates a GPU device. ShaderFormats is the list of shader bytecode formats this backend must support; SDL picks a backend supporting at least one of them. Debug enables the GPU validation layer. Name is null to use the default driver or one of the driver atoms returned by sdl_getgpudriver/2.

The device is the root handle from which windows and resources are claimed/created.

See also
- https://wiki.libsdl.org/SDL3/SDL_CreateGPUDevice
  360sdl_creategpudevice(Device, ShaderFormats, Debug, Name) :-
  361   must_be(var, Device),
  362   must_be(list(sdl_gpu_shader_format), ShaderFormats),
  363   must_be(boolean, Debug),
  364   must_be((oneof([null]) ; sdl_gpu_driver), Name),
  365   maplist(sdl_gpu_shader_format, ShaderFormats, IntFlags),
  366   or_list(IntFlags, IntFlag),
  367   sdl_creategpudevice_(Device, IntFlag, Debug, Name).
 sdl_destroygpudevice(+Device:blob) is det
Destroys the GPU device, releasing all claimed windows and resources created from it on the SDL side. The Blob is invalid after this call.
See also
- https://wiki.libsdl.org/SDL3/SDL_DestroyGPUDevice
  376sdl_destroygpudevice(Device) :-
  377   must_be(sdl_gpu_device_blob, Device),
  378   sdl_destroygpudevice_(Device).
  379
  380% --- SDL_gpu: claim / release window ----------------------------------------
  381% Claims a window for GPU rendering (creates its swapchain) or releases it.
  382% The window must have been created with the backend-matching window flag
  383% (`vulkan` on Linux/Windows, `metal` on macOS).  These are state mutations
  384% on existing handles — no new blob is produced, like sdl_setwindowposition.
  385%
  386% The device blob maintains a registered-ref list of claimed windows so the
  387% window blob cannot be garbage-collected while the claim is live (mirrors
  388% the SDLRendererBlob -> SDLWindowBlob parent ref).  sdl_releasewindowfrom-
  389% gpudevice/2 throws existence_error(claimed_window, Window) if the window
  390% is not currently claimed by the device, catching double-release and
  391% release-without-claim bugs.  SDL_DestroyGPUDevice releases all claimed
  392% windows on the SDL side and clears the ref list, so explicit release is
  393% only required to reclaim a window before device destruction.
 sdl_claimwindowforgpudevice(+Device:blob, +Window:blob) is det
Claims a window for GPU rendering (creates its swapchain) or releases it. The window must have been created with the backend-matching window flag (vulkan on Linux/Windows, metal on macOS). These are state mutations on existing handles — no new blob is produced, like sdl_setwindowposition.

The device blob maintains a registered-ref list of claimed windows so the window blob cannot be GC'd while the claim is live (mirrors the SDLRendererBlob -> SDLWindowBlob parent ref). sdl_releasewindowfrom- gpudevice/2 throws existence_error(claimed_window, Window) if the window is not currently claimed by the device, catching double-release and release-without-claim bugs. SDL_DestroyGPUDevice releases all claimed windows on the SDL side and clears the ref list, so explicit release is only required to reclaim a window before device destruction.

  411sdl_claimwindowforgpudevice(Device, Window) :-
  412   must_be(sdl_gpu_device_blob, Device),
  413   must_be(sdl_window_blob, Window),
  414   sdl_claimwindowforgpudevice_(Device, Window).
 sdl_releasewindowfromgpudevice(+Device:blob, +Window:blob) is det
Releases a window previously claimed with sdl_claimwindowforgpudevice/2, removing its swapchain. Throws existence_error(claimed_window, Window) if the window is not currently claimed by the device, catching double-release and release-without-claim bugs. SDL_DestroyGPUDevice releases all claimed windows on the SDL side, so this is only required to reclaim a window before device destruction.
See also
- https://wiki.libsdl.org/SDL3/SDL_ReleaseWindowFromGPUDevice
  427sdl_releasewindowfromgpudevice(Device, Window) :-
  428   must_be(sdl_gpu_device_blob, Device),
  429   must_be(sdl_window_blob, Window),
  430   sdl_releasewindowfromgpudevice_(Device, Window).
  431
  432% --- SDL_gpu: command buffer ------------------------------------------------
  433% A command buffer is acquired per frame from the device, commands are
  434% recorded into it, then it is submitted to the GPU for execution.  The
  435% command buffer may only be used on the thread that acquired it.
  436%
  437% RAII: if a command buffer blob is GC'd without being submitted (e.g. an
  438% exception discarded it mid-frame), the foreign destroy hook calls
  439% SDL_CancelGPUCommandBuffer to prevent a leak.  After a successful submit
  440% the blob is marked consumed so the cancel path is not triggered.  The blob
  441% holds a parent ref to the device, pinning it against GC for the command
  442% buffer's lifetime (mirrors SDLRendererBlob -> SDLWindowBlob).
  443%
  444% Submitting an already-submitted/cancelled command buffer raises
  445% existence_error(command_buffer, CmdBuf).
 sdl_acquiregpucommandbuffer(-CmdBuf:blob, +Device:blob) is det
Acquire a command buffer for the current frame. Commands are recorded into it, then submitted to the GPU. The command buffer may only be used on the thread that acquired it.

RAII: if a command buffer blob is GC'd without being submitted (e.g. an exception discarded it mid-frame), the foreign destroy hook calls SDL_CancelGPUCommandBuffer to prevent a leak. After a successful submit the blob is marked consumed so the cancel path is not triggered. The blob holds a parent ref to the device, pinning it against GC for the command buffer's lifetime (mirrors SDLRendererBlob -> SDLWindowBlob).

Submitting an already-submitted/cancelled command buffer raises existence_error(command_buffer, CmdBuf).

See also
- https://wiki.libsdl.org/SDL3/SDL_AcquireGPUCommandBuffer
  465sdl_acquiregpucommandbuffer(CmdBuf, Device) :-
  466   must_be(var, CmdBuf),
  467   must_be(sdl_gpu_device_blob, Device),
  468   sdl_acquiregpucommandbuffer_(CmdBuf, Device).
 sdl_submitgpucommandbuffer(+CmdBuf:blob) is det
Submits the command buffer to the GPU for execution. After submission the command buffer pointer is invalid; the blob is marked consumed so its destructor does not cancel an already-submitted buffer. Submitting an already-submitted/cancelled command buffer raises existence_error(command_buffer, CmdBuf).
See also
- https://wiki.libsdl.org/SDL3/SDL_SubmitGPUCommandBuffer
  480sdl_submitgpucommandbuffer(CmdBuf) :-
  481   must_be(sdl_gpu_cmdbuf_blob, CmdBuf),
  482   sdl_submitgpucommandbuffer_(CmdBuf).
  483
  484% sdl_cancelgpucommandbuffer/1 is the explicit counterpart to the implicit
  485% cancel that the blob destructor performs on unsubmitted command buffers
  486% during GC.  Use it to discard a command buffer early (e.g. a frame aborted
  487% by a logic error) rather than waiting for GC.  After cancel the command
  488% buffer is invalid; the blob is marked consumed so the destructor does not
  489% cancel again.  Cancelling an already-submitted/cancelled buffer raises
  490% existence_error(command_buffer, CmdBuf).
 sdl_cancelgpucommandbuffer(+CmdBuf:blob) is det
Cancels a command buffer acquired with sdl_acquiregpucommandbuffer/2, discarding any recorded commands. CmdBuf is consumed; after this call the buffer is invalid. Cancelling an already-submitted/cancelled buffer raises existence_error(command_buffer, CmdBuf).
See also
- https://wiki.libsdl.org/SDL3/SDL_CancelGPUCommandBuffer
  501sdl_cancelgpucommandbuffer(CmdBuf) :-
  502   must_be(sdl_gpu_cmdbuf_blob, CmdBuf),
  503   sdl_cancelgpucommandbuffer_(CmdBuf).
  504
  505% --- SDL_gpu: swapchain texture ---------------------------------------------
  506% A swapchain texture is the render target that will be presented to the
  507% screen when the command buffer is submitted.  It is acquired each frame
  508% from a command buffer + claimed window.  The texture is managed by SDL
  509% (must not be freed), valid only within the command buffer that acquired
  510% it, and write-only.
  511%
  512% The texture may be `null` (e.g. window minimized, or too many frames in
  513% flight for the non-blocking variant).  This is not an error — skip
  514% rendering that frame.  After acquiring a swapchain texture it is an error
  515% to cancel the command buffer; submit it instead (SDL handles presentation).
  516%
  517% The blob is a non-owning view (like PtrBlob): destroy() does not free the
  518% texture.  It holds a parent ref to the command buffer, preventing GC from
  519% auto-cancelling the command buffer while a swapchain texture view is live.
 sdl_acquiregpuswapchaintexture(+CmdBuf:blob, +Window:blob, -Texture:null;blob, -Width:integer, -Height:integer) is det
Acquires the swapchain texture for the current frame (non-blocking). Texture may be the atom null when the window is minimized or too many frames are in flight — this is not an error; skip rendering that frame and submit the empty command buffer. The texture is managed by SDL (must not be freed) and is valid only within CmdBuf. After acquiring a swapchain texture, submit the command buffer rather than cancelling it (SDL handles presentation).
See also
- https://wiki.libsdl.org/SDL3/SDL_AcquireGPUSwapchainTexture
  533sdl_acquiregpuswapchaintexture(CmdBuf, Window, Texture, W, H) :-
  534   must_be(sdl_gpu_cmdbuf_blob, CmdBuf),
  535   must_be(sdl_window_blob, Window),
  536   must_be(var, Texture),
  537   must_be(var, W),
  538   must_be(var, H),
  539   sdl_acquiregpuswapchaintexture_(CmdBuf, Window, Texture, W, H).
 sdl_waitandacquiregpuswapchaintexture(+CmdBuf:blob, +Window:blob, -Texture:null;blob, -Width:integer, -Height:integer) is det
Blocking variant of sdl_acquiregpuswapchaintexture/5: waits until a swapchain texture is available, then acquires it. Texture may still be the atom null when the window is minimized — this is not an error; skip rendering that frame and submit the empty command buffer. The texture is managed by SDL (must not be freed) and is valid only within CmdBuf. After acquiring a swapchain texture, submit the command buffer rather than cancelling it (SDL handles presentation).
See also
- https://wiki.libsdl.org/SDL3/SDL_WaitAndAcquireGPUSwapchainTexture
  553sdl_waitandacquiregpuswapchaintexture(CmdBuf, Window, Texture, W, H) :-
  554   must_be(sdl_gpu_cmdbuf_blob, CmdBuf),
  555   must_be(sdl_window_blob, Window),
  556   must_be(var, Texture),
  557   must_be(var, W),
  558   must_be(var, H),
  559   sdl_waitandacquiregpuswapchaintexture_(CmdBuf, Window, Texture, W, H).
  560
  561% --- SDL_gpu: enum/flag tables ----------------------------------------------
  562% SDL_GPULoadOp controls what happens to the render target's previous
  563% contents at the start of a render pass.  SDL_GPUStoreOp controls what
  564% happens to the render pass results at the end.
 sdl_gpu_load_op(?LoadOp:atom, ?Value:integer) is nondet
Enumerate SDL_GPULoadOp values. Each flag is a Prolog atom linked to its SDL enum value.

The user-facing load-op atoms are:

See also
- https://wiki.libsdl.org/SDL3/SDL_GPULoadOp
  578sdl_gpu_load_op(load, 0).
  579sdl_gpu_load_op(clear, 1).
  580sdl_gpu_load_op(dont_care, 2).
 sdl_gpu_store_op(?StoreOp:atom, ?Value:integer) is nondet
Enumerate SDL_GPUStoreOp values. Each flag is a Prolog atom linked to its SDL enum value.

The user-facing store-op atoms are:

See also
- https://wiki.libsdl.org/SDL3/SDL_GPUStoreOp
  595sdl_gpu_store_op(store, 0).
  596sdl_gpu_store_op(dont_care, 1).
  597sdl_gpu_store_op(resolve, 2).
  598sdl_gpu_store_op(resolve_and_store, 3).
 sdl_gpu_texture_type(?Type:atom, ?Value:integer) is nondet
Enumerate SDL_GPUTextureType values. Each flag is a Prolog atom linked to its SDL enum value.

The user-facing texture-type atoms are:

See also
- https://wiki.libsdl.org/SDL3/SDL_GPUTextureType
  614sdl_gpu_texture_type('2d',         0).
  615sdl_gpu_texture_type('2d_array',   1).
  616sdl_gpu_texture_type('3d',         2).
  617sdl_gpu_texture_type(cube,       3).
  618sdl_gpu_texture_type(cube_array, 4).
 sdl_gpu_texture_usage(?Usage:atom, ?Value:integer) is nondet
Enumerate SDL_GPUTextureUsageFlag values. Each flag is a Prolog atom linked to its SDL bit-mask value; a list of these atoms may be combined into a single mask where used.

The user-facing texture-usage atoms are:

See also
- https://wiki.libsdl.org/SDL3/SDL_GPUTextureUsageFlags
  637sdl_gpu_texture_usage(sampler,                                 0x00000001).
  638sdl_gpu_texture_usage(color_target,                            0x00000002).
  639sdl_gpu_texture_usage(depth_stencil_target,                    0x00000004).
  640sdl_gpu_texture_usage(graphics_storage_read,                   0x00000008).
  641sdl_gpu_texture_usage(compute_storage_read,                    0x00000010).
  642sdl_gpu_texture_usage(compute_storage_write,                   0x00000020).
  643sdl_gpu_texture_usage(compute_storage_simultaneous_read_write, 0x00000040).
 sdl_gpu_sample_count(?Count:integer, ?Value:integer) is nondet
Enumerate SDL_GPUSampleCount values. Each flag is a Prolog integer linked to its SDL enum value.

The user-facing sample-count values are:

See also
- https://wiki.libsdl.org/SDL3/SDL_GPUSampleCount
  658sdl_gpu_sample_count(1, 0).
  659sdl_gpu_sample_count(2, 1).
  660sdl_gpu_sample_count(4, 2).
  661sdl_gpu_sample_count(8, 3).
 sdl_gpu_texture_format(?Format:atom, ?Value:integer) is nondet
Enumerate SDL_GPUTextureFormat values. Each Format is a Prolog atom linked to its SDL enum value. Generated from SDL_gpu.h.

The user-facing texture-format atoms are:

See also
- https://wiki.libsdl.org/SDL3/SDL_GPUTextureFormat sdl_gpu_texture_format/2 — maps SDL_GPUTextureFormat enum values.
  777sdl_gpu_texture_format(invalid, 0).
  778sdl_gpu_texture_format(a8_unorm, 1).
  779sdl_gpu_texture_format(r8_unorm, 2).
  780sdl_gpu_texture_format(r8g8_unorm, 3).
  781sdl_gpu_texture_format(r8g8b8a8_unorm, 4).
  782sdl_gpu_texture_format(r16_unorm, 5).
  783sdl_gpu_texture_format(r16g16_unorm, 6).
  784sdl_gpu_texture_format(r16g16b16a16_unorm, 7).
  785sdl_gpu_texture_format(r10g10b10a2_unorm, 8).
  786sdl_gpu_texture_format(b5g6r5_unorm, 9).
  787sdl_gpu_texture_format(b5g5r5a1_unorm, 10).
  788sdl_gpu_texture_format(b4g4r4a4_unorm, 11).
  789sdl_gpu_texture_format(b8g8r8a8_unorm, 12).
  790sdl_gpu_texture_format(bc1_rgba_unorm, 13).
  791sdl_gpu_texture_format(bc2_rgba_unorm, 14).
  792sdl_gpu_texture_format(bc3_rgba_unorm, 15).
  793sdl_gpu_texture_format(bc4_r_unorm, 16).
  794sdl_gpu_texture_format(bc5_rg_unorm, 17).
  795sdl_gpu_texture_format(bc7_rgba_unorm, 18).
  796sdl_gpu_texture_format(bc6h_rgb_float, 19).
  797sdl_gpu_texture_format(bc6h_rgb_ufloat, 20).
  798sdl_gpu_texture_format(r8_snorm, 21).
  799sdl_gpu_texture_format(r8g8_snorm, 22).
  800sdl_gpu_texture_format(r8g8b8a8_snorm, 23).
  801sdl_gpu_texture_format(r16_snorm, 24).
  802sdl_gpu_texture_format(r16g8_snorm, 25).
  803sdl_gpu_texture_format(r16g16b16a16_snorm, 26).
  804sdl_gpu_texture_format(r16_float, 27).
  805sdl_gpu_texture_format(r16g16_float, 28).
  806sdl_gpu_texture_format(r16g16b16a16_float, 29).
  807sdl_gpu_texture_format(r32_float, 30).
  808sdl_gpu_texture_format(r32g32_float, 31).
  809sdl_gpu_texture_format(r32g32b32a32_float, 32).
  810sdl_gpu_texture_format(r11g11b10_ufloat, 33).
  811sdl_gpu_texture_format(r8_uint, 34).
  812sdl_gpu_texture_format(r8g8_uint, 35).
  813sdl_gpu_texture_format(r8g8b8a8_uint, 36).
  814sdl_gpu_texture_format(r16_uint, 37).
  815sdl_gpu_texture_format(r16g16_uint, 38).
  816sdl_gpu_texture_format(r16g16b16a16_uint, 39).
  817sdl_gpu_texture_format(r32_uint, 40).
  818sdl_gpu_texture_format(r32g32_uint, 41).
  819sdl_gpu_texture_format(r32g32b32a32_uint, 42).
  820sdl_gpu_texture_format(r8_int, 43).
  821sdl_gpu_texture_format(r8g8_int, 44).
  822sdl_gpu_texture_format(r8g8b8a8_int, 45).
  823sdl_gpu_texture_format(r16_int, 46).
  824sdl_gpu_texture_format(r16g16_int, 47).
  825sdl_gpu_texture_format(r16g16b16a16_int, 48).
  826sdl_gpu_texture_format(r32_int, 49).
  827sdl_gpu_texture_format(r32g32_int, 50).
  828sdl_gpu_texture_format(r32g32b32a32_int, 51).
  829sdl_gpu_texture_format(r8g8b8a8_unorm_srgb, 52).
  830sdl_gpu_texture_format(b8g8r8a8_unorm_srgb, 53).
  831sdl_gpu_texture_format(bc1_rgba_unorm_srgb, 54).
  832sdl_gpu_texture_format(bc2_rgba_unorm_srgb, 55).
  833sdl_gpu_texture_format(bc3_rgba_unorm_srgb, 56).
  834sdl_gpu_texture_format(bc7_rgba_unorm_srgb, 57).
  835sdl_gpu_texture_format(d16_unorm, 58).
  836sdl_gpu_texture_format(d24_unorm, 59).
  837sdl_gpu_texture_format(d32_float, 60).
  838sdl_gpu_texture_format(d24_unorm_s8_uint, 61).
  839sdl_gpu_texture_format(d32_float_s8_uint, 62).
  840sdl_gpu_texture_format(astc_4x4_unorm, 63).
  841sdl_gpu_texture_format(astc_5x4_unorm, 64).
  842sdl_gpu_texture_format(astc_5x5_unorm, 65).
  843sdl_gpu_texture_format(astc_6x5_unorm, 66).
  844sdl_gpu_texture_format(astc_6x6_unorm, 67).
  845sdl_gpu_texture_format(astc_8x5_unorm, 68).
  846sdl_gpu_texture_format(astc_8x6_unorm, 69).
  847sdl_gpu_texture_format(astc_8x8_unorm, 70).
  848sdl_gpu_texture_format(astc_10x5_unorm, 71).
  849sdl_gpu_texture_format(astc_10x6_unorm, 72).
  850sdl_gpu_texture_format(astc_10x8_unorm, 73).
  851sdl_gpu_texture_format(astc_10x10_unorm, 74).
  852sdl_gpu_texture_format(astc_12x10_unorm, 75).
  853sdl_gpu_texture_format(astc_12x12_unorm, 76).
  854sdl_gpu_texture_format(astc_4x4_unorm_srgb, 77).
  855sdl_gpu_texture_format(astc_5x4_unorm_srgb, 78).
  856sdl_gpu_texture_format(astc_5x5_unorm_srgb, 79).
  857sdl_gpu_texture_format(astc_6x5_unorm_srgb, 80).
  858sdl_gpu_texture_format(astc_6x6_unorm_srgb, 81).
  859sdl_gpu_texture_format(astc_8x5_unorm_srgb, 82).
  860sdl_gpu_texture_format(astc_8x6_unorm_srgb, 83).
  861sdl_gpu_texture_format(astc_8x8_unorm_srgb, 84).
  862sdl_gpu_texture_format(astc_10x5_unorm_srgb, 85).
  863sdl_gpu_texture_format(astc_10x6_unorm_srgb, 86).
  864sdl_gpu_texture_format(astc_10x8_unorm_srgb, 87).
  865sdl_gpu_texture_format(astc_10x10_unorm_srgb, 88).
  866sdl_gpu_texture_format(astc_12x10_unorm_srgb, 89).
  867sdl_gpu_texture_format(astc_12x12_unorm_srgb, 90).
  868sdl_gpu_texture_format(astc_4x4_float, 91).
  869sdl_gpu_texture_format(astc_5x4_float, 92).
  870sdl_gpu_texture_format(astc_5x5_float, 93).
  871sdl_gpu_texture_format(astc_6x5_float, 94).
  872sdl_gpu_texture_format(astc_6x6_float, 95).
  873sdl_gpu_texture_format(astc_8x5_float, 96).
  874sdl_gpu_texture_format(astc_8x6_float, 97).
  875sdl_gpu_texture_format(astc_8x8_float, 98).
  876sdl_gpu_texture_format(astc_10x5_float, 99).
  877sdl_gpu_texture_format(astc_10x6_float, 100).
  878sdl_gpu_texture_format(astc_10x8_float, 101).
  879sdl_gpu_texture_format(astc_10x10_float, 102).
  880sdl_gpu_texture_format(astc_12x10_float, 103).
  881sdl_gpu_texture_format(astc_12x12_float, 104).
 sdl_gpu_shader_stage(?Stage:atom, ?Value:integer) is nondet
Enumerate SDL_GPUShaderStage values. Each flag is a Prolog atom linked to its SDL enum value.

The user-facing shader-stage atoms are:

See also
- https://wiki.libsdl.org/SDL3/SDL_GPUShaderStage
  894sdl_gpu_shader_stage(vertex, 0).
  895sdl_gpu_shader_stage(fragment, 1).
 sdl_gpu_primitive_type(?Type:atom, ?Value:integer) is nondet
Enumerate SDL_GPUPrimitiveType values. Each flag is a Prolog atom linked to its SDL enum value.

The user-facing primitive-type atoms are:

See also
- https://wiki.libsdl.org/SDL3/SDL_GPUPrimitiveType
  911sdl_gpu_primitive_type(trianglelist, 0).
  912sdl_gpu_primitive_type(trianglestrip, 1).
  913sdl_gpu_primitive_type(linelist, 2).
  914sdl_gpu_primitive_type(linestrip, 3).
  915sdl_gpu_primitive_type(pointlist, 4).
 sdl_gpu_fill_mode(?Mode:atom, ?Value:integer) is nondet
Enumerate SDL_GPUFillMode values. Each flag is a Prolog atom linked to its SDL enum value.

The user-facing fill-mode atoms are:

See also
- https://wiki.libsdl.org/SDL3/SDL_GPUFillMode
  928sdl_gpu_fill_mode(fill, 0).
  929sdl_gpu_fill_mode(line, 1).
 sdl_gpu_cull_mode(?Mode:atom, ?Value:integer) is nondet
Enumerate SDL_GPUCullMode values. Each flag is a Prolog atom linked to its SDL enum value.

The user-facing cull-mode atoms are:

See also
- https://wiki.libsdl.org/SDL3/SDL_GPUCullMode
  943sdl_gpu_cull_mode(none, 0).
  944sdl_gpu_cull_mode(front, 1).
  945sdl_gpu_cull_mode(back, 2).
 sdl_gpu_front_face(?Face:atom, ?Value:integer) is nondet
Enumerate SDL_GPUFrontFace values. Each flag is a Prolog atom linked to its SDL enum value.

The user-facing front-face atoms are:

See also
- https://wiki.libsdl.org/SDL3/SDL_GPUFrontFace
  958sdl_gpu_front_face(counter_clockwise, 0).
  959sdl_gpu_front_face(clockwise, 1).
 sdl_gpu_compare_op(?Op:atom, ?Value:integer) is nondet
Enumerate SDL_GPUCompareOp values. Each flag is a Prolog atom linked to its SDL enum value.

The user-facing compare-op atoms are:

See also
- https://wiki.libsdl.org/SDL3/SDL_GPUCompareOp
  979sdl_gpu_compare_op(invalid, 0).
  980sdl_gpu_compare_op(never, 1).
  981sdl_gpu_compare_op(less, 2).
  982sdl_gpu_compare_op(equal, 3).
  983sdl_gpu_compare_op(less_or_equal, 4).
  984sdl_gpu_compare_op(greater, 5).
  985sdl_gpu_compare_op(not_equal, 6).
  986sdl_gpu_compare_op(greater_or_equal, 7).
  987sdl_gpu_compare_op(always, 8).
 sdl_gpu_stencil_op(?Op:atom, ?Value:integer) is nondet
Enumerate SDL_GPUStencilOp values. Each flag is a Prolog atom linked to its SDL enum value.

The user-facing stencil-op atoms are:

See also
- https://wiki.libsdl.org/SDL3/SDL_GPUStencilOp
 1007sdl_gpu_stencil_op(invalid, 0).
 1008sdl_gpu_stencil_op(keep, 1).
 1009sdl_gpu_stencil_op(zero, 2).
 1010sdl_gpu_stencil_op(replace, 3).
 1011sdl_gpu_stencil_op(increment_and_clamp, 4).
 1012sdl_gpu_stencil_op(decrement_and_clamp, 5).
 1013sdl_gpu_stencil_op(invert, 6).
 1014sdl_gpu_stencil_op(increment_and_wrap, 7).
 1015sdl_gpu_stencil_op(decrement_and_wrap, 8).
 sdl_gpu_blend_op(?Op:atom, ?Value:integer) is nondet
Enumerate SDL_GPUBlendOp values. Each flag is a Prolog atom linked to its SDL enum value.

The user-facing blend-op atoms are:

See also
- https://wiki.libsdl.org/SDL3/SDL_GPUBlendOp
 1032sdl_gpu_blend_op(invalid, 0).
 1033sdl_gpu_blend_op(add, 1).
 1034sdl_gpu_blend_op(subtract, 2).
 1035sdl_gpu_blend_op(reverse_subtract, 3).
 1036sdl_gpu_blend_op(min, 4).
 1037sdl_gpu_blend_op(max, 5).
 sdl_gpu_blend_factor(?Factor:atom, ?Value:integer) is nondet
Enumerate SDL_GPUBlendFactor values. Each flag is a Prolog atom linked to its SDL enum value.

The user-facing blend-factor atoms are:

See also
- https://wiki.libsdl.org/SDL3/SDL_GPUBlendFactor
 1062sdl_gpu_blend_factor(invalid, 0).
 1063sdl_gpu_blend_factor(zero, 1).
 1064sdl_gpu_blend_factor(one, 2).
 1065sdl_gpu_blend_factor(src_color, 3).
 1066sdl_gpu_blend_factor(one_minus_src_color, 4).
 1067sdl_gpu_blend_factor(dst_color, 5).
 1068sdl_gpu_blend_factor(one_minus_dst_color, 6).
 1069sdl_gpu_blend_factor(src_alpha, 7).
 1070sdl_gpu_blend_factor(one_minus_src_alpha, 8).
 1071sdl_gpu_blend_factor(dst_alpha, 9).
 1072sdl_gpu_blend_factor(one_minus_dst_alpha, 10).
 1073sdl_gpu_blend_factor(constant_color, 11).
 1074sdl_gpu_blend_factor(one_minus_constant_color, 12).
 1075sdl_gpu_blend_factor(src_alpha_saturate, 13).
 sdl_gpu_vertex_input_rate(?Rate:atom, ?Value:integer) is nondet
Enumerate SDL_GPUVertexInputRate values. Each flag is a Prolog atom linked to its SDL enum value.

The user-facing vertex-input-rate atoms are:

See also
- https://wiki.libsdl.org/SDL3/SDL_GPUVertexInputRate
 1088sdl_gpu_vertex_input_rate(vertex, 0).
 1089sdl_gpu_vertex_input_rate(instance, 1).
 sdl_gpu_vertex_element_format(?Format:atom, ?Value:integer) is nondet
Enumerate SDL_GPUVertexElementFormat values. Each Format is a Prolog atom linked to its SDL enum value.

The user-facing vertex-element-format atoms are:

See also
- https://wiki.libsdl.org/SDL3/SDL_GPUVertexElementFormat sdl_gpu_vertex_element_format/2 — maps SDL_GPUVertexElementFormat enum values (sequential from 0).
 1132sdl_gpu_vertex_element_format(invalid, 0).
 1133sdl_gpu_vertex_element_format(int, 1).
 1134sdl_gpu_vertex_element_format(int2, 2).
 1135sdl_gpu_vertex_element_format(int3, 3).
 1136sdl_gpu_vertex_element_format(int4, 4).
 1137sdl_gpu_vertex_element_format(uint, 5).
 1138sdl_gpu_vertex_element_format(uint2, 6).
 1139sdl_gpu_vertex_element_format(uint3, 7).
 1140sdl_gpu_vertex_element_format(uint4, 8).
 1141sdl_gpu_vertex_element_format(float, 9).
 1142sdl_gpu_vertex_element_format(float2, 10).
 1143sdl_gpu_vertex_element_format(float3, 11).
 1144sdl_gpu_vertex_element_format(float4, 12).
 1145sdl_gpu_vertex_element_format(byte2, 13).
 1146sdl_gpu_vertex_element_format(byte4, 14).
 1147sdl_gpu_vertex_element_format(ubyte2, 15).
 1148sdl_gpu_vertex_element_format(ubyte4, 16).
 1149sdl_gpu_vertex_element_format(byte2_norm, 17).
 1150sdl_gpu_vertex_element_format(byte4_norm, 18).
 1151sdl_gpu_vertex_element_format(ubyte2_norm, 19).
 1152sdl_gpu_vertex_element_format(ubyte4_norm, 20).
 1153sdl_gpu_vertex_element_format(short2, 21).
 1154sdl_gpu_vertex_element_format(short4, 22).
 1155sdl_gpu_vertex_element_format(ushort2, 23).
 1156sdl_gpu_vertex_element_format(ushort4, 24).
 1157sdl_gpu_vertex_element_format(short2_norm, 25).
 1158sdl_gpu_vertex_element_format(short4_norm, 26).
 1159sdl_gpu_vertex_element_format(ushort2_norm, 27).
 1160sdl_gpu_vertex_element_format(ushort4_norm, 28).
 1161sdl_gpu_vertex_element_format(half2, 29).
 1162sdl_gpu_vertex_element_format(half4, 30).
 sdl_gpu_color_component(?Component:atom, ?Value:integer) is nondet
Enumerate SDL_GPUColorComponentFlag values. Each flag is a Prolog atom linked to its SDL bit-mask value; a list of these atoms may be combined into a single mask where used.

The user-facing color-component atoms are:

See also
- https://wiki.libsdl.org/SDL3/SDL_GPUColorComponent
 1178sdl_gpu_color_component(r, 0x01).
 1179sdl_gpu_color_component(g, 0x02).
 1180sdl_gpu_color_component(b, 0x04).
 1181sdl_gpu_color_component(a, 0x08).
 1182
 1183% --- SDL_gpu: struct records ------------------------------------------------
 1184% The following records map 1-to-1 to SDL_gpu structs.  Field order matches
 1185% the C struct (the foreign layer reads by position).  Field types are
 1186% checked automatically by is_<record>/1 (generated by library(record)).
 1187% Use make_<record>([field(Value), ...], Record) for partial construction
 1188% with defaults; unspecified fields get their default values.
 1189
 1190% SDL_GPUColorTargetInfo
 1191:- record color_target(
 1192   texture:sdl_gpu_texture,                                       % required
 1193   mip_level:nonneg=0,
 1194   layer_or_depth_plane:nonneg=0,
 1195   clear_color:fcolor=fcolor(0.0,0.0,0.0,1.0),
 1196   load_op:sdl_gpu_load_op,                                       % required
 1197   store_op:sdl_gpu_store_op,                                     % required
 1198   resolve_texture:(oneof([null]);sdl_gpu_texture)=null,
 1199   resolve_mip_level:nonneg=0,
 1200   resolve_layer:nonneg=0,
 1201   cycle:boolean=false,
 1202   cycle_resolve_texture:boolean=false
 1203).
 1204
 1205% SDL_GPUDepthStencilTargetInfo
 1206:- record depth_stencil_target(
 1207   texture:sdl_gpu_texture,                                       % required
 1208   clear_depth:number=1.0,
 1209   load_op:sdl_gpu_load_op,                                       % required
 1210   store_op:sdl_gpu_store_op,                                     % required
 1211   stencil_load_op:sdl_gpu_load_op=dont_care,
 1212   stencil_store_op:sdl_gpu_store_op=dont_care,
 1213   cycle:boolean=false,
 1214   clear_stencil:between(0,255)=0,
 1215   mip_level:between(0,255)=0,
 1216   layer:between(0,255)=0
 1217).
 1218
 1219% SDL_GPUTextureCreateInfo (props is always 0, omitted)
 1220:- record gpu_texture_create_info(
 1221   type:sdl_gpu_texture_type='2d',
 1222   format:sdl_gpu_texture_format,                                 % required
 1223   usage:list(sdl_gpu_texture_usage),                             % required
 1224   width:nonneg,                                                  % required
 1225   height:nonneg,                                                 % required
 1226   layer_count_or_depth:nonneg=1,
 1227   num_levels:nonneg=1,
 1228   sample_count:sdl_gpu_sample_count=1
 1229).
 1230
 1231% SDL_GPUShaderCreateInfo (props is always 0, omitted).  Code is a Prolog
 1232% string containing raw shader bytecode (e.g. SPIR-V for Vulkan).  Read it
 1233% from a .spv file with read_file_to_string(File, Code, [type(binary)]).
 1234:- record gpu_shader_create_info(
 1235   code:string,                                                   % required
 1236   entrypoint:string="main",
 1237   format:sdl_gpu_shader_format,                                  % required
 1238   stage:sdl_gpu_shader_stage,                                    % required
 1239   num_samplers:nonneg=0,
 1240   num_storage_textures:nonneg=0,
 1241   num_storage_buffers:nonneg=0,
 1242   num_uniform_buffers:nonneg=0
 1243).
 1244
 1245% --- Graphics pipeline nested structs ---
 1246
 1247% SDL_GPUVertexBufferDescription
 1248:- record vertex_buffer_description(
 1249   slot:nonneg=0,
 1250   pitch:nonneg,
 1251   input_rate:sdl_gpu_vertex_input_rate=vertex,
 1252   instance_step_rate:nonneg=0
 1253).
 1254
 1255% SDL_GPUVertexAttribute
 1256:- record vertex_attribute(
 1257   location:nonneg,
 1258   buffer_slot:nonneg=0,
 1259   format:sdl_gpu_vertex_element_format,
 1260   offset:nonneg=0
 1261).
 1262
 1263% SDL_GPUStencilOpState.  Defaults match SDL's zero-initialization (invalid=0).
 1264% When enable_stencil_test is false these values are ignored.
 1265:- record stencil_op_state(
 1266   fail_op:sdl_gpu_stencil_op=invalid,
 1267   pass_op:sdl_gpu_stencil_op=invalid,
 1268   depth_fail_op:sdl_gpu_stencil_op=invalid,
 1269   compare_op:sdl_gpu_compare_op=invalid
 1270).
 1271
 1272% SDL_GPUColorTargetBlendState
 1273:- record color_target_blend_state(
 1274   src_color_blendfactor:sdl_gpu_blend_factor=one,
 1275   dst_color_blendfactor:sdl_gpu_blend_factor=zero,
 1276   color_blend_op:sdl_gpu_blend_op=add,
 1277   src_alpha_blendfactor:sdl_gpu_blend_factor=one,
 1278   dst_alpha_blendfactor:sdl_gpu_blend_factor=zero,
 1279   alpha_blend_op:sdl_gpu_blend_op=add,
 1280   color_write_mask:list(sdl_gpu_color_component)=[r,g,b,a],
 1281   enable_blend:boolean=false,
 1282   enable_color_write_mask:boolean=false
 1283).
 1284
 1285% SDL_GPUColorTargetDescription
 1286:- record color_target_description(
 1287   format:sdl_gpu_texture_format,
 1288   blend_state:color_target_blend_state
 1289).
 1290
 1291% SDL_GPUVertexInputState (no pointer fields; lists are inlined)
 1292:- record vertex_input_state(
 1293   vertex_buffer_descriptions:list(vertex_buffer_description)=[],
 1294   vertex_attributes:list(vertex_attribute)=[]
 1295).
 1296
 1297% SDL_GPURasterizerState
 1298:- record rasterizer_state(
 1299   fill_mode:sdl_gpu_fill_mode=fill,
 1300   cull_mode:sdl_gpu_cull_mode=none,
 1301   front_face:sdl_gpu_front_face=counter_clockwise,
 1302   depth_bias_constant_factor:number=0.0,
 1303   depth_bias_clamp:number=0.0,
 1304   depth_bias_slope_factor:number=0.0,
 1305   enable_depth_bias:boolean=false,
 1306   enable_depth_clip:boolean=true
 1307).
 1308
 1309% SDL_GPUMultisampleState
 1310:- record multisample_state(
 1311   sample_count:sdl_gpu_sample_count=1,
 1312   sample_mask:nonneg=0,
 1313   enable_mask:boolean=false,
 1314   enable_alpha_to_coverage:boolean=false
 1315).
 1316
 1317% SDL_GPUDepthStencilState
 1318:- record depth_stencil_state(
 1319   compare_op:sdl_gpu_compare_op=less,
 1320   back_stencil_state:stencil_op_state,
 1321   front_stencil_state:stencil_op_state,
 1322   compare_mask:between(0,255)=255,
 1323   write_mask:between(0,255)=255,
 1324   enable_depth_test:boolean=false,
 1325   enable_depth_write:boolean=true,
 1326   enable_stencil_test:boolean=false
 1327).
 1328
 1329% SDL_GPUGraphicsPipelineTargetInfo.  depth_stencil_format defaults to
 1330% invalid (0) — it is ignored when has_depth_stencil_target is false.
 1331:- record target_info(
 1332   color_target_descriptions:list(color_target_description)=[],
 1333   depth_stencil_format:sdl_gpu_texture_format=invalid,
 1334   has_depth_stencil_target:boolean=false
 1335).
 1336
 1337% SDL_GPUGraphicsPipelineCreateInfo (props is always 0, omitted)
 1338:- record gpu_graphics_pipeline_create_info(
 1339   vertex_shader:sdl_gpu_shader_blob,
 1340   fragment_shader:sdl_gpu_shader_blob,
 1341   vertex_input_state:vertex_input_state,
 1342   primitive_type:sdl_gpu_primitive_type=trianglelist,
 1343   rasterizer_state:rasterizer_state,
 1344   multisample_state:multisample_state,
 1345   depth_stencil_state:depth_stencil_state,
 1346   target_info:target_info
 1347).
 1348
 1349% SDL_GPUBufferBinding — used for binding vertex and index buffers.
 1350:- record buffer_binding(
 1351   buffer:sdl_gpu_buffer_blob,
 1352   offset:nonneg=0
 1353).
 1354
 1355% SDL_GPUTransferBufferLocation — source for SDL_UploadToGPUBuffer.
 1356:- record transfer_buffer_location(
 1357   transfer_buffer:sdl_gpu_transfer_buffer_blob,
 1358   offset:nonneg=0
 1359).
 1360
 1361% SDL_GPUBufferRegion — destination for SDL_UploadToGPUBuffer.
 1362:- record buffer_region(
 1363   buffer:sdl_gpu_buffer_blob,
 1364   offset:nonneg=0,
 1365   size:nonneg
 1366).
 1367
 1368% Type aliases backed by the generated is_*/1 predicates.
 1369error:has_type(sdl_gpu_color_target, X) :- is_color_target(X).
 1370error:has_type(sdl_gpu_depth_stencil_target, X) :- is_depth_stencil_target(X).
 1371error:has_type(sdl_gpu_texture_create_info, X) :- is_gpu_texture_create_info(X).
 1372error:has_type(sdl_gpu_shader_create_info, X) :- is_gpu_shader_create_info(X).
 1373error:has_type(vertex_buffer_description, X) :- is_vertex_buffer_description(X).
 1374error:has_type(vertex_attribute, X) :- is_vertex_attribute(X).
 1375error:has_type(stencil_op_state, X) :- is_stencil_op_state(X).
 1376error:has_type(color_target_blend_state, X) :- is_color_target_blend_state(X).
 1377error:has_type(color_target_description, X) :- is_color_target_description(X).
 1378error:has_type(vertex_input_state, X) :- is_vertex_input_state(X).
 1379error:has_type(rasterizer_state, X) :- is_rasterizer_state(X).
 1380error:has_type(multisample_state, X) :- is_multisample_state(X).
 1381error:has_type(depth_stencil_state, X) :- is_depth_stencil_state(X).
 1382error:has_type(target_info, X) :- is_target_info(X).
 1383error:has_type(sdl_gpu_graphics_pipeline_create_info, X) :- is_gpu_graphics_pipeline_create_info(X).
 1384error:has_type(buffer_binding, X) :- is_buffer_binding(X).
 1385error:has_type(transfer_buffer_location, X) :- is_transfer_buffer_location(X).
 1386error:has_type(buffer_region, X) :- is_buffer_region(X).
 1387
 1388% --- SDL_gpu: render pass ---------------------------------------------------
 1389% A render pass targets one or more color textures (typically the swapchain
 1390% texture) and optionally a depth-stencil texture.  All graphics operations
 1391% must take place inside a render pass.  ColorTargets is a list of
 1392% color_target records.  DepthStencil is `null` (no depth-stencil target)
 1393% or a depth_stencil_target record.
 1394%
 1395% RAII: the render pass blob holds a parent ref to the command buffer.  If
 1396% GC'd without being explicitly ended, destroy() calls SDL_EndGPURenderPass
 1397% as a safety net.  After explicit end the blob is marked consumed.  Ending
 1398% an already-ended render pass raises existence_error(render_pass, Pass).
 sdl_begingpurenderpass(-RenderPass:blob, +CmdBuf:blob, +ColorTargets:list(sdl_gpu_color_target), +DepthStencil:null;depth_stencil_target) is det
Begins a render pass on CmdBuf, targeting one or more color textures (typically the swapchain texture) and optionally a depth-stencil texture. All graphics operations must take place inside a render pass, ended with sdl_endgpurenderpass/1. ColorTargets is a list of color_target records; DepthStencil is null or a depth_stencil_target record.

RAII: the render pass blob holds a parent ref to the command buffer. If GC'd without being explicitly ended, the foreign destroy hook calls sdl_endgpurenderpass as a safety net. After explicit end the blob is marked consumed; ending an already-ended render pass raises existence_error(render_pass, Pass).

See also
- https://wiki.libsdl.org/SDL3/SDL_BeginGPURenderPass
 1416sdl_begingpurenderpass(RenderPass, CmdBuf, ColorTargets, DepthStencil) :-
 1417   must_be(var, RenderPass),
 1418   must_be(sdl_gpu_cmdbuf_blob, CmdBuf),
 1419   must_be(list(sdl_gpu_color_target), ColorTargets),
 1420   must_be((oneof([null]) ; sdl_gpu_depth_stencil_target), DepthStencil),
 1421   maplist(color_target_int, ColorTargets, IntTargets),
 1422   depth_stencil_int(DepthStencil, IntDepthStencil),
 1423   sdl_begingpurenderpass_(RenderPass, CmdBuf, IntTargets, IntDepthStencil).
 sdl_endgpurenderpass(+RenderPass:blob) is det
Ends the render pass, marking the render pass blob consumed. After this call RenderPass is invalid. Ending an already-ended render pass raises existence_error(render_pass, Pass).
See also
- https://wiki.libsdl.org/SDL3/SDL_EndGPURenderPass
 1433sdl_endgpurenderpass(RenderPass) :-
 1434   must_be(sdl_gpu_renderpass_blob, RenderPass),
 1435   sdl_endgpurenderpass_(RenderPass).
 1436
 1437% Translate color_target load_op/store_op atoms to ints for the foreign
 1438% predicate.  The compound is reconstructed with int values.
 1439color_target_int(
 1440   color_target(Texture, MipLevel, LayerOrDepthPlane, ClearColor,
 1441                LoadOp, StoreOp, ResolveTexture, ResolveMipLevel,
 1442                ResolveLayer, Cycle, CycleResolveTexture),
 1443   IntTarget) =>
 1444   sdl_gpu_load_op(LoadOp, IntLoadOp),
 1445   sdl_gpu_store_op(StoreOp, IntStoreOp),
 1446   IntTarget = color_target(Texture, MipLevel, LayerOrDepthPlane, ClearColor,
 1447                            IntLoadOp, IntStoreOp, ResolveTexture, ResolveMipLevel,
 1448                            ResolveLayer, Cycle, CycleResolveTexture).
 1449
 1450% Translate depth_stencil_target load/store op atoms to ints.  null passes
 1451% through unchanged.
 1452depth_stencil_int(null, IntTarget) => IntTarget = null.
 1453depth_stencil_int(
 1454   depth_stencil_target(Texture, ClearDepth, LoadOp, StoreOp,
 1455                        StencilLoadOp, StencilStoreOp, Cycle,
 1456                        ClearStencil, MipLevel, Layer),
 1457   IntTarget) =>
 1458   sdl_gpu_load_op(LoadOp, IntLoadOp),
 1459   sdl_gpu_store_op(StoreOp, IntStoreOp),
 1460   sdl_gpu_load_op(StencilLoadOp, IntStencilLoadOp),
 1461   sdl_gpu_store_op(StencilStoreOp, IntStencilStoreOp),
 1462   IntTarget = depth_stencil_target(Texture, ClearDepth, IntLoadOp, IntStoreOp,
 1463                                    IntStencilLoadOp, IntStencilStoreOp, Cycle,
 1464                                    ClearStencil, MipLevel, Layer).
 1465
 1466% --- SDL_gpu: create / release texture --------------------------------------
 1467% Creates a GPU texture (render target, sampler source, storage, etc.) or
 1468% releases it.  The gpu_texture_create_info record maps 1-to-1 to
 1469% SDL_GPUTextureCreateInfo (props is always 0).
 1470%
 1471% The blob is owning: destroy() calls SDL_ReleaseGPUTexture.  It holds a
 1472% parent ref to the device, pinning it against GC.  Releasing an
 1473% already-released texture raises existence_error(texture, Texture).
 sdl_creategputexture(-Texture:blob, +Device:blob, +CreateInfo:sdl_gpu_texture_create_info) is det
Creates a GPU texture (render target, sampler source, storage, etc.). CreateInfo is a gpu_texture_create_info record mapping 1-to-1 to SDL_GPUTextureCreateInfo (props is always 0).

The blob is owning: destroy() calls SDL_ReleaseGPUTexture. It holds a parent ref to the device, pinning it against GC.

See also
- https://wiki.libsdl.org/SDL3/SDL_CreateGPUTexture
 1486sdl_creategputexture(Texture, Device, CreateInfo) :-
 1487   must_be(var, Texture),
 1488   must_be(sdl_gpu_device_blob, Device),
 1489   must_be(sdl_gpu_texture_create_info, CreateInfo),
 1490   texture_create_info_int(CreateInfo, IntCreateInfo),
 1491   sdl_creategputexture_(Texture, Device, IntCreateInfo).
 sdl_releasegputexture(+Texture:blob) is det
Releases a GPU texture created with sdl_creategputexture/3. The blob is marked consumed; after this call Texture is invalid. Releasing an already-released texture raises existence_error(texture, Texture).
See also
- https://wiki.libsdl.org/SDL3/SDL_ReleaseGPUTexture
 1501sdl_releasegputexture(Texture) :-
 1502   must_be(sdl_gpu_texture_blob, Texture),
 1503   sdl_releasegputexture_(Texture).
 1504
 1505% Translate gpu_texture_create_info atoms (Type, Format, Usage, SampleCount)
 1506% to ints for the foreign predicate.  The compound is reconstructed with int
 1507% values.
 1508texture_create_info_int(
 1509   gpu_texture_create_info(Type, Format, Usage, Width, Height,
 1510                           LayerCountOrDepth, NumLevels, SampleCount),
 1511   IntInfo) =>
 1512   sdl_gpu_texture_type(Type, IntType),
 1513   sdl_gpu_texture_format(Format, IntFormat),
 1514   maplist(sdl_gpu_texture_usage, Usage, UsageInts),
 1515   or_list(UsageInts, IntUsage),
 1516   sdl_gpu_sample_count(SampleCount, IntSampleCount),
 1517   IntInfo = gpu_texture_create_info(IntType, IntFormat, IntUsage, Width, Height,
 1518                                     LayerCountOrDepth, NumLevels, IntSampleCount).
 1519
 1520% --- SDL_gpu: create / release shader ---------------------------------------
 1521% Creates a GPU shader from precompiled bytecode (e.g. SPIR-V for Vulkan)
 1522% and releases it.  The gpu_shader_create_info record maps 1-to-1 to
 1523% SDL_GPUShaderCreateInfo (props is always 0).  Code is a Prolog string
 1524% containing raw bytecode — read it from a .spv file with
 1525% read_file_to_string(File, Code, [type(binary)]).
 1526%
 1527% The blob is owning: destroy() calls SDL_ReleaseGPUShader.  It holds a
 1528% parent ref to the device, pinning it against GC.  Releasing an
 1529% already-released shader raises existence_error(shader, Shader).
 sdl_creategpushader(-Shader:blob, +Device:blob, +CreateInfo:sdl_gpu_shader_create_info) is det
Creates a GPU shader from precompiled bytecode (e.g. SPIR-V for Vulkan). CreateInfo is a gpu_shader_create_info record mapping 1-to-1 to SDL_GPUShaderCreateInfo (props is always 0). Code is a Prolog string containing raw bytecode — read it from a .spv file with read_file_to_string(File, Code, [type(binary)]).

The blob is owning: destroy() calls SDL_ReleaseGPUShader. It holds a parent ref to the device, pinning it against GC.

See also
- https://wiki.libsdl.org/SDL3/SDL_CreateGPUShader
 1544sdl_creategpushader(Shader, Device, CreateInfo) :-
 1545   must_be(var, Shader),
 1546   must_be(sdl_gpu_device_blob, Device),
 1547   must_be(sdl_gpu_shader_create_info, CreateInfo),
 1548   shader_create_info_int(CreateInfo, IntCreateInfo),
 1549   sdl_creategpushader_(Shader, Device, IntCreateInfo).
 sdl_releasegpushader(+Shader:blob) is det
Releases a GPU shader created with sdl_creategpushader/3. The blob is marked consumed; after this call Shader is invalid. Releasing an already-released shader raises existence_error(shader, Shader).
See also
- https://wiki.libsdl.org/SDL3/SDL_ReleaseGPUShader
 1559sdl_releasegpushader(Shader) :-
 1560   must_be(sdl_gpu_shader_blob, Shader),
 1561   sdl_releasegpushader_(Shader).
 1562
 1563% Translate gpu_shader_create_info atoms (Format, Stage) to ints for the
 1564% foreign predicate.  Code and Entrypoint are strings, passed through
 1565% unchanged.
 1566shader_create_info_int(
 1567   gpu_shader_create_info(Code, Entrypoint, Format, Stage,
 1568                          NumSamplers, NumStorageTextures,
 1569                          NumStorageBuffers, NumUniformBuffers),
 1570   IntInfo) =>
 1571   sdl_gpu_shader_format(Format, IntFormat),
 1572   sdl_gpu_shader_stage(Stage, IntStage),
 1573   IntInfo = gpu_shader_create_info(Code, Entrypoint, IntFormat, IntStage,
 1574                                    NumSamplers, NumStorageTextures,
 1575                                    NumStorageBuffers, NumUniformBuffers).
 1576
 1577% --- SDL_gpu: create / release graphics pipeline ----------------------------
 1578% Creates a graphics pipeline from a gpu_graphics_pipeline_create_info record
 1579% and releases it.  The record maps 1-to-1 to SDL_GPUGraphicsPipelineCreateInfo
 1580% (props is always 0), with nested records for each sub-struct.
 1581%
 1582% The blob is owning: destroy() calls SDL_ReleaseGPUGraphicsPipeline.  It
 1583% holds a parent ref to the device.  Releasing an already-released pipeline
 1584% raises existence_error(pipeline, Pipeline).
 sdl_creategpugraphicspipeline(-Pipeline:blob, +Device:blob, +CreateInfo:sdl_gpu_graphics_pipeline_create_info) is det
Creates a graphics pipeline. CreateInfo is a gpu_graphics_pipeline_create_info record mapping 1-to-1 to SDL_GPUGraphicsPipelineCreateInfo (props is always 0), with nested records for each sub-struct.

The blob is owning: destroy() calls SDL_ReleaseGPUGraphicsPipeline. It holds a parent ref to the device.

See also
- https://wiki.libsdl.org/SDL3/SDL_CreateGPUGraphicsPipeline
 1598sdl_creategpugraphicspipeline(Pipeline, Device, CreateInfo) :-
 1599   must_be(var, Pipeline),
 1600   must_be(sdl_gpu_device_blob, Device),
 1601   must_be(sdl_gpu_graphics_pipeline_create_info, CreateInfo),
 1602   graphics_pipeline_create_info_int(CreateInfo, IntCreateInfo),
 1603   sdl_creategpugraphicspipeline_(Pipeline, Device, IntCreateInfo).
 sdl_releasegpugraphicspipeline(+Pipeline:blob) is det
Releases a graphics pipeline created with sdl_creategpugraphicspipeline/3. The blob is marked consumed; after this call Pipeline is invalid. Releasing an already-released pipeline raises existence_error(pipeline, Pipeline).
See also
- https://wiki.libsdl.org/SDL3/SDL_ReleaseGPUGraphicsPipeline
 1614sdl_releasegpugraphicspipeline(Pipeline) :-
 1615   must_be(sdl_gpu_pipeline_blob, Pipeline),
 1616   sdl_releasegpugraphicspipeline_(Pipeline).
 1617
 1618% Translate all enum/flag atoms in the pipeline create info to ints.
 1619% Each sub-record is destructured and reconstructed with int values.
 1620graphics_pipeline_create_info_int(
 1621   gpu_graphics_pipeline_create_info(VertShader, FragShader,
 1622                                     VertexInputState, PrimitiveType,
 1623                                     RasterizerState, MultisampleState,
 1624                                     DepthStencilState, TargetInfo),
 1625   IntInfo) =>
 1626   sdl_gpu_primitive_type(PrimitiveType, IntPrimitiveType),
 1627   vertex_input_state_int(VertexInputState, IntVIS),
 1628   rasterizer_state_int(RasterizerState, IntRS),
 1629   multisample_state_int(MultisampleState, IntMS),
 1630   depth_stencil_state_int(DepthStencilState, IntDSS),
 1631   target_info_int(TargetInfo, IntTI),
 1632   IntInfo = gpu_graphics_pipeline_create_info(
 1633      VertShader, FragShader, IntVIS, IntPrimitiveType,
 1634      IntRS, IntMS, IntDSS, IntTI).
 1635
 1636vertex_input_state_int(
 1637   vertex_input_state(VBDescs, VAttrs),
 1638   IntVIS) =>
 1639   maplist(vertex_buffer_description_int, VBDescs, IntVBDescs),
 1640   maplist(vertex_attribute_int, VAttrs, IntVAttrs),
 1641   IntVIS = vertex_input_state(IntVBDescs, IntVAttrs).
 1642
 1643vertex_buffer_description_int(
 1644   vertex_buffer_description(Slot, Pitch, InputRate, InstanceStepRate),
 1645   IntVBD) =>
 1646   sdl_gpu_vertex_input_rate(InputRate, IntInputRate),
 1647   IntVBD = vertex_buffer_description(Slot, Pitch, IntInputRate, InstanceStepRate).
 1648
 1649vertex_attribute_int(
 1650   vertex_attribute(Location, BufferSlot, Format, Offset),
 1651   IntVA) =>
 1652   sdl_gpu_vertex_element_format(Format, IntFormat),
 1653   IntVA = vertex_attribute(Location, BufferSlot, IntFormat, Offset).
 1654
 1655rasterizer_state_int(
 1656   rasterizer_state(FillMode, CullMode, FrontFace, DBCF, DBC, DBSF,
 1657                    EnableDepthBias, EnableDepthClip),
 1658   IntRS) =>
 1659   sdl_gpu_fill_mode(FillMode, IntFillMode),
 1660   sdl_gpu_cull_mode(CullMode, IntCullMode),
 1661   sdl_gpu_front_face(FrontFace, IntFrontFace),
 1662   IntRS = rasterizer_state(IntFillMode, IntCullMode, IntFrontFace,
 1663                            DBCF, DBC, DBSF, EnableDepthBias, EnableDepthClip).
 1664
 1665multisample_state_int(
 1666   multisample_state(SampleCount, SampleMask, EnableMask, EnableAlphaToCoverage),
 1667   IntMS) =>
 1668   sdl_gpu_sample_count(SampleCount, IntSampleCount),
 1669   IntMS = multisample_state(IntSampleCount, SampleMask, EnableMask,
 1670                             EnableAlphaToCoverage).
 1671
 1672stencil_op_state_int(
 1673   stencil_op_state(FailOp, PassOp, DepthFailOp, CompareOp),
 1674   IntSOS) =>
 1675   sdl_gpu_stencil_op(FailOp, IntFailOp),
 1676   sdl_gpu_stencil_op(PassOp, IntPassOp),
 1677   sdl_gpu_stencil_op(DepthFailOp, IntDepthFailOp),
 1678   sdl_gpu_compare_op(CompareOp, IntCompareOp),
 1679   IntSOS = stencil_op_state(IntFailOp, IntPassOp, IntDepthFailOp, IntCompareOp).
 1680
 1681depth_stencil_state_int(
 1682   depth_stencil_state(CompareOp, BackStencilState, FrontStencilState,
 1683                       CompareMask, WriteMask, EnableDepthTest,
 1684                       EnableDepthWrite, EnableStencilTest),
 1685   IntDSS) =>
 1686   sdl_gpu_compare_op(CompareOp, IntCompareOp),
 1687   stencil_op_state_int(BackStencilState, IntBSS),
 1688   stencil_op_state_int(FrontStencilState, IntFSS),
 1689   IntDSS = depth_stencil_state(IntCompareOp, IntBSS, IntFSS,
 1690                                CompareMask, WriteMask, EnableDepthTest,
 1691                                EnableDepthWrite, EnableStencilTest).
 1692
 1693color_target_blend_state_int(
 1694   color_target_blend_state(SrcColorBF, DstColorBF, ColorBlendOp,
 1695                            SrcAlphaBF, DstAlphaBF, AlphaBlendOp,
 1696                            ColorWriteMask, EnableBlend, EnableColorWriteMask),
 1697   IntCTBS) =>
 1698   sdl_gpu_blend_factor(SrcColorBF, IntSrcColorBF),
 1699   sdl_gpu_blend_factor(DstColorBF, IntDstColorBF),
 1700   sdl_gpu_blend_op(ColorBlendOp, IntColorBlendOp),
 1701   sdl_gpu_blend_factor(SrcAlphaBF, IntSrcAlphaBF),
 1702   sdl_gpu_blend_factor(DstAlphaBF, IntDstAlphaBF),
 1703   sdl_gpu_blend_op(AlphaBlendOp, IntAlphaBlendOp),
 1704   maplist(sdl_gpu_color_component, ColorWriteMask, CWMInts),
 1705   or_list(CWMInts, IntColorWriteMask),
 1706   IntCTBS = color_target_blend_state(
 1707      IntSrcColorBF, IntDstColorBF, IntColorBlendOp,
 1708      IntSrcAlphaBF, IntDstAlphaBF, IntAlphaBlendOp,
 1709      IntColorWriteMask, EnableBlend, EnableColorWriteMask).
 1710
 1711color_target_description_int(
 1712   color_target_description(Format, BlendState),
 1713   IntCTD) =>
 1714   sdl_gpu_texture_format(Format, IntFormat),
 1715   color_target_blend_state_int(BlendState, IntBlendState),
 1716   IntCTD = color_target_description(IntFormat, IntBlendState).
 1717
 1718target_info_int(
 1719   target_info(ColorTargetDescriptions, DepthStencilFormat, HasDepthStencilTarget),
 1720   IntTI) =>
 1721   maplist(color_target_description_int, ColorTargetDescriptions, IntCTDs),
 1722   sdl_gpu_texture_format(DepthStencilFormat, IntDSFormat),
 1723   IntTI = target_info(IntCTDs, IntDSFormat, HasDepthStencilTarget).
 1724
 1725% --- SDL_gpu: create / release buffer ---------------------------------------
 1726% Creates a GPU buffer (vertex, index, indirect, or storage) and releases it.
 1727% Usage is a list of sdl_gpu_buffer_usage atoms (OR-ed together).  Size is the
 1728% buffer size in bytes.  The blob is owning: destroy() calls
 1729% SDL_ReleaseGPUBuffer.  Releasing an already-released buffer raises
 1730% existence_error(buffer, Buffer).
 sdl_gpu_buffer_usage(?Usage:atom, ?Value:integer) is nondet
Enumerate SDL_GPUBufferUsageFlag values. Each flag is a Prolog atom linked to its SDL bit-mask value; a list of these atoms may be combined into a single mask where used.

The user-facing buffer-usage atoms are:

See also
- https://wiki.libsdl.org/SDL3/SDL_GPUBufferUsage
 1748sdl_gpu_buffer_usage(vertex,                0x00000001).
 1749sdl_gpu_buffer_usage(index,                 0x00000002).
 1750sdl_gpu_buffer_usage(indirect,              0x00000004).
 1751sdl_gpu_buffer_usage(graphics_storage_read, 0x00000008).
 1752sdl_gpu_buffer_usage(compute_storage_read,  0x00000010).
 1753sdl_gpu_buffer_usage(compute_storage_write, 0x00000020).
 sdl_creategpubuffer(-Buffer:blob, +Device:blob, +Usage:list(sdl_gpu_buffer_usage), +Size:nonneg) is det
Creates a GPU buffer (vertex, index, indirect, or storage). Usage is a list of sdl_gpu_buffer_usage atoms (OR-ed together); Size is the buffer size in bytes. The blob is owning: destroy() calls SDL_ReleaseGPUBuffer.
See also
- https://wiki.libsdl.org/SDL3/SDL_CreateGPUBuffer
 1763sdl_creategpubuffer(Buffer, Device, Usage, Size) :-
 1764   must_be(var, Buffer),
 1765   must_be(sdl_gpu_device_blob, Device),
 1766   must_be(list(sdl_gpu_buffer_usage), Usage),
 1767   must_be(nonneg, Size),
 1768   maplist(sdl_gpu_buffer_usage, Usage, UsageInts),
 1769   or_list(UsageInts, IntUsage),
 1770   sdl_creategpubuffer_(Buffer, Device, IntUsage, Size).
 sdl_releasegpubuffer(+Buffer:blob) is det
Releases a buffer created with sdl_creategpubuffer/4. The blob is marked consumed; after this call Buffer is invalid. Releasing an already-released buffer raises existence_error(buffer, Buffer).
See also
- https://wiki.libsdl.org/SDL3/SDL_ReleaseGPUBuffer
 1780sdl_releasegpubuffer(Buffer) :-
 1781   must_be(sdl_gpu_buffer_blob, Buffer),
 1782   sdl_releasegpubuffer_(Buffer).
 1783
 1784% --- SDL_gpu: create / release transfer buffer ------------------------------
 1785% Creates a transfer buffer (staging area for uploading/downloading GPU data)
 1786% and releases it.  Usage is a sdl_gpu_transfer_buffer_usage atom (upload or
 1787% download).  Size is the buffer size in bytes.  The blob is owning:
 1788% destroy() calls SDL_ReleaseGPUTransferBuffer.  Releasing an already-released
 1789% transfer buffer raises existence_error(transfer_buffer, TransferBuffer).
 sdl_gpu_transfer_buffer_usage(?Usage:atom, ?Value:integer) is nondet
Enumerate SDL_GPUTransferBufferUsage values. Each flag is a Prolog atom linked to its SDL enum value.

The user-facing transfer-buffer-usage atoms are:

See also
- https://wiki.libsdl.org/SDL3/SDL_GPUTransferBufferUsage
 1802sdl_gpu_transfer_buffer_usage(upload, 0).
 1803sdl_gpu_transfer_buffer_usage(download, 1).
 sdl_creategputransferbuffer(-TransferBuffer:blob, +Device:blob, +Usage:sdl_gpu_transfer_buffer_usage, +Size:nonneg) is det
Creates a transfer buffer (staging area for uploading/downloading GPU data). Usage is an sdl_gpu_transfer_buffer_usage atom (upload or download); Size is the buffer size in bytes. The blob is owning: destroy() calls SDL_ReleaseGPUTransferBuffer.
See also
- https://wiki.libsdl.org/SDL3/SDL_CreateGPUTransferBuffer
 1814sdl_creategputransferbuffer(TransferBuffer, Device, Usage, Size) :-
 1815   must_be(var, TransferBuffer),
 1816   must_be(sdl_gpu_device_blob, Device),
 1817   must_be(sdl_gpu_transfer_buffer_usage, Usage),
 1818   must_be(nonneg, Size),
 1819   sdl_gpu_transfer_buffer_usage(Usage, IntUsage),
 1820   sdl_creategputransferbuffer_(TransferBuffer, Device, IntUsage, Size).
 sdl_releasegputransferbuffer(+TransferBuffer:blob) is det
Releases a transfer buffer created with sdl_creategputransferbuffer/4. The blob is marked consumed; after this call TransferBuffer is invalid. Releasing an already-released transfer buffer raises existence_error(transfer_buffer, TransferBuffer).
See also
- https://wiki.libsdl.org/SDL3/SDL_ReleaseGPUTransferBuffer
 1831sdl_releasegputransferbuffer(TransferBuffer) :-
 1832   must_be(sdl_gpu_transfer_buffer_blob, TransferBuffer),
 1833   sdl_releasegputransferbuffer_(TransferBuffer).
 1834
 1835% --- SDL_gpu: map / unmap transfer buffer -----------------------------------
 1836% Maps a transfer buffer into application address space (returns a PtrBlob)
 1837% and unmaps it.  The PtrBlob is a non-owning view — the memory is owned by
 1838% the driver and must NOT be freed.  The PtrBlob's parent is the transfer
 1839% buffer blob, preventing GC from releasing it while mapped.  Must unmap
 1840% before encoding upload commands (SDL_UploadToGPUBuffer).
 1841%
 1842% This is the GPU equivalent of sdl_locktexture / sdl_unlocktexture: the
 1843% caller writes vertex/index data into the PtrBlob (via library(ptr) writers
 1844% or cairo), then unmaps and uploads.
 sdl_mapgputransferbuffer(-Ptr:ptr_blob, +TransferBuffer:blob, +Cycle:boolean) is det
Maps a transfer buffer into application address space. On success Ptr is a PtrBlob to the mapped memory; write vertex/index data into it via library(ptr) writers or cairo. Unmap with sdl_unmapgputransferbuffer/1 before encoding upload commands.
See also
- https://wiki.libsdl.org/SDL3/SDL_MapGPUTransferBuffer
 1855sdl_mapgputransferbuffer(Ptr, TransferBuffer, Cycle) :-
 1856   must_be(var, Ptr),
 1857   must_be(sdl_gpu_transfer_buffer_blob, TransferBuffer),
 1858   must_be(boolean, Cycle),
 1859   sdl_mapgputransferbuffer_(Ptr, TransferBuffer, Cycle).
 sdl_unmapgputransferbuffer(+TransferBuffer:blob) is det
Unmaps a transfer buffer previously mapped with sdl_mapgputransferbuffer/3. Must be called before encoding upload commands.
See also
- https://wiki.libsdl.org/SDL3/SDL_UnmapGPUTransferBuffer
 1869sdl_unmapgputransferbuffer(TransferBuffer) :-
 1870   must_be(sdl_gpu_transfer_buffer_blob, TransferBuffer),
 1871   sdl_unmapgputransferbuffer_(TransferBuffer).
 1872
 1873% --- SDL_gpu: copy pass -----------------------------------------------------
 1874% A copy pass is begun on a command buffer and is used for upload/download
 1875% operations (SDL_UploadToGPUBuffer, etc.).  All copy operations must take
 1876% place inside a copy pass.  You must not begin another copy pass, render
 1877% pass, or compute pass before ending the current copy pass.
 1878%
 1879% RAII: the copy pass blob holds a parent ref to the command buffer.  If
 1880% GC'd without being explicitly ended, destroy() calls SDL_EndGPUCopyPass
 1881% as a safety net.  After explicit end the blob is marked consumed.  Ending
 1882% an already-ended copy pass raises existence_error(copy_pass, CopyPass).
 sdl_begingpucopypass(-CopyPass:blob, +CmdBuf:blob) is det
Begins a copy pass on a command buffer, used for upload/download operations (e.g. sdl_uploadtogpubuffer/4). All copy operations must take place inside a copy pass. You must not begin another copy pass, render pass, or compute pass before ending the current copy pass.

RAII: if the copy pass blob is GC'd without being explicitly ended, destroy() calls SDL_EndGPUCopyPass as a safety net.

See also
- https://wiki.libsdl.org/SDL3/SDL_BeginGPUCopyPass
 1896sdl_begingpucopypass(CopyPass, CmdBuf) :-
 1897   must_be(var, CopyPass),
 1898   must_be(sdl_gpu_cmdbuf_blob, CmdBuf),
 1899   sdl_begingpucopypass_(CopyPass, CmdBuf).
 sdl_endgpucopypass(+CopyPass:blob) is det
Ends a copy pass begun with sdl_begingpucopypass/2. The blob is marked consumed; after this call CopyPass is invalid. Ending an already-ended copy pass raises existence_error(copy_pass, CopyPass).
See also
- https://wiki.libsdl.org/SDL3/SDL_EndGPUCopyPass
 1909sdl_endgpucopypass(CopyPass) :-
 1910   must_be(sdl_gpu_copypass_blob, CopyPass),
 1911   sdl_endgpucopypass_(CopyPass).
 1912
 1913% --- SDL_gpu: upload to buffer ----------------------------------------------
 1914% Uploads data from a transfer buffer to a GPU buffer.  Must be called inside
 1915% a copy pass.  Source is a transfer_buffer_location/2 compound:
 1916%   transfer_buffer_location(TransferBuffer, Offset)
 1917% Destination is a buffer_region/3 compound:
 1918%   buffer_region(Buffer, Offset, Size)
 1919% Cycle is a boolean: true cycles the buffer if already bound, false
 1920% overwrites.  No new blob is created — this is a command recorded into the
 1921% copy pass.
 sdl_uploadtogpubuffer(+CopyPass:blob, +Source:term, +Destination:term, +Cycle:boolean) is det
Uploads data from a transfer buffer to a GPU buffer. Must be called inside a copy pass. Source is a transfer_buffer_location(TransferBuffer, Offset) compound; Destination is a buffer_region(Buffer, Offset, Size) compound. Cycle is true to cycle the buffer if already bound, false to overwrite.
See also
- https://wiki.libsdl.org/SDL3/SDL_UploadToGPUBuffer
 1933sdl_uploadtogpubuffer(CopyPass, Source, Destination, Cycle) :-
 1934   must_be(sdl_gpu_copypass_blob, CopyPass),
 1935   must_be(transfer_buffer_location, Source),
 1936   must_be(buffer_region, Destination),
 1937   must_be(boolean, Cycle),
 1938   sdl_uploadtogpubuffer_(CopyPass, Source, Destination, Cycle).
 1939
 1940% --- SDL_gpu: draw commands -------------------------------------------------
 1941% These are render-pass commands — no blobs are created.  They record drawing
 1942% state into the command buffer via the render pass.
 1943%
 1944% A graphics pipeline must be bound before any draw calls.  Vertex buffers
 1945% and an optional index buffer are bound, then draw primitives or draw
 1946% indexed primitives is called.
 sdl_gpu_index_element_size(?Size:atom, ?Value:integer) is nondet
Enumerate SDL_GPUIndexElementSize values. Each flag is a Prolog atom linked to its SDL enum value.

The user-facing index-element-size atoms are:

See also
- https://wiki.libsdl.org/SDL3/SDL_GPUIndexElementSize
 1959sdl_gpu_index_element_size('16bit', 0).
 1960sdl_gpu_index_element_size('32bit', 1).
 sdl_bindgpugraphicspipeline(+RenderPass:blob, +Pipeline:blob) is det
Binds a graphics pipeline for use in subsequent draw commands in the render pass.
See also
- https://wiki.libsdl.org/SDL3/SDL_BindGPUGraphicsPipeline
 1969sdl_bindgpugraphicspipeline(RenderPass, Pipeline) :-
 1970   must_be(sdl_gpu_renderpass_blob, RenderPass),
 1971   must_be(sdl_gpu_pipeline_blob, Pipeline),
 1972   sdl_bindgpugraphicspipeline_(RenderPass, Pipeline).
 sdl_bindgpuvertexbuffers(+RenderPass:blob, +FirstSlot:nonneg, +Bindings:list(buffer_binding)) is det
Binds vertex buffers starting at FirstSlot. Bindings is a list of buffer_binding(Buffer, Offset) compounds.
See also
- https://wiki.libsdl.org/SDL3/SDL_BindGPUVertexBuffers
 1981sdl_bindgpuvertexbuffers(RenderPass, FirstSlot, Bindings) :-
 1982   must_be(sdl_gpu_renderpass_blob, RenderPass),
 1983   must_be(nonneg, FirstSlot),
 1984   must_be(list(buffer_binding), Bindings),
 1985   sdl_bindgpuvertexbuffers_(RenderPass, FirstSlot, Bindings).
 sdl_bindgpuindexbuffer(+RenderPass:blob, +Binding:buffer_binding, +IndexElementSize:sdl_gpu_index_element_size) is det
Binds an index buffer for use in sdl_drawgpuindexedprimitives/6. IndexElementSize is `16bit or 32bit`.
See also
- https://wiki.libsdl.org/SDL3/SDL_BindGPUIndexBuffer
 1994sdl_bindgpuindexbuffer(RenderPass, Binding, IndexElementSize) :-
 1995   must_be(sdl_gpu_renderpass_blob, RenderPass),
 1996   must_be(buffer_binding, Binding),
 1997   must_be(sdl_gpu_index_element_size, IndexElementSize),
 1998   sdl_gpu_index_element_size(IndexElementSize, IntSize),
 1999   sdl_bindgpuindexbuffer_(RenderPass, Binding, IntSize).
 sdl_drawgpuindexedprimitives(+RenderPass:blob, +NumIndices:nonneg, +NumInstances:nonneg, +FirstIndex:nonneg, +VertexOffset:integer, +FirstInstance:nonneg) is det
Draws indexed primitives from the bound index and vertex buffers.
See also
- https://wiki.libsdl.org/SDL3/SDL_DrawGPUIndexedPrimitives
 2007sdl_drawgpuindexedprimitives(RenderPass, NumIndices, NumInstances,
 2008                             FirstIndex, VertexOffset, FirstInstance) :-
 2009   must_be(sdl_gpu_renderpass_blob, RenderPass),
 2010   must_be(nonneg, NumIndices),
 2011   must_be(nonneg, NumInstances),
 2012   must_be(nonneg, FirstIndex),
 2013   must_be(integer, VertexOffset),
 2014   must_be(nonneg, FirstInstance),
 2015   sdl_drawgpuindexedprimitives_(RenderPass, NumIndices, NumInstances,
 2016                                 FirstIndex, VertexOffset, FirstInstance).
 sdl_drawgpuprimitives(+RenderPass:blob, +NumVertices:nonneg, +NumInstances:nonneg, +FirstVertex:nonneg, +FirstInstance:nonneg) is det
Draws primitives from the bound vertex buffers.
See also
- https://wiki.libsdl.org/SDL3/SDL_DrawGPUPrimitives
 2024sdl_drawgpuprimitives(RenderPass, NumVertices, NumInstances,
 2025                      FirstVertex, FirstInstance) :-
 2026   must_be(sdl_gpu_renderpass_blob, RenderPass),
 2027   must_be(nonneg, NumVertices),
 2028   must_be(nonneg, NumInstances),
 2029   must_be(nonneg, FirstVertex),
 2030   must_be(nonneg, FirstInstance),
 2031   sdl_drawgpuprimitives_(RenderPass, NumVertices, NumInstances,
 2032                          FirstVertex, FirstInstance)