view TaskManager/Test/test_render/spe/Set_Texture.cpp @ 352:3f5289873643

add global_alloc.h
author admin@mb22-no-macbook-2.local
date Mon, 13 Jul 2009 19:25:10 +0900
parents 4be5ae77e02c
children b89ba1d96fff
line wrap: on
line source

// #define DEBUG
#include "error.h"
#include <string.h>
#include "Set_Texture.h"
#include "texture.h"
#include "global_alloc.h"

SchedDefineTask(SetTexture);

//texture をglobal 領域にコピーするタスク
int
SetTexture::run(void *rbuf, void *wbuf)
{
    __debug_spe("SetTexture\n");
    void *src[4];

    src[0] = get_input(rbuf, 0);
    src[1] = get_input(rbuf, 1);
    src[2] = get_input(rbuf, 2);
    src[3] = get_input(rbuf, 3);

    if (global_get(TEXTURE_ID)) {
        return 0;
    } else {
        //タスクが共有できる領域確保
        void *data = global_alloc(TEXTURE_ID, MAX_LOAD_SIZE*4);

        memcpy(data, src[0], MAX_LOAD_SIZE);
        memcpy((void*)((int)data + MAX_LOAD_SIZE), src[1], MAX_LOAD_SIZE);
        memcpy((void*)((int)data + MAX_LOAD_SIZE*2), src[2], MAX_LOAD_SIZE);
        memcpy((void*)((int)data + MAX_LOAD_SIZE*3), src[3], MAX_LOAD_SIZE);
    }

    return 0;
}