You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
rust: Port the sprite and texture upload geometry in graphics.c to obs-graphics #2082
Port the sprite and texture upload geometry in libobs/graphics/graphics.c.h to rust/obs-graphics, as a new module sprite:
assign_sprite_rect, assign_sprite_uv, build_sprite, build_sprite_norm, build_subsprite_norm and build_sprite_rect: the four points and their UVs;
in gs_draw_quadf: the refusals (not 2D; no texture and a 0 size) and the choice of size;
in gs_draw_sprite_subregion: the "whole texture" shortcut;
in gs_texture_set_image: the copy plan (row_copy, the flipped start row, one copy or row by row);
in gs_texture_create: is_pow2 and the mipmap rules.
These stay C: the device exports, map/unmap and every memcpy, the vertex buffers, the matrix stack, the logs and gs_perspective.
Plan (one PR, separate commits)
A behaviour-neutral move into libobs/graphics/graphics-sprite.c.h, as hidden functions. One exception is recorded in the PR: with a flip and a height of 0, the copy plan now returns "no rows" before it computes the flipped start offset. Today that offset is (height - 1) * linesize and wraps, which is undefined pointer arithmetic even though no row is copied.
Characterization in test_sprite_geometry_steps. It covers:
each flip value;
subregions inside the texture, at its edges, larger than it, and of a 0-size texture;
the upload plan for equal and unequal line sizes, with and without flip;
the mipmap rule for power-of-two and other sizes, levels 0, 1 and 5, with and without GS_RENDER_TARGET / GS_BUILD_MIPMAPS.
RED, then GREEN: the safe Rust core plus shims, in a libobs.ported-sprite group. Exported symbols are unchanged.
Tier 3 parity against the original C: bit-equal f32 over a proptest of sizes and flips, and exhaustive over the flag sets. Plus a deliberate-break check and port_comparison numbers.
test_texture_render, test_image_size_precheck, the test_graphics_alias_* tests, test_shader_sampler_convert and the scene render tests must stay green on every lane.
Activity
rdoupe commentedon Oct 24, 2026
Claiming: #2082.
obs-graphics: Port the sprite and texture upload geometry (obs-rust#2107