本文整理汇总了C++中DynArray::Resize方法的典型用法代码示例。如果您正苦于以下问题:C++ DynArray::Resize方法的具体用法?C++ DynArray::Resize怎么用?C++ DynArray::Resize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynArray
的用法示例。
在下文中一共展示了DynArray::Resize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/// Resolve a set of shader preprocessor options from the associated index.
///
/// @param[in] shaderType Type of shader.
/// @param[in] index Option set index.
/// @param[out] rToggleNames List of enabled shader toggles.
/// @param[out] rSelectPairs List shader selection pair values.
void Shader::Options::GetOptionSetFromIndex(
RShader::EType shaderType,
size_t index,
DynArray< Name >& rToggleNames,
DynArray< SelectPair >& rSelectPairs ) const
{
HELIUM_ASSERT( static_cast< size_t >( shaderType ) < static_cast< size_t >( RShader::TYPE_MAX ) );
rToggleNames.Resize( 0 );
rSelectPairs.Resize( 0 );
uint32_t shaderTypeMask = ( 1 << shaderType );
size_t shaderToggleCount = m_toggles.GetSize();
for( size_t shaderToggleIndex = 0; shaderToggleIndex < shaderToggleCount; ++shaderToggleIndex )
{
const Toggle& rShaderToggle = m_toggles[ shaderToggleIndex ];
if( !( rShaderToggle.shaderTypeFlags & shaderTypeMask ) )
{
continue;
}
if( index & 0x1 )
{
HELIUM_VERIFY( rToggleNames.New( rShaderToggle.name ) );
}
index >>= 1;
}
size_t shaderSelectCount = m_selects.GetSize();
for( size_t shaderSelectIndex = 0; shaderSelectIndex < shaderSelectCount; ++shaderSelectIndex )
{
const Select& rShaderSelect = m_selects[ shaderSelectIndex ];
if( !( rShaderSelect.shaderTypeFlags & shaderTypeMask ) )
{
continue;
}
const DynArray< Name >& rShaderSelectChoices = rShaderSelect.choices;
size_t shaderSelectChoiceCount = rShaderSelectChoices.GetSize();
size_t selectIndexMultiplier = shaderSelectChoiceCount + rShaderSelect.bOptional;
size_t selectIndex = index % selectIndexMultiplier;
index /= selectIndexMultiplier;
if( !rShaderSelect.bOptional || selectIndex != shaderSelectChoiceCount )
{
SelectPair* pSelectPair = rSelectPairs.New();
HELIUM_ASSERT( pSelectPair );
pSelectPair->name = rShaderSelect.name;
pSelectPair->choice = rShaderSelectChoices[ selectIndex ];
}
}
}
示例2:
void Helium::ResourceHandler::SaveObjectToPersistentDataBuffer( Reflect::Object *_object, DynArray< uint8_t > &_buffer )
{
_buffer.Resize(0);
if (!_object)
{
return;
}
Cache::WriteCacheObjectToBuffer(*_object, _buffer);
}
示例3: xml_out
void Helium::Cache::WriteCacheObjectToBuffer( Reflect::Object &_object, DynArray< uint8_t > &_buffer )
{
#if USE_XML_FOR_CACHE_DATA
{
tstringstream xml_out_ss;
Reflect::ArchiveXML xml_out(new Reflect::TCharStream(&xml_out_ss, false), true);
xml_out.WriteFileHeader();
xml_out.WriteSingleObject(_object);
xml_out.WriteFileFooter();
xml_out.Close();
tstring xml_str;
xml_str = xml_out_ss.str();
if (xml_str.size() > 0)
{
_buffer.Resize(xml_str.size() * sizeof(tchar_t));
memcpy(&_buffer[0], xml_str.data(), xml_str.size() * sizeof(tchar_t));
}
}
#else
{
std::stringstream ss_out;
Reflect::ArchiveBinary binary_out(new Reflect::CharStream(&ss_out, false, Helium::ByteOrders::LittleEndian, Helium::Reflect::CharacterEncodings::UTF_16), true);
binary_out.SerializeInstance( &_object );
// This is not an efficient way to do this
std::string str_out;
str_out = ss_out.str();
if (!str_out.empty())
{
_buffer.Resize(str_out.size());
memcpy(&_buffer[0], str_out.data(), str_out.size());
}
}
#endif
}
示例4: Serialize
void StructureDynArrayData::Serialize( ArchiveT& archive )
{
const Structure *structure = GetInternalStructure();
DynArray< ObjectPtr > components;
components.Resize( structure->m_DynArrayAdapter->GetSize(GetInternalPtr(structure)) );
for (size_t i = 0; i < components.GetSize(); ++i)
{
components[i] = structure->m_DynArrayAdapter->GetItem(GetInternalPtr(structure), i, m_Instance, m_Field);
}
archive.SerializeArray( components );
}
示例5: GetAllResourceHandlers
/// Gather all existing resource handlers.
///
/// This will iterate through all sub-types of ResourceHandler and add their template objects to a dynamic array.
///
/// @param[out] rResourceHandlers List of existing resource handlers.
void ResourceHandler::GetAllResourceHandlers( DynArray< ResourceHandler* >& rResourceHandlers )
{
rResourceHandlers.Resize( 0 );
const GameObjectType* pResourceHandlerType = GetStaticType();
HELIUM_ASSERT( pResourceHandlerType );
GameObjectType::ConstIterator typeEnd = GameObjectType::GetTypeEnd();
for( GameObjectType::ConstIterator typeIterator = GameObjectType::GetTypeBegin(); typeIterator != typeEnd; ++typeIterator )
{
const GameObjectType& rType = *typeIterator;
if( &rType != pResourceHandlerType && rType.GetClass()->IsType( pResourceHandlerType->GetClass() ) )
{
ResourceHandler* pHandler = Reflect::AssertCast< ResourceHandler >( rType.GetTemplate() );
HELIUM_ASSERT( pHandler );
rResourceHandlers.Push( pHandler );
}
}
}
示例6: CompileShader
/// Helper function for compiling a shader for a specific profile.
///
/// @param[in] pVariant Shader variant for which we are compiling.
/// @param[in] pPreprocessor Platform preprocessor to use for compiling.
/// @param[in] platformIndex Platform index.
/// @param[in] shaderProfileIndex Index of the target shader profile.
/// @param[in] shaderType Type of shader to compile.
/// @param[in] pShaderSourceData Buffer in which the shader source code is stored.
/// @param[in] shaderSourceSize Size of the shader source buffer, in bytes.
/// @param[in] rTokens Array specifying preprocessor tokens to pass to the shader compiler.
/// @param[out] rCompiledCodeBuffer Buffer in which the compiled code will be stored.
///
/// @return True if compiling was successful, false if not.
bool ShaderVariantResourceHandler::CompileShader(
ShaderVariant* pVariant,
PlatformPreprocessor* pPreprocessor,
size_t platformIndex,
size_t shaderProfileIndex,
RShader::EType shaderType,
const void* pShaderSourceData,
size_t shaderSourceSize,
const DynArray< PlatformPreprocessor::ShaderToken >& rTokens,
DynArray< uint8_t >& rCompiledCodeBuffer )
{
HELIUM_ASSERT( pVariant );
HELIUM_ASSERT( pPreprocessor );
HELIUM_ASSERT( static_cast< size_t >( shaderType ) < static_cast< size_t >( RShader::TYPE_MAX ) );
HELIUM_ASSERT( pShaderSourceData || shaderSourceSize == 0 );
HELIUM_UNREF( platformIndex ); // Variable is used for logging only.
rCompiledCodeBuffer.Resize( 0 );
#if HELIUM_ENABLE_TRACE
DynArray< String > errorMessages;
#endif
Path shaderFilePath;
if ( !File::GetDataDirectory( shaderFilePath ) )
{
HELIUM_TRACE(
TRACE_ERROR,
TXT( "ShaderVariantResourceHandler: Failed to obtain data directory." ) );
return false;
}
shaderFilePath += pVariant->GetPath().GetParent().ToFilePathString().GetData();
bool bCompileResult = pPreprocessor->CompileShader(
shaderFilePath,
shaderProfileIndex,
shaderType,
pShaderSourceData,
shaderSourceSize,
rTokens.GetData(),
rTokens.GetSize(),
rCompiledCodeBuffer
#if HELIUM_ENABLE_TRACE
, &errorMessages
#else
, NULL
#endif
);
if( !bCompileResult )
{
rCompiledCodeBuffer.Resize( 0 );
#if HELIUM_ENABLE_TRACE
String tokenList;
#if HELIUM_UNICODE
String convertedToken;
#endif
size_t tokenCount = rTokens.GetSize();
for( size_t tokenIndex = 0; tokenIndex < tokenCount; ++tokenIndex )
{
tokenList += TXT( ' ' );
#if HELIUM_UNICODE
StringConverter< char, tchar_t >::Convert( convertedToken, rTokens[ tokenIndex ].name );
tokenList += convertedToken;
#else
tokenList += rTokens[ tokenIndex ].name;
#endif
}
size_t errorCount = errorMessages.GetSize();
HELIUM_TRACE(
TRACE_ERROR,
( TXT( "ShaderVariantResourceHandler: Failed to compile \"%s\" for platform %" ) TPRIuSZ
TXT( ", profile %" ) TPRIuSZ TXT( "; %" ) TPRIuSZ TXT( " errors (tokens:%s):\n" ) ),
*pVariant->GetPath().ToString(),
platformIndex,
shaderProfileIndex,
errorCount,
*tokenList );
for( size_t errorIndex = 0; errorIndex < errorCount; ++errorIndex )
{
HELIUM_TRACE( TRACE_ERROR, TXT( "- %s\n" ), *errorMessages[ errorIndex ] );
//.........这里部分代码省略.........
示例7: CacheResource
//.........这里部分代码省略.........
TXT( "exceeds the maximum supported (%" ) TPRIuSZ TXT( ").\n" ) ),
systemOptionSetCount,
*pShader->GetPath().ToString(),
static_cast< size_t >( UINT32_MAX ) );
allocator.Free( pShaderSource );
return false;
}
uint32_t systemOptionSetCount32 = static_cast< uint32_t >( systemOptionSetCount );
for( size_t platformIndex = 0; platformIndex < static_cast< size_t >( Cache::PLATFORM_MAX ); ++platformIndex )
{
PlatformPreprocessor* pPreprocessor = pObjectPreprocessor->GetPlatformPreprocessor(
static_cast< Cache::EPlatform >( platformIndex ) );
if( !pPreprocessor )
{
continue;
}
Resource::PreprocessedData& rPreprocessedData = pVariant->GetPreprocessedData(
static_cast< Cache::EPlatform >( platformIndex ) );
ShaderVariant::PersistentResourceData persistentResourceData;
persistentResourceData.m_resourceCount = systemOptionSetCount32;
SaveObjectToPersistentDataBuffer(&persistentResourceData, rPreprocessedData.persistentDataBuffer);
size_t shaderProfileCount = pPreprocessor->GetShaderProfileCount();
size_t shaderCount = shaderProfileCount * systemOptionSetCount;
DynArray< DynArray< uint8_t > >& rSubDataBuffers = rPreprocessedData.subDataBuffers;
rSubDataBuffers.Reserve( shaderCount );
rSubDataBuffers.Resize( 0 );
rSubDataBuffers.Resize( shaderCount );
rSubDataBuffers.Trim();
rPreprocessedData.bLoaded = true;
}
// DynArray< uint8_t > compiledCodeBuffer;
// DynArray< ShaderConstantBufferInfo > constantBuffers, pcSm4ConstantBuffers;
// DynArray< ShaderSamplerInfo > samplerInputs;
// DynArray< ShaderTextureInfo > textureInputs;
CompiledShaderData csd_pc_sm4;
for( size_t systemOptionSetIndex = 0; systemOptionSetIndex < systemOptionSetCount; ++systemOptionSetIndex )
{
rSystemOptions.GetOptionSetFromIndex( shaderType, systemOptionSetIndex, toggleNames, selectPairs );
size_t systemToggleNameCount = toggleNames.GetSize();
for( size_t toggleNameIndex = 0; toggleNameIndex < systemToggleNameCount; ++toggleNameIndex )
{
PlatformPreprocessor::ShaderToken* pToken = shaderTokens.New();
HELIUM_ASSERT( pToken );
StringConverter< tchar_t, char >::Convert( pToken->name, *toggleNames[ toggleNameIndex ] );
pToken->definition = "1";
}
size_t systemSelectPairCount = selectPairs.GetSize();
for( size_t selectPairIndex = 0; selectPairIndex < systemSelectPairCount; ++selectPairIndex )
{
const Shader::SelectPair& rPair = selectPairs[ selectPairIndex ];
PlatformPreprocessor::ShaderToken* pToken = shaderTokens.New();