本文整理汇总了C++中ConstantBuffer::addVariableDefinition方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstantBuffer::addVariableDefinition方法的具体用法?C++ ConstantBuffer::addVariableDefinition怎么用?C++ ConstantBuffer::addVariableDefinition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConstantBuffer
的用法示例。
在下文中一共展示了ConstantBuffer::addVariableDefinition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processLoadedShaderBlob
HRESULT ShaderBase::processLoadedShaderBlob( ID3DBlob *shaderSource )
{
HRESULT res = build( shaderSource );
if ( FAILED(res) )
{
std::cout << "Error (ShaderBase::processLoadedShaderBlob): Error creating shader" << std::endl;
return res;
}
// setup buffers using the shader reflection
ID3D11ShaderReflection *reflector;
res = D3DReflect( shaderSource->GetBufferPointer(), shaderSource->GetBufferSize(),
IID_ID3D11ShaderReflection, (void**)&reflector );
if ( FAILED( res ) )
{
std::cout << "Error (ShaderBase::processLoadedShaderBlob): Error creating shader reflection" << std::endl;
return res;
}
D3D11_SHADER_DESC shaderDesc;
ZeroMemory( &shaderDesc, sizeof( D3D11_SHADER_DESC ) );
res = reflector->GetDesc( &shaderDesc );
if ( FAILED( res ) )
{
std::cout << "Error (ShaderBase::processLoadedShaderBlob): Error creating shader reflection description" << std::endl;
reflector->Release();
return res;
}
for ( UINT i = 0U; i < shaderDesc.ConstantBuffers; ++i )
{
ID3D11ShaderReflectionConstantBuffer *constBuffReflection = reflector->GetConstantBufferByIndex( i );
D3D11_SHADER_BUFFER_DESC shaderBuffDesc;
constBuffReflection->GetDesc( &shaderBuffDesc );
//TODO: these can be put on the stack
ConstantBuffer *cBuff = new ConstantBuffer( m_dxDev, i, shaderBuffDesc.Name );
cBuff->create( shaderBuffDesc.Size );
for ( UINT j = 0U; j < shaderBuffDesc.Variables; ++j )
{
ID3D11ShaderReflectionVariable *variableRefl = constBuffReflection->GetVariableByIndex( j );
D3D11_SHADER_VARIABLE_DESC shaderVarDesc;
variableRefl->GetDesc( &shaderVarDesc );
cBuff->addVariableDefinition( shaderVarDesc.Name, shaderVarDesc.StartOffset, shaderVarDesc.Size );
}
m_constBuffers.push_back( cBuff );
m_dxConstBuffers.push_back( cBuff->getDxBufferPtr() );
}
reflector->Release();
return S_OK;
}