Commit 71aede9
committed
gfx/d3d8: Upload RGUI menu framebuffer directly as ARGB4444
The D3D8 driver previously expanded RGUI's 16bpp menu framebuffer
to 32bpp on the CPU every frame via a per-pixel loop, then uploaded
the result into a D3DFMT_A8R8G8B8 texture. RGUI already assembles
its framebuffer in 16bpp; D3D8 has supported D3DFMT_A4R4G4B4 as a
baseline texture format since launch, on both PC and Original Xbox.
Add D3D8_ARGB4444_FORMAT to the existing D3D8 format macros (with
D3DFMT_LIN_A4R4G4B4 for the _XBOX build path), and a "d3d8" case
to the RGUI pixel format dispatcher selecting argb32_to_argb4444
(already in use by the rsx/PS3 and d3d9_hlsl/d3d9_cg drivers, which
target the same ARGB4444 bit layout).
In d3d8_set_menu_texture_frame, allocate the menu texture as
D3DFMT_A4R4G4B4 when rgb32 is false (the only case in current
practice; RGUI is the sole caller), and upload row-by-row via
memcpy. The rgb32 = true API branch is preserved for forward
compatibility and continues to use D3DFMT_A8R8G8B8.
Track the bpp of the currently-allocated menu texture in a new
d3d8_video_t::menu_tex_rgb32 field so the texture is recreated
when the rgb32 flag flips between calls — same approach the D3D9
patch uses for d3d9_video_t.
Endian-safe by construction: argb32_to_argb4444 produces a
host-endian uint16_t with A in bits 15..12 down to B in 3..0;
D3DFMT_A4R4G4B4 is read by D3D as host-endian 16-bit units with
the same bit assignments. D3D8 only targets LE hosts (Pentium III
on Original Xbox, x86/x64 on legacy Windows), so there is no
byte-swap concern in either direction.
Xbox-specific tex_coords[2]/[3] assignment after texture (re)creation
is preserved.1 parent 67e2a9e commit 71aede9
2 files changed
Lines changed: 40 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| 87 | + | |
86 | 88 | | |
87 | 89 | | |
88 | 90 | | |
| |||
128 | 130 | | |
129 | 131 | | |
130 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
131 | 141 | | |
132 | 142 | | |
133 | 143 | | |
| |||
2000 | 2010 | | |
2001 | 2011 | | |
2002 | 2012 | | |
2003 | | - | |
2004 | | - | |
2005 | | - | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
2006 | 2017 | | |
2007 | 2018 | | |
2008 | 2019 | | |
2009 | 2020 | | |
2010 | 2021 | | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
| 2026 | + | |
| 2027 | + | |
| 2028 | + | |
2011 | 2029 | | |
2012 | 2030 | | |
2013 | | - | |
| 2031 | + | |
2014 | 2032 | | |
2015 | 2033 | | |
2016 | 2034 | | |
2017 | 2035 | | |
2018 | 2036 | | |
2019 | 2037 | | |
2020 | 2038 | | |
| 2039 | + | |
2021 | 2040 | | |
2022 | 2041 | | |
2023 | 2042 | | |
| |||
2031 | 2050 | | |
2032 | 2051 | | |
2033 | 2052 | | |
2034 | | - | |
| 2053 | + | |
2035 | 2054 | | |
2036 | 2055 | | |
2037 | 2056 | | |
| |||
2047 | 2066 | | |
2048 | 2067 | | |
2049 | 2068 | | |
2050 | | - | |
2051 | | - | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
2052 | 2080 | | |
2053 | | - | |
| 2081 | + | |
2054 | 2082 | | |
2055 | | - | |
2056 | | - | |
2057 | | - | |
2058 | | - | |
2059 | | - | |
2060 | | - | |
2061 | | - | |
2062 | | - | |
2063 | | - | |
2064 | | - | |
2065 | | - | |
2066 | | - | |
2067 | | - | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
2068 | 2086 | | |
2069 | 2087 | | |
2070 | 2088 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1397 | 1397 | | |
1398 | 1398 | | |
1399 | 1399 | | |
| 1400 | + | |
1400 | 1401 | | |
1401 | 1402 | | |
1402 | 1403 | | |
| |||
0 commit comments