Skip to content

d3d12: Add support for Xbox GDK

Ethan Lee requested to merge flibitijibibo/mesa:xbox-d3d12 into main

This is a (very very extremely) early draft that allows building and running the GLon12 Mesa driver on Xbox One and Xbox Series X|S, via the Xbox Game Development Kit.

This patch was written primarily to be used by FNA and its upcoming revamp of Xbox support. As part of this work, we also submitted GDK support for Meson, which was submitted (and merged!) here. The feature is being developed in a partnership between the FNA team and Eden Industries, an experienced development studio for console and mobile games.

Thankfully (and perhaps expectedly, since you're reading this from the public repo!) this change required no disclosures of private code/binaries - we were able to get this working with minor changes, using terminology/defines visible from Microsoft's own public example code. However, building/running this still requires a private GDKX agreement with Microsoft, and will not work with the PC-only GDK.

Right off the bat, we got some really good notes from Jesse that we still need to apply, so here they are:

  • The change for D3D12SerializeVersionedRootSignature I'd propose doing a bit differently – I think it'd be cleaner if that function was moved to the screen. Then, when constructing an Xbox screen you can just reference the function by name like you're doing. Otherwise when constructing a PC screen, we already have the util_dl_get_proc_address call for D3D12CreateDevice, we can grab the root signature export at the same time. I'd do that kind of refactoring as a first commit (moving the export to the screen, updating callers to get at it from the screen), and then when you add the Xbox screen variation in a later commit, it's pretty straightforward to just assign the new field. Done!
  • I think the MAX_SCISSOR update can just be done without an #ifdef Done!
  • I don't like WINSYS_HANDLE_TYPE_D3D12_HEAP only because it's already a pretty big wart to have a backend-specific type in that common header... fortunately there's plenty of fields in that struct that are unused when dealing with WINSYS_HANDLE_TYPE_D3D12_RES, and there's only one place that'll ever store a heap in there, so I think it's reasonable to just assign something (maybe modifier) to identify that it's a heap instead of a resource. Done!

Aside from the above, we'd also really like to undo the clunky IID_GRAPHICS_PPV_ARGS define which encompasses a large percentage of the current patch and could easily be fixed in the Xbox configuration without making a special define for everyone else Done!.

This draft MR exists so that others can keep a close eye on what we're doing - our top priority is to upstream this both to ease maintenance and allow others to deploy OpenGL applications on Xbox devices.

As a final bonus, here is SDL's testgl2 application running on real hardware (can't see much for obvious reasons, but it's real!):

IMG_1534

Edited by Ethan Lee

Merge request reports