head	1.1;
branch	1.1.1;
access;
symbols
	netbsd-11-0-RC4:1.1.1.2
	netbsd-11-0-RC3:1.1.1.2
	netbsd-11-0-RC2:1.1.1.2
	netbsd-11-0-RC1:1.1.1.2
	netbsd-11:1.1.1.2.0.4
	netbsd-11-base:1.1.1.2
	netbsd-10-1-RELEASE:1.1.1.2
	netbsd-9-4-RELEASE:1.1.1.1
	netbsd-10-0-RELEASE:1.1.1.2
	netbsd-10-0-RC6:1.1.1.2
	netbsd-10-0-RC5:1.1.1.2
	netbsd-10-0-RC4:1.1.1.2
	netbsd-10-0-RC3:1.1.1.2
	netbsd-10-0-RC2:1.1.1.2
	netbsd-10-0-RC1:1.1.1.2
	netbsd-10:1.1.1.2.0.2
	netbsd-10-base:1.1.1.2
	netbsd-9-3-RELEASE:1.1.1.1
	mesa-21-3-7:1.1.1.2
	netbsd-9-2-RELEASE:1.1.1.1
	netbsd-9-1-RELEASE:1.1.1.1
	netbsd-9-0-RELEASE:1.1.1.1
	netbsd-9-0-RC2:1.1.1.1
	netbsd-9-0-RC1:1.1.1.1
	mesalib-19-1-7:1.1.1.1
	netbsd-9:1.1.1.1.0.2
	netbsd-9-base:1.1.1.1
	mesa-18-3-6:1.1.1.1
	mesa-18-3-4:1.1.1.1
	xorg:1.1.1;
locks; strict;
comment	@// @;


1.1
date	2019.03.10.03.42.45;	author mrg;	state Exp;
branches
	1.1.1.1;
next	;
commitid	r12jo1Nf3ebQKLeB;

1.1.1.1
date	2019.03.10.03.42.45;	author mrg;	state Exp;
branches;
next	1.1.1.2;
commitid	r12jo1Nf3ebQKLeB;

1.1.1.2
date	2022.05.09.01.23.34;	author mrg;	state Exp;
branches;
next	;
commitid	UEBs6hNk81DdQjDD;


desc
@@


1.1
log
@Initial revision
@
text
@/****************************************************************************
 * Copyright (C) 2016 Intel Corporation.   All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 * IN THE SOFTWARE.
 ***************************************************************************/

#include "memory/InitMemory.h"
#include "util/u_cpu_detect.h"
#include "util/u_dl.h"
#include "swr_public.h"
#include "swr_screen.h"

#include <stdio.h>

// Helper function to resolve the backend filename based on architecture
static bool
swr_initialize_screen_interface(struct swr_screen *screen, const char arch[])
{
#ifdef HAVE_SWR_BUILTIN
   screen->pLibrary = NULL;
   screen->pfnSwrGetInterface = SwrGetInterface;
   InitTilesTable();
   fprintf(stderr, "(using: builtin).\n");
#else
   char filename[256] = { 0 };
   sprintf(filename, "%sswr%s%s", UTIL_DL_PREFIX, arch, UTIL_DL_EXT);

   screen->pLibrary = util_dl_open(filename);
   if (!screen->pLibrary) {
      fprintf(stderr, "(skipping: %s).\n", util_dl_error());
      return false;
   }

   util_dl_proc pApiProc = util_dl_get_proc_address(screen->pLibrary,
      "SwrGetInterface");
   util_dl_proc pInitFunc = util_dl_get_proc_address(screen->pLibrary,
      "InitTilesTable");
   if (!pApiProc || !pInitFunc) {
      fprintf(stderr, "(skipping: %s).\n", util_dl_error());
      util_dl_close(screen->pLibrary);
      screen->pLibrary = NULL;
      return false;
   }

   screen->pfnSwrGetInterface = (PFNSwrGetInterface)pApiProc;
   pInitFunc();

   fprintf(stderr, "(using: %s).\n", filename);
#endif
   return true;
}


