Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/d3d9-bridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ in the environment.)
- From the app: the bundled library is used by default; `P2_RENDERER=opengl
"~/Applications/Portal 2 Natif.app/Contents/MacOS/launcher"` forces OpenGL.
- `P2_D3D9_VENDOR_ID` / `P2_D3D9_DEVICE_ID` (hex): PCI ids handed to the
library for `D3DADAPTER_IDENTIFIER9` (default Apple `106b` / `0000`; Source
keys vendor-specific paths on them). `P2_D3D9_CACHE`: shader/PSO cache
library for `D3DADAPTER_IDENTIFIER9` (default NVIDIA `10de` / `0000`; Source
keys vendor-specific paths on them, and with Apple `106b` it turns off the
shadow depth textures of dynamic lights). `P2_D3D9_CACHE`: shader/PSO cache
directory (default `<user_dir>/d3d9metal-cache`).
- Memory caps: before `d3d9metal_init` the runtime puts
`memory.pageboxPoolCapMB=64;memory.vbibRetentionCapMB=192;memory.vramBudgetMB=1024`
Expand Down
6 changes: 4 additions & 2 deletions runtime/d3d9.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,10 @@ static void fill_host(void) {
.size = sizeof(D3D9MetalHost), .user = NULL,
.metal_layer = host_metal_layer, .alloc_app = host_alloc_app, .free_app = host_free_app,
.blocking_begin = host_blocking_begin, .blocking_end = host_blocking_end,
// Apple par défaut : aucune branche propre à un fabricant dans Source.
.vendor_id = env_id("P2_D3D9_VENDOR_ID", 0x106b), .device_id = env_id("P2_D3D9_DEVICE_ID", 0),
// NVIDIA par défaut : avec un fabricant inconnu (Apple, 0x106b), shaderapivk
// désactive les textures de profondeur des ombres dynamiques
// (r_flashlightdepthtexture 0, issue #20). OpenGL les a déjà.
.vendor_id = env_id("P2_D3D9_VENDOR_ID", 0x10de), .device_id = env_id("P2_D3D9_DEVICE_ID", 0),
.cache_dir = NULL,
};
const char *env = getenv("P2_D3D9_CACHE"), *user = rt_user_root();
Expand Down
4 changes: 2 additions & 2 deletions tests/checks_d3d9.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,15 @@ RT_CHECK(d3d9_bridge_against_fake_native_library) {
assert(rt_shim(&c, "Direct3DCreate9") == 1);
uint32_t d3d_proxy = c.eax;
assert(d3d_proxy && R32(d3d_proxy + 4) == tag(D3D9_IDirect3D9) && R64(d3d_proxy + 8) == (uintptr_t)&d3d);
assert(fake_host && fake_host->vendor_id == 0x106b && fake_host->metal_layer && fake_host->alloc_app);
assert(fake_host && fake_host->vendor_id == 0x10de && fake_host->metal_layer && fake_host->alloc_app);
assert(!strcmp(rt_dynamic_import_name(R32(R32(d3d_proxy) + 4 * 16)), "IDirect3D9::CreateDevice"));

// D3DADAPTER_IDENTIFIER9 : 1100 octets i386, rien au-delà.
uint32_t id = SCRATCH;
memset(GPTR(id), 0xcc, 1104);
assert(CALL(d3d_proxy, IDirect3D9, GetAdapterIdentifier, 0, 0, id).eax == 0);
assert(!strcmp((const char *)GPTR(id + 512), "Fake Metal GPU") && R64(id + 1056) == 0x0001000200030004ull);
assert(R32(id + 1064) == 0x106b && R32(id + 1068) == 0x1234 && R8(id + 1095) == 0x5a && R32(id + 1096) == 0xabcd);
assert(R32(id + 1064) == 0x10de && R32(id + 1068) == 0x1234 && R8(id + 1095) == 0x5a && R32(id + 1096) == 0xabcd);
assert(R32(id + 1100) == 0xccccccccu);

// CreateDevice : D3DPRESENT_PARAMETERS i386 (56 octets, HWND en 0x1c) traduits et réécrits.
Expand Down
Loading