~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/egl/drivers/dri2/egl_dri2.h

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include <stdint.h>
33
33
 
34
34
#ifdef HAVE_X11_PLATFORM
35
 
#include <xcb/xcb.h>
 
35
#include <X11/Xlib-xcb.h>
36
36
#include <xcb/dri2.h>
37
37
#include <xcb/randr.h>
 
38
#include <xcb/xcb.h>
38
39
#include <xcb/xfixes.h>
39
 
#include <X11/Xlib-xcb.h>
40
40
 
41
41
#include "loader_dri_helper.h"
42
42
#ifdef HAVE_DRI3
82
82
 
83
83
#include "eglconfig.h"
84
84
#include "eglcontext.h"
 
85
#include "eglcurrent.h"
85
86
#include "egldevice.h"
86
87
#include "egldisplay.h"
87
88
#include "egldriver.h"
88
 
#include "eglcurrent.h"
 
89
#include "eglimage.h"
89
90
#include "egllog.h"
90
91
#include "eglsurface.h"
91
 
#include "eglimage.h"
92
92
#include "eglsync.h"
93
93
 
 
94
#include "util/bitset.h"
 
95
#include "util/u_dynarray.h"
94
96
#include "util/u_vector.h"
95
 
#include "util/u_dynarray.h"
96
 
#include "util/bitset.h"
97
97
 
98
98
struct wl_buffer;
99
99
 
102
102
   int (*authenticate)(_EGLDisplay *disp, uint32_t id);
103
103
 
104
104
   /* mandatory */
