~linaro-graphics-wg/+junk/spandex-package

« back to all changes in this revision

Viewing changes to sct/common/modules/opengles2/sct_opengles2checkerroraction.c

  • Committer: Alexandros Frantzis
  • Date: 2011-05-04 08:50:52 UTC
  • Revision ID: alexandros.frantzis@linaro.org-20110504085052-88gps4jrg317s6lc
Tags: upstream-1.1.3~git20110502.0ae20368
ImportĀ upstreamĀ versionĀ 1.1.3~git20110502.0ae20368

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Spandex benchmark and test framework.
 
3
 *
 
4
 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
 
5
 *
 
6
 * Contact: Kari J. Kangas <kari.j.kangas@nokia.com>
 
7
 *
 
8
 *   This framework is free software; you can redistribute it and/or modify it
 
9
 * under the terms of the GNU Lesser General Public License as published by the
 
10
 * Free Software Foundation, version 2.1 of the License.
 
11
 *
 
12
 *   This framework is distributed in the hope that it will be useful, but
 
13
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 
14
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
 
15
 * for more details.
 
16
 *
 
17
 *   You should have received a copy of the GNU Lesser General Public License
 
18
 * along with this framework; if not, see <http://www.gnu.org/licenses/>.
 
19
 *
 
20
 */
 
21
 
 
22
#include "sct_opengles2checkerroraction.h"
 
23
#include "sct_sicommon.h"
 
24
#include "sct_utils.h"
 
25
 
 
26
#include "sct_gl2.h"
 
27
 
 
28
#include <stdio.h>
 
29
#include <string.h>
 
30
 
 
31
/*!
 
32
 *
 
33
 *
 
34
 */
 
35
void* sctiCreateOpenGLES2CheckErrorActionContext( void* moduleContext, SCTAttributeList* attributes )
 
36
{
 
37
    SCTOpenGLES2CheckErrorActionContext*    context;
 
38
    SCTOpenGLES2ModuleContext*              mc;
 
39
 
 
40
    SCT_ASSERT_ALWAYS( moduleContext != NULL );
 
41
    SCT_ASSERT_ALWAYS( attributes != NULL );
 
42
 
 
43
    mc      = ( SCTOpenGLES2ModuleContext* )( moduleContext );
 
44
    context = ( SCTOpenGLES2CheckErrorActionContext* )( siCommonMemoryAlloc( NULL, sizeof( SCTOpenGLES2CheckErrorActionContext ) ) );
 
45
    if( context == NULL )
 
46
    {
 
47
        SCT_LOG_ERROR( "Allocation failed in CheckError@OpenGLES2 context creation." );
 
48
        return NULL;
 
49
    }
 
50
    memset( context, 0, sizeof( SCTOpenGLES2CheckErrorActionContext ) );
 
51
 
 
52
    context->moduleContext = mc;
 
53
 
 
54
    if( sctiParseOpenGLES2CheckErrorActionAttributes( &( context->data ), attributes ) == SCT_FALSE )
 
55
    {
 
56
        sctiDestroyOpenGLES2CheckErrorActionContext( context );
 
57
        return NULL;
 
58
    }
 
59
 
 
60
    return context;
 
61
}
 
62
 
 
63
/*!
 
64
 *
 
65
 *
 
66
 */
 
67
void sctiDestroyOpenGLES2CheckErrorActionContext( void* context )
 
68
{
 
69
    if( context == NULL )
 
70
    {
 
71
        return;
 
72
    }
 
73
    siCommonMemoryFree( NULL, context );
 
74
}
 
75
 
 
76
/*!
 
77
 *
 
78
 *
 
79
 */
 
80
SCTBoolean sctiOpenGLES2CheckErrorActionExecute( SCTAction* action, int frameNumber )
 
81
{
 
82
    SCTOpenGLES2CheckErrorActionContext*    context;
 
83
    OpenGLES2CheckErrorActionData*          data;
 
84
    GLenum                                  err;
 
85
 
 
86
    SCT_ASSERT( action != NULL );
 
87
    SCT_ASSERT( action->context != NULL );
 
88
    SCT_USE_VARIABLE( action );
 
89
    SCT_USE_VARIABLE( frameNumber );
 
90
 
 
91
    context = ( SCTOpenGLES2CheckErrorActionContext* )( action->context );
 
92
    data    = &( context->data );
 
93
    
 
94
    err = glGetError();
 
95
    
 
96
    if( err != GL_NO_ERROR )
 
97
    {
 
98
        char buf[ 512 ];
 
99
        sprintf( buf, "GL error %s, message \"%s\" in CheckError@OpenGLES2 action execute.",
 
100
                 sctiOpenGLES2GetErrorString( err ), data->message );
 
101
        SCT_LOG_ERROR( buf );
 
102
 
 
103
#if defined( SCT_DEBUG )
 
104
        siCommonDebugPrintf( NULL, "SPANDEX: %s", buf );
 
105
#endif  /* defined( SCT_DEBUG ) */
 
106
        
 
107
        return SCT_FALSE;
 
108
    }
 
109
 
 
110
    return SCT_TRUE;
 
111
}
 
112
 
 
113
/*!
 
114
 *
 
115
 *
 
116
 */
 
117
void sctiOpenGLES2CheckErrorActionDestroy( SCTAction* action )
 
118
{
 
119
    SCT_ASSERT_ALWAYS( action != NULL );
 
120
 
 
121
    sctiDestroyOpenGLES2CheckErrorActionContext( action->context );
 
122
    action->context = NULL;
 
123
}