struct pipe_screen *
swr_create_screen(struct sw_winsys *winsys)
{
   struct pipe_screen *p_screen = swr_create_screen_internal(winsys);
   if (!p_screen) {
      return NULL;
   }

   struct swr_screen *screen = swr_screen(p_screen);
   screen->is_knl = false;

   util_cpu_detect();

   if (util_cpu_caps.has_avx512f && util_cpu_caps.has_avx512er) {
      fprintf(stderr, "SWR detected KNL instruction support ");
#ifndef HAVE_SWR_KNL
      fprintf(stderr, "(skipping: not built).\n");
#else
      if (swr_initialize_screen_interface(screen, "KNL")) {
         screen->is_knl = true;
         return p_screen;
      }
#endif
   }

   if (util_cpu_caps.has_avx512f && util_cpu_caps.has_avx512bw) {
      fprintf(stderr, "SWR detected SKX instruction support ");
#ifndef HAVE_SWR_SKX
      fprintf(stderr, "(skipping not built).\n");
#else
      if (swr_initialize_screen_interface(screen, "SKX"))
         return p_screen;
#endif
   }

   if (util_cpu_caps.has_avx2) {
      fprintf(stderr, "SWR detected AVX2 instruction support ");
#ifndef HAVE_SWR_AVX2
      fprintf(stderr, "(skipping not built).\n");
#else
      if (swr_initialize_screen_interface(screen, "AVX2"))
         return p_screen;
#endif
   }

   if (util_cpu_caps.has_avx) {
      fprintf(stderr, "SWR detected AVX instruction support ");
#ifndef HAVE_SWR_AVX
      fprintf(stderr, "(skipping not built).\n");
#else
      if (swr_initialize_screen_interface(screen, "AVX"))
         return p_screen;
#endif
   }

   fprintf(stderr, "SWR could not initialize a supported CPU architecture.\n");
   swr_destroy_screen_internal(&screen);

   return NULL;
}


#ifdef _WIN32
// swap function called from libl_gdi.c

void
swr_gdi_swap(struct pipe_screen *screen,
             struct pipe_resource *res,
             void *hDC)
{
   screen->flush_frontbuffer(screen,
                             res,
                             0, 0,
                             hDC,
                             NULL);
}

#endif /* _WIN32 */
@


1.1.1.1
log
@from maya:

Import mesa 18.3.4.

Mesa 18.3.4 implements the OpenGL 4.5 API.
Some drivers don't support all the features required in OpenGL 4.5.
@
text
@@


1.1.1.2
log
@initial import of mesa 21.3.7

main changes since 19.1.7 include:
- more support for Vulkan functions
- better supported for newer radeonsi (both amdgpu and radeon backends)
- various bug fixes in many drivers
- many fixes and enhancements for intel drivers
- some fixes for nvidia
- OpenGL 4.6 for some drivers (intel, radeonsi)
- intel Tigerlake and Rocketlake support
- Vulkan 1.2 for some drivers
- OpenGL 4.5, GLES 3.2, and more on llvmpipe
- working Panfrost and Midgard drivers
- fix warnings in radeonsi vs newer llvm
@
text
@a38 1
   screen->pfnSwrGetTileInterface = SwrGetTileIterface;
d40 1
a40 1
   swr_print_info("(using: builtin).\n");
a52 2
   util_dl_proc pTileApiProc = util_dl_get_proc_address(screen->pLibrary,
      "SwrGetTileIterface");
d55 1
a55 1
   if (!pApiProc || !pInitFunc || !pTileApiProc) {
a62 6
   screen->pfnSwrGetTileInterface = (PFNSwrGetTileInterface)pTileApiProc;

   SWR_ASSERT(screen->pfnSwrGetInterface != nullptr);
   SWR_ASSERT(screen->pfnSwrGetTileInterface != nullptr);
   SWR_ASSERT(pInitFunc != nullptr);

d65 1
a65 1
   swr_print_info("(using: %s).\n", filename);
a66 1

d84 2
a85 2
   if (util_get_cpu_caps()->has_avx512f && util_get_cpu_caps()->has_avx512er) {
      swr_print_info("SWR detected KNL instruction support ");
d87 1
a87 1
      swr_print_info("(skipping: not built).\n");
d96 2
a97 2
   if (util_get_cpu_caps()->has_avx512f && util_get_cpu_caps()->has_avx512bw) {
      swr_print_info("SWR detected SKX instruction support ");
d99 1
a99 1
      swr_print_info("(skipping not built).\n");
d106 2
a107 2
   if (util_get_cpu_caps()->has_avx2) {
      swr_print_info("SWR detected AVX2 instruction support ");
d109 1
a109 1
      swr_print_info("(skipping not built).\n");
d116 2
a117 2
   if (util_get_cpu_caps()->has_avx) {
      swr_print_info("SWR detected AVX instruction support ");
d119 1
a119 1
      swr_print_info("(skipping not built).\n");
a137 1
             struct pipe_context *ctx,
a141 1
                             ctx,
@

