Skip to content

VertexTypes

Chuck Walbourn edited this page Jun 28, 2016 · 10 revisions

The VertexTypes.h header defines these commonly used vertex data structures:

  • VertexPosition
  • VertexPositionColor
  • VertexPositionTexture
  • VertexPositionDualTexture
  • VertexPositionNormal
  • VertexPositionColorTexture
  • VertexPositionNormalColor
  • VertexPositionNormalTexture
  • VertexPositionNormalColorTexture

Header

#include <VertexTypes.h>

Input Layout

Each type provides a D3D12_INPUT_LAYOUT_DESC structure which can be used to create a Pipeline State Object (PSO):

D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc = {};
psoDesc.InputLayout = VertexPositionColor::InputLayout;
...
DX::ThrowIfFailed(
    device->CreateGraphicsPipelineState(&psoDesc,
        IID_PPV_ARGS(m_pipelineState.ReleaseAndGetAddressOf())));

They are typically used with EffectPipelineStateDescription:

RenderTargetState rtState(m_deviceResources->GetBackBufferFormat(),
    m_deviceResources->GetDepthBufferFormat());

EffectPipelineStateDescription pd(
    &VertexPositionColor::InputLayout,
    &CommonStates::Opaque,
    &CommonStates::DepthDefault,
    &CommonStates::CullNone,
    &rtState);

Usage

Position (which uses the semantic "SV_Position") is required for all rendering. This is XMFLOAT3 (DXGI_FORMAT_R32G32B32_FLOAT).

Normal is required for any effect that supports lighting computations. This is XMFLOAT3 (DXGI_FORMAT_R32G32B32_FLOAT).

Color is for per-vertex coloring used by some effects. Color is typically XMFLOAT4(DXGI_FORMAT_R32G32B32A32_FLOAT).

Texture coordinates (which uses the semantic "TEXCOORD0") are XMFLOAT2 (DXGI_FORMAT_R32G32_FLOAT).

DualTexture coordinates (which uses the semantic "TEXCOORD0" and "TEXCOORD1") are XMFLOAT2 (DXGI_FORMAT_R32G32_FLOAT).

Geometry formats

See DirectXMesh for more information.

DirectX SDK SDKMESH

The .SDKMESH format describes input layouts as Direct3D 9 style vertex decls. There is therefore no specific vertex structure for .SDKMESH data and such input layouts are built on-the-fly. The Model loader attempts to create input layouts that match the needs of the standard Effects, so it can end up ignoring some of the vertex layout content if the critical content is found first.

Remarks

The DirectX 11 version of DirectX Tool Kit also defines VertexPositionNormalTangentColorTexture and VertexPositionNormalTangentColorTextureSkinning created to support the Visual Studio DGSL/CMO content pipeline which is not implemented for DirectX 12.

For Use

  • Universal Windows Platform apps
  • Windows desktop apps
  • Windows 11
  • Windows 10
  • Xbox One
  • Xbox Series X|S

Architecture

  • x86
  • x64
  • ARM64

For Development

  • Visual Studio 2022
  • Visual Studio 2019 (16.11)
  • clang/LLVM v12 - v18
  • MinGW 12.2, 13.2
  • CMake 3.20

Related Projects

DirectX Tool Kit for DirectX 11

DirectXMesh

DirectXTex

DirectXMath

Tools

Test Suite

Model Viewer

Content Exporter

DxCapsViewer

See also

DirectX Landing Page

Clone this wiki locally