本文整理汇总了C++中TVector::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ TVector::Add方法的具体用法?C++ TVector::Add怎么用?C++ TVector::Add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TVector
的用法示例。
在下文中一共展示了TVector::Add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateInputLayoutDescFromVertexShaderSignature
HRESULT FMaterial::CreateInputLayoutDescFromVertexShaderSignature(ID3D11ShaderReflection* VertexShaderReflection, ID3DBlob* VertexShaderBlob, ID3D11Device* Device)
{
// Get shader info
D3D11_SHADER_DESC ShaderDescription;
VertexShaderReflection->GetDesc(&ShaderDescription);
// Read input layout description from shader info
TVector<D3D11_INPUT_ELEMENT_DESC> InputLayoutDesc;
for (size_t i = 0; i < ShaderDescription.InputParameters; i++)
{
D3D11_SIGNATURE_PARAMETER_DESC ParamDescription;
VertexShaderReflection->GetInputParameterDesc(i, &ParamDescription);
// fill out input element desc
D3D11_INPUT_ELEMENT_DESC ElementDesc;
ElementDesc.SemanticName = ParamDescription.SemanticName;
ElementDesc.SemanticIndex = ParamDescription.SemanticIndex;
ElementDesc.InputSlot = 0;
ElementDesc.AlignedByteOffset = D3D11_APPEND_ALIGNED_ELEMENT;
ElementDesc.InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
ElementDesc.InstanceDataStepRate = 0;
// determine DXGI format
if (ParamDescription.Mask == 1)
{
if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_UINT32) ElementDesc.Format = DXGI_FORMAT_R32_UINT;
else if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_SINT32) ElementDesc.Format = DXGI_FORMAT_R32_SINT;
else if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_FLOAT32) ElementDesc.Format = DXGI_FORMAT_R32_FLOAT;
}
else if (ParamDescription.Mask <= 3)
{
if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_UINT32) ElementDesc.Format = DXGI_FORMAT_R32G32_UINT;
else if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_SINT32) ElementDesc.Format = DXGI_FORMAT_R32G32_SINT;
else if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_FLOAT32) ElementDesc.Format = DXGI_FORMAT_R32G32_FLOAT;
}
else if (ParamDescription.Mask <= 7)
{
if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_UINT32) ElementDesc.Format = DXGI_FORMAT_R32G32B32_UINT;
else if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_SINT32) ElementDesc.Format = DXGI_FORMAT_R32G32B32_SINT;
else if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_FLOAT32) ElementDesc.Format = DXGI_FORMAT_R32G32B32_FLOAT;
}
else if (ParamDescription.Mask <= 15)
{
if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_UINT32) ElementDesc.Format = DXGI_FORMAT_R32G32B32A32_UINT;
else if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_SINT32) ElementDesc.Format = DXGI_FORMAT_R32G32B32A32_SINT;
else if (ParamDescription.ComponentType == D3D_REGISTER_COMPONENT_FLOAT32) ElementDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
}
if (strcmp(ParamDescription.SemanticName, "COLOR") == 0)
{
// Special case: colour is actually a r8b8g8a8_unorm.
ElementDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
}
//save element desc
InputLayoutDesc.Add(ElementDesc);
}
// Special case here:
// If we're using SV_VertexID only then we don't actually need an input layout.
if (InputLayoutDesc.Size() == 1 && strcmp(InputLayoutDesc[0].SemanticName, "SV_VertexID") != -1)
{
return S_OK;
}
// Try to create Input Layout
HRESULT hr = Device->CreateInputLayout(&InputLayoutDesc[0], InputLayoutDesc.Size(), VertexShaderBlob->GetBufferPointer(), VertexShaderBlob->GetBufferSize(), &InputLayout);
return hr;
}