| 272 | } |
| 273 | |
| 274 | void RootSignatureDX12::ToString(StringBuilder& sb, bool singleLine) const |
| 275 | { |
| 276 | // Flags |
| 277 | sb.Append(TEXT("RootFlags(ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT)")); |
| 278 | |
| 279 | // Parameters |
| 280 | const Char newLine = singleLine ? ' ' : '\n'; |
| 281 | for (const D3D12_ROOT_PARAMETER& param : _parameters) |
| 282 | { |
| 283 | const Char* visibility = GetRootSignatureShaderVisibility(param.ShaderVisibility); |
| 284 | switch (param.ParameterType) |
| 285 | { |
| 286 | case D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE: |
| 287 | sb.AppendFormat(TEXT(",{}DescriptorTable("), newLine); |
| 288 | for (uint32 rangeIndex = 0; rangeIndex < param.DescriptorTable.NumDescriptorRanges; rangeIndex++) |
| 289 | { |
| 290 | if (rangeIndex) |
| 291 | sb.Append(TEXT(", ")); |
| 292 | const D3D12_DESCRIPTOR_RANGE& range = param.DescriptorTable.pDescriptorRanges[rangeIndex]; |
| 293 | switch (range.RangeType) |
| 294 | { |
| 295 | case D3D12_DESCRIPTOR_RANGE_TYPE_SRV: |
| 296 | sb.AppendFormat(TEXT("SRV(t{}"), range.BaseShaderRegister); |
| 297 | break; |
| 298 | case D3D12_DESCRIPTOR_RANGE_TYPE_UAV: |
| 299 | sb.AppendFormat(TEXT("UAV(u{}"), range.BaseShaderRegister); |
| 300 | break; |
| 301 | case D3D12_DESCRIPTOR_RANGE_TYPE_CBV: |
| 302 | sb.AppendFormat(TEXT("CBV(b{}"), range.BaseShaderRegister); |
| 303 | break; |
| 304 | case D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER: |
| 305 | sb.AppendFormat(TEXT("Sampler(s{}"), range.BaseShaderRegister); |
| 306 | break; |
| 307 | } |
| 308 | if (range.NumDescriptors != 1) |
| 309 | { |
| 310 | if (range.NumDescriptors == UINT_MAX) |
| 311 | sb.Append(TEXT(", numDescriptors=unbounded")); |
| 312 | else |
| 313 | sb.AppendFormat(TEXT(", numDescriptors={}"), range.NumDescriptors); |
| 314 | } |
| 315 | if (range.OffsetInDescriptorsFromTableStart != D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND) |
| 316 | sb.AppendFormat(TEXT(", offset={}"), range.OffsetInDescriptorsFromTableStart); |
| 317 | sb.Append(')'); |
| 318 | } |
| 319 | sb.AppendFormat(TEXT("{})"), visibility); |
| 320 | break; |
| 321 | case D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS: |
| 322 | sb.AppendFormat(TEXT(",{}RootConstants(num32BitConstants={}, b{}{})"), newLine, param.Constants.Num32BitValues, param.Constants.ShaderRegister, visibility); |
| 323 | break; |
| 324 | case D3D12_ROOT_PARAMETER_TYPE_CBV: |
| 325 | sb.AppendFormat(TEXT(",{}CBV(b{}{})"), newLine, param.Descriptor.ShaderRegister, visibility); |
| 326 | break; |
| 327 | case D3D12_ROOT_PARAMETER_TYPE_SRV: |
| 328 | sb.AppendFormat(TEXT(",{}SRV(t{}{})"), newLine, param.Descriptor.ShaderRegister, visibility); |
| 329 | break; |
| 330 | case D3D12_ROOT_PARAMETER_TYPE_UAV: |
| 331 | sb.AppendFormat(TEXT(",{}UAV(u{}{})"), newLine, param.Descriptor.ShaderRegister, visibility); |
no test coverage detected