commit c72693840d744ce27613a4067f84cddaf869f1e8
Author: mrfox <jens.se@icloud.com>
AuthorDate: Wed Nov 25 16:26:21 2026 +0100
Commit: mrfox <jens.se@icloud.com>
CommitDate: Wed Nov 25 16:26:21 2026 +0100
xex video: works on hardware; drop the display experiments
The picture shows on the console at 61 fps since the XAM-style commit.
Removes the VdTurnDisplayOn/VdCallGraphicsNotificationRoutines stubs,
makes xex_video_rgb opaque and documents the video test and display path.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---
platform/xex/README.md | 8 ++++++++
platform/xex/runtime/extra_imports.S | 8 --------
platform/xex/runtime/video.c | 14 +++-----------
platform/xex/runtime/xex_video.h | 6 ++----
platform/xex/tests/video/main.cpp | 2 +-
5 files changed, 14 insertions(+), 24 deletions(-)
diff --git a/platform/xex/README.md b/platform/xex/README.md
index f78f689..3dbb274 100644
--- a/platform/xex/README.md
+++ b/platform/xex/README.md
@@ -53,6 +53,13 @@ read-only, so file writes only work on a console.
- **Exit:** returning from `main`/`exit()` calls `XamLoaderTerminateTitle`,
which goes back to the dashboard.
- `xex_runtime.h`: `xex_notify()` (guide notification), timing helpers.
+- **Video** (`xex_video.h`): takes the GPU engines like Direct3D, flips two
+ tiled 32 bpp front buffers with `VdSwap` at vertical blank. On hardware a
+ title's surface only shows once the display LUT is filled and the surface
+ is committed the way XAM does it (0x2840/0x2844 + D1GRPH, then 0x60EC = 1);
+ found by [xsdk](https://github.com/jessenic/xsdk) (docs/HARDWARE.md).
+ Pixels: `B << 24 | G << 16 | R << 8 | A`.
+- **Input** (`xex_input.h`): `XamInputGetState` per port.
## Tests
@@ -60,3 +67,4 @@ read-only, so file writes only work on a console.
|---|---|
| `tests/hello` | static constructors, C++ exceptions, `std::regex`, notifications, exit to dashboard |
| `tests/fs` | time, `clock()`, directory listing, write/append/read/seek/stat/mkdir/remove on every device; writes `game:/fs-test-report.txt` |
+| `tests/video` | CPU-drawn frames at 60 fps through the title's own GPU ring, controller input (d-pad moves a square, A/B/X/Y colour it); logs to `game:/video-log.txt`, exits after 20 s or on Back+Start |
diff --git a/platform/xex/runtime/extra_imports.S b/platform/xex/runtime/extra_imports.S
index 604119d..2ebb0ad 100644
--- a/platform/xex/runtime/extra_imports.S
+++ b/platform/xex/runtime/extra_imports.S
@@ -46,11 +46,3 @@ xbox360_stub VdQueryVideoMode, 0x010001ca
xbox360_end VdInitializeScalerCommandBuffer, 0x010001c5
.endif
-/* Display output control (xboxkrnl 0x1DE / 0x1DD); arguments unknown,
- * called with 0. Direct3D turns the output on once a title's first frame
- * is up. */
-xbox360_stub VdTurnDisplayOn, 0x010001de
-xbox360_stub VdTurnDisplayOff, 0x010001dd
-
-/* VdCallGraphicsNotificationRoutines(1, ...) - xboxkrnl 0x1B1 */
-xbox360_stub VdCallGraphicsNotificationRoutines, 0x010001b1
diff --git a/platform/xex/runtime/video.c b/platform/xex/runtime/video.c
index 4d422a4..902a877 100644
--- a/platform/xex/runtime/video.c
+++ b/platform/xex/runtime/video.c
@@ -25,9 +25,6 @@ extern ULONG VdInitializeScalerCommandBuffer(ULONG source_xy, ULONG source_wh, U
ULONG horizontal_filter_type, void *horizontal_filter,
ULONG unknown9, PULONG commands, ULONG command_dwords);
-extern ULONG VdTurnDisplayOn(ULONG unknown);
-extern ULONG VdCallGraphicsNotificationRoutines(ULONG unknown0, ULONG unknown1, ULONG unknown2);
-
void (*xex_video_trace)(const char *fmt, ...);
#define TRACE(...) do { if (xex_video_trace) xex_video_trace(__VA_ARGS__); } while (0)
@@ -483,11 +480,9 @@ static void submit_flip(uint32_t address, const uint32_t fetch_constant[6])
}
/*
- * Program the display scaler the way Direct3D does after device creation:
- * the kernel writes scaler packets (source surface -> output mode) into a
- * NOP-filled buffer, which goes into the command ring. Without it the
- * scanout of a title surface is not shown (black screen on hardware;
- * Xenia does not emulate the scaler).
+ * Optional (xex_video_scaler_via_kernel): the scaler program Direct3D gets
+ * from the kernel. Not needed to show a picture (the kernel's scaler
+ * setting is kept), and it hung on hardware with these arguments.
*/
#define SCALER_COMMAND_DWORDS 200 /* 0x320 bytes, as D3D uses */
@@ -596,9 +591,6 @@ static void load_identity_gamma(void)
TRACE("gamma: identity LUT %s", (gpu_read(0x64a0 / 4) & 2) ? "loaded" : "timed out");
}
-uint32_t xex_video_turn_display_on(void) { return VdTurnDisplayOn(0); }
-uint32_t xex_video_call_notifications(void) { return VdCallGraphicsNotificationRoutines(1, 0, 0); }
-
int xex_video_scaler_via_kernel = 0;
const char *xex_video_error(void)
diff --git a/platform/xex/runtime/xex_video.h b/platform/xex/runtime/xex_video.h
index 56c0d69..e19b4cf 100644
--- a/platform/xex/runtime/xex_video.h
+++ b/platform/xex/runtime/xex_video.h
@@ -44,8 +44,6 @@ void xex_video_dump_registers(const char *label);
uint32_t xex_video_read_register(uint32_t offset);
void xex_video_write_register(uint32_t offset, uint32_t value);
void xex_video_dump_lut(void);
-uint32_t xex_video_turn_display_on(void); /* VdTurnDisplayOn(0) */
-uint32_t xex_video_call_notifications(void); /* VdCallGraphicsNotificationRoutines(1, 0, 0) */
/* Nonzero: program the scaler with VdInitializeScalerCommandBuffer at init
* (hangs on hardware so far). */
extern int xex_video_scaler_via_kernel;
@@ -54,7 +52,7 @@ extern int xex_video_scaler_via_kernel;
void xex_video_shutdown(void);
/* Word index of pixel (x, y) in a tiled surface of `pitch` pixels. The
- * pixel word is B << 24 | G << 16 | R << 8. */
+ * pixel word is B << 24 | G << 16 | R << 8 | A (opaque: A = 0xff). */
static inline int xex_video_tiled_index(int x, int y, int pitch)
{
return (((y >> 5) * 32 * pitch + ((x >> 5) << 10)
@@ -64,7 +62,7 @@ static inline int xex_video_tiled_index(int x, int y, int pitch)
static inline uint32_t xex_video_rgb(uint8_t r, uint8_t g, uint8_t b)
{
- return ((uint32_t)b << 24) | ((uint32_t)g << 16) | ((uint32_t)r << 8);
+ return ((uint32_t)b << 24) | ((uint32_t)g << 16) | ((uint32_t)r << 8) | 0xffu;
}
#ifdef __cplusplus
diff --git a/platform/xex/tests/video/main.cpp b/platform/xex/tests/video/main.cpp
index a4ca595..f79691b 100644
--- a/platform/xex/tests/video/main.cpp
+++ b/platform/xex/tests/video/main.cpp
@@ -85,7 +85,7 @@ int main(int, char **) {
} else {
c = xex_video_rgb((uint8_t)(x + t), (uint8_t)(y + t / 2), 96);
}
- f.pixels[xex_video_tiled_index(f.window_x + x, py, f.pitch)] = c | 0xff;
+ f.pixels[xex_video_tiled_index(f.window_x + x, py, f.pitch)] = c;
}
}
xex_video_present();