Exemplo n.º 1
0
static void radeonInitTextureObjects( GLcontext *ctx )
{
   radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
   struct gl_texture_object *texObj;
   GLuint tmp = ctx->Texture.CurrentUnit;

   ctx->Texture.CurrentUnit = 0;

   texObj = ctx->Texture.Unit[0].Current1D;
   radeonBindTexture( ctx, GL_TEXTURE_1D, texObj );
   move_to_tail( &rmesa->texture.swapped,
		 (radeonTexObjPtr)texObj->DriverData );

   texObj = ctx->Texture.Unit[0].Current2D;
   radeonBindTexture( ctx, GL_TEXTURE_2D, texObj );
   move_to_tail( &rmesa->texture.swapped,
		 (radeonTexObjPtr)texObj->DriverData );

   ctx->Texture.CurrentUnit = 1;

   texObj = ctx->Texture.Unit[1].Current1D;
   radeonBindTexture( ctx, GL_TEXTURE_1D, texObj );
   move_to_tail( &rmesa->texture.swapped,
		 (radeonTexObjPtr)texObj->DriverData );

   texObj = ctx->Texture.Unit[1].Current2D;
   radeonBindTexture( ctx, GL_TEXTURE_2D, texObj );
   move_to_tail( &rmesa->texture.swapped,
		 (radeonTexObjPtr)texObj->DriverData );

   ctx->Texture.CurrentUnit = tmp;
}
Exemplo n.º 2
0
    void set(int key, int value) {
        if (hash.find(key) != hash.end()) {
            ListNode* prev= hash[key];
            prev->next->val = value;
            move_to_tail(prev);
        } else {
            ListNode* new_node = new ListNode(key, value);

            tail->next = new_node;
            hash[key] = tail;
            tail = new_node;

            size++;

            if (size > capacity) {
                ListNode* head = dummy->next;

                dummy->next = head->next;
                if (dummy->next != NULL) {
                    hash[dummy->next->key] = dummy;
                }

                hash.erase(head->key);
                delete head;

                size--;
            }
        }
    }
/**
 * \brief Keep track of swapped out texture objects.
 * 
 * \param rmesa Radeon context.
 * \param t Radeon texture object.
 *
 * Frees the memory associated with the texture, marks all mipmap images in
 * the texture as dirty and add it to the radeon_texture::swapped list.
 */
static void radeonSwapOutTexObj( radeonContextPtr rmesa, radeonTexObjPtr t )
{
   if ( t->memBlock ) {
      mmFreeMem( t->memBlock );
      t->memBlock = NULL;
   }

   t->dirty_images = ~0;
   move_to_tail( &rmesa->texture.swapped, t );
}
Exemplo n.º 4
0
    int get(int key) {
        if (hash.find(key) == hash.end()) {
            return -1;
        }

        ListNode* prev = hash[key];
        int val = prev->next->val;
        move_to_tail(prev);

        return val;
    }
Exemplo n.º 5
0
/*
 * read_cache - read the node (if exists) with given uri
 * 
 * Input is the cache-list header, the given uri, the response pointer that will
 * be filled
 * 
 * return -1 when no node is found
 */
int read_cache(Cache cache, char *uri, char *ret_res)
{
    // 我锁
    sem_wait(cache->all);
    cache->reader_cnt++;
    if(cache->reader_cnt == 1) 
    {
        sem_wait(cache->write);
    }
    sem_post(cache->all);

    // 在 cache 中找这个请求对应的节点
    Node node = find_node(cache, uri);
    c_dbgprintf("\n-------------------------------\n");
    c_dbgprintf("    -try reading uri: %s\n", uri);

    // 我解锁
    sem_wait(cache->all);
    cache->reader_cnt--;
    if(cache->reader_cnt == 0) 
    {
        sem_post(cache->write);
    }
    sem_post(cache->all);


    // 如果 cache 中有这个请求对应的节点
    if (node != NULL)
    {
        sem_wait(cache->write);
        memcpy(ret_res, node->res, node->res_size);

        // 最近读的放到列表尾部,即成为了 most recently used
        move_to_tail(cache, node);

        c_dbgprintf("    -reading: %d byte\n", node->res_size);
        c_dbgprintf("-------------------------------\n");

        sem_post(cache->write);
        return node->res_size;
    }

    c_dbgprintf("-------------------------------\n");

    return -1;
}