add place-holder directory for the a3000 wd533c93 scsi controller implementation.
[AROS.git] / workbench / libs / mesa / mesa3dgl_glacreatecontext.c
blobfc3a6c7676b9b3a3d557c020ec3e7df018e062ae
1 /*
2 Copyright © 2009-2019, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
8 #include "util/os_misc.h"
9 #include "pipe/p_defines.h"
10 #include "pipe/p_screen.h"
11 #include "pipe/p_state.h"
13 #include "util/u_inlines.h"
15 #include <gallium/gallium.h>
17 #include <proto/exec.h>
18 #include <proto/gallium.h>
20 #include "mesa3dgl_support.h"
21 #include "mesa3dgl_gallium.h"
23 /*****************************************************************************
25 NAME */
27 GLAContext glACreateContext(
29 /* SYNOPSIS */
30 struct TagItem *tagList)
32 /* FUNCTION
34 Crates a GL rendering context that can be later used in subsequent
35 calls.
37 INPUTS
39 tagList - a pointer to tags to be used during creation.
41 TAGS
43 GLA_Left - specifies the left rendering offset on the rastport.
44 Typically equals to window->BorderLeft.
46 GLA_Top - specifies the top rendering offset on the rastport.
47 Typically equals to window->BorderTop.
49 GLA_Right - specifies the right rendering offset on the rastport.
50 Typically equals to window->BorderRight.
52 GLA_Bottom - specifies the bottom rendering offset on the rastport.
53 Typically equals to window->BorderBottom.
55 GLA_Width - specifies the width of the rendering area.
56 GLA_Width + GLA_Left + GLA_Right should equal the width of
57 the rastport. The GLA_Width is interchangable at cration
58 time with GLA_Right. Later durring window resizing, width
59 is calculated from scalled left, righ and window width.
61 GLA_Height - specifies the height of the rendering area.
62 GLA_Height + GLA_Top + GLA_Bottom should equal the height
63 of the rastport. The GLA_Height is interchangable at
64 cration time with GLA_Bottom. Later durring window resizing
65 , height is calculated from scalled top, bottom and window
66 height.
68 GLA_Screen - pointer to Screen onto which scene is to be rendered. When
69 selecting RastPort has lower priority than GLA_Window.
71 GLA_Window - pointer to Window onto which scene is to be rendered. Must
72 be provided.
74 GLA_RastPort - ignored. Use GLA_Window.
76 GLA_DoubleBuf - ignored. All rendering is always double buffered.
78 GLA_RGBMode - ignored. All rendering is done in RGB. Indexed modes are
79 not supported.
81 GLA_AlphaFlag - ignored. All rendering is done with alpha channel.
83 GLA_NoDepth - disables the depth/Z buffer. Depth buffer is enabled by
84 default and is 16 or 24 bit based on rendering
85 capabilities.
87 GLA_NoStencil - disables the stencil buffer. Stencil buffer is enabled
88 by default.
90 GLA_NoAccum - disables the accumulation buffer. Accumulation buffer is
91 enabled by default.
93 RESULT
95 A valid GL context or NULL of creation was not succesfull.
97 BUGS
99 INTERNALS
101 HISTORY
103 *****************************************************************************/
105 struct mesa3dgl_context * ctx = NULL;
106 struct TagItem pscreen_tags[] =
108 { CPS_PipeFriendBitMap, 0 },
109 { CPS_PipeScreenDriver, 0 },
110 { TAG_DONE, 0 }
112 struct pipe_screen * pscreen = NULL;
113 struct st_context_attribs attribs = {0};
114 enum st_context_error st_error = 0;
116 D(bug("[MESA3DGL] %s()\n", __func__));
118 /* Allocate MESA3DGL context */
119 if (!(ctx = (struct mesa3dgl_context *)AllocVec(sizeof(struct mesa3dgl_context), MEMF_PUBLIC | MEMF_CLEAR)))
121 bug("%s: ERROR - failed to allocate GLAContext\n", __func__);
122 return NULL;
124 pscreen_tags[1].ti_Data = (IPTR)&ctx->driver;
126 D(bug("[MESA3DGL] %s: ctx @ 0x%p\n", __func__, ctx));
128 MESA3DGLSelectRastPort(ctx, tagList);
129 if (!ctx->visible_rp)
131 bug("%s: ERROR - failed to select visible rastport\n", __func__);
132 goto error_out;
135 D(bug("[MESA3DGL] %s: visible_rp @ 0x%p\n", __func__, ctx->visible_rp));
136 pscreen_tags[0].ti_Data = (IPTR)ctx->visible_rp->BitMap;
137 D(bug("[MESA3DGL] %s: _bmap @ 0x%p\n", __func__, pscreen_tags[0].ti_Data));
139 MESA3DGLStandardInit(ctx, tagList);
141 if (CreatePipeV(pscreen_tags))
143 pscreen = CreatePipeScreen(ctx->driver);
144 if (!pscreen)
146 bug("%s: ERROR - failed to create gallium pipe screen\n", __func__);
147 goto error_out;
150 else
152 bug("%s: ERROR - failed to create gallium pipe\n", __func__);
153 goto error_out;
156 D(bug("[MESA3DGL] %s: pipe screen @ 0x%p\n", __func__, pscreen));
157 D(bug("[MESA3DGL] %s: pipe driver @ 0x%p\n", __func__, ctx->driver));
159 if (!(ctx->stmanager = MESA3DGLNewStManager(pscreen)))
161 bug("%s: ERROR - failed to create ST Manager\n");
162 DestroyPipeScreen(ctx->driver, pscreen);
163 #if (0)
164 DestroyPipe(ctx->driver);
165 #endif
166 goto error_out;
169 D(bug("[MESA3DGL] %s: ST Manager @ 0x%p \n", __func__, ctx->stmanager));
171 if (!MESA3DGLFillVisual(&ctx->stvis, ctx->stmanager->screen, ctx->BitsPerPixel, tagList))
173 bug("%s: ERROR - failed to fill ST Visual\n", __func__);
174 goto error_out;
177 attribs.profile = ST_PROFILE_DEFAULT;
178 attribs.visual = ctx->stvis;
180 ctx->st = glstapi->create_context(glstapi, ctx->stmanager, &attribs, &st_error, NULL);
181 if (!ctx->st)
183 bug("%s: ERROR - failed to create mesa state tracker context\n", __func__);
184 goto error_out;
187 ctx->framebuffer = MESA3DGLNewFrameBuffer(ctx, &ctx->stvis);
189 if (!ctx->framebuffer)
191 bug("%s: ERROR - failed to create frame buffer\n", __func__);
192 goto error_out;
195 return (GLAContext)ctx;
197 error_out:
198 if (ctx->stmanager) MESA3DGLFreeStManager(ctx->driver, ctx->stmanager);
199 if (ctx) MESA3DGLFreeContext(ctx);
200 return (GLAContext)NULL;