Compare commits

...
Author SHA1 Message Date
ates 808c5d17c5 Merge remote-tracking branch 'origin/main' into track-e/680-xuser-duplicate
Signed-off-by: ates <ahmetrizaates@hotmail.com>

# Conflicts:
#	CHANGELOG.md
2026-11-29 16:50:01 +03:00
Ateş 64f9b1dcb5 Merge pull request #684 from MacosPorters/track-c/669-serialized-pipelines-fail
[Boot] d3d12_xs: fail serialized and derived pipeline calls in null-render mode
2026-11-29 15:44:46 +03:00
Ateş 740df46b10 Merge pull request #689 from MacosPorters/process/agent-self-setup
[Process] A collaborator only says "work": the agent makes the machine ready itself
2026-11-29 15:44:23 +03:00
erkinemreta1 77af218878 d3d12_xs: fail serialized and derived pipeline calls in null-render mode
Signed-off-by: erkinemreta1 <erkinemreta1@users.noreply.github.com>
2026-11-29 14:08:41 +03:00
ates 620019564b xgameruntime: restore the XUserDuplicateHandle implementation (#680)
The previous commit on this branch recorded main's com_dispatch.cpp and
xgameruntime.cpp by mistake (they had been restored into the index for
the negative-control run), which removed the fix and left only its
test. This puts the implementation back; it is the code the fixture was
built and run against.

Signed-off-by: ates <ahmetrizaates@hotmail.com>
2026-11-29 11:46:43 +03:00
ates 36a0f3f6c5 xgameruntime: XUserDuplicateHandle through IXUser slot 3 (#680)
Slot 3 follows the public XUser.h order (duplicate, close, compare). A
duplicate is a new handle to the one offline user; each handle is closed
on its own; XUserCompare returns 0 for two valid handles of that user.
A project-authorized target build duplicates its user handle after
sign-in and waited when the slot returned E_NOTIMPL.

test_xgameruntime obtains a user, duplicates it through the slot, and
checks comparison, independent closing, refusal of a closed handle with
the out pointer cleared, and E_POINTER. It fails on the previous
runtime. Built and run on D3DMetal; the earlier WIP commit on this
branch holds the code.

Signed-off-by: ates <ahmetrizaates@hotmail.com>
2026-11-29 11:38:36 +03:00
ates 29c8a29051 Merge remote-tracking branch 'origin/main' into track-e/680-xuser-duplicate 2026-11-29 11:37:55 +03:00
ates 9239ba6551 WIP: XUserDuplicateHandle through IXUser slot 3 (#680), not yet built or tested
Signed-off-by: ates <ahmetrizaates@hotmail.com>
2026-11-29 11:22:02 +03:00
7 changed files with 295 additions and 17 deletions

No files matched your search

+2
View File
@@ -26,6 +26,7 @@ remains unsupported.
- `dxbc-accc` no longer classifies `DXIL` chunks whose bitcode payload starts with the `NOBC` header-only placeholder as executable DXIL (Track D prerequisite from ADR 0008 / `docs/roadmap.md`). `inspect_dxbc` and `bx_shader_inspect` still report the container's `dxil_chunk_size`, stage, and shader model, but leave `kind` as `Unknown` (or `AcccOnly` when paired with an `ACCC` chunk) instead of `Dxil` or `DualDxilAndAccc`, and `bx_shader_prepare_for_d3dmetal` returns `BX_SHADER_ERR_UNSUPPORTED` rather than passing a bitcode-less container through. Covered by synthetic `NOBC`, mixed-chunk, and bounds-safety unit tests in `dxbc-accc`; live CrossOver execution is unchanged.
### Added
- `xgameruntime.dll` serves `XUserDuplicateHandle` through `IXUser` slot 3 (#680). A duplicate is a new handle to the one offline user; each handle is closed on its own, and `XUserCompare` returns 0 for any two valid handles of that user. A project-authorized target build duplicates its user handle after sign-in and waited when the slot was unimplemented. `test_xgameruntime` checks the slot through `QueryApiImpl`.
- Shader corpus, Phase 0 of the console shader translator (#649). `shader-transpiler/corpus/hlsl/` holds eight BetterXen-authored compute kernels covering integer and float ALU, divergent branches, loops, groupshared memory, wave operations, atomics and system values. `scripts/shader-corpus/build.sh` compiles each one locally with the console `xdxc` (a title-style container: `DXIL` plus `ACCC`/`FSPX`), the console PIX compiler (Microsoft's ISA listing) and the public PC DXC (DXIL for a D3DMetal reference run). `extract_code.py` then takes the code from the `FSPX` kind-6 section, skips the leading `v_nop_xbox_data` words and disassembles it with LLVM's public `gfx1030` decoder. All eight kernels build and decode cleanly. The extractor has nine unit tests on synthetic containers that need no GDK. Compiler outputs stay in the git-ignored `target/shader-corpus/`. One open question is recorded: a `v_cmp_class_f16` in the `wave` kernel's ballot sequence.
- `docs/research/console-shader-abi.md` and `CLAIM-XBOX-CS-ENTRY-ABI` (class U, not yet independently reproduced): the compute shader entry ABI observed from the NewBE backend of Microsoft's Series X|S PIX shader compiler, used under Microsoft's authorization, on eleven project-authored probes. Compute code is wave64. Root data starts at `s4` in root-parameter order: one SGPR per constant, two per root descriptor address, one per 32-bit table pointer. The thread-group IDs follow the root data, and `s0:s1` holds the root-data address when it overflows. Root buffer descriptors are built inline with no effective bounds check, table buffer descriptors are 32 bytes apart (samplers 16), and the compiler reports the HLSL binding of each descriptor load. No compiler output, binary or documentation text is in the repository. Register roles are inferences, and the ACCC container layout remains unknown.
- Opt-in diagnostics in `bx_runtime_veh.dll`, all off by default:
@@ -86,6 +87,7 @@ remains unsupported.
- `d3d12_xs.dll!D3D12ConfigureVirtualMemoryX` now decodes the Xbox virtual-memory configuration (`D3D12XBOX_VIRTUAL_MEMORY_CONFIGURATION`) alongside the existing `BXVM` contract. Layout and behaviour follow the authorized GDK documentation of the function and structure: no flags, a GPU page-table size in 4 MB units clamped to 33, a frame-buffer preserve size (0, -1 for the legacy size, or bytes clamped to 64 MiB), and two output addresses, the minimum always 2 GiB and the maximum 159.375 GiB at the default 5 pages. The call fails with `E_FAIL` once a D3D12 device exists. Call-site observation of a project-authorized target build agrees with the documented layout. Inferred, and marked as such: the maximum for other page-table sizes scales linearly (`max_estimated=1` in the log), and a page-table size of 0, an unreadable configuration or unwritable outputs fail with `E_INVALIDARG`. The host sizes no GPU page tables and keeps no cross-process frame buffer, so the path records both (`vmem_config_recorded`, `applied=0 recorded_only=1`), leaves the `BXVM` record and cached backing heap untouched, and still emits `BX_STUB_LOG`. `tests/conformance/test_d3d12_vmem_xbox/` checks the documented outputs, clamps and post-device `E_FAIL`, the refused cases, and that a cached `BXVM` backing heap survives.
### Fixed
- `d3d12_xs.dll` no longer turns `DeserializeGraphicsPipelineStateX`, `DeserializeComputePipelineStateX`, `CreateDerivedGraphicsPipelineStateX` or `CreateDerivedComputePipelineStateX` into null pipelines in null-render mode (`BX_NULL_RENDER=1`) (#669). All four calls now always return `E_NOTIMPL`, clear `*ppv` and log `pipeline_refused` without `; null pipeline returned`, so a title falls back to creating pipelines from shader containers instead of silently receiving null pipelines. `test_d3d12_serialized_pipelines` checks all four slots and their refusal log lines with `BX_NULL_RENDER=1` active alongside a control shader-container null pipeline.
- `XCRDAPI.dll` Xbox DirectStorage fixes:
- **Zlib requests read the file.** The file handle was not set for them, so every compressed file request failed. The request options are now decoded, and zlib streams are inflated in-tree.
- **`AutoSubmitDisabled` is honoured.** Xbox `CreateQueueX` respects `DSTORAGE_QUEUE_OPTIONS.AutoSubmitDisabled`: a queue with the flag runs nothing before `Submit`, and when it is full the enqueuer waits until `Submit` is called on another thread. A queue without the flag submits by itself once half full.
+26 -17
View File
@@ -173,6 +173,13 @@ HRESULT refused(ID3D12Device* device, HRESULT hr, const char* kind, REFIID riid,
return bx_xbox_wrap_result(S_OK, riid, ppv);
}
HRESULT refused_always_fail(HRESULT hr, const char* kind) {
char detail[128];
std::snprintf(detail, sizeof(detail), "%s pipeline refused hr=0x%08lx", kind, static_cast<unsigned long>(hr));
bx_log_emit(BX_LOG_WARN, "d3d12_xs", "pipeline_refused", detail);
return hr;
}
void log_extended(const char* kind, UINT count) {
if (!count) return;
char detail[96];
@@ -433,33 +440,35 @@ void STDMETHODCALLTYPE bx_xbox_allocator_set_callback_x(void*, void* callback, U
/*
* DeserializeGraphics/ComputePipelineStateX create a pipeline from a serialized console pipeline
* (console shader code), which has no host form. They fail with E_NOTIMPL (logged as a refused
* pipeline); in null-render mode they return a null pipeline like any other refused pipeline.
* (console shader code), which has no host form. They always fail with E_NOTIMPL and log
* `pipeline_refused` — even in null-render mode — so a title falls back to creating its pipelines
* from shader containers instead of receiving a null pipeline (#669).
*/
extern "C" HRESULT STDMETHODCALLTYPE bx_xbox_device_deserialize_graphics_pipeline_state_x(void* self, const void*, REFIID riid,
extern "C" HRESULT STDMETHODCALLTYPE bx_xbox_device_deserialize_graphics_pipeline_state_x(void*, const void*, REFIID,
void** ppv) {
BX_D3D_TRACE("XboxDevice", "DeserializeGraphicsPipelineStateX");
if (!ppv) return E_POINTER;
*ppv = nullptr;
return refused(bx_xbox_host<ID3D12Device>(self), E_NOTIMPL, "deserialized graphics (console code)", riid, ppv);
return refused_always_fail(E_NOTIMPL, "deserialized graphics (console code)");
}
extern "C" HRESULT STDMETHODCALLTYPE bx_xbox_device_deserialize_compute_pipeline_state_x(void* self, const void*, REFIID riid,
extern "C" HRESULT STDMETHODCALLTYPE bx_xbox_device_deserialize_compute_pipeline_state_x(void*, const void*, REFIID,
void** ppv) {
BX_D3D_TRACE("XboxDevice", "DeserializeComputePipelineStateX");
if (!ppv) return E_POINTER;
*ppv = nullptr;
return refused(bx_xbox_host<ID3D12Device>(self), E_NOTIMPL, "deserialized compute (console code)", riid, ppv);
return refused_always_fail(E_NOTIMPL, "deserialized compute (console code)");
}
/*
* CreateDerived{Graphics,Compute}PipelineStateX: a pipeline equal to `source` with some state
* groups replaced. Derived from a null pipeline, the result is a null pipeline too. Deriving
* from a host pipeline needs its creation description, which this layer does not keep yet: that
* case is refused (logged) and, in null-render mode, is a null pipeline as well.
* groups replaced. Deriving from a host pipeline needs its creation description, which this layer
* does not keep yet. Both calls always fail with E_NOTIMPL and log `pipeline_refused` — even in
* null-render mode — so a title falls back to creating its pipelines from shader containers
* instead of silently receiving null pipelines (#669).
*/
namespace {
HRESULT derived(void* self, ID3D12PipelineState* source, REFIID riid, void** ppv, const char* kind) {
HRESULT derived(ID3D12PipelineState* source, void** ppv, const char* kind) {
if (!ppv) return E_POINTER;
*ppv = nullptr;
const bool from_null = bx_xbox_pipeline_is_null(source);
@@ -470,18 +479,18 @@ HRESULT derived(void* self, ID3D12PipelineState* source, REFIID riid, void** ppv
"deriving from a host pipeline is not implemented (its creation description is not kept)");
}
}
return refused(bx_xbox_host<ID3D12Device>(self), E_NOTIMPL, kind, riid, ppv);
return refused_always_fail(E_NOTIMPL, kind);
}
} // namespace
extern "C" HRESULT STDMETHODCALLTYPE bx_xbox_device_create_derived_graphics_pipeline_state_x(void* self, ID3D12PipelineState* source,
UINT, const void*, REFIID riid, void** ppv) {
extern "C" HRESULT STDMETHODCALLTYPE bx_xbox_device_create_derived_graphics_pipeline_state_x(void*, ID3D12PipelineState* source,
UINT, const void*, REFIID, void** ppv) {
BX_D3D_TRACE("XboxDevice", "CreateDerivedGraphicsPipelineStateX");
return derived(self, source, riid, ppv, "derived graphics");
return derived(source, ppv, "derived graphics");
}
extern "C" HRESULT STDMETHODCALLTYPE bx_xbox_device_create_derived_compute_pipeline_state_x(void* self, ID3D12PipelineState* source,
UINT, const void*, REFIID riid, void** ppv) {
extern "C" HRESULT STDMETHODCALLTYPE bx_xbox_device_create_derived_compute_pipeline_state_x(void*, ID3D12PipelineState* source,
UINT, const void*, REFIID, void** ppv) {
BX_D3D_TRACE("XboxDevice", "CreateDerivedComputePipelineStateX");
return derived(self, source, riid, ppv, "derived compute");
return derived(source, ppv, "derived compute");
}
+11
View File
@@ -45,6 +45,8 @@ void WINAPI XAsyncCancel(void*);
HRESULT WINAPI XUserAddAsync(uint32_t, void*);
HRESULT WINAPI XUserAddResult(void*, void**);
void WINAPI XUserCloseHandle(void*);
HRESULT WINAPI bx_xuser_duplicate_handle(void*, void**);
bool WINAPI bx_xuser_is_handle(void*);
HRESULT WINAPI XUserGetId(void*, uint64_t*);
HRESULT WINAPI XUserGetGamertag(void*, uint32_t, size_t, char*, size_t*);
HRESULT WINAPI XUserGetTokenAndSignatureAsync(void*, uint32_t, const char*, const char*, size_t, const void*, size_t,
@@ -433,8 +435,16 @@ std::unordered_set<uint64_t> user_event_tokens;
void WINAPI user_close_handle(void*, void* h) {
XUserCloseHandle(h);
}
HRESULT WINAPI user_duplicate_handle(void*, void* user, void** out) {
const HRESULT hr = bx_xuser_duplicate_handle(user, out);
bx_log_emit(SUCCEEDED(hr) ? BX_LOG_INFO : BX_LOG_WARN, "xgameruntime", "XUserDuplicateHandle",
SUCCEEDED(hr) ? "duplicate handle for the offline user" : "invalid user handle");
return hr;
}
int32_t WINAPI user_compare(void*, void* u1, void* u2) {
if (u1 == u2) return 0;
// One offline user: every valid handle (duplicates included) names the same user.
if (bx_xuser_is_handle(u1) && bx_xuser_is_handle(u2)) return 0;
return reinterpret_cast<uintptr_t>(u1) < reinterpret_cast<uintptr_t>(u2) ? -1 : 1;
}
HRESULT WINAPI user_get_max_users(void*, uint32_t* max_users) {
@@ -517,6 +527,7 @@ HRESULT WINAPI user_get_gamertag(void*, void* user, uint32_t comp, size_t sz, ch
const std::array<const void*, 64> kUserVtbl = [] {
auto v = make_default_vtbl<64>();
v[3] = reinterpret_cast<const void*>(&user_duplicate_handle);
v[4] = reinterpret_cast<const void*>(&user_close_handle);
v[5] = reinterpret_cast<const void*>(&user_compare);
v[6] = reinterpret_cast<const void*>(&user_get_max_users);
+15
View File
@@ -643,6 +643,21 @@ HRESULT WINAPI XUserAddResult(AsyncBlock* block, void** out) {
return result;
}
// Not exported: XUserDuplicateHandle is reached through IXUser (com_dispatch.cpp). A duplicate is
// a new handle to the same (single, offline) user; each handle is closed separately.
HRESULT WINAPI bx_xuser_duplicate_handle(void* user, void** out) {
if (!out) return E_POINTER;
*out = nullptr;
std::lock_guard lock(state_mutex);
if (!users.contains(user)) return runtime_invalid_handle;
return create_handle(users, out);
}
bool WINAPI bx_xuser_is_handle(void* user) {
std::lock_guard lock(state_mutex);
return users.contains(user);
}
void WINAPI XUserCloseHandle(void* user) {
std::lock_guard lock(state_mutex);
users.erase(user);
@@ -0,0 +1,3 @@
add_executable(test_d3d12_serialized_pipelines main.cpp)
target_compile_definitions(test_d3d12_serialized_pipelines PRIVATE WIDL_EXPLICIT_AGGREGATE_RETURNS)
target_link_libraries(test_d3d12_serialized_pipelines PRIVATE d3d12_xs kernel32 uuid)
@@ -0,0 +1,198 @@
/*
* Conformance test for #669: serialized and derived Xbox pipeline-state calls must fail with
* E_NOTIMPL and log `pipeline_refused` even when BX_NULL_RENDER=1 is active, so a title falls
* back to creating pipelines from shader containers instead of silently receiving null pipelines.
*
* Slot numbers follow the Xbox Series ID3D12Device vtable layout (ADR 0009):
* 2 = Release
* 11 = CreateComputePipelineState
* 55 = CreateDerivedGraphicsPipelineStateX
* 57 = DeserializeGraphicsPipelineStateX
* 63 = CreateDerivedComputePipelineStateX
* 67 = DeserializeComputePipelineStateX
*/
#include <windows.h>
#include <d3d12.h>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <string>
extern "C" __declspec(dllimport) HRESULT WINAPI D3D12XboxCreateDevice(PVOID adapter, const void* params, REFIID riid,
void** ppv);
namespace {
constexpr int kRelease = 2;
constexpr int kDevCreateComputePipelineState = 11;
constexpr int kDevCreateDerivedGraphicsPipelineStateX = 55;
constexpr int kDevDeserializeGraphicsPipelineStateX = 57;
constexpr int kDevCreateDerivedComputePipelineStateX = 63;
constexpr int kDevDeserializeComputePipelineStateX = 67;
int g_checks = 0;
int g_failed = 0;
#define CHECK(cond, ...) \
do { \
++g_checks; \
if (!(cond)) { \
++g_failed; \
std::fprintf(stderr, "FAIL: test_d3d12_serialized_pipelines:%d: ", __LINE__); \
std::fprintf(stderr, __VA_ARGS__); \
std::fprintf(stderr, "\n"); \
} \
} while (0)
template <typename Fn>
Fn slot(void* object, int index) {
return reinterpret_cast<Fn>((*static_cast<void* const* const*>(object))[index]);
}
using ReleaseFn = ULONG(STDMETHODCALLTYPE*)(void*);
using CreateComputePsoFn = HRESULT(STDMETHODCALLTYPE*)(void*, const D3D12_COMPUTE_PIPELINE_STATE_DESC*, REFIID, void**);
using DeserializePsoFn = HRESULT(STDMETHODCALLTYPE*)(void*, const void*, REFIID, void**);
using CreateDerivedPsoFn = HRESULT(STDMETHODCALLTYPE*)(void*, ID3D12PipelineState*, UINT, const void*, REFIID, void**);
std::string read_log() {
char path[MAX_PATH];
const DWORD n = GetEnvironmentVariableA("BX_LOG_FILE", path, sizeof(path));
if (n == 0 || n >= sizeof(path)) return {};
std::string text;
if (FILE* f = std::fopen(path, "rb")) {
char buffer[4096];
size_t got;
while ((got = std::fread(buffer, 1, sizeof(buffer), f)) > 0) text.append(buffer, got);
std::fclose(f);
}
return text;
}
bool log_has_refusal_without_null(const std::string& log, const char* kind) {
size_t pos = 0;
while (pos < log.size()) {
size_t end = log.find('\n', pos);
if (end == std::string::npos) end = log.size();
const std::string line = log.substr(pos, end - pos);
if (line.find("\"event\":\"pipeline_refused\"") != std::string::npos && line.find(kind) != std::string::npos) {
return line.find("null pipeline returned") == std::string::npos;
}
pos = end + 1;
}
return false;
}
} // namespace
int main() {
// Enable null-render mode before any pipeline call so d3d12_xs caches BX_NULL_RENDER=1.
SetEnvironmentVariableA("BX_NULL_RENDER", "1");
alignas(8) unsigned char title_params[80] = {};
const UINT version = 0x20004;
std::memcpy(title_params, &version, sizeof(version));
void* dev = nullptr;
HRESULT hr = D3D12XboxCreateDevice(nullptr, title_params, __uuidof(ID3D12Device), &dev);
if (hr == E_NOINTERFACE) {
std::printf("SKIP: test_d3d12_serialized_pipelines: host lacks Xbox-layout device interface (E_NOINTERFACE)\n");
return 77;
}
CHECK(hr == S_OK && dev != nullptr, "Xbox-layout device creation hr=0x%08lx", static_cast<unsigned long>(hr));
if (!dev) return 1;
// 1. Control check: a refused shader-container pipeline still becomes a null pipeline when
// BX_NULL_RENDER=1, confirming null-render mode is active.
static const uint8_t kBogusShader[16] = {0x44, 0x58, 0x42, 0x43};
D3D12_COMPUTE_PIPELINE_STATE_DESC compute_desc{};
compute_desc.CS.pShaderBytecode = kBogusShader;
compute_desc.CS.BytecodeLength = sizeof(kBogusShader);
void* null_pso = nullptr;
hr = slot<CreateComputePsoFn>(dev, kDevCreateComputePipelineState)(
dev, &compute_desc, __uuidof(ID3D12PipelineState), &null_pso);
CHECK(hr == S_OK && null_pso != nullptr,
"control: refused CreateComputePipelineState returns null pipeline in BX_NULL_RENDER=1 (hr=0x%08lx)",
static_cast<unsigned long>(hr));
// 2. Serialized pipeline calls must fail with E_NOTIMPL and clear *ppv even with BX_NULL_RENDER=1.
auto* sentinel = reinterpret_cast<void*>(static_cast<uintptr_t>(0xDEAD));
void* out = sentinel;
hr = slot<DeserializePsoFn>(dev, kDevDeserializeGraphicsPipelineStateX)(
dev, nullptr, __uuidof(ID3D12PipelineState), &out);
CHECK(hr == E_NOTIMPL && out == nullptr,
"DeserializeGraphicsPipelineStateX must fail with E_NOTIMPL and null out (hr=0x%08lx, out=%p)",
static_cast<unsigned long>(hr), out);
hr = slot<DeserializePsoFn>(dev, kDevDeserializeGraphicsPipelineStateX)(
dev, nullptr, __uuidof(ID3D12PipelineState), nullptr);
CHECK(hr == E_POINTER, "DeserializeGraphicsPipelineStateX(ppv=nullptr) must return E_POINTER (hr=0x%08lx)",
static_cast<unsigned long>(hr));
out = sentinel;
hr = slot<DeserializePsoFn>(dev, kDevDeserializeComputePipelineStateX)(
dev, nullptr, __uuidof(ID3D12PipelineState), &out);
CHECK(hr == E_NOTIMPL && out == nullptr,
"DeserializeComputePipelineStateX must fail with E_NOTIMPL and null out (hr=0x%08lx, out=%p)",
static_cast<unsigned long>(hr), out);
hr = slot<DeserializePsoFn>(dev, kDevDeserializeComputePipelineStateX)(
dev, nullptr, __uuidof(ID3D12PipelineState), nullptr);
CHECK(hr == E_POINTER, "DeserializeComputePipelineStateX(ppv=nullptr) must return E_POINTER (hr=0x%08lx)",
static_cast<unsigned long>(hr));
// 3. Derived pipeline calls must also fail with E_NOTIMPL and clear *ppv (both from a null
// pipeline source and from a nullptr source) even with BX_NULL_RENDER=1.
auto* null_src = static_cast<ID3D12PipelineState*>(null_pso);
out = sentinel;
hr = slot<CreateDerivedPsoFn>(dev, kDevCreateDerivedGraphicsPipelineStateX)(
dev, null_src, 0, nullptr, __uuidof(ID3D12PipelineState), &out);
CHECK(hr == E_NOTIMPL && out == nullptr,
"CreateDerivedGraphicsPipelineStateX(null source) must fail with E_NOTIMPL and null out (hr=0x%08lx, out=%p)",
static_cast<unsigned long>(hr), out);
out = sentinel;
hr = slot<CreateDerivedPsoFn>(dev, kDevCreateDerivedGraphicsPipelineStateX)(
dev, nullptr, 0, nullptr, __uuidof(ID3D12PipelineState), &out);
CHECK(hr == E_NOTIMPL && out == nullptr,
"CreateDerivedGraphicsPipelineStateX(nullptr) must fail with E_NOTIMPL and null out (hr=0x%08lx, out=%p)",
static_cast<unsigned long>(hr), out);
hr = slot<CreateDerivedPsoFn>(dev, kDevCreateDerivedGraphicsPipelineStateX)(
dev, null_src, 0, nullptr, __uuidof(ID3D12PipelineState), nullptr);
CHECK(hr == E_POINTER, "CreateDerivedGraphicsPipelineStateX(ppv=nullptr) must return E_POINTER (hr=0x%08lx)",
static_cast<unsigned long>(hr));
out = sentinel;
hr = slot<CreateDerivedPsoFn>(dev, kDevCreateDerivedComputePipelineStateX)(
dev, null_src, 0, nullptr, __uuidof(ID3D12PipelineState), &out);
CHECK(hr == E_NOTIMPL && out == nullptr,
"CreateDerivedComputePipelineStateX(null source) must fail with E_NOTIMPL and null out (hr=0x%08lx, out=%p)",
static_cast<unsigned long>(hr), out);
out = sentinel;
hr = slot<CreateDerivedPsoFn>(dev, kDevCreateDerivedComputePipelineStateX)(
dev, nullptr, 0, nullptr, __uuidof(ID3D12PipelineState), &out);
CHECK(hr == E_NOTIMPL && out == nullptr,
"CreateDerivedComputePipelineStateX(nullptr) must fail with E_NOTIMPL and null out (hr=0x%08lx, out=%p)",
static_cast<unsigned long>(hr), out);
hr = slot<CreateDerivedPsoFn>(dev, kDevCreateDerivedComputePipelineStateX)(
dev, null_src, 0, nullptr, __uuidof(ID3D12PipelineState), nullptr);
CHECK(hr == E_POINTER, "CreateDerivedComputePipelineStateX(ppv=nullptr) must return E_POINTER (hr=0x%08lx)",
static_cast<unsigned long>(hr));
// 4. When BX_LOG_FILE is active, verify each refusal was logged without "null pipeline returned".
const std::string log = read_log();
if (!log.empty()) {
CHECK(log_has_refusal_without_null(log, "deserialized graphics (console code)"),
"log must record deserialized graphics refusal without null pipeline");
CHECK(log_has_refusal_without_null(log, "deserialized compute (console code)"),
"log must record deserialized compute refusal without null pipeline");
CHECK(log_has_refusal_without_null(log, "derived graphics"),
"log must record derived graphics refusal without null pipeline");
CHECK(log_has_refusal_without_null(log, "derived compute"),
"log must record derived compute refusal without null pipeline");
}
if (null_pso) slot<ReleaseFn>(null_pso, kRelease)(null_pso);
slot<ReleaseFn>(dev, kRelease)(dev);
std::printf("%s: test_d3d12_serialized_pipelines (%d of %d checks passed)\n",
g_failed ? "FAIL" : "PASS", g_checks - g_failed, g_checks);
return g_failed ? 1 : 0;
}
@@ -802,6 +802,46 @@ int main() {
CHECK(unreg_ev(com_user, ev_tok, false));
CHECK(!unreg_ev(com_user, ev_tok, false));
// XUserDuplicateHandle, XUserCloseHandle and XUserCompare through IXUser slots 3, 4 and 5
// (#680). Slot numbers follow the public XUser.h declaration order; the expected behaviour
// is the documented one: a duplicate is a separate handle to the same user, each handle
// is closed on its own, and XUserCompare returns 0 for two handles of one user.
{
auto dup = reinterpret_cast<HRESULT(WINAPI*)(void*, void*, void**)>(user_vtbl[3]);
auto close = reinterpret_cast<void(WINAPI*)(void*, void*)>(user_vtbl[4]);
auto compare = reinterpret_cast<int32_t(WINAPI*)(void*, void*, void*)>(user_vtbl[5]);
auto get_id = reinterpret_cast<HRESULT(WINAPI*)(void*, void*, uint64_t*)>(user_vtbl[11]);
Async add{nullptr, nullptr, nullptr, {}};
CHECK(XUserAddAsync(1, &add) == S_OK);
CHECK(XAsyncGetStatus(&add, true) == S_OK);
void* original = nullptr;
CHECK(XUserAddResult(&add, &original) == S_OK && original);
void* copy = nullptr;
CHECK(dup(com_user, original, &copy) == S_OK && copy && copy != original);
CHECK(compare(com_user, original, copy) == 0 && compare(com_user, copy, original) == 0);
uint64_t copy_id = 0;
CHECK(get_id(com_user, copy, &copy_id) == S_OK && copy_id == 0x0009000000000001ULL);
// Closing the original leaves the duplicate valid, and the other way round.
close(com_user, original);
uint64_t gone = 0;
CHECK(FAILED(XUserGetId(original, &gone)));
CHECK(get_id(com_user, copy, &copy_id) == S_OK);
void* second = nullptr;
CHECK(dup(com_user, copy, &second) == S_OK && second && second != copy);
close(com_user, copy);
CHECK(FAILED(XUserGetId(copy, &gone)));
CHECK(XUserGetId(second, &gone) == S_OK);
// A closed or unknown handle is refused and the out pointer is cleared.
void* refused = reinterpret_cast<void*>(uintptr_t{0x1234});
CHECK(FAILED(dup(com_user, copy, &refused)) && refused == nullptr);
CHECK(dup(com_user, second, nullptr) == E_POINTER);
CHECK(compare(com_user, second, copy) != 0);
close(com_user, second);
}
check_delayed_callback(query_api);
}