summaryrefslogtreecommitdiff
path: root/src/VBox/Additions/common/crOpenGL/array/arrayspu_init.c
blob: f05ee5b7079f5a1519bf3756022efb92ff503a1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/* Copyright (c) 2001, Stanford University
 * All rights reserved
 *
 * See the file LICENSE.txt for information on redistributing this software.
 */

#include "cr_spu.h"
#include "arrayspu.h"
#include "cr_mem.h"
#include <stdio.h>

extern SPUNamedFunctionTable _cr_array_table[];

extern SPUOptions arraySPUOptions[];

static SPUFunctions array_functions = {
    NULL, /* CHILD COPY */
    NULL, /* DATA */
    _cr_array_table /* THE ACTUAL FUNCTIONS */
};

static SPUFunctions *arraySPUInit( int id, SPU *child, SPU *self,
        unsigned int context_id,
        unsigned int num_contexts )
{

    (void) context_id;
    (void) num_contexts;

#ifdef CHROMIUM_THREADSAFE
    crInitMutex(&_ArrayMutex);
#endif

    array_spu.id = id;
    array_spu.has_child = 0;
    if (child)
    {
        crSPUInitDispatchTable( &(array_spu.child) );
        crSPUCopyDispatchTable( &(array_spu.child), &(child->dispatch_table) );
        array_spu.has_child = 1;
    }
    crSPUInitDispatchTable( &(array_spu.super) );
    crSPUCopyDispatchTable( &(array_spu.super), &(self->superSPU->dispatch_table) );
    arrayspuSetVBoxConfiguration();

    crStateInit();
/*@todo seems default context ain't needed at all*/
    array_spu.defaultctx = crStateCreateContext( NULL, 0, NULL );
#ifdef CR_ARB_vertex_buffer_object
    array_spu.defaultctx->bufferobject.retainBufferData = GL_TRUE;
#endif
    /* we call SetCurrent instead of MakeCurrent as the differencer
     * isn't setup yet anyway */
    crStateSetCurrent( array_spu.defaultctx );

    array_spu.numContexts = 0;
    crMemZero(array_spu.context, CR_MAX_CONTEXTS * sizeof(ContextInfo));

    return &array_functions;
}

static void arraySPUSelfDispatch(SPUDispatchTable *self)
{
    crSPUInitDispatchTable( &(array_spu.self) );
    crSPUCopyDispatchTable( &(array_spu.self), self );
}

static int arraySPUCleanup(void)
{
    return 1;
}

int SPULoad( char **name, char **super, SPUInitFuncPtr *init,
         SPUSelfDispatchFuncPtr *self, SPUCleanupFuncPtr *cleanup,
         SPUOptionsPtr *options, int *flags )
{
    *name = "array";
    *super = "passthrough";
    *init = arraySPUInit;
    *self = arraySPUSelfDispatch;
    *cleanup = arraySPUCleanup;
    *options = arraySPUOptions;
    *flags = (SPU_NO_PACKER|SPU_NOT_TERMINAL|SPU_MAX_SERVERS_ZERO);
    
    return 1;
}