> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# DispatchRaysX (XBOX Series 主機)

> DispatchRays 的可擴充版本。工作記憶體集可由使用者提供。

DispatchRays 的可擴充版本。工作記憶體集可由使用者提供。

## 語法

```cpp theme={null}
void DispatchRaysX(  
         const D3D12XBOX_DISPATCH_RAYS_DESC* pDesc  
)  
```

### 參數

*pDesc*   \_In\_\
類型：[D3D12XBOX\_DISPATCH\_RAYS\_DESC\*](/zh-TW/reference/graphics/d3d12_xs/structs/d3d12xbox_dispatch_rays_desc)

DispatchRays 在內部會使用驅動程式配置來存放 DXR 堆疊，並自動同步處理對該記憶體的存取。DispatchRaysX 則允許遊戲指定自己的記憶體配置與大小。驅動程式會相應地調整內部光線追蹤 Dispatch 的大小。

### 傳回值

類型：void

## 備註

範例 1：應用程式使用自己的記憶體配置，且必須確保適當的同步處理

```CPP theme={null}
D3D12XBOX_DISPATCH_RAYS_DESC dispatchDescX {};
dispatchDescX.DispatchArgs = dispatchDesc;
dispatchDescX.Scratch.StartAddress = m_customStackScratch->GetGPUVirtualAddress();
dispatchDescX.Scratch.SizeInBytes = CUSTOM_SCRATCH_SIZE;
m_commandList->DispatchRaysX(&dispatchDescX);  
```

暫存記憶體的大小可以大致估算，例如驅動程式對所有分派都使用相同大小的暫存空間 (只是改變執行中的波數目)，也可以適當地調整大小。請注意，由於佔用率降低，極度緊縮的暫存空間會對效能造成一些影響。如果需要更精確的計算，可以使用 GetInformationX 進行查詢。

範例 2：使用 GetInformationX 查詢每個波所需的暫存空間量

```CPP theme={null}
D3D12XBOX_RAYTRACING_INFORMATION stats {};
ComPtr<ID3D12StateObjectProperties> stateObjectProperties;
auto& ref = ComPtr<ID3D12StateObject>(pRTPSO);
ThrowIfFailed(ref.As(&stateObjectProperties));
stateObjectProperties->GetInformationX(0, &stats);  
```

"stats" 結構內有一個名為 ScratchSize 的欄位，代表每個通道所需的暫存空間位元組數。暫存空間以 1024B 為區塊進行配置，因此若要取得一個波的安全配置量，需要計算 ScratchSize \* 32 (XDXR 在內部一律以 wave 32 執行)，並將其無條件進位至 1KB。

## 需求

**標頭：** d3d12\_xs.h

**程式庫：** d3d12\_xs.lib\
**支援的平台：** XBOX Series 主機

## 另請參閱

[ID3D12GraphicsCommandList6](/zh-TW/reference/graphics/d3d12_xs/interfaces/ID3D12GraphicsCommandList6/id3d12graphicscommandlist6)


## Related topics

- [DispatchRays (XBOX Series consoles)](/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist4/methods/id3d12graphicscommandlist4_dispatchrays_public.md)
- [DispatchRays (consolas XBOX Series)](/es/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist4/methods/id3d12graphicscommandlist4_dispatchrays_public.md)
- [DispatchRays (XBOX Series 主机)](/zh-CN/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist4/methods/id3d12graphicscommandlist4_dispatchrays_public.md)
- [DispatchRays (XBOX Series 콘솔)](/ko/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist4/methods/id3d12graphicscommandlist4_dispatchrays_public.md)
- [DispatchRays (XBOX Series 本体)](/ja-jp/reference/graphics/d3d12/interfaces/id3d12graphicscommandlist4/methods/id3d12graphicscommandlist4_dispatchrays_public.md)
