MCPcopy Create free account
hub / github.com/davideberly/GeometricTools / DX11InputLayout

Method DX11InputLayout

GTE/Graphics/DX11/DX11InputLayout.cpp:17–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15}
16
17DX11InputLayout::DX11InputLayout(ID3D11Device* device,
18 VertexBuffer const* vbuffer, Shader const* vshader)
19 :
20 mLayout(nullptr),
21 mNumElements(0)
22{
23 LogAssert(vbuffer != nullptr && vshader != nullptr, "Invalid inputs.");
24
25 std::memset(&mElements[0], 0, VAConstant::MAX_ATTRIBUTES*sizeof(mElements[0]));
26
27 VertexFormat const& format = vbuffer->GetFormat();
28 mNumElements = format.GetNumAttributes();
29 for (int32_t i = 0; i < mNumElements; ++i)
30 {
31 VASemantic semantic{};
32 DFType type{};
33 uint32_t unit{}, offset{};
34 format.GetAttribute(i, semantic, type, unit, offset);
35
36 D3D11_INPUT_ELEMENT_DESC& element = mElements[i];
37 element.SemanticName = msSemantic[semantic];
38 element.SemanticIndex = unit;
39 element.Format = static_cast<DXGI_FORMAT>(type);
40 element.InputSlot = 0; // TODO: Streams not yet supported.
41 element.AlignedByteOffset = offset;
42 element.InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
43 element.InstanceDataStepRate = 0;
44 }
45
46 auto const& compiledCode = vshader->GetCompiledCode();
47 DX11Log(device->CreateInputLayout(mElements, (UINT)mNumElements,
48 &compiledCode[0], compiledCode.size(), &mLayout));
49}
50
51void DX11InputLayout::Enable(ID3D11DeviceContext* context)
52{

Callers

nothing calls this directly

Calls 3

GetNumAttributesMethod · 0.80
GetAttributeMethod · 0.80
GetFormatMethod · 0.45

Tested by

no test coverage detected