> ## 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.

# GetShaderStackSize (XBOX Series 主機)

> 取得在 HLSL 中叫用光線追蹤著色器所需的堆疊記憶體數量。

取得在 HLSL 中叫用光線追蹤著色器所需的堆疊記憶體數量。

## 語法

```cpp theme={null}
UINT64 GetShaderStackSize(
    LPCWSTR pExportName
)
```

### 參數

*pExportName*\
類型：LPCWSTR

狀態物件中要擷取其堆疊大小的著色器進入點。對於命中群組，必須使用下列語法指定命中群組中的個別著色器：

hitGroupName::shaderType

其中 <i>hitGroupName</i> 是命中群組的進入點名稱，而 <i>shaderType</i> 是下列其中之一：

<ul>
  <li>intersection</li>
  <li>anyhit</li>
  <li>closesthit</li>
</ul>

這些值全都區分大小寫。

範例值為："myTreeLeafHitGroup::anyhit"。

### 傳回值

類型：UINT64

叫用著色器所需的堆疊記憶體數量 (以位元組為單位)。如果著色器在狀態物件中未完全解析，或著色器未知，或屬於與堆疊大小無關的類型 (例如命中群組)，傳回值為 0xffffffff。UINT64 傳回值使用 32 位元的 0xffffffff 值，以確保在計算整體管線堆疊大小時與其他值加總，不正確的傳回值不會遺失。

## 備註

只有在應用程式想要呼叫 [SetPipelineStackSize](/zh-TW/reference/graphics/d3d12/interfaces/id3d12stateobjectproperties/methods/id3d12stateobjectproperties_setpipelinestacksize_public) 來設定堆疊大小，而不是依賴保守的預設堆疊大小時，才需要呼叫此方法。此方法僅對光線產生著色器、命中群組、遺漏著色器和可呼叫著色器有效。即使是光線產生著色器，儘管位於堆疊底部，也可能傳回非零值。

對於命中群組，必須查詢組成命中群組之個別著色器 (相交著色器、任何命中著色器、最接近命中著色器) 的堆疊大小，因為每個著色器的堆疊大小需求可能不同。無法直接查詢這些個別著色器的堆疊大小，因為它們的編譯方式可能會受到包含它們的整體命中群組影響。<i>pExportName</i> 參數包含用於識別命中群組內個別著色器的語法。

此 API 可以在集合狀態物件或光線追蹤管線狀態物件上呼叫。

## 需求

**標頭:** d3d12\_xs.h\
**程式庫:** d3d12\_xs.lib\
**支援的平台**: XBOX Series 主機

## 另請參閱

[ID3D12StateObjectProperties](/zh-TW/reference/graphics/d3d12_xs/interfaces/ID3D12StateObjectProperties/id3d12stateobjectproperties)


## Related topics

- [SetPipelineStackSize (XBOX Series 主機)](/zh-TW/reference/graphics/d3d12/interfaces/id3d12stateobjectproperties/methods/id3d12stateobjectproperties_setpipelinestacksize_public.md)
- [GetPipelineStackSize (XBOX Series 主機)](/zh-TW/reference/graphics/d3d12/interfaces/id3d12stateobjectproperties/methods/id3d12stateobjectproperties_getpipelinestacksize_public.md)
- [GetShaderIdentifier (XBOX Series 主機)](/zh-TW/reference/graphics/d3d12/interfaces/id3d12stateobjectproperties/methods/id3d12stateobjectproperties_getshaderidentifier_public.md)
- [D3D12_RAYTRACING_SHADER_CONFIG (XBOX Series 主機)](/zh-TW/reference/graphics/d3d12/structs/d3d12_raytracing_shader_config_public.md)
- [ShaderCacheControl (XBOX Series 主機)](/zh-TW/reference/graphics/d3d12/interfaces/id3d12device9/methods/id3d12device9_shadercachecontrol_public.md)
