Initial import
[glmemperf] / cpuinterleavingtest.h
1 /**
2  * OpenGL ES 2.0 memory performance estimator
3  * Copyright (C) 2009 Nokia
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * \author Sami Kyöstilä <sami.kyostila@nokia.com>
20  *
21  * CPU texture streaming test
22  */
23 #ifndef CPUINTERLEAVINGTEST_H
24 #define CPUINTERLEAVINGTEST_H
25
26 #include "blittest.h"
27 #include "util.h"
28 #include <map>
29 #include <EGL/egl.h>
30 #include <X11/extensions/XShm.h>
31
32 enum CPUInterleavingMethod
33 {
34     CPUI_TEXTURE_UPLOAD,
35     CPUI_XSHM_IMAGE,
36     /*CPUI_XSHM_PIXMAP, xshm pixmaps are generally not supported anymore */
37     CPUI_IMG_TEXTURE_STREAMING,
38     CPUI_PIXEL_BUFFER_OBJECT,
39     CPUI_EGL_LOCK_SURFACE,
40 };
41
42 const int CPUI_MAX_BUFFERS = 2;
43
44 class CPUInterleavingTest: public BlitTest
45 {
46     CPUInterleavingMethod m_method;
47     int m_buffers;
48     GLuint m_textures[CPUI_MAX_BUFFERS];
49     
50     char* m_textureData[CPUI_MAX_BUFFERS];
51     int m_dataStride;
52     int m_dataBitsPerPixel;
53
54     int m_readBuffer;
55     int m_writeBuffer;
56
57     Pixmap m_pixmaps[CPUI_MAX_BUFFERS];
58     EGLSurface m_surfaces[CPUI_MAX_BUFFERS];
59     EGLConfig m_config;
60     
61     XShmSegmentInfo m_shminfo[CPUI_MAX_BUFFERS];
62     XImage* m_ximage[CPUI_MAX_BUFFERS];
63     GC m_gc[CPUI_MAX_BUFFERS];
64     int m_completionEvent;
65     std::map<Drawable, int> m_drawableIndex;
66     bool m_writeCompleted[CPUI_MAX_BUFFERS];
67
68 public:
69     CPUInterleavingTest(CPUInterleavingMethod method, int buffers,
70                         int bitsPerPixel,
71                         int width, int height,
72                         float texW = 1.0f, float texH = 1.0f);
73
74     void prepare();
75     void operator()(int frame);
76     void teardown();
77
78     std::string name() const;
79 };
80
81 #endif // CPUINTERLEAVINGTEST_H