Beispiel #1
0
Reflect::ObjectPtr Helium::Cache::ReadCacheObjectFromBuffer( const DynArray< uint8_t > &_buffer )
{
    if (_buffer.GetSize() == 0)
    {
        Reflect::ObjectPtr null_object;
        return null_object;
    }

    return ReadCacheObjectFromBuffer(_buffer.GetData(), 0, _buffer.GetSize());
}
Beispiel #2
0
int main()
{
	DynArray <char> a;
	DynArray <char> b;

	char c = 'c';
	char d = 'd';
	char e = 'e';
	char f = 'f';
	char g = 'g';

	a.Push_Back(c);
	a.Push_Back(d);
	b.Push_Back(e);
	b.Push_Back(f);

	char result = a.At(0,result);

	//a = c,d 
	//b = e,f

	printf("At 0: %c\n", result);

	printf("A at 0,1: %c,%c\nB at 0,1: %c,%c\n", a[0], a[1], b[0], b[1]);

	a.Clear();

	printf("A clear... Size: %i\n", a.Size());

	a.Push_Back(c);
	a.Push_Back(d);

	a += b;

	printf("A after += : %c,%c,%c,%c\n", a[0], a[1], a[2], a[3]);

	printf("A[0] = %c, A[3] = %c\n", a[0], a[3]);

	printf("A.GetData = %p\n", a.GetData());

	printf("Capacity: %i, size = %i\n", a.Capacity(), a.Size());

	printf("Empty: ");

	if (a.Empty())
	{
		printf("yes\n");
	}
	else
	{
		printf("no\n");
	}

	a.Flip();

	printf("A fliped: %c,%c,%c,%c\n", a[0], a[1], a[2], a[3]);

	a.Push_Back(c);
	a.Push_Back(d);
	a.Push_Back(e);
	a.Push_Back(f);

	a.Insert(2, g);

	printf("A inserted g in 2: %c,%c,%c,%c,%c,%c,%c,%c,%c\n", a[0], a[1], a[2], a[3], a[4], a[5], a[6], a[7], a[8]);

	a.Erase(1);

	printf("A: %s\n", a.GetData());

	DynArray <int> test;
	int swaps = 0;
	int z;
	time_t t;

	test.Push_Back(5);
	test.Push_Back(8);
	test.Push_Back(3);
	test.Push_Back(1);
	test.Push_Back(4);
	test.Push_Back(2);

	printf("Int Array : %i,%i,%i,%i,%i,%i\n", test[0], test[1], test[2], test[3], test[4], test[5]);

	swaps = test.BubbleSort();

	printf("Int Array : %i,%i,%i,%i,%i,%i\nSwaps: %i\n", test[0], test[1], test[2], test[3], test[4], test[5], swaps);
	
	DynArray <int> test2;
	time(&t);
	srand(t);
	for (int i = 0; i <= 1000; i++)
	{
		z = rand();
		test2.Push_Back(z);
	}

	system("pause");
	return 0;
}
Beispiel #3
0
/// 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 ] );
        }
#endif  // HELIUM_ENABLE_TRACE
    }

    return bCompileResult;
}