NTSTATUS HookModuleInit(PDRIVER_OBJECT DriverObject, PVOID Context) { NTSTATUS status = STATUS_UNSUCCESSFUL; DEBUG_ENTER_FUNCTION("DriverObject=0x%p; Context=0x%p", DriverObject, Context); UNREFERENCED_PARAMETER(DriverObject); UNREFERENCED_PARAMETER(Context); KeInitializeSpinLock(&_driverValidationTableLock); status = HashTableCreate(httNoSynchronization, 37, _HashFunction, _DriverValidationCompareFunction, NULL, &_driverValidationTable); if (NT_SUCCESS(status)) { KeInitializeSpinLock(&_deviceValidationTableLock); status = HashTableCreate(httNoSynchronization, 37, _HashFunction, _DeviceValidationCompareFunction, NULL, &_deviceValidationTable); if (NT_SUCCESS(status)) { KeInitializeSpinLock(&_driverTableLock); status = HashTableCreate(httNoSynchronization, 37, _HashFunction, _DriverCompareFunction, _DriverFreeFunction, &_driverTable); if (!NT_SUCCESS(status)) HashTableDestroy(_deviceValidationTable); } if (!NT_SUCCESS(status)) HashTableDestroy(_driverValidationTable); } DEBUG_EXIT_FUNCTION("0x%x", status); return status; }
VOID HookModuleFinit(PDRIVER_OBJECT DriverObject, PVOID Context) { LARGE_INTEGER time; DEBUG_ENTER_FUNCTION("DriverObject=0x%p; Context=0x%p", DriverObject, Context); HashTableDestroy(_deviceValidationTable); HashTableDestroy(_driverValidationTable); HashTableDestroy(_driverTable); time.QuadPart = -50000000; (VOID) KeDelayExecutionThread(KernelMode, FALSE, &time); DEBUG_EXIT_FUNCTION_VOID(); return; }
VOID GnttabTeardown( IN PXENBUS_GNTTAB_CONTEXT Context ) { Trace("====>\n"); Context->Fdo = NULL; HashTableDestroy(Context->MapTable); Context->MapTable = NULL; RtlZeroMemory(&Context->Lock, sizeof (KSPIN_LOCK)); RtlZeroMemory(&Context->List, sizeof (LIST_ENTRY)); RtlZeroMemory(&Context->DebugInterface, sizeof (XENBUS_DEBUG_INTERFACE)); RtlZeroMemory(&Context->SuspendInterface, sizeof (XENBUS_SUSPEND_INTERFACE)); RtlZeroMemory(&Context->CacheInterface, sizeof (XENBUS_CACHE_INTERFACE)); RtlZeroMemory(&Context->RangeSetInterface, sizeof (XENBUS_RANGE_SET_INTERFACE)); ASSERT(IsZeroMemory(Context, sizeof (XENBUS_GNTTAB_CONTEXT))); __GnttabFree(Context); Trace("<====\n"); }
void DigestCacheDestroy(DigestCache* self) { HashTableDestroy(&self->m_Table); MmapFileDestroy(&self->m_StateFile); LinearAllocDestroy(&self->m_Allocator); HeapDestroy(&self->m_Heap); ReadWriteLockDestroy(&self->m_Lock); }
/* * Removes some or all tags from some or all contigs. * If the contig list or tag list is blank it implies all contigs or all tags. * * Returns 0 on success * -1 on failure */ int delete_tags(GapIO *io, int ncontigs, contig_list_t *contigs, char *tag_list, int verbose) { HashTable *h = NULL; int ret = 0; /* Hash tag types */ if (tag_list && *tag_list) { int i; if (SetActiveTags(tag_list) == -1) { return -1; } h = HashTableCreate(32, 0); for (i = 0; i < number_of_active_tags; i++) { HashData hd; hd.i = 0; HashTableAdd(h, active_tag_types[i], 4, hd, NULL); } } /* Iterate over contig list or all contigs */ if (verbose) vfuncheader("Delete Tags"); if (ncontigs) { int i; for (i = 0; i < ncontigs; i++) { contig_t *c = cache_search(io, GT_Contig, contigs[i].contig); vmessage("Scanning contig %d of %d (%s)\n", i+1, ncontigs, c->name); ret |= delete_tag_single_contig(io, contigs[i].contig, h, verbose); UpdateTextOutput(); cache_flush(io); } } else { int i; tg_rec *order = ArrayBase(tg_rec, io->contig_order); for (i = 0; i < NumContigs(io); i++) { contig_t *c = cache_search(io, GT_Contig, order[i]); vmessage("Scanning contig %d of %d (%s)\n", i+1, NumContigs(io), c->name); ret |= delete_tag_single_contig(io, order[i], h, verbose); UpdateTextOutput(); cache_flush(io); } } SetActiveTags(""); if (h) HashTableDestroy(h, 0); return ret; }
static VOID _DriverHookRecordFree(PDRIVER_HOOK_RECORD Record) { DEBUG_ENTER_FUNCTION("Record=0x%p", Record); HashTableDestroy(Record->SelectedDevices); HeapMemoryFree(Record->DriverName.Buffer); HeapMemoryFree(Record); DEBUG_EXIT_FUNCTION_VOID(); return; }
void LuaProfilerDestroy() { LuaProfilerState* self = &s_Profiler; lua_sethook(self->m_LuaState, nullptr, 0, 0); MemAllocHeap* heap = self->m_Heap; HeapFree(heap, self->m_InvocationTable); HashTableDestroy(&self->m_Functions); }
void free_values_destroy(HashTable * tab) { KeyValuePair * cursor; int bucket; for(bucket=0; bucket< tab -> numOfBuckets; bucket++) { cursor = tab -> bucketArray[bucket]; while (1) { if(!cursor) break; char * read_txt = (char *) cursor ->value; free(read_txt); cursor = cursor->next; } } HashTableDestroy(tab); }
VOID HandleTableDestroy(PCHANDLE_TABLE HandleTable) { DEBUG_ENTER_FUNCTION("HandleTable=0x%p", HandleTable); HashTableDestroy(HandleTable->HashTable); switch (HandleTable->HandleTableType) { case httPassiveLevel: ExDeleteResourceLite(&HandleTable->LockP); break; case httDispatchLevel: break; case httNoSynchronization: break; default: break; } HeapMemoryFree(HandleTable); DEBUG_EXIT_FUNCTION_VOID(); return; }
/* * free results structure */ void chksum_free_results(chksum_results_t *results) { HashTableDestroy(results->rgHash, 1); free(results); }
int transfer_SAM_to_position_table(char * sam_file) { char linebuf[max(2*MAX_READ_LENGTH+300,3000)]; int allreads=0,mapped=0; char mate_chro[MAX_CHROMOSOME_NAME_LEN+1]; unsigned int mate_pos; int flags_mate; char cigar_mate[EXON_MAX_CIGAR_LEN+1]; gene_input_t input_file; HashTable * local_reassembly_pileup_files; HashTable * chromosome_size_table; chromosome_size_table = HashTableCreate(100); HashTableSetDeallocationFunctions(chromosome_size_table, NULL, NULL); HashTableSetKeyComparisonFunction(chromosome_size_table, my_strcmp); HashTableSetHashFunction(chromosome_size_table, HashTableStringHashFunction); local_reassembly_pileup_files = HashTableCreate(100); HashTableSetDeallocationFunctions(local_reassembly_pileup_files, NULL, NULL); HashTableSetKeyComparisonFunction(local_reassembly_pileup_files, my_strcmp); HashTableSetHashFunction(local_reassembly_pileup_files ,HashTableStringHashFunction); geinput_open_sam(sam_file, &input_file,0); while(1) { unsigned int read_pos =0xffffffff; char read_name[MAX_READ_NAME_LEN+1]; int flags; char chro_name[MAX_CHROMOSOME_NAME_LEN+1]; unsigned int pos, pair_dist; char cigar[EXON_MAX_CIGAR_LEN+1]; char read_text[MAX_READ_LENGTH+1]; char qual_text[MAX_READ_LENGTH+1]; int read_len, is_repeated, mapping_quality, is_anchor_certain=1; int pos_delta = 0; int is_paired_end_reads = 0; unsigned long long int file_offset = ftello(input_file.input_fp); if(feof(input_file.input_fp))break; read_text[0]=0; qual_text[0]=0; geinput_readline(&input_file, linebuf,0); int res = parse_SAM_line(linebuf, read_name,& flags, chro_name, & pos, cigar, & mapping_quality, & pair_dist, read_text , qual_text, & read_len, & is_repeated); int cigar_cursor = 0; int firstM = 1,xx=0; is_paired_end_reads = flags &1; if(res==0) { for(; cigar[cigar_cursor]; cigar_cursor++) { char nch = cigar[cigar_cursor]; if(nch>='0'&&nch<='9') { xx=xx*10+(nch-'0'); }else { if(nch=='M') firstM=0; else if(nch=='S') { if(firstM) pos_delta = xx; } xx=0; } } pos -= pos_delta; } if(res == 1) {chro_name[0]='*'; chro_name[1]=0;} //printf("MAPPED=%d\n", res); if(res == 0) // mapped { read_pos = pos - 1; mapped++; } else if(res == 1 && is_paired_end_reads) // unmapped { is_anchor_certain=0; if(mate_chro[0]) { if(mate_chro[0]!='*') { read_pos = mate_pos ; strcpy(chro_name, mate_chro); } //printf("RECOVERED 1: %u - %s ; LEN=%d ; YOU_ARE_FIRST=%d\n%s\n%s\n", read_anchor_position, read_name, read_len, flags_mate & SAM_FLAG_FIRST_READ_IN_PAIR, read_text, qual_text); } else { char read_text_null[MAX_READ_LENGTH+1]; char qual_text_null[MAX_READ_LENGTH+1]; geinput_readline_back(&input_file, linebuf); res = parse_SAM_line(linebuf, read_name,& flags_mate, mate_chro, & mate_pos, cigar_mate, & mapping_quality, & pair_dist, read_text_null , qual_text_null, & read_len, & is_repeated); if(res==0) { read_pos = mate_pos - 1; strcpy(chro_name, mate_chro); } //printf("RECOVERED 2: %u - %s ; LEN=%d ; YOU_ARE_FIRST=%d\n%s\n%s\n", read_anchor_position, read_name, read_len, flags_mate & SAM_FLAG_FIRST_READ_IN_PAIR, read_text, qual_text); } } if(read_pos<0xffff0000) { unsigned int read_span = calculate_read_span(cigar); write_read_pos(chro_name, read_pos, read_len, flags, file_offset, cigar, read_span, local_reassembly_pileup_files); unsigned int old_max_pos = HashTableGet(chromosome_size_table, chro_name) - NULL; if(old_max_pos==0) { char * chro_name_new = malloc(strlen(chro_name)+1); strcpy(chro_name_new , chro_name); HashTablePut(chromosome_size_table, chro_name_new, NULL+read_pos + read_span+1); } else if(read_pos + read_span +1 > old_max_pos ) HashTablePutReplace(chromosome_size_table, chro_name, NULL+read_pos + read_span+1, 0); } if(allreads %2==1) mate_chro[0] = 0; else { strcpy(mate_chro, chro_name); mate_pos = pos - 1; flags_mate = flags; } allreads++; } SUBREADprintf("Processed %d reads; %d mapped.\n", allreads, mapped); destroy_pileup_table(local_reassembly_pileup_files); finalise_sam_index(chromosome_size_table, sam_file); HashTableDestroy(chromosome_size_table); return 0; }
int handle_http_propfind(http_req * req, http_rsp * rsp) { int ret = OK; HashElement * e = NULL; int depth = -1; HashHandle props = NULL_HANDLE; CacheHandle cache = NULL_HANDLE; char * propxml = NULL; int contentlen = 0; char * vpath = req->uri; struct stat buf; WEBLOG_API(); #ifdef WEBCFG_SUPPORT_AUTH /* Authentication has a very high priority. */ if (OK != CheckAuthorization(req, rsp)) { return handle_http_error(401, req, rsp); } #endif if(OK != Webdav_CheckPath(req->uri)) { WEBLOG_ERROR("<%s> PROPFIND is not allowed for non-webdav path [%s].\n", __FUNCTION__, req->uri); handle_http_error(403, req, rsp); ret = NG; goto __error_out; } if(0 == strlen(vpath)) { strcat(vpath, "/"); WEBLOG_VERBOSE("<%s> redirect to root path. [%s].\n", __FUNCTION__, vpath); } WEBLOG_INFO("<%s> stat the file \"%s\".\n", __FUNCTION__, vpath); ret = stat(vpath, &buf); /* Check if statistics are valid: */ if(ret != 0) { WEBLOG_ERROR("<%s> fail to stat the file \"%s\".\n", __FUNCTION__, vpath); switch (errno) { case ENOENT: WEBLOG_ERROR("<%s> File %s not found.\n", __FUNCTION__, vpath); handle_http_error(404, req, rsp); ret = NG; goto __error_out; case EINVAL: /* no break */ default: /* Should never be reached. */ WEBLOG_ERROR("<%s> Unexpected error in _stat.\n", __FUNCTION__); handle_http_error(500, req, rsp); ret = NG; goto __error_out; } } props = HashTableCreate(64); ASSERT(props != NULL_HANDLE); /* get depth. */ e = HashLookup(req->headOptions, "Depth"); if(!e) depth = -1; else if(e->value.data.string[0] == '0') depth = 0; else if(e->value.data.string[0] == '1') depth = 1; else depth = -1; if(depth == -1 && TRUE == Webdav_isFolder(vpath)) { WEBLOG_ERROR("<%s> PROPFIND a collection with infinite depth is not allowed.\n", __FUNCTION__); handle_http_error(403, req, rsp); ret = NG; goto __error_out; } #ifdef WEBCFG_MINIMIZE_SERVER #else e = HashLookup(req->headOptions, "Content-Type"); if(e && strstr(e->value.data.string, "xml")) { char * xmlsockbuf = NULL; char strbuf[128] = {0}; char *end, *p, *q; HashValue eeee = HashString("", FALSE); // empty value! WEBLOG_INFO("<%s> Client request props in a xml body.\n", __FUNCTION__); e = HashLookup(req->headOptions, "Content-Length"); if(!e) { /* RFC2616, 14.23. */ WEBLOG_ERROR("<%s> Missing \"Content-Length\" for xml body.\n", __FUNCTION__); handle_http_error(400, req, rsp); ret = NG; goto __error_out; } contentlen = atoi(e->value.data.string); xmlsockbuf = (char *)webmalloc(contentlen+1); memset(xmlsockbuf, 0, contentlen+1); if(req->datalen > 0) // data left in head buffer. { memcpy(xmlsockbuf, req->sockbuf, req->datalen); WEBLOG_VERBOSE("<%s> previous buffered %d/%d bytes consumed.\n", __FUNCTION__, req->datalen, contentlen); } /* if there's more data in socket.... */ if (req->datalen < contentlen) { /* read rest of data from socket. */ p = xmlsockbuf + req->datalen; req->datalen = recv(req->sock, p, contentlen-req->datalen, 0); WEBLOG_VERBOSE("<%s> %d/%d bytes read from socket.\n", __FUNCTION__, req->datalen, contentlen); dumpText(xmlsockbuf, contentlen); } p = strstr(xmlsockbuf, "<prop>") + 6; end = strstr(xmlsockbuf, "</prop>"); if(strstr(xmlsockbuf, "<allprop/>")) { WEBLOG_INFO("<%s> client request all props.\n", __FUNCTION__); } else { ASSERT(p<end); *end = '\0'; /* good for str api. */ /* Possible Value: WinXP: <propname/> Cadaver: <propname xmlns="DAV:"/> */ do { p = strchr(p, '<'); if(!p) break; else p++; q = strstr(p, "/>"); ASSERT(q && (q-p < sizeof(strbuf))); strncpy(strbuf, p, q-p); p = strchr(strbuf, ' '); if(p) *p = '\0'; p = strtrim(strbuf); WEBLOG_INFO("<%s> client request prop: <%s>\n", __FUNCTION__, p); HashAdd(props, p, eeee); p = q + 2; } while(p<end); /* <xxx/>\r\n</prop> */ } } #endif cache = CacheCreate(); Webdav_Props(props, cache, vpath, depth); contentlen = CacheGetData(cache, &propxml); ASSERT(propxml); dumpText(propxml, contentlen); WEBLOG_INFO("<%s> response xml ready. len %d.\n", __FUNCTION__, contentlen); rsp->code = 207; rsp->body = propxml; http_add_rspoption(rsp, "Content-Type", "text/xml"); http_send_response(rsp); __error_out: if (props != NULL_HANDLE) HashTableDestroy(props); if (cache != NULL_HANDLE) CacheDestroy(cache); return ret; }
/*********************************************************************************** Function Name : DeInitContext Inputs : gc Outputs : Returns : Description : Destroys the given context. ************************************************************************************/ static IMG_BOOL DeInitContext(GLES2Context *gc) { IMG_UINT32 i; IMG_BOOL bPass = IMG_TRUE; if(!gc->psSharedState) { /* If there's no shared state then the rest of the context hasn't been initialised */ return IMG_TRUE; } #if defined(DEBUG) if(gc->pShaderAnalysisHandle) fclose(gc->pShaderAnalysisHandle); #endif /* Free vao state */ FreeVertexArrayObjectState(gc); /* Wait all the VAO attached resources */ KRM_WaitForAllResources(&gc->sVAOKRM, GLES2_DEFAULT_WAIT_RETRIES); #if defined(GLES2_EXTENSION_VERTEX_ARRAY_OBJECT) /* Destroy all the unshareable resources: currently only VAO attached resources */ for (i = 0; i < GLES2_MAX_UNSHAREABLE_NAMETYPE; i++) { if(gc->apsNamesArray[i]) { DestroyNamesArray(gc, gc->apsNamesArray[i]); } } #endif /* defined(GLES2_EXTENSION_VERTEX_ARRAY_OBJECT) */ /* Destroy the TA kick VAO manager, this must be after Destroy unshareable name arrays (vao name array in this case) */ KRM_Destroy(gc, &gc->sVAOKRM); HashTableDestroy(gc, &gc->sProgram.sPDSFragmentVariantHashTable); if(!FreeTextureState(gc)) { PVR_DPF((PVR_DBG_ERROR,"DeInitContext: FreeTextureState failed")); bPass = IMG_FALSE; } FreeProgramState(gc); FreeBufObjState(gc); /* FrameBuffers must be freed _after_ freeing textures due to FBOs. See FreeTexture() */ FreeFrameBufferState(gc); FreeContextSharedState(gc); /* TexStreamsState must be freed after freeing all the default and named textures, which might refer to stream buffer devices */ #if defined(GLES2_EXTENSION_TEXTURE_STREAM) if(FreeTexStreamState(gc) != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR,"DeInitContext: FreeTexStreamState failed")); bPass = IMG_FALSE; } #endif GLES2FREEDEVICEMEM(gc->ps3DDevData, gc->sKRMTAStatusUpdate.psMemInfo); #if defined(FIX_HW_BRN_26922) FreeBRN26922Mem(gc); #endif /* defined(FIX_HW_BRN_26922) */ #if defined (TIMING) || defined (DEBUG) OutputMetrics(gc); #endif for(i=0; i < CBUF_NUM_TA_BUFFERS; i++) { if(gc->apsBuffers[i]) { CBUF_DestroyBuffer(gc->ps3DDevData, gc->apsBuffers[i]); } } /* The UniPatch context must be freed _after_ the shared state is freed because the latter may try to free shaders and that requires a working UniPatch context. */ PVRUniPatchDestroyContext(gc->sProgram.pvUniPatchContext); gc->sProgram.pvUniPatchContext = IMG_NULL; return bPass; }
/*********************************************************************************** Function Name : InitContext Inputs : gc, psShareContext, psMode Outputs : - Returns : Success Description : Initialises a context - may setup shared name tables from a sharecontext. Also sets up default framebuffer ************************************************************************************/ static IMG_BOOL InitContext(GLES2Context *gc, GLES2Context *psShareContext, EGLcontextMode *psMode) { #if defined(GLES2_EXTENSION_VERTEX_ARRAY_OBJECT) GLES2NameType aeNameType[GLES2_MAX_UNSHAREABLE_NAMETYPE] = { GLES2_NAMETYPE_VERARROBJ }; #endif /* defined(GLES2_EXTENSION_VERTEX_ARRAY_OBJECT) */ IMG_UINT32 i, j; GLES_ASSERT(gc); GetApplicationHints(&gc->sAppHints, psMode); #if defined(FIX_HW_BRN_26922) if(!AllocateBRN26922Mem(gc)) { PVR_DPF((PVR_DBG_ERROR,"InitContext: AllocateBRN26922Mem failed")); goto FAILED_AllocateBRN26922Mem; } #endif /* defined(FIX_HW_BRN_26922) */ if(!CreateSharedState(gc, psShareContext)) { PVR_DPF((PVR_DBG_ERROR,"InitContext: CreateSharedState failed")); goto FAILED_CreateSharedState; } #if defined(GLES2_EXTENSION_VERTEX_ARRAY_OBJECT) /* Initialize the unshareable names arrays */ for (i = 0; i < GLES2_MAX_UNSHAREABLE_NAMETYPE; i++) { gc->apsNamesArray[i] = CreateNamesArray(gc, aeNameType[i], (PVRSRV_MUTEX_HANDLE)0); if(!gc->apsNamesArray[i]) { PVR_DPF((PVR_DBG_ERROR,"InitContext: Couldn't create unshareable names array %d", i)); DestroyNamesArray(gc, gc->apsNamesArray[i]); return IMG_FALSE; } } #endif /* defined(GLES2_EXTENSION_VERTEX_ARRAY_OBJECT) */ if(GLES2ALLOCDEVICEMEM(gc->ps3DDevData, gc->psSysContext->hSyncInfoHeap, PVRSRV_MEM_WRITE | PVRSRV_MEM_READ | PVRSRV_MEM_NO_SYNCOBJ | PVRSRV_MEM_CACHE_CONSISTENT, 4, 0, &gc->sKRMTAStatusUpdate.psMemInfo) != PVRSRV_OK) { PVR_DPF((PVR_DBG_ERROR, "InitContext: Failed to create TA sync object")); goto FAILED_TASync; } gc->sKRMTAStatusUpdate.ui32StatusValue = 1; PVRSRVMemSet(gc->sKRMTAStatusUpdate.psMemInfo->pvLinAddr, 0, 4); if(!HashTableCreate(gc, &gc->sProgram.sPDSFragmentVariantHashTable, STATEHASH_LOG2TABLESIZE, STATEHASH_MAXNUMENTRIES, DestroyHashedPDSVariant)) { PVR_DPF((PVR_DBG_ERROR,"InitContext: HashTableCreate failed")); goto FAILED_CreateHashTable; } if(!CreateTextureState(gc)) { PVR_DPF((PVR_DBG_ERROR,"InitContext: CreateTextureState failed")); goto FAILED_CreateTextureState; } if(!CreateProgramState(gc)) { PVR_DPF((PVR_DBG_ERROR,"InitContext: CreateProgramState failed")); goto FAILED_CreateProgramState; } if(!CreateBufObjState(gc)) { PVR_DPF((PVR_DBG_ERROR,"InitContext: CreateBufObjState failed")); goto FAILED_CreateBufObjState; } if(!CreateFrameBufferState(gc, psMode)) { PVR_DPF((PVR_DBG_ERROR,"InitContext: CreateRenderBufferState failed")); goto FAILED_CreateFrameBufferState; } if(!CreateVertexArrayObjectState(gc)) { PVR_DPF((PVR_DBG_ERROR,"InitContext: CreateVertexArrayObjectState failed")); goto FAILED_CreateVertexArrayObjectState; } /* Initialise the TA kick VAO manager */ if(!KRM_Initialize(&gc->sVAOKRM, KRM_TYPE_TA, IMG_FALSE, 0, /* PVRSRV_MUTEX_HANDLE */ gc->ps3DDevData, gc->psSysContext->sHWInfo.sMiscInfo.hOSGlobalEvent, ReclaimVAOMemKRM, IMG_TRUE, DestroyVAOGhostKRM)) { PVR_DPF((PVR_DBG_ERROR,"InitContext: Couldn't initialise the TA kick VAO manager")); goto FAILED_CreateVertexArrayObjectState; } if(!InitSpecialUSECodeBlocks(gc)) { PVR_DPF((PVR_DBG_ERROR,"InitContext: InitSpecialUSECodeBlocks failed")); goto FAILED_InitSpecialUSECodeBlocks; } gc->sState.sRaster.ui32ColorMask = GLES2_COLORMASK_ALL; gc->sState.sRaster.sClearColor.fRed = GLES2_Zero; gc->sState.sRaster.sClearColor.fGreen = GLES2_Zero; gc->sState.sRaster.sClearColor.fBlue = GLES2_Zero; gc->sState.sRaster.sClearColor.fAlpha = GLES2_Zero; gc->sState.sRaster.ui32BlendFactor = ((GLES2_BLENDFACTOR_ONE << GLES2_BLENDFACTOR_RGBSRC_SHIFT) | (GLES2_BLENDFACTOR_ONE << GLES2_BLENDFACTOR_ALPHASRC_SHIFT) | (GLES2_BLENDFACTOR_ZERO << GLES2_BLENDFACTOR_RGBDST_SHIFT) | (GLES2_BLENDFACTOR_ZERO << GLES2_BLENDFACTOR_ALPHADST_SHIFT)); gc->sState.sRaster.ui32BlendEquation = (GLES2_BLENDFUNC_ADD << GLES2_BLENDFUNC_RGB_SHIFT) | (GLES2_BLENDFUNC_ADD << GLES2_BLENDFUNC_ALPHA_SHIFT); gc->sState.sRaster.sBlendColor.fRed = GLES2_Zero; gc->sState.sRaster.sBlendColor.fGreen = GLES2_Zero; gc->sState.sRaster.sBlendColor.fBlue = GLES2_Zero; gc->sState.sRaster.sBlendColor.fAlpha = GLES2_Zero; gc->sState.sLine.fWidth = GLES2_One; gc->sState.sPolygon.eCullMode = GL_BACK; gc->sState.sPolygon.eFrontFaceDirection = GL_CCW; gc->sState.sPolygon.factor.fVal = GLES2_Zero; gc->sState.sPolygon.fUnits = GLES2_Zero; gc->sState.sStencil.ui32FFStencil = EURASIA_ISPC_SCMP_ALWAYS | EURASIA_ISPC_SOP1_KEEP | EURASIA_ISPC_SOP2_KEEP | EURASIA_ISPC_SOP3_KEEP | (GLES2_MAX_STENCIL_VALUE << EURASIA_ISPC_SCMPMASK_SHIFT) | (GLES2_MAX_STENCIL_VALUE << EURASIA_ISPC_SWMASK_SHIFT); gc->sState.sStencil.ui32BFStencil = EURASIA_ISPC_SCMP_ALWAYS | EURASIA_ISPC_SOP1_KEEP | EURASIA_ISPC_SOP2_KEEP | EURASIA_ISPC_SOP3_KEEP | (GLES2_MAX_STENCIL_VALUE << EURASIA_ISPC_SCMPMASK_SHIFT) | (GLES2_MAX_STENCIL_VALUE << EURASIA_ISPC_SWMASK_SHIFT); gc->sState.sStencil.ui32FFStencilRef = (0 << EURASIA_ISPA_SREF_SHIFT); gc->sState.sStencil.ui32BFStencilRef = (0 << EURASIA_ISPA_SREF_SHIFT); gc->sState.sStencil.ui32Clear = 0; gc->sState.sStencil.ui32FFStencilCompareMaskIn = GLES2_MAX_STENCIL_VALUE; gc->sState.sStencil.ui32BFStencilCompareMaskIn = GLES2_MAX_STENCIL_VALUE; gc->sState.sStencil.ui32FFStencilWriteMaskIn = GLES2_MAX_STENCIL_VALUE; gc->sState.sStencil.ui32BFStencilWriteMaskIn = GLES2_MAX_STENCIL_VALUE; gc->sState.sStencil.i32FFStencilRefIn = 0; gc->sState.sStencil.i32BFStencilRefIn = 0; gc->sState.sStencil.ui32MaxFBOStencilVal = GLES2_MAX_STENCIL_VALUE; gc->sState.sMultisample.bSampleCoverageInvert = IMG_FALSE; gc->sState.sMultisample.fSampleCoverageValue = GLES2_One; gc->sState.sDepth.ui32TestFunc = EURASIA_ISPA_DCMPMODE_LT; gc->sState.sDepth.fClear = GLES2_One; gc->ui32Enables = GLES2_DITHER_ENABLE; gc->sState.sClientPixel.ui32UnpackAlignment = 4; gc->sState.sClientPixel.ui32PackAlignment = 4; gc->ui32DirtyState = GLES2_DIRTYFLAG_ALL; gc->ui32EmitMask = GLES2_EMITSTATE_ALL; /* * Set up attrib array default values */ for (i=0; i < GLES2_MAX_VERTEX_ATTRIBS; ++i) { GLES2AttribArrayPointerState *psAPState = &(gc->sVAOMachine.sDefaultVAO.asVAOState[AP_VERTEX_ATTRIB0 + i]); psAPState->ui32StreamTypeSize = GLES2_STREAMTYPE_FLOAT | (4 << GLES2_STREAMSIZE_SHIFT); gc->sVAOMachine.asAttribPointer[AP_VERTEX_ATTRIB0 + i].psState = psAPState; gc->sVAOMachine.asAttribPointer[AP_VERTEX_ATTRIB0 + i].ui32Size = 16; gc->sVAOMachine.asAttribPointer[AP_VERTEX_ATTRIB0 + i].ui32Stride = 16; gc->sVAOMachine.asCurrentAttrib[AP_VERTEX_ATTRIB0 + i].fX = GLES2_Zero; gc->sVAOMachine.asCurrentAttrib[AP_VERTEX_ATTRIB0 + i].fY = GLES2_Zero; gc->sVAOMachine.asCurrentAttrib[AP_VERTEX_ATTRIB0 + i].fZ = GLES2_Zero; gc->sVAOMachine.asCurrentAttrib[AP_VERTEX_ATTRIB0 + i].fW = GLES2_One; } for(i=0; i < GLES2_HINT_NUMHINTS; i++) { gc->sState.sHints.eHint[i] = GL_DONT_CARE; } j = 0; for(i=0; i < CBUF_NUM_TA_BUFFERS; i++) { IMG_UINT32 ui32Size; IMG_HANDLE hMemHeap; switch(i) { case CBUF_TYPE_PDS_VERT_BUFFER: { hMemHeap = gc->psSysContext->hPDSVertexHeap; ui32Size = gc->sAppHints.ui32DefaultPDSVertBufferSize; break; } case CBUF_TYPE_VERTEX_DATA_BUFFER: { hMemHeap = gc->psSysContext->hGeneralHeap; ui32Size = gc->sAppHints.ui32DefaultVertexBufferSize; break; } case CBUF_TYPE_INDEX_DATA_BUFFER: { hMemHeap = gc->psSysContext->hGeneralHeap; ui32Size = gc->sAppHints.ui32DefaultIndexBufferSize; break; } case CBUF_TYPE_VDM_CTRL_BUFFER: { hMemHeap = gc->psSysContext->hGeneralHeap; ui32Size = gc->sAppHints.ui32DefaultVDMBufferSize; break; } case CBUF_TYPE_PDS_VERT_SECONDARY_PREGEN_BUFFER: { PVR_DPF((PVR_DBG_MESSAGE,"InitContext: ignoring buffer type CBUF_TYPE_PDS_VERT_SECONDARY_PREGEN_BUFFER")); hMemHeap = gc->psSysContext->hPDSVertexHeap; ui32Size = 4; break; } case CBUF_TYPE_MTE_COPY_PREGEN_BUFFER: { hMemHeap = gc->psSysContext->hPDSVertexHeap; if(gc->sAppHints.bEnableStaticMTECopy) { ui32Size = ((gc->sAppHints.ui32DefaultPregenMTECopyBufferSize / GLES2_ALIGNED_MTE_COPY_PROG_SIZE) * GLES2_ALIGNED_MTE_COPY_PROG_SIZE); } else { PVR_DPF((PVR_DBG_WARNING,"InitContext: ignoring buffer type CBUF_TYPE_MTE_COPY_PREGEN_BUFFER")); ui32Size = 4; } break; } case CBUF_TYPE_PDS_AUXILIARY_PREGEN_BUFFER: { /* Unused */ gc->apsBuffers[i] = IMG_NULL; continue; } default: { PVR_DPF((PVR_DBG_ERROR,"InitContext: Invalid buffer type")); goto FAILED_CBUF_CreateBuffer; } } gc->apsBuffers[i] = CBUF_CreateBuffer(gc->ps3DDevData, i, hMemHeap, gc->psSysContext->hSyncInfoHeap, gc->psSysContext->sHWInfo.sMiscInfo.hOSGlobalEvent, ui32Size); if(!gc->apsBuffers[i]) { PVR_DPF((PVR_DBG_ERROR,"InitContext: Failed to create buffer %u",i)); goto FAILED_CBUF_CreateBuffer; } /* Point the TA Kick status update to the device memory reserved for status updates in the buffer */ gc->sKickTA.asTAStatusUpdate[j].hKernelMemInfo = gc->apsBuffers[i]->psStatusUpdateMemInfo->hKernelMemInfo; gc->sKickTA.asTAStatusUpdate[j].sCtlStatus.sStatusDevAddr.uiAddr = gc->apsBuffers[i]->psStatusUpdateMemInfo->sDevVAddr.uiAddr; /* set the read offset pointer in the buffer */ gc->apsBuffers[i]->pui32ReadOffset = (IMG_UINT32*)gc->apsBuffers[i]->psStatusUpdateMemInfo->pvLinAddr; j++; if(i == CBUF_TYPE_MTE_COPY_PREGEN_BUFFER) { if(gc->sAppHints.bEnableStaticMTECopy) { if(SetupMTEPregenBuffer(gc) != GLES2_NO_ERROR) { PVR_DPF((PVR_DBG_ERROR,"InitContext: Failed to fill pregen buffer %u",i)); goto FAILED_CBUF_CreateBuffer; } } } } gc->sKickTA.sKickTACommon.ui32NumTAStatusVals = j; /* Setup 3D status val sync */ gc->sKickTA.sKickTACommon.ui32Num3DStatusVals = 2; if(BuildExtensionString(gc) != IMG_TRUE) { goto FAILED_BuildExtensionString; } #if defined(SGX_FEATURE_SW_VDM_CONTEXT_SWITCH) gc->sSmallKickTA.ui32NumIndicesThisTA = 0; gc->sSmallKickTA.ui32NumPrimitivesThisTA = 0; gc->sSmallKickTA.ui32NumIndicesThisFrame = 0; gc->sSmallKickTA.ui32NumPrimitivesThisFrame = 0; /* Default value to ensure no TA splitting on the first frame */ gc->sSmallKickTA.ui32KickThreshold = 0xFFFFFFFF; #endif #if defined(DEBUG) if(gc->sAppHints.bDumpShaderAnalysis) { gc->pShaderAnalysisHandle = OpenShaderAnalysisFile(); } #endif /* defined(DEBUG) */ PDUMP_STRING_CONTINUOUS((gc, "PDump from OpenGL ES 2.0 driver, version %s. HW variant %s, %d\n",PVRVERSION_STRING, pszRenderer, SGX_CORE_REV)); return IMG_TRUE; /* Clean up any memory */ FAILED_BuildExtensionString: FAILED_CBUF_CreateBuffer: for(i=0; i < CBUF_NUM_TA_BUFFERS; i++) { if(gc->apsBuffers[i]) { CBUF_DestroyBuffer(gc->ps3DDevData, gc->apsBuffers[i]); } } FAILED_InitSpecialUSECodeBlocks: FreeVertexArrayObjectState(gc); FAILED_CreateVertexArrayObjectState: FreeFrameBufferState(gc); FAILED_CreateFrameBufferState: FreeBufObjState(gc); FAILED_CreateBufObjState: FreeProgramState(gc); FAILED_CreateProgramState: FreeTextureState(gc); FAILED_CreateTextureState: HashTableDestroy(gc, &gc->sProgram.sPDSFragmentVariantHashTable); FAILED_CreateHashTable: GLES2FREEDEVICEMEM(gc->ps3DDevData, gc->sKRMTAStatusUpdate.psMemInfo); FAILED_TASync: FreeContextSharedState(gc); FAILED_CreateSharedState: #if defined(FIX_HW_BRN_26922) FreeBRN26922Mem(gc); FAILED_AllocateBRN26922Mem: #endif /* defined(FIX_HW_BRN_26922) */ return IMG_FALSE; }
/* * Complements a scaffold; both complementing each contig within it and * reversing the order of contigs in the scaffold. * * Returns 0 on success * -1 on failure */ int complement_scaffold(GapIO *io, tg_rec srec) { scaffold_t *f; int i, j, nc = ArrayMax(io->contig_order); scaffold_member_t *contigs; tg_rec *crecs; HashTable *h; reg_order ro; reg_buffer_start rs; reg_buffer_end re; if (!(f = cache_search(io, GT_Scaffold, srec))) return -1; if (!(f = cache_rw(io, f))) return -1; cache_incr(io, f); /* Complement contigs */ contigs = ArrayBase(scaffold_member_t, f->contig); for (i = 0; i < ArrayMax(f->contig); i++) { complement_contig(io, contigs[i].rec); } /* Reverse the order of the contigs in the scaffold array */ for (i = 0, j = ArrayMax(f->contig)-1; i < j; i++, j--) { scaffold_member_t cr1 = contigs[i]; contigs[i] = contigs[j]; contigs[j] = cr1; } /* * Reverse the order of contigs in the contig_order array too. * This is the part that really matters. It's also hard as the contigs * in the contig order array could be in any order and not adjacent. * For our purposes we'll just ensure the contigs in this scaffold in * the contig order array match our freshly complemented scaffold * ordering. * * We initially build a hash table of contigs in this scaffold, and * then iterate through contig_order copying out the new contigs whenever * one matches. */ h = HashTableCreate(nc, 0); for (i = 0; i < ArrayMax(f->contig); i++) { HashData hd; hd.i = 0; HashTableAdd(h, (char *)&contigs[i].rec, sizeof(tg_rec), hd, NULL); } /* Replace any contig matching the scaffold with the new order */ crecs = ArrayBase(tg_rec, io->contig_order); for (i = j = 0; i < nc; i++) { HashItem *hi; if (!(hi = HashTableSearch(h, (char *)&crecs[i], sizeof(tg_rec)))) continue; crecs[i] = contigs[j++].rec; } /* Send event messages around */ rs.job = REG_BUFFER_START; for (i = 0; i < nc; i++) { HashItem *hi; if (!(hi = HashTableSearch(h, (char *)&crecs[i], sizeof(tg_rec)))) continue; contig_notify(io, crecs[i], (reg_data *)&rs); } ro.job = REG_ORDER; for (i = 0; i < nc; i++) { HashItem *hi; if (!(hi = HashTableSearch(h, (char *)&crecs[i], sizeof(tg_rec)))) continue; ro.pos = i+1; contig_notify(io, crecs[i], (reg_data *)&ro); } /* Notify the end of our updates */ re.job = REG_BUFFER_END; for (i = 0; i < nc; i++) { HashItem *hi; if (!(hi = HashTableSearch(h, (char *)&crecs[i], sizeof(tg_rec)))) continue; contig_notify(io, crecs[i], (reg_data *)&re); } HashTableDestroy(h, 0); cache_decr(io, f); return 0; }