glsNAMEDOBJECT_PTR glfFindNamedObject( IN glsNAMEDOBJECTLIST_PTR List, IN gctUINT32 Name ) { gcmHEADER_ARG("List=0x%x Name=%u", List, Name); /* Allocated objects can never have zero-valued names. */ if (Name) { /* Determine the index into the hash table. */ gctUINT32 index = Name % glvNAMEDOBJECT_HASHTABLE_SIZE; /* Get a shortcut to the table entry. */ glsNAMEDOBJECT_PTR* entry = &List->hashTable[index]; /* Keep history. */ glsNAMEDOBJECT_PTR prev = gcvNULL; /* Start from the beginning. */ glsNAMEDOBJECT_PTR curr = *entry; while (curr) { if (curr->name == Name) { /* Move to the front of the list. */ if (prev != gcvNULL) { prev->next = curr->next; curr->next = *entry; *entry = curr; } gcmFOOTER_ARG("curr=0x%x", curr); return curr; } /* The current becomes history. */ prev = curr; /* Move to the next one. */ curr = curr->next; } } gcmFOOTER_ARG("curr=0x%x", gcvNULL); return gcvNULL; }
_VGObject * vgshFindObject( _VGContext *Context, VGuint Name ) { VGuint index; _VGObject* object; gcmHEADER_ARG("Context=0x%x Name=%u", Context, Name); index = Name % NAMED_OBJECTS_HASH; for (object = Context->sharedData->namedObjects[index]; object != gcvNULL; object = object->next) { if (object->name == (VGint) Name) { if (object->prev != gcvNULL) { object->prev->next = object->next; if (object->next != gcvNULL) { object->next->prev = object->prev; } object->prev = gcvNULL; object->next = Context->sharedData->namedObjects[index]; object->next->prev = object; Context->sharedData->namedObjects[index] = object; } gcmFOOTER_ARG("return=0x%x", object); return object; } } gcmFOOTER_ARG("return=0x%x", gcvNULL); return gcvNULL; }
gctBOOL vgshInsertObject( _VGContext *Context, _VGObject *Object, _VGObjectType Type ) { VGuint index; gcmHEADER_ARG("Context=0x%x Object=0x%x Type=%d", Context, Object, Type); Object->name = Context->sharedData->objectCount + 1; Object->type = Type; if (Object->name == 0) { gcmFOOTER_ARG("return=%s", "FALSE"); return gcvFALSE; } Context->sharedData->objectCount = Object->name; index = Object->name % NAMED_OBJECTS_HASH; Object->prev = gcvNULL; Object->next = Context->sharedData->namedObjects[index]; if (Object->next != gcvNULL) { Object->next->prev = Object; } Context->sharedData->namedObjects[index] = Object; gcmFOOTER_ARG("return=%s", "FALSE"); return gcvTRUE; }
gceSTATUS glfConstructNamedObjectList( IN glsCONTEXT_PTR Context, IN glsNAMEDOBJECTLIST_PTR List, IN gctUINT32 ObjectSize ) { gcmHEADER_ARG("Context=0x%x List=0x%x ObjectSize=%u", Context, List, ObjectSize); List->objectSize = ObjectSize; List->nextName = 1; gcmFOOTER_ARG("return=%s", "gcvSTATUS_OK"); return gcvSTATUS_OK; }
/******************************************************************************* ** ** gcoDUMP_IsEnabled ** ** Test whether dumping is enabeld or not. ** ** INPUT: ** ** gcoDUMP Dump ** Pointer to a gcoDUMP object. ** ** OUTPUT: ** ** gctBOOL * Enabled ** Pointer to a variable receiving the dump status. */ gceSTATUS gcoDUMP_IsEnabled( IN gcoDUMP Dump, OUT gctBOOL * Enabled ) { gcmHEADER_ARG("Dump=0x%x Enabled=0x%x", Dump, Enabled); /* Verify the arguments. */ gcmVERIFY_OBJECT(Dump, gcvOBJ_DUMP); gcmVERIFY_ARGUMENT(Enabled != gcvNULL); /* Return dump status. */ *Enabled = (Dump->file != gcvNULL); /* Success. */ gcmFOOTER_ARG("*Enabled=%d", *Enabled); return gcvSTATUS_OK; }
gceSTATUS gcoOS_GetNextDisplayInfoEx( IN HALNativeDisplayType Display, IN HALNativeWindowType Window, IN gctUINT DisplayInfoSize, OUT halDISPLAY_INFO * DisplayInfo ) { int rc; gceSTATUS status = gcvSTATUS_OK; screen_buffer_t buf[gcdDISPLAY_BACK_BUFFERS]; gcmHEADER_ARG("Display=0x%x Window=0x%x DisplayInfoSize=%u", Display, Window, DisplayInfoSize); if ((Window == gcvNULL) || (DisplayInfoSize != sizeof(halDISPLAY_INFO))) { goto OnError; } rc = screen_get_window_property_pv((screen_window_t)Window, SCREEN_PROPERTY_RENDER_BUFFERS, (void**)buf); if (rc) { goto OnError; } rc = screen_post_window((screen_window_t)Window, buf[0], 0, NULL, 0); if (rc) { goto OnError; } status = gcoOS_GetDisplayInfoEx(Display, Window, DisplayInfoSize, DisplayInfo); gcmFOOTER_ARG("*DisplayInfo=0x%x", *DisplayInfo); return status; OnError: status = gcvSTATUS_INVALID_ARGUMENT; gcmFOOTER(); return status; }
/******************************************************************************* ** ** gcoDUMP_Construct ** ** Construct a new gcoDUMP object. ** ** INPUT: ** ** gcoOS Os ** Pointer to an gcoOS object. ** ** gcoOS Hal ** Pointer to an gcoHAL object. ** ** OUTPUT: ** ** gcoDUMP * Dump ** Pointer to a variable receiving the gcoDUMP object pointer. */ gceSTATUS gcoDUMP_Construct( IN gcoOS Os, IN gcoHAL Hal, OUT gcoDUMP * Dump ) { gceSTATUS status; gcoDUMP dump; gctPOINTER pointer = gcvNULL; gcmHEADER_ARG("Os=0x%x Dump=0x%x", Os, Dump); /* Verify the arguments. */ gcmVERIFY_ARGUMENT(Dump != gcvNULL); do { /* Allocate the gcoDUMP structure. */ gcmERR_BREAK(gcoOS_Allocate(Os, sizeof(struct _gcoDUMP), &pointer)); dump = pointer; /* Initialize the gcoDUMP object. */ dump->object.type = gcvOBJ_DUMP; dump->file = gcvNULL; /* Return pointer to the object. */ *Dump = dump; } while (gcvFALSE); /* Return the status. */ gcmFOOTER_ARG("*Dump=0x%x", *Dump); return status; }
gceSTATUS gcoOS_GetDisplayInfoEx( IN HALNativeDisplayType Display, IN HALNativeWindowType Window, IN gctUINT DisplayInfoSize, OUT halDISPLAY_INFO * DisplayInfo ) { gceSTATUS status = gcvSTATUS_OK; screen_buffer_t buf[gcdDISPLAY_BACK_BUFFERS]; gctPOINTER pointer; off64_t paddr; gctINT rc, stride; gctINT size[2]; gcmHEADER_ARG("Display=0x%x Window=0x%x DisplayInfoSize=%u", Display, Window, DisplayInfoSize); /* Valid Window? and structure size? */ if ((Window == gcvNULL) || (DisplayInfoSize != sizeof(halDISPLAY_INFO))) { goto OnError; } rc = screen_get_window_property_pv((screen_window_t)Window, SCREEN_PROPERTY_RENDER_BUFFERS, (void**)buf); if (rc) { goto OnError; } /* For QNX, the Width and Height are size of the framebuffer. */ rc = screen_get_buffer_property_iv(buf[0], SCREEN_PROPERTY_BUFFER_SIZE, size); if (rc) { goto OnError; } DisplayInfo->width = size[0]; DisplayInfo->height = size[1]; /* The stride of the window. */ rc = screen_get_buffer_property_iv(buf[0], SCREEN_PROPERTY_STRIDE, &stride); if (rc) { goto OnError; } DisplayInfo->stride = stride; /* The logical address of the window. */ rc = screen_get_buffer_property_pv(buf[0], SCREEN_PROPERTY_POINTER, &pointer); if (rc) { goto OnError; } DisplayInfo->logical = pointer; /* The physical address of the window. */ rc = screen_get_buffer_property_llv(buf[0], SCREEN_PROPERTY_PHYSICAL_ADDRESS, &paddr); if (rc) { goto OnError; } DisplayInfo->physical = paddr; /* Flip. */ DisplayInfo->flip = 1; /* Success. */ gcmFOOTER_ARG("*DisplayInfo=0x%x", *DisplayInfo); return status; OnError: status = gcvSTATUS_INVALID_ARGUMENT; gcmFOOTER(); return status; }
gceSTATUS ppoPREPROCESSOR_MacroExpand_2_NoFormalArgs( ppoPREPROCESSOR PP, ppoINPUT_STREAM *IS, ppoTOKEN *Head, ppoTOKEN *End, gctBOOL *AnyExpanationHappened, gctBOOL *MatchCase, ppoTOKEN ID, ppoMACRO_SYMBOL MS) { gceSTATUS status = gcvSTATUS_INVALID_DATA; ppoTOKEN id = ID; ppoMACRO_SYMBOL ms = MS; ppoTOKEN replacement_list = gcvNULL; gcmHEADER_ARG("PP=0x%x IS=0x%x Head=0x%x End=0x%x AnyExpanationHappened=0x%x MatchCase=0x%x ID=0x%x MS=0x%x", PP, IS, Head, End, AnyExpanationHappened, MatchCase, ID, MS); gcmASSERT(ms != gcvNULL); if (ms->argc == 0) { gcmTRACE(gcvLEVEL_VERBOSE, "ME : macro %s has no arg(s).",id->poolString); if (ms->replacementList == gcvNULL) { gcmTRACE(gcvLEVEL_VERBOSE, "ME : macro %s, has no replacement-list.",id->poolString); *Head = gcvNULL; *End = gcvNULL; *AnyExpanationHappened = gcvTRUE; *MatchCase = gcvTRUE; status = ppoTOKEN_Destroy(PP,id); if (gcmIS_SUCCESS(status)) { gcmFOOTER_ARG("*Head=0x%x *End=0x%x *AnyExpanationHappened=%d *MatchCase=%d", *Head, *End, *AnyExpanationHappened, *MatchCase); return gcvSTATUS_OK; } else { gcmFOOTER(); return status; } } gcmTRACE(gcvLEVEL_VERBOSE, "ME : macro %s, has replacement-list.",id->poolString); gcmTRACE(gcvLEVEL_VERBOSE, "ME : macro %s, colon replacement-list.",id->poolString); gcmONERROR(ppoTOKEN_ColonTokenList( PP, ms->replacementList, __FILE__, __LINE__, "ME : colon replacementList", &replacement_list) ); *Head = replacement_list; gcmTRACE(gcvLEVEL_VERBOSE, "ME : macro %s, add hs.",id->poolString); while(replacement_list) { gcmASSERT(replacement_list->hideSet == gcvNULL); ppoHIDE_SET_LIST_Append( PP, replacement_list, id); ppoHIDE_SET_AddHS(PP, replacement_list, id->poolString); if((void*)replacement_list->inputStream.base.node.prev == gcvNULL) { *End = replacement_list; } replacement_list = (ppoTOKEN)replacement_list->inputStream.base.node.prev; } *AnyExpanationHappened = gcvTRUE; *MatchCase = gcvTRUE; status = ppoTOKEN_Destroy(PP,id); if (gcmIS_SUCCESS(status)) { gcmFOOTER_ARG("*Head=0x%x *End=0x%x *AnyExpanationHappened=%d *MatchCase=%d", *Head, *End, *AnyExpanationHappened, *MatchCase); return gcvSTATUS_OK; } else { gcmFOOTER(); return status; } } else/*if (ms->argc == 0)*/ { *Head = gcvNULL; *End = gcvNULL; *AnyExpanationHappened = gcvFALSE; *MatchCase = gcvFALSE; gcmFOOTER_ARG("*Head=0x%x *End=0x%x *AnyExpanationHappened=%d *MatchCase=%d", *Head, *End, *AnyExpanationHappened, *MatchCase); return gcvSTATUS_OK; } OnError: gcmFOOTER(); return status; }
EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib( EGLDisplay Dpy, EGLConfig Config, EGLint attribute, EGLint *value ) { VEGLThreadData thread; VEGLDisplay dpy; VEGLConfig config; gcmHEADER_ARG("Dpy=0x%x Config=0x%x attribute=%d", Dpy, Config, attribute); /* Get thread data. */ thread = veglGetThreadData(); if (thread == gcvNULL) { gcmTRACE( gcvLEVEL_ERROR, "%s(%d): veglGetThreadData failed.", __FUNCTION__, __LINE__ ); gcmFOOTER_ARG("return=%d", EGL_FALSE); return EGL_FALSE; } /* Create shortcuts to objects. */ dpy = VEGL_DISPLAY(Dpy); config = VEGL_CONFIG(Config); /* Test for valid EGLDisplay structure. */ if ((dpy == gcvNULL) || (dpy->signature != EGL_DISPLAY_SIGNATURE) ) { /* Bad display. */ thread->error = EGL_BAD_DISPLAY; gcmFOOTER_ARG("return=%d", EGL_FALSE); return EGL_FALSE; } if (value == gcvNULL) { /* Bad parameter. */ thread->error = EGL_BAD_PARAMETER; gcmFOOTER_ARG("return=%d", EGL_FALSE); return EGL_FALSE; } /* Test for valid config. */ if ((config < dpy->config) || (config >= dpy->config + dpy->configCount) ) { thread->error = EGL_BAD_CONFIG; gcmFOOTER_ARG("0x%x", EGL_FALSE); return EGL_FALSE; } /* Reference the EGLDisplay. */ if (!veglReferenceDisplay(thread, dpy)) { /* Not initialized. */ thread->error = EGL_NOT_INITIALIZED; gcmFOOTER_ARG("return=%d", EGL_FALSE); return EGL_FALSE; } switch (attribute) { case EGL_BUFFER_SIZE: *value = config->bufferSize; break; case EGL_ALPHA_SIZE: *value = config->alphaSize; break; case EGL_BLUE_SIZE: *value = config->blueSize; break; case EGL_GREEN_SIZE: *value = config->greenSize; break; case EGL_RED_SIZE: *value = config->redSize; break; case EGL_DEPTH_SIZE: *value = config->depthSize; break; case EGL_STENCIL_SIZE: *value = config->stencilSize; break; case EGL_CONFIG_CAVEAT: *value = config->configCaveat; break; case EGL_CONFIG_ID: *value = config->configId; break; case EGL_LEVEL: *value = 0; break; case EGL_MAX_PBUFFER_WIDTH: *value = thread->maxWidth; break; case EGL_MAX_PBUFFER_HEIGHT: *value = thread->maxHeight; break; case EGL_MAX_PBUFFER_PIXELS: *value = thread->maxWidth * thread->maxHeight; break; case EGL_NATIVE_RENDERABLE: *value = config->nativeRenderable; break; case EGL_NATIVE_VISUAL_ID: *value = veglGetNativeVisualId(dpy, config); break; case EGL_NATIVE_VISUAL_TYPE: *value = config->nativeVisualType; break; case EGL_PRESERVED_RESOURCES: *value = EGL_TRUE; break; case EGL_SAMPLES: *value = config->samples; break; case EGL_SAMPLE_BUFFERS: if ((config->samples == 16) && (thread->api == EGL_OPENVG_API)) { *value = 0; } else { *value = config->sampleBuffers; } break; case EGL_SURFACE_TYPE: *value = config->surfaceType; break; case EGL_TRANSPARENT_TYPE: *value = EGL_NONE; break; case EGL_TRANSPARENT_BLUE_VALUE: case EGL_TRANSPARENT_GREEN_VALUE: case EGL_TRANSPARENT_RED_VALUE: *value = EGL_DONT_CARE; break; case EGL_BIND_TO_TEXTURE_RGB: *value = config->bindToTetxureRGB; break; case EGL_BIND_TO_TEXTURE_RGBA: *value = config->bindToTetxureRGBA; break; case EGL_MIN_SWAP_INTERVAL: case EGL_MAX_SWAP_INTERVAL: *value = 1; break; case EGL_LUMINANCE_SIZE: *value = config->luminanceSize; break; case EGL_ALPHA_MASK_SIZE: *value = config->alphaMaskSize; break; case EGL_COLOR_BUFFER_TYPE: *value = config->colorBufferType; break; case EGL_RENDERABLE_TYPE: *value = config->renderableType; break; case EGL_CONFORMANT: *value = config->conformant; break; case EGL_MATCH_NATIVE_PIXMAP: *value = config->matchNativePixmap; break; case EGL_RECORDABLE_ANDROID: *value = config->recordableConfig; break; default: /* Dereference the EGLDisplay. */ veglDereferenceDisplay(thread, dpy, EGL_FALSE); /* Bad attribute. */ thread->error = EGL_BAD_ATTRIBUTE; gcmFOOTER_ARG("return=%d", EGL_FALSE); return EGL_FALSE; } /* Dereference the EGLDisplay. */ veglDereferenceDisplay(thread, dpy, EGL_FALSE); /* Success. */ thread->error = EGL_SUCCESS; gcmDUMP_API("${EGL eglGetConfigAttrib 0x%08X 0x%08X 0x%08X := 0x%08X}", Dpy, Config, attribute, *value); gcmFOOTER_ARG("*value=%d", *value); return EGL_TRUE; }
gceSTATUS gcoQUEUE_Construct( IN gcoOS Os, OUT gcoQUEUE * Queue ) { gcoQUEUE queue = gcvNULL; gceSTATUS status; #ifdef __QNXNTO__ gctSIZE_T allocationSize; gctPHYS_ADDR physAddr; #endif gctPOINTER pointer = gcvNULL; gcmHEADER(); /* Verify the arguments. */ gcmVERIFY_ARGUMENT(Queue != gcvNULL); /* Create the queue. */ gcmONERROR( gcoOS_Allocate(gcvNULL, gcmSIZEOF(struct _gcoQUEUE), &pointer)); queue = pointer; /* Initialize the object. */ queue->object.type = gcvOBJ_QUEUE; /* Nothing in the queue yet. */ queue->head = queue->tail = gcvNULL; queue->recordCount = 0; #ifdef __QNXNTO__ /* Allocate buffer of records. */ allocationSize = BUFFER_SIZE; physAddr = 0; gcmONERROR( gcoOS_AllocateNonPagedMemory(gcvNULL, gcvTRUE, &allocationSize, &physAddr, (gctPOINTER *) &queue->records)); queue->freeBytes = allocationSize; queue->offset = 0; #else queue->freeList = gcvNULL; #endif /* Return gcoQUEUE pointer. */ *Queue = queue; /* Success. */ gcmFOOTER_ARG("*Queue=0x%x", *Queue); return gcvSTATUS_OK; OnError: if (queue != gcvNULL) { /* Roll back. */ gcmVERIFY_OK(gcmOS_SAFE_FREE(gcvNULL, queue)); } /* Return the status. */ gcmFOOTER(); return status; }
gceSTATUS gcoQUEUE_AppendEvent( IN gcoQUEUE Queue, IN gcsHAL_INTERFACE * Interface ) { gceSTATUS status; gcsQUEUE_PTR record = gcvNULL; #ifdef __QNXNTO__ gctSIZE_T allocationSize; gctPHYS_ADDR physAddr; #else gctPOINTER pointer = gcvNULL; #endif gcmHEADER_ARG("Queue=0x%x Interface=0x%x", Queue, Interface); /* Verify the arguments. */ gcmVERIFY_OBJECT(Queue, gcvOBJ_QUEUE); gcmVERIFY_ARGUMENT(Interface != gcvNULL); /* Allocate record. */ #ifdef __QNXNTO__ allocationSize = gcmSIZEOF(gcsQUEUE); if (Queue->freeBytes < allocationSize) { gctSIZE_T recordsSize = BUFFER_SIZE; gcsQUEUE_PTR prevRecords = Queue->records; gcsHAL_INTERFACE iface; /* Allocate new set of records. */ gcmONERROR( gcoOS_AllocateNonPagedMemory(gcvNULL, gcvTRUE, &recordsSize, &physAddr, (gctPOINTER *) &Queue->records)); Queue->freeBytes = recordsSize; Queue->offset = 0; if ( Queue->freeBytes < allocationSize ) { gcmFOOTER_ARG("status=%d", gcvSTATUS_DATA_TOO_LARGE); return gcvSTATUS_DATA_TOO_LARGE; } /* Schedule to free Queue->records, * hence not unmapping currently scheduled events immediately. */ iface.command = gcvHAL_FREE_NON_PAGED_MEMORY; iface.u.FreeNonPagedMemory.bytes = BUFFER_SIZE; iface.u.FreeNonPagedMemory.physical = 0; iface.u.FreeNonPagedMemory.logical = prevRecords; gcmONERROR( gcoQUEUE_AppendEvent(Queue, &iface)); } record = (gcsQUEUE_PTR)((gctUINT32)Queue->records + Queue->offset); Queue->offset += allocationSize; Queue->freeBytes -= allocationSize; #else /* Check if we have records on the free list. */ if (Queue->freeList != gcvNULL) { /* Allocate from hte free list. */ record = Queue->freeList; Queue->freeList = record->next; } else { gcmONERROR(gcoOS_Allocate(gcvNULL, gcmSIZEOF(gcsQUEUE), &pointer)); record = pointer; } #endif /* Initialize record. */ record->next = gcvNULL; gcoOS_MemCopy(&record->iface, Interface, gcmSIZEOF(record->iface)); if (Queue->head == gcvNULL) { /* Initialize queue. */ Queue->head = record; } else { /* Append record to end of queue. */ Queue->tail->next = record; } /* Mark end of queue. */ Queue->tail = record; /* update count */ Queue->recordCount++; /* Success. */ gcmFOOTER_NO(); return gcvSTATUS_OK; OnError: #ifndef __QNXNTO__ if (pointer != gcvNULL) { /* Put record on free list. */ record->next = Queue->freeList; Queue->freeList = record; } #endif /* Return the status. */ gcmFOOTER(); return status; }
gceSTATUS gcoOS_CreatePixmap( IN HALNativeDisplayType Display, IN gctINT Width, IN gctINT Height, IN gctINT BitsPerPixel, OUT HALNativePixmapType * Pixmap ) { gctINT size[2]; gctINT screen_format = SCREEN_FORMAT_RGBA8888; gctINT screen_usage = SCREEN_USAGE_OPENGL_ES1 | SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_OPENVG; gctINT rc; gceSTATUS status = gcvSTATUS_OK; gcmHEADER_ARG("Display=0x%x Width=%d Height=%d BitsPerPixel=%d", Display, Width, Height, BitsPerPixel); if ((Width <= 0) || (Height <= 0) || (BitsPerPixel <= 0)) { status = gcvSTATUS_INVALID_ARGUMENT; gcmFOOTER(); return status; } /* Create pixmap structure. */ rc = screen_create_pixmap((struct _screen_pixmap **)Pixmap, screen_ctx); if (rc) { fprintf(stderr, "screen_create_pixmap failed with error %d (0x%08x)\n", errno, errno); status = gcvSTATUS_OUT_OF_RESOURCES; gcmFOOTER(); return status; } switch (BitsPerPixel) { case 8: screen_format = SCREEN_FORMAT_BYTE; break; case 16: screen_format = SCREEN_FORMAT_RGB565; break; case 24: screen_format = SCREEN_FORMAT_RGB888; break; case 32: screen_format = SCREEN_FORMAT_RGBA8888; break; default: break; } /* Set pximap format. */ rc = screen_set_pixmap_property_iv(*Pixmap, SCREEN_PROPERTY_FORMAT, &screen_format); if (rc) { fprintf(stderr, "screen_set_pixmap_property_iv(SCREEN_PROPERTY_FORMAT) failed with error %d (0x%08x)\n", errno, errno); screen_destroy_pixmap(*Pixmap); status = gcvSTATUS_OUT_OF_RESOURCES; gcmFOOTER(); return status; } /* Set pixmap usage. */ rc = screen_set_pixmap_property_iv(*Pixmap, SCREEN_PROPERTY_USAGE, &screen_usage); if (rc) { fprintf(stderr, "screen_set_pixmap_property_iv(SCREEN_PROPERTY_USAGE) failed with error %d (0x%08x)\n", errno, errno); screen_destroy_pixmap(*Pixmap); status = gcvSTATUS_OUT_OF_RESOURCES; gcmFOOTER(); return status; } /* Resize the pixmap. */ size[0] = Width; size[1] = Height; rc = screen_set_pixmap_property_iv(*Pixmap, SCREEN_PROPERTY_BUFFER_SIZE, size); if (rc) { fprintf(stderr, "screen_set_pixmap_property_iv(SCREEN_PROPERTY_BUFFER_SIZE) failed with error %d (0x%08x)\n", errno, errno); screen_destroy_pixmap(*Pixmap); status = gcvSTATUS_OUT_OF_RESOURCES; gcmFOOTER(); return status; } /* Create pixmap buffer. */ rc = screen_create_pixmap_buffer(*Pixmap); if (rc) { fprintf(stderr, "screen_create_pixmap_buffer failed with error %d (0x%08x)\n", errno, errno); screen_destroy_pixmap(*Pixmap); status = gcvSTATUS_OUT_OF_RESOURCES; gcmFOOTER(); return status; } gcmFOOTER_ARG("*Pixmap=0x%x", *Pixmap); return status; }
gceSTATUS vgsMEMORYMANAGER_Allocate( IN vgsMEMORYMANAGER_PTR Manager, OUT gctPOINTER * Pointer ) { gceSTATUS status; vgsMEMORYITEM_PTR firstFree; gcmHEADER_ARG("Manager=0x%x Pointer=0x%x", Manager, Pointer); /* Verify arguments. */ gcmVERIFY_ARGUMENT(Manager != gcvNULL); gcmVERIFY_ARGUMENT(Pointer != gcvNULL); /* Get the first free. */ firstFree = Manager->firstFree; /* Are there free items? */ if (firstFree != gcvNULL) { /* Set the result. */ * Pointer = firstFree + 1; /* Remove from the free list. */ Manager->firstFree = firstFree->next; /* Update allocated items count. */ #if vgvVALIDATE_MEMORY_MANAGER Manager->allocatedCount += 1; if ((gctUINT) Manager->allocatedCount > Manager->maximumAllocated) { Manager->maximumAllocated = Manager->allocatedCount; } #endif /* Success. */ gcmFOOTER_ARG("*Pointer=0x%x", *Pointer); return gcvSTATUS_OK; } /* No free items available. */ do { vgsMEMORYITEM_PTR newBuffer; gctUINT i, itemCount; gctUINT itemSize; /* Allocate a new buffer. */ gcmERR_BREAK(gcoOS_Allocate( Manager->os, Manager->allocationSize, (gctPOINTER) &newBuffer )); /* Link in. */ newBuffer->next = Manager->firstAllocated; Manager->firstAllocated = newBuffer; /* Set the result. */ * Pointer = newBuffer + 2; /* Update allocated items count. */ #if vgvVALIDATE_MEMORY_MANAGER Manager->allocatedCount += 1; Manager->allocatedBufferCount += 1; if ((gctUINT) Manager->allocatedCount > Manager->maximumAllocated) { Manager->maximumAllocated = Manager->allocatedCount; } #endif /* Get the number of items per allocation. */ itemCount = Manager->itemCount; /* Get the item size. */ itemSize = Manager->itemSize; /* Determine the first free item. */ firstFree = (vgsMEMORYITEM_PTR) ( (gctUINT8_PTR) (newBuffer + 1) + itemSize ); /* Populate the new buffer. */ for (i = 1; i < itemCount; i++) { /* Add to the free item list. */ firstFree->next = Manager->firstFree; Manager->firstFree = firstFree; /* Advance to the next item. */ firstFree = (vgsMEMORYITEM_PTR) ( (gctUINT8_PTR) firstFree + itemSize ); } } while (gcvFALSE); gcmFOOTER(); /* Return status. */ return status; }
/******************************************************************************* ** ** gcoCMDBUF_Construct ** ** Construct a new gcoCMDBUF object. ** ** INPUT: ** ** gcoOS Os ** Pointer to a gcoOS object. ** ** gcoHARDWARE Hardware ** Pointer to a gcoHARDWARE object. ** ** gctSIZE_T Bytes ** Number of bytes for the buffer. ** ** gcsCOMMAND_BUFFER_PTR Info ** Alignment and head/tail information. ** ** OUTPUT: ** ** gcoCMDBUF * CommandBuffer ** Pointer to a variable that will hold the the gcoCMDBUF object ** pointer. */ gceSTATUS gcoCMDBUF_Construct( IN gcoOS Os, IN gcoHARDWARE Hardware, IN gctSIZE_T Bytes, IN gcsCOMMAND_INFO_PTR Info, OUT gcoCMDBUF * CommandBuffer ) { gceSTATUS status; gcoCMDBUF commandBuffer = gcvNULL; gctSIZE_T objectSize; #ifdef __QNXNTO__ gctPHYS_ADDR physical; #else gctPOINTER pointer = gcvNULL; #endif gcmHEADER_ARG("Bytes=%lu Info=0x%x", Bytes, Info); /* Verify the arguments. */ gcmDEBUG_VERIFY_ARGUMENT(Bytes > 0); gcmDEBUG_VERIFY_ARGUMENT(CommandBuffer != gcvNULL); /* Set the size of the object. */ objectSize = gcmSIZEOF(struct _gcoCMDBUF); /* Allocate the gcoCMDBUF object. */ #ifdef __QNXNTO__ /* gcoCMDBUF object needs to be accessible from the kernel; to avoid copying of the data for each access, allocate the object from the kernel non-paged memory. */ gcmONERROR(gcoOS_AllocateNonPagedMemory( gcvNULL, gcvTRUE, &objectSize, &physical, (gctPOINTER *) &commandBuffer )); #else /* Currently in most OS we are able to access the user-side data from the kernel by simple memory mapping, therefore here we allocate the object from the cached user memory. */ gcmONERROR(gcoOS_Allocate(gcvNULL, objectSize, &pointer)); commandBuffer = pointer; #endif /* Reset the command buffer object. */ gcmONERROR(gcoOS_ZeroMemory(commandBuffer, objectSize)); /* Initialize the gcoCMDBUF object. */ commandBuffer->object.type = gcvOBJ_COMMANDBUFFER; commandBuffer->bytes = Bytes; /* Allocate the physical buffer for the command. */ gcmONERROR(gcoOS_AllocateContiguous( gcvNULL, gcvTRUE, &commandBuffer->bytes, &commandBuffer->physical, &commandBuffer->logical )); /* Initialize command buffer. */ commandBuffer->free = commandBuffer->bytes; #if gcdSECURE_USER /* Determine the size of the state array. */ commandBuffer->hintArraySize = Bytes; /* Allocate the state array. */ #ifdef __QNXNTO__ gcmONERROR(gcoOS_AllocateNonPagedMemory( gcvNULL, gcvTRUE, &commandBuffer->hintArraySize, &physical, (gctPOINTER *) &commandBuffer->hintArray )); #else gcmONERROR(gcoOS_Allocate( gcvNULL, commandBuffer->hintArraySize, &pointer )); commandBuffer->hintArray = pointer; #endif /* Initialize the state array tail pointer. */ commandBuffer->hintArrayTail = commandBuffer->hintArray; #endif /* Return pointer to the gcoCMDBUF object. */ *CommandBuffer = commandBuffer; /* Success. */ gcmFOOTER_ARG("*CommandBuffer=0x%x", *CommandBuffer); return gcvSTATUS_OK; OnError: /* Roll back. */ if (commandBuffer != gcvNULL) { if (commandBuffer->logical != gcvNULL) { gcmVERIFY_OK(gcoOS_FreeContiguous( gcvNULL, commandBuffer->physical, commandBuffer->logical, commandBuffer->bytes )); } #if gcdSECURE_USER if (commandBuffer->hintArray != gcvNULL) { #ifdef __QNXNTO__ gcmVERIFY_OK(gcoOS_FreeNonPagedMemory( gcvNULL, commandBuffer->hintArraySize, gcvNULL, commandBuffer->hintArray )); #else gcmVERIFY_OK(gcmOS_SAFE_FREE(gcvNULL, commandBuffer->hintArray)); #endif } #endif #ifdef __QNXNTO__ gcmVERIFY_OK(gcoOS_FreeNonPagedMemory( gcvNULL, objectSize, gcvNULL, commandBuffer )); #else gcmVERIFY_OK(gcmOS_SAFE_FREE(gcvNULL, commandBuffer)); #endif } /* Return the status. */ gcmFOOTER(); return status; }
static gceSTATUS _ConvertWindowFormat( IN gctINT ScreenFormat, OUT gctINT * BitsPerPixel, OUT gctINT * Format ) { gctUINT bpp, fmt; gceSTATUS status = gcvSTATUS_OK; gcmHEADER_ARG("ScreenFormat=%d.", ScreenFormat); switch (ScreenFormat) { case SCREEN_FORMAT_BYTE: bpp = 8; fmt = gcvSURF_L8; break; case SCREEN_FORMAT_RGBA4444: bpp = 16; fmt = gcvSURF_A4R4G4B4; break; case SCREEN_FORMAT_RGBX4444: bpp = 16; fmt = gcvSURF_X4R4G4B4; break; case SCREEN_FORMAT_RGBA5551: bpp = 16; fmt = gcvSURF_A1R5G5B5; break; case SCREEN_FORMAT_RGBX5551: bpp = 16; fmt = gcvSURF_X1R5G5B5; break; case SCREEN_FORMAT_RGB565: bpp = 16; fmt = gcvSURF_R5G6B5; break; case SCREEN_FORMAT_RGB888: bpp = 24; fmt = gcvSURF_R8G8B8; break; case SCREEN_FORMAT_RGBA8888: bpp = 32; fmt = gcvSURF_A8R8G8B8; break; case SCREEN_FORMAT_RGBX8888: bpp = 32; fmt = gcvSURF_X8R8G8B8; break; default: goto OnError; } if (gcvNULL != BitsPerPixel) { *BitsPerPixel = bpp; } if (gcvNULL != Format) { *Format = fmt; } gcmFOOTER_ARG("*BitsPerPixel=%d, *Format=%d.", bpp, fmt); return status; OnError: status = gcvSTATUS_INVALID_ARGUMENT; gcmFOOTER(); return status; }
EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs( EGLDisplay Dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config ) { VEGLThreadData thread; VEGLDisplay dpy; gcmHEADER_ARG("Dpy=0x%x configs=0x%x config_size=%d", Dpy, configs, config_size); /* Get thread data. */ thread = veglGetThreadData(); if (thread == gcvNULL) { gcmTRACE( gcvLEVEL_ERROR, "%s(%d): veglGetThreadData failed.", __FUNCTION__, __LINE__ ); gcmFOOTER_ARG("return=%d", EGL_FALSE); return EGL_FALSE; } /* Create a shortcut to the display. */ dpy = VEGL_DISPLAY(Dpy); /* Test for valid EGLDisplay structure. */ if ( (dpy == gcvNULL) || (dpy->signature != EGL_DISPLAY_SIGNATURE) ) { /* Bad display. */ thread->error = EGL_BAD_DISPLAY; gcmFOOTER_ARG("return=%d", EGL_FALSE); return EGL_FALSE; } /* Test for initialized or not. */ if (dpy->referenceDpy == gcvNULL && dpy->contextStack == EGL_NO_CONTEXT) { thread->error = EGL_NOT_INITIALIZED; gcmFOOTER_ARG("return=%d", EGL_FALSE); return EGL_FALSE; } if (num_config == gcvNULL) { /* Bad parameter. */ thread->error = EGL_BAD_PARAMETER; gcmFOOTER_ARG("return=%d", EGL_FALSE); return EGL_FALSE; } /* Reference the EGLDisplay. */ if (!veglReferenceDisplay(thread, dpy)) { /* Not initialized. */ thread->error = EGL_NOT_INITIALIZED; gcmFOOTER_ARG("return=%d", EGL_FALSE); return EGL_FALSE; } if (configs == gcvNULL) { /* Return number of configurations. */ *num_config = dpy->configCount; } else { EGLint index; /* Copy pointers to configurations into supplied buffer. */ for (index = 0; index < dpy->configCount; index++) { /* Bail out if the supplied buffer is too small. */ if (index >= config_size) { break; } configs[index] = &dpy->config[index]; } *num_config = index; /* Zero any remaining configurations in the supplied buffer. */ while (index < config_size) { configs[index++] = gcvNULL; } } /* Dereference the EGLDisplay. */ veglDereferenceDisplay(thread, dpy, EGL_FALSE); /* Success. */ thread->error = EGL_SUCCESS; gcmDUMP_API("${EGL eglGetConfigs 0x%08X (0x%08X) 0x%08X (0x%08X)", Dpy, configs, config_size, num_config); gcmDUMP_API_ARRAY(configs, *num_config); gcmDUMP_API_ARRAY(num_config, 1); gcmDUMP_API("$}"); gcmFOOTER_ARG("*num_config=%d", *num_config); return EGL_TRUE; }
EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig( EGLDisplay Dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config ) { VEGLThreadData thread; VEGLDisplay dpy; struct eglConfig criteria = { 0 }; EGLint config; gcmHEADER_ARG("Dpy=0x%x attrib_list=0x%x configs=0x%x config_size=%d", Dpy, attrib_list, configs, config_size); /* Get thread data. */ thread = veglGetThreadData(); if (thread == gcvNULL) { gcmTRACE( gcvLEVEL_ERROR, "%s(%d): veglGetThreadData failed.", __FUNCTION__, __LINE__ ); gcmFOOTER_ARG("return=%d", EGL_FALSE); return EGL_FALSE; } /* Create a shortcut to the display. */ dpy = VEGL_DISPLAY(Dpy); /* Test for valid EGLDisplay structure. */ if ((dpy == gcvNULL) || (dpy->signature != EGL_DISPLAY_SIGNATURE) ) { /* Bad display. */ thread->error = EGL_BAD_DISPLAY; gcmFOOTER_ARG("return=%d", EGL_FALSE); return EGL_FALSE; } if (num_config == gcvNULL) { /* Bad parameter. */ thread->error = EGL_BAD_PARAMETER; gcmFOOTER_ARG("return=%d", EGL_FALSE); return EGL_FALSE; } /* Parse attributes. */ if (!veglParseAttributes(dpy, attrib_list, &criteria)) { /* Bail out on invalid or non-matching attributes. */ gcmFOOTER_ARG("return=%d", EGL_FALSE); return EGL_FALSE; } /* Reference the EGLDisplay. */ if (!veglReferenceDisplay(thread, dpy)) { /* Not initialized. */ thread->error = EGL_NOT_INITIALIZED; gcmFOOTER_ARG("return=%d", EGL_FALSE); return EGL_FALSE; } /* Reset number of configurations. */ *num_config = 0; /* Walk through all configurations. */ for (config = 0; config < dpy->configCount; config++) { /* Get pointer to configuration. */ VEGLConfig configuration = &dpy->config[config]; gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, "%s: examining config index=%d", __FUNCTION__, config); if (criteria.configId != EGL_DONT_CARE) { if (!((criteria.configId == configuration->configId) || ((criteria.configId == 0) && configuration->defaultConfig))) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on config ID."); continue; } else { *num_config += 1; if (configs != gcvNULL) { /* Copy configuration into specified buffer. */ *configs = configuration; } break; } } /* Check configuration against criteria. */ if (criteria.bufferSize > configuration->bufferSize) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on buffer size."); continue; } if (criteria.alphaSize > configuration->alphaSize) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on alpha size."); continue; } if (criteria.blueSize > configuration->blueSize) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on blue size."); continue; } if (criteria.greenSize > configuration->greenSize) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on green size."); continue; } if (criteria.redSize > configuration->redSize) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on red size."); continue; } if (criteria.depthSize > configuration->depthSize) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on depth size."); continue; } if (criteria.stencilSize > configuration->stencilSize) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on stencil size."); continue; } if ((criteria.configCaveat != (EGLenum) EGL_DONT_CARE) && (criteria.configCaveat != configuration->configCaveat) ) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on config caveat."); continue; } if ((criteria.configId != EGL_DONT_CARE) && !((criteria.configId == configuration->configId) || ((criteria.configId == 0) && configuration->defaultConfig))) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on config ID."); continue; } if ((criteria.nativeRenderable != (EGLBoolean) EGL_DONT_CARE) && criteria.nativeRenderable && (criteria.nativeRenderable != configuration->nativeRenderable) ) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on native renderable."); continue; } if ((criteria.nativeVisualType != EGL_DONT_CARE) && (criteria.nativeVisualType != configuration->nativeVisualType)) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on native visual type."); continue; } if (criteria.samples > configuration->samples) { if ((criteria.samples == 1) && (configuration->samples == 0)) { /* Criterium still matches. */ } else { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on samples."); continue; } } if (criteria.sampleBuffers > configuration->sampleBuffers) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on sample buffers."); continue; } if ((criteria.surfaceType != (EGLenum) EGL_DONT_CARE) && !(criteria.surfaceType & configuration->surfaceType) ) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on surface type."); continue; } if ((criteria.bindToTetxureRGB != (EGLBoolean) EGL_DONT_CARE) && (criteria.bindToTetxureRGB != configuration->bindToTetxureRGB) ) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on bind to tetxure RGB."); continue; } if ((criteria.bindToTetxureRGBA != (EGLBoolean) EGL_DONT_CARE) && (criteria.bindToTetxureRGBA != configuration->bindToTetxureRGBA) ) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on bind to tetxure RGBA."); continue; } if (criteria.luminanceSize > configuration->luminanceSize) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on luminance size."); continue; } if (criteria.alphaMaskSize > configuration->alphaMaskSize) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on alpha mask size."); continue; } if ((criteria.colorBufferType != (EGLenum) EGL_DONT_CARE) && (criteria.colorBufferType != configuration->colorBufferType) ) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on color buffer type."); continue; } if ((criteria.renderableType != (EGLenum) EGL_DONT_CARE) && ((criteria.renderableType & configuration->renderableType) != criteria.renderableType) ) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on renderable type."); continue; } if ((criteria.conformant != (EGLenum) EGL_DONT_CARE) && (criteria.conformant != 0) && !(criteria.conformant & configuration->conformant) ) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on conformant."); continue; } if ((criteria.matchNativePixmap != EGL_DONT_CARE) && (criteria.matchNativePixmap != EGL_NONE) ) { EGLBoolean bMatch = EGL_TRUE; gctUINT width, height; gceSURF_FORMAT format = gcvSURF_UNKNOWN; gctUINT bitsPerPixel; if (!(configuration->surfaceType & EGL_PIXMAP_BIT) || !veglGetPixmapInfo(dpy->hdc, (NativePixmapType) gcmINT2PTR(criteria.matchNativePixmap), &width, &height, &bitsPerPixel, &format) ) { /* surface type of config is not EGL_PIXMAP_BIT or bad pixmap. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on match native pixmap."); continue; } switch (format) { case gcvSURF_R5G6B5: if ((configuration->redSize != 5) || (configuration->greenSize != 6) || (configuration->blueSize != 5) ) { bMatch = EGL_FALSE; } break; case gcvSURF_X8R8G8B8: if ((configuration->redSize != 8) || (configuration->greenSize != 8) || (configuration->blueSize != 8) || (configuration->alphaSize != 0) ) { bMatch = EGL_FALSE; } break; default: break; } if (!bMatch) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on match native pixmap."); continue; } } if ((criteria.matchFormat != (EGLenum) EGL_DONT_CARE) && (criteria.matchFormat != (EGLenum) EGL_NONE) ) { EGLBoolean bMatch = EGL_TRUE; switch(criteria.matchFormat) { case EGL_FORMAT_RGB_565_EXACT_KHR: if (configuration->matchFormat != EGL_FORMAT_RGB_565_EXACT_KHR) { bMatch = EGL_FALSE; } break; case EGL_FORMAT_RGB_565_KHR: if ((configuration->matchFormat != EGL_FORMAT_RGB_565_EXACT_KHR) && (configuration->matchFormat != EGL_FORMAT_RGB_565_KHR) ) { bMatch = EGL_FALSE; } break; case EGL_FORMAT_RGBA_8888_EXACT_KHR: if (configuration->matchFormat != EGL_FORMAT_RGBA_8888_EXACT_KHR) { bMatch = EGL_FALSE; } break; case EGL_FORMAT_RGBA_8888_KHR: if ((configuration->matchFormat != EGL_FORMAT_RGBA_8888_EXACT_KHR) && (configuration->matchFormat != EGL_FORMAT_RGBA_8888_KHR) ) { bMatch = EGL_FALSE; } break; default: break; } if (!bMatch) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on conformant."); continue; } } if ((criteria.recordableConfig != (EGLBoolean) EGL_DONT_CARE) && (criteria.recordableConfig != configuration->recordableConfig) ) { /* Criterium doesn't match. */ gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " rejected on recordable config."); continue; } gcmTRACE_ZONE(gcvLEVEL_INFO, gcdZONE_EGL_CONFIG, " accepted."); if (configs != gcvNULL) { /* Copy configuration into specified buffer. */ configs[*num_config] = configuration; } *num_config += 1; if (*num_config == config_size) { /* Bail out if the specified buffer is full. */ break; } } if ((*num_config > 1) && (configs != gcvNULL)) { /* Sort the matching configurations. */ veglSort((VEGLConfig *) configs, *num_config, &criteria); } /* Dereference the EGLDisplay. */ veglDereferenceDisplay(thread, dpy, EGL_FALSE); /* Success. */ thread->error = EGL_SUCCESS; gcmDUMP_API("${EGL eglChooseConfig 0x%08X (0x%08X) (0x%08X) 0x%08X " "(0x%08X)", Dpy, attrib_list, configs, config_size, num_config); gcmDUMP_API_ARRAY_TOKEN(attrib_list, EGL_NONE); gcmDUMP_API_ARRAY(configs, *num_config); gcmDUMP_API_ARRAY(num_config, 1); gcmDUMP_API("$}"); gcmFOOTER_ARG("*num_config=%d", *num_config); return EGL_TRUE; }
static gceSTATUS gcoBUFFER_GetCMDBUF( IN gcoBUFFER Buffer ) { gceSTATUS status; gcoCMDBUF command; gctSIZE_T index; gcePIPE_SELECT entryPipe; gcmHEADER_ARG("Buffer=0x%x", Buffer); /* Determine the next command buffer. */ if (Buffer->currentCommandBuffer == gcvNULL) { /* First time - get the first buffer. */ index = 0; /* Select 3D pipe for the first buffer. */ entryPipe = gcvPIPE_3D; } else { /* Get current entry pipe. */ entryPipe = Buffer->currentCommandBuffer->entryPipe; /* Determine the next command buffer index. */ index = (Buffer->currentCommandBufferIndex + 1) % Buffer->count; } /* Test if command buffer is available. */ status = gcoOS_WaitSignal(gcvNULL, Buffer->signal[index], 0); if (status == gcvSTATUS_TIMEOUT) { if (Buffer->count < gcdMAX_CMD_BUFFERS) { do { if (Buffer->commandBuffers[Buffer->count] == gcvNULL) { /* Construct a command buffer. */ gcmERR_BREAK(gcoCMDBUF_Construct( gcvNULL, gcvNULL, Buffer->maxSize, &Buffer->info, &Buffer->commandBuffers[Buffer->count])); } if (Buffer->signal[Buffer->count] == gcvNULL) { /* Create the signal. */ gcmERR_BREAK(gcoOS_CreateSignal( gcvNULL, gcvFALSE, &Buffer->signal[Buffer->count])); gcmTRACE_ZONE( gcvLEVEL_INFO, gcvZONE_SIGNAL, "%s(%d): buffer %d signal created 0x%08X", __FUNCTION__, __LINE__, Buffer->count, Buffer->signal[Buffer->count]); } /* Mark the buffer as available. */ gcmERR_BREAK(gcoOS_Signal(gcvNULL, Buffer->signal[Buffer->count], gcvTRUE)); /* Use the new buffer. */ index = Buffer->count; Buffer->count += 1; gcmTRACE_ZONE(gcvLEVEL_INFO, gcvZONE_BUFFER, "Using %lu command buffers.", Buffer->count); } while (gcvFALSE); } /* Wait for buffer to become available. */ gcmONERROR(gcoOS_WaitSignal(gcvNULL, Buffer->signal[index], gcPLS.hal->timeOut)); } else { gcmONERROR(status); } /* Select new command buffer. */ Buffer->currentCommandBufferIndex = index; Buffer->currentCommandBuffer = Buffer->commandBuffers[index]; /* Grab pointer to current command buffer. */ command = Buffer->currentCommandBuffer; /* Set the entry pipe. */ command->entryPipe = entryPipe; /* Reset command buffer. */ command->startOffset = 0; command->offset = Buffer->info.reservedHead; command->free = command->bytes - Buffer->totalReserved; /* Succees. */ gcmFOOTER_ARG("currentCommandBufferIndex=%d", Buffer->currentCommandBufferIndex); return gcvSTATUS_OK; OnError: /* Return the status. */ gcmFOOTER(); return status; }
gceSTATUS gcoOS_CreateWindow( IN HALNativeDisplayType Display, IN gctINT X, IN gctINT Y, IN gctINT Width, IN gctINT Height, OUT HALNativeWindowType * Window ) { gctINT pos[2]; gctINT size[2]; gctINT screen_format = SCREEN_FORMAT_RGBX8888; gctINT screen_transparency = SCREEN_TRANSPARENCY_NONE; gctINT screen_usage = SCREEN_USAGE_OPENGL_ES1 | SCREEN_USAGE_OPENGL_ES2 | SCREEN_USAGE_OPENVG ; /* Use 0 for no-vsync, and 1 for vsync limited. */ gctINT screen_swap_interval = 0; gctINT rc; gceSTATUS status = gcvSTATUS_OK; gcmHEADER_ARG("Display=0x%x X=%d Y=%d Width=%d Height=%d", Display, X, Y, Width, Height); /* Create window strcture. */ rc = screen_create_window((struct _screen_window **)Window, screen_ctx); if (rc) { fprintf(stderr, "screen_create_window failed with error %d (0x%08x)\n", errno, errno); status = gcvSTATUS_OUT_OF_RESOURCES; gcmFOOTER(); return status; } /* Set window pximap format. */ rc = screen_set_window_property_iv(*Window, SCREEN_PROPERTY_FORMAT, &screen_format); if (rc) { fprintf(stderr, "screen_set_window_property_iv(SCREEN_PROPERTY_FORMAT) failed with error %d (0x%08x)\n", errno, errno); screen_destroy_window(*Window); status = gcvSTATUS_OUT_OF_RESOURCES; gcmFOOTER(); return status; } /* Set window usage. */ rc = screen_set_window_property_iv(*Window, SCREEN_PROPERTY_USAGE, &screen_usage); if (rc) { fprintf(stderr, "screen_set_window_property_iv(SCREEN_PROPERTY_USAGE) failed with error %d (0x%08x)\n", errno, errno); screen_destroy_window(*Window); status = gcvSTATUS_OUT_OF_RESOURCES; gcmFOOTER(); return status; } /* Get fullscreen window size. */ rc = screen_get_window_property_iv(*Window, SCREEN_PROPERTY_SIZE, size); if (rc) { fprintf(stderr, "screen_get_window_property_iv(SCREEN_PROPERTY_SIZE) failed with error %d (0x%08x)\n", errno, errno); screen_destroy_window(*Window); status = gcvSTATUS_OUT_OF_RESOURCES; gcmFOOTER(); return status; } /* Disable transparency. Due to a bug in Screen, this must be set after format. */ rc = screen_set_window_property_iv(*Window, SCREEN_PROPERTY_TRANSPARENCY, &screen_transparency); if (rc) { fprintf(stderr, "screen_get_window_property_iv(SCREEN_PROPERTY_TRANSPARENCY) failed with error %d (0x%08x)\n", errno, errno); screen_destroy_window(*Window); status = gcvSTATUS_OUT_OF_RESOURCES; gcmFOOTER(); return status; } /* Set swap interval. */ rc = screen_set_window_property_iv(*Window, SCREEN_PROPERTY_SWAP_INTERVAL, &screen_swap_interval); if (rc) { fprintf(stderr, "screen_get_window_property_iv(SCREEN_PROPERTY_SWAP_INTERVAL) failed with error %d (0x%08x)\n", errno, errno); screen_destroy_window(*Window); status = gcvSTATUS_OUT_OF_RESOURCES; gcmFOOTER(); return status; } /* Test for zero width. */ if (Width == 0) { Width = size[0]; } /* Test for zero height. */ if (Height == 0) { Height = size[1]; } /* Test for auto-center X coordinate. */ if (X == -1) { X = (size[0] - Width) / 2; } /* Test for auto-center X coordinate. */ if (Y == -1) { Y = (size[1] - Height) / 2; } /* Resize the window. */ size[0] = Width; size[1] = Height; rc = screen_set_window_property_iv(*Window, SCREEN_PROPERTY_SIZE, size); if (rc) { fprintf(stderr, "screen_set_window_property_iv(SCREEN_PROPERTY_SIZE) failed with error %d (0x%08x)\n", errno, errno); screen_destroy_window(*Window); status = gcvSTATUS_OUT_OF_RESOURCES; gcmFOOTER(); return status; } /* Create window buffer. */ /* Second argument is the number of back buffers to be used. */ rc = screen_create_window_buffers(*Window, gcdDISPLAY_BACK_BUFFERS); if (rc) { fprintf(stderr, "screen_create_window_buffers failed with error %d (0x%08x)\n", errno, errno); screen_destroy_window(*Window); status = gcvSTATUS_OUT_OF_RESOURCES; gcmFOOTER(); return status; } /* Move window position. */ pos[0] = X; pos[1] = Y; rc = screen_set_window_property_iv(*Window, SCREEN_PROPERTY_POSITION, pos); if (rc) { fprintf(stderr, "screen_set_window_property_iv(SCREEN_PROPERTY_POSITION) failed with error %d (0x%08x)\n", errno, errno); screen_destroy_window(*Window); status = gcvSTATUS_OUT_OF_RESOURCES; gcmFOOTER(); return status; } gcmFOOTER_ARG("*Window=0x%x", *Window); return status; }
/******************************************************************************* ** ** gcoBUFFER_Construct ** ** Construct a new gcoBUFFER object. ** ** INPUT: ** ** gcoHAL Hal ** Pointer to a gcoHAL object. ** ** gcoHARDWARE Hardware ** Pointer to a gcoHARDWARE object. ** ** gckCONTEXT Context ** Pointer to a gckCONTEXT object. ** ** gctSIZE_T MaxSize ** Maximum size of buffer. ** ** OUTPUT: ** ** gcoBUFFER * Buffer ** Pointer to a variable that will hold the the gcoBUFFER object ** pointer. */ gceSTATUS gcoBUFFER_Construct( IN gcoHAL Hal, IN gcoHARDWARE Hardware, IN gckCONTEXT Context, IN gctSIZE_T MaxSize, OUT gcoBUFFER * Buffer ) { gceSTATUS status; gcoBUFFER buffer = gcvNULL; gctUINT i = 0; gctPOINTER pointer = gcvNULL; gcmHEADER_ARG("Hal=0x%x Hardware=0x%x Context=0x%x MaxSize=%lu", Hal, Hardware, Context, MaxSize); /* Verify the arguments. */ gcmVERIFY_OBJECT(Hal, gcvOBJ_HAL); gcmVERIFY_OBJECT(Hardware, gcvOBJ_HARDWARE); gcmDEBUG_VERIFY_ARGUMENT(Buffer != gcvNULL); /*************************************************************************** ** Allocate and reset the gcoBUFFER object. */ gcmONERROR(gcoOS_Allocate( gcvNULL, gcmSIZEOF(struct _gcoBUFFER), &pointer )); buffer = pointer; /* Initialize the gcoBUFFER object. */ buffer->object.type = gcvOBJ_BUFFER; buffer->hal = Hal; buffer->context = Context; /* Maximum size of buffer. */ buffer->size = 0; buffer->maxSize = MaxSize; /* Zero the command buffers. */ for (i = 0; i < gcmCOUNTOF(buffer->commandBuffers); ++i) { buffer->commandBuffers[i] = gcvNULL; buffer->signal[i] = gcvNULL; } /*************************************************************************** ** Query alignment. */ gcmONERROR(gcoHARDWARE_QueryCommandBuffer( &buffer->info.alignment, &buffer->info.reservedHead, &buffer->info.reservedTail )); buffer->totalReserved = buffer->info.reservedHead + buffer->info.reservedTail + buffer->info.alignment; /*************************************************************************** ** Initialize the command buffers. */ for (i = 0; i < gcdCMD_BUFFERS; ++i) { /* Construct a command buffer. */ gcmONERROR(gcoCMDBUF_Construct( gcvNULL, gcvNULL, buffer->maxSize, &buffer->info, &buffer->commandBuffers[i] )); /* Create the signal. */ gcmONERROR(gcoOS_CreateSignal( gcvNULL, gcvFALSE, &buffer->signal[i] )); gcmTRACE_ZONE( gcvLEVEL_INFO, gcvZONE_SIGNAL, "%s(%d): buffer %d signal created 0x%08X", __FUNCTION__, __LINE__, i, buffer->signal[i] ); /* Mark the buffer as available. */ gcmONERROR(gcoOS_Signal( gcvNULL, buffer->signal[i], gcvTRUE\ )); } /* Number of buffers initialized. */ buffer->count = gcdCMD_BUFFERS; /* Grab the first command buffer. */ buffer->currentCommandBuffer = gcvNULL; gcmONERROR(gcoBUFFER_GetCMDBUF(buffer)); /* Return pointer to the gcoBUFFER object. */ *Buffer = buffer; /* Success. */ gcmFOOTER_ARG("*Buffer=0x%x", *Buffer); return gcvSTATUS_OK; OnError: if (buffer != gcvNULL) { gcmVERIFY_OK(gcoBUFFER_FreeObjects(buffer)); } /* Return the status. */ gcmFOOTER(); return status; }
GLboolean glfQueryBufferState( glsCONTEXT_PTR Context, GLenum Name, GLvoid* Value, gleTYPE Type ) { GLboolean result = GL_TRUE; gcmHEADER_ARG("Context=0x%x Name=0x%04x Value=0x%x Type=0x%04x", Context, Name, Value, Type); switch (Name) { case GL_ARRAY_BUFFER_BINDING: glfGetFromInt( (Context->arrayBuffer == gcvNULL) ? 0 : Context->arrayBuffer->name, Value, Type ); break; case GL_ELEMENT_ARRAY_BUFFER_BINDING: glfGetFromInt( (Context->elementArrayBuffer == gcvNULL) ? 0 : Context->elementArrayBuffer->name, Value, Type ); break; case GL_VERTEX_ARRAY_BUFFER_BINDING: glfGetFromInt( (Context->aPositionInfo.buffer == gcvNULL) ? 0 : Context->aPositionInfo.buffer->name, Value, Type ); break; case GL_NORMAL_ARRAY_BUFFER_BINDING: glfGetFromInt( (Context->aNormalInfo.buffer == gcvNULL) ? 0 : Context->aNormalInfo.buffer->name, Value, Type ); break; case GL_COLOR_ARRAY_BUFFER_BINDING: glfGetFromInt( (Context->aColorInfo.buffer == gcvNULL) ? 0 : Context->aColorInfo.buffer->name, Value, Type ); break; case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING: { glsTEXTURESAMPLER_PTR sampler = Context->texture.activeClientSampler; glfGetFromInt( (sampler->aTexCoordInfo.buffer == gcvNULL) ? 0 : sampler->aTexCoordInfo.buffer->name, Value, Type ); } break; case GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES: glfGetFromInt( (Context->aPointSizeInfo.buffer == gcvNULL) ? 0 : Context->aPointSizeInfo.buffer->name, Value, Type ); break; case GL_MATRIX_INDEX_ARRAY_BUFFER_BINDING_OES: glfGetFromInt( (Context->aMatrixIndexInfo.buffer == gcvNULL) ? 0 : Context->aMatrixIndexInfo.buffer->name, Value, Type ); break; case GL_WEIGHT_ARRAY_BUFFER_BINDING_OES: glfGetFromInt( (Context->aWeightInfo.buffer == gcvNULL) ? 0 : Context->aWeightInfo.buffer->name, Value, Type ); break; default: result = GL_FALSE; } gcmFOOTER_ARG("return=%d", result); /* Return result. */ return result; }