105
 
   _EGLSurface* (*create_window_surface)(_EGLDisplay *disp, _EGLConfig *config,
 
105
   _EGLSurface *(*create_window_surface)(_EGLDisplay *disp, _EGLConfig *config,
106
106
                                         void *native_window,
107
107
                                         const EGLint *attrib_list);
108
108
 
109
109
   /* optional */
110
 
   _EGLSurface* (*create_pixmap_surface)(_EGLDisplay *disp, _EGLConfig *config,
 
110
   _EGLSurface *(*create_pixmap_surface)(_EGLDisplay *disp, _EGLConfig *config,
111
111
                                         void *native_pixmap,
112
112
                                         const EGLint *attrib_list);
113
113
 
114
114
   /* optional */
115
 
   _EGLSurface* (*create_pbuffer_surface)(_EGLDisplay *disp, _EGLConfig *config,
 
115
   _EGLSurface *(*create_pbuffer_surface)(_EGLDisplay *disp, _EGLConfig *config,
116
116
                                          const EGLint *attrib_list);
117
117
 
118
118
   /* mandatory */
123
123
                               EGLint interval);
124
124
 
125
125
   /* mandatory */
126
 
   _EGLImage* (*create_image)(_EGLDisplay *disp, _EGLContext *ctx,
 
126
   _EGLImage *(*create_image)(_EGLDisplay *disp, _EGLContext *ctx,
127
127
                              EGLenum target, EGLClientBuffer buffer,
128
128
                              const EGLint *attr_list);
129
129
 
131
131
   EGLBoolean (*swap_buffers)(_EGLDisplay *disp, _EGLSurface *surf);
132
132
 
133
133
   /* optional - falls back to .swap_buffers */
134
 
   EGLBoolean (*swap_buffers_with_damage)(_EGLDisplay *disp, _EGLSurface *surface,
 
134
   EGLBoolean (*swap_buffers_with_damage)(_EGLDisplay *disp,
 
135
                                          _EGLSurface *surface,
135
136
                                          const EGLint *rects, EGLint n_rects);
136
137
 
137
138
   /* optional */
139
140
                                     EGLint numRects, const EGLint *rects);
140
141
 
141
142
   /* optional */
142
 
   EGLBoolean (*post_sub_buffer)(_EGLDisplay *disp, _EGLSurface *surf,
143
 
                                 EGLint x, EGLint y,
144
 
                                 EGLint width, EGLint height);
 
143
   EGLBoolean (*post_sub_buffer)(_EGLDisplay *disp, _EGLSurface *surf, EGLint x,
 
144
                                 EGLint y, EGLint width, EGLint height);
145
145
 
146
146
   /* optional */
147
147
   EGLBoolean (*copy_buffers)(_EGLDisplay *disp, _EGLSurface *surf,
155
155
                               EGLint attribute, EGLint *value);
156
156
 
157
157
   /* optional */
158
 
   struct wl_buffer* (*create_wayland_buffer_from_image)(_EGLDisplay *disp,
 
158
   struct wl_buffer *(*create_wayland_buffer_from_image)(_EGLDisplay *disp,
159
159
                                                         _EGLImage *img);
160
160
 
161
161
   /* optional */
215
215
};
216
216
#endif
217
217
 
218
 
struct dri2_egl_display
219
 
{
 
218
struct dri2_egl_display {
220
219
   const struct dri2_egl_display_vtbl *vtbl;
221
220
 
222
221
   mtx_t lock;
224
223
   int dri2_major;
225
224
   int dri2_minor;
226
225
   __DRIscreen *dri_screen_render_gpu;
227
 
   /* dri_screen_display_gpu holds display GPU in case of prime gpu offloading else
228
 
    * dri_screen_render_gpu and dri_screen_display_gpu is same.
229
 
    * In case of prime gpu offloading, if display and render driver names are different
230
 
    * (potentially not compatible), dri_screen_display_gpu will be NULL but fd_display_gpu
231
 
    * will still hold fd for display driver.
 
226
   /* dri_screen_display_gpu holds display GPU in case of prime gpu offloading
 
227
    * else dri_screen_render_gpu and dri_screen_display_gpu is same. In case of
 
228
    * prime gpu offloading, if display and render driver names are different
 
229
    * (potentially not compatible), dri_screen_display_gpu will be NULL but
 
230
    * fd_display_gpu will still hold fd for display driver.
232
231
    */
233
232
   __DRIscreen *dri_screen_display_gpu;
234
233
   bool own_dri_screen;
319
318
   bool is_render_node;
320
319
};
321
320
 
322
 
struct dri2_egl_context
323
 
{
 
321
struct dri2_egl_context {
324
322
   _EGLContext base;
325
323
   __DRIcontext *dri_context;
326
324
};
327
325
 
328
 
struct dri2_egl_surface
329
 
{
 
326
struct dri2_egl_surface {
330
327
   _EGLSurface base;
331
328
   __DRIdrawable *dri_drawable;
332
329
   __DRIbuffer buffers[5];
418
415
   char *swrast_device_buffer;
419
416
};
420
417
 
421
 
struct dri2_egl_config
422
 
{
 
418
struct dri2_egl_config {
423
419
   _EGLConfig base;
424
420
   const __DRIconfig *dri_config[2][2];
425
421
};
426
422
 
427
 
struct dri2_egl_image
428
 
{
 
423
struct dri2_egl_image {
429
424
   _EGLImage base;
430
425
   __DRIimage *dri_image;
431
426
};
455
450
}
456
451
 
457
452
static inline EGLBoolean
458
 
dri2_egl_error_unlock(struct dri2_egl_display *dri2_dpy, EGLint err, const char *msg)
 
453
dri2_egl_error_unlock(struct dri2_egl_display *dri2_dpy, EGLint err,
 
454
                      const char *msg)
459
455
{
460
456
   mtx_unlock(&dri2_dpy->lock);
461
457
   return _eglError(err, msg);
502
498
 
503
499
void
504
500
dri2_get_shifts_and_sizes(const __DRIcoreExtension *core,
505
 
                          const __DRIconfig *config, int *shifts,
506
 
                          unsigned int *sizes);
 
501
                          const __DRIconfig *config, int *shifts,
 
502
                          unsigned int *sizes);
507
503
 
508
504
void
509
505
dri2_get_render_type_float(const __DRIcoreExtension *core,
510
 
                           const __DRIconfig *config,
511
 
                           bool *is_float);
 
506
                           const __DRIconfig *config, bool *is_float);
512
507
 
513
508
unsigned int
514
509
dri2_image_format_for_pbuffer_config(struct dri2_egl_display *dri2_dpy,
547
542
   return _eglError(EGL_NOT_INITIALIZED, "X11 platform not built");
548
543
}
549
544
static inline void
550
 
dri2_teardown_x11(struct dri2_egl_display *dri2_dpy) {}
 
545
dri2_teardown_x11(struct dri2_egl_display *dri2_dpy)
 
546
{
 
547
}
551
548
static inline unsigned int
552
549
dri2_x11_get_red_mask_for_depth(struct dri2_egl_display *dri2_dpy, int depth)
553
550
{
567
564
   return _eglError(EGL_NOT_INITIALIZED, "GBM/DRM platform not built");
568
565
}
569
566
static inline void
570
 
dri2_teardown_drm(struct dri2_egl_display *dri2_dpy) {}
 
567
dri2_teardown_drm(struct dri2_egl_display *dri2_dpy)
 
568
{
 
569
}
571
570
#endif
572
571
 
573
572
#ifdef HAVE_WAYLAND_PLATFORM
576
575
void
577
576
dri2_teardown_wayland(struct dri2_egl_display *dri2_dpy);
578
577
bool
579
 
dri2_wl_is_format_supported(void* user_data, uint32_t format);
 
578
dri2_wl_is_format_supported(void *user_data, uint32_t format);
580
579
#else
581
580
static inline EGLBoolean
582
581
dri2_initialize_wayland(_EGLDisplay *disp)
584
583
   return _eglError(EGL_NOT_INITIALIZED, "Wayland platform not built");
585
584
}
586
585
static inline void
587
 
dri2_teardown_wayland(struct dri2_egl_display *dri2_dpy) {}
 
586
dri2_teardown_wayland(struct dri2_egl_display *dri2_dpy)
 
587
{
 
588
}
588
589
#endif
589
590
 
590
591
#ifdef HAVE_ANDROID_PLATFORM
604
605
EGLBoolean
605
606
dri2_initialize_device(_EGLDisplay *disp);
606
607
static inline void
607
 
dri2_teardown_device(struct dri2_egl_display *dri2_dpy) { /* noop */ }
 
608
dri2_teardown_device(struct dri2_egl_display *dri2_dpy)
 
609
{ /* noop */
 
610
}
608
611
 
609
612
void
610
 
dri2_flush_drawable_for_swapbuffers_flags(_EGLDisplay *disp, _EGLSurface *draw,
611
 
                                          enum __DRI2throttleReason throttle_reason);
 
613
dri2_flush_drawable_for_swapbuffers_flags(
 
614
   _EGLDisplay *disp, _EGLSurface *draw,
 
615
   enum __DRI2throttleReason throttle_reason);
612
616
void
613
617
dri2_flush_drawable_for_swapbuffers(_EGLDisplay *disp, _EGLSurface *draw);
614
618
 
623
627
   struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
624
628
 
625
629
   if (dri2_dpy->device_name && dri2_dpy->image) {
626
 
       if (dri2_dpy->image->base.version >= 10 &&
627
 
           dri2_dpy->image->getCapabilities != NULL) {
628
 
           int capabilities;
 
630
      if (dri2_dpy->image->base.version >= 10 &&
 
631
          dri2_dpy->image->getCapabilities != NULL) {
 
632
         int capabilities;
629
633
 
630
 
           capabilities =
631
 
               dri2_dpy->image->getCapabilities(dri2_dpy->dri_screen_render_gpu);
632
 
           disp->Extensions.WL_bind_wayland_display =
633
 
               (capabilities & __DRI_IMAGE_CAP_GLOBAL_NAMES) != 0;
634
 
       } else {
635
 
           disp->Extensions.WL_bind_wayland_display = EGL_TRUE;
636
 
       }
 
634
         capabilities =
 
635
            dri2_dpy->image->getCapabilities(dri2_dpy->dri_screen_render_gpu);
 
636
         disp->Extensions.WL_bind_wayland_display =
 
637
            (capabilities & __DRI_IMAGE_CAP_GLOBAL_NAMES) != 0;
 
638
      } else {
 
639
         disp->Extensions.WL_bind_wayland_display = EGL_TRUE;
 
640
      }
637
641
   }
638
642
#endif
639
643
}
650
654
 
651
655
EGLBoolean
652
656
dri2_init_surface(_EGLSurface *surf, _EGLDisplay *disp, EGLint type,
653
 
        _EGLConfig *conf, const EGLint *attrib_list,
654
 
        EGLBoolean enable_out_fence, void *native_surface);
 
657
                  _EGLConfig *conf, const EGLint *attrib_list,
 
658
                  EGLBoolean enable_out_fence, void *native_surface);
655
659
 
656
660
void
657
661
dri2_fini_surface(_EGLSurface *surf);
659
663
EGLBoolean
660
664
dri2_create_drawable(struct dri2_egl_display *dri2_dpy,
661
665
                     const __DRIconfig *config,
662
 
                     struct dri2_egl_surface *dri2_surf,
663
 
                     void *loaderPrivate);
 
666
                     struct dri2_egl_surface *dri2_surf, void *loaderPrivate);
664
667
 
665
668
static inline uint64_t
666
669
combine_u32_into_u64(uint32_t hi, uint32_t lo)
667
670
{
668
 
   return (((uint64_t) hi) << 32) | (((uint64_t) lo) & 0xffffffff);
 
671
   return (((uint64_t)hi) << 32) | (((uint64_t)lo) & 0xffffffff);
669
672
}
670
673
 
671
674
#endif /* EGL_DRI2_INCLUDED */