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

# D3D12_SHADER_COMPONENT_MAPPING

> Especifica como a memória é roteada por uma SRV (exibição de recurso de sombreador).

Especifica como a memória é roteada por uma SRV (exibição de recurso de sombreador).

## Sintaxe

```cpp theme={null}
typedef enum D3D12_SHADER_COMPONENT_MAPPING
{
    D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_0 = 0,
    D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_1 = 1,
    D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_2 = 2,
    D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_3 = 3,
    D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_0 = 4,
    D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_1 = 5
} D3D12_SHADER_COMPONENT_MAPPING
```

## Constantes

| Constante | Descrição |
| - | - |
| D3D12\_SHADER\_COMPONENT\_MAPPING\_FROM\_MEMORY\_COMPONENT\_0 | Indica o componente de retorno 0 (vermelho). |
| D3D12\_SHADER\_COMPONENT\_MAPPING\_FROM\_MEMORY\_COMPONENT\_1 | Indica o componente de retorno 1 (verde). |
| D3D12\_SHADER\_COMPONENT\_MAPPING\_FROM\_MEMORY\_COMPONENT\_2 | Indica o componente de retorno 2 (azul). |
| D3D12\_SHADER\_COMPONENT\_MAPPING\_FROM\_MEMORY\_COMPONENT\_3 | Indica o componente de retorno 3 (alfa). |
| D3D12\_SHADER\_COMPONENT\_MAPPING\_FORCE\_VALUE\_0 | Indica que o valor resultante deve ser forçado para 0. |
| D3D12\_SHADER\_COMPONENT\_MAPPING\_FORCE\_VALUE\_1 | Indica que o valor resultante deve ser forçado para 1. O valor de forçar 1 é 0x1 ou 1.0f, dependendo do tipo de formato desse componente no formato de origem. |

## Comentários

Esta enumeração permite que a SRV selecione como a memória é roteada para os quatro componentes de retorno em um sombreador após uma busca na memória. As opções para cada componente do sombreador \[0..3] (correspondentes a RGBA) são: componente 0..3 do resultado da busca da SRV, ou forçar 0, ou forçar 1.

O mapeamento padrão 1:1 pode ser indicado especificando **D3D12\_DEFAULT\_SHADER\_4\_COMPONENT\_MAPPING**; caso contrário, um mapeamento arbitrário pode ser especificado usando a macro **D3D12\_ENCODE\_SHADER\_4\_COMPONENT\_MAPPING**.

Veja abaixo.

Observe as definições a seguir.

```cpp theme={null}
#define D3D12_SHADER_COMPONENT_MAPPING_MASK 0x7
#define D3D12_SHADER_COMPONENT_MAPPING_SHIFT 3
#define D3D12_SHADER_COMPONENT_MAPPING_ALWAYS_SET_BIT_AVOIDING_ZEROMEM_MISTAKES \
(1<<(D3D12_SHADER_COMPONENT_MAPPING_SHIFT*4))
#define D3D12_ENCODE_SHADER_4_COMPONENT_MAPPING(Src0,Src1,Src2,Src3) \
((((Src0)&D3D12_SHADER_COMPONENT_MAPPING_MASK)| \
(((Src1)&D3D12_SHADER_COMPONENT_MAPPING_MASK)<<D3D12_SHADER_COMPONENT_MAPPING_SHIFT)| \
(((Src2)&D3D12_SHADER_COMPONENT_MAPPING_MASK)<<(D3D12_SHADER_COMPONENT_MAPPING_SHIFT*2))| \
(((Src3)&D3D12_SHADER_COMPONENT_MAPPING_MASK)<<(D3D12_SHADER_COMPONENT_MAPPING_SHIFT*3))| \
D3D12_SHADER_COMPONENT_MAPPING_ALWAYS_SET_BIT_AVOIDING_ZEROMEM_MISTAKES))
#define D3D12_DECODE_SHADER_4_COMPONENT_MAPPING(ComponentToExtract,Mapping) \
((D3D12_SHADER_COMPONENT_MAPPING)(Mapping >> (D3D12_SHADER_COMPONENT_MAPPING_SHIFT*ComponentToExtract) & D3D12_SHADER_COMPONENT_MAPPING_MASK))
#define D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING D3D12_ENCODE_SHADER_4_COMPONENT_MAPPING(0,1,2,3)
```

## Requisitos

**Cabeçalho:** d3d12\_xs.h ou d3d12\_x.h\
**Biblioteca:** d3d12\_xs.lib ou d3d12\_x.lib\
**Plataformas com suporte**: consoles XBOX Series e família XBOX One

## Confira também

[Enumerações principais](https://learn.microsoft.com/en-us/windows/desktop/direct3d12/direct3d-12-enumerations)


## Related topics

- [D3D12_SHADER_RESOURCE_VIEW_DESC](/pt-BR/reference/graphics/d3d12/structs/d3d12_shader_resource_view_desc_public.md)
- [D3D12_SHADER_VISIBILITY](/pt-BR/reference/graphics/d3d12/enums/d3d12_shader_visibility_public.md)
- [D3D12_SHADER_BYTECODE](/pt-BR/reference/graphics/d3d12/structs/d3d12_shader_bytecode_public.md)
- [D3D12_TILE_MAPPING_FLAGS](/pt-BR/reference/graphics/d3d12/enums/d3d12_tile_mapping_flags_public.md)
- [D3D12_SHADER_CACHE_FLAGS](/pt-BR/reference/graphics/d3d12/enums/d3d12_shader_cache_flags_public.md)
