Skip to content

rust: Port the sprite and texture upload geometry in graphics.c to obs-graphics #2082

Closed

Description

@rdoupe

Unit

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)

  1. 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.
  2. 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.
  3. RED, then GREEN: the safe Rust core plus shims, in a libobs.ported-sprite group. Exported symbols are unchanged.
  4. 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

  1. rdoupe commented on Oct 24, 2026

    @rdoupe
    CollaboratorAuthor

    Claiming: #2082.

  2. added
    claimed
    on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    claimed

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions