mirror of
https://github.com/Creased/RCM-Emulator.git
synced 2026-12-06 02:48:11 +01:00
Model DC window address offsets and block-linear VIC surfaces, with a test
- DC: a window's fetch starts at ADDR_V_OFFSET * LINE_STRIDE + ADDR_H_OFFSET (TRM 24.11.1). That is the window's top-left pixel, or top-right with H_DIRECTION, or bottom-left with V_DIRECTION, and the fetch walks away from it; before, the offsets were ignored and flips mirrored within the window. HOS's column-scan offset (0x13FF) and hekate's inverted-pitch offset (1279) both land where they should. Layer order is documented: the TRM sorts windows by depth without saying which way. - VIC: slot and output surfaces may be block linear (BlkKind 1, 2^BlkHeight GOBs per block) as well as pitch. - GOB addressing moves to t210/block_linear.h, shared by the scan-out and VIC. - tests/display: one bare-metal payload built per scenario (a pitch window, Nyx's VIC turn into pitch and into block-linear surfaces, a block-linear VIC source, the DC's own column scan with an address offset, a mirrored window with window D blended over). check.py compares every pixel of the frame the emulator shows with the picture drawn. It runs in make test and in CI. hwtest's frame is unchanged, and Nyx's differs only in its clock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YYewwDPujjo5B2xRyC5Grb
This commit is contained in:
12 files changed
+466
-55
No files matched your search
@@ -45,11 +45,13 @@ jobs:
|
|||||||
grep -q "RCM Payload Emulator" out.txt \
|
grep -q "RCM Payload Emulator" out.txt \
|
||||||
|| { echo "banner missing - binary did not start"; exit 1; }
|
|| { echo "banner missing - binary did not start"; exit 1; }
|
||||||
|
|
||||||
- name: CCPLEX regression test
|
- name: CCPLEX and display regression tests
|
||||||
# A small self-contained payload boots CPU0 through bdk's
|
# Small self-contained payloads. One boots CPU0 through bdk's
|
||||||
# ccplex_boot_cpu0() register sequence: an unpowered release must be
|
# ccplex_boot_cpu0() register sequence: an unpowered release must be
|
||||||
# refused, a powered one must run an AArch64 blob at EL3, and WFE must
|
# refused, a powered one must run an AArch64 blob at EL3, and WFE must
|
||||||
# park the core.
|
# park the core. The others drive the display controller and VIC in
|
||||||
|
# six scenarios, and the frame the emulator shows must match the
|
||||||
|
# picture drawn, pixel for pixel.
|
||||||
run: make test
|
run: make test
|
||||||
|
|
||||||
- name: hwtest end to end
|
- name: hwtest end to end
|
||||||
|
|||||||
@@ -385,18 +385,25 @@ reports a frame end and a vblank, which bdk polls before DSI commands.
|
|||||||
Each display tick builds the picture the panel would receive, 720x1280 and
|
Each display tick builds the picture the panel would receive, 720x1280 and
|
||||||
portrait, the way the DC builds it:
|
portrait, the way the DC builds it:
|
||||||
|
|
||||||
1. Every enabled window's surface is fetched at `START_ADDR`. The layout
|
1. Every enabled window's surface is fetched from `START_ADDR`. The layout
|
||||||
comes from `SURFACE_KIND`: pitch, 16x16 tiled, or block linear with
|
comes from `SURFACE_KIND`: pitch, 16x16 tiled, or block linear with
|
||||||
2^`BLOCK_HEIGHT` GOBs (Groups of Bytes, 64x8-byte tiles) per block. The
|
2^`BLOCK_HEIGHT` GOBs (Groups of Bytes, 64x8-byte tiles) per block. The
|
||||||
line pitch is `LINE_STRIDE`, and pixels are decoded per `COLOR_DEPTH`.
|
line pitch is `LINE_STRIDE`, and pixels are decoded per `COLOR_DEPTH`.
|
||||||
Block-linear byte order follows TRM 20.1.2 and Figure 47.
|
Block-linear byte order follows TRM 20.1.2 and Figure 47
|
||||||
2. `WIN_OPTIONS` turns the surface: H_DIRECTION and V_DIRECTION mirror it,
|
(`t210/block_linear.h`, shared with VIC).
|
||||||
and SCAN_COLUMN walks its columns (90/270 degrees, TRM Table 122). The
|
2. The fetch starts at `ADDR_V_OFFSET * LINE_STRIDE + ADDR_H_OFFSET` (TRM
|
||||||
result is scaled from `PRESCALED_SIZE` to `SIZE`, nearest-neighbour, and
|
24.11.1): the window's top-left pixel, top-right with H_DIRECTION,
|
||||||
placed at `POSITION`.
|
bottom-left with V_DIRECTION, in surface terms. It walks away from there
|
||||||
3. The windows are stacked by layer depth (A under D when equal) and blended
|
per the direction bits, and SCAN_COLUMN walks columns instead of rows
|
||||||
per `BLEND_LAYER_CONTROL` and `BLEND_MATCH_SELECT`. Hekate's log console
|
(90/270 degrees, TRM Table 122). Pixels before `START_ADDR` or past the
|
||||||
(window D, K1 = 200) shows through as it does on the console.
|
surface are black. The result is scaled from `PRESCALED_SIZE` to `SIZE`,
|
||||||
|
nearest-neighbour, and placed at `POSITION`.
|
||||||
|
3. The windows are stacked by layer depth and blended per
|
||||||
|
`BLEND_LAYER_CONTROL` and `BLEND_MATCH_SELECT`. The TRM sorts windows by
|
||||||
|
depth into its blend stages without saying which way; lower depth is
|
||||||
|
nearer the top here, as Linux programs later Tegras, and equal depths
|
||||||
|
stack A under D. Hekate's log console (window D, K1 = 200) shows
|
||||||
|
through as it does on the console.
|
||||||
|
|
||||||
The panel picture is then turned for the host window. When the surface on
|
The panel picture is then turned for the host window. When the surface on
|
||||||
show was turned on its way to the panel, by the DC (SCAN_COLUMN) or by a
|
show was turned on its way to the panel, by the DC (SCAN_COLUMN) or by a
|
||||||
@@ -420,13 +427,14 @@ bdk drives VIC through the Falcon private-register window. The model keeps
|
|||||||
the config struct's address (`VIC_SC_PRAMBASE`), the slots' source surfaces
|
the config struct's address (`VIC_SC_PRAMBASE`), the slots' source surfaces
|
||||||
(`VIC_SC_SFC0_BASE_LUMA(n)`) and the target (`VIC_BL_TARGET_BASADR`). On
|
(`VIC_SC_SFC0_BASE_LUMA(n)`) and the target (`VIC_BL_TARGET_BASADR`). On
|
||||||
`VIC_FC_COMPOSE` it reads bdk's `vic_config_t` from guest memory and draws
|
`VIC_FC_COMPOSE` it reads bdk's `vic_config_t` from guest memory and draws
|
||||||
every enabled pitch slot into the target, scaling the source rect onto the
|
every enabled slot into the target, scaling the source rect onto the
|
||||||
dest rect, clipped to the target rect, with the output flip X, flip Y and
|
dest rect, clipped to the target rect, with the output flip X, flip Y and
|
||||||
transpose applied. The output size is given before the transpose, so a
|
transpose applied. The output size is given before the transpose, so a
|
||||||
transposed target is H x W pixels, which is how the DC then reads it. The
|
transposed target is H x W pixels, which is how the DC then reads it. The
|
||||||
compose also records the target address and the turn applied, which the
|
compose also records the target address and the turn applied, which the
|
||||||
display uses to undo it. Nyx's 270-degree rotation is flip X then transpose.
|
display uses to undo it. Nyx's 270-degree rotation is flip X then transpose.
|
||||||
Block-linear VIC surfaces are not modelled, and nothing in bdk uses them.
|
Slot and output surfaces are pitch or block linear (BlkKind 1, with
|
||||||
|
2^BlkHeight GOBs per block).
|
||||||
|
|
||||||
### UART
|
### UART
|
||||||
|
|
||||||
@@ -650,9 +658,14 @@ final `for(;;) wfe;` would otherwise spin through a billion instructions per
|
|||||||
emulated second.
|
emulated second.
|
||||||
|
|
||||||
`make test` runs `tests/ccplex/`, a self-contained payload that checks the
|
`make test` runs `tests/ccplex/`, a self-contained payload that checks the
|
||||||
refusal, the EL3 entry, the mailbox, WFE parking and the reset.
|
refusal, the EL3 entry, the mailbox, WFE parking and the reset, and
|
||||||
`tests/hwtest/` builds hwtest-rcm with distro toolchains and runs its whole
|
`tests/display/`, one payload built per scenario that drives the display
|
||||||
sweep; CI runs both.
|
controller and VIC the way bdk does (a pitch window; Nyx's VIC turn into
|
||||||
|
pitch and into block-linear surfaces; a block-linear VIC source; the DC's
|
||||||
|
own column scan with an address offset; a mirrored window with window D
|
||||||
|
blended over it). `check.py` compares every pixel of the frame the emulator
|
||||||
|
shows with the picture the payload drew. `tests/hwtest/` builds hwtest-rcm
|
||||||
|
with distro toolchains and runs its whole sweep; CI runs all three.
|
||||||
|
|
||||||
## Bug history
|
## Bug history
|
||||||
|
|
||||||
|
|||||||
@@ -98,10 +98,19 @@ tests/ccplex/payload.bin: tests/ccplex/payload.c tests/ccplex/link.ld
|
|||||||
$(TEST_CC) $(TEST_CFLAGS) -T tests/ccplex/link.ld -o tests/ccplex/payload.elf $<
|
$(TEST_CC) $(TEST_CFLAGS) -T tests/ccplex/link.ld -o tests/ccplex/payload.elf $<
|
||||||
$(TEST_OBJCOPY) -O binary tests/ccplex/payload.elf $@
|
$(TEST_OBJCOPY) -O binary tests/ccplex/payload.elf $@
|
||||||
|
|
||||||
test: $(OUTPUT) tests/ccplex/payload.bin
|
DISPLAY_SCENARIOS = 1 2 3 4 5 6
|
||||||
|
DISPLAY_PAYLOADS = $(DISPLAY_SCENARIOS:%=tests/display/payload_%.bin)
|
||||||
|
|
||||||
|
tests/display/payload_%.bin: tests/display/payload.c tests/display/link.ld
|
||||||
|
$(TEST_CC) $(TEST_CFLAGS) -DSCENARIO=$* -T tests/display/link.ld -o tests/display/payload_$*.elf $<
|
||||||
|
$(TEST_OBJCOPY) -O binary tests/display/payload_$*.elf $@
|
||||||
|
|
||||||
|
test: $(OUTPUT) tests/ccplex/payload.bin $(DISPLAY_PAYLOADS)
|
||||||
sh tests/ccplex/run.sh ./$(OUTPUT) tests/ccplex/payload.bin
|
sh tests/ccplex/run.sh ./$(OUTPUT) tests/ccplex/payload.bin
|
||||||
|
sh tests/display/run.sh ./$(OUTPUT) tests/display
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(OUTPUT) $(OBJS) $(OBJS:.o=.d) \
|
rm -f $(OUTPUT) $(OBJS) $(OBJS:.o=.d) \
|
||||||
tests/ccplex/payload.elf tests/ccplex/payload.bin tests/ccplex/out.log \
|
tests/ccplex/payload.elf tests/ccplex/payload.bin tests/ccplex/out.log \
|
||||||
|
tests/display/payload_*.elf tests/display/payload_*.bin \
|
||||||
$(WIN_OUT) $(WIN_OBJS) $(WIN_OBJS:.o=.d)
|
$(WIN_OUT) $(WIN_OBJS) $(WIN_OBJS:.o=.d)
|
||||||
@@ -175,7 +175,7 @@ real consoles. Details in [DESIGN.md](DESIGN.md#ccplex-cpu0).
|
|||||||
## Tests
|
## Tests
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make test # CCPLEX regression payload (needs arm-none-eabi-gcc)
|
make test # CCPLEX + display regression payloads (arm-none-eabi-gcc, python3)
|
||||||
tests/hwtest/build.sh build-hwtest # build hwtest-rcm (+ gcc-aarch64-linux-gnu)
|
tests/hwtest/build.sh build-hwtest # build hwtest-rcm (+ gcc-aarch64-linux-gnu)
|
||||||
tests/hwtest/run.sh ./rcm_emu build-hwtest/hwtest-rcm/build/hwtest.bin
|
tests/hwtest/run.sh ./rcm_emu build-hwtest/hwtest-rcm/build/hwtest.bin
|
||||||
```
|
```
|
||||||
|
|||||||
+29
-18
@@ -2,6 +2,7 @@
|
|||||||
#include "config_window.h"
|
#include "config_window.h"
|
||||||
#include "console_window.h"
|
#include "console_window.h"
|
||||||
#include "../emu_state.h"
|
#include "../emu_state.h"
|
||||||
|
#include "../t210/block_linear.h"
|
||||||
#include "../t210/memory_map.h"
|
#include "../t210/memory_map.h"
|
||||||
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
@@ -162,7 +163,9 @@ struct Win {
|
|||||||
int idx = 0;
|
int idx = 0;
|
||||||
uint64_t addr = 0;
|
uint64_t addr = 0;
|
||||||
uint32_t depth = 0, bpp = 4, kind = 0, gob_h = 1, stride = 0, gobs = 0;
|
uint32_t depth = 0, bpp = 4, kind = 0, gob_h = 1, stride = 0, gobs = 0;
|
||||||
uint32_t src_w = 0, src_h = 0; // the surface, before the DC turns it
|
uint32_t src_w = 0, src_h = 0; // the fetch, before the DC turns it
|
||||||
|
uint32_t x0 = 0, y0 = 0; // first pixel fetched (ADDR_H/V_OFFSET)
|
||||||
|
uint32_t cols = 0, rows = 0; // surface extent from START_ADDR
|
||||||
uint32_t pre_w = 0, pre_h = 0; // PRESCALED_SIZE, in pixels (post-turn)
|
uint32_t pre_w = 0, pre_h = 0; // PRESCALED_SIZE, in pixels (post-turn)
|
||||||
uint32_t out_w = 0, out_h = 0; // SIZE
|
uint32_t out_w = 0, out_h = 0; // SIZE
|
||||||
int32_t x = 0, y = 0;
|
int32_t x = 0, y = 0;
|
||||||
@@ -179,14 +182,8 @@ inline size_t fetch_off(const Win &w, uint32_t sx, uint32_t sy) {
|
|||||||
case 1: // 16x16-byte tiles, row-major
|
case 1: // 16x16-byte tiles, row-major
|
||||||
return (size_t)(sy / 16) * w.stride * 16 + (xb / 16) * 256 +
|
return (size_t)(sy / 16) * w.stride * 16 + (xb / 16) * 256 +
|
||||||
(sy % 16) * 16 + (xb % 16);
|
(sy % 16) * 16 + (xb % 16);
|
||||||
case 2: { // block linear, TRM 20.1.2 (Figure 47 sector order)
|
case 2: // block linear
|
||||||
uint32_t gob_y = sy / 8;
|
return bl_offset(xb, sy, w.gobs, w.gob_h);
|
||||||
size_t gob = ((size_t)(gob_y / w.gob_h) * w.gobs + xb / 64) * w.gob_h +
|
|
||||||
gob_y % w.gob_h;
|
|
||||||
uint32_t x = xb % 64, y = sy % 8;
|
|
||||||
return gob * 512 + (x / 32) * 256 + (y / 2) * 64 + ((x % 32) / 16) * 32 +
|
|
||||||
(y % 2) * 16 + (x % 16);
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
return (size_t)sy * w.stride + xb;
|
return (size_t)sy * w.stride + xb;
|
||||||
}
|
}
|
||||||
@@ -236,17 +233,26 @@ bool load_window(EmuState *state, uc_engine *uc, int idx, const uint32_t *r,
|
|||||||
if (!w.stride)
|
if (!w.stride)
|
||||||
w.stride = w.src_w * w.bpp;
|
w.stride = w.src_w * w.bpp;
|
||||||
w.addr = (uint64_t)r[dcwin::START_ADDR] + (int64_t)state->manual_offset;
|
w.addr = (uint64_t)r[dcwin::START_ADDR] + (int64_t)state->manual_offset;
|
||||||
|
// The fetch starts at START_ADDR + ADDR_V_OFFSET * LINE_STRIDE +
|
||||||
|
// ADDR_H_OFFSET (TRM 24.11.1): the window's top-left pixel, or top-right
|
||||||
|
// with H_DIRECTION, bottom-left with V_DIRECTION - in surface terms,
|
||||||
|
// before SCAN_COLUMN turns it - and walks away from it.
|
||||||
|
uint64_t start = (uint64_t)r[dcwin::ADDR_V_OFF] * w.stride +
|
||||||
|
r[dcwin::ADDR_H_OFF];
|
||||||
|
w.y0 = (uint32_t)std::min<uint64_t>(start / w.stride, 0xFFFF);
|
||||||
|
w.x0 = (uint32_t)(start % w.stride) / w.bpp;
|
||||||
|
w.cols = w.stride / w.bpp;
|
||||||
|
w.rows = (w.xf & dcwin::XF_FLIP_Y) ? w.y0 + 1 : w.y0 + w.src_h;
|
||||||
switch (w.kind) {
|
switch (w.kind) {
|
||||||
case 2:
|
case 2:
|
||||||
w.gobs = (w.stride + 63) / 64;
|
w.gobs = (w.stride + 63) / 64;
|
||||||
w.len = (size_t)w.gobs * 512 * w.gob_h *
|
w.len = bl_size(w.gobs, w.gob_h, w.rows);
|
||||||
((w.src_h + 8 * w.gob_h - 1) / (8 * w.gob_h));
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
w.len = (size_t)w.stride * ((w.src_h + 15) / 16) * 16;
|
w.len = (size_t)w.stride * ((w.rows + 15) / 16) * 16;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
w.len = (size_t)w.stride * w.src_h;
|
w.len = (size_t)w.stride * w.rows;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (w.len == 0 || w.len > 64u * 1024 * 1024)
|
if (w.len == 0 || w.len > 64u * 1024 * 1024)
|
||||||
@@ -308,9 +314,11 @@ void draw_window(const Win &w, std::vector<uint32_t> &panel) {
|
|||||||
uint32_t tx = txs[ox];
|
uint32_t tx = txs[ox];
|
||||||
// (tx, ty) is post-turn; walk it back to the surface.
|
// (tx, ty) is post-turn; walk it back to the surface.
|
||||||
uint32_t a = column ? ty : tx, b = column ? tx : ty;
|
uint32_t a = column ? ty : tx, b = column ? tx : ty;
|
||||||
uint32_t sx = hflip ? w.src_w - 1 - a : a;
|
int64_t sx = hflip ? (int64_t)w.x0 - a : (int64_t)w.x0 + a;
|
||||||
uint32_t sy = vflip ? w.src_h - 1 - b : b;
|
int64_t sy = vflip ? (int64_t)w.y0 - b : (int64_t)w.y0 + b;
|
||||||
size_t off = fetch_off(w, sx, sy);
|
if (sx < 0 || sy < 0 || sx >= w.cols || sy >= w.rows)
|
||||||
|
continue; // before START_ADDR or past the surface
|
||||||
|
size_t off = fetch_off(w, (uint32_t)sx, (uint32_t)sy);
|
||||||
if (off + w.bpp > w.len)
|
if (off + w.bpp > w.len)
|
||||||
continue;
|
continue;
|
||||||
uint32_t s = depth_argb(w.mem + off, w.depth);
|
uint32_t s = depth_argb(w.mem + off, w.depth);
|
||||||
@@ -356,7 +364,10 @@ void sdl_display_update(EmuState *state, uc_engine *uc) {
|
|||||||
if (load_window(state, uc, i, r, g_swizzle_override, w))
|
if (load_window(state, uc, i, r, g_swizzle_override, w))
|
||||||
wins.push_back(std::move(w));
|
wins.push_back(std::move(w));
|
||||||
}
|
}
|
||||||
// Deeper layers first; equal depths stack A (bottom) to D (top).
|
// The TRM sorts windows by depth into the blend stages (24.3.12) without
|
||||||
|
// saying which way; lower depth nearer the top, as Linux programs later
|
||||||
|
// Tegras (depth = 255 - zpos). Equal depths stack A (bottom) to D (top),
|
||||||
|
// which puts hekate's log window D over A, as its blending expects.
|
||||||
std::stable_sort(wins.begin(), wins.end(), [](const Win &l, const Win &r) {
|
std::stable_sort(wins.begin(), wins.end(), [](const Win &l, const Win &r) {
|
||||||
return l.layer > r.layer;
|
return l.layer > r.layer;
|
||||||
});
|
});
|
||||||
@@ -410,7 +421,7 @@ void sdl_display_update(EmuState *state, uc_engine *uc) {
|
|||||||
{(uint64_t)w.idx, w.addr, w.len, w.depth, w.kind, w.gob_h,
|
{(uint64_t)w.idx, w.addr, w.len, w.depth, w.kind, w.gob_h,
|
||||||
w.stride, (uint64_t)w.pre_w << 32 | w.pre_h,
|
w.stride, (uint64_t)w.pre_w << 32 | w.pre_h,
|
||||||
(uint64_t)w.out_w << 32 | w.out_h, w.xf, w.blend_layer,
|
(uint64_t)w.out_w << 32 | w.out_h, w.xf, w.blend_layer,
|
||||||
w.blend_match});
|
w.blend_match, (uint64_t)w.x0 << 32 | w.y0});
|
||||||
where.push_back((uint64_t)(uint32_t)w.x << 32 | (uint32_t)w.y);
|
where.push_back((uint64_t)(uint32_t)w.x << 32 | (uint32_t)w.y);
|
||||||
}
|
}
|
||||||
static std::vector<uint64_t> last_shape, last_where;
|
static std::vector<uint64_t> last_shape, last_where;
|
||||||
|
|||||||
@@ -105,6 +105,8 @@ constexpr uint32_t LINE_STRIDE = 0x00A; // DC_WIN_LINE_STRIDE (bytes)
|
|||||||
constexpr uint32_t BLEND_LAYER = 0x016; // DC_WINBUF_BLEND_LAYER_CONTROL
|
constexpr uint32_t BLEND_LAYER = 0x016; // DC_WINBUF_BLEND_LAYER_CONTROL
|
||||||
constexpr uint32_t BLEND_MATCH = 0x017; // DC_WINBUF_BLEND_MATCH_SELECT
|
constexpr uint32_t BLEND_MATCH = 0x017; // DC_WINBUF_BLEND_MATCH_SELECT
|
||||||
constexpr uint32_t START_ADDR = 0x100; // DC_WINBUF_START_ADDR
|
constexpr uint32_t START_ADDR = 0x100; // DC_WINBUF_START_ADDR
|
||||||
|
constexpr uint32_t ADDR_H_OFF = 0x106; // DC_WINBUF_ADDR_H_OFFSET (bytes)
|
||||||
|
constexpr uint32_t ADDR_V_OFF = 0x108; // DC_WINBUF_ADDR_V_OFFSET (lines)
|
||||||
constexpr uint32_t SURFACE_KIND = 0x10B; // DC_WINBUF_SURFACE_KIND
|
constexpr uint32_t SURFACE_KIND = 0x10B; // DC_WINBUF_SURFACE_KIND
|
||||||
|
|
||||||
// WIN_OPTIONS bits.
|
// WIN_OPTIONS bits.
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
// Tegra X1 block-linear surfaces (TRM 20.1.2), as the display controller and
|
||||||
|
// VIC read and write them. A GOB is 64 bytes x 8 lines (512 bytes) of 16Bx2
|
||||||
|
// sectors; GOBs stack gob_h high into a block, and blocks run left to right,
|
||||||
|
// then down, gobs_per_row GOBs to a row.
|
||||||
|
|
||||||
|
// Byte offset of byte column xb (pixel x * bytes per pixel) on line y.
|
||||||
|
inline size_t bl_offset(uint32_t xb, uint32_t y, uint32_t gobs_per_row,
|
||||||
|
uint32_t gob_h) {
|
||||||
|
uint32_t gob_y = y / 8;
|
||||||
|
size_t gob = ((size_t)(gob_y / gob_h) * gobs_per_row + xb / 64) * gob_h +
|
||||||
|
gob_y % gob_h;
|
||||||
|
// Within the GOB, TRM Figure 47's sector order.
|
||||||
|
uint32_t x = xb % 64, l = y % 8;
|
||||||
|
return gob * 512 + (x / 32) * 256 + (l / 2) * 64 + ((x % 32) / 16) * 32 +
|
||||||
|
(l % 2) * 16 + (x % 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bytes a surface h lines tall occupies (whole blocks).
|
||||||
|
inline size_t bl_size(uint32_t gobs_per_row, uint32_t gob_h, uint32_t h) {
|
||||||
|
return (size_t)gobs_per_row * 512 * gob_h *
|
||||||
|
((h + 8 * gob_h - 1) / (8 * gob_h));
|
||||||
|
}
|
||||||
+30
-18
@@ -1,4 +1,5 @@
|
|||||||
#include "mmio.h"
|
#include "mmio.h"
|
||||||
|
#include "block_linear.h"
|
||||||
#include "trace.h"
|
#include "trace.h"
|
||||||
#include "../emu_state.h"
|
#include "../emu_state.h"
|
||||||
#include "../platform.h"
|
#include "../platform.h"
|
||||||
@@ -3737,8 +3738,9 @@ static void se_write(EmuState *state, uint64_t addr, uint32_t val) {
|
|||||||
// for registers that need them; none of the ones modelled here do. The model
|
// for registers that need them; none of the ones modelled here do. The model
|
||||||
// keeps what a compose needs - the config struct's address (PRAMBASE), the
|
// keeps what a compose needs - the config struct's address (PRAMBASE), the
|
||||||
// slots' source surfaces and the target surface - and, on COMPOSE_START,
|
// slots' source surfaces and the target surface - and, on COMPOSE_START,
|
||||||
// reads the config struct from guest memory and draws the enabled pitch
|
// reads the config struct from guest memory and draws the enabled slots
|
||||||
// slots into the target with the output flip/transpose. That is what Nyx
|
// into the target with the output flip/transpose. Surfaces are pitch or
|
||||||
|
// block linear (BlkKind 1, BlkHeight = log2 GOBs per block). That is what Nyx
|
||||||
// relies on: its 1280x720 GUI is turned into the panel's 720x1280 portrait
|
// relies on: its 1280x720 GUI is turned into the panel's 720x1280 portrait
|
||||||
// framebuffer by a 270-degree VIC rotation (flip X, then transpose).
|
// framebuffer by a 270-degree VIC rotation (flip X, then transpose).
|
||||||
//
|
//
|
||||||
@@ -3746,7 +3748,8 @@ static void se_write(EmuState *state, uint64_t addr, uint32_t val) {
|
|||||||
// bitfields):
|
// bitfields):
|
||||||
// 0x10 OutputConfig u64 0: FlipX b48, FlipY b49, Transpose b50
|
// 0x10 OutputConfig u64 0: FlipX b48, FlipY b49, Transpose b50
|
||||||
// u64 1: TargetRect L b0, R b16, T b32, B b48
|
// u64 1: TargetRect L b0, R b16, T b32, B b48
|
||||||
// 0x20 OutputSurfaceConfig u64 0: format b0, BlkKind b11, W-1 b32, H-1 b46
|
// 0x20 OutputSurfaceConfig u64 0: format b0, BlkKind b11, BlkHeight b15,
|
||||||
|
// W-1 b32, H-1 b46
|
||||||
// 0x90 + n * 0xB0 slot n: u64 0: SlotEnable b0
|
// 0x90 + n * 0xB0 slot n: u64 0: SlotEnable b0
|
||||||
// u64 4/5: SourceRect L|R, T|B (16.16, b0/b32)
|
// u64 4/5: SourceRect L|R, T|B (16.16, b0/b32)
|
||||||
// u64 6: DestRect L b0, R b16, T b32, B b48
|
// u64 6: DestRect L b0, R b16, T b32, B b48
|
||||||
@@ -3804,6 +3807,7 @@ static void vic_compose(EmuState *state) {
|
|||||||
uint32_t tl = bits(c[3], 0, 14), tr = bits(c[3], 16, 14);
|
uint32_t tl = bits(c[3], 0, 14), tr = bits(c[3], 16, 14);
|
||||||
uint32_t tt = bits(c[3], 32, 14), tb = bits(c[3], 48, 14);
|
uint32_t tt = bits(c[3], 32, 14), tb = bits(c[3], 48, 14);
|
||||||
uint32_t ofmt = bits(c[4], 0, 7), okind = bits(c[4], 11, 4);
|
uint32_t ofmt = bits(c[4], 0, 7), okind = bits(c[4], 11, 4);
|
||||||
|
uint32_t ogob = 1u << std::min(bits(c[4], 15, 4), 5u);
|
||||||
uint32_t ow = bits(c[4], 32, 14) + 1, oh = bits(c[4], 46, 14) + 1;
|
uint32_t ow = bits(c[4], 32, 14) + 1, oh = bits(c[4], 46, 14) + 1;
|
||||||
uint32_t bpp = vic_bpp(ofmt);
|
uint32_t bpp = vic_bpp(ofmt);
|
||||||
|
|
||||||
@@ -3815,11 +3819,16 @@ static void vic_compose(EmuState *state) {
|
|||||||
printf("[vic] compose skipped: %s\n", what);
|
printf("[vic] compose skipped: %s\n", what);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (!bpp || okind != 0)
|
// BlkKind 0 is pitch, 1 the Tegra 16Bx2 block-linear layout; BlkHeight is
|
||||||
return log_once("output surface not pitch or format not modelled");
|
// log2 of the block height in GOBs.
|
||||||
|
if (!bpp || okind > 1)
|
||||||
|
return log_once("output surface format or layout not modelled");
|
||||||
|
|
||||||
uint32_t out_pitch = (transpose ? oh : ow) * bpp;
|
// The output as laid out in memory: a transposed target is oh x ow.
|
||||||
uint64_t out_len = (uint64_t)out_pitch * (transpose ? ow : oh);
|
uint32_t out_w = transpose ? oh : ow, out_h = transpose ? ow : oh;
|
||||||
|
uint32_t out_pitch = out_w * bpp, out_gobs = (out_pitch + 63) / 64;
|
||||||
|
uint64_t out_len = okind ? bl_size(out_gobs, ogob, out_h)
|
||||||
|
: (uint64_t)out_pitch * out_h;
|
||||||
uint8_t *dst = vic_dram(state, vic.target, out_len);
|
uint8_t *dst = vic_dram(state, vic.target, out_len);
|
||||||
if (!dst)
|
if (!dst)
|
||||||
return log_once("target outside DRAM");
|
return log_once("target outside DRAM");
|
||||||
@@ -3833,12 +3842,17 @@ static void vic_compose(EmuState *state) {
|
|||||||
if (!(sl[0] & 1) || !vic.sfc[n])
|
if (!(sl[0] & 1) || !vic.sfc[n])
|
||||||
continue;
|
continue;
|
||||||
uint32_t sfmt = bits(sl[8], 0, 7), skind = bits(sl[8], 11, 4);
|
uint32_t sfmt = bits(sl[8], 0, 7), skind = bits(sl[8], 11, 4);
|
||||||
|
uint32_t sgob = 1u << std::min(bits(sl[8], 15, 4), 5u);
|
||||||
uint32_t sw = bits(sl[8], 32, 14) + 1, sh = bits(sl[8], 46, 14) + 1;
|
uint32_t sw = bits(sl[8], 32, 14) + 1, sh = bits(sl[8], 46, 14) + 1;
|
||||||
if (skind != 0 || vic_bpp(sfmt) != bpp) {
|
if (skind > 1 || vic_bpp(sfmt) != bpp) {
|
||||||
log_once("slot surface not pitch or not the output's size of pixel");
|
log_once("slot surface layout not modelled, or not the output's size "
|
||||||
|
"of pixel");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const uint8_t *src = vic_dram(state, vic.sfc[n], (uint64_t)sw * sh * bpp);
|
uint32_t src_pitch = sw * bpp, src_gobs = (src_pitch + 63) / 64;
|
||||||
|
const uint8_t *src = vic_dram(state, vic.sfc[n],
|
||||||
|
skind ? bl_size(src_gobs, sgob, sh)
|
||||||
|
: (uint64_t)src_pitch * sh);
|
||||||
if (!src)
|
if (!src)
|
||||||
continue;
|
continue;
|
||||||
uint32_t sl_l = bits(sl[4], 16, 14), sl_r = bits(sl[4], 48, 14);
|
uint32_t sl_l = bits(sl[4], 16, 14), sl_r = bits(sl[4], 48, 14);
|
||||||
@@ -3858,25 +3872,23 @@ static void vic_compose(EmuState *state) {
|
|||||||
for (uint32_t tx = x0; tx <= x1; tx++)
|
for (uint32_t tx = x0; tx <= x1; tx++)
|
||||||
sxs[tx - x0] = sl_l + (uint32_t)((uint64_t)(tx - dl) *
|
sxs[tx - x0] = sl_l + (uint32_t)((uint64_t)(tx - dl) *
|
||||||
(sl_r - sl_l + 1) / (dr - dl + 1));
|
(sl_r - sl_l + 1) / (dr - dl + 1));
|
||||||
uint32_t src_pitch = sw * bpp;
|
|
||||||
for (uint32_t ty = y0; ty <= y1; ty++) {
|
for (uint32_t ty = y0; ty <= y1; ty++) {
|
||||||
uint32_t sy = sl_t + (uint32_t)((uint64_t)(ty - dt) * (sl_b - sl_t + 1) /
|
uint32_t sy = sl_t + (uint32_t)((uint64_t)(ty - dt) * (sl_b - sl_t + 1) /
|
||||||
(db - dt + 1));
|
(db - dt + 1));
|
||||||
if (sy >= sh)
|
if (sy >= sh)
|
||||||
continue;
|
continue;
|
||||||
const uint8_t *srow = src + (uint64_t)sy * src_pitch;
|
|
||||||
uint32_t fy = flip_y ? oh - 1 - ty : ty;
|
uint32_t fy = flip_y ? oh - 1 - ty : ty;
|
||||||
for (uint32_t tx = x0; tx <= x1; tx++) {
|
for (uint32_t tx = x0; tx <= x1; tx++) {
|
||||||
uint32_t sx = sxs[tx - x0];
|
uint32_t sx = sxs[tx - x0];
|
||||||
if (sx >= sw)
|
if (sx >= sw)
|
||||||
continue;
|
continue;
|
||||||
uint32_t fx = flip_x ? ow - 1 - tx : tx;
|
uint32_t fx = flip_x ? ow - 1 - tx : tx;
|
||||||
uint64_t o = transpose ? (uint64_t)fx * out_pitch + (uint64_t)fy * bpp
|
uint32_t col = transpose ? fy : fx, row = transpose ? fx : fy;
|
||||||
: (uint64_t)fy * out_pitch + (uint64_t)fx * bpp;
|
uint64_t o = okind ? bl_offset(col * bpp, row, out_gobs, ogob)
|
||||||
if (bpp == 4)
|
: (uint64_t)row * out_pitch + (uint64_t)col * bpp;
|
||||||
memcpy(dst + o, srow + (uint64_t)sx * 4, 4);
|
uint64_t i = skind ? bl_offset(sx * bpp, sy, src_gobs, sgob)
|
||||||
else
|
: (uint64_t)sy * src_pitch + (uint64_t)sx * bpp;
|
||||||
memcpy(dst + o, srow + (uint64_t)sx * bpp, bpp);
|
memcpy(dst + o, src + i, bpp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Executable
+76
@@ -0,0 +1,76 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Compare the emulator's frame snapshot with what a display scenario drew.
|
||||||
|
|
||||||
|
Usage: check.py <scenario> <last_fb.rgba> <last_fb.meta>
|
||||||
|
|
||||||
|
last_fb.rgba is the host view, ARGB8888 little-endian, as last_fb.meta's
|
||||||
|
"W H" gives it. The expected picture follows tests/display/payload.c.
|
||||||
|
"""
|
||||||
|
import sys
|
||||||
|
from array import array
|
||||||
|
|
||||||
|
|
||||||
|
def pat(x, y):
|
||||||
|
return 0xFF000000 | ((x * 7) & 0xFF) << 16 | ((y * 3) & 0xFF) << 8 | ((x ^ y) & 0xFF)
|
||||||
|
|
||||||
|
|
||||||
|
def patq(x, y):
|
||||||
|
return 0xFF000000 | ((x * 5 + y) & 0xFF) << 16 | 0x4000 | ((y * 9) & 0xFF)
|
||||||
|
|
||||||
|
|
||||||
|
def blend(s, d, k1):
|
||||||
|
# BLEND_MATCH_SELECT SRC K1, DST NEG_K1 (1 - K1), per channel, opaque.
|
||||||
|
out = 0xFF000000
|
||||||
|
for sh in (0, 8, 16):
|
||||||
|
c = (((s >> sh) & 0xFF) * k1 + ((d >> sh) & 0xFF) * (255 - k1)) // 255
|
||||||
|
out |= min(c, 255) << sh
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
def expected(scenario, w, h):
|
||||||
|
if scenario == 1:
|
||||||
|
return (720, 1280), lambda x, y: pat(x, y)
|
||||||
|
if scenario in (2, 3, 4, 5):
|
||||||
|
# The picture was drawn landscape and turned on its way to the
|
||||||
|
# panel; the view turns it back.
|
||||||
|
return (1280, 720), lambda x, y: pat(x, y)
|
||||||
|
if scenario == 6:
|
||||||
|
def f(x, y):
|
||||||
|
a = pat(x, 1279 - y)
|
||||||
|
if 100 <= x < 300 and 200 <= y < 500:
|
||||||
|
return blend(patq(x - 100, y - 200), a, 128)
|
||||||
|
return a
|
||||||
|
return (720, 1280), f
|
||||||
|
raise SystemExit("unknown scenario %d" % scenario)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
scenario = int(sys.argv[1])
|
||||||
|
w, h = map(int, open(sys.argv[3]).read().split())
|
||||||
|
frame = array("I")
|
||||||
|
with open(sys.argv[2], "rb") as fh:
|
||||||
|
frame.frombytes(fh.read())
|
||||||
|
(ew, eh), f = expected(scenario, w, h)
|
||||||
|
if (w, h) != (ew, eh):
|
||||||
|
print(" FAIL scenario %d: view is %dx%d, expected %dx%d" % (scenario, w, h, ew, eh))
|
||||||
|
return 1
|
||||||
|
bad = 0
|
||||||
|
first = None
|
||||||
|
for y in range(h):
|
||||||
|
row = y * w
|
||||||
|
for x in range(w):
|
||||||
|
want = f(x, y)
|
||||||
|
if frame[row + x] != want:
|
||||||
|
bad += 1
|
||||||
|
if first is None:
|
||||||
|
first = (x, y, frame[row + x], want)
|
||||||
|
if bad:
|
||||||
|
x, y, got, want = first
|
||||||
|
print(" FAIL scenario %d: %d of %d pixels differ; first at (%d,%d): %08X, expected %08X"
|
||||||
|
% (scenario, bad, w * h, x, y, got, want))
|
||||||
|
return 1
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
/* Loaded and entered at 0x40010000, like any RCM payload. */
|
||||||
|
ENTRY(_start)
|
||||||
|
SECTIONS {
|
||||||
|
. = 0x40010000;
|
||||||
|
.text : { KEEP(*(.text.start)) *(.text*) }
|
||||||
|
.rodata : { *(.rodata*) }
|
||||||
|
.data : { *(.data*) }
|
||||||
|
.bss : { *(.bss*) *(COMMON) }
|
||||||
|
/DISCARD/ : { *(.comment) *(.note*) *(.ARM.attributes) *(.ARM.exidx*) }
|
||||||
|
}
|
||||||
@@ -0,0 +1,190 @@
|
|||||||
|
/*
|
||||||
|
* Display regression payload.
|
||||||
|
*
|
||||||
|
* A freestanding BPMP payload that drives the emulator's display controller
|
||||||
|
* and VIC models the way bdk does - window registers through
|
||||||
|
* DISPLAY_WINDOW_HEADER and STATE_CONTROL, VIC through its Falcon register
|
||||||
|
* window and a vic_config_t in DRAM - then parks. tests/display/run.sh
|
||||||
|
* compares the frame the emulator shows (last_fb.rgba) with the picture the
|
||||||
|
* payload drew. Built once per scenario with -DSCENARIO=n:
|
||||||
|
*
|
||||||
|
* 1 a pitch window (hekate's TUI setup)
|
||||||
|
* 2 VIC turns a 1280x720 picture 270 degrees into a pitch surface that
|
||||||
|
* window A shows (Nyx's setup); the view undoes the turn
|
||||||
|
* 3 as 2, but VIC writes a block-linear surface (16-GOB blocks)
|
||||||
|
* 4 VIC copies the picture into a block-linear surface, and window A
|
||||||
|
* shows it turned by the DC itself: SCAN_COLUMN | H_DIRECTION with
|
||||||
|
* ADDR_H_OFFSET at the top-right pixel's last byte (HOS's setup)
|
||||||
|
* 5 as 2, but VIC reads a block-linear source surface
|
||||||
|
* 6 window A mirrored top-bottom (V_DIRECTION, ADDR_V_OFFSET at the
|
||||||
|
* last line), with window D blended over it at K1 = 128
|
||||||
|
*
|
||||||
|
* Every surface holds pat(x, y), which differs between neighbouring
|
||||||
|
* pixels in both directions, so a wrong stride, turn, flip or offset shows
|
||||||
|
* up almost everywhere.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SCENARIO
|
||||||
|
#define SCENARIO 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef unsigned int u32;
|
||||||
|
|
||||||
|
#define REG(a) (*(volatile u32 *)(a))
|
||||||
|
|
||||||
|
#define UARTB_THR 0x70006040u
|
||||||
|
#define DC 0x54200000u
|
||||||
|
#define VIC 0x54340000u
|
||||||
|
|
||||||
|
#define DCR(i) REG(DC + (i) * 4u)
|
||||||
|
/* bdk's _vic_write_priv() for registers with no low address bits. */
|
||||||
|
#define VICP(r) REG(VIC + 0x1000u + ((r) >> 6))
|
||||||
|
|
||||||
|
#define SRC_L 0xC0000000u /* 1280x720 landscape picture, pitch */
|
||||||
|
#define SURF_B 0xC0400000u /* block-linear intermediate */
|
||||||
|
#define DST 0xC0800000u /* what window A scans out */
|
||||||
|
#define SRC_P 0xC0C00000u /* 720x1280 portrait picture, pitch */
|
||||||
|
#define SRC_Q 0xC1000000u /* 200x300 overlay for window D */
|
||||||
|
#define CFG 0xC1400000u /* vic_config_t, 256-byte aligned */
|
||||||
|
|
||||||
|
/* DC window registers (word indices) and bits. */
|
||||||
|
#define WINDOW_HEADER 0x042u
|
||||||
|
#define STATE_CONTROL 0x041u
|
||||||
|
#define WIN_OPTIONS 0x700u
|
||||||
|
#define COLOR_DEPTH 0x703u
|
||||||
|
#define POSITION 0x704u
|
||||||
|
#define SIZE 0x705u
|
||||||
|
#define PRESCALED 0x706u
|
||||||
|
#define LINE_STRIDE 0x70Au
|
||||||
|
#define BLEND_LAYER 0x716u
|
||||||
|
#define BLEND_MATCH 0x717u
|
||||||
|
#define START_ADDR 0x800u
|
||||||
|
#define ADDR_H_OFFSET 0x806u
|
||||||
|
#define ADDR_V_OFFSET 0x808u
|
||||||
|
#define SURFACE_KIND 0x80Bu
|
||||||
|
|
||||||
|
#define H_DIRECTION BIT(0)
|
||||||
|
#define V_DIRECTION BIT(2)
|
||||||
|
#define SCAN_COLUMN BIT(4)
|
||||||
|
#define WIN_ENABLE BIT(30)
|
||||||
|
#define BIT(n) (1u << (n))
|
||||||
|
|
||||||
|
#define KIND_PITCH 0u
|
||||||
|
#define KIND_BLOCK (2u | (4u << 4)) /* block linear, 16-GOB blocks */
|
||||||
|
|
||||||
|
static void puts_(const char *s) {
|
||||||
|
while (*s)
|
||||||
|
REG(UARTB_THR) = (u32)(unsigned char)*s++;
|
||||||
|
}
|
||||||
|
|
||||||
|
static u32 pat(u32 x, u32 y) {
|
||||||
|
return 0xFF000000u | ((x * 7u) & 0xFFu) << 16 | ((y * 3u) & 0xFFu) << 8 |
|
||||||
|
((x ^ y) & 0xFFu);
|
||||||
|
}
|
||||||
|
|
||||||
|
static u32 patq(u32 x, u32 y) {
|
||||||
|
return 0xFF000000u | ((x * 5u + y) & 0xFFu) << 16 | 0x4000u |
|
||||||
|
((y * 9u) & 0xFFu);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void fill(u32 base, u32 w, u32 h, u32 (*f)(u32, u32)) {
|
||||||
|
volatile u32 *p = (volatile u32 *)base;
|
||||||
|
for (u32 y = 0; y < h; y++)
|
||||||
|
for (u32 x = 0; x < w; x++)
|
||||||
|
p[y * w + x] = f(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* One u64 bitfield word of vic_config_t, written as two halves. */
|
||||||
|
static void cfg64(u32 off, u32 lo, u32 hi) {
|
||||||
|
REG(CFG + off) = lo;
|
||||||
|
REG(CFG + off + 4) = hi;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* One VIC compose of a sw x sh X8R8G8B8 surface (slot 0) into a target of
|
||||||
|
* the same size, with bdk's vic_set_surface() field layout. kind: 0 pitch,
|
||||||
|
* 1 block linear; gob: log2 GOBs per block.
|
||||||
|
*/
|
||||||
|
static void vic_compose(u32 src, u32 skind, u32 sgob, u32 dst, u32 okind,
|
||||||
|
u32 ogob, u32 sw, u32 sh, u32 flip_x, u32 transpose) {
|
||||||
|
for (u32 i = 0; i < 0x610; i += 4)
|
||||||
|
REG(CFG + i) = 0;
|
||||||
|
/* OutputConfig: FlipX b48, Transpose b50; TargetRect R b16, B b48. */
|
||||||
|
cfg64(0x10, 0, (flip_x ? BIT(16) : 0) | (transpose ? BIT(18) : 0));
|
||||||
|
cfg64(0x18, (sw - 1) << 16, (sh - 1) << 16);
|
||||||
|
/* OutputSurfaceConfig: X8R8G8B8 (36), BlkKind b11, BlkHeight b15,
|
||||||
|
* width - 1 b32, height - 1 b46. */
|
||||||
|
cfg64(0x20, 36u | okind << 11 | ogob << 15, (sw - 1) | (sh - 1) << 14);
|
||||||
|
/* Slot 0: enable; SourceRect in 16.16; DestRect. */
|
||||||
|
cfg64(0x90, 1, 0);
|
||||||
|
cfg64(0xB0, 0, (sw - 1) << 16);
|
||||||
|
cfg64(0xB8, 0, (sh - 1) << 16);
|
||||||
|
cfg64(0xC0, (sw - 1) << 16, (sh - 1) << 16);
|
||||||
|
cfg64(0xD0, 36u | skind << 11 | sgob << 15, (sw - 1) | (sh - 1) << 14);
|
||||||
|
|
||||||
|
VICP(0x14000) = CFG >> 8; /* VIC_SC_PRAMBASE */
|
||||||
|
VICP(0x14300) = src >> 8; /* VIC_SC_SFC0_BASE_LUMA(0) */
|
||||||
|
VICP(0x22000) = dst >> 8; /* VIC_BL_TARGET_BASADR */
|
||||||
|
VICP(0x10000) = 1; /* VIC_FC_COMPOSE */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Program window w (0 = A .. 3 = D) and activate it. */
|
||||||
|
static void window(u32 w, u32 opts, u32 pos, u32 width, u32 height,
|
||||||
|
u32 stride, u32 kind, u32 addr, u32 h_off, u32 v_off,
|
||||||
|
u32 blend_layer, u32 blend_match) {
|
||||||
|
DCR(WINDOW_HEADER) = BIT(4 + w);
|
||||||
|
DCR(WIN_OPTIONS) = 0;
|
||||||
|
DCR(COLOR_DEPTH) = 0xC; /* B8G8R8A8 */
|
||||||
|
DCR(POSITION) = pos;
|
||||||
|
DCR(SIZE) = height << 16 | width;
|
||||||
|
DCR(PRESCALED) = height << 16 | width * 4;
|
||||||
|
DCR(LINE_STRIDE) = stride;
|
||||||
|
DCR(SURFACE_KIND) = kind;
|
||||||
|
DCR(START_ADDR) = addr;
|
||||||
|
DCR(ADDR_H_OFFSET) = h_off;
|
||||||
|
DCR(ADDR_V_OFFSET) = v_off;
|
||||||
|
DCR(BLEND_LAYER) = blend_layer;
|
||||||
|
DCR(BLEND_MATCH) = blend_match;
|
||||||
|
DCR(WIN_OPTIONS) = opts | WIN_ENABLE;
|
||||||
|
DCR(STATE_CONTROL) = BIT(8) | BIT(9 + w); /* GENERAL + WIN_x_UPDATE */
|
||||||
|
DCR(STATE_CONTROL) = BIT(0) | BIT(1 + w); /* GENERAL + WIN_x_ACT_REQ */
|
||||||
|
}
|
||||||
|
|
||||||
|
#define BYPASS 0x01000000u /* BLEND_LAYER_CONTROL reset: blending bypassed */
|
||||||
|
|
||||||
|
__attribute__((section(".text.start"), noreturn))
|
||||||
|
void _start(void) {
|
||||||
|
#if SCENARIO == 1
|
||||||
|
fill(SRC_P, 720, 1280, pat);
|
||||||
|
window(0, 0, 0, 720, 1280, 720 * 4, KIND_PITCH, SRC_P, 0, 0, BYPASS, 0);
|
||||||
|
#elif SCENARIO == 2
|
||||||
|
fill(SRC_L, 1280, 720, pat);
|
||||||
|
vic_compose(SRC_L, 0, 0, DST, 0, 0, 1280, 720, 1, 1);
|
||||||
|
window(0, 0, 0, 720, 1280, 720 * 4, KIND_PITCH, DST, 0, 0, BYPASS, 0);
|
||||||
|
#elif SCENARIO == 3
|
||||||
|
fill(SRC_L, 1280, 720, pat);
|
||||||
|
vic_compose(SRC_L, 0, 0, DST, 1, 4, 1280, 720, 1, 1);
|
||||||
|
window(0, 0, 0, 720, 1280, 720 * 4, KIND_BLOCK, DST, 0, 0, BYPASS, 0);
|
||||||
|
#elif SCENARIO == 4
|
||||||
|
fill(SRC_L, 1280, 720, pat);
|
||||||
|
vic_compose(SRC_L, 0, 0, SURF_B, 1, 4, 1280, 720, 0, 0);
|
||||||
|
window(0, SCAN_COLUMN | H_DIRECTION, 0, 720, 1280, 1280 * 4, KIND_BLOCK,
|
||||||
|
SURF_B, 1280 * 4 - 1, 0, BYPASS, 0);
|
||||||
|
#elif SCENARIO == 5
|
||||||
|
fill(SRC_L, 1280, 720, pat);
|
||||||
|
vic_compose(SRC_L, 0, 0, SURF_B, 1, 4, 1280, 720, 0, 0);
|
||||||
|
vic_compose(SURF_B, 1, 4, DST, 0, 0, 1280, 720, 1, 1);
|
||||||
|
window(0, 0, 0, 720, 1280, 720 * 4, KIND_PITCH, DST, 0, 0, BYPASS, 0);
|
||||||
|
#elif SCENARIO == 6
|
||||||
|
fill(SRC_P, 720, 1280, pat);
|
||||||
|
fill(SRC_Q, 200, 300, patq);
|
||||||
|
window(0, V_DIRECTION, 0, 720, 1280, 720 * 4, KIND_PITCH, SRC_P, 0, 1279,
|
||||||
|
BYPASS, 0);
|
||||||
|
/* K1 = 128, blending on, depth 0; SRC x K1 + DST x (1 - K1). */
|
||||||
|
window(3, 0, 200u << 16 | 100u, 200, 300, 200 * 4, KIND_PITCH, SRC_Q,
|
||||||
|
0, 0, 128u << 8, 0x72u);
|
||||||
|
#endif
|
||||||
|
puts_("display test: ready\n");
|
||||||
|
for (;;)
|
||||||
|
;
|
||||||
|
}
|
||||||
Executable
+59
@@ -0,0 +1,59 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Display regression test: run each scenario payload (tests/display/payload.c,
|
||||||
|
# built with -DSCENARIO=n) and compare the frame the emulator shows with the
|
||||||
|
# picture the payload drew.
|
||||||
|
# Usage: tests/display/run.sh [rcm_emu] [payload dir]
|
||||||
|
EMU=$(cd "$(dirname "${1:-./rcm_emu}")" && pwd)/$(basename "${1:-./rcm_emu}")
|
||||||
|
DIR=$(cd "${2:-tests/display}" && pwd)
|
||||||
|
HERE=$(cd "$(dirname "$0")" && pwd)
|
||||||
|
LIMIT=${LIMIT:-60}
|
||||||
|
|
||||||
|
names="pitch window|VIC 270-degree turn into a pitch surface|VIC turn into a block-linear surface|DC column scan with an address offset|VIC block-linear source|V mirror with window D blended over"
|
||||||
|
|
||||||
|
run() {
|
||||||
|
n=$1
|
||||||
|
work=$(mktemp -d)
|
||||||
|
# The frame snapshot lands in the working directory.
|
||||||
|
(cd "$work" && SDL_VIDEODRIVER=dummy RCM_EMU_NO_AUDIO=1 \
|
||||||
|
"$EMU" "$DIR/payload_$n.bin" > out.log 2>&1) &
|
||||||
|
pid=$!
|
||||||
|
t=0
|
||||||
|
until grep -q 'display test: ready' "$work/out.log" 2>/dev/null; do
|
||||||
|
sleep 1
|
||||||
|
t=$((t + 1))
|
||||||
|
[ $t -ge "$LIMIT" ] && break
|
||||||
|
done
|
||||||
|
# The renderer writes a snapshot about a second after the frame changes.
|
||||||
|
sleep 3
|
||||||
|
kill $pid 2>/dev/null
|
||||||
|
wait $pid 2>/dev/null
|
||||||
|
name=$(echo "$names" | cut -d'|' -f"$n")
|
||||||
|
if [ ! -f "$work/last_fb.rgba" ]; then
|
||||||
|
echo " FAIL $n: $name (no frame snapshot)"
|
||||||
|
rc=1
|
||||||
|
elif python3 "$HERE/check.py" "$n" "$work/last_fb.rgba" "$work/last_fb.meta"; then
|
||||||
|
echo " ok $n: $name"
|
||||||
|
rc=0
|
||||||
|
else
|
||||||
|
echo " FAIL $n: $name (log: $work/out.log)"
|
||||||
|
rc=1
|
||||||
|
fi
|
||||||
|
[ $rc -eq 0 ] && rm -rf "$work"
|
||||||
|
return $rc
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "display test:"
|
||||||
|
fail=0
|
||||||
|
pids=""
|
||||||
|
for n in 1 2 3 4 5 6; do
|
||||||
|
run "$n" > "$DIR/result_$n.txt" 2>&1 &
|
||||||
|
pids="$pids $!"
|
||||||
|
done
|
||||||
|
n=0
|
||||||
|
for p in $pids; do
|
||||||
|
n=$((n + 1))
|
||||||
|
wait "$p" || fail=1
|
||||||
|
cat "$DIR/result_$n.txt"
|
||||||
|
rm -f "$DIR/result_$n.txt"
|
||||||
|
done
|
||||||
|
[ $fail -eq 0 ] && echo "display test: PASS" || { echo "display test: FAIL"; exit 1; }
|
||||||
Reference in new issue
Block a user