1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! Fragment shader texture uniforms — the two config words
//! (`tex_p0[0]`/`tex_p1[0]`) that make up the *entire* uniform stream
//! the captured fragment shader fetches, per its QIR dump. Fixed for
//! this demo's exact texture setup: `GL_RGBA`/`GL_UNSIGNED_BYTE`,
//! `GL_NEAREST` filtering both directions, no mipmaps, default
//! `GL_REPEAT` wrap — the same configuration the GLES program that
//! produced that shader used, since that is what compiled the
//! fragment shader this builder's output must match.
//!
//! Field layout is `vc4_packet.h`'s `VC4_TEX_P0_*`/`VC4_TEX_P1_*`
//! macros (saved conceptually alongside `vc4_packet.xml`, though this
//! particular header has no XML counterpart — it's C-only), with the
//! actual field *values* cross-checked against Mesa's real assignment
//! code (`vc4_state.c`'s texture state setup) rather than derived from
//! the macros alone:
//!
//! - `WIDTH`/`HEIGHT` are literal pixel dimensions masked to 11 bits
//! (`width0 & 2047`) — not a "size minus one" encoding, confirmed by
//! reading the real assignment rather than assuming either
//! convention.
//! - `OFFSET` is the texture data's bus address, shifted right by 12
//! — meaning the texture buffer must be 4096-byte aligned. This is
//! coarser than anything else in this crate's V3D pipeline (the
//! 16/32/64-byte alignments other packets need) and
//! [`crate::v3d::GpuBuffer`]'s own `align(32)` is not sufficient on
//! its own — whatever allocates real texture data (Phase 7) needs
//! its own stronger alignment, not just a plain `GpuBuffer`.
//! - Filter/wrap values resolve through small lookup tables in
//! `vc4_state.c` down to `1` (nearest) and `0` (repeat)
//! respectively for this exact GL setup — read directly from that
//! code, not guessed from the macro names.
/// Runtime parameters for [`build_fragment_shader_uniforms`].
/// Builds the fragment shader's two-word texture uniform stream into
/// `cl`, returning the number of bytes written (always 8). Panics (via
/// slice indexing) if `cl` is too small.