#define TX (32)
#define TY (32)
+#define CHECK_SUCCESS 0
+#define CHECK_FAIL 1
int gl_acceleration_capability_check (void) {
- int test_failure = 0;
+ //int test_failure = 0;
GloContext *context;
GloSurface *surface;
- unsigned char *datain = (unsigned char *)malloc(4*TX*TY);
- unsigned char *datain_flip = (unsigned char *)malloc(4*TX*TY); // flipped input data (for GL)
- unsigned char *dataout = (unsigned char *)malloc(4*TX*TY);
+ unsigned char *datain;
+ unsigned char *datain_flip;
+ unsigned char *dataout;
unsigned char *p;
int x,y;
const int bufferAttributes[] = {
// test failed.
return 1;
}
-*/
- memset(datain_flip, 0, TX*TY*4);
+*/
+ datain = (unsigned char *)malloc(4*TX*TY);
+ datain_flip = (unsigned char *)malloc(4*TX*TY);
+
memset(datain, 0, TX*TY*4);
+ memset(datain_flip, 0, TX*TY*4);
+
p = datain;
for (y=0;y<TY;y++) {
for (x=0;x<TX;x++) {
if (glo_init() != 0) {
printf ("Host does not have GL hardware acceleration!(glo_init() failed)\n");
- test_failure = 1;
- goto TEST_END;
+ free (datain);
+ free (datain_flip);
+ return CHECK_FAIL;
}
// new surface
context = glo_context_create(bufferFlags, 0);
if (context == NULL) {
printf ("Host does not have GL hardware acceleration!(context_create() failed)\n");
- test_failure = 1;
- goto TEST_END;
+ free (datain);
+ free (datain_flip);
+ return CHECK_FAIL;
}
surface = glo_surface_create(TX, TY, context);
if (surface == NULL) {
printf ("Host does not have GL hardware acceleration!(surface_create() failed)\n");
- test_failure = 1;
- goto TEST_END;
+ free (datain);
+ free (datain_flip);
+ return CHECK_FAIL;
}
glo_surface_makecurrent(surface);
//printf("GLSL VERSION %s\n", glGetString(GL_SHADING_LANGUAGE_VERSION));
if (strstr((const char*)glGetString(GL_RENDERER), "Software")) {
- printf ("Host does not have GL hardware acceleration!\n");
- test_failure = 1;
- goto TEST_END;
+ printf ("Host does not have GL hardware acceleration!(No host gl driver)\n");
+ free (datain);
+ free (datain_flip);
+ return CHECK_FAIL;
}
// fill with stuff (in correctly ordered way)
printf("glFormat: 0x%08X glType: 0x%08X\n", glFormat, glType);
glDrawPixels(TX,TY,glFormat, glType, datain_flip);
glFlush();
-
+
+ dataout = (unsigned char *)malloc(4*TX*TY);
memset(dataout, 0, bpp*TX*TY);
glo_surface_getcontents(surface, TX*bpp, bpp*8, dataout);
glo_context_destroy(context);
// compare
if (memcmp(datain, dataout, bpp*TX*TY)!=0) {
- test_failure = 1;
+ printf ("Host does not have GL hardware acceleration!(datain != dataout)\n");
+ free (datain);
+ free (datain_flip);
+ free (dataout);
+ return CHECK_FAIL;
}
-TEST_END:
+
//glo_kill();
//printf ("Testing %s\n", (test_failure ? "FAILED" : "PASSED"));
free (datain);
free (datain_flip);
free (dataout);
- return test_failure;
+
+ return CHECK_SUCCESS;
}
glo_inited = 1; // safe because we are single threaded. Otherwise we cause
// recursion on the next call.
// set the X error handler.
- XErrorHandler old_handler = XSetErrorHandler (x_errhandler);
+ XSetErrorHandler (x_errhandler);
glo_test_readback_methods();
return 0;
}
XSetWindowAttributes attr = { 0 };
unsigned long mask;
XVisualInfo *vis;
- int pixmapAttribs[] = { GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
- GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGB_EXT,
- None };
if (!context)
return 0;
}
void glo_surface_updatecontents(GloSurface *surface) {
- XImage *img;
if (!surface)
return;
XShmGetImage (glo.dpy, surface->pixmap, surface->image, 0, 0, AllPlanes);
}
else {
- img = XGetImage(glo.dpy, surface->pixmap, 0, 0, surface->width, surface->height, AllPlanes, ZPixmap);
+ XGetImage(glo.dpy, surface->pixmap, 0, 0, surface->width, surface->height, AllPlanes, ZPixmap);
}
}
unsigned char *datain = (unsigned char *)g_malloc(4*TX*TY);
unsigned char *datain_flip = (unsigned char *)g_malloc(4*TX*TY); // flipped input data (for GL)
- unsigned char *dataout = (unsigned char *)g_malloc(4*TX*TY);
+ unsigned char *dataout;
unsigned char *p;
int x,y;
}
context = glo_context_create(bufferFlags, 0);
- if (context == NULL)
+ if (context == NULL) {
+ g_free(datain);
+ g_free(datain_flip);
return 1;
+ }
surface = glo_surface_create(TX, TY, context);
- if (surface == NULL)
+ if (surface == NULL) {
+ g_free(datain);
+ g_free(datain_flip);
return 1;
+ }
glo_surface_makecurrent(surface);
glDrawPixels(TX,TY,glFormat, glType, datain_flip);
glFlush();
+ dataout = (unsigned char *)g_malloc(4*TX*TY);
memset(dataout, 0, bpp*TX*TY);
glo_surface_getcontents(surface, TX*4, bpp*8, dataout);
glo_surface_destroy(surface);
glo_context_destroy(context);
- if (memcmp(datain, dataout, bpp*TX*TY)==0)
+ if (memcmp(datain, dataout, bpp*TX*TY)==0) {
+ g_free(datain);
+ g_free(datain_flip);
+ g_free(dataout);
return 1;
+ }
+
+ g_free(datain);
+ g_free(datain_flip);
+ g_free(dataout);
return 0;
}
{
qsurface->glstate = state;
- QTAILQ_INSERT_HEAD(&state->qsurfaces, qsurface, next);
+ if ( qsurface->type == SURFACE_WINDOW )
+ QTAILQ_INSERT_HEAD(&state->qsurfaces, qsurface, next);
state->current_qsurface = qsurface;
}
{
qsurface->glstate = NULL;
- QTAILQ_REMOVE(&state->qsurfaces, qsurface, next);
+ if ( qsurface->type == SURFACE_WINDOW )
+ QTAILQ_REMOVE(&state->qsurfaces, qsurface, next);
if ( state->current_qsurface == qsurface )
state->current_qsurface = NULL;
{
int i;
- /* XXX:Current limitation is that each surface is binded to one
- * context, thus not support sharing surface between contexts. If guest
- * does this, deleting surface in one context make trouble to other
- * context. Leave the work until the uninitialization. Need clean the code
- * and decouple the context and surface in future.
- */
-#if 0
QGloSurface *qsurface, *tmp;
QTAILQ_FOREACH_SAFE(qsurface, &state->qsurfaces, next, tmp) {
QTAILQ_REMOVE(&state->qsurfaces, qsurface, next);
g_free(qsurface);
}
-#endif
if (state->context)
glo_context_destroy(state->context);
GLState *get_glstate_for_fake_ctxt(ProcessState *process, int fake_ctxt)
{
int i;
- for (i = 0; i < process->nb_states; i++)
+ for (i = 0; i < process->nb_states; i++) {
if (process->glstates[i]->fake_ctxt == fake_ctxt)
return process->glstates[i];
+ }
+
return 0;
}
if (process->cmdbuf)
g_free(process->cmdbuf);
- for (i = 0; &processes[i] != process; i ++);
- memmove(&processes[i], &processes[i + 1],
- (MAX_HANDLED_PROCESS - 1 - i) * sizeof(ProcessState));
+ for (i = 0; &processes[i] != process; i ++) {
+ ; // do nothing
+ }
+
+ memmove(&processes[i], &processes[i + 1],
+ (MAX_HANDLED_PROCESS - 1 - i) * sizeof(ProcessState));
}
static const int beginend_allowed[GL_N_CALLS] = {
* process->current_state contains info on which of the guests contexts is
* current.
*/
- for (i = 0; i < MAX_HANDLED_PROCESS; i ++)
+ for (i = 0; i < MAX_HANDLED_PROCESS; i ++) {
if (processes[i].p.process_id == pid) {
process = &processes[i];
break;
process->current_state = &process->default_state;
break;
}
+ }
if (process == NULL) {
DEBUGF( "Too many processes !\n");
}
start = s;
- for (; *n && *s && !strchr(delim, *s); s++, (*n)--);
+ for (; *n && *s && !strchr(delim, *s); s++, (*n)--) {
+ ; // do nothing
+ }
+
if (*n > 0)
s++, (*n)--;
if (!strncmp(p, "lowp", 4) || !strncmp(p, "mediump", 7) || !strncmp(p, "highp", 5)) {
continue;
} else if (!strncmp(p, "precision", 9)) {
- while ((p = opengl_strtok(0, &length, &saveptr, p)) && !strchr(p, ';'));
+ while ((p = opengl_strtok(0, &length, &saveptr, p)) && !strchr(p, ';')) {
+ // do nothing
+ ;
+ }
} else {
if (!strncmp(p, "gl_MaxVertexUniformVectors", 26)) {
p = "(gl_MaxVertexUniformComponents / 4)";
patched[*patched_len] = 0;
/* check that we don't leave dummy preprocessor lines */
for (sp = patched; *sp;) {
- for (; *sp == ' ' || *sp == '\t'; sp++);
+ for (; *sp == ' ' || *sp == '\t'; sp++) {
+ ; // do nothing
+ }
if (!strncmp(sp, "#define", 7)) {
- for (p = sp + 7; *p == ' ' || *p == '\t'; p++);
+ for (p = sp + 7; *p == ' ' || *p == '\t'; p++) {
+ ; // do nothing
+ }
if (*p == '\n' || *p == '\r' || *p == '/') {
memset(sp, 0x20, 7);
}
}
- for (; *sp && *sp != '\n' && *sp != '\r'; sp++);
- for (; *sp == '\n' || *sp == '\r'; sp++);
+ for (; *sp && *sp != '\n' && *sp != '\r'; sp++) {
+ ; // do nothing
+ }
+ for (; *sp == '\n' || *sp == '\r'; sp++) {
+ ; // do nothing
+ }
}
return patched;
}
if(string[i]) {
s[i] = do_eglShaderPatch(string[i], len, &l[i]);
if(!s[i]) {
- while(i)
+ while(i) {
free(s[--i]);
+ }
free(l);
free(s);
glstate->context);
qsurface->client_drawable = client_drawable;
qsurface->ref = 1;
+ qsurface->type = SURFACE_WINDOW;
+ qsurface->status = SURFACE_ACTIVE;
bind_qsurface(glstate, qsurface);
// DEBUGF( " --Client drawable not found, create new surface: %16x %16lx\n", (unsigned int)qsurface, (unsigned long int)client_drawable);
ptr_func_glShaderSource(args[0], args[1], tab_prog_new, tab_length_new);
- for (i = 0; i < args[1]; i++)
+ for (i = 0; i < args[1]; i++) {
free(tab_prog_new[i]);
+ }
+
free(tab_prog_new);
free(tab_length_new);