Skip to content

iris-hostgl: an accumulation buffer, and packed pixel types with their standard numbers - #175

Merged
techomancer merged 2 commits into
techomancer:mainfrom
atomchild411:hostgl-accum-pr
Oct 4, 2026
Merged

techomancer merged 2 commits into
techomancer:mainfrom
atomchild411:hostgl-accum-pr

Conversation

@atomchild411

Copy link
Copy Markdown
Contributor

Problem

Two host GL gaps, both found by the IRIX GL test suite in iris-guest-tools:

  • glAccum does nothing. Every guest drawable is a framebuffer object on the host, and OpenGL gives an accumulation buffer only to the window system's framebuffer, so there is none to accumulate into. IRIX programs use it for jittered antialiasing, motion blur and depth of field, and IRIS GL's acbuf is the same operation.
  • GL_UNSIGNED_SHORT_5_6_5 and GL_UNSIGNED_BYTE_2_3_3_REV come out swapped. The host swapped the two because IRIX 6.5.7's <GL/gl.h> numbers them the wrong way round. IRIX 6.5.22's header numbers them as OpenGL 1.2 does (2_3_3_REV = 0x8362, 5_6_5 = 0x8363), and programs and the guest libraries are built against it, so the swap now breaks them.

Fix

Accumulation buffer (iris-hostgl/src/accum.rs): one per drawable, a pair of RGBA32F textures the drawable's size.

  • Each operation is one pass of a small shader, new = old*a + colour*b + c, into the other texture of the pair, so no float blending is needed (not every GPU has it).
  • GL_RETURN draws old*value into the drawable, clamped by its fixed-point storage.
  • Every pass honours the scissor box; GL_RETURN also honours the colour mask and draw buffer. The program's GL state is saved around each pass and put back.
  • glAccum, glClearAccum and glClear's GL_ACCUM_BUFFER_BIT go to it; GL_ACCUM_*_BITS answer 16 and GL_ACCUM_CLEAR_VALUE the value set. The executor now knows the drawable drawn into as well as the one read.

Packed pixel types: the swap is gone; the numbers go to the host as they come.

Compatibility: a program compiled against a 6.5.7-era header that uses either of those two packed types would now get them the other way round. Current IRIX (6.5.22) headers and the guest libraries use the standard numbers.

Testing

  • cargo test --manifest-path iris-hostgl/Cargo.toml: 27 passed, including the new accumulation_buffer_operations and packed_5_6_5_and_2_3_3_rev_keep_their_meaning. calls.rs regenerates unchanged from tools/glshim.py.
  • cargo build --release --features hostgl,jitv2,tcache.
  • Indigo2 IMPACT R10000 (IP28), IRIX 6.5.22m, iris-guest-tools v20261002.3: gltest 166/166 on n32 and o32 (including glAccum and the 5_6_5, 2_3_3_REV and 8_8_8_8_REV draw/read checks, which fail without this), irisgltest all ok, glcheck PASSED.

🤖 Generated with Claude Code

atomchild411 and others added 2 commits October 2, 2026 23:56
IRIX 6.5.22's <GL/gl.h> numbers UNSIGNED_BYTE_2_3_3_REV 0x8362 and
UNSIGNED_SHORT_5_6_5 0x8363, as OpenGL 1.2 does; earlier 6.5 headers
(6.5.7's among them) had the two the other way round, and the host
swapped them back. Programs and the guest libraries are built against
6.5.22 now, so the numbers go to the host as they come.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every drawable is a framebuffer object, and OpenGL attaches an
accumulation buffer only to the window system's framebuffer: glAccum
on the host did nothing. IRIX programs use it for jittered
antialiasing, motion blur and depth of field, and IRIS GL's acbuf is
the same operation.

accum.rs keeps one per drawable instead: a pair of RGBA32F textures the
drawable's size. Each operation is one pass of a small shader,
new = old*a + colour*b + c, into the other texture of the pair (no
float blending needed, which not every GPU has); GL_RETURN draws
old*value into the drawable, clamped by its fixed-point storage. Every
pass honours the scissor box, GL_RETURN the colour mask and draw buffer,
and the program's state is saved around each pass and put back.

glAccum, glClearAccum and glClear's GL_ACCUM_BUFFER_BIT go to it;
GL_ACCUM_*_BITS answer 16 and GL_ACCUM_CLEAR_VALUE the value set. The
executor now knows the drawable drawn into as well as the one read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@techomancer
techomancer merged commit 6bc2082 into techomancer:main Oct 4, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants