xref: /aosp_15_r20/external/mesa3d/src/gallium/frontends/wgl/stw_winsys.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /**************************************************************************
2  *
3  * Copyright 2008-2009 VMware, Inc.
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sub license, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice (including the
15  * next paragraph) shall be included in all copies or substantial portions
16  * of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  *
26  **************************************************************************/
27 
28 #ifndef STW_WINSYS_H
29 #define STW_WINSYS_H
30 
31 #include <windows.h> /* for HDC */
32 
33 #include "util/compiler.h"
34 #include "frontend/api.h"
35 
36 struct pipe_screen;
37 struct pipe_context;
38 struct pipe_resource;
39 
40 struct stw_shared_surface;
41 
42 typedef enum
43 {
44    stw_pfd_gdi_support   = 1 << 0,
45    stw_pfd_double_buffer = 1 << 1,
46 } stw_pfd_flag;
47 
48 struct stw_winsys_framebuffer
49 {
50    void
51    (*destroy)(struct stw_winsys_framebuffer *fb,
52               struct pipe_context *context);
53 
54    bool
55    (*present)(struct stw_winsys_framebuffer *fb,
56               int interval);
57 
58    void
59    (*resize)(struct stw_winsys_framebuffer *fb,
60              struct pipe_context *context,
61              struct pipe_resource *templ);
62 
63    struct pipe_resource *
64    (*get_resource)(struct stw_winsys_framebuffer *fb,
65                    enum st_attachment_type statt);
66 
67    void
68    (*flush_frontbuffer)(struct stw_winsys_framebuffer *fb,
69                         struct pipe_context *context);
70 
71    void
72    (*set_latency)(struct stw_winsys_framebuffer *fb,
73                   int latency);
74 };
75 
76 struct stw_winsys
77 {
78    struct pipe_screen *
79    (*create_screen)( HDC hDC );
80 
81    /* XXX is it actually possible to have non-zero level/layer ??? */
82    /**
83     * Present the color buffer to the window associated with the device context.
84     */
85    void
86    (*present)( struct pipe_screen *screen,
87                struct pipe_context *context,
88                struct pipe_resource *res,
89                HDC hDC );
90 
91    /**
92     * Locally unique identifier (LUID) of the graphics adapter.
93     *
94     * @sa GLCBPRESENTBUFFERSDATA::AdapterLuid;
95     */
96    bool
97    (*get_adapter_luid)( struct pipe_screen *screen,
98                         HDC hDC,
99                         LUID *pAdapterLuid );
100 
101    /**
102     * Open a shared surface (optional).
103     *
104     * @sa GLCBPRESENTBUFFERSDATA::hSharedSurface;
105     */
106    struct stw_shared_surface *
107    (*shared_surface_open)(struct pipe_screen *screen,
108                           HANDLE hSharedSurface);
109 
110    /**
111     * Close a shared surface (optional).
112     */
113    void
114    (*shared_surface_close)(struct pipe_screen *screen,
115                            struct stw_shared_surface *surface);
116 
117    /**
118     * Compose into a shared surface (optional).
119     *
120     * Blit the color buffer into a shared surface.
121     *
122     * @sa GLPRESENTBUFFERSDATA::PresentHistoryToken.
123     */
124    void
125    (*compose)( struct pipe_screen *screen,
126                struct pipe_resource *res,
127                struct stw_shared_surface *dest,
128                LPCRECT pRect,
129                ULONGLONG PresentHistoryToken );
130 
131    /**
132     * Create a winsys-specific object for a given DC's framebuffer
133     */
134    struct stw_winsys_framebuffer *
135    (*create_framebuffer)( struct pipe_screen *screen,
136                           HWND hWnd,
137                           int iPixelFormat );
138 
139    /**
140     * Get the name of the screen that was created
141     */
142    const char *
143    (*get_name)(void);
144 };
145 
146 bool
147 stw_init(const struct stw_winsys *stw_winsys);
148 
149 bool
150 stw_init_thread(void);
151 
152 void
153 stw_cleanup_thread(void);
154 
155 void
156 stw_cleanup(void);
157 
158 #endif /* STW_WINSYS_H */
159