2 Copyright © 2009-2018, The AROS Development Team. All rights reserved.
7 #include <aros/debug.h>
9 #include <proto/exec.h>
10 #include <proto/gallium.h>
12 #include <gallium/gallium.h>
13 #include <gallium/pipe/p_context.h>
14 #include <gallium/pipe/p_screen.h>
16 #include "mesa3dgl_support.h"
17 #include "mesa3dgl_gallium.h"
19 /*****************************************************************************
23 GLAContext
glACreateContext(
26 struct TagItem
*tagList
)
30 Creates a GL rendering context that can be later used in subsequent
35 tagList - a pointer to tags to be used during creation.
39 GLA_Left - specifies the left rendering offset on the rastport.
40 Typically equals to window->BorderLeft.
42 GLA_Top - specifies the top rendering offset on the rastport.
43 Typically equals to window->BorderTop.
45 GLA_Right - specifies the right rendering offset on the rastport.
46 Typically equals to window->BorderRight.
48 GLA_Bottom - specifies the bottom rendering offset on the rastport.
49 Typically equals to window->BorderBottom.
51 GLA_Width - specifies the width of the rendering area.
52 GLA_Width + GLA_Left + GLA_Right should equal the width of
53 the rastport. The GLA_Width is interchangable at cration
54 time with GLA_Right. Later durring window resizing, width
55 is calculated from scalled left, righ and window width.
57 GLA_Height - specifies the height of the rendering area.
58 GLA_Height + GLA_Top + GLA_Bottom should equal the height
59 of the rastport. The GLA_Height is interchangable at
60 cration time with GLA_Bottom. Later durring window resizing
61 , height is calculated from scalled top, bottom and window
64 GLA_Screen - pointer to Screen onto which scene is to be rendered. When
65 selecting RastPort has lower priority than GLA_Window.
67 GLA_Window - pointer to Window onto which scene is to be rendered. Must
70 GLA_RastPort - ignored. Use GLA_Window.
72 GLA_DoubleBuf - ignored. All rendering is always double buffered.
74 GLA_RGBMode - ignored. All rendering is done in RGB. Indexed modes are
77 GLA_AlphaFlag - ignored. All rendering is done with alpha channel.
79 GLA_NoDepth - disables the depth/Z buffer. Depth buffer is enabled by
80 default and is 16 or 24 bit based on rendering
83 GLA_NoStencil - disables the stencil buffer. Stencil buffer is enabled
86 GLA_NoAccum - disables the accumulation buffer. Accumulation buffer is
91 A valid GL context or NULL if creation was not successful.
99 *****************************************************************************/
101 struct mesa3dgl_context
* ctx
= NULL
;
102 struct TagItem pscreen_tags
[] =
104 { CPS_PipeFriendBitMap
, 0 },
105 { CPS_PipeScreenDriver
, 0 },
108 struct pipe_screen
* pscreen
= NULL
;
109 struct st_context_attribs attribs
= {0};
111 D(bug("[MESA3DGL] %s()\n", __func__
));
113 /* Allocate MESA3DGL context */
114 if (!(ctx
= (struct mesa3dgl_context
*)AllocVec(sizeof(struct mesa3dgl_context
), MEMF_PUBLIC
| MEMF_CLEAR
)))
116 bug("%s: ERROR - failed to allocate GLAContext\n", __func__
);
119 pscreen_tags
[1].ti_Data
= (IPTR
)&ctx
->driver
;
121 D(bug("[MESA3DGL] %s: ctx @ 0x%p\n", __func__
, ctx
));
123 MESA3DGLSelectRastPort(ctx
, tagList
);
124 if (!ctx
->visible_rp
)
126 bug("%s: ERROR - failed to select visible rastport\n", __func__
);
130 D(bug("[MESA3DGL] %s: visible_rp @ 0x%p\n", __func__
, ctx
->visible_rp
));
131 pscreen_tags
[0].ti_Data
= (IPTR
)ctx
->visible_rp
->BitMap
;
132 D(bug("[MESA3DGL] %s: _bmap @ 0x%p\n", __func__
, pscreen_tags
[0].ti_Data
));
134 MESA3DGLStandardInit(ctx
, tagList
);
136 if (CreatePipeV(pscreen_tags
))
138 pscreen
= CreatePipeScreen(ctx
->driver
);
141 bug("%s: ERROR - failed to create gallium pipe screen\n", __func__
);
147 bug("%s: ERROR - failed to create gallium pipe\n", __func__
);
151 D(bug("[MESA3DGL] %s: pipe screen @ 0x%p\n", __func__
, pscreen
));
152 D(bug("[MESA3DGL] %s: pipe driver @ 0x%p\n", __func__
, ctx
->driver
));
154 if (!(ctx
->stmanager
= MESA3DGLNewStManager(pscreen
)))
156 bug("%s: ERROR - failed to create ST Manager\n");
157 DestroyPipeScreen(ctx
->driver
, pscreen
);
161 D(bug("[MESA3DGL] %s: ST Manager @ 0x%p \n", __func__
, ctx
->stmanager
));
163 if (!MESA3DGLFillVisual(&ctx
->stvis
, ctx
->stmanager
->screen
, ctx
->BitsPerPixel
, tagList
))
165 bug("%s: ERROR - failed to fill ST Visual\n", __func__
);
169 attribs
.profile
= ST_PROFILE_DEFAULT
;
170 attribs
.visual
= ctx
->stvis
;
172 ctx
->st
= glstapi
->create_context(glstapi
, ctx
->stmanager
, &attribs
, NULL
);
175 bug("%s: ERROR - failed to create mesa state tracker context\n", __func__
);
179 ctx
->framebuffer
= MESA3DGLNewFrameBuffer(ctx
, &ctx
->stvis
);
181 if (!ctx
->framebuffer
)
183 bug("%s: ERROR - failed to create frame buffer\n", __func__
);
187 return (GLAContext
)ctx
;
190 if (ctx
->stmanager
) MESA3DGLFreeStManager(ctx
->driver
, ctx
->stmanager
);
191 if (ctx
) MESA3DGLFreeContext(ctx
);
192 return (GLAContext
)NULL
;