Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / libs / gallium / createpipescreen.c
blobb9347015921a1c0736e111e0d381fc37a0ed1345
1 /*
2 Copyright © 2010-2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include "gallium_intern.h"
7 #include <proto/utility.h>
8 #include <aros/debug.h>
10 #undef HiddGalliumAttrBase
11 #define HiddGalliumAttrBase GB(GalliumBase)->galliumAttrBase
13 /*****************************************************************************
15 NAME */
17 AROS_LH1(struct pipe_screen *, CreatePipeScreen,
19 /* SYNOPSIS */
20 AROS_LHA(struct TagItem *, tags, A0),
22 /* LOCATION */
23 struct Library *, GalliumBase, 5, Gallium)
25 /* FUNCTION
26 Creates a gallium pipe screen.
28 INPUTS
29 tags - a pointer to tags to be used during creation.
31 TAGS
32 CPS_GalliumInterfaceVersion - Indicates a version of gallium interface
33 that a client is expected to receive. The client expected version
34 must ideally match with the version that the driver provides,
35 because gallium interface is not backwards compatible. This tag is
36 required. Unless otherwise needed, the value
37 GALLIUM_INTERFACE_VERSION should be passed.
38 See also CreatePipeScreenV.
40 RESULT
41 A valid pipe screen instance or NULL if creation was not successful.
43 BUGS
45 INTERNALS
47 *****************************************************************************/
49 AROS_LIBFUNC_INIT
51 struct pipe_screen * screen = NULL;
52 LONG requestedinterfaceversion =
53 GetTagData(CPS_GalliumInterfaceVersion, -1, tags);
55 /* The tag is missing */
56 if (requestedinterfaceversion == -1)
57 return NULL;
59 ObtainSemaphore(&GB(GalliumBase)->driversemaphore);
61 if (!GB(GalliumBase)->driver)
62 GB(GalliumBase)->driver = SelectGalliumDriver(requestedinterfaceversion, GalliumBase);
64 if(GB(GalliumBase)->driver)
66 /* Validate driver gallium interface version */
67 if (IsVersionMatching(requestedinterfaceversion, GB(GalliumBase)->driver, GalliumBase))
69 /* Create screen */
70 struct pHidd_Gallium_CreatePipeScreen cpsmsg;
72 cpsmsg.mID = OOP_GetMethodID(IID_Hidd_Gallium, moHidd_Gallium_CreatePipeScreen);
73 screen = (struct pipe_screen *)OOP_DoMethod(GB(GalliumBase)->driver, (OOP_Msg)&cpsmsg);
75 else
77 bug("[gallium.library] Requested gallium interface version does not match selected driver\n");
80 else
82 bug("[gallium.library] Failed to acquire a driver\n");
85 ReleaseSemaphore(&GB(GalliumBase)->driversemaphore);
87 return screen;
89 AROS_LIBFUNC_EXIT