本文整理汇总了C++中microsoft::wrl::ComPtr::GetInputParameterDesc方法的典型用法代码示例。如果您正苦于以下问题:C++ ComPtr::GetInputParameterDesc方法的具体用法?C++ ComPtr::GetInputParameterDesc怎么用?C++ ComPtr::GetInputParameterDesc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类microsoft::wrl::ComPtr
的用法示例。
在下文中一共展示了ComPtr::GetInputParameterDesc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createShaders
bool Shader::createShaders(const Microsoft::WRL::ComPtr<ID3D11Device> &pDevice
, const std::wstring &shaderFile, const std::string &vsFunc, const std::string &psFunc)
{
// vertex shader
{
Microsoft::WRL::ComPtr<ID3DBlob> vblob;
HRESULT hr = CompileShaderFromFile(shaderFile.c_str(), vsFunc.c_str(), "vs_4_0_level_9_1", &vblob);
if (FAILED(hr))
return false;
hr = pDevice->CreateVertexShader(vblob->GetBufferPointer(), vblob->GetBufferSize(), NULL, &m_pVsh);
if (FAILED(hr))
return false;
// vertex shader reflection
Microsoft::WRL::ComPtr<ID3D11ShaderReflection> pReflector;
hr = D3DReflect(vblob->GetBufferPointer(), vblob->GetBufferSize(), IID_ID3D11ShaderReflection, &pReflector);
if (FAILED(hr))
return false;
OutputDebugPrintfA("#### VertexShader ####\n");
if (!m_constant->Initialize(pDevice, SHADERSTAGE_VERTEX, pReflector)){
return false;
}
D3D11_SHADER_DESC shaderdesc;
pReflector->GetDesc(&shaderdesc);
// Create InputLayout
std::vector<D3D11_INPUT_ELEMENT_DESC> vbElement;
for (size_t i = 0; i < shaderdesc.InputParameters; ++i){
D3D11_SIGNATURE_PARAMETER_DESC sigdesc;
pReflector->GetInputParameterDesc(i, &sigdesc);
auto format = GetDxgiFormat(sigdesc.ComponentType, sigdesc.Mask);
D3D11_INPUT_ELEMENT_DESC eledesc = {
sigdesc.SemanticName
, sigdesc.SemanticIndex
, format
, 0 // 決め打ち
, D3D11_APPEND_ALIGNED_ELEMENT // 決め打ち
, D3D11_INPUT_PER_VERTEX_DATA // 決め打ち
, 0 // 決め打ち
};
vbElement.push_back(eledesc);
}
if (!vbElement.empty()){
hr = pDevice->CreateInputLayout(&vbElement[0], vbElement.size(),
vblob->GetBufferPointer(), vblob->GetBufferSize(), &m_pInputLayout);
if (FAILED(hr))
return false;
}
}
// pixel shader
{
Microsoft::WRL::ComPtr<ID3DBlob> pblob;
auto hr = CompileShaderFromFile(shaderFile.c_str(), psFunc.c_str(), "ps_4_0_level_9_1", &pblob);
if (FAILED(hr))
return false;
hr = pDevice->CreatePixelShader(pblob->GetBufferPointer(), pblob->GetBufferSize(), NULL, &m_pPsh);
if (FAILED(hr))
return false;
// pixel shader reflection
Microsoft::WRL::ComPtr<ID3D11ShaderReflection> pReflector;
hr = D3DReflect(pblob->GetBufferPointer(), pblob->GetBufferSize(), IID_ID3D11ShaderReflection,
&pReflector);
if (FAILED(hr))
return false;
OutputDebugPrintfA("#### PixelShader ####\n");
if (!m_constant->Initialize(pDevice, SHADERSTAGE_PIXEL, pReflector)){
return false;
}
}
return true;
}
示例2: CompileShaderFromFile
/// 生成する
bool D3DShader::Create(DXGIManager *pDxgi)
{
if(m_pVsh)return true;
auto pDevice=pDxgi->GetD3DDevice();
// vertex shader
{
Microsoft::WRL::ComPtr<ID3DBlob> vblob;
HRESULT hr = CompileShaderFromFile(m_info.path, m_info.vs
, vblob.GetAddressOf());
if (FAILED(hr)) return false;
hr = pDevice->CreateVertexShader(
vblob->GetBufferPointer(), vblob->GetBufferSize()
, NULL, m_pVsh.ReleaseAndGetAddressOf());
if (FAILED(hr)) return false;
// vertex shader reflection
Microsoft::WRL::ComPtr<ID3D11ShaderReflection> pReflector;
hr = D3DReflect(vblob->GetBufferPointer(), vblob->GetBufferSize()
, IID_ID3D11ShaderReflection, &pReflector);
if (FAILED(hr)) return false;
D3D11_SHADER_DESC shaderdesc;
pReflector->GetDesc(&shaderdesc);
// Create InputLayout
std::vector<D3D11_INPUT_ELEMENT_DESC> vbElement;
for (size_t i = 0; i < shaderdesc.InputParameters; ++i){
D3D11_SIGNATURE_PARAMETER_DESC sigdesc;
pReflector->GetInputParameterDesc(i, &sigdesc);
auto format = GetDxgiFormat(sigdesc.ComponentType, sigdesc.Mask);
D3D11_INPUT_ELEMENT_DESC eledesc = {
sigdesc.SemanticName
, sigdesc.SemanticIndex
, format
, 0 // 決め打ち
, D3D11_APPEND_ALIGNED_ELEMENT // 決め打ち
, D3D11_INPUT_PER_VERTEX_DATA // 決め打ち
, 0 // 決め打ち
};
vbElement.push_back(eledesc);
}
if (!vbElement.empty()){
hr = pDevice->CreateInputLayout(&vbElement[0], vbElement.size(),
vblob->GetBufferPointer(), vblob->GetBufferSize(), &m_pInputLayout);
if (FAILED(hr)) return false;
}
}
// pixel shader
{
Microsoft::WRL::ComPtr<ID3DBlob> pblob;
auto hr = CompileShaderFromFile(m_info.path, m_info.ps
, pblob.GetAddressOf());
if (FAILED(hr)) return false;
hr = pDevice->CreatePixelShader(
pblob->GetBufferPointer(), pblob->GetBufferSize()
, NULL, m_pPsh.ReleaseAndGetAddressOf());
if (FAILED(hr)) return false;
}
return true;
}