diff options
Diffstat (limited to 'repo/mesa')
-rw-r--r-- | repo/mesa/0001-freedreno-Enable-A619.patch | 37 | ||||
-rw-r--r-- | repo/mesa/add-use-elf-tls.patch | 29 | ||||
-rw-r--r-- | repo/mesa/mesa-21.3.7-add_xdemos-1.patch | 3197 | ||||
-rw-r--r-- | repo/mesa/mesa-21.3.7-nouveau_fixes-1.patch | 2878 | ||||
-rw-r--r-- | repo/mesa/mesa.xibuild | 13 | ||||
-rw-r--r-- | repo/mesa/musl-fix-includes.patch | 13 |
6 files changed, 42 insertions, 6125 deletions
diff --git a/repo/mesa/0001-freedreno-Enable-A619.patch b/repo/mesa/0001-freedreno-Enable-A619.patch new file mode 100644 index 0000000..e815b69 --- /dev/null +++ b/repo/mesa/0001-freedreno-Enable-A619.patch @@ -0,0 +1,37 @@ +From 6366f2452865ccc7103211b8e6d8ad9e65c6a95e Mon Sep 17 00:00:00 2001 +From: Konrad Dybcio <konrad.dybcio@somainline.org> +Date: Sun, 10 Oct 2021 20:16:12 +0200 +Subject: [PATCH] freedreno: Enable A619 + +Enable A619 as found in various SKUs of the SM Lagoon SoC, such as SM6350 and +SM7225. + +Signed-off-by: Konrad Dybcio <konrad.dybcio@somainline.org> +--- + src/freedreno/common/freedreno_devices.py | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/freedreno/common/freedreno_devices.py b/src/freedreno/common/freedreno_devices.py +index e13b5c6c2c1..e2d311c0d74 100644 +--- a/src/freedreno/common/freedreno_devices.py ++++ b/src/freedreno/common/freedreno_devices.py +@@ -202,7 +202,7 @@ add_gpus([ + # info parameters are keyed to the sub-generation. These templates reduce + # the copypaste + +-# a615, a618, a630: ++# a615, a616, a618, a619 and a630: + a6xx_gen1 = dict( + fibers_per_sp = 128 * 16, + reg_size_vec4 = 96, +@@ -267,6 +267,7 @@ a6xx_gen4 = dict( + add_gpus([ + GPUId(615), + GPUId(618), ++ GPUId(619), + ], A6xxGPUInfo( + a6xx_gen1, + num_sp_cores = 1, +-- +2.30.1 (Apple Git-130) + diff --git a/repo/mesa/add-use-elf-tls.patch b/repo/mesa/add-use-elf-tls.patch deleted file mode 100644 index 629c5ac..0000000 --- a/repo/mesa/add-use-elf-tls.patch +++ /dev/null @@ -1,29 +0,0 @@ -diff --git a/meson.build b/meson.build -index e1e94e7..b355f94 100644 ---- a/meson.build -+++ b/meson.build -@@ -447,7 +447,9 @@ endif - - # Android uses emutls for versions <= P/28. For USE_ELF_TLS we need ELF TLS. - use_elf_tls = false --if (not ['freebsd', 'openbsd', 'haiku'].contains(host_machine.system()) and -+with_use_elf_tls = get_option('use-elf-tls') -+if with_use_elf_tls and -+ (not ['freebsd', 'openbsd', 'haiku'].contains(host_machine.system()) and - (not with_platform_android or get_option('platform-sdk-version') >= 29) and - (not with_platform_windows or not with_shared_glapi)) - pre_args += '-DUSE_ELF_TLS' -diff --git a/meson_options.txt b/meson_options.txt -index a7030ab..73bd28e 100644 ---- a/meson_options.txt -+++ b/meson_options.txt -@@ -465,3 +465,9 @@ option( - value : true, - description : 'use msse2 flag for mingw x86. Default: true', - ) -+option( -+ 'use-elf-tls', -+ type : 'boolean', -+ value : false, -+ description : 'Build support for initial-exec TLS model' -+) diff --git a/repo/mesa/mesa-21.3.7-add_xdemos-1.patch b/repo/mesa/mesa-21.3.7-add_xdemos-1.patch deleted file mode 100644 index 6b41e57..0000000 --- a/repo/mesa/mesa-21.3.7-add_xdemos-1.patch +++ /dev/null @@ -1,3197 +0,0 @@ -Submitted By: DJ Lucas <dj@linuxfromscratch.org> - based on previous patches submitted - by Armin K and Fernando de Oliveira -Date: 2020-10-16 -Initial Package Version: 19.0.4 -Upstream Status: Not applicable. -Origin: Self. -Description: This patch adds two OpenGL demos, glxinfo and - glxgears and respective man pages. - -diff -Naurp mesa-20.2.1-orig/src/glx/meson.build mesa-20.2.1/src/glx/meson.build ---- mesa-20.2.1-orig/src/glx/meson.build 2020-10-14 12:19:10.623185200 -0500 -+++ mesa-20.2.1/src/glx/meson.build 2020-10-15 23:06:45.823362439 -0500 -@@ -165,6 +165,8 @@ libgl = shared_library( - install : true, - ) - -+subdir('xdemos') -+ - if with_tests - subdir('tests') - endif -diff -Naurp mesa-20.2.1-orig/src/glx/xdemos/glinfo_common.c mesa-20.2.1/src/glx/xdemos/glinfo_common.c ---- mesa-20.2.1-orig/src/glx/xdemos/glinfo_common.c 1969-12-31 18:00:00.000000000 -0600 -+++ mesa-20.2.1/src/glx/xdemos/glinfo_common.c 2020-10-15 23:06:45.826695773 -0500 -@@ -0,0 +1,800 @@ -+/* -+ * Copyright (C) 1999-2014 Brian Paul 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 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 -+ * BRIAN PAUL 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 <assert.h> -+#include <ctype.h> -+#include <stdio.h> -+#include <stdlib.h> -+#include <string.h> -+#include "glinfo_common.h" -+ -+#ifdef _WIN32 -+#define snprintf _snprintf -+#endif -+ -+ -+/** -+ * Return the GL enum name for a numeric value. -+ * We really only care about the compressed texture formats for now. -+ */ -+static const char * -+enum_name(GLenum val) -+{ -+ static const struct { -+ const char *name; -+ GLenum val; -+ } enums [] = { -+ { "GL_COMPRESSED_ALPHA", 0x84E9 }, -+ { "GL_COMPRESSED_LUMINANCE", 0x84EA }, -+ { "GL_COMPRESSED_LUMINANCE_ALPHA", 0x84EB }, -+ { "GL_COMPRESSED_INTENSITY", 0x84EC }, -+ { "GL_COMPRESSED_RGB", 0x84ED }, -+ { "GL_COMPRESSED_RGBA", 0x84EE }, -+ { "GL_COMPRESSED_TEXTURE_FORMATS", 0x86A3 }, -+ { "GL_COMPRESSED_RGB", 0x84ED }, -+ { "GL_COMPRESSED_RGBA", 0x84EE }, -+ { "GL_COMPRESSED_TEXTURE_FORMATS", 0x86A3 }, -+ { "GL_COMPRESSED_ALPHA", 0x84E9 }, -+ { "GL_COMPRESSED_LUMINANCE", 0x84EA }, -+ { "GL_COMPRESSED_LUMINANCE_ALPHA", 0x84EB }, -+ { "GL_COMPRESSED_INTENSITY", 0x84EC }, -+ { "GL_COMPRESSED_SRGB", 0x8C48 }, -+ { "GL_COMPRESSED_SRGB_ALPHA", 0x8C49 }, -+ { "GL_COMPRESSED_SLUMINANCE", 0x8C4A }, -+ { "GL_COMPRESSED_SLUMINANCE_ALPHA", 0x8C4B }, -+ { "GL_COMPRESSED_RED", 0x8225 }, -+ { "GL_COMPRESSED_RG", 0x8226 }, -+ { "GL_COMPRESSED_RED_RGTC1", 0x8DBB }, -+ { "GL_COMPRESSED_SIGNED_RED_RGTC1", 0x8DBC }, -+ { "GL_COMPRESSED_RG_RGTC2", 0x8DBD }, -+ { "GL_COMPRESSED_SIGNED_RG_RGTC2", 0x8DBE }, -+ { "GL_COMPRESSED_RGB8_ETC2", 0x9274 }, -+ { "GL_COMPRESSED_SRGB8_ETC2", 0x9275 }, -+ { "GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2", 0x9276 }, -+ { "GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2", 0x9277 }, -+ { "GL_COMPRESSED_RGBA8_ETC2_EAC", 0x9278 }, -+ { "GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", 0x9279 }, -+ { "GL_COMPRESSED_R11_EAC", 0x9270 }, -+ { "GL_COMPRESSED_SIGNED_R11_EAC", 0x9271 }, -+ { "GL_COMPRESSED_RG11_EAC", 0x9272 }, -+ { "GL_COMPRESSED_SIGNED_RG11_EAC", 0x9273 }, -+ { "GL_COMPRESSED_ALPHA_ARB", 0x84E9 }, -+ { "GL_COMPRESSED_LUMINANCE_ARB", 0x84EA }, -+ { "GL_COMPRESSED_LUMINANCE_ALPHA_ARB", 0x84EB }, -+ { "GL_COMPRESSED_INTENSITY_ARB", 0x84EC }, -+ { "GL_COMPRESSED_RGB_ARB", 0x84ED }, -+ { "GL_COMPRESSED_RGBA_ARB", 0x84EE }, -+ { "GL_COMPRESSED_TEXTURE_FORMATS_ARB", 0x86A3 }, -+ { "GL_COMPRESSED_RGBA_BPTC_UNORM_ARB", 0x8E8C }, -+ { "GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB", 0x8E8D }, -+ { "GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB", 0x8E8E }, -+ { "GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB", 0x8E8F }, -+ { "GL_COMPRESSED_RGBA_ASTC_4x4_KHR", 0x93B0 }, -+ { "GL_COMPRESSED_RGBA_ASTC_5x4_KHR", 0x93B1 }, -+ { "GL_COMPRESSED_RGBA_ASTC_5x5_KHR", 0x93B2 }, -+ { "GL_COMPRESSED_RGBA_ASTC_6x5_KHR", 0x93B3 }, -+ { "GL_COMPRESSED_RGBA_ASTC_6x6_KHR", 0x93B4 }, -+ { "GL_COMPRESSED_RGBA_ASTC_8x5_KHR", 0x93B5 }, -+ { "GL_COMPRESSED_RGBA_ASTC_8x6_KHR", 0x93B6 }, -+ { "GL_COMPRESSED_RGBA_ASTC_8x8_KHR", 0x93B7 }, -+ { "GL_COMPRESSED_RGBA_ASTC_10x5_KHR", 0x93B8 }, -+ { "GL_COMPRESSED_RGBA_ASTC_10x6_KHR", 0x93B9 }, -+ { "GL_COMPRESSED_RGBA_ASTC_10x8_KHR", 0x93BA }, -+ { "GL_COMPRESSED_RGBA_ASTC_10x10_KHR", 0x93BB }, -+ { "GL_COMPRESSED_RGBA_ASTC_12x10_KHR", 0x93BC }, -+ { "GL_COMPRESSED_RGBA_ASTC_12x12_KHR", 0x93BD }, -+ { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR", 0x93D0 }, -+ { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR", 0x93D1 }, -+ { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR", 0x93D2 }, -+ { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR", 0x93D3 }, -+ { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR", 0x93D4 }, -+ { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR", 0x93D5 }, -+ { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR", 0x93D6 }, -+ { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR", 0x93D7 }, -+ { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR", 0x93D8 }, -+ { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR", 0x93D9 }, -+ { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR", 0x93DA }, -+ { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR", 0x93DB }, -+ { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR", 0x93DC }, -+ { "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR", 0x93DD }, -+ { "GL_COMPRESSED_RGB_FXT1_3DFX", 0x86B0 }, -+ { "GL_COMPRESSED_RGBA_FXT1_3DFX", 0x86B1 }, -+ { "GL_COMPRESSED_LUMINANCE_LATC1_EXT", 0x8C70 }, -+ { "GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT", 0x8C71 }, -+ { "GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT", 0x8C72 }, -+ { "GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT", 0x8C73 }, -+ { "GL_COMPRESSED_RED_RGTC1_EXT", 0x8DBB }, -+ { "GL_COMPRESSED_SIGNED_RED_RGTC1_EXT", 0x8DBC }, -+ { "GL_COMPRESSED_RED_GREEN_RGTC2_EXT", 0x8DBD }, -+ { "GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT", 0x8DBE }, -+ { "GL_COMPRESSED_RGB_S3TC_DXT1_EXT", 0x83F0 }, -+ { "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT", 0x83F1 }, -+ { "GL_COMPRESSED_RGBA_S3TC_DXT3_EXT", 0x83F2 }, -+ { "GL_COMPRESSED_RGBA_S3TC_DXT5_EXT", 0x83F3 }, -+ { "GL_COMPRESSED_SRGB_EXT", 0x8C48 }, -+ { "GL_COMPRESSED_SRGB_ALPHA_EXT", 0x8C49 }, -+ { "GL_COMPRESSED_SLUMINANCE_EXT", 0x8C4A }, -+ { "GL_COMPRESSED_SLUMINANCE_ALPHA_EXT", 0x8C4B }, -+ { "GL_COMPRESSED_SRGB_S3TC_DXT1_EXT", 0x8C4C }, -+ { "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT", 0x8C4D }, -+ { "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT", 0x8C4E }, -+ { "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT", 0x8C4F }, -+ { "GL_PALETTE4_RGB8_OES", 0x8B90 }, -+ { "GL_PALETTE4_RGBA8_OES", 0x8B91 }, -+ { "GL_PALETTE4_R5_G6_B5_OES", 0x8B92 }, -+ { "GL_PALETTE4_RGBA4_OES", 0x8B93 }, -+ { "GL_PALETTE4_RGB5_A1_OES", 0x8B94 }, -+ { "GL_PALETTE8_RGB8_OES", 0x8B95 }, -+ { "GL_PALETTE8_RGBA8_OES", 0x8B96 }, -+ { "GL_PALETTE8_R5_G6_B5_OES", 0x8B97 }, -+ { "GL_PALETTE8_RGBA4_OES", 0x8B98 }, -+ { "GL_PALETTE8_RGB5_A1_OES", 0x8B99 } -+ }; -+ const int n = sizeof(enums) / sizeof(enums[0]); -+ static char buffer[100]; -+ int i; -+ for (i = 0; i < n; i++) { -+ if (enums[i].val == val) { -+ return enums[i].name; -+ } -+ } -+ /* enum val not found, just print hexadecimal value into static buffer */ -+ snprintf(buffer, sizeof(buffer), "0x%x", val); -+ return buffer; -+} -+ -+ -+/* -+ * qsort callback for string comparison. -+ */ -+static int -+compare_string_ptr(const void *p1, const void *p2) -+{ -+ return strcmp(* (char * const *) p1, * (char * const *) p2); -+} -+ -+/* -+ * Print a list of extensions, with word-wrapping. -+ */ -+void -+print_extension_list(const char *ext, GLboolean singleLine) -+{ -+ char **extensions; -+ int num_extensions; -+ const char *indentString = " "; -+ const int indent = 4; -+ const int max = 79; -+ int width, i, j, k; -+ -+ if (!ext || !ext[0]) -+ return; -+ -+ /* count the number of extensions, ignoring successive spaces */ -+ num_extensions = 0; -+ j = 1; -+ do { -+ if ((ext[j] == ' ' || ext[j] == 0) && ext[j - 1] != ' ') { -+ ++num_extensions; -+ } -+ } while(ext[j++]); -+ -+ /* copy individual extensions to an array */ -+ extensions = malloc(num_extensions * sizeof *extensions); -+ if (!extensions) { -+ fprintf(stderr, "Error: malloc() failed\n"); -+ exit(1); -+ } -+ i = j = k = 0; -+ while (1) { -+ if (ext[j] == ' ' || ext[j] == 0) { -+ /* found end of an extension name */ -+ const int len = j - i; -+ -+ if (len) { -+ assert(k < num_extensions); -+ -+ extensions[k] = malloc(len + 1); -+ if (!extensions[k]) { -+ fprintf(stderr, "Error: malloc() failed\n"); -+ exit(1); -+ } -+ -+ memcpy(extensions[k], ext + i, len); -+ extensions[k][len] = 0; -+ -+ ++k; -+ }; -+ -+ i += len + 1; -+ -+ if (ext[j] == 0) { -+ break; -+ } -+ } -+ j++; -+ } -+ assert(k == num_extensions); -+ -+ /* sort extensions alphabetically */ -+ qsort(extensions, num_extensions, sizeof extensions[0], compare_string_ptr); -+ -+ /* print the extensions */ -+ width = indent; -+ printf("%s", indentString); -+ for (k = 0; k < num_extensions; ++k) { -+ const int len = strlen(extensions[k]); -+ if ((!singleLine) && (width + len > max)) { -+ /* start a new line */ -+ printf("\n"); -+ width = indent; -+ printf("%s", indentString); -+ } -+ /* print the extension name */ -+ printf("%s", extensions[k]); -+ -+ /* either we're all done, or we'll continue with next extension */ -+ width += len + 1; -+ -+ if (singleLine) { -+ printf("\n"); -+ width = indent; -+ printf("%s", indentString); -+ } -+ else if (k < (num_extensions -1)) { -+ printf(", "); -+ width += 2; -+ } -+ } -+ printf("\n"); -+ -+ for (k = 0; k < num_extensions; ++k) { -+ free(extensions[k]); -+ } -+ free(extensions); -+} -+ -+ -+ -+ -+/** -+ * Get list of OpenGL extensions using core profile's glGetStringi(). -+ */ -+char * -+build_core_profile_extension_list(const struct ext_functions *extfuncs) -+{ -+ GLint i, n, totalLen; -+ char *buffer; -+ -+ glGetIntegerv(GL_NUM_EXTENSIONS, &n); -+ -+ /* compute totalLen */ -+ totalLen = 0; -+ for (i = 0; i < n; i++) { -+ const char *ext = (const char *) extfuncs->GetStringi(GL_EXTENSIONS, i); -+ if (ext) -+ totalLen += strlen(ext) + 1; /* plus a space */ -+ } -+ -+ if (!totalLen) -+ return NULL; -+ -+ buffer = malloc(totalLen + 1); -+ if (buffer) { -+ int pos = 0; -+ for (i = 0; i < n; i++) { -+ const char *ext = (const char *) extfuncs->GetStringi(GL_EXTENSIONS, i); -+ strcpy(buffer + pos, ext); -+ pos += strlen(ext); -+ buffer[pos++] = ' '; -+ } -+ buffer[pos] = '\0'; -+ } -+ return buffer; -+} -+ -+ -+/** Is extension 'ext' supported? */ -+GLboolean -+extension_supported(const char *ext, const char *extensionsList) -+{ -+ while (1) { -+ const char *p = strstr(extensionsList, ext); -+ if (p) { -+ /* check that next char is a space or end of string */ -+ int extLen = strlen(ext); -+ if (p[extLen] == 0 || p[extLen] == ' ') { -+ return 1; -+ } -+ else { -+ /* We found a superset string, keep looking */ -+ extensionsList += extLen; -+ } -+ } -+ else { -+ break; -+ } -+ } -+ return 0; -+} -+ -+ -+/** -+ * Is verNum >= verString? -+ * \param verString such as "2.1", "3.0", etc. -+ * \param verNum such as 20, 21, 30, 31, 32, etc. -+ */ -+static GLboolean -+version_supported(const char *verString, int verNum) -+{ -+ int v; -+ -+ if (!verString || -+ !isdigit(verString[0]) || -+ verString[1] != '.' || -+ !isdigit(verString[2])) { -+ return GL_FALSE; -+ } -+ -+ v = (verString[0] - '0') * 10 + (verString[2] - '0'); -+ -+ return verNum >= v; -+} -+ -+ -+struct token_name -+{ -+ GLenum token; -+ const char *name; -+}; -+ -+ -+static void -+print_shader_limit_list(const struct token_name *lim) -+{ -+ GLint max[1]; -+ unsigned i; -+ -+ for (i = 0; lim[i].token; i++) { -+ glGetIntegerv(lim[i].token, max); -+ if (glGetError() == GL_NO_ERROR) { -+ printf(" %s = %d\n", lim[i].name, max[0]); -+ } -+ } -+} -+ -+ -+/** -+ * Print interesting limits for vertex/fragment shaders. -+ */ -+static void -+print_shader_limits(GLenum target) -+{ -+ static const struct token_name vertex_limits[] = { -+ { GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB" }, -+ { GL_MAX_VARYING_FLOATS_ARB, "GL_MAX_VARYING_FLOATS_ARB" }, -+ { GL_MAX_VERTEX_ATTRIBS_ARB, "GL_MAX_VERTEX_ATTRIBS_ARB" }, -+ { GL_MAX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_TEXTURE_IMAGE_UNITS_ARB" }, -+ { GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB" }, -+ { GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB" }, -+ { GL_MAX_TEXTURE_COORDS_ARB, "GL_MAX_TEXTURE_COORDS_ARB" }, -+ { GL_MAX_VERTEX_OUTPUT_COMPONENTS , "GL_MAX_VERTEX_OUTPUT_COMPONENTS " }, -+ { (GLenum) 0, NULL } -+ }; -+ static const struct token_name fragment_limits[] = { -+ { GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB, "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB" }, -+ { GL_MAX_TEXTURE_COORDS_ARB, "GL_MAX_TEXTURE_COORDS_ARB" }, -+ { GL_MAX_TEXTURE_IMAGE_UNITS_ARB, "GL_MAX_TEXTURE_IMAGE_UNITS_ARB" }, -+ { GL_MAX_FRAGMENT_INPUT_COMPONENTS , "GL_MAX_FRAGMENT_INPUT_COMPONENTS " }, -+ { (GLenum) 0, NULL } -+ }; -+ static const struct token_name geometry_limits[] = { -+ { GL_MAX_GEOMETRY_UNIFORM_COMPONENTS, "GL_MAX_GEOMETRY_UNIFORM_COMPONENTS" }, -+ { GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS, "GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS" }, -+ { GL_MAX_GEOMETRY_OUTPUT_VERTICES , "GL_MAX_GEOMETRY_OUTPUT_VERTICES " }, -+ { GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS, "GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS" }, -+ { GL_MAX_GEOMETRY_INPUT_COMPONENTS , "GL_MAX_GEOMETRY_INPUT_COMPONENTS " }, -+ { GL_MAX_GEOMETRY_OUTPUT_COMPONENTS, "GL_MAX_GEOMETRY_OUTPUT_COMPONENTS" }, -+ { (GLenum) 0, NULL } -+ }; -+ -+ switch (target) { -+ case GL_VERTEX_SHADER: -+ printf(" GL_VERTEX_SHADER_ARB:\n"); -+ print_shader_limit_list(vertex_limits); -+ break; -+ -+ case GL_FRAGMENT_SHADER: -+ printf(" GL_FRAGMENT_SHADER_ARB:\n"); -+ print_shader_limit_list(fragment_limits); -+ break; -+ -+ case GL_GEOMETRY_SHADER: -+ printf(" GL_GEOMETRY_SHADER:\n"); -+ print_shader_limit_list(geometry_limits); -+ break; -+ } -+} -+ -+ -+/** -+ * Print interesting limits for vertex/fragment programs. -+ */ -+static void -+print_program_limits(GLenum target, -+ const struct ext_functions *extfuncs) -+{ -+#if defined(GL_ARB_vertex_program) || defined(GL_ARB_fragment_program) -+ struct token_name { -+ GLenum token; -+ const char *name; -+ }; -+ static const struct token_name common_limits[] = { -+ { GL_MAX_PROGRAM_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_INSTRUCTIONS_ARB" }, -+ { GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB" }, -+ { GL_MAX_PROGRAM_TEMPORARIES_ARB, "GL_MAX_PROGRAM_TEMPORARIES_ARB" }, -+ { GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB, "GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB" }, -+ { GL_MAX_PROGRAM_PARAMETERS_ARB, "GL_MAX_PROGRAM_PARAMETERS_ARB" }, -+ { GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB, "GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB" }, -+ { GL_MAX_PROGRAM_ATTRIBS_ARB, "GL_MAX_PROGRAM_ATTRIBS_ARB" }, -+ { GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB, "GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB" }, -+ { GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB, "GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB" }, -+ { GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB, "GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB" }, -+ { GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB, "GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB" }, -+ { GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, "GL_MAX_PROGRAM_ENV_PARAMETERS_ARB" }, -+ { (GLenum) 0, NULL } -+ }; -+ static const struct token_name fragment_limits[] = { -+ { GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB" }, -+ { GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB" }, -+ { GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB, "GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB" }, -+ { GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB" }, -+ { GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB" }, -+ { GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB, "GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB" }, -+ { (GLenum) 0, NULL } -+ }; -+ -+ GLint max[1]; -+ int i; -+ -+ if (target == GL_VERTEX_PROGRAM_ARB) { -+ printf(" GL_VERTEX_PROGRAM_ARB:\n"); -+ } -+ else if (target == GL_FRAGMENT_PROGRAM_ARB) { -+ printf(" GL_FRAGMENT_PROGRAM_ARB:\n"); -+ } -+ else { -+ return; /* something's wrong */ -+ } -+ -+ for (i = 0; common_limits[i].token; i++) { -+ extfuncs->GetProgramivARB(target, common_limits[i].token, max); -+ if (glGetError() == GL_NO_ERROR) { -+ printf(" %s = %d\n", common_limits[i].name, max[0]); -+ } -+ } -+ if (target == GL_FRAGMENT_PROGRAM_ARB) { -+ for (i = 0; fragment_limits[i].token; i++) { -+ extfuncs->GetProgramivARB(target, fragment_limits[i].token, max); -+ if (glGetError() == GL_NO_ERROR) { -+ printf(" %s = %d\n", fragment_limits[i].name, max[0]); -+ } -+ } -+ } -+#endif /* GL_ARB_vertex_program / GL_ARB_fragment_program */ -+} -+ -+ -+/** -+ * Print interesting OpenGL implementation limits. -+ * \param version 20, 21, 30, 31, 32, etc. -+ */ -+void -+print_limits(const char *extensions, const char *oglstring, int version, -+ const struct ext_functions *extfuncs) -+{ -+ struct token_name { -+ GLuint count; -+ GLenum token; -+ const char *name; -+ const char *extension; /* NULL or GL extension name or version string */ -+ }; -+ static const struct token_name limits[] = { -+ { 1, GL_MAX_ATTRIB_STACK_DEPTH, "GL_MAX_ATTRIB_STACK_DEPTH", NULL }, -+ { 1, GL_MAX_CLIENT_ATTRIB_STACK_DEPTH, "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH", NULL }, -+ { 1, GL_MAX_CLIP_PLANES, "GL_MAX_CLIP_PLANES", NULL }, -+ { 1, GL_MAX_COLOR_MATRIX_STACK_DEPTH, "GL_MAX_COLOR_MATRIX_STACK_DEPTH", "GL_ARB_imaging" }, -+ { 1, GL_MAX_ELEMENTS_VERTICES, "GL_MAX_ELEMENTS_VERTICES", NULL }, -+ { 1, GL_MAX_ELEMENTS_INDICES, "GL_MAX_ELEMENTS_INDICES", NULL }, -+ { 1, GL_MAX_EVAL_ORDER, "GL_MAX_EVAL_ORDER", NULL }, -+ { 1, GL_MAX_LIGHTS, "GL_MAX_LIGHTS", NULL }, -+ { 1, GL_MAX_LIST_NESTING, "GL_MAX_LIST_NESTING", NULL }, -+ { 1, GL_MAX_MODELVIEW_STACK_DEPTH, "GL_MAX_MODELVIEW_STACK_DEPTH", NULL }, -+ { 1, GL_MAX_NAME_STACK_DEPTH, "GL_MAX_NAME_STACK_DEPTH", NULL }, -+ { 1, GL_MAX_PIXEL_MAP_TABLE, "GL_MAX_PIXEL_MAP_TABLE", NULL }, -+ { 1, GL_MAX_PROJECTION_STACK_DEPTH, "GL_MAX_PROJECTION_STACK_DEPTH", NULL }, -+ { 1, GL_MAX_TEXTURE_STACK_DEPTH, "GL_MAX_TEXTURE_STACK_DEPTH", NULL }, -+ { 1, GL_MAX_TEXTURE_SIZE, "GL_MAX_TEXTURE_SIZE", NULL }, -+ { 1, GL_MAX_3D_TEXTURE_SIZE, "GL_MAX_3D_TEXTURE_SIZE", NULL }, -+#if defined(GL_EXT_texture_array) -+ { 1, GL_MAX_ARRAY_TEXTURE_LAYERS_EXT, "GL_MAX_ARRAY_TEXTURE_LAYERS", "GL_EXT_texture_array" }, -+#endif -+ { 2, GL_MAX_VIEWPORT_DIMS, "GL_MAX_VIEWPORT_DIMS", NULL }, -+ { 2, GL_ALIASED_LINE_WIDTH_RANGE, "GL_ALIASED_LINE_WIDTH_RANGE", NULL }, -+ { 2, GL_SMOOTH_LINE_WIDTH_RANGE, "GL_SMOOTH_LINE_WIDTH_RANGE", NULL }, -+ { 2, GL_ALIASED_POINT_SIZE_RANGE, "GL_ALIASED_POINT_SIZE_RANGE", NULL }, -+ { 2, GL_SMOOTH_POINT_SIZE_RANGE, "GL_SMOOTH_POINT_SIZE_RANGE", NULL }, -+#if defined(GL_ARB_texture_cube_map) -+ { 1, GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB", "GL_ARB_texture_cube_map" }, -+#endif -+#if defined(GL_NV_texture_rectangle) -+ { 1, GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, "GL_MAX_RECTANGLE_TEXTURE_SIZE_NV", "GL_NV_texture_rectangle" }, -+#endif -+#if defined(GL_ARB_multitexture) -+ { 1, GL_MAX_TEXTURE_UNITS_ARB, "GL_MAX_TEXTURE_UNITS_ARB", "GL_ARB_multitexture" }, -+#endif -+#if defined(GL_EXT_texture_lod_bias) -+ { 1, GL_MAX_TEXTURE_LOD_BIAS_EXT, "GL_MAX_TEXTURE_LOD_BIAS_EXT", "GL_EXT_texture_lod_bias" }, -+#endif -+#if defined(GL_EXT_texture_filter_anisotropic) -+ { 1, GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT", "GL_EXT_texture_filter_anisotropic" }, -+#endif -+#if defined(GL_ARB_draw_buffers) -+ { 1, GL_MAX_DRAW_BUFFERS_ARB, "GL_MAX_DRAW_BUFFERS_ARB", "GL_ARB_draw_buffers" }, -+#endif -+#if defined(GL_ARB_blend_func_extended) -+ { 1, GL_MAX_DUAL_SOURCE_DRAW_BUFFERS, "GL_MAX_DUAL_SOURCE_DRAW_BUFFERS", "GL_ARB_blend_func_extended" }, -+#endif -+#if defined (GL_ARB_framebuffer_object) -+ { 1, GL_MAX_RENDERBUFFER_SIZE, "GL_MAX_RENDERBUFFER_SIZE", "GL_ARB_framebuffer_object" }, -+ { 1, GL_MAX_COLOR_ATTACHMENTS, "GL_MAX_COLOR_ATTACHMENTS", "GL_ARB_framebuffer_object" }, -+ { 1, GL_MAX_SAMPLES, "GL_MAX_SAMPLES", "GL_ARB_framebuffer_object" }, -+#endif -+#if defined (GL_EXT_transform_feedback) -+ { 1, GL_MAX_TRANSFORM_FEEDBACK_BUFFERS, "GL_MAX_TRANSFORM_FEEDBACK_BUFFERS", "GL_EXT_transform_feedback" }, -+ { 1, GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT, "GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS", "GL_EXT_transform_feedback" }, -+ { 1, GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT, "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS", "GL_EXT_transform_feedback", }, -+ { 1, GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT, "GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS", "GL_EXT_transform_feedback" }, -+#endif -+#if defined (GL_ARB_texture_buffer_object) -+ { 1, GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT, "GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT", "GL_ARB_texture_buffer_object" }, -+ { 1, GL_MAX_TEXTURE_BUFFER_SIZE, "GL_MAX_TEXTURE_BUFFER_SIZE", "GL_ARB_texture_buffer_object" }, -+#endif -+#if defined (GL_ARB_texture_multisample) -+ { 1, GL_MAX_COLOR_TEXTURE_SAMPLES, "GL_MAX_COLOR_TEXTURE_SAMPLES", "GL_ARB_texture_multisample" }, -+ { 1, GL_MAX_DEPTH_TEXTURE_SAMPLES, "GL_MAX_DEPTH_TEXTURE_SAMPLES", "GL_ARB_texture_multisample" }, -+ { 1, GL_MAX_INTEGER_SAMPLES, "GL_MAX_INTEGER_SAMPLES", "GL_ARB_texture_multisample" }, -+#endif -+#if defined (GL_ARB_uniform_buffer_object) -+ { 1, GL_MAX_VERTEX_UNIFORM_BLOCKS, "GL_MAX_VERTEX_UNIFORM_BLOCKS", "GL_ARB_uniform_buffer_object" }, -+ { 1, GL_MAX_FRAGMENT_UNIFORM_BLOCKS, "GL_MAX_FRAGMENT_UNIFORM_BLOCKS", "GL_ARB_uniform_buffer_object" }, -+ { 1, GL_MAX_GEOMETRY_UNIFORM_BLOCKS, "GL_MAX_GEOMETRY_UNIFORM_BLOCKS" , "GL_ARB_uniform_buffer_object" }, -+ { 1, GL_MAX_COMBINED_UNIFORM_BLOCKS, "GL_MAX_COMBINED_UNIFORM_BLOCKS", "GL_ARB_uniform_buffer_object" }, -+ { 1, GL_MAX_UNIFORM_BUFFER_BINDINGS, "GL_MAX_UNIFORM_BUFFER_BINDINGS", "GL_ARB_uniform_buffer_object" }, -+ { 1, GL_MAX_UNIFORM_BLOCK_SIZE, "GL_MAX_UNIFORM_BLOCK_SIZE", "GL_ARB_uniform_buffer_object" }, -+ { 1, GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS, "GL_MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS", "GL_ARB_uniform_buffer_object" }, -+ { 1, GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS, "GL_MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS", "GL_ARB_uniform_buffer_object" }, -+ { 1, GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS, "GL_MAX_COMBINED_GEOMETRY_UNIFORM_COMPONENTS", "GL_ARB_uniform_buffer_object" }, -+ { 1, GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, "GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT", "GL_ARB_uniform_buffer_object" }, -+#endif -+#if defined (GL_ARB_vertex_attrib_binding) -+ { 1, GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET, "GL_MAX_VERTEX_ATTRIB_RELATIVE_OFFSET", "GL_ARB_vertex_attrib_binding" }, -+ { 1, GL_MAX_VERTEX_ATTRIB_BINDINGS, "GL_MAX_VERTEX_ATTRIB_BINDINGS", "GL_ARB_vertex_attrib_binding" }, -+#endif -+#if defined(GL_VERSION_4_4) -+ { 1, GL_MAX_VERTEX_ATTRIB_STRIDE, "GL_MAX_VERTEX_ATTRIB_STRIDE", "4.4" }, -+#endif -+ { 0, (GLenum) 0, NULL, NULL } -+ }; -+ GLint i, max[2]; -+ -+ printf("%s limits:\n", oglstring); -+ for (i = 0; limits[i].count; i++) { -+ if (!limits[i].extension || -+ version_supported(limits[i].extension, version) || -+ extension_supported(limits[i].extension, extensions)) { -+ glGetIntegerv(limits[i].token, max); -+ if (glGetError() == GL_NO_ERROR) { -+ if (limits[i].count == 1) -+ printf(" %s = %d\n", limits[i].name, max[0]); -+ else /* XXX fix if we ever query something with more than 2 values */ -+ printf(" %s = %d, %d\n", limits[i].name, max[0], max[1]); -+ } -+ } -+ } -+ -+ /* these don't fit into the above mechanism, unfortunately */ -+ if (extension_supported("GL_ARB_imaging", extensions)) { -+ extfuncs->GetConvolutionParameteriv(GL_CONVOLUTION_2D, -+ GL_MAX_CONVOLUTION_WIDTH, max); -+ extfuncs->GetConvolutionParameteriv(GL_CONVOLUTION_2D, -+ GL_MAX_CONVOLUTION_HEIGHT, max+1); -+ printf(" GL_MAX_CONVOLUTION_WIDTH/HEIGHT = %d, %d\n", max[0], max[1]); -+ } -+ -+ if (extension_supported("GL_ARB_texture_compression", extensions)) { -+ GLint i, n; -+ GLint *formats; -+ glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &n); -+ printf(" GL_NUM_COMPRESSED_TEXTURE_FORMATS = %d\n", n); -+ formats = (GLint *) malloc(n * sizeof(GLint)); -+ glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, formats); -+ for (i = 0; i < n; i++) { -+ printf(" %s\n", enum_name(formats[i])); -+ } -+ free(formats); -+ } -+#if defined(GL_ARB_vertex_program) -+ if (extension_supported("GL_ARB_vertex_program", extensions)) { -+ print_program_limits(GL_VERTEX_PROGRAM_ARB, extfuncs); -+ } -+#endif -+#if defined(GL_ARB_fragment_program) -+ if (extension_supported("GL_ARB_fragment_program", extensions)) { -+ print_program_limits(GL_FRAGMENT_PROGRAM_ARB, extfuncs); -+ } -+#endif -+ if (extension_supported("GL_ARB_vertex_shader", extensions)) { -+ print_shader_limits(GL_VERTEX_SHADER_ARB); -+ } -+ if (extension_supported("GL_ARB_fragment_shader", extensions)) { -+ print_shader_limits(GL_FRAGMENT_SHADER_ARB); -+ } -+ if (version >= 32) { -+ print_shader_limits(GL_GEOMETRY_SHADER); -+ } -+} -+ -+ -+ -+/** -+ * Return string representation for bits in a bitmask. -+ */ -+const char * -+bitmask_to_string(const struct bit_info bits[], int numBits, int mask) -+{ -+ static char buffer[256], *p; -+ int i; -+ -+ strcpy(buffer, "(none)"); -+ p = buffer; -+ for (i = 0; i < numBits; i++) { -+ if (mask & bits[i].bit) { -+ if (p > buffer) -+ *p++ = ','; -+ strcpy(p, bits[i].name); -+ p += strlen(bits[i].name); -+ } -+ } -+ -+ return buffer; -+} -+ -+/** -+ * Return string representation for the bitmask returned by -+ * GL_CONTEXT_PROFILE_MASK (OpenGL 3.2 or later). -+ */ -+const char * -+profile_mask_string(int mask) -+{ -+ const static struct bit_info bits[] = { -+#ifdef GL_CONTEXT_CORE_PROFILE_BIT -+ { GL_CONTEXT_CORE_PROFILE_BIT, "core profile"}, -+#endif -+#ifdef GL_CONTEXT_COMPATIBILITY_PROFILE_BIT -+ { GL_CONTEXT_COMPATIBILITY_PROFILE_BIT, "compatibility profile" } -+#endif -+ }; -+ -+ return bitmask_to_string(bits, ELEMENTS(bits), mask); -+} -+ -+ -+/** -+ * Return string representation for the bitmask returned by -+ * GL_CONTEXT_FLAGS (OpenGL 3.0 or later). -+ */ -+const char * -+context_flags_string(int mask) -+{ -+ const static struct bit_info bits[] = { -+#ifdef GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT -+ { GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT, "forward-compatible" }, -+#endif -+#ifdef GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB -+ { GL_CONTEXT_FLAG_ROBUST_ACCESS_BIT_ARB, "robust-access" }, -+#endif -+ }; -+ -+ return bitmask_to_string(bits, ELEMENTS(bits), mask); -+} -+ -+ -+static void -+usage(void) -+{ -+#ifdef _WIN32 -+ printf("Usage: wglinfo [-v] [-t] [-h] [-b] [-l] [-s]\n"); -+#else -+ printf("Usage: glxinfo [-v] [-t] [-h] [-b] [-l] [-s] [-i] [-display <dname>]\n"); -+ printf("\t-display <dname>: Print GLX visuals on specified server.\n"); -+ printf("\t-i: Force an indirect rendering context.\n"); -+#endif -+ printf("\t-B: brief output, print only the basics.\n"); -+ printf("\t-v: Print visuals info in verbose form.\n"); -+ printf("\t-t: Print verbose table.\n"); -+ printf("\t-h: This information.\n"); -+ printf("\t-b: Find the 'best' visual and print its number.\n"); -+ printf("\t-l: Print interesting OpenGL limits.\n"); -+ printf("\t-s: Print a single extension per line.\n"); -+} -+ -+void -+parse_args(int argc, char *argv[], struct options *options) -+{ -+ int i; -+ -+ options->mode = Normal; -+ options->findBest = GL_FALSE; -+ options->limits = GL_FALSE; -+ options->singleLine = GL_FALSE; -+ options->displayName = NULL; -+ options->allowDirect = GL_TRUE; -+ -+ for (i = 1; i < argc; i++) { -+#ifndef _WIN32 -+ if (strcmp(argv[i], "-display") == 0 && i + 1 < argc) { -+ options->displayName = argv[i + 1]; -+ i++; -+ } -+ else if (strcmp(argv[i], "-i") == 0) { -+ options->allowDirect = GL_FALSE; -+ } -+ else -+#endif -+ if (strcmp(argv[i], "-t") == 0) { -+ options->mode = Wide; -+ } -+ else if (strcmp(argv[i], "-v") == 0) { -+ options->mode = Verbose; -+ } -+ else if (strcmp(argv[i], "-B") == 0) { -+ options->mode = Brief; -+ } -+ else if (strcmp(argv[i], "-b") == 0) { -+ options->findBest = GL_TRUE; -+ } -+ else if (strcmp(argv[i], "-l") == 0) { -+ options->limits = GL_TRUE; -+ } -+ else if (strcmp(argv[i], "-h") == 0) { -+ usage(); -+ exit(0); -+ } -+ else if(strcmp(argv[i], "-s") == 0) { -+ options->singleLine = GL_TRUE; -+ } -+ else { -+ printf("Unknown option `%s'\n", argv[i]); -+ usage(); -+ exit(0); -+ } -+ } -+} -diff -Naurp mesa-20.2.1-orig/src/glx/xdemos/glinfo_common.h mesa-20.2.1/src/glx/xdemos/glinfo_common.h ---- mesa-20.2.1-orig/src/glx/xdemos/glinfo_common.h 1969-12-31 18:00:00.000000000 -0600 -+++ mesa-20.2.1/src/glx/xdemos/glinfo_common.h 2020-10-15 23:06:45.826695773 -0500 -@@ -0,0 +1,142 @@ -+/* -+ * Copyright (C) 1999-2014 Brian Paul 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 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 -+ * BRIAN PAUL 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. -+ */ -+ -+ -+/** -+ * Common code shared by glxinfo and wglinfo. -+ */ -+ -+#ifndef GLINFO_COMMON_H -+#define GLINFO_COMMON_H -+ -+ -+#ifdef _WIN32 -+/* GL/glext.h is not commonly available on Windows. */ -+#include <GL/glew.h> -+#else -+#include <GL/gl.h> -+#include <GL/glext.h> -+#endif -+ -+typedef void (APIENTRY * GETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params); -+typedef const GLubyte *(APIENTRY * GETSTRINGIPROC) (GLenum name, GLuint index); -+typedef void (APIENTRY * GETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params); -+ -+ -+/** -+ * Ext functions needed in common code but must be provided by -+ * glxinfo or wglinfo. -+ */ -+struct ext_functions -+{ -+ GETPROGRAMIVARBPROC GetProgramivARB; -+ GETSTRINGIPROC GetStringi; -+ GETCONVOLUTIONPARAMETERIVPROC GetConvolutionParameteriv; -+}; -+ -+ -+#define ELEMENTS(array) (sizeof(array) / sizeof(array[0])) -+ -+ -+struct bit_info -+{ -+ int bit; -+ const char *name; -+}; -+ -+ -+typedef enum -+{ -+ Normal, -+ Wide, -+ Verbose, -+ Brief -+} InfoMode; -+ -+ -+struct options -+{ -+ InfoMode mode; -+ GLboolean findBest; -+ GLboolean limits; -+ GLboolean singleLine; -+ /* GLX only */ -+ char *displayName; -+ GLboolean allowDirect; -+}; -+ -+ -+/** list of known OpenGL versions */ -+static const struct { int major, minor; } gl_versions[] = { -+ {4, 5}, -+ {4, 4}, -+ {4, 3}, -+ {4, 2}, -+ {4, 1}, -+ {4, 0}, -+ -+ {3, 3}, -+ {3, 2}, -+ {3, 1}, -+ {3, 0}, -+ -+ {2, 1}, -+ {2, 0}, -+ -+ {1, 5}, -+ {1, 4}, -+ {1, 3}, -+ {1, 2}, -+ {1, 1}, -+ {1, 0}, -+ -+ {0, 0} /* end of list */ -+}; -+ -+ -+void -+print_extension_list(const char *ext, GLboolean singleLine); -+ -+char * -+build_core_profile_extension_list(const struct ext_functions *extfuncs); -+ -+GLboolean -+extension_supported(const char *ext, const char *extensionsList); -+ -+void -+print_limits(const char *extensions, const char *oglstring, int version, -+ const struct ext_functions *extfuncs); -+ -+const char * -+bitmask_to_string(const struct bit_info bits[], int numBits, int mask); -+ -+const char * -+profile_mask_string(int mask); -+ -+const char * -+context_flags_string(int mask); -+ -+ -+void -+parse_args(int argc, char *argv[], struct options *options); -+ -+ -+#endif /* GLINFO_COMMON_H */ -diff -Naurp mesa-20.2.1-orig/src/glx/xdemos/glxgears.1 mesa-20.2.1/src/glx/xdemos/glxgears.1 ---- mesa-20.2.1-orig/src/glx/xdemos/glxgears.1 1969-12-31 18:00:00.000000000 -0600 -+++ mesa-20.2.1/src/glx/xdemos/glxgears.1 2020-10-15 23:06:45.826695773 -0500 -@@ -0,0 +1,37 @@ -+.TH glxgears 1 "2006-11-29" -+.SH NAME -+glxgears \- ``gears'' demo for GLX -+.SH SYNOPSIS -+.B glxgears -+.RI [ options ] -+.SH DESCRIPTION -+The \fIglxgears\fP program is a port of the ``gears'' demo to GLX. It displays -+a set of rotating gears and prints out the frame rate at regular intervals. It -+has become quite popular as basic benchmarking tool. -+.SH OPTIONS -+.TP 8 -+.B \-display \fIdisplay\fP -+Specify which X display to run on. -+.TP 8 -+.B \-stereo -+Use a stereo enabled GLX visual. -+.TP 8 -+.B \-samples \fIN\fP -+Run in multisample mode with at least N samples. -+.TP 8 -+.B \-fullscreen -+Run in fullscreen mode. -+.TP 8 -+.B \-info -+Display OpenGL renderer information. -+.TP 8 -+.B \-geometry \fIWxH+X+Y\fP -+Window geometry. -+.SH AUTHOR -+glxgears was written by Brian Paul <brian.paul@tungstengraphics.com>. -+.PP -+This manual page was written by Thierry Reding <thierry@gilfi.de>, for the -+Debian project and updated by Fernando de Oliveira <famobr at yahoo dot -+com dot br>, for the Linux From Scratch (LFS) project (but may be used by -+others). -+ -diff -Naurp mesa-20.2.1-orig/src/glx/xdemos/glxgears.c mesa-20.2.1/src/glx/xdemos/glxgears.c ---- mesa-20.2.1-orig/src/glx/xdemos/glxgears.c 1969-12-31 18:00:00.000000000 -0600 -+++ mesa-20.2.1/src/glx/xdemos/glxgears.c 2020-10-15 23:06:45.826695773 -0500 -@@ -0,0 +1,809 @@ -+/* -+ * Copyright (C) 1999-2001 Brian Paul 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 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 -+ * BRIAN PAUL 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. -+ */ -+ -+/* -+ * This is a port of the infamous "gears" demo to straight GLX (i.e. no GLUT) -+ * Port by Brian Paul 23 March 2001 -+ * -+ * See usage() below for command line options. -+ */ -+ -+ -+#include <math.h> -+#include <stdlib.h> -+#include <stdio.h> -+#include <string.h> -+#include <X11/Xlib.h> -+#include <X11/keysym.h> -+#include <GL/gl.h> -+#include <GL/glx.h> -+#include <GL/glxext.h> -+ -+#ifndef GLX_MESA_swap_control -+#define GLX_MESA_swap_control 1 -+typedef int (*PFNGLXGETSWAPINTERVALMESAPROC)(void); -+#endif -+ -+ -+#define BENCHMARK -+ -+#ifdef BENCHMARK -+ -+/* XXX this probably isn't very portable */ -+ -+#include <sys/time.h> -+#include <unistd.h> -+ -+/* return current time (in seconds) */ -+static double -+current_time(void) -+{ -+ struct timeval tv; -+#ifdef __VMS -+ (void) gettimeofday(&tv, NULL ); -+#else -+ struct timezone tz; -+ (void) gettimeofday(&tv, &tz); -+#endif -+ return (double) tv.tv_sec + tv.tv_usec / 1000000.0; -+} -+ -+#else /*BENCHMARK*/ -+ -+/* dummy */ -+static double -+current_time(void) -+{ -+ /* update this function for other platforms! */ -+ static double t = 0.0; -+ static int warn = 1; -+ if (warn) { -+ fprintf(stderr, "Warning: current_time() not implemented!!\n"); -+ warn = 0; -+ } -+ return t += 1.0; -+} -+ -+#endif /*BENCHMARK*/ -+ -+ -+ -+#ifndef M_PI -+#define M_PI 3.14159265 -+#endif -+ -+ -+/** Event handler results: */ -+#define NOP 0 -+#define EXIT 1 -+#define DRAW 2 -+ -+static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; -+static GLint gear1, gear2, gear3; -+static GLfloat angle = 0.0; -+ -+static GLboolean fullscreen = GL_FALSE; /* Create a single fullscreen window */ -+static GLboolean stereo = GL_FALSE; /* Enable stereo. */ -+static GLint samples = 0; /* Choose visual with at least N samples. */ -+static GLboolean animate = GL_TRUE; /* Animation */ -+static GLfloat eyesep = 5.0; /* Eye separation. */ -+static GLfloat fix_point = 40.0; /* Fixation point distance. */ -+static GLfloat left, right, asp; /* Stereo frustum params. */ -+ -+ -+/* -+ * -+ * Draw a gear wheel. You'll probably want to call this function when -+ * building a display list since we do a lot of trig here. -+ * -+ * Input: inner_radius - radius of hole at center -+ * outer_radius - radius at center of teeth -+ * width - width of gear -+ * teeth - number of teeth -+ * tooth_depth - depth of tooth -+ */ -+static void -+gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width, -+ GLint teeth, GLfloat tooth_depth) -+{ -+ GLint i; -+ GLfloat r0, r1, r2; -+ GLfloat angle, da; -+ GLfloat u, v, len; -+ -+ r0 = inner_radius; -+ r1 = outer_radius - tooth_depth / 2.0; -+ r2 = outer_radius + tooth_depth / 2.0; -+ -+ da = 2.0 * M_PI / teeth / 4.0; -+ -+ glShadeModel(GL_FLAT); -+ -+ glNormal3f(0.0, 0.0, 1.0); -+ -+ /* draw front face */ -+ glBegin(GL_QUAD_STRIP); -+ for (i = 0; i <= teeth; i++) { -+ angle = i * 2.0 * M_PI / teeth; -+ glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); -+ glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); -+ if (i < teeth) { -+ glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); -+ glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -+ width * 0.5); -+ } -+ } -+ glEnd(); -+ -+ /* draw front sides of teeth */ -+ glBegin(GL_QUADS); -+ da = 2.0 * M_PI / teeth / 4.0; -+ for (i = 0; i < teeth; i++) { -+ angle = i * 2.0 * M_PI / teeth; -+ -+ glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); -+ glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); -+ glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -+ width * 0.5); -+ glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -+ width * 0.5); -+ } -+ glEnd(); -+ -+ glNormal3f(0.0, 0.0, -1.0); -+ -+ /* draw back face */ -+ glBegin(GL_QUAD_STRIP); -+ for (i = 0; i <= teeth; i++) { -+ angle = i * 2.0 * M_PI / teeth; -+ glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); -+ glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); -+ if (i < teeth) { -+ glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -+ -width * 0.5); -+ glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); -+ } -+ } -+ glEnd(); -+ -+ /* draw back sides of teeth */ -+ glBegin(GL_QUADS); -+ da = 2.0 * M_PI / teeth / 4.0; -+ for (i = 0; i < teeth; i++) { -+ angle = i * 2.0 * M_PI / teeth; -+ -+ glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -+ -width * 0.5); -+ glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -+ -width * 0.5); -+ glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); -+ glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); -+ } -+ glEnd(); -+ -+ /* draw outward faces of teeth */ -+ glBegin(GL_QUAD_STRIP); -+ for (i = 0; i < teeth; i++) { -+ angle = i * 2.0 * M_PI / teeth; -+ -+ glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5); -+ glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5); -+ u = r2 * cos(angle + da) - r1 * cos(angle); -+ v = r2 * sin(angle + da) - r1 * sin(angle); -+ len = sqrt(u * u + v * v); -+ u /= len; -+ v /= len; -+ glNormal3f(v, -u, 0.0); -+ glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5); -+ glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5); -+ glNormal3f(cos(angle), sin(angle), 0.0); -+ glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -+ width * 0.5); -+ glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da), -+ -width * 0.5); -+ u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da); -+ v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da); -+ glNormal3f(v, -u, 0.0); -+ glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -+ width * 0.5); -+ glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da), -+ -width * 0.5); -+ glNormal3f(cos(angle), sin(angle), 0.0); -+ } -+ -+ glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5); -+ glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5); -+ -+ glEnd(); -+ -+ glShadeModel(GL_SMOOTH); -+ -+ /* draw inside radius cylinder */ -+ glBegin(GL_QUAD_STRIP); -+ for (i = 0; i <= teeth; i++) { -+ angle = i * 2.0 * M_PI / teeth; -+ glNormal3f(-cos(angle), -sin(angle), 0.0); -+ glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5); -+ glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5); -+ } -+ glEnd(); -+} -+ -+ -+static void -+draw(void) -+{ -+ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); -+ -+ glPushMatrix(); -+ glRotatef(view_rotx, 1.0, 0.0, 0.0); -+ glRotatef(view_roty, 0.0, 1.0, 0.0); -+ glRotatef(view_rotz, 0.0, 0.0, 1.0); -+ -+ glPushMatrix(); -+ glTranslatef(-3.0, -2.0, 0.0); -+ glRotatef(angle, 0.0, 0.0, 1.0); -+ glCallList(gear1); -+ glPopMatrix(); -+ -+ glPushMatrix(); -+ glTranslatef(3.1, -2.0, 0.0); -+ glRotatef(-2.0 * angle - 9.0, 0.0, 0.0, 1.0); -+ glCallList(gear2); -+ glPopMatrix(); -+ -+ glPushMatrix(); -+ glTranslatef(-3.1, 4.2, 0.0); -+ glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0); -+ glCallList(gear3); -+ glPopMatrix(); -+ -+ glPopMatrix(); -+} -+ -+ -+static void -+draw_gears(void) -+{ -+ if (stereo) { -+ /* First left eye. */ -+ glDrawBuffer(GL_BACK_LEFT); -+ -+ glMatrixMode(GL_PROJECTION); -+ glLoadIdentity(); -+ glFrustum(left, right, -asp, asp, 5.0, 60.0); -+ -+ glMatrixMode(GL_MODELVIEW); -+ -+ glPushMatrix(); -+ glTranslated(+0.5 * eyesep, 0.0, 0.0); -+ draw(); -+ glPopMatrix(); -+ -+ /* Then right eye. */ -+ glDrawBuffer(GL_BACK_RIGHT); -+ -+ glMatrixMode(GL_PROJECTION); -+ glLoadIdentity(); -+ glFrustum(-right, -left, -asp, asp, 5.0, 60.0); -+ -+ glMatrixMode(GL_MODELVIEW); -+ -+ glPushMatrix(); -+ glTranslated(-0.5 * eyesep, 0.0, 0.0); -+ draw(); -+ glPopMatrix(); -+ } -+ else { -+ draw(); -+ } -+} -+ -+ -+/** Draw single frame, do SwapBuffers, compute FPS */ -+static void -+draw_frame(Display *dpy, Window win) -+{ -+ static int frames = 0; -+ static double tRot0 = -1.0, tRate0 = -1.0; -+ double dt, t = current_time(); -+ -+ if (tRot0 < 0.0) -+ tRot0 = t; -+ dt = t - tRot0; -+ tRot0 = t; -+ -+ if (animate) { -+ /* advance rotation for next frame */ -+ angle += 70.0 * dt; /* 70 degrees per second */ -+ if (angle > 3600.0) -+ angle -= 3600.0; -+ } -+ -+ draw_gears(); -+ glXSwapBuffers(dpy, win); -+ -+ frames++; -+ -+ if (tRate0 < 0.0) -+ tRate0 = t; -+ if (t - tRate0 >= 5.0) { -+ GLfloat seconds = t - tRate0; -+ GLfloat fps = frames / seconds; -+ printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, -+ fps); -+ fflush(stdout); -+ tRate0 = t; -+ frames = 0; -+ } -+} -+ -+ -+/* new window size or exposure */ -+static void -+reshape(int width, int height) -+{ -+ glViewport(0, 0, (GLint) width, (GLint) height); -+ -+ if (stereo) { -+ GLfloat w; -+ -+ asp = (GLfloat) height / (GLfloat) width; -+ w = fix_point * (1.0 / 5.0); -+ -+ left = -5.0 * ((w - 0.5 * eyesep) / fix_point); -+ right = 5.0 * ((w + 0.5 * eyesep) / fix_point); -+ } -+ else { -+ GLfloat h = (GLfloat) height / (GLfloat) width; -+ -+ glMatrixMode(GL_PROJECTION); -+ glLoadIdentity(); -+ glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0); -+ } -+ -+ glMatrixMode(GL_MODELVIEW); -+ glLoadIdentity(); -+ glTranslatef(0.0, 0.0, -40.0); -+} -+ -+ -+ -+static void -+init(void) -+{ -+ static GLfloat pos[4] = { 5.0, 5.0, 10.0, 0.0 }; -+ static GLfloat red[4] = { 0.8, 0.1, 0.0, 1.0 }; -+ static GLfloat green[4] = { 0.0, 0.8, 0.2, 1.0 }; -+ static GLfloat blue[4] = { 0.2, 0.2, 1.0, 1.0 }; -+ -+ glLightfv(GL_LIGHT0, GL_POSITION, pos); -+ glEnable(GL_CULL_FACE); -+ glEnable(GL_LIGHTING); -+ glEnable(GL_LIGHT0); -+ glEnable(GL_DEPTH_TEST); -+ -+ /* make the gears */ -+ gear1 = glGenLists(1); -+ glNewList(gear1, GL_COMPILE); -+ glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red); -+ gear(1.0, 4.0, 1.0, 20, 0.7); -+ glEndList(); -+ -+ gear2 = glGenLists(1); -+ glNewList(gear2, GL_COMPILE); -+ glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green); -+ gear(0.5, 2.0, 2.0, 10, 0.7); -+ glEndList(); -+ -+ gear3 = glGenLists(1); -+ glNewList(gear3, GL_COMPILE); -+ glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue); -+ gear(1.3, 2.0, 0.5, 10, 0.7); -+ glEndList(); -+ -+ glEnable(GL_NORMALIZE); -+} -+ -+ -+/** -+ * Remove window border/decorations. -+ */ -+static void -+no_border( Display *dpy, Window w) -+{ -+ static const unsigned MWM_HINTS_DECORATIONS = (1 << 1); -+ static const int PROP_MOTIF_WM_HINTS_ELEMENTS = 5; -+ -+ typedef struct -+ { -+ unsigned long flags; -+ unsigned long functions; -+ unsigned long decorations; -+ long inputMode; -+ unsigned long status; -+ } PropMotifWmHints; -+ -+ PropMotifWmHints motif_hints; -+ Atom prop, proptype; -+ unsigned long flags = 0; -+ -+ /* setup the property */ -+ motif_hints.flags = MWM_HINTS_DECORATIONS; -+ motif_hints.decorations = flags; -+ -+ /* get the atom for the property */ -+ prop = XInternAtom( dpy, "_MOTIF_WM_HINTS", True ); -+ if (!prop) { -+ /* something went wrong! */ -+ return; -+ } -+ -+ /* not sure this is correct, seems to work, XA_WM_HINTS didn't work */ -+ proptype = prop; -+ -+ XChangeProperty( dpy, w, /* display, window */ -+ prop, proptype, /* property, type */ -+ 32, /* format: 32-bit datums */ -+ PropModeReplace, /* mode */ -+ (unsigned char *) &motif_hints, /* data */ -+ PROP_MOTIF_WM_HINTS_ELEMENTS /* nelements */ -+ ); -+} -+ -+ -+/* -+ * Create an RGB, double-buffered window. -+ * Return the window and context handles. -+ */ -+static void -+make_window( Display *dpy, const char *name, -+ int x, int y, int width, int height, -+ Window *winRet, GLXContext *ctxRet, VisualID *visRet) -+{ -+ int attribs[64]; -+ int i = 0; -+ -+ int scrnum; -+ XSetWindowAttributes attr; -+ unsigned long mask; -+ Window root; -+ Window win; -+ GLXContext ctx; -+ XVisualInfo *visinfo; -+ -+ /* Singleton attributes. */ -+ attribs[i++] = GLX_RGBA; -+ attribs[i++] = GLX_DOUBLEBUFFER; -+ if (stereo) -+ attribs[i++] = GLX_STEREO; -+ -+ /* Key/value attributes. */ -+ attribs[i++] = GLX_RED_SIZE; -+ attribs[i++] = 1; -+ attribs[i++] = GLX_GREEN_SIZE; -+ attribs[i++] = 1; -+ attribs[i++] = GLX_BLUE_SIZE; -+ attribs[i++] = 1; -+ attribs[i++] = GLX_DEPTH_SIZE; -+ attribs[i++] = 1; -+ if (samples > 0) { -+ attribs[i++] = GLX_SAMPLE_BUFFERS; -+ attribs[i++] = 1; -+ attribs[i++] = GLX_SAMPLES; -+ attribs[i++] = samples; -+ } -+ -+ attribs[i++] = None; -+ -+ scrnum = DefaultScreen( dpy ); -+ root = RootWindow( dpy, scrnum ); -+ -+ visinfo = glXChooseVisual(dpy, scrnum, attribs); -+ if (!visinfo) { -+ printf("Error: couldn't get an RGB, Double-buffered"); -+ if (stereo) -+ printf(", Stereo"); -+ if (samples > 0) -+ printf(", Multisample"); -+ printf(" visual\n"); -+ exit(1); -+ } -+ -+ /* window attributes */ -+ attr.background_pixel = 0; -+ attr.border_pixel = 0; -+ attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone); -+ attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; -+ /* XXX this is a bad way to get a borderless window! */ -+ mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; -+ -+ win = XCreateWindow( dpy, root, x, y, width, height, -+ 0, visinfo->depth, InputOutput, -+ visinfo->visual, mask, &attr ); -+ -+ if (fullscreen) -+ no_border(dpy, win); -+ -+ /* set hints and properties */ -+ { -+ XSizeHints sizehints; -+ sizehints.x = x; -+ sizehints.y = y; -+ sizehints.width = width; -+ sizehints.height = height; -+ sizehints.flags = USSize | USPosition; -+ XSetNormalHints(dpy, win, &sizehints); -+ XSetStandardProperties(dpy, win, name, name, -+ None, (char **)NULL, 0, &sizehints); -+ } -+ -+ ctx = glXCreateContext( dpy, visinfo, NULL, True ); -+ if (!ctx) { -+ printf("Error: glXCreateContext failed\n"); -+ exit(1); -+ } -+ -+ *winRet = win; -+ *ctxRet = ctx; -+ *visRet = visinfo->visualid; -+ -+ XFree(visinfo); -+} -+ -+ -+/** -+ * Determine whether or not a GLX extension is supported. -+ */ -+static int -+is_glx_extension_supported(Display *dpy, const char *query) -+{ -+ const int scrnum = DefaultScreen(dpy); -+ const char *glx_extensions = NULL; -+ const size_t len = strlen(query); -+ const char *ptr; -+ -+ if (glx_extensions == NULL) { -+ glx_extensions = glXQueryExtensionsString(dpy, scrnum); -+ } -+ -+ ptr = strstr(glx_extensions, query); -+ return ((ptr != NULL) && ((ptr[len] == ' ') || (ptr[len] == '\0'))); -+} -+ -+ -+/** -+ * Attempt to determine whether or not the display is synched to vblank. -+ */ -+static void -+query_vsync(Display *dpy, GLXDrawable drawable) -+{ -+ int interval = 0; -+ -+#if defined(GLX_EXT_swap_control) -+ if (is_glx_extension_supported(dpy, "GLX_EXT_swap_control")) { -+ unsigned int tmp = -1; -+ glXQueryDrawable(dpy, drawable, GLX_SWAP_INTERVAL_EXT, &tmp); -+ interval = tmp; -+ } else -+#endif -+ if (is_glx_extension_supported(dpy, "GLX_MESA_swap_control")) { -+ PFNGLXGETSWAPINTERVALMESAPROC pglXGetSwapIntervalMESA = -+ (PFNGLXGETSWAPINTERVALMESAPROC) -+ glXGetProcAddressARB((const GLubyte *) "glXGetSwapIntervalMESA"); -+ -+ interval = (*pglXGetSwapIntervalMESA)(); -+ } else if (is_glx_extension_supported(dpy, "GLX_SGI_swap_control")) { -+ /* The default swap interval with this extension is 1. Assume that it -+ * is set to the default. -+ * -+ * Many Mesa-based drivers default to 0, but all of these drivers also -+ * export GLX_MESA_swap_control. In that case, this branch will never -+ * be taken, and the correct result should be reported. -+ */ -+ interval = 1; -+ } -+ -+ -+ if (interval > 0) { -+ printf("Running synchronized to the vertical refresh. The framerate should be\n"); -+ if (interval == 1) { -+ printf("approximately the same as the monitor refresh rate.\n"); -+ } else if (interval > 1) { -+ printf("approximately 1/%d the monitor refresh rate.\n", -+ interval); -+ } -+ } -+} -+ -+/** -+ * Handle one X event. -+ * \return NOP, EXIT or DRAW -+ */ -+static int -+handle_event(Display *dpy, Window win, XEvent *event) -+{ -+ (void) dpy; -+ (void) win; -+ -+ switch (event->type) { -+ case Expose: -+ return DRAW; -+ case ConfigureNotify: -+ reshape(event->xconfigure.width, event->xconfigure.height); -+ break; -+ case KeyPress: -+ { -+ char buffer[10]; -+ int code; -+ code = XLookupKeysym(&event->xkey, 0); -+ if (code == XK_Left) { -+ view_roty += 5.0; -+ } -+ else if (code == XK_Right) { -+ view_roty -= 5.0; -+ } -+ else if (code == XK_Up) { -+ view_rotx += 5.0; -+ } -+ else if (code == XK_Down) { -+ view_rotx -= 5.0; -+ } -+ else { -+ XLookupString(&event->xkey, buffer, sizeof(buffer), -+ NULL, NULL); -+ if (buffer[0] == 27) { -+ /* escape */ -+ return EXIT; -+ } -+ else if (buffer[0] == 'a' || buffer[0] == 'A') { -+ animate = !animate; -+ } -+ } -+ return DRAW; -+ } -+ } -+ return NOP; -+} -+ -+ -+static void -+event_loop(Display *dpy, Window win) -+{ -+ while (1) { -+ int op; -+ while (!animate || XPending(dpy) > 0) { -+ XEvent event; -+ XNextEvent(dpy, &event); -+ op = handle_event(dpy, win, &event); -+ if (op == EXIT) -+ return; -+ else if (op == DRAW) -+ break; -+ } -+ -+ draw_frame(dpy, win); -+ } -+} -+ -+ -+static void -+usage(void) -+{ -+ printf("Usage:\n"); -+ printf(" -display <displayname> set the display to run on\n"); -+ printf(" -stereo run in stereo mode\n"); -+ printf(" -samples N run in multisample mode with at least N samples\n"); -+ printf(" -fullscreen run in fullscreen mode\n"); -+ printf(" -info display OpenGL renderer info\n"); -+ printf(" -geometry WxH+X+Y window geometry\n"); -+} -+ -+ -+int -+main(int argc, char *argv[]) -+{ -+ unsigned int winWidth = 300, winHeight = 300; -+ int x = 0, y = 0; -+ Display *dpy; -+ Window win; -+ GLXContext ctx; -+ char *dpyName = NULL; -+ GLboolean printInfo = GL_FALSE; -+ VisualID visId; -+ int i; -+ -+ for (i = 1; i < argc; i++) { -+ if (strcmp(argv[i], "-display") == 0) { -+ dpyName = argv[i+1]; -+ i++; -+ } -+ else if (strcmp(argv[i], "-info") == 0) { -+ printInfo = GL_TRUE; -+ } -+ else if (strcmp(argv[i], "-stereo") == 0) { -+ stereo = GL_TRUE; -+ } -+ else if (i < argc-1 && strcmp(argv[i], "-samples") == 0) { -+ samples = strtod(argv[i+1], NULL ); -+ ++i; -+ } -+ else if (strcmp(argv[i], "-fullscreen") == 0) { -+ fullscreen = GL_TRUE; -+ } -+ else if (i < argc-1 && strcmp(argv[i], "-geometry") == 0) { -+ XParseGeometry(argv[i+1], &x, &y, &winWidth, &winHeight); -+ i++; -+ } -+ else { -+ usage(); -+ return -1; -+ } -+ } -+ -+ dpy = XOpenDisplay(dpyName); -+ if (!dpy) { -+ printf("Error: couldn't open display %s\n", -+ dpyName ? dpyName : getenv("DISPLAY")); -+ return -1; -+ } -+ -+ if (fullscreen) { -+ int scrnum = DefaultScreen(dpy); -+ -+ x = 0; y = 0; -+ winWidth = DisplayWidth(dpy, scrnum); -+ winHeight = DisplayHeight(dpy, scrnum); -+ } -+ -+ make_window(dpy, "glxgears", x, y, winWidth, winHeight, &win, &ctx, &visId); -+ XMapWindow(dpy, win); -+ glXMakeCurrent(dpy, win, ctx); -+ query_vsync(dpy, win); -+ -+ if (printInfo) { -+ printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); -+ printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); -+ printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); -+ printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS)); -+ printf("VisualID %d, 0x%x\n", (int) visId, (int) visId); -+ } -+ -+ init(); -+ -+ /* Set initial projection/viewing transformation. -+ * We can't be sure we'll get a ConfigureNotify event when the window -+ * first appears. -+ */ -+ reshape(winWidth, winHeight); -+ -+ event_loop(dpy, win); -+ -+ glDeleteLists(gear1, 1); -+ glDeleteLists(gear2, 1); -+ glDeleteLists(gear3, 1); -+ glXMakeCurrent(dpy, None, NULL); -+ glXDestroyContext(dpy, ctx); -+ XDestroyWindow(dpy, win); -+ XCloseDisplay(dpy); -+ -+ return 0; -+} -diff -Naurp mesa-20.2.1-orig/src/glx/xdemos/glxinfo.1 mesa-20.2.1/src/glx/xdemos/glxinfo.1 ---- mesa-20.2.1-orig/src/glx/xdemos/glxinfo.1 1969-12-31 18:00:00.000000000 -0600 -+++ mesa-20.2.1/src/glx/xdemos/glxinfo.1 2020-10-15 23:06:45.826695773 -0500 -@@ -0,0 +1,46 @@ -+.TH glxinfo 1 "2006-11-29" -+.SH NAME -+glxinfo \- show information about the GLX implementation -+.SH SYNOPSIS -+.B glxinfo -+.RI [ options ] -+.SH DESCRIPTION -+The \fIglxinfo\fP program shows information about the OpenGL and GLX -+implementations running on a given X display. -+.PP -+The information includes details about the server- and client-side GLX -+implementation, the OpenGL and GLU implementations as well as a list -+of available GLX visuals. -+.SH OPTIONS -+.TP 8 -+.B \-v -+Print visuals info in verbose form. -+.TP 8 -+.B \-t -+Print verbose table. -+.TP 8 -+.B \-display \fIdisplay\fP -+Specify the X display to interrogate. -+.TP 8 -+.B \-h -+Print usage information. -+.TP 8 -+.B \-i -+Force an indirect rendering context. -+.TP 8 -+.B \-b -+Find the "best" visual and print its number. -+.TP 8 -+.B \-l -+Print interesting OpenGL limits. -+.TP 8 -+.B \-s -+Print a single extension per line. -+.SH AUTHOR -+glxinfo was written by Brian Paul <brian.paul@tungstengraphics.com>. -+.PP -+This manual page was written by Thierry Reding <thierry@gilfi.de>, for the -+Debian project and updated by Fernando de Oliveira <famobr at yahoo dot -+com dot br>, for the Linux From Scratch (LFS) project (but may be used by -+others). -+ -diff -Naurp mesa-20.2.1-orig/src/glx/xdemos/glxinfo.c mesa-20.2.1/src/glx/xdemos/glxinfo.c ---- mesa-20.2.1-orig/src/glx/xdemos/glxinfo.c 1969-12-31 18:00:00.000000000 -0600 -+++ mesa-20.2.1/src/glx/xdemos/glxinfo.c 2020-10-15 23:06:45.826695773 -0500 -@@ -0,0 +1,1281 @@ -+/* -+ * Copyright (C) 1999-2006 Brian Paul 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 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 -+ * BRIAN PAUL 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. -+ */ -+ -+ -+/* -+ * This program is a work-alike of the IRIX glxinfo program. -+ * Command line options: -+ * -t print wide table -+ * -v print verbose information -+ * -display DisplayName specify the X display to interogate -+ * -B brief, print only the basics -+ * -b only print ID of "best" visual on screen 0 -+ * -i use indirect rendering connection only -+ * -l print interesting OpenGL limits (added 5 Sep 2002) -+ * -+ * Brian Paul 26 January 2000 -+ */ -+ -+#define GLX_GLXEXT_PROTOTYPES -+#define GL_GLEXT_PROTOTYPES -+ -+#include <assert.h> -+#include <X11/Xlib.h> -+#include <X11/Xutil.h> -+#include <GL/gl.h> -+#include <GL/glx.h> -+#include <stdio.h> -+#include <string.h> -+#include <stdlib.h> -+#include "glinfo_common.h" -+ -+ -+#ifndef GLX_NONE_EXT -+#define GLX_NONE_EXT 0x8000 -+#endif -+ -+#ifndef GLX_TRANSPARENT_RGB -+#define GLX_TRANSPARENT_RGB 0x8008 -+#endif -+ -+#ifndef GLX_RGBA_BIT -+#define GLX_RGBA_BIT 0x00000001 -+#endif -+ -+#ifndef GLX_COLOR_INDEX_BIT -+#define GLX_COLOR_INDEX_BIT 0x00000002 -+#endif -+ -+ -+struct visual_attribs -+{ -+ /* X visual attribs */ -+ int id; /* May be visual ID or FBConfig ID */ -+ int vis_id; /* Visual ID. Only set for FBConfigs */ -+ int klass; -+ int depth; -+ int redMask, greenMask, blueMask; -+ int colormapSize; -+ int bitsPerRGB; -+ -+ /* GL visual attribs */ -+ int supportsGL; -+ int drawableType; -+ int transparentType; -+ int transparentRedValue; -+ int transparentGreenValue; -+ int transparentBlueValue; -+ int transparentAlphaValue; -+ int transparentIndexValue; -+ int bufferSize; -+ int level; -+ int render_type; -+ int doubleBuffer; -+ int stereo; -+ int auxBuffers; -+ int redSize, greenSize, blueSize, alphaSize; -+ int depthSize; -+ int stencilSize; -+ int accumRedSize, accumGreenSize, accumBlueSize, accumAlphaSize; -+ int numSamples, numMultisample; -+ int visualCaveat; -+ int floatComponents; -+ int packedfloatComponents; -+ int srgb; -+}; -+ -+ -+/** -+ * Version of the context that was created -+ * -+ * 20, 21, 30, 31, 32, etc. -+ */ -+static int version; -+ -+/** -+ * GL Error checking/warning. -+ */ -+static void -+CheckError(int line) -+{ -+ int n; -+ n = glGetError(); -+ if (n) -+ printf("Warning: GL error 0x%x at line %d\n", n, line); -+} -+ -+ -+static void -+print_display_info(Display *dpy) -+{ -+ printf("name of display: %s\n", DisplayString(dpy)); -+} -+ -+ -+/** -+ * Choose a simple FB Config. -+ */ -+static GLXFBConfig * -+choose_fb_config(Display *dpy, int scrnum) -+{ -+ int fbAttribSingle[] = { -+ GLX_RENDER_TYPE, GLX_RGBA_BIT, -+ GLX_RED_SIZE, 1, -+ GLX_GREEN_SIZE, 1, -+ GLX_BLUE_SIZE, 1, -+ GLX_DOUBLEBUFFER, False, -+ None }; -+ int fbAttribDouble[] = { -+ GLX_RENDER_TYPE, GLX_RGBA_BIT, -+ GLX_RED_SIZE, 1, -+ GLX_GREEN_SIZE, 1, -+ GLX_BLUE_SIZE, 1, -+ GLX_DOUBLEBUFFER, True, -+ None }; -+ GLXFBConfig *configs; -+ int nConfigs; -+ -+ configs = glXChooseFBConfig(dpy, scrnum, fbAttribSingle, &nConfigs); -+ if (!configs) -+ configs = glXChooseFBConfig(dpy, scrnum, fbAttribDouble, &nConfigs); -+ -+ return configs; -+} -+ -+ -+static Bool CreateContextErrorFlag; -+ -+static int -+create_context_error_handler(Display *dpy, XErrorEvent *error) -+{ -+ (void) dpy; -+ (void) error->error_code; -+ CreateContextErrorFlag = True; -+ return 0; -+} -+ -+ -+/** -+ * Try to create a GLX context of the given version with flags/options. -+ * Note: A version number is required in order to get a core profile -+ * (at least w/ NVIDIA). -+ */ -+static GLXContext -+create_context_flags(Display *dpy, GLXFBConfig fbconfig, int major, int minor, -+ int contextFlags, int profileMask, Bool direct) -+{ -+#ifdef GLX_ARB_create_context -+ static PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB_func = 0; -+ static Bool firstCall = True; -+ int (*old_handler)(Display *, XErrorEvent *); -+ GLXContext context; -+ int attribs[20]; -+ int n = 0; -+ -+ if (firstCall) { -+ /* See if we have GLX_ARB_create_context_profile and get pointer to -+ * glXCreateContextAttribsARB() function. -+ */ -+ const char *glxExt = glXQueryExtensionsString(dpy, 0); -+ if (extension_supported("GLX_ARB_create_context_profile", glxExt)) { -+ glXCreateContextAttribsARB_func = (PFNGLXCREATECONTEXTATTRIBSARBPROC) -+ glXGetProcAddress((const GLubyte *) "glXCreateContextAttribsARB"); -+ } -+ firstCall = False; -+ } -+ -+ if (!glXCreateContextAttribsARB_func) -+ return 0; -+ -+ /* setup attribute array */ -+ if (major) { -+ attribs[n++] = GLX_CONTEXT_MAJOR_VERSION_ARB; -+ attribs[n++] = major; -+ attribs[n++] = GLX_CONTEXT_MINOR_VERSION_ARB; -+ attribs[n++] = minor; -+ } -+ if (contextFlags) { -+ attribs[n++] = GLX_CONTEXT_FLAGS_ARB; -+ attribs[n++] = contextFlags; -+ } -+#ifdef GLX_ARB_create_context_profile -+ if (profileMask) { -+ attribs[n++] = GLX_CONTEXT_PROFILE_MASK_ARB; -+ attribs[n++] = profileMask; -+ } -+#endif -+ attribs[n++] = 0; -+ -+ /* install X error handler */ -+ old_handler = XSetErrorHandler(create_context_error_handler); -+ CreateContextErrorFlag = False; -+ -+ /* try creating context */ -+ context = glXCreateContextAttribsARB_func(dpy, -+ fbconfig, -+ 0, /* share_context */ -+ direct, -+ attribs); -+ -+ /* restore error handler */ -+ XSetErrorHandler(old_handler); -+ -+ if (CreateContextErrorFlag) -+ context = 0; -+ -+ if (context && direct) { -+ if (!glXIsDirect(dpy, context)) { -+ glXDestroyContext(dpy, context); -+ return 0; -+ } -+ } -+ -+ return context; -+#else -+ return 0; -+#endif -+} -+ -+ -+/** -+ * Try to create a GLX context of the newest version. -+ */ -+static GLXContext -+create_context_with_config(Display *dpy, GLXFBConfig config, -+ Bool coreProfile, Bool es2Profile, Bool direct) -+{ -+ GLXContext ctx = 0; -+ -+ if (coreProfile) { -+ /* Try to create a core profile, starting with the newest version of -+ * GL that we're aware of. If we don't specify the version -+ */ -+ int i; -+ for (i = 0; gl_versions[i].major > 0; i++) { -+ /* don't bother below GL 3.0 */ -+ if (gl_versions[i].major == 3 && -+ gl_versions[i].minor == 0) -+ return 0; -+ ctx = create_context_flags(dpy, config, -+ gl_versions[i].major, -+ gl_versions[i].minor, -+ 0x0, -+ GLX_CONTEXT_CORE_PROFILE_BIT_ARB, -+ direct); -+ if (ctx) -+ return ctx; -+ } -+ /* couldn't get core profile context */ -+ return 0; -+ } -+ -+ if (es2Profile) { -+#ifdef GLX_CONTEXT_ES2_PROFILE_BIT_EXT -+ if (extension_supported("GLX_EXT_create_context_es2_profile", -+ glXQueryExtensionsString(dpy, 0))) { -+ ctx = create_context_flags(dpy, config, 2, 0, 0x0, -+ GLX_CONTEXT_ES2_PROFILE_BIT_EXT, -+ direct); -+ return ctx; -+ } -+#endif -+ return 0; -+ } -+ -+ /* GLX should return a context of the latest GL version that supports -+ * the full profile. -+ */ -+ ctx = glXCreateNewContext(dpy, config, GLX_RGBA_TYPE, NULL, direct); -+ -+ /* make sure the context is direct, if direct was requested */ -+ if (ctx && direct) { -+ if (!glXIsDirect(dpy, ctx)) { -+ glXDestroyContext(dpy, ctx); -+ return 0; -+ } -+ } -+ -+ return ctx; -+} -+ -+ -+static XVisualInfo * -+choose_xvisinfo(Display *dpy, int scrnum) -+{ -+ int attribSingle[] = { -+ GLX_RGBA, -+ GLX_RED_SIZE, 1, -+ GLX_GREEN_SIZE, 1, -+ GLX_BLUE_SIZE, 1, -+ None }; -+ int attribDouble[] = { -+ GLX_RGBA, -+ GLX_RED_SIZE, 1, -+ GLX_GREEN_SIZE, 1, -+ GLX_BLUE_SIZE, 1, -+ GLX_DOUBLEBUFFER, -+ None }; -+ XVisualInfo *visinfo; -+ -+ visinfo = glXChooseVisual(dpy, scrnum, attribSingle); -+ if (!visinfo) -+ visinfo = glXChooseVisual(dpy, scrnum, attribDouble); -+ -+ return visinfo; -+} -+ -+ -+static void -+query_renderer(void) -+{ -+#ifdef GLX_MESA_query_renderer -+ PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC queryInteger; -+ PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC queryString; -+ unsigned int v[3]; -+ -+ queryInteger = (PFNGLXQUERYCURRENTRENDERERINTEGERMESAPROC) -+ glXGetProcAddressARB((const GLubyte *) -+ "glXQueryCurrentRendererIntegerMESA"); -+ queryString = (PFNGLXQUERYCURRENTRENDERERSTRINGMESAPROC) -+ glXGetProcAddressARB((const GLubyte *) -+ "glXQueryCurrentRendererStringMESA"); -+ -+ printf("Extended renderer info (GLX_MESA_query_renderer):\n"); -+ queryInteger(GLX_RENDERER_VENDOR_ID_MESA, v); -+ printf(" Vendor: %s (0x%x)\n", -+ queryString(GLX_RENDERER_VENDOR_ID_MESA), *v); -+ queryInteger(GLX_RENDERER_DEVICE_ID_MESA, v); -+ printf(" Device: %s (0x%x)\n", -+ queryString(GLX_RENDERER_DEVICE_ID_MESA), *v); -+ queryInteger(GLX_RENDERER_VERSION_MESA, v); -+ printf(" Version: %d.%d.%d\n", v[0], v[1], v[2]); -+ queryInteger(GLX_RENDERER_ACCELERATED_MESA, v); -+ printf(" Accelerated: %s\n", *v ? "yes" : "no"); -+ queryInteger(GLX_RENDERER_VIDEO_MEMORY_MESA, v); -+ printf(" Video memory: %dMB\n", *v); -+ queryInteger(GLX_RENDERER_UNIFIED_MEMORY_ARCHITECTURE_MESA, v); -+ printf(" Unified memory: %s\n", *v ? "yes" : "no"); -+ queryInteger(GLX_RENDERER_PREFERRED_PROFILE_MESA, v); -+ printf(" Preferred profile: %s (0x%x)\n", -+ *v == GLX_CONTEXT_CORE_PROFILE_BIT_ARB ? "core" : -+ *v == GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB ? "compat" : -+ "unknown", *v); -+ queryInteger(GLX_RENDERER_OPENGL_CORE_PROFILE_VERSION_MESA, v); -+ printf(" Max core profile version: %d.%d\n", v[0], v[1]); -+ queryInteger(GLX_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION_MESA, v); -+ printf(" Max compat profile version: %d.%d\n", v[0], v[1]); -+ queryInteger(GLX_RENDERER_OPENGL_ES_PROFILE_VERSION_MESA, v); -+ printf(" Max GLES1 profile version: %d.%d\n", v[0], v[1]); -+ queryInteger(GLX_RENDERER_OPENGL_ES2_PROFILE_VERSION_MESA, v); -+ printf(" Max GLES[23] profile version: %d.%d\n", v[0], v[1]); -+#endif -+} -+ -+ -+static Bool -+print_screen_info(Display *dpy, int scrnum, -+ const struct options *opts, -+ Bool coreProfile, Bool es2Profile, Bool limits, -+ Bool coreWorked) -+{ -+ Window win; -+ XSetWindowAttributes attr; -+ unsigned long mask; -+ Window root; -+ GLXContext ctx = NULL; -+ XVisualInfo *visinfo; -+ int width = 100, height = 100; -+ GLXFBConfig *fbconfigs; -+ const char *oglstring = coreProfile ? "OpenGL core profile" : -+ es2Profile ? "OpenGL ES profile" : "OpenGL"; -+ -+ root = RootWindow(dpy, scrnum); -+ -+ /* -+ * Choose FBConfig or XVisualInfo and create a context. -+ */ -+ fbconfigs = choose_fb_config(dpy, scrnum); -+ if (fbconfigs) { -+ ctx = create_context_with_config(dpy, fbconfigs[0], -+ coreProfile, es2Profile, -+ opts->allowDirect); -+ if (!ctx && opts->allowDirect && !coreProfile) { -+ /* try indirect */ -+ ctx = create_context_with_config(dpy, fbconfigs[0], -+ coreProfile, es2Profile, False); -+ } -+ -+ visinfo = glXGetVisualFromFBConfig(dpy, fbconfigs[0]); -+ XFree(fbconfigs); -+ } -+ else if (!coreProfile && !es2Profile) { -+ visinfo = choose_xvisinfo(dpy, scrnum); -+ if (visinfo) -+ ctx = glXCreateContext(dpy, visinfo, NULL, opts->allowDirect); -+ } else -+ visinfo = NULL; -+ -+ if (!visinfo && !coreProfile && !es2Profile) { -+ fprintf(stderr, "Error: couldn't find RGB GLX visual or fbconfig\n"); -+ return False; -+ } -+ -+ if (!ctx) { -+ if (!coreProfile && !es2Profile) -+ fprintf(stderr, "Error: glXCreateContext failed\n"); -+ XFree(visinfo); -+ return False; -+ } -+ -+ /* -+ * Create a window so that we can just bind the context. -+ */ -+ attr.background_pixel = 0; -+ attr.border_pixel = 0; -+ attr.colormap = XCreateColormap(dpy, root, visinfo->visual, AllocNone); -+ attr.event_mask = StructureNotifyMask | ExposureMask; -+ mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask; -+ win = XCreateWindow(dpy, root, 0, 0, width, height, -+ 0, visinfo->depth, InputOutput, -+ visinfo->visual, mask, &attr); -+ -+ if (glXMakeCurrent(dpy, win, ctx)) { -+ const char *serverVendor = glXQueryServerString(dpy, scrnum, GLX_VENDOR); -+ const char *serverVersion = glXQueryServerString(dpy, scrnum, GLX_VERSION); -+ const char *serverExtensions = glXQueryServerString(dpy, scrnum, GLX_EXTENSIONS); -+ const char *clientVendor = glXGetClientString(dpy, GLX_VENDOR); -+ const char *clientVersion = glXGetClientString(dpy, GLX_VERSION); -+ const char *clientExtensions = glXGetClientString(dpy, GLX_EXTENSIONS); -+ const char *glxExtensions = glXQueryExtensionsString(dpy, scrnum); -+ const char *glVendor = (const char *) glGetString(GL_VENDOR); -+ const char *glRenderer = (const char *) glGetString(GL_RENDERER); -+ const char *glVersion = (const char *) glGetString(GL_VERSION); -+ char *glExtensions = NULL; -+ int glxVersionMajor = 0; -+ int glxVersionMinor = 0; -+ char *displayName = NULL; -+ char *colon = NULL, *period = NULL; -+ struct ext_functions extfuncs; -+ -+ CheckError(__LINE__); -+ -+ /* Get some ext functions */ -+ extfuncs.GetProgramivARB = (GETPROGRAMIVARBPROC) -+ glXGetProcAddressARB((GLubyte *) "glGetProgramivARB"); -+ extfuncs.GetStringi = (GETSTRINGIPROC) -+ glXGetProcAddressARB((GLubyte *) "glGetStringi"); -+ extfuncs.GetConvolutionParameteriv = (GETCONVOLUTIONPARAMETERIVPROC) -+ glXGetProcAddressARB((GLubyte *) "glGetConvolutionParameteriv"); -+ -+ if (!glXQueryVersion(dpy, & glxVersionMajor, & glxVersionMinor)) { -+ fprintf(stderr, "Error: glXQueryVersion failed\n"); -+ exit(1); -+ } -+ -+ /* Get list of GL extensions */ -+ if (coreProfile && extfuncs.GetStringi) -+ glExtensions = build_core_profile_extension_list(&extfuncs); -+ if (!glExtensions) { -+ coreProfile = False; -+ glExtensions = (char *) glGetString(GL_EXTENSIONS); -+ } -+ -+ CheckError(__LINE__); -+ -+ if (!coreWorked) { -+ /* Strip the screen number from the display name, if present. */ -+ if (!(displayName = (char *) malloc(strlen(DisplayString(dpy)) + 1))) { -+ fprintf(stderr, "Error: malloc() failed\n"); -+ exit(1); -+ } -+ strcpy(displayName, DisplayString(dpy)); -+ colon = strrchr(displayName, ':'); -+ if (colon) { -+ period = strchr(colon, '.'); -+ if (period) -+ *period = '\0'; -+ } -+ -+ printf("display: %s screen: %d\n", displayName, scrnum); -+ free(displayName); -+ printf("direct rendering: "); -+ if (glXIsDirect(dpy, ctx)) { -+ printf("Yes\n"); -+ } -+ else { -+ if (!opts->allowDirect) { -+ printf("No (-i specified)\n"); -+ } -+ else if (getenv("LIBGL_ALWAYS_INDIRECT")) { -+ printf("No (LIBGL_ALWAYS_INDIRECT set)\n"); -+ } -+ else { -+ printf("No (If you want to find out why, try setting " -+ "LIBGL_DEBUG=verbose)\n"); -+ } -+ } -+ if (opts->mode != Brief) { -+ printf("server glx vendor string: %s\n", serverVendor); -+ printf("server glx version string: %s\n", serverVersion); -+ printf("server glx extensions:\n"); -+ print_extension_list(serverExtensions, opts->singleLine); -+ printf("client glx vendor string: %s\n", clientVendor); -+ printf("client glx version string: %s\n", clientVersion); -+ printf("client glx extensions:\n"); -+ print_extension_list(clientExtensions, opts->singleLine); -+ printf("GLX version: %u.%u\n", glxVersionMajor, glxVersionMinor); -+ printf("GLX extensions:\n"); -+ print_extension_list(glxExtensions, opts->singleLine); -+ } -+ if (strstr(glxExtensions, "GLX_MESA_query_renderer")) -+ query_renderer(); -+ printf("OpenGL vendor string: %s\n", glVendor); -+ printf("OpenGL renderer string: %s\n", glRenderer); -+ } else -+ printf("\n"); -+ -+ printf("%s version string: %s\n", oglstring, glVersion); -+ -+ version = (glVersion[0] - '0') * 10 + (glVersion[2] - '0'); -+ -+ CheckError(__LINE__); -+ -+#ifdef GL_VERSION_2_0 -+ if (version >= 20) { -+ char *v = (char *) glGetString(GL_SHADING_LANGUAGE_VERSION); -+ printf("%s shading language version string: %s\n", oglstring, v); -+ } -+#endif -+ CheckError(__LINE__); -+#ifdef GL_VERSION_3_0 -+ if (version >= 30 && !es2Profile) { -+ GLint flags; -+ glGetIntegerv(GL_CONTEXT_FLAGS, &flags); -+ printf("%s context flags: %s\n", oglstring, context_flags_string(flags)); -+ } -+#endif -+ CheckError(__LINE__); -+#ifdef GL_VERSION_3_2 -+ if (version >= 32 && !es2Profile) { -+ GLint mask; -+ glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &mask); -+ printf("%s profile mask: %s\n", oglstring, profile_mask_string(mask)); -+ } -+#endif -+ -+ CheckError(__LINE__); -+ -+ if (opts->mode != Brief) { -+ printf("%s extensions:\n", oglstring); -+ print_extension_list(glExtensions, opts->singleLine); -+ } -+ -+ if (limits) { -+ print_limits(glExtensions, oglstring, version, &extfuncs); -+ } -+ -+ if (coreProfile) -+ free(glExtensions); -+ } -+ else { -+ fprintf(stderr, "Error: glXMakeCurrent failed\n"); -+ } -+ -+ glXDestroyContext(dpy, ctx); -+ XFree(visinfo); -+ XDestroyWindow(dpy, win); -+ XSync(dpy, 1); -+ return True; -+} -+ -+ -+static const char * -+visual_class_name(int cls) -+{ -+ switch (cls) { -+ case StaticColor: -+ return "StaticColor"; -+ case PseudoColor: -+ return "PseudoColor"; -+ case StaticGray: -+ return "StaticGray"; -+ case GrayScale: -+ return "GrayScale"; -+ case TrueColor: -+ return "TrueColor"; -+ case DirectColor: -+ return "DirectColor"; -+ default: -+ return ""; -+ } -+} -+ -+static const char * -+visual_drawable_type(int type) -+{ -+ const static struct bit_info bits[] = { -+ { GLX_WINDOW_BIT, "window" }, -+ { GLX_PIXMAP_BIT, "pixmap" }, -+ { GLX_PBUFFER_BIT, "pbuffer" } -+ }; -+ -+ return bitmask_to_string(bits, ELEMENTS(bits), type); -+} -+ -+static const char * -+visual_class_abbrev(int cls) -+{ -+ switch (cls) { -+ case StaticColor: -+ return "sc"; -+ case PseudoColor: -+ return "pc"; -+ case StaticGray: -+ return "sg"; -+ case GrayScale: -+ return "gs"; -+ case TrueColor: -+ return "tc"; -+ case DirectColor: -+ return "dc"; -+ default: -+ return ""; -+ } -+} -+ -+static const char * -+visual_render_type_name(int type) -+{ -+ switch (type) { -+ case GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT: -+ return "ufloat"; -+ case GLX_RGBA_FLOAT_BIT_ARB: -+ return "float"; -+ case GLX_RGBA_BIT: -+ return "rgba"; -+ case GLX_COLOR_INDEX_BIT: -+ return "ci"; -+ case GLX_RGBA_BIT | GLX_COLOR_INDEX_BIT: -+ return "rgba|ci"; -+ default: -+ return ""; -+ } -+} -+ -+static const char * -+caveat_string(int caveat) -+{ -+ switch (caveat) { -+#ifdef GLX_EXT_visual_rating -+ case GLX_SLOW_VISUAL_EXT: -+ return "Slow"; -+ case GLX_NON_CONFORMANT_VISUAL_EXT: -+ return "Ncon"; -+ case GLX_NONE_EXT: -+ /* fall-through */ -+#endif -+ case 0: -+ /* fall-through */ -+ default: -+ return "None"; -+ } -+} -+ -+ -+static Bool -+get_visual_attribs(Display *dpy, XVisualInfo *vInfo, -+ struct visual_attribs *attribs) -+{ -+ const char *ext = glXQueryExtensionsString(dpy, vInfo->screen); -+ int rgba; -+ -+ memset(attribs, 0, sizeof(struct visual_attribs)); -+ -+ attribs->id = vInfo->visualid; -+#if defined(__cplusplus) || defined(c_plusplus) -+ attribs->klass = vInfo->c_class; -+#else -+ attribs->klass = vInfo->class; -+#endif -+ attribs->depth = vInfo->depth; -+ attribs->redMask = vInfo->red_mask; -+ attribs->greenMask = vInfo->green_mask; -+ attribs->blueMask = vInfo->blue_mask; -+ attribs->colormapSize = vInfo->colormap_size; -+ attribs->bitsPerRGB = vInfo->bits_per_rgb; -+ -+ if (glXGetConfig(dpy, vInfo, GLX_USE_GL, &attribs->supportsGL) != 0 || -+ !attribs->supportsGL) -+ return False; -+ glXGetConfig(dpy, vInfo, GLX_BUFFER_SIZE, &attribs->bufferSize); -+ glXGetConfig(dpy, vInfo, GLX_LEVEL, &attribs->level); -+ glXGetConfig(dpy, vInfo, GLX_RGBA, &rgba); -+ if (rgba) -+ attribs->render_type = GLX_RGBA_BIT; -+ else -+ attribs->render_type = GLX_COLOR_INDEX_BIT; -+ -+ glXGetConfig(dpy, vInfo, GLX_DRAWABLE_TYPE, &attribs->drawableType); -+ glXGetConfig(dpy, vInfo, GLX_DOUBLEBUFFER, &attribs->doubleBuffer); -+ glXGetConfig(dpy, vInfo, GLX_STEREO, &attribs->stereo); -+ glXGetConfig(dpy, vInfo, GLX_AUX_BUFFERS, &attribs->auxBuffers); -+ glXGetConfig(dpy, vInfo, GLX_RED_SIZE, &attribs->redSize); -+ glXGetConfig(dpy, vInfo, GLX_GREEN_SIZE, &attribs->greenSize); -+ glXGetConfig(dpy, vInfo, GLX_BLUE_SIZE, &attribs->blueSize); -+ glXGetConfig(dpy, vInfo, GLX_ALPHA_SIZE, &attribs->alphaSize); -+ glXGetConfig(dpy, vInfo, GLX_DEPTH_SIZE, &attribs->depthSize); -+ glXGetConfig(dpy, vInfo, GLX_STENCIL_SIZE, &attribs->stencilSize); -+ glXGetConfig(dpy, vInfo, GLX_ACCUM_RED_SIZE, &attribs->accumRedSize); -+ glXGetConfig(dpy, vInfo, GLX_ACCUM_GREEN_SIZE, &attribs->accumGreenSize); -+ glXGetConfig(dpy, vInfo, GLX_ACCUM_BLUE_SIZE, &attribs->accumBlueSize); -+ glXGetConfig(dpy, vInfo, GLX_ACCUM_ALPHA_SIZE, &attribs->accumAlphaSize); -+ -+ /* get transparent pixel stuff */ -+ glXGetConfig(dpy, vInfo,GLX_TRANSPARENT_TYPE, &attribs->transparentType); -+ if (attribs->transparentType == GLX_TRANSPARENT_RGB) { -+ glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_RED_VALUE, &attribs->transparentRedValue); -+ glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_GREEN_VALUE, &attribs->transparentGreenValue); -+ glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_BLUE_VALUE, &attribs->transparentBlueValue); -+ glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_ALPHA_VALUE, &attribs->transparentAlphaValue); -+ } -+ else if (attribs->transparentType == GLX_TRANSPARENT_INDEX) { -+ glXGetConfig(dpy, vInfo, GLX_TRANSPARENT_INDEX_VALUE, &attribs->transparentIndexValue); -+ } -+ -+ /* multisample attribs */ -+#ifdef GLX_ARB_multisample -+ if (ext && strstr(ext, "GLX_ARB_multisample")) { -+ glXGetConfig(dpy, vInfo, GLX_SAMPLE_BUFFERS_ARB, &attribs->numMultisample); -+ glXGetConfig(dpy, vInfo, GLX_SAMPLES_ARB, &attribs->numSamples); -+ } -+#endif -+ else { -+ attribs->numSamples = 0; -+ attribs->numMultisample = 0; -+ } -+ -+#if defined(GLX_EXT_visual_rating) -+ if (ext && strstr(ext, "GLX_EXT_visual_rating")) { -+ glXGetConfig(dpy, vInfo, GLX_VISUAL_CAVEAT_EXT, &attribs->visualCaveat); -+ } -+ else { -+ attribs->visualCaveat = GLX_NONE_EXT; -+ } -+#else -+ attribs->visualCaveat = 0; -+#endif -+ -+#if defined(GLX_EXT_framebuffer_sRGB) -+ if (ext && strstr(ext, "GLX_EXT_framebuffer_sRGB")) { -+ glXGetConfig(dpy, vInfo, GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT, &attribs->srgb); -+ } -+#endif -+ -+ return True; -+} -+ -+#ifdef GLX_VERSION_1_3 -+ -+static int -+glx_token_to_visual_class(int visual_type) -+{ -+ switch (visual_type) { -+ case GLX_TRUE_COLOR: -+ return TrueColor; -+ case GLX_DIRECT_COLOR: -+ return DirectColor; -+ case GLX_PSEUDO_COLOR: -+ return PseudoColor; -+ case GLX_STATIC_COLOR: -+ return StaticColor; -+ case GLX_GRAY_SCALE: -+ return GrayScale; -+ case GLX_STATIC_GRAY: -+ return StaticGray; -+ case GLX_NONE: -+ default: -+ return None; -+ } -+} -+ -+static Bool -+get_fbconfig_attribs(Display *dpy, GLXFBConfig fbconfig, -+ struct visual_attribs *attribs) -+{ -+ const char *ext = glXQueryExtensionsString(dpy, 0); -+ int visual_type; -+ XVisualInfo *vInfo; -+ -+ memset(attribs, 0, sizeof(struct visual_attribs)); -+ -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_FBCONFIG_ID, &attribs->id); -+ -+ vInfo = glXGetVisualFromFBConfig(dpy, fbconfig); -+ -+ if (vInfo != NULL) { -+ attribs->vis_id = vInfo->visualid; -+ attribs->depth = vInfo->depth; -+ attribs->redMask = vInfo->red_mask; -+ attribs->greenMask = vInfo->green_mask; -+ attribs->blueMask = vInfo->blue_mask; -+ attribs->colormapSize = vInfo->colormap_size; -+ attribs->bitsPerRGB = vInfo->bits_per_rgb; -+ } -+ -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_X_VISUAL_TYPE, &visual_type); -+ attribs->klass = glx_token_to_visual_class(visual_type); -+ -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_DRAWABLE_TYPE, &attribs->drawableType); -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_BUFFER_SIZE, &attribs->bufferSize); -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_LEVEL, &attribs->level); -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_RENDER_TYPE, &attribs->render_type); -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_DOUBLEBUFFER, &attribs->doubleBuffer); -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_STEREO, &attribs->stereo); -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_AUX_BUFFERS, &attribs->auxBuffers); -+ -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_RED_SIZE, &attribs->redSize); -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_GREEN_SIZE, &attribs->greenSize); -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_BLUE_SIZE, &attribs->blueSize); -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_ALPHA_SIZE, &attribs->alphaSize); -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_DEPTH_SIZE, &attribs->depthSize); -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_STENCIL_SIZE, &attribs->stencilSize); -+ -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_RED_SIZE, &attribs->accumRedSize); -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_GREEN_SIZE, &attribs->accumGreenSize); -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_BLUE_SIZE, &attribs->accumBlueSize); -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_ACCUM_ALPHA_SIZE, &attribs->accumAlphaSize); -+ -+ /* get transparent pixel stuff */ -+ glXGetFBConfigAttrib(dpy, fbconfig,GLX_TRANSPARENT_TYPE, &attribs->transparentType); -+ if (attribs->transparentType == GLX_TRANSPARENT_RGB) { -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_RED_VALUE, &attribs->transparentRedValue); -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_GREEN_VALUE, &attribs->transparentGreenValue); -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_BLUE_VALUE, &attribs->transparentBlueValue); -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_ALPHA_VALUE, &attribs->transparentAlphaValue); -+ } -+ else if (attribs->transparentType == GLX_TRANSPARENT_INDEX) { -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_TRANSPARENT_INDEX_VALUE, &attribs->transparentIndexValue); -+ } -+ -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_SAMPLE_BUFFERS, &attribs->numMultisample); -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_SAMPLES, &attribs->numSamples); -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_CONFIG_CAVEAT, &attribs->visualCaveat); -+ -+#if defined(GLX_NV_float_buffer) -+ if (ext && strstr(ext, "GLX_NV_float_buffer")) { -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_FLOAT_COMPONENTS_NV, &attribs->floatComponents); -+ } -+#endif -+#if defined(GLX_ARB_fbconfig_float) -+ if (ext && strstr(ext, "GLX_ARB_fbconfig_float")) { -+ if (attribs->render_type & GLX_RGBA_FLOAT_BIT_ARB) { -+ attribs->floatComponents = True; -+ } -+ } -+#endif -+#if defined(GLX_EXT_fbconfig_packed_float) -+ if (ext && strstr(ext, "GLX_EXT_fbconfig_packed_float")) { -+ if (attribs->render_type & GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT) { -+ attribs->packedfloatComponents = True; -+ } -+ } -+#endif -+ -+#if defined(GLX_EXT_framebuffer_sRGB) -+ if (ext && strstr(ext, "GLX_EXT_framebuffer_sRGB")) { -+ glXGetFBConfigAttrib(dpy, fbconfig, GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT, &attribs->srgb); -+ } -+#endif -+ return True; -+} -+ -+#endif -+ -+ -+ -+static void -+print_visual_attribs_verbose(const struct visual_attribs *attribs, -+ int fbconfigs) -+{ -+ if (fbconfigs) { -+ printf("FBConfig ID: %x Visual ID=%x depth=%d class=%s, type=%s\n", -+ attribs->id, attribs->vis_id, attribs->depth, -+ visual_class_name(attribs->klass), -+ visual_drawable_type(attribs->drawableType)); -+ } -+ else { -+ printf("Visual ID: %x depth=%d class=%s, type=%s\n", -+ attribs->id, attribs->depth, visual_class_name(attribs->klass), -+ visual_drawable_type(attribs->drawableType)); -+ } -+ printf(" bufferSize=%d level=%d renderType=%s doubleBuffer=%d stereo=%d\n", -+ attribs->bufferSize, attribs->level, -+ visual_render_type_name(attribs->render_type), -+ attribs->doubleBuffer, attribs->stereo); -+ printf(" rgba: redSize=%d greenSize=%d blueSize=%d alphaSize=%d float=%c sRGB=%c\n", -+ attribs->redSize, attribs->greenSize, -+ attribs->blueSize, attribs->alphaSize, -+ attribs->packedfloatComponents ? 'P' : attribs->floatComponents ? 'Y' : 'N', -+ attribs->srgb ? 'Y' : 'N'); -+ printf(" auxBuffers=%d depthSize=%d stencilSize=%d\n", -+ attribs->auxBuffers, attribs->depthSize, attribs->stencilSize); -+ printf(" accum: redSize=%d greenSize=%d blueSize=%d alphaSize=%d\n", -+ attribs->accumRedSize, attribs->accumGreenSize, -+ attribs->accumBlueSize, attribs->accumAlphaSize); -+ printf(" multiSample=%d multiSampleBuffers=%d\n", -+ attribs->numSamples, attribs->numMultisample); -+#ifdef GLX_EXT_visual_rating -+ if (attribs->visualCaveat == GLX_NONE_EXT || attribs->visualCaveat == 0) -+ printf(" visualCaveat=None\n"); -+ else if (attribs->visualCaveat == GLX_SLOW_VISUAL_EXT) -+ printf(" visualCaveat=Slow\n"); -+ else if (attribs->visualCaveat == GLX_NON_CONFORMANT_VISUAL_EXT) -+ printf(" visualCaveat=Nonconformant\n"); -+#endif -+ if (attribs->transparentType == GLX_NONE) { -+ printf(" Opaque.\n"); -+ } -+ else if (attribs->transparentType == GLX_TRANSPARENT_RGB) { -+ printf(" Transparent RGB: Red=%d Green=%d Blue=%d Alpha=%d\n",attribs->transparentRedValue,attribs->transparentGreenValue,attribs->transparentBlueValue,attribs->transparentAlphaValue); -+ } -+ else if (attribs->transparentType == GLX_TRANSPARENT_INDEX) { -+ printf(" Transparent index=%d\n",attribs->transparentIndexValue); -+ } -+} -+ -+ -+static void -+print_visual_attribs_short_header(void) -+{ -+ printf(" visual x bf lv rg d st colorbuffer sr ax dp st accumbuffer ms cav\n"); -+ printf(" id dep cl sp sz l ci b ro r g b a F gb bf th cl r g b a ns b eat\n"); -+ printf("----------------------------------------------------------------------------\n"); -+} -+ -+ -+static void -+print_visual_attribs_short(const struct visual_attribs *attribs) -+{ -+ const char *caveat = caveat_string(attribs->visualCaveat); -+ -+ printf("0x%03x %2d %2s %2d %3d %2d %c%c %c %c %2d %2d %2d %2d %c %c %2d %2d %2d", -+ attribs->id, -+ attribs->depth, -+ visual_class_abbrev(attribs->klass), -+ attribs->transparentType != GLX_NONE, -+ attribs->bufferSize, -+ attribs->level, -+ (attribs->render_type & GLX_RGBA_BIT) ? 'r' : ' ', -+ (attribs->render_type & GLX_COLOR_INDEX_BIT) ? 'c' : ' ', -+ attribs->doubleBuffer ? 'y' : '.', -+ attribs->stereo ? 'y' : '.', -+ attribs->redSize, attribs->greenSize, -+ attribs->blueSize, attribs->alphaSize, -+ attribs->packedfloatComponents ? 'u' : attribs->floatComponents ? 'f' : '.', -+ attribs->srgb ? 's' : '.', -+ attribs->auxBuffers, -+ attribs->depthSize, -+ attribs->stencilSize -+ ); -+ -+ printf(" %2d %2d %2d %2d %2d %1d %s\n", -+ attribs->accumRedSize, attribs->accumGreenSize, -+ attribs->accumBlueSize, attribs->accumAlphaSize, -+ attribs->numSamples, attribs->numMultisample, -+ caveat -+ ); -+} -+ -+ -+static void -+print_visual_attribs_long_header(void) -+{ -+ printf("Vis Vis Visual Trans buff lev render DB ste r g b a s aux dep ste accum buffer MS MS \n"); -+ printf(" ID Depth Type parent size el type reo sz sz sz sz flt rgb buf th ncl r g b a num bufs caveats\n"); -+ printf("--------------------------------------------------------------------------------------------------------------------\n"); -+} -+ -+ -+static void -+print_visual_attribs_long(const struct visual_attribs *attribs) -+{ -+ const char *caveat = caveat_string(attribs->visualCaveat); -+ -+ printf("0x%3x %2d %-11s %2d %3d %2d %4s %3d %3d %3d %3d %3d %3d", -+ attribs->id, -+ attribs->depth, -+ visual_class_name(attribs->klass), -+ attribs->transparentType != GLX_NONE, -+ attribs->bufferSize, -+ attribs->level, -+ visual_render_type_name(attribs->render_type), -+ attribs->doubleBuffer, -+ attribs->stereo, -+ attribs->redSize, attribs->greenSize, -+ attribs->blueSize, attribs->alphaSize -+ ); -+ -+ printf(" %c %c %3d %4d %2d %3d %3d %3d %3d %2d %2d %6s\n", -+ attribs->floatComponents ? 'f' : '.', -+ attribs->srgb ? 's' : '.', -+ attribs->auxBuffers, -+ attribs->depthSize, -+ attribs->stencilSize, -+ attribs->accumRedSize, attribs->accumGreenSize, -+ attribs->accumBlueSize, attribs->accumAlphaSize, -+ attribs->numSamples, attribs->numMultisample, -+ caveat -+ ); -+} -+ -+ -+static void -+print_visual_info(Display *dpy, int scrnum, InfoMode mode) -+{ -+ XVisualInfo theTemplate; -+ XVisualInfo *visuals; -+ int numVisuals, numGlxVisuals; -+ long mask; -+ int i; -+ struct visual_attribs attribs; -+ -+ /* get list of all visuals on this screen */ -+ theTemplate.screen = scrnum; -+ mask = VisualScreenMask; -+ visuals = XGetVisualInfo(dpy, mask, &theTemplate, &numVisuals); -+ -+ numGlxVisuals = 0; -+ for (i = 0; i < numVisuals; i++) { -+ if (get_visual_attribs(dpy, &visuals[i], &attribs)) -+ numGlxVisuals++; -+ } -+ -+ if (numGlxVisuals == 0) -+ return; -+ -+ printf("%d GLX Visuals\n", numGlxVisuals); -+ -+ if (mode == Normal) -+ print_visual_attribs_short_header(); -+ else if (mode == Wide) -+ print_visual_attribs_long_header(); -+ -+ for (i = 0; i < numVisuals; i++) { -+ if (!get_visual_attribs(dpy, &visuals[i], &attribs)) -+ continue; -+ -+ if (mode == Verbose) -+ print_visual_attribs_verbose(&attribs, False); -+ else if (mode == Normal) -+ print_visual_attribs_short(&attribs); -+ else if (mode == Wide) -+ print_visual_attribs_long(&attribs); -+ } -+ printf("\n"); -+ -+ XFree(visuals); -+} -+ -+#ifdef GLX_VERSION_1_3 -+ -+static void -+print_fbconfig_info(Display *dpy, int scrnum, InfoMode mode) -+{ -+ int numFBConfigs = 0; -+ struct visual_attribs attribs; -+ GLXFBConfig *fbconfigs; -+ int i; -+ -+ /* get list of all fbconfigs on this screen */ -+ fbconfigs = glXGetFBConfigs(dpy, scrnum, &numFBConfigs); -+ -+ if (numFBConfigs == 0) { -+ XFree(fbconfigs); -+ return; -+ } -+ -+ printf("%d GLXFBConfigs:\n", numFBConfigs); -+ if (mode == Normal) -+ print_visual_attribs_short_header(); -+ else if (mode == Wide) -+ print_visual_attribs_long_header(); -+ -+ for (i = 0; i < numFBConfigs; i++) { -+ get_fbconfig_attribs(dpy, fbconfigs[i], &attribs); -+ -+ if (mode == Verbose) -+ print_visual_attribs_verbose(&attribs, True); -+ else if (mode == Normal) -+ print_visual_attribs_short(&attribs); -+ else if (mode == Wide) -+ print_visual_attribs_long(&attribs); -+ } -+ printf("\n"); -+ -+ XFree(fbconfigs); -+} -+ -+#endif -+ -+/* -+ * Stand-alone Mesa doesn't really implement the GLX protocol so it -+ * doesn't really know the GLX attributes associated with an X visual. -+ * The first time a visual is presented to Mesa's pseudo-GLX it -+ * attaches ancilliary buffers to it (like depth and stencil). -+ * But that usually only works if glXChooseVisual is used. -+ * This function calls glXChooseVisual() to sort of "prime the pump" -+ * for Mesa's GLX so that the visuals that get reported actually -+ * reflect what applications will see. -+ * This has no effect when using true GLX. -+ */ -+static void -+mesa_hack(Display *dpy, int scrnum) -+{ -+ static int attribs[] = { -+ GLX_RGBA, -+ GLX_RED_SIZE, 1, -+ GLX_GREEN_SIZE, 1, -+ GLX_BLUE_SIZE, 1, -+ GLX_DEPTH_SIZE, 1, -+ GLX_STENCIL_SIZE, 1, -+ GLX_ACCUM_RED_SIZE, 1, -+ GLX_ACCUM_GREEN_SIZE, 1, -+ GLX_ACCUM_BLUE_SIZE, 1, -+ GLX_ACCUM_ALPHA_SIZE, 1, -+ GLX_DOUBLEBUFFER, -+ None -+ }; -+ XVisualInfo *visinfo; -+ -+ visinfo = glXChooseVisual(dpy, scrnum, attribs); -+ if (visinfo) -+ XFree(visinfo); -+} -+ -+ -+/* -+ * Examine all visuals to find the so-called best one. -+ * We prefer deepest RGBA buffer with depth, stencil and accum -+ * that has no caveats. -+ */ -+static int -+find_best_visual(Display *dpy, int scrnum) -+{ -+ XVisualInfo theTemplate; -+ XVisualInfo *visuals; -+ int numVisuals; -+ long mask; -+ int i; -+ struct visual_attribs bestVis; -+ -+ /* get list of all visuals on this screen */ -+ theTemplate.screen = scrnum; -+ mask = VisualScreenMask; -+ visuals = XGetVisualInfo(dpy, mask, &theTemplate, &numVisuals); -+ -+ /* init bestVis with first visual info */ -+ get_visual_attribs(dpy, &visuals[0], &bestVis); -+ -+ /* try to find a "better" visual */ -+ for (i = 1; i < numVisuals; i++) { -+ struct visual_attribs vis; -+ -+ get_visual_attribs(dpy, &visuals[i], &vis); -+ -+ /* always skip visuals with caveats */ -+ if (vis.visualCaveat != GLX_NONE_EXT) -+ continue; -+ -+ /* see if this vis is better than bestVis */ -+ if ((!bestVis.supportsGL && vis.supportsGL) || -+ (bestVis.visualCaveat != GLX_NONE_EXT) || -+ (!(bestVis.render_type & GLX_RGBA_BIT) && (vis.render_type & GLX_RGBA_BIT)) || -+ (!bestVis.doubleBuffer && vis.doubleBuffer) || -+ (bestVis.redSize < vis.redSize) || -+ (bestVis.greenSize < vis.greenSize) || -+ (bestVis.blueSize < vis.blueSize) || -+ (bestVis.alphaSize < vis.alphaSize) || -+ (bestVis.depthSize < vis.depthSize) || -+ (bestVis.stencilSize < vis.stencilSize) || -+ (bestVis.accumRedSize < vis.accumRedSize)) { -+ /* found a better visual */ -+ bestVis = vis; -+ } -+ } -+ -+ XFree(visuals); -+ -+ return bestVis.id; -+} -+ -+ -+int -+main(int argc, char *argv[]) -+{ -+ Display *dpy; -+ int numScreens, scrnum; -+ struct options opts; -+ Bool coreWorked; -+ -+ parse_args(argc, argv, &opts); -+ -+ dpy = XOpenDisplay(opts.displayName); -+ if (!dpy) { -+ fprintf(stderr, "Error: unable to open display %s\n", -+ XDisplayName(opts.displayName)); -+ return -1; -+ } -+ -+ if (opts.findBest) { -+ int b; -+ mesa_hack(dpy, 0); -+ b = find_best_visual(dpy, 0); -+ printf("%d\n", b); -+ } -+ else { -+ numScreens = ScreenCount(dpy); -+ print_display_info(dpy); -+ for (scrnum = 0; scrnum < numScreens; scrnum++) { -+ mesa_hack(dpy, scrnum); -+ coreWorked = print_screen_info(dpy, scrnum, &opts, -+ True, False, opts.limits, False); -+ print_screen_info(dpy, scrnum, &opts, False, False, -+ opts.limits, coreWorked); -+ print_screen_info(dpy, scrnum, &opts, False, True, False, True); -+ -+ printf("\n"); -+ -+ if (opts.mode != Brief) { -+ print_visual_info(dpy, scrnum, opts.mode); -+#ifdef GLX_VERSION_1_3 -+ print_fbconfig_info(dpy, scrnum, opts.mode); -+#endif -+ } -+ -+ if (scrnum + 1 < numScreens) -+ printf("\n\n"); -+ } -+ } -+ -+ XCloseDisplay(dpy); -+ -+ return 0; -+} -diff -Naurp mesa-20.2.1-orig/src/glx/xdemos/meson.build mesa-20.2.1/src/glx/xdemos/meson.build ---- mesa-20.2.1-orig/src/glx/xdemos/meson.build 1969-12-31 18:00:00.000000000 -0600 -+++ mesa-20.2.1/src/glx/xdemos/meson.build 2020-10-15 23:07:14.486696790 -0500 -@@ -0,0 +1,32 @@ -+inc_xdemos = include_directories('.') -+ -+glxinfo_files = files( -+ 'glxinfo.c', -+ 'glinfo_common.c', -+) -+ -+x11_dep = dependency('x11', required: true) -+ -+executable('glxinfo', glxinfo_files, -+ install : true, -+ #c_args : gl_lib_cargs, -+ link_args : [ld_args_bsymbolic, ld_args_gc_sections, extra_ld_args_libgl, '-lm'], -+ link_with : libgl, -+ include_directories : [ inc_src, inc_include, inc_mesa, inc_glx], -+ dependencies : [x11_dep] -+) -+ -+executable('glxgears', 'glxgears.c', -+ install : true, -+ #c_args : gl_lib_cargs, -+ link_args : [ld_args_bsymbolic, ld_args_gc_sections, extra_ld_args_libgl, '-lm'], -+ link_with : libgl, -+ include_directories : [inc_src, inc_include, inc_mesa, inc_glx], -+ dependencies : [x11_dep] -+) -+ -+man_dir = get_option('prefix') + '/share/man/man1' -+install_data(['glxinfo.1', 'glxgears.1'], -+ install_dir : man_dir -+) -+ diff --git a/repo/mesa/mesa-21.3.7-nouveau_fixes-1.patch b/repo/mesa/mesa-21.3.7-nouveau_fixes-1.patch deleted file mode 100644 index ecf6008..0000000 --- a/repo/mesa/mesa-21.3.7-nouveau_fixes-1.patch +++ /dev/null @@ -1,2878 +0,0 @@ -Submitted By: Douglas R. Reno <renodr at linuxfromscratch dot org> -Date: 2022-02-11 -Initial Package Version: 21.3.6 -Upstream Status: Merge Request (Partial), Self -Origin: Upstream MR (#10752) with modifications -Description: Fixes several multi-threading related issues in the - Nouveau driver in Mesa. These issues can lead to - kernel panics and application crashes, and also cause - KDE Plasma in Wayland mode to instantly crash the system - once launched on a NVC0 or later card (NV50 is - unaffected). My changes include additional PUSH commands - to fix timing issues, which will be picked up upstream - shortly. Tested with KDE Plasma/Wayland, GNOME, VLC, - MPlayer, Minecraft, Discord, Zoom, XINE, and Kdenlive. - -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nouveau_buffer.c mesa-21.3.6/src/gallium/drivers/nouveau/nouveau_buffer.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nouveau_buffer.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nouveau_buffer.c 2022-02-11 16:51:08.220134863 -0600 -@@ -91,12 +91,8 @@ nouveau_buffer_release_gpu_storage(struc - { - assert(!(buf->status & NOUVEAU_BUFFER_STATUS_USER_PTR)); - -- if (buf->fence && buf->fence->state < NOUVEAU_FENCE_STATE_FLUSHED) { -- nouveau_fence_work(buf->fence, nouveau_fence_unref_bo, buf->bo); -- buf->bo = NULL; -- } else { -- nouveau_bo_ref(NULL, &buf->bo); -- } -+ nouveau_fence_work(buf->fence, nouveau_fence_unref_bo, buf->bo); -+ buf->bo = NULL; - - if (buf->mm) - release_allocation(&buf->mm, buf->fence); -@@ -172,7 +168,7 @@ nouveau_transfer_staging(struct nouveau_ - nouveau_mm_allocate(nv->screen->mm_GART, size, &tx->bo, &tx->offset); - if (tx->bo) { - tx->offset += adj; -- if (!nouveau_bo_map(tx->bo, 0, NULL)) -+ if (!BO_MAP(nv->screen, tx->bo, 0, NULL)) - tx->map = (uint8_t *)tx->bo->map + tx->offset; - } - } -@@ -195,7 +191,7 @@ nouveau_transfer_read(struct nouveau_con - nv->copy_data(nv, tx->bo, tx->offset, NOUVEAU_BO_GART, - buf->bo, buf->offset + base, buf->domain, size); - -- if (nouveau_bo_wait(tx->bo, NOUVEAU_BO_RD, nv->client)) -+ if (BO_WAIT(nv->screen, tx->bo, NOUVEAU_BO_RD, nv->client)) - return false; - - if (buf->data) -@@ -233,8 +229,8 @@ nouveau_transfer_write(struct nouveau_co - else - nv->push_data(nv, buf->bo, buf->offset + base, buf->domain, size, data); - -- nouveau_fence_ref(nv->screen->fence.current, &buf->fence); -- nouveau_fence_ref(nv->screen->fence.current, &buf->fence_wr); -+ nouveau_fence_ref(nv->fence, &buf->fence); -+ nouveau_fence_ref(nv->fence, &buf->fence_wr); - } - - /* Does a CPU wait for the buffer's backing data to become reliably accessible -@@ -303,10 +299,9 @@ nouveau_buffer_transfer_del(struct nouve - { - if (tx->map) { - if (likely(tx->bo)) { -- nouveau_fence_work(nv->screen->fence.current, -- nouveau_fence_unref_bo, tx->bo); -+ nouveau_fence_work(nv->fence, nouveau_fence_unref_bo, tx->bo); - if (tx->mm) -- release_allocation(&tx->mm, nv->screen->fence.current); -+ release_allocation(&tx->mm, nv->fence); - } else { - align_free(tx->map - - (tx->base.box.x & NOUVEAU_MIN_BUFFER_MAP_ALIGN_MASK)); -@@ -475,9 +470,9 @@ nouveau_buffer_transfer_map(struct pipe_ - * wait on the whole slab and instead use the logic below to return a - * reasonable buffer for that case. - */ -- ret = nouveau_bo_map(buf->bo, -- buf->mm ? 0 : nouveau_screen_transfer_flags(usage), -- nv->client); -+ ret = BO_MAP(nv->screen, buf->bo, -+ buf->mm ? 0 : nouveau_screen_transfer_flags(usage), -+ nv->client); - if (ret) { - FREE(tx); - return NULL; -@@ -601,11 +596,11 @@ nouveau_copy_buffer(struct nouveau_conte - src->bo, src->offset + srcx, src->domain, size); - - dst->status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING; -- nouveau_fence_ref(nv->screen->fence.current, &dst->fence); -- nouveau_fence_ref(nv->screen->fence.current, &dst->fence_wr); -+ nouveau_fence_ref(nv->fence, &dst->fence); -+ nouveau_fence_ref(nv->fence, &dst->fence_wr); - - src->status |= NOUVEAU_BUFFER_STATUS_GPU_READING; -- nouveau_fence_ref(nv->screen->fence.current, &src->fence); -+ nouveau_fence_ref(nv->fence, &src->fence); - } else { - struct pipe_box src_box; - src_box.x = srcx; -@@ -643,10 +638,10 @@ nouveau_resource_map_offset(struct nouve - unsigned rw; - rw = (flags & NOUVEAU_BO_WR) ? PIPE_MAP_WRITE : PIPE_MAP_READ; - nouveau_buffer_sync(nv, res, rw); -- if (nouveau_bo_map(res->bo, 0, NULL)) -+ if (BO_MAP(nv->screen, res->bo, 0, NULL)) - return NULL; - } else { -- if (nouveau_bo_map(res->bo, flags, nv->client)) -+ if (BO_MAP(nv->screen, res->bo, flags, nv->client)) - return NULL; - } - return (uint8_t *)res->bo->map + res->offset + offset; -@@ -802,7 +797,7 @@ nouveau_buffer_data_fetch(struct nouveau - { - if (!nouveau_buffer_malloc(buf)) - return false; -- if (nouveau_bo_map(bo, NOUVEAU_BO_RD, nv->client)) -+ if (BO_MAP(nv->screen, bo, NOUVEAU_BO_RD, nv->client)) - return false; - memcpy(buf->data, (uint8_t *)bo->map + offset, size); - return true; -@@ -827,7 +822,7 @@ nouveau_buffer_migrate(struct nouveau_co - if (new_domain == NOUVEAU_BO_GART && old_domain == 0) { - if (!nouveau_buffer_allocate(screen, buf, new_domain)) - return false; -- ret = nouveau_bo_map(buf->bo, 0, nv->client); -+ ret = BO_MAP(nv->screen, buf->bo, 0, nv->client); - if (ret) - return ret; - memcpy((uint8_t *)buf->bo->map + buf->offset, buf->data, size); -@@ -853,9 +848,9 @@ nouveau_buffer_migrate(struct nouveau_co - nv->copy_data(nv, buf->bo, buf->offset, new_domain, - bo, offset, old_domain, buf->base.width0); - -- nouveau_fence_work(screen->fence.current, nouveau_fence_unref_bo, bo); -+ nouveau_fence_work(nv->fence, nouveau_fence_unref_bo, bo); - if (mm) -- release_allocation(&mm, screen->fence.current); -+ release_allocation(&mm, nv->fence); - } else - if (new_domain == NOUVEAU_BO_VRAM && old_domain == 0) { - struct nouveau_transfer tx; -@@ -897,7 +892,7 @@ nouveau_user_buffer_upload(struct nouvea - if (!nouveau_buffer_reallocate(screen, buf, NOUVEAU_BO_GART)) - return false; - -- ret = nouveau_bo_map(buf->bo, 0, nv->client); -+ ret = BO_MAP(nv->screen, buf->bo, 0, nv->client); - if (ret) - return false; - memcpy((uint8_t *)buf->bo->map + buf->offset + base, buf->data + base, size); -@@ -964,7 +959,7 @@ nouveau_scratch_runout_release(struct no - if (!nv->scratch.runout) - return; - -- if (!nouveau_fence_work(nv->screen->fence.current, nouveau_scratch_unref_bos, -+ if (!nouveau_fence_work(nv->fence, nouveau_scratch_unref_bos, - nv->scratch.runout)) - return; - -@@ -993,7 +988,7 @@ nouveau_scratch_runout(struct nouveau_co - - ret = nouveau_scratch_bo_alloc(nv, &nv->scratch.runout->bo[n], size); - if (!ret) { -- ret = nouveau_bo_map(nv->scratch.runout->bo[n], 0, NULL); -+ ret = BO_MAP(nv->screen, nv->scratch.runout->bo[n], 0, NULL); - if (ret) - nouveau_bo_ref(NULL, &nv->scratch.runout->bo[--nv->scratch.runout->nr]); - } -@@ -1031,7 +1026,7 @@ nouveau_scratch_next(struct nouveau_cont - nv->scratch.offset = 0; - nv->scratch.end = nv->scratch.bo_size; - -- ret = nouveau_bo_map(bo, NOUVEAU_BO_WR, nv->client); -+ ret = BO_MAP(nv->screen, bo, NOUVEAU_BO_WR, nv->client); - if (!ret) - nv->scratch.map = bo->map; - return !ret; -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nouveau_context.h mesa-21.3.6/src/gallium/drivers/nouveau/nouveau_context.h ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nouveau_context.h 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nouveau_context.h 2022-02-11 16:51:52.682577582 -0600 -@@ -15,6 +15,7 @@ struct nouveau_context { - - struct nouveau_client *client; - struct nouveau_pushbuf *pushbuf; -+ struct nouveau_fence *fence; - struct pipe_debug_callback debug; - - bool vbo_dirty; -@@ -66,7 +67,7 @@ void - nouveau_context_init_vdec(struct nouveau_context *); - - void --nouveau_context_init(struct nouveau_context *); -+nouveau_context_init(struct nouveau_context *, struct nouveau_screen *); - - void - nouveau_scratch_runout_release(struct nouveau_context *); -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nouveau_fence.c mesa-21.3.6/src/gallium/drivers/nouveau/nouveau_fence.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nouveau_fence.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nouveau_fence.c 2022-02-11 17:03:39.714131948 -0600 -@@ -21,6 +21,7 @@ - */ - - #include "nouveau_screen.h" -+#include "nouveau_context.h" - #include "nouveau_winsys.h" - #include "nouveau_fence.h" - #include "util/os_time.h" -@@ -30,13 +31,14 @@ - #endif - - bool --nouveau_fence_new(struct nouveau_screen *screen, struct nouveau_fence **fence) -+nouveau_fence_new(struct nouveau_context *nv, struct nouveau_fence **fence) - { - *fence = CALLOC_STRUCT(nouveau_fence); - if (!*fence) - return false; - -- (*fence)->screen = screen; -+ (*fence)->screen = nv->screen; -+ (*fence)->context = nv; - (*fence)->ref = 1; - list_inithead(&(*fence)->work); - -@@ -59,22 +61,25 @@ void - nouveau_fence_emit(struct nouveau_fence *fence) - { - struct nouveau_screen *screen = fence->screen; -+ struct nouveau_fence_list *fence_list = &screen->fence; - -- assert(fence->state == NOUVEAU_FENCE_STATE_AVAILABLE); -+ assert(fence->state != NOUVEAU_FENCE_STATE_EMITTING); -+ if (fence->state >= NOUVEAU_FENCE_STATE_EMITTED) -+ return; - - /* set this now, so that if fence.emit triggers a flush we don't recurse */ - fence->state = NOUVEAU_FENCE_STATE_EMITTING; - - ++fence->ref; - -- if (screen->fence.tail) -- screen->fence.tail->next = fence; -+ if (fence_list->tail) -+ fence_list->tail->next = fence; - else -- screen->fence.head = fence; -+ fence_list->head = fence; - -- screen->fence.tail = fence; -+ fence_list->tail = fence; - -- screen->fence.emit(&screen->base, &fence->sequence); -+ fence_list->emit(&screen->base, &fence->sequence); - - assert(fence->state == NOUVEAU_FENCE_STATE_EMITTING); - fence->state = NOUVEAU_FENCE_STATE_EMITTED; -@@ -84,19 +89,19 @@ void - nouveau_fence_del(struct nouveau_fence *fence) - { - struct nouveau_fence *it; -- struct nouveau_screen *screen = fence->screen; -+ struct nouveau_fence_list *fence_list = &fence->screen->fence; - - if (fence->state == NOUVEAU_FENCE_STATE_EMITTED || - fence->state == NOUVEAU_FENCE_STATE_FLUSHED) { -- if (fence == screen->fence.head) { -- screen->fence.head = fence->next; -- if (!screen->fence.head) -- screen->fence.tail = NULL; -+ if (fence == fence_list->head) { -+ fence_list->head = fence->next; -+ if (!fence_list->head) -+ fence_list->tail = NULL; - } else { -- for (it = screen->fence.head; it && it->next != fence; it = it->next); -+ for (it = fence_list->head; it && it->next != fence; it = it->next); - it->next = fence->next; -- if (screen->fence.tail == fence) -- screen->fence.tail = it; -+ if (fence_list->tail == fence) -+ fence_list->tail = it; - } - } - -@@ -109,18 +114,19 @@ nouveau_fence_del(struct nouveau_fence * - } - - void --nouveau_fence_cleanup(struct nouveau_screen *screen) -+nouveau_fence_cleanup(struct nouveau_context *nv) - { -- if (screen->fence.current) { -+ struct nouveau_fence_list *fence_list = &nv->screen->fence; -+ if (nv->fence) { - struct nouveau_fence *current = NULL; - - /* nouveau_fence_wait will create a new current fence, so wait on the - * _current_ one, and remove both. - */ -- nouveau_fence_ref(screen->fence.current, ¤t); -+ nouveau_fence_ref(nv->fence, ¤t); - nouveau_fence_wait(current, NULL); - nouveau_fence_ref(NULL, ¤t); -- nouveau_fence_ref(NULL, &screen->fence.current); -+ nouveau_fence_ref(NULL, &nv->fence); - } - } - -@@ -129,13 +135,14 @@ nouveau_fence_update(struct nouveau_scre - { - struct nouveau_fence *fence; - struct nouveau_fence *next = NULL; -- u32 sequence = screen->fence.update(&screen->base); -+ struct nouveau_fence_list *fence_list = &screen->fence; -+ u32 sequence = fence_list->update(&screen->base); - -- if (screen->fence.sequence_ack == sequence) -+ if (fence_list->sequence_ack == sequence) - return; -- screen->fence.sequence_ack = sequence; -+ fence_list->sequence_ack = sequence; - -- for (fence = screen->fence.head; fence; fence = next) { -+ for (fence = fence_list->head; fence; fence = next) { - next = fence->next; - sequence = fence->sequence; - -@@ -144,12 +151,12 @@ nouveau_fence_update(struct nouveau_scre - nouveau_fence_trigger_work(fence); - nouveau_fence_ref(NULL, &fence); - -- if (sequence == screen->fence.sequence_ack) -+ if (sequence == fence_list->sequence_ack) - break; - } -- screen->fence.head = next; -+ fence_list->head = next; - if (!next) -- screen->fence.tail = NULL; -+ fence_list->tail = NULL; - - if (flushed) { - for (fence = next; fence; fence = fence->next) -@@ -178,25 +185,23 @@ static bool - nouveau_fence_kick(struct nouveau_fence *fence) - { - struct nouveau_screen *screen = fence->screen; -+ struct nouveau_fence_list *fence_list = &screen->fence; -+ bool current = !fence->sequence; - - /* wtf, someone is waiting on a fence in flush_notify handler? */ - assert(fence->state != NOUVEAU_FENCE_STATE_EMITTING); - - if (fence->state < NOUVEAU_FENCE_STATE_EMITTED) { - PUSH_SPACE(screen->pushbuf, 8); -- /* The space allocation might trigger a flush, which could emit the -- * current fence. So check again. -- */ -- if (fence->state < NOUVEAU_FENCE_STATE_EMITTED) -- nouveau_fence_emit(fence); -+ nouveau_fence_emit(fence); - } - - if (fence->state < NOUVEAU_FENCE_STATE_FLUSHED) - if (nouveau_pushbuf_kick(screen->pushbuf, screen->pushbuf->channel)) - return false; - -- if (fence == screen->fence.current) -- nouveau_fence_next(screen); -+ if (current) -+ nouveau_fence_next(fence->context); - - nouveau_fence_update(screen, false); - -@@ -207,6 +212,7 @@ bool - nouveau_fence_wait(struct nouveau_fence *fence, struct pipe_debug_callback *debug) - { - struct nouveau_screen *screen = fence->screen; -+ struct nouveau_fence_list *fence_list = &screen->fence; - uint32_t spins = 0; - int64_t start = 0; - -@@ -237,24 +243,26 @@ nouveau_fence_wait(struct nouveau_fence - - debug_printf("Wait on fence %u (ack = %u, next = %u) timed out !\n", - fence->sequence, -- screen->fence.sequence_ack, screen->fence.sequence); -+ fence_list->sequence_ack, fence_list->sequence); - - return false; - } - - void --nouveau_fence_next(struct nouveau_screen *screen) -+nouveau_fence_next(struct nouveau_context *nv) - { -- if (screen->fence.current->state < NOUVEAU_FENCE_STATE_EMITTING) { -- if (screen->fence.current->ref > 1) -- nouveau_fence_emit(screen->fence.current); -+ struct nouveau_fence_list *fence_list = &nv->screen->fence; -+ -+ if (nv->fence->state < NOUVEAU_FENCE_STATE_EMITTING) { -+ if (nv->fence->ref > 1) -+ nouveau_fence_emit(nv->fence); - else - return; - } - -- nouveau_fence_ref(NULL, &screen->fence.current); -+ nouveau_fence_ref(NULL, &nv->fence); - -- nouveau_fence_new(screen, &screen->fence.current); -+ nouveau_fence_new(nv, &nv->fence); - } - - void -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nouveau_fence.h mesa-21.3.6/src/gallium/drivers/nouveau/nouveau_fence.h ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nouveau_fence.h 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nouveau_fence.h 2022-02-11 17:06:52.375811111 -0600 -@@ -22,6 +22,7 @@ struct nouveau_fence_work { - struct nouveau_fence { - struct nouveau_fence *next; - struct nouveau_screen *screen; -+ struct nouveau_context *context; - int state; - int ref; - uint32_t sequence; -@@ -29,14 +30,23 @@ struct nouveau_fence { - struct list_head work; - }; - -+struct nouveau_fence_list { -+ struct nouveau_fence *head; -+ struct nouveau_fence *tail; -+ uint32_t sequence; -+ uint32_t sequence_ack; -+ void (*emit)(struct pipe_screen *, uint32_t *sequence); -+ uint32_t (*update)(struct pipe_screen *); -+}; -+ - void nouveau_fence_emit(struct nouveau_fence *); - void nouveau_fence_del(struct nouveau_fence *); - --bool nouveau_fence_new(struct nouveau_screen *, struct nouveau_fence **); --void nouveau_fence_cleanup(struct nouveau_screen *); -+bool nouveau_fence_new(struct nouveau_context *, struct nouveau_fence **); -+void nouveau_fence_cleanup(struct nouveau_context *); - bool nouveau_fence_work(struct nouveau_fence *, void (*)(void *), void *); - void nouveau_fence_update(struct nouveau_screen *, bool flushed); --void nouveau_fence_next(struct nouveau_screen *); -+void nouveau_fence_next(struct nouveau_context *); - bool nouveau_fence_wait(struct nouveau_fence *, struct pipe_debug_callback *); - bool nouveau_fence_signalled(struct nouveau_fence *); - -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nouveau_mm.c mesa-21.3.6/src/gallium/drivers/nouveau/nouveau_mm.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nouveau_mm.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nouveau_mm.c 2022-02-11 17:09:55.188637737 -0600 -@@ -1,6 +1,7 @@ - - #include <inttypes.h> - -+#include "util/simple_mtx.h" - #include "util/u_inlines.h" - #include "util/u_memory.h" - #include "util/list.h" -@@ -29,6 +30,7 @@ struct mm_bucket { - struct list_head used; - struct list_head full; - int num_free; -+ simple_mtx_t lock; - }; - - struct nouveau_mman { -@@ -124,6 +126,8 @@ mm_slab_new(struct nouveau_mman *cache, - int words, ret; - const uint32_t size = mm_default_slab_size(chunk_order); - -+ simple_mtx_assert_locked(&bucket->lock); -+ - words = ((size >> chunk_order) + 31) / 32; - assert(words); - -@@ -151,7 +155,7 @@ mm_slab_new(struct nouveau_mman *cache, - assert(bucket == mm_bucket_by_order(cache, chunk_order)); - list_add(&slab->head, &bucket->free); - -- cache->allocated += size; -+ p_atomic_add(&cache->allocated, size); - - if (nouveau_mesa_debug) - debug_printf("MM: new slab, total memory = %"PRIu64" KiB\n", -@@ -182,6 +186,11 @@ nouveau_mm_allocate(struct nouveau_mman - return NULL; - } - -+ alloc = MALLOC_STRUCT(nouveau_mm_allocation); -+ if (!alloc) -+ return NULL; -+ -+ simple_mtx_lock(&bucket->lock); - if (!list_is_empty(&bucket->used)) { - slab = LIST_ENTRY(struct mm_slab, bucket->used.next, head); - } else { -@@ -196,16 +205,13 @@ nouveau_mm_allocate(struct nouveau_mman - - *offset = mm_slab_alloc(slab) << slab->order; - -- alloc = MALLOC_STRUCT(nouveau_mm_allocation); -- if (!alloc) -- return NULL; -- - nouveau_bo_ref(slab->bo, bo); - - if (slab->free == 0) { - list_del(&slab->head); - list_add(&slab->head, &bucket->full); - } -+ simple_mtx_unlock(&bucket->lock); - - alloc->offset = *offset; - alloc->priv = (void *)slab; -@@ -229,6 +235,7 @@ nouveau_mm_free(struct nouveau_mm_alloca - list_del(&slab->head); - list_addtail(&slab->head, &bucket->used); - } -+ simple_mtx_unlock(&bucket->lock); - - FREE(alloc); - } -@@ -258,6 +265,7 @@ nouveau_mm_create(struct nouveau_device - list_inithead(&cache->bucket[i].free); - list_inithead(&cache->bucket[i].used); - list_inithead(&cache->bucket[i].full); -+ simple_mtx_init(&cache->bucket[i].lock, mtx_plain); - } - - return cache; -@@ -292,6 +300,7 @@ nouveau_mm_destroy(struct nouveau_mman * - nouveau_mm_free_slabs(&cache->bucket[i].free); - nouveau_mm_free_slabs(&cache->bucket[i].used); - nouveau_mm_free_slabs(&cache->bucket[i].full); -+ simple_mtx_destroy(&cache->bucket[i].lock); - } - - FREE(cache); -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nouveau_screen.c mesa-21.3.6/src/gallium/drivers/nouveau/nouveau_screen.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nouveau_screen.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nouveau_screen.c 2022-02-11 17:11:30.951045828 -0600 -@@ -394,7 +394,11 @@ nouveau_set_debug_callback(struct pipe_c - } - - void --nouveau_context_init(struct nouveau_context *context) -+nouveau_context_init(struct nouveau_context *context, struct nouveau_screen *screen) - { - context->pipe.set_debug_callback = nouveau_set_debug_callback; -+ -+ context->screen = screen; -+ context->client = screen->client; -+ context->pushbuf = screen->pushbuf; - } -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nouveau_screen.h mesa-21.3.6/src/gallium/drivers/nouveau/nouveau_screen.h ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nouveau_screen.h 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nouveau_screen.h 2022-02-11 17:12:22.999729379 -0600 -@@ -6,6 +6,8 @@ - #include "util/u_atomic.h" - #include "util/u_memory.h" - -+#include "nouveau_fence.h" -+ - #ifndef NDEBUG - # define NOUVEAU_ENABLE_DRIVER_STATISTICS - #endif -@@ -44,15 +46,7 @@ struct nouveau_screen { - - uint16_t class_3d; - -- struct { -- struct nouveau_fence *head; -- struct nouveau_fence *tail; -- struct nouveau_fence *current; -- u32 sequence; -- u32 sequence_ack; -- void (*emit)(struct pipe_screen *, u32 *sequence); -- u32 (*update)(struct pipe_screen *); -- } fence; -+ struct nouveau_fence_list fence; - - struct nouveau_mman *mm_VRAM; - struct nouveau_mman *mm_GART; -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nouveau_video.c mesa-21.3.6/src/gallium/drivers/nouveau/nouveau_video.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nouveau_video.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nouveau_video.c 2022-02-11 17:13:47.703221196 -0600 -@@ -37,12 +37,12 @@ nouveau_vpe_init(struct nouveau_decoder - int ret; - if (dec->cmds) - return 0; -- ret = nouveau_bo_map(dec->cmd_bo, NOUVEAU_BO_RDWR, dec->client); -+ ret = BO_MAP(dec->screen, dec->cmd_bo, NOUVEAU_BO_RDWR, dec->client); - if (ret) { - debug_printf("Mapping cmd bo: %s\n", strerror(-ret)); - return ret; - } -- ret = nouveau_bo_map(dec->data_bo, NOUVEAU_BO_RDWR, dec->client); -+ ret = BO_MAP(dec->screen, dec->data_bo, NOUVEAU_BO_RDWR, dec->client); - if (ret) { - debug_printf("Mapping data bo: %s\n", strerror(-ret)); - return ret; -@@ -73,7 +73,7 @@ nouveau_vpe_fini(struct nouveau_decoder - if (!dec->cmds) - return; - -- nouveau_pushbuf_space(push, 16, 2, 0); -+ PUSH_SPACE_EX(push, 16, 2, 0); - nouveau_bufctx_reset(dec->bufctx, NV31_VIDEO_BIND_CMD); - - #define BCTX_ARGS dec->bufctx, NV31_VIDEO_BIND_CMD, NOUVEAU_BO_RD -@@ -88,7 +88,7 @@ nouveau_vpe_fini(struct nouveau_decoder - - #undef BCTX_ARGS - -- if (unlikely(nouveau_pushbuf_validate(dec->push))) -+ if (unlikely(PUSH_VAL(dec->push))) - return; - - BEGIN_NV04(push, NV31_MPEG(EXEC), 1); -@@ -582,13 +582,13 @@ nouveau_create_decoder(struct pipe_conte - 0, 4096, NULL, &dec->fence_bo); - if (ret) - goto fail; -- nouveau_bo_map(dec->fence_bo, NOUVEAU_BO_RDWR, NULL); -+ BO_MAP(dec->fence_bo, NOUVEAU_BO_RDWR, NULL); - dec->fence_map = dec->fence_bo->map; - dec->fence_map[0] = 0; - #endif - - nouveau_pushbuf_bufctx(dec->push, dec->bufctx); -- nouveau_pushbuf_space(push, 32, 4, 0); -+ PUSH_SPACE_EX(push, 32, 4, 0); - - BEGIN_NV04(push, SUBC_MPEG(NV01_SUBCHAN_OBJECT), 1); - PUSH_DATA (push, dec->mpeg->handle); -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nouveau_vp3_video.c mesa-21.3.6/src/gallium/drivers/nouveau/nouveau_vp3_video.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nouveau_vp3_video.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nouveau_vp3_video.c 2022-02-11 17:14:38.549919717 -0600 -@@ -27,6 +27,7 @@ - - #include <nvif/class.h> - -+#include "nouveau_winsys.h" - #include "nouveau_screen.h" - #include "nouveau_context.h" - #include "nouveau_vp3_video.h" -@@ -284,13 +285,14 @@ nouveau_vp3_load_firmware(struct nouveau - char path[PATH_MAX]; - ssize_t r; - uint32_t *end, endval; -+ struct nouveau_screen *screen = nouveau_screen(dec->base.context->screen); - - if (chipset >= 0xa3 && chipset != 0xaa && chipset != 0xac) - vp4_getpath(profile, path); - else - vp3_getpath(profile, path); - -- if (nouveau_bo_map(dec->fw_bo, NOUVEAU_BO_WR, dec->client)) -+ if (BO_MAP(screen, dec->fw_bo, NOUVEAU_BO_WR, dec->client)) - return 1; - - fd = open(path, O_RDONLY | O_CLOEXEC); -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nouveau_winsys.h mesa-21.3.6/src/gallium/drivers/nouveau/nouveau_winsys.h ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nouveau_winsys.h 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nouveau_winsys.h 2022-02-11 17:17:15.566002822 -0600 -@@ -9,6 +9,8 @@ - #include "drm-uapi/drm.h" - #include <nouveau.h> - -+#include "nouveau_screen.h" -+ - #ifndef NV04_PFIFO_MAX_PACKET_LEN - #define NV04_PFIFO_MAX_PACKET_LEN 2047 - #endif -@@ -23,12 +25,18 @@ PUSH_AVAIL(struct nouveau_pushbuf *push) - } - - static inline bool -+PUSH_SPACE_EX(struct nouveau_pushbuf *push, uint32_t size, uint32_t relocs, uint32_t pushes) -+{ -+ return nouveau_pushbuf_space(push, size, relocs, pushes) == 0; -+} -+ -+static inline bool - PUSH_SPACE(struct nouveau_pushbuf *push, uint32_t size) - { - /* Provide a buffer so that fences always have room to be emitted */ - size += 8; - if (PUSH_AVAIL(push) < size) -- return nouveau_pushbuf_space(push, size, 0, 0) == 0; -+ return PUSH_SPACE_EX(push, size, 0, 0); - return true; - } - -@@ -66,6 +74,23 @@ PUSH_KICK(struct nouveau_pushbuf *push) - nouveau_pushbuf_kick(push, push->channel); - } - -+static inline int -+PUSH_VAL(struct nouveau_pushbuf *push) -+{ -+ return nouveau_pushbuf_validate(push); -+} -+ -+static inline int -+BO_MAP(struct nouveau_screen *screen, struct nouveau_bo *bo, uint32_t access, struct nouveau_client *client) -+{ -+ return nouveau_bo_map(bo, access, client); -+} -+ -+static inline int -+BO_WAIT(struct nouveau_screen *screen, struct nouveau_bo *bo, uint32_t access, struct nouveau_client *client) -+{ -+ return nouveau_bo_wait(bo, access, client); -+} - - #define NOUVEAU_RESOURCE_FLAG_LINEAR (PIPE_RESOURCE_FLAG_DRV_PRIV << 0) - #define NOUVEAU_RESOURCE_FLAG_DRV_PRIV (PIPE_RESOURCE_FLAG_DRV_PRIV << 1) -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv30/nv30_clear.c mesa-21.3.6/src/gallium/drivers/nouveau/nv30/nv30_clear.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv30/nv30_clear.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv30/nv30_clear.c 2022-02-11 14:24:23.189190438 -0600 -@@ -128,7 +128,7 @@ nv30_clear_render_target(struct pipe_con - - refn.bo = mt->base.bo; - refn.flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_WR; -- if (nouveau_pushbuf_space(push, 32, 1, 0) || -+ if (!PUSH_SPACE_EX(push, 32, 1, 0) || - nouveau_pushbuf_refn (push, &refn, 1)) - return; - -@@ -193,7 +193,7 @@ nv30_clear_depth_stencil(struct pipe_con - - refn.bo = mt->base.bo; - refn.flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_WR; -- if (nouveau_pushbuf_space(push, 32, 1, 0) || -+ if (!PUSH_SPACE_EX(push, 32, 1, 0) || - nouveau_pushbuf_refn (push, &refn, 1)) - return; - -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv30/nv30_context.c mesa-21.3.6/src/gallium/drivers/nouveau/nv30/nv30_context.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv30/nv30_context.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv30/nv30_context.c 2022-02-11 14:28:00.534301647 -0600 -@@ -45,7 +45,7 @@ nv30_context_kick_notify(struct nouveau_ - nv30 = container_of(push->user_priv, struct nv30_context, bufctx); - screen = &nv30->screen->base; - -- nouveau_fence_next(screen); -+ nouveau_fence_next(&nv30->base); - nouveau_fence_update(screen, true); - - if (push->bufctx) { -@@ -53,13 +53,13 @@ nv30_context_kick_notify(struct nouveau_ - LIST_FOR_EACH_ENTRY(bref, &push->bufctx->current, thead) { - struct nv04_resource *res = bref->priv; - if (res && res->mm) { -- nouveau_fence_ref(screen->fence.current, &res->fence); -+ nouveau_fence_ref(nv30->base.fence, &res->fence); - - if (bref->flags & NOUVEAU_BO_RD) - res->status |= NOUVEAU_BUFFER_STATUS_GPU_READING; - - if (bref->flags & NOUVEAU_BO_WR) { -- nouveau_fence_ref(screen->fence.current, &res->fence_wr); -+ nouveau_fence_ref(nv30->base.fence, &res->fence_wr); - res->status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING | - NOUVEAU_BUFFER_STATUS_DIRTY; - } -@@ -76,7 +76,7 @@ nv30_context_flush(struct pipe_context * - struct nouveau_pushbuf *push = nv30->base.pushbuf; - - if (fence) -- nouveau_fence_ref(nv30->screen->base.fence.current, -+ nouveau_fence_ref(nv30->base.fence, - (struct nouveau_fence **)fence); - - PUSH_KICK(push); -@@ -176,6 +176,7 @@ nv30_context_destroy(struct pipe_context - if (nv30->screen->cur_ctx == nv30) - nv30->screen->cur_ctx = NULL; - -+ nouveau_fence_cleanup(&nv30->base); - nouveau_context_destroy(&nv30->base); - } - -@@ -191,7 +192,6 @@ nv30_context_create(struct pipe_screen * - { - struct nv30_screen *screen = nv30_screen(pscreen); - struct nv30_context *nv30 = CALLOC_STRUCT(nv30_context); -- struct nouveau_pushbuf *push; - struct pipe_context *pipe; - int ret; - -@@ -199,7 +199,6 @@ nv30_context_create(struct pipe_screen * - return NULL; - - nv30->screen = screen; -- nv30->base.screen = &screen->base; - nv30->base.copy_data = nv30_transfer_copy_data; - - pipe = &nv30->base.pipe; -@@ -208,6 +207,9 @@ nv30_context_create(struct pipe_screen * - pipe->destroy = nv30_context_destroy; - pipe->flush = nv30_context_flush; - -+ nouveau_context_init(&nv30->base, &screen->base); -+ nv30->base.pushbuf->kick_notify = nv30_context_kick_notify; -+ - nv30->base.pipe.stream_uploader = u_upload_create_default(&nv30->base.pipe); - if (!nv30->base.pipe.stream_uploader) { - nv30_context_destroy(pipe); -@@ -215,14 +217,6 @@ nv30_context_create(struct pipe_screen * - } - nv30->base.pipe.const_uploader = nv30->base.pipe.stream_uploader; - -- /*XXX: *cough* per-context client */ -- nv30->base.client = screen->base.client; -- -- /*XXX: *cough* per-context pushbufs */ -- push = screen->base.pushbuf; -- nv30->base.pushbuf = push; -- push->kick_notify = nv30_context_kick_notify; -- - nv30->base.invalidate_resource_storage = nv30_invalidate_resource_storage; - - ret = nouveau_bufctx_new(nv30->base.client, 64, &nv30->bufctx); -@@ -244,7 +238,6 @@ nv30_context_create(struct pipe_screen * - if (debug_get_bool_option("NV30_SWTNL", false)) - nv30->draw_flags |= NV30_NEW_SWTNL; - -- nouveau_context_init(&nv30->base); - nv30->sample_mask = 0xffff; - nv30_vbo_init(pipe); - nv30_query_init(pipe); -@@ -265,6 +258,7 @@ nv30_context_create(struct pipe_screen * - } - - nouveau_context_init_vdec(&nv30->base); -+ nouveau_fence_new(&nv30->base, &nv30->base.fence); - - return pipe; - } -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv30/nv30_draw.c mesa-21.3.6/src/gallium/drivers/nouveau/nv30/nv30_draw.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv30/nv30_draw.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv30/nv30_draw.c 2022-02-11 14:28:44.868118544 -0600 -@@ -124,7 +124,7 @@ nv30_render_draw_elements(struct vbuf_re - { - struct nv30_render *r = nv30_render(render); - struct nv30_context *nv30 = r->nv30; -- struct nouveau_pushbuf *push = nv30->screen->base.pushbuf; -+ struct nouveau_pushbuf *push = nv30->base.pushbuf; - unsigned i; - - BEGIN_NV04(push, NV30_3D(VTXBUF(0)), r->vertex_info.num_attribs); -@@ -280,7 +280,7 @@ nv30_render_validate(struct nv30_context - struct nv30_render *r = nv30_render(nv30->draw->render); - struct nv30_rasterizer_stateobj *rast = nv30->rast; - struct pipe_screen *pscreen = &nv30->screen->base.base; -- struct nouveau_pushbuf *push = nv30->screen->base.pushbuf; -+ struct nouveau_pushbuf *push = nv30->base.pushbuf; - struct nouveau_object *eng3d = nv30->screen->eng3d; - struct nv30_vertprog *vp = nv30->vertprog.program; - struct vertex_info *vinfo = &r->vertex_info; -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv30/nv30_miptree.c mesa-21.3.6/src/gallium/drivers/nouveau/nv30/nv30_miptree.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv30/nv30_miptree.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv30/nv30_miptree.c 2022-02-11 14:29:22.740961717 -0600 -@@ -359,7 +359,7 @@ nv30_miptree_transfer_map(struct pipe_co - if (usage & PIPE_MAP_WRITE) - access |= NOUVEAU_BO_WR; - -- ret = nouveau_bo_map(tx->tmp.bo, access, nv30->base.client); -+ ret = BO_MAP(nv30->base.screen, tx->tmp.bo, access, nv30->base.client); - if (ret) { - pipe_resource_reference(&tx->base.resource, NULL); - FREE(tx); -@@ -393,7 +393,7 @@ nv30_miptree_transfer_unmap(struct pipe_ - } - - /* Allow the copies above to finish executing before freeing the source */ -- nouveau_fence_work(nv30->screen->base.fence.current, -+ nouveau_fence_work(nv30->base.fence, - nouveau_fence_unref_bo, tx->tmp.bo); - } else { - nouveau_bo_ref(NULL, &tx->tmp.bo); -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv30/nv30_screen.c mesa-21.3.6/src/gallium/drivers/nouveau/nv30/nv30_screen.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv30/nv30_screen.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv30/nv30_screen.c 2022-02-11 14:30:44.381622525 -0600 -@@ -508,8 +508,6 @@ nv30_screen_destroy(struct pipe_screen * - if (!nouveau_drm_screen_unref(&screen->base)) - return; - -- nouveau_fence_cleanup(&screen->base); -- - nouveau_bo_ref(NULL, &screen->notify); - - nouveau_heap_destroy(&screen->query_heap); -@@ -684,7 +682,7 @@ nv30_screen_create(struct nouveau_device - - ret = nouveau_bo_wrap(screen->base.device, fifo->notify, &screen->notify); - if (ret == 0) -- ret = nouveau_bo_map(screen->notify, 0, screen->base.client); -+ ret = BO_MAP(&screen->base, screen->notify, 0, screen->base.client); - if (ret) - FAIL_SCREEN_INIT("error mapping notifier memory: %d\n", ret); - -@@ -811,9 +809,7 @@ nv30_screen_create(struct nouveau_device - PUSH_DATA (push, screen->ntfy->handle); - BEGIN_NV04(push, NV05_SIFM(COLOR_CONVERSION), 1); - PUSH_DATA (push, NV05_SIFM_COLOR_CONVERSION_TRUNCATE); -+ PUSH_KICK (push); - -- nouveau_pushbuf_kick(push, push->channel); -- -- nouveau_fence_new(&screen->base, &screen->base.fence.current); - return &screen->base; - } -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv30/nv30_state_validate.c mesa-21.3.6/src/gallium/drivers/nouveau/nv30/nv30_state_validate.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv30/nv30_state_validate.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv30/nv30_state_validate.c 2022-02-11 14:32:00.766303956 -0600 -@@ -463,7 +463,6 @@ nv30_state_context_switch(struct nv30_co - bool - nv30_state_validate(struct nv30_context *nv30, uint32_t mask, bool hwtnl) - { -- struct nouveau_screen *screen = &nv30->screen->base; - struct nouveau_pushbuf *push = nv30->base.pushbuf; - struct nouveau_bufctx *bctx = nv30->bufctx; - struct nouveau_bufref *bref; -@@ -499,7 +498,7 @@ nv30_state_validate(struct nv30_context - } - - nouveau_pushbuf_bufctx(push, bctx); -- if (nouveau_pushbuf_validate(push)) { -+ if (PUSH_VAL(push)) { - nouveau_pushbuf_bufctx(push, NULL); - return false; - } -@@ -523,13 +522,13 @@ nv30_state_validate(struct nv30_context - LIST_FOR_EACH_ENTRY(bref, &bctx->current, thead) { - struct nv04_resource *res = bref->priv; - if (res && res->mm) { -- nouveau_fence_ref(screen->fence.current, &res->fence); -+ nouveau_fence_ref(nv30->base.fence, &res->fence); - - if (bref->flags & NOUVEAU_BO_RD) - res->status |= NOUVEAU_BUFFER_STATUS_GPU_READING; - - if (bref->flags & NOUVEAU_BO_WR) { -- nouveau_fence_ref(screen->fence.current, &res->fence_wr); -+ nouveau_fence_ref(nv30->base.fence, &res->fence_wr); - res->status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING; - } - } -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv30/nv30_transfer.c mesa-21.3.6/src/gallium/drivers/nouveau/nv30/nv30_transfer.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv30/nv30_transfer.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv30/nv30_transfer.c 2022-02-11 14:35:05.786902168 -0600 -@@ -155,7 +155,7 @@ nv30_transfer_rect_blit(XFER_ARGS) - u32 texfmt, texswz; - u32 format, stride; - -- if (nouveau_pushbuf_space(push, 512, 8, 0) || -+ if (!PUSH_SPACE_EX(push, 512, 8, 0) || - nouveau_pushbuf_refn (push, refs, ARRAY_SIZE(refs))) - return; - -@@ -431,7 +431,7 @@ nv30_transfer_rect_sifm(XFER_ARGS) - si_arg |= NV03_SIFM_FORMAT_FILTER_BILINEAR; - } - -- if (nouveau_pushbuf_space(push, 64, 6, 0) || -+ if (!PUSH_SPACE_EX(push, 64, 6, 0) || - nouveau_pushbuf_refn (push, refs, 2)) - return; - -@@ -516,7 +516,7 @@ nv30_transfer_rect_m2mf(XFER_ARGS) - while (h) { - unsigned lines = (h > 2047) ? 2047 : h; - -- if (nouveau_pushbuf_space(push, 32, 2, 0) || -+ if (!PUSH_SPACE_EX(push, 32, 2, 0) || - nouveau_pushbuf_refn (push, refs, 2)) - return; - -@@ -635,8 +635,8 @@ nv30_transfer_rect_cpu(XFER_ARGS) - char *srcmap, *dstmap; - int x, y; - -- nouveau_bo_map(src->bo, NOUVEAU_BO_RD, nv30->base.client); -- nouveau_bo_map(dst->bo, NOUVEAU_BO_WR, nv30->base.client); -+ BO_MAP(nv30->base.screen, src->bo, NOUVEAU_BO_RD, nv30->base.client); -+ BO_MAP(nv30->base.screen, dst->bo, NOUVEAU_BO_WR, nv30->base.client); - srcmap = src->bo->map + src->offset; - dstmap = dst->bo->map + dst->offset; - -@@ -708,7 +708,7 @@ nv30_transfer_copy_data(struct nouveau_c - lines = (pages > 2047) ? 2047 : pages; - pages -= lines; - -- if (nouveau_pushbuf_space(push, 32, 2, 0) || -+ if (!PUSH_SPACE_EX(push, 32, 2, 0) || - nouveau_pushbuf_refn (push, refs, 2)) - return; - -@@ -732,7 +732,7 @@ nv30_transfer_copy_data(struct nouveau_c - } - - if (size) { -- if (nouveau_pushbuf_space(push, 32, 2, 0) || -+ if (!PUSH_SPACE_EX(push, 32, 2, 0) || - nouveau_pushbuf_refn (push, refs, 2)) - return; - -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_compute.c mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_compute.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_compute.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_compute.c 2022-02-11 14:39:27.849132704 -0600 -@@ -518,7 +518,7 @@ nv50_state_validate_cp(struct nv50_conte - nv50->bufctx_cp); - - if (unlikely(nv50->state.flushed)) -- nv50_bufctx_fence(nv50->bufctx_cp, true); -+ nv50_bufctx_fence(nv50, nv50->bufctx_cp, true); - return ret; - } - -@@ -526,7 +526,7 @@ static void - nv50_compute_upload_input(struct nv50_context *nv50, const uint32_t *input) - { - struct nv50_screen *screen = nv50->screen; -- struct nouveau_pushbuf *push = screen->base.pushbuf; -+ struct nouveau_pushbuf *push = nv50->base.pushbuf; - unsigned size = align(nv50->compprog->parm_size, 0x4); - - BEGIN_NV04(push, NV50_CP(USER_PARAM_COUNT), 1); -@@ -540,19 +540,19 @@ nv50_compute_upload_input(struct nv50_co - mm = nouveau_mm_allocate(screen->base.mm_GART, size, &bo, &offset); - assert(mm); - -- nouveau_bo_map(bo, 0, screen->base.client); -+ BO_MAP(&screen->base, bo, 0, nv50->base.client); - memcpy(bo->map + offset, input, size); - - nouveau_bufctx_refn(nv50->bufctx, 0, bo, NOUVEAU_BO_GART | NOUVEAU_BO_RD); - nouveau_pushbuf_bufctx(push, nv50->bufctx); -- nouveau_pushbuf_validate(push); -+ PUSH_VAL(push); - -- nouveau_pushbuf_space(push, 0, 0, 1); -+ PUSH_SPACE_EX(push, 0, 0, 1); - - BEGIN_NV04(push, NV50_CP(USER_PARAM(1)), size / 4); - nouveau_pushbuf_data(push, bo, offset, size); - -- nouveau_fence_work(screen->base.fence.current, nouveau_mm_free_work, mm); -+ nouveau_fence_work(nv50->base.fence, nouveau_mm_free_work, mm); - nouveau_bo_ref(NULL, &bo); - nouveau_bufctx_reset(nv50->bufctx, 0); - } -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_context.c mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_context.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_context.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_context.c 2022-02-11 17:44:52.706228555 -0600 -@@ -34,9 +34,10 @@ nv50_flush(struct pipe_context *pipe, - unsigned flags) - { - struct nouveau_screen *screen = nouveau_screen(pipe->screen); -+ struct nouveau_context *context = nouveau_context(pipe); - - if (fence) -- nouveau_fence_ref(screen->fence.current, (struct nouveau_fence **)fence); -+ nouveau_fence_ref(context->fence, (struct nouveau_fence **)fence); - - PUSH_KICK(screen->pushbuf); - -@@ -135,12 +136,12 @@ void - nv50_default_kick_notify(struct nouveau_pushbuf *push) - { - struct nv50_screen *screen = push->user_priv; -+ struct nv50_context *context = screen->cur_ctx; - -- if (screen) { -- nouveau_fence_next(&screen->base); -+ if (context) { -+ nouveau_fence_next(&context->base); - nouveau_fence_update(&screen->base, true); -- if (screen->cur_ctx) -- screen->cur_ctx->state.flushed = true; -+ context->state.flushed = true; - } - } - -@@ -193,12 +194,13 @@ nv50_destroy(struct pipe_context *pipe) - u_upload_destroy(nv50->base.pipe.stream_uploader); - - nouveau_pushbuf_bufctx(nv50->base.pushbuf, NULL); -- nouveau_pushbuf_kick(nv50->base.pushbuf, nv50->base.pushbuf->channel); -+ PUSH_KICK(nv50->base.pushbuf); - - nv50_context_unreference_resources(nv50); - - FREE(nv50->blit); - -+ nouveau_fence_cleanup(&nv50->base); - nouveau_context_destroy(&nv50->base); - } - -@@ -312,20 +314,18 @@ nv50_create(struct pipe_screen *pscreen, - if (!nv50_blitctx_create(nv50)) - goto out_err; - -- nv50->base.pushbuf = screen->base.pushbuf; -- nv50->base.client = screen->base.client; -+ nouveau_context_init(&nv50->base, &screen->base); - -- ret = nouveau_bufctx_new(screen->base.client, 2, &nv50->bufctx); -+ ret = nouveau_bufctx_new(nv50->base.client, 2, &nv50->bufctx); - if (!ret) -- ret = nouveau_bufctx_new(screen->base.client, NV50_BIND_3D_COUNT, -+ ret = nouveau_bufctx_new(nv50->base.client, NV50_BIND_3D_COUNT, - &nv50->bufctx_3d); - if (!ret) -- ret = nouveau_bufctx_new(screen->base.client, NV50_BIND_CP_COUNT, -+ ret = nouveau_bufctx_new(nv50->base.client, NV50_BIND_CP_COUNT, - &nv50->bufctx_cp); - if (ret) - goto out_err; - -- nv50->base.screen = &screen->base; - nv50->base.copy_data = nv50_m2mf_copy_linear; - nv50->base.push_data = nv50_sifc_linear_u8; - nv50->base.push_cb = nv50_cb_push; -@@ -360,7 +360,6 @@ nv50_create(struct pipe_screen *pscreen, - } - nv50->base.pushbuf->kick_notify = nv50_default_kick_notify; - -- nouveau_context_init(&nv50->base); - nv50_init_query_functions(nv50); - nv50_init_surface_functions(nv50); - nv50_init_state_functions(nv50); -@@ -416,6 +415,8 @@ nv50_create(struct pipe_screen *pscreen, - // zero entry if it's not otherwise set. - nv50->dirty_3d |= NV50_NEW_3D_SAMPLERS; - -+ nouveau_fence_new(&nv50->base, &nv50->base.fence); -+ - return pipe; - - out_err: -@@ -433,7 +434,7 @@ out_err: - } - - void --nv50_bufctx_fence(struct nouveau_bufctx *bufctx, bool on_flush) -+nv50_bufctx_fence(struct nv50_context *nv50, struct nouveau_bufctx *bufctx, bool on_flush) - { - struct nouveau_list *list = on_flush ? &bufctx->current : &bufctx->pending; - struct nouveau_list *it; -@@ -442,7 +443,7 @@ nv50_bufctx_fence(struct nouveau_bufctx - struct nouveau_bufref *ref = (struct nouveau_bufref *)it; - struct nv04_resource *res = ref->priv; - if (res) -- nv50_resource_validate(res, (unsigned)ref->priv_data); -+ nv50_resource_validate(nv50, res, (unsigned)ref->priv_data); - } - } - -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_context.h mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_context.h ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_context.h 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_context.h 2022-02-11 14:48:38.488869249 -0600 -@@ -254,10 +254,28 @@ nv50_context_shader_stage(unsigned pipe) - } - } - -+static inline void -+nv50_resource_validate(struct nv50_context *context, struct nv04_resource *res, uint32_t flags) -+{ -+ if (likely(res->bo)) { -+ if (flags & NOUVEAU_BO_WR) -+ res->status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING | -+ NOUVEAU_BUFFER_STATUS_DIRTY; -+ if (flags & NOUVEAU_BO_RD) -+ res->status |= NOUVEAU_BUFFER_STATUS_GPU_READING; -+ -+ if (res->mm) { -+ nouveau_fence_ref(context->base.fence, &res->fence); -+ if (flags & NOUVEAU_BO_WR) -+ nouveau_fence_ref(context->base.fence, &res->fence_wr); -+ } -+ } -+} -+ - /* nv50_context.c */ - struct pipe_context *nv50_create(struct pipe_screen *, void *, unsigned flags); - --void nv50_bufctx_fence(struct nouveau_bufctx *, bool on_flush); -+void nv50_bufctx_fence(struct nv50_context *, struct nouveau_bufctx *, bool on_flush); - - void nv50_default_kick_notify(struct nouveau_pushbuf *); - -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_miptree.c mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_miptree.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_miptree.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_miptree.c 2022-02-11 14:49:23.116575689 -0600 -@@ -163,11 +163,7 @@ nv50_miptree_destroy(struct pipe_screen - { - struct nv50_miptree *mt = nv50_miptree(pt); - -- if (mt->base.fence && mt->base.fence->state < NOUVEAU_FENCE_STATE_FLUSHED) -- nouveau_fence_work(mt->base.fence, nouveau_fence_unref_bo, mt->base.bo); -- else -- nouveau_bo_ref(NULL, &mt->base.bo); -- -+ nouveau_fence_work(mt->base.fence, nouveau_fence_unref_bo, mt->base.bo); - nouveau_fence_ref(NULL, &mt->base.fence); - nouveau_fence_ref(NULL, &mt->base.fence_wr); - -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_query_hw.c mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_query_hw.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_query_hw.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_query_hw.c 2022-02-11 14:53:02.848195107 -0600 -@@ -52,7 +52,7 @@ nv50_hw_query_allocate(struct nv50_conte - if (hq->state == NV50_HW_QUERY_STATE_READY) - nouveau_mm_free(hq->mm); - else -- nouveau_fence_work(screen->base.fence.current, -+ nouveau_fence_work(nv50->base.fence, - nouveau_mm_free_work, hq->mm); - } - } -@@ -63,7 +63,7 @@ nv50_hw_query_allocate(struct nv50_conte - return false; - hq->offset = hq->base_offset; - -- ret = nouveau_bo_map(hq->bo, 0, screen->base.client); -+ ret = BO_MAP(&screen->base, hq->bo, 0, nv50->base.client); - if (ret) { - nv50_hw_query_allocate(nv50, q, 0); - return false; -@@ -265,7 +265,7 @@ nv50_hw_end_query(struct nv50_context *n - break; - } - if (hq->is64bit) -- nouveau_fence_ref(nv50->screen->base.fence.current, &hq->fence); -+ nouveau_fence_ref(nv50->base.fence, &hq->fence); - } - - static bool -@@ -294,7 +294,7 @@ nv50_hw_get_query_result(struct nv50_con - } - return false; - } -- if (nouveau_bo_wait(hq->bo, NOUVEAU_BO_RD, nv50->screen->base.client)) -+ if (BO_WAIT(&nv50->screen->base, hq->bo, NOUVEAU_BO_RD, nv50->base.client)) - return false; - } - hq->state = NV50_HW_QUERY_STATE_READY; -@@ -447,14 +447,15 @@ nv50_hw_get_driver_query_info(struct nv5 - } - - void --nv50_hw_query_pushbuf_submit(struct nouveau_pushbuf *push, uint16_t method, -+nv50_hw_query_pushbuf_submit(struct nv50_context *nv50, uint16_t method, - struct nv50_query *q, unsigned result_offset) - { -+ struct nouveau_pushbuf *push = nv50->base.pushbuf; - struct nv50_hw_query *hq = nv50_hw_query(q); - - nv50_hw_query_update(q); - if (hq->state != NV50_HW_QUERY_STATE_READY) -- nouveau_bo_wait(hq->bo, NOUVEAU_BO_RD, push->client); -+ BO_WAIT(&nv50->screen->base, hq->bo, NOUVEAU_BO_RD, push->client); - hq->state = NV50_HW_QUERY_STATE_READY; - - BEGIN_NV04(push, SUBC_3D(method), 1); -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_query_hw.h mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_query_hw.h ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_query_hw.h 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_query_hw.h 2022-02-11 14:53:21.749080536 -0600 -@@ -52,7 +52,7 @@ nv50_hw_get_driver_query_info(struct nv5 - bool - nv50_hw_query_allocate(struct nv50_context *, struct nv50_query *, int); - void --nv50_hw_query_pushbuf_submit(struct nouveau_pushbuf *, uint16_t, -+nv50_hw_query_pushbuf_submit(struct nv50_context *, uint16_t, - struct nv50_query *, unsigned); - void - nv84_hw_query_fifo_wait(struct nouveau_pushbuf *, struct nv50_query *); -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_query_hw_sm.c mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_query_hw_sm.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_query_hw_sm.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_query_hw_sm.c 2022-02-11 14:54:28.454680509 -0600 -@@ -321,7 +321,7 @@ nv50_hw_sm_query_read_data(uint32_t coun - if (hq->data[b + 4] != hq->sequence) { - if (!wait) - return false; -- if (nouveau_bo_wait(hq->bo, NOUVEAU_BO_RD, nv50->base.client)) -+ if (BO_WAIT(&nv50->screen->base, hq->bo, NOUVEAU_BO_RD, nv50->base.client)) - return false; - } - count[p][c] = hq->data[b + hsq->ctr[c]]; -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_screen.c mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_screen.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_screen.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_screen.c 2022-02-11 14:55:45.692224889 -0600 -@@ -595,8 +595,6 @@ nv50_screen_destroy(struct pipe_screen * - if (!nouveau_drm_screen_unref(&screen->base)) - return; - -- nouveau_fence_cleanup(&screen->base); -- - if (screen->base.pushbuf) - screen->base.pushbuf->user_priv = NULL; - -@@ -1074,7 +1072,7 @@ nv50_screen_create(struct nouveau_device - goto fail; - } - -- nouveau_bo_map(screen->fence.bo, 0, NULL); -+ BO_MAP(&screen->base, screen->fence.bo, 0, NULL); - screen->fence.map = screen->fence.bo->map; - screen->base.fence.emit = nv50_screen_fence_emit; - screen->base.fence.update = nv50_screen_fence_update; -@@ -1217,8 +1215,6 @@ nv50_screen_create(struct nouveau_device - goto fail; - } - -- nouveau_fence_new(&screen->base, &screen->base.fence.current); -- - return &screen->base; - - fail: -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_screen.h mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_screen.h ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_screen.h 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_screen.h 2022-02-11 14:56:32.391952891 -0600 -@@ -133,32 +133,6 @@ int nv50_screen_tsc_alloc(struct nv50_sc - - int nv50_screen_compute_setup(struct nv50_screen *, struct nouveau_pushbuf *); - --static inline void --nv50_resource_fence(struct nv04_resource *res, uint32_t flags) --{ -- struct nv50_screen *screen = nv50_screen(res->base.screen); -- -- if (res->mm) { -- nouveau_fence_ref(screen->base.fence.current, &res->fence); -- if (flags & NOUVEAU_BO_WR) -- nouveau_fence_ref(screen->base.fence.current, &res->fence_wr); -- } --} -- --static inline void --nv50_resource_validate(struct nv04_resource *res, uint32_t flags) --{ -- if (likely(res->bo)) { -- if (flags & NOUVEAU_BO_WR) -- res->status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING | -- NOUVEAU_BUFFER_STATUS_DIRTY; -- if (flags & NOUVEAU_BO_RD) -- res->status |= NOUVEAU_BUFFER_STATUS_GPU_READING; -- -- nv50_resource_fence(res, flags); -- } --} -- - struct nv50_format { - uint32_t rt; - struct { -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_shader_state.c mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_shader_state.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_shader_state.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_shader_state.c 2022-02-11 14:56:59.654795192 -0600 -@@ -717,7 +717,7 @@ nv50_stream_output_validate(struct nv50_ - PUSH_DATA(push, targ->pipe.buffer_size); - if (!targ->clean) { - assert(targ->pq); -- nv50_hw_query_pushbuf_submit(push, NVA0_3D_STRMOUT_OFFSET(i), -+ nv50_hw_query_pushbuf_submit(nv50, NVA0_3D_STRMOUT_OFFSET(i), - nv50_query(targ->pq), 0x4); - } else { - BEGIN_NV04(push, NVA0_3D(STRMOUT_OFFSET(i)), 1); -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_state_validate.c 2022-02-11 14:58:09.012397327 -0600 -@@ -556,10 +556,10 @@ nv50_state_validate(struct nv50_context - PUSH_DATA (nv50->base.pushbuf, 0); - } - -- nv50_bufctx_fence(bufctx, false); -+ nv50_bufctx_fence(nv50, bufctx, false); - } - nouveau_pushbuf_bufctx(nv50->base.pushbuf, bufctx); -- ret = nouveau_pushbuf_validate(nv50->base.pushbuf); -+ ret = PUSH_VAL(nv50->base.pushbuf); - - return !ret; - } -@@ -575,7 +575,7 @@ nv50_state_validate_3d(struct nv50_conte - - if (unlikely(nv50->state.flushed)) { - nv50->state.flushed = false; -- nv50_bufctx_fence(nv50->bufctx_3d, true); -+ nv50_bufctx_fence(nv50, nv50->bufctx_3d, true); - } - return ret; - } -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_surface.c mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_surface.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_surface.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_surface.c 2022-02-11 18:05:39.993075211 -0600 -@@ -257,7 +257,7 @@ nv50_resource_copy_region(struct pipe_co - BCTX_REFN(nv50->bufctx, 2D, nv04_resource(src), RD); - BCTX_REFN(nv50->bufctx, 2D, nv04_resource(dst), WR); - nouveau_pushbuf_bufctx(nv50->base.pushbuf, nv50->bufctx); -- nouveau_pushbuf_validate(nv50->base.pushbuf); -+ PUSH_VAL(nv50->base.pushbuf); - - for (; dst_layer < dstz + src_box->depth; ++dst_layer, ++src_layer) { - ret = nv50_2d_texture_do_copy(nv50->base.pushbuf, -@@ -295,7 +295,7 @@ nv50_clear_render_target(struct pipe_con - PUSH_DATAf(push, color->f[2]); - PUSH_DATAf(push, color->f[3]); - -- if (nouveau_pushbuf_space(push, 64 + sf->depth, 1, 0)) -+ if (!PUSH_SPACE_EX(push, 64 + sf->depth, 1, 0)) - return; - - PUSH_REFN(push, bo, mt->base.domain | NOUVEAU_BO_WR); -@@ -394,7 +394,7 @@ nv50_clear_depth_stencil(struct pipe_con - mode |= NV50_3D_CLEAR_BUFFERS_S; - } - -- if (nouveau_pushbuf_space(push, 64 + sf->depth, 1, 0)) -+ if (!PUSH_SPACE_EX(push, 64 + sf->depth, 1, 0)) - return; - - PUSH_REFN(push, bo, mt->base.domain | NOUVEAU_BO_WR); -@@ -653,7 +653,7 @@ nv50_clear_buffer_push(struct pipe_conte - - nouveau_bufctx_refn(nv50->bufctx, 0, buf->bo, buf->domain | NOUVEAU_BO_WR); - nouveau_pushbuf_bufctx(push, nv50->bufctx); -- nouveau_pushbuf_validate(push); -+ PUSH_VAL(push); - - offset &= ~0xff; - -@@ -692,7 +692,7 @@ nv50_clear_buffer_push(struct pipe_conte - count -= nr; - } - -- nv50_resource_validate(buf, NOUVEAU_BO_WR); -+ nv50_resource_validate(nv50, buf, NOUVEAU_BO_WR); - - nouveau_bufctx_reset(nv50->bufctx, 0); - } -@@ -771,7 +771,7 @@ nv50_clear_buffer(struct pipe_context *p - PUSH_DATA (push, color.ui[2]); - PUSH_DATA (push, color.ui[3]); - -- if (nouveau_pushbuf_space(push, 64, 1, 0)) -+ if (!PUSH_SPACE_EX(push, 64, 1, 0)) - return; - - PUSH_REFN(push, buf->bo, buf->domain | NOUVEAU_BO_WR); -@@ -815,7 +815,7 @@ nv50_clear_buffer(struct pipe_context *p - BEGIN_NV04(push, NV50_3D(COND_MODE), 1); - PUSH_DATA (push, nv50->cond_condmode); - -- nv50_resource_validate(buf, NOUVEAU_BO_WR); -+ nv50_resource_validate(nv50, buf, NOUVEAU_BO_WR); - - if (width * height != elements) { - offset += width * height * data_size; -@@ -1639,7 +1639,7 @@ nv50_blit_eng2d(struct nv50_context *nv5 - BCTX_REFN(nv50->bufctx, 2D, &dst->base, WR); - BCTX_REFN(nv50->bufctx, 2D, &src->base, RD); - nouveau_pushbuf_bufctx(nv50->base.pushbuf, nv50->bufctx); -- if (nouveau_pushbuf_validate(nv50->base.pushbuf)) -+ if (PUSH_VAL(nv50->base.pushbuf)) - return; - - for (i = 0; i < info->dst.box.depth; ++i) { -@@ -1679,7 +1679,7 @@ nv50_blit_eng2d(struct nv50_context *nv5 - PUSH_DATA (push, srcy >> 32); - } - } -- nv50_bufctx_fence(nv50->bufctx, false); -+ nv50_bufctx_fence(nv50, nv50->bufctx, false); - - nouveau_bufctx_reset(nv50->bufctx, NV50_BIND_2D); - -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_transfer.c mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_transfer.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_transfer.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_transfer.c 2022-02-11 15:02:10.331043100 -0600 -@@ -67,7 +67,7 @@ nv50_2d_transfer_rect(struct nv50_contex - nouveau_bufctx_refn(bctx, 0, src->bo, src->domain | NOUVEAU_BO_RD); - nouveau_bufctx_refn(bctx, 0, dst->bo, dst->domain | NOUVEAU_BO_WR); - nouveau_pushbuf_bufctx(push, bctx); -- nouveau_pushbuf_validate(push); -+ PUSH_VAL(push); - - uint32_t format; - switch (cpp) { -@@ -197,7 +197,7 @@ nv50_m2mf_transfer_rect(struct nv50_cont - nouveau_bufctx_refn(bctx, 0, src->bo, src->domain | NOUVEAU_BO_RD); - nouveau_bufctx_refn(bctx, 0, dst->bo, dst->domain | NOUVEAU_BO_WR); - nouveau_pushbuf_bufctx(push, bctx); -- nouveau_pushbuf_validate(push); -+ PUSH_VAL(push); - - if (nouveau_bo_memtype(src->bo)) { - BEGIN_NV04(push, NV50_M2MF(LINEAR_IN), 6); -@@ -284,7 +284,7 @@ nv50_sifc_linear_u8(struct nouveau_conte - - nouveau_bufctx_refn(nv50->bufctx, 0, dst, domain | NOUVEAU_BO_WR); - nouveau_pushbuf_bufctx(push, nv50->bufctx); -- nouveau_pushbuf_validate(push); -+ PUSH_VAL(push); - - offset &= ~0xff; - -@@ -337,7 +337,7 @@ nv50_m2mf_copy_linear(struct nouveau_con - nouveau_bufctx_refn(bctx, 0, src, srcdom | NOUVEAU_BO_RD); - nouveau_bufctx_refn(bctx, 0, dst, dstdom | NOUVEAU_BO_WR); - nouveau_pushbuf_bufctx(push, bctx); -- nouveau_pushbuf_validate(push); -+ PUSH_VAL(push); - - BEGIN_NV04(push, NV50_M2MF(LINEAR_IN), 1); - PUSH_DATA (push, 1); -@@ -375,7 +375,6 @@ nv50_miptree_transfer_map(struct pipe_co - const struct pipe_box *box, - struct pipe_transfer **ptransfer) - { -- struct nv50_screen *screen = nv50_screen(pctx->screen); - struct nv50_context *nv50 = nv50_context(pctx); - struct nouveau_device *dev = nv50->screen->base.device; - const struct nv50_miptree *mt = nv50_miptree(res); -@@ -454,7 +453,7 @@ nv50_miptree_transfer_map(struct pipe_co - if (usage & PIPE_MAP_WRITE) - flags |= NOUVEAU_BO_WR; - -- ret = nouveau_bo_map(tx->rect[1].bo, flags, screen->base.client); -+ ret = BO_MAP(nv50->base.screen, tx->rect[1].bo, flags, nv50->base.client); - if (ret) { - nouveau_bo_ref(NULL, &tx->rect[1].bo); - FREE(tx); -@@ -486,7 +485,7 @@ nv50_miptree_transfer_unmap(struct pipe_ - } - - /* Allow the copies above to finish executing before freeing the source */ -- nouveau_fence_work(nv50->screen->base.fence.current, -+ nouveau_fence_work(nv50->base.fence, - nouveau_fence_unref_bo, tx->rect[1].bo); - } else { - nouveau_bo_ref(NULL, &tx->rect[1].bo); -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_vbo.c mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_vbo.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv50_vbo.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv50_vbo.c 2022-02-11 15:03:36.446568575 -0600 -@@ -624,14 +624,14 @@ nv50_draw_elements(struct nv50_context * - * the not-yet-written data. Ideally this wait would only happen on - * pushbuf submit, but it's probably not a big performance difference. - */ -- if (buf->fence_wr && !nouveau_fence_signalled(buf->fence_wr)) -+ if (buf->fence_wr) - nouveau_fence_wait(buf->fence_wr, &nv50->base.debug); - - while (instance_count--) { - BEGIN_NV04(push, NV50_3D(VERTEX_BEGIN_GL), 1); - PUSH_DATA (push, prim); - -- nouveau_pushbuf_space(push, 16, 0, 1); -+ PUSH_SPACE_EX(push, 16, 0, 1); - PUSH_REFN(push, buf->bo, NOUVEAU_BO_RD | buf->domain); - - switch (index_size) { -@@ -737,7 +737,7 @@ nva0_draw_stream_output(struct nv50_cont - PUSH_DATA (push, 0); - BEGIN_NV04(push, NVA0_3D(DRAW_TFB_STRIDE), 1); - PUSH_DATA (push, so->stride); -- nv50_hw_query_pushbuf_submit(push, NVA0_3D_DRAW_TFB_BYTES, -+ nv50_hw_query_pushbuf_submit(nv50, NVA0_3D_DRAW_TFB_BYTES, - nv50_query(so->pq), 0x4); - BEGIN_NV04(push, NV50_3D(VERTEX_END_GL), 1); - PUSH_DATA (push, 0); -@@ -752,8 +752,6 @@ nv50_draw_vbo_kick_notify(struct nouveau - struct nv50_screen *screen = chan->user_priv; - - nouveau_fence_update(&screen->base, true); -- -- nv50_bufctx_fence(screen->cur_ctx->bufctx_3d, true); - } - - void -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv84_video_bsp.c mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv84_video_bsp.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv84_video_bsp.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv84_video_bsp.c 2022-02-11 15:09:14.426111024 -0600 -@@ -89,6 +89,7 @@ nv84_decoder_bsp(struct nv84_decoder *de - const unsigned *num_bytes, - struct nv84_video_buffer *dest) - { -+ struct nouveau_screen *screen = nouveau_screen(dec->base.context->screen); - struct iparm params; - uint32_t more_params[0x44 / 4] = {0}; - unsigned total_bytes = 0; -@@ -103,7 +104,7 @@ nv84_decoder_bsp(struct nv84_decoder *de - { dec->fence, NOUVEAU_BO_RDWR | NOUVEAU_BO_VRAM }, - }; - -- nouveau_bo_wait(dec->fence, NOUVEAU_BO_RDWR, dec->client); -+ BO_WAIT(screen, dec->fence, NOUVEAU_BO_RDWR, dec->client); - - STATIC_ASSERT(sizeof(struct iparm) == 0x530); - -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv84_video.c mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv84_video.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv84_video.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv84_video.c 2022-02-11 15:08:27.115135546 -0600 -@@ -69,6 +69,7 @@ nv84_load_firmwares(struct nouveau_devic - { - int ret, size1, size2 = 0; - struct nouveau_bo *fw; -+ struct nouveau_screen *screen = nouveau_screen(dec->base.context->screen); - - size1 = filesize(fw1); - if (fw2) -@@ -81,7 +82,7 @@ nv84_load_firmwares(struct nouveau_devic - ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, dec->vp_fw2_offset + size2, NULL, &fw); - if (ret) - return NULL; -- ret = nouveau_bo_map(fw, NOUVEAU_BO_WR, dec->client); -+ ret = BO_MAP(screen, fw, NOUVEAU_BO_WR, dec->client); - if (ret) - goto error; - -@@ -183,11 +184,12 @@ nv84_decoder_begin_frame_mpeg12(struct p - struct pipe_video_buffer *target, - struct pipe_picture_desc *picture) - { -+ struct nouveau_screen *screen = nouveau_screen(decoder->context->screen); - struct nv84_decoder *dec = (struct nv84_decoder *)decoder; - struct pipe_mpeg12_picture_desc *desc = (struct pipe_mpeg12_picture_desc *)picture; - int i; - -- nouveau_bo_wait(dec->mpeg12_bo, NOUVEAU_BO_RDWR, dec->client); -+ BO_WAIT(screen, dec->mpeg12_bo, NOUVEAU_BO_RDWR, dec->client); - dec->mpeg12_mb_info = dec->mpeg12_bo->map + 0x100; - dec->mpeg12_data = dec->mpeg12_bo->map + 0x100 + - align(0x20 * mb(dec->base.width) * mb(dec->base.height), 0x100); -@@ -406,14 +408,14 @@ nv84_create_decoder(struct pipe_context - NULL, &dec->bitstream); - if (ret) - goto fail; -- ret = nouveau_bo_map(dec->bitstream, NOUVEAU_BO_WR, dec->client); -+ ret = BO_MAP(screen, dec->bitstream, NOUVEAU_BO_WR, dec->client); - if (ret) - goto fail; - ret = nouveau_bo_new(screen->device, NOUVEAU_BO_GART, - 0, 0x2000, NULL, &dec->vp_params); - if (ret) - goto fail; -- ret = nouveau_bo_map(dec->vp_params, NOUVEAU_BO_WR, dec->client); -+ ret = BO_MAP(screen, dec->vp_params, NOUVEAU_BO_WR, dec->client); - if (ret) - goto fail; - } -@@ -425,7 +427,7 @@ nv84_create_decoder(struct pipe_context - NULL, &dec->mpeg12_bo); - if (ret) - goto fail; -- ret = nouveau_bo_map(dec->mpeg12_bo, NOUVEAU_BO_WR, dec->client); -+ ret = BO_MAP(screen,dec->mpeg12_bo, NOUVEAU_BO_WR, dec->client); - if (ret) - goto fail; - } -@@ -434,7 +436,7 @@ nv84_create_decoder(struct pipe_context - 0, 0x1000, NULL, &dec->fence); - if (ret) - goto fail; -- ret = nouveau_bo_map(dec->fence, NOUVEAU_BO_WR, dec->client); -+ ret = BO_MAP(screen, dec->fence, NOUVEAU_BO_WR, dec->client); - if (ret) - goto fail; - *(uint32_t *)dec->fence->map = 0; -@@ -493,17 +495,17 @@ nv84_create_decoder(struct pipe_context - surf.offset = dec->vpring->size - 0x1000; - context->clear_render_target(context, &surf.base, &color, 0, 0, 1024, 1, false); - -- PUSH_SPACE(screen->pushbuf, 5); -- PUSH_REFN(screen->pushbuf, dec->fence, NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR); -+ PUSH_SPACE(nv50->base.pushbuf, 5); -+ PUSH_REFN(nv50->base.pushbuf, dec->fence, NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR); - /* The clear_render_target is done via 3D engine, so use it to write to a - * sempahore to indicate that it's done. - */ -- BEGIN_NV04(screen->pushbuf, NV50_3D(QUERY_ADDRESS_HIGH), 4); -- PUSH_DATAh(screen->pushbuf, dec->fence->offset); -- PUSH_DATA (screen->pushbuf, dec->fence->offset); -- PUSH_DATA (screen->pushbuf, 1); -- PUSH_DATA (screen->pushbuf, 0xf010); -- PUSH_KICK (screen->pushbuf); -+ BEGIN_NV04(nv50->base.pushbuf, NV50_3D(QUERY_ADDRESS_HIGH), 4); -+ PUSH_DATAh(nv50->base.pushbuf, dec->fence->offset); -+ PUSH_DATA (nv50->base.pushbuf, dec->fence->offset); -+ PUSH_DATA (nv50->base.pushbuf, 1); -+ PUSH_DATA (nv50->base.pushbuf, 0xf010); -+ PUSH_KICK (nv50->base.pushbuf); - - PUSH_SPACE(bsp_push, 2 + 12 + 2 + 4 + 3); - -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv98_video_bsp.c mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv98_video_bsp.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv98_video_bsp.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv98_video_bsp.c 2022-02-11 15:12:36.619828402 -0600 -@@ -39,6 +39,7 @@ nv98_decoder_bsp(struct nouveau_vp3_deco - unsigned *vp_caps, unsigned *is_ref, - struct nouveau_vp3_video_buffer *refs[16]) - { -+ struct nouveau_screen *screen = nouveau_screen(dec->base.context->screen); - struct nouveau_pushbuf *push = dec->pushbuf[0]; - enum pipe_video_format codec = u_reduce_video_profile(dec->base.profile); - uint32_t bsp_addr, comm_addr, inter_addr; -@@ -95,7 +96,7 @@ nv98_decoder_bsp(struct nouveau_vp3_deco - bo_refs[1].bo = dec->inter_bo[comm_seq & 1] = inter_bo = tmp_bo; - } - -- ret = nouveau_bo_map(bsp_bo, NOUVEAU_BO_WR, dec->client); -+ ret = BO_MAP(screen, bsp_bo, NOUVEAU_BO_WR, dec->client); - if (ret) { - debug_printf("map failed: %i %s\n", ret, strerror(-ret)); - return -1; -@@ -107,7 +108,7 @@ nv98_decoder_bsp(struct nouveau_vp3_deco - - nouveau_vp3_vp_caps(dec, desc, target, comm_seq, vp_caps, is_ref, refs); - -- nouveau_pushbuf_space(push, 32, num_refs, 0); -+ PUSH_SPACE_EX(push, 32, num_refs, 0); - nouveau_pushbuf_refn(push, bo_refs, num_refs); - - bsp_addr = bsp_bo->offset >> 8; -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv98_video.c mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv98_video.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv98_video.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv98_video.c 2022-02-11 15:11:41.428930690 -0600 -@@ -85,7 +85,8 @@ struct pipe_video_codec * - nv98_create_decoder(struct pipe_context *context, - const struct pipe_video_codec *templ) - { -- struct nouveau_screen *screen = &((struct nv50_context *)context)->screen->base; -+ struct nv50_context *nv50 = nv50_context(context); -+ struct nouveau_screen *screen = &nv50->screen->base; - struct nouveau_vp3_decoder *dec; - struct nouveau_pushbuf **push; - struct nv04_fifo nv04_data = {.vram = 0xbeef0201, .gart = 0xbeef0202}; -@@ -106,7 +107,7 @@ nv98_create_decoder(struct pipe_context - dec = CALLOC_STRUCT(nouveau_vp3_decoder); - if (!dec) - return NULL; -- dec->client = screen->client; -+ dec->client = nv50->base.client; - dec->base = *templ; - nouveau_vp3_decoder_init_common(&dec->base); - -@@ -119,7 +120,7 @@ nv98_create_decoder(struct pipe_context - &nv04_data, sizeof(nv04_data), &dec->channel[0]); - - if (!ret) -- ret = nouveau_pushbuf_new(screen->client, dec->channel[0], 4, -+ ret = nouveau_pushbuf_new(nv50->base.client, dec->channel[0], 4, - 32 * 1024, true, &dec->pushbuf[0]); - - for (i = 1; i < 3; ++i) { -@@ -268,13 +269,13 @@ nv98_create_decoder(struct pipe_context - if (ret) - goto fail; - -- nouveau_bo_map(dec->fence_bo, NOUVEAU_BO_RDWR, screen->client); -+ BO_MAP(dec->fence_bo, NOUVEAU_BO_RDWR, screen->client); - dec->fence_map = dec->fence_bo->map; - dec->fence_map[0] = dec->fence_map[4] = dec->fence_map[8] = 0; - dec->comm = (struct comm *)(dec->fence_map + (COMM_OFFSET/sizeof(*dec->fence_map))); - - /* So lets test if the fence is working? */ -- nouveau_pushbuf_space(push[0], 16, 1, 0); -+ PUSH_SPACE_EX(push[0], 16, 1, 0); - PUSH_REFN (push[0], dec->fence_bo, NOUVEAU_BO_GART|NOUVEAU_BO_RDWR); - BEGIN_NV04(push[0], SUBC_BSP(0x240), 3); - PUSH_DATAh(push[0], dec->fence_bo->offset); -@@ -285,7 +286,7 @@ nv98_create_decoder(struct pipe_context - PUSH_DATA (push[0], 0); - PUSH_KICK (push[0]); - -- nouveau_pushbuf_space(push[1], 16, 1, 0); -+ PUSH_SPACE_EX(push[1], 16, 1, 0); - PUSH_REFN (push[1], dec->fence_bo, NOUVEAU_BO_GART|NOUVEAU_BO_RDWR); - BEGIN_NV04(push[1], SUBC_VP(0x240), 3); - PUSH_DATAh(push[1], (dec->fence_bo->offset + 0x10)); -@@ -296,7 +297,7 @@ nv98_create_decoder(struct pipe_context - PUSH_DATA (push[1], 0); - PUSH_KICK (push[1]); - -- nouveau_pushbuf_space(push[2], 16, 1, 0); -+ PUSH_SPACE_EX(push[2], 16, 1, 0); - PUSH_REFN (push[2], dec->fence_bo, NOUVEAU_BO_GART|NOUVEAU_BO_RDWR); - BEGIN_NV04(push[2], SUBC_PPP(0x240), 3); - PUSH_DATAh(push[2], (dec->fence_bo->offset + 0x20)); -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv98_video_ppp.c mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv98_video_ppp.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv98_video_ppp.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv98_video_ppp.c 2022-02-11 15:12:49.083803035 -0600 -@@ -94,7 +94,7 @@ nv98_decoder_ppp(struct nouveau_vp3_deco - struct nouveau_pushbuf *push = dec->pushbuf[2]; - unsigned ppp_caps = 0x10; - -- nouveau_pushbuf_space(push, 32, 4, 0); -+ PUSH_SPACE_EX(push, 32, 4, 0); - - switch (codec) { - case PIPE_VIDEO_FORMAT_MPEG12: { -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv98_video_vp.c mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv98_video_vp.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nv50/nv98_video_vp.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nv50/nv98_video_vp.c 2022-02-11 15:13:28.216718331 -0600 -@@ -44,7 +44,7 @@ static void dump_comm_vp(struct nouveau_ - - if ((comm->pvp_stage & 0xff) != 0xff) { - unsigned *map; -- int ret = nouveau_bo_map(inter_bo, NOUVEAU_BO_RD|NOUVEAU_BO_NOBLOCK, dec->client); -+ int ret = BO_MAP(inter_bo, NOUVEAU_BO_RD|NOUVEAU_BO_NOBLOCK, dec->client); - assert(ret >= 0); - map = inter_bo->map; - for (i = 0; i < comm->byte_ofs + slice_size; i += 0x10) { -@@ -111,7 +111,7 @@ nv98_decoder_vp(struct nouveau_vp3_decod - if (!is_ref && (dec->refs[target->valid_ref].decoded_top && dec->refs[target->valid_ref].decoded_bottom)) - nv98_decoder_kick_ref(dec, target); - -- nouveau_pushbuf_space(push, 32 + codec_extra, num_refs, 0); -+ PUSH_SPACE_EX(push, 32 + codec_extra, num_refs, 0); - - nouveau_pushbuf_refn(push, bo_refs, num_refs); - -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_compute.c 2022-02-11 15:16:25.426251672 -0600 -@@ -428,10 +428,11 @@ nvc0_launch_grid(struct pipe_context *pi - struct nvc0_program *cp = nvc0->compprog; - int ret; - -+ simple_mtx_lock(&screen->state_lock); - ret = !nvc0_state_validate_cp(nvc0, ~0); - if (ret) { - NOUVEAU_ERR("Failed to launch grid !\n"); -- return; -+ goto out; - } - - nvc0_compute_upload_input(nvc0, info); -@@ -464,7 +465,7 @@ nvc0_launch_grid(struct pipe_context *pi - PUSH_DATA (push, (info->block[1] << 16) | info->block[0]); - PUSH_DATA (push, info->block[2]); - -- nouveau_pushbuf_space(push, 32, 2, 1); -+ PUSH_SPACE_EX(push, 32, 2, 1); - PUSH_REFN(push, screen->text, NV_VRAM_DOMAIN(&screen->base) | NOUVEAU_BO_RD); - - if (unlikely(info->indirect)) { -@@ -502,6 +503,9 @@ nvc0_launch_grid(struct pipe_context *pi - nvc0->images_dirty[5] |= nvc0->images_valid[5]; - - nvc0_update_compute_invocations_counter(nvc0, info); -+ -+out: -+ simple_mtx_unlock(&screen->state_lock); - } - - static void -@@ -511,7 +515,7 @@ nvc0_compute_update_indirect_invocations - struct nv04_resource *res = nv04_resource(info->indirect); - uint32_t offset = res->offset + info->indirect_offset; - -- nouveau_pushbuf_space(push, 16, 0, 8); -+ PUSH_SPACE_EX(push, 16, 0, 8); - PUSH_REFN(push, res->bo, NOUVEAU_BO_RD | res->domain); - BEGIN_1IC0(push, NVC0_3D(MACRO_COMPUTE_COUNTER), 7); - PUSH_DATA(push, 6); -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_context.c mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_context.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_context.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_context.c 2022-02-11 18:08:12.440206042 -0600 -@@ -81,10 +81,9 @@ nvc0_flush(struct pipe_context *pipe, - unsigned flags) - { - struct nvc0_context *nvc0 = nvc0_context(pipe); -- struct nouveau_screen *screen = &nvc0->screen->base; - - if (fence) -- nouveau_fence_ref(screen->fence.current, (struct nouveau_fence **)fence); -+ nouveau_fence_ref(nvc0->base.fence, (struct nouveau_fence **)fence); - - PUSH_KICK(nvc0->base.pushbuf); /* fencing handled in kick_notify */ - -@@ -257,7 +256,7 @@ nvc0_destroy(struct pipe_context *pipe) - * Other contexts will always set their bufctx again on action calls. - */ - nouveau_pushbuf_bufctx(nvc0->base.pushbuf, NULL); -- nouveau_pushbuf_kick(nvc0->base.pushbuf, nvc0->base.pushbuf->channel); -+ PUSH_KICK(nvc0->base.pushbuf); - - nvc0_context_unreference_resources(nvc0); - nvc0_blitctx_destroy(nvc0); -@@ -272,6 +271,7 @@ nvc0_destroy(struct pipe_context *pipe) - free(pos); - } - -+ nouveau_fence_cleanup(&nvc0->base); - nouveau_context_destroy(&nvc0->base); - } - -@@ -279,12 +279,12 @@ void - nvc0_default_kick_notify(struct nouveau_pushbuf *push) - { - struct nvc0_screen *screen = push->user_priv; -+ struct nvc0_context *nvc0 = screen->cur_ctx; - -- if (screen) { -- nouveau_fence_next(&screen->base); -+ if (nvc0) { -+ nouveau_fence_next(&nvc0->base); - nouveau_fence_update(&screen->base, true); -- if (screen->cur_ctx) -- screen->cur_ctx->state.flushed = true; -+ nvc0->state.flushed = true; - NOUVEAU_DRV_STAT(&screen->base, pushbuf_count, 1); - } - } -@@ -425,22 +425,19 @@ nvc0_create(struct pipe_screen *pscreen, - if (!nvc0_blitctx_create(nvc0)) - goto out_err; - -- nvc0->base.pushbuf = screen->base.pushbuf; -- nvc0->base.client = screen->base.client; -+ nouveau_context_init(&nvc0->base, &screen->base); - -- ret = nouveau_bufctx_new(screen->base.client, 2, &nvc0->bufctx); -+ ret = nouveau_bufctx_new(nvc0->base.client, 2, &nvc0->bufctx); - if (!ret) -- ret = nouveau_bufctx_new(screen->base.client, NVC0_BIND_3D_COUNT, -+ ret = nouveau_bufctx_new(nvc0->base.client, NVC0_BIND_3D_COUNT, - &nvc0->bufctx_3d); - if (!ret) -- ret = nouveau_bufctx_new(screen->base.client, NVC0_BIND_CP_COUNT, -+ ret = nouveau_bufctx_new(nvc0->base.client, NVC0_BIND_CP_COUNT, - &nvc0->bufctx_cp); - if (ret) - goto out_err; - - nvc0->screen = screen; -- nvc0->base.screen = &screen->base; -- - pipe->screen = pscreen; - pipe->priv = priv; - pipe->stream_uploader = u_upload_create_default(pipe); -@@ -464,7 +461,6 @@ nvc0_create(struct pipe_screen *pscreen, - pipe->emit_string_marker = nvc0_emit_string_marker; - pipe->get_device_reset_status = nvc0_get_device_reset_status; - -- nouveau_context_init(&nvc0->base); - nvc0_init_query_functions(nvc0); - nvc0_init_surface_functions(nvc0); - nvc0_init_state_functions(nvc0); -@@ -553,6 +549,8 @@ nvc0_create(struct pipe_screen *pscreen, - nvc0->dirty_cp |= NVC0_NEW_CP_SAMPLERS; - } - -+ nouveau_fence_new(&nvc0->base, &nvc0->base.fence); -+ - return pipe; - - out_err: -@@ -583,7 +581,7 @@ nvc0_bufctx_fence(struct nvc0_context *n - struct nouveau_bufref *ref = (struct nouveau_bufref *)it; - struct nv04_resource *res = ref->priv; - if (res) -- nvc0_resource_validate(res, (unsigned)ref->priv_data); -+ nvc0_resource_validate(nvc0, res, (unsigned)ref->priv_data); - NOUVEAU_DRV_STAT_IFD(count++); - } - NOUVEAU_DRV_STAT(&nvc0->screen->base, resource_validate_count, count); -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_context.h mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_context.h ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_context.h 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_context.h 2022-02-11 15:23:13.508824215 -0600 -@@ -311,6 +311,30 @@ nvc0_shader_stage(unsigned pipe) - } - - -+static inline void -+nvc0_resource_fence(struct nvc0_context *nvc0, struct nv04_resource *res, uint32_t flags) -+{ -+ if (res->mm) { -+ nouveau_fence_ref(nvc0->base.fence, &res->fence); -+ if (flags & NOUVEAU_BO_WR) -+ nouveau_fence_ref(nvc0->base.fence, &res->fence_wr); -+ } -+} -+ -+static inline void -+nvc0_resource_validate(struct nvc0_context *nvc0, struct nv04_resource *res, uint32_t flags) -+{ -+ if (likely(res->bo)) { -+ if (flags & NOUVEAU_BO_WR) -+ res->status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING | -+ NOUVEAU_BUFFER_STATUS_DIRTY; -+ if (flags & NOUVEAU_BO_RD) -+ res->status |= NOUVEAU_BUFFER_STATUS_GPU_READING; -+ -+ nvc0_resource_fence(nvc0, res, flags); -+ } -+} -+ - /* nvc0_context.c */ - struct pipe_context *nvc0_create(struct pipe_screen *, void *, unsigned flags); - void nvc0_bufctx_fence(struct nvc0_context *, struct nouveau_bufctx *, -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_program.c mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_program.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_program.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_program.c 2022-02-11 15:25:32.848266636 -0600 -@@ -884,6 +884,7 @@ nvc0_program_upload(struct nvc0_context - size += TU102_SHADER_HEADER_SIZE; - } - -+ simple_mtx_assert_locked(&nvc0->screen->state_lock); - ret = nvc0_program_alloc_code(nvc0, prog); - if (ret) { - struct nouveau_heap *heap = screen->text_heap; -@@ -990,8 +991,11 @@ nvc0_program_destroy(struct nvc0_context - const struct pipe_shader_state pipe = prog->pipe; - const ubyte type = prog->type; - -- if (prog->mem) -+ if (prog->mem) { -+ if (nvc0) -+ simple_mtx_assert_locked(&nvc0->screen->state_lock); - nouveau_heap_free(&prog->mem); -+ } - FREE(prog->code); /* may be 0 for hardcoded shaders */ - FREE(prog->relocs); - FREE(prog->fixups); -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw.c 2022-02-11 15:30:18.641058844 -0600 -@@ -44,7 +44,7 @@ nvc0_hw_query_allocate(struct nvc0_conte - if (hq->state == NVC0_HW_QUERY_STATE_READY) - nouveau_mm_free(hq->mm); - else -- nouveau_fence_work(screen->base.fence.current, -+ nouveau_fence_work(nvc0->base.fence, - nouveau_mm_free_work, hq->mm); - } - } -@@ -55,7 +55,7 @@ nvc0_hw_query_allocate(struct nvc0_conte - return false; - hq->offset = hq->base_offset; - -- ret = nouveau_bo_map(hq->bo, 0, screen->base.client); -+ ret = BO_MAP(&screen->base, hq->bo, 0, nvc0->base.client); - if (ret) { - nvc0_hw_query_allocate(nvc0, q, 0); - return false; -@@ -129,7 +129,7 @@ nvc0_hw_query_write_compute_invocations( - { - struct nouveau_pushbuf *push = nvc0->base.pushbuf; - -- nouveau_pushbuf_space(push, 16, 0, 8); -+ PUSH_SPACE_EX(push, 16, 0, 8); - PUSH_REFN(push, hq->bo, NOUVEAU_BO_GART | NOUVEAU_BO_WR); - BEGIN_1IC0(push, NVC0_3D(MACRO_COMPUTE_COUNTER_TO_QUERY), 4); - PUSH_DATA (push, nvc0->compute_invocations); -@@ -301,7 +301,7 @@ nvc0_hw_end_query(struct nvc0_context *n - break; - } - if (hq->is64bit) -- nouveau_fence_ref(nvc0->screen->base.fence.current, &hq->fence); -+ nouveau_fence_ref(nvc0->base.fence, &hq->fence); - } - - static bool -@@ -319,7 +319,7 @@ nvc0_hw_get_query_result(struct nvc0_con - return hq->funcs->get_query_result(nvc0, hq, wait, result); - - if (hq->state != NVC0_HW_QUERY_STATE_READY) -- nvc0_hw_query_update(nvc0->screen->base.client, q); -+ nvc0_hw_query_update(nvc0->base.client, q); - - if (hq->state != NVC0_HW_QUERY_STATE_READY) { - if (!wait) { -@@ -330,7 +330,7 @@ nvc0_hw_get_query_result(struct nvc0_con - } - return false; - } -- if (nouveau_bo_wait(hq->bo, NOUVEAU_BO_RD, nvc0->screen->base.client)) -+ if (BO_WAIT(&nvc0->screen->base, hq->bo, NOUVEAU_BO_RD, nvc0->base.client)) - return false; - NOUVEAU_DRV_STAT(&nvc0->screen->base, query_sync_count, 1); - } -@@ -403,7 +403,7 @@ nvc0_hw_get_query_result_resource(struct - if (index == -1) { - /* TODO: Use a macro to write the availability of the query */ - if (hq->state != NVC0_HW_QUERY_STATE_READY) -- nvc0_hw_query_update(nvc0->screen->base.client, q); -+ nvc0_hw_query_update(nvc0->base.client, q); - uint32_t ready[2] = {hq->state == NVC0_HW_QUERY_STATE_READY}; - nvc0->base.push_cb(&nvc0->base, buf, offset, - result_type >= PIPE_QUERY_TYPE_I64 ? 2 : 1, -@@ -412,7 +412,7 @@ nvc0_hw_get_query_result_resource(struct - util_range_add(&buf->base, &buf->valid_buffer_range, offset, - offset + (result_type >= PIPE_QUERY_TYPE_I64 ? 8 : 4)); - -- nvc0_resource_validate(buf, NOUVEAU_BO_WR); -+ nvc0_resource_validate(nvc0, buf, NOUVEAU_BO_WR); - - return; - } -@@ -420,7 +420,7 @@ nvc0_hw_get_query_result_resource(struct - /* If the fence guarding this query has not been emitted, that makes a lot - * of the following logic more complicated. - */ -- if (hq->is64bit && hq->fence->state < NOUVEAU_FENCE_STATE_EMITTED) -+ if (hq->is64bit) - nouveau_fence_emit(hq->fence); - - /* We either need to compute a 32- or 64-bit difference between 2 values, -@@ -430,12 +430,12 @@ nvc0_hw_get_query_result_resource(struct - * outputs the difference (no need to worry about 64-bit clamping). - */ - if (hq->state != NVC0_HW_QUERY_STATE_READY) -- nvc0_hw_query_update(nvc0->screen->base.client, q); -+ nvc0_hw_query_update(nvc0->base.client, q); - - if (wait && hq->state != NVC0_HW_QUERY_STATE_READY) - nvc0_hw_query_fifo_wait(nvc0, q); - -- nouveau_pushbuf_space(push, 32, 2, 3); -+ PUSH_SPACE_EX(push, 32, 2, 3); - PUSH_REFN (push, hq->bo, NOUVEAU_BO_GART | NOUVEAU_BO_RD); - PUSH_REFN (push, buf->bo, buf->domain | NOUVEAU_BO_WR); - BEGIN_1IC0(push, NVC0_3D(MACRO_QUERY_BUFFER_WRITE), 9); -@@ -511,7 +511,7 @@ nvc0_hw_get_query_result_resource(struct - util_range_add(&buf->base, &buf->valid_buffer_range, offset, - offset + (result_type >= PIPE_QUERY_TYPE_I64 ? 8 : 4)); - -- nvc0_resource_validate(buf, NOUVEAU_BO_WR); -+ nvc0_resource_validate(nvc0, buf, NOUVEAU_BO_WR); - } - - static const struct nvc0_query_funcs hw_query_funcs = { -@@ -642,7 +642,7 @@ nvc0_hw_query_fifo_wait(struct nvc0_cont - unsigned offset = hq->offset; - - /* ensure the query's fence has been emitted */ -- if (hq->is64bit && hq->fence->state < NOUVEAU_FENCE_STATE_EMITTED) -+ if (hq->is64bit) - nouveau_fence_emit(hq->fence); - - PUSH_SPACE(push, 5); -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_sm.c mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_sm.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_sm.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_query_hw_sm.c 2022-02-11 15:31:39.237707036 -0600 -@@ -2636,7 +2636,7 @@ nvc0_hw_sm_query_read_data(uint32_t coun - if (hq->data[b + 8] != hq->sequence) { - if (!wait) - return false; -- if (nouveau_bo_wait(hq->bo, NOUVEAU_BO_RD, nvc0->base.client)) -+ if (BO_WAIT(&nvc0->screen->base, hq->bo, NOUVEAU_BO_RD, nvc0->base.client)) - return false; - } - count[p][c] = hq->data[b + hsq->ctr[c]] * (1 << c); -@@ -2664,7 +2664,7 @@ nve4_hw_sm_query_read_data(uint32_t coun - if (hq->data[b + 20 + d] != hq->sequence) { - if (!wait) - return false; -- if (nouveau_bo_wait(hq->bo, NOUVEAU_BO_RD, nvc0->base.client)) -+ if (BO_WAIT(&nvc0->screen->base, hq->bo, NOUVEAU_BO_RD, nvc0->base.client)) - return false; - } - if (hsq->ctr[c] & ~0x3) -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_screen.c 2022-02-11 16:20:30.965275088 -0600 -@@ -701,8 +701,6 @@ nvc0_screen_destroy(struct pipe_screen * - if (!nouveau_drm_screen_unref(&screen->base)) - return; - -- nouveau_fence_cleanup(&screen->base); -- - if (screen->base.pushbuf) - screen->base.pushbuf->user_priv = NULL; - -@@ -733,6 +731,7 @@ nvc0_screen_destroy(struct pipe_screen * - nouveau_object_del(&screen->nvsw); - - nouveau_screen_fini(&screen->base); -+ simple_mtx_destroy(&screen->state_lock); - - FREE(screen); - } -@@ -1058,6 +1057,8 @@ nvc0_screen_create(struct nouveau_device - return NULL; - pscreen = &screen->base.base; - pscreen->destroy = nvc0_screen_destroy; -+ -+ simple_mtx_init(&screen->state_lock, mtx_plain); - - ret = nouveau_screen_init(&screen->base, dev); - if (ret) -@@ -1109,7 +1110,7 @@ nvc0_screen_create(struct nouveau_device - ret = nouveau_bo_new(dev, flags, 0, 4096, NULL, &screen->fence.bo); - if (ret) - FAIL_SCREEN_INIT("Error allocating fence BO: %d\n", ret); -- nouveau_bo_map(screen->fence.bo, 0, NULL); -+ BO_MAP(&screen->base, screen->fence.bo, 0, NULL); - screen->fence.map = screen->fence.bo->map; - screen->base.fence.emit = nvc0_screen_fence_emit; - screen->base.fence.update = nvc0_screen_fence_update; -@@ -1558,8 +1559,6 @@ nvc0_screen_create(struct nouveau_device - if (!nvc0_blitter_create(screen)) - goto fail; - -- nouveau_fence_new(&screen->base, &screen->base.fence.current); -- - return &screen->base; - - fail: -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h 2022-02-11 16:21:46.650277251 -0600 -@@ -71,6 +71,7 @@ struct nvc0_screen { - - struct nvc0_context *cur_ctx; - struct nvc0_graph_state save_state; -+ simple_mtx_t state_lock; - - int num_occlusion_queries_active; - -@@ -157,32 +158,6 @@ int nvc0_screen_resize_text_area(struct - // 3D Only - void nvc0_screen_bind_cb_3d(struct nvc0_screen *, bool *, int, int, int, uint64_t); - --static inline void --nvc0_resource_fence(struct nv04_resource *res, uint32_t flags) --{ -- struct nvc0_screen *screen = nvc0_screen(res->base.screen); -- -- if (res->mm) { -- nouveau_fence_ref(screen->base.fence.current, &res->fence); -- if (flags & NOUVEAU_BO_WR) -- nouveau_fence_ref(screen->base.fence.current, &res->fence_wr); -- } --} -- --static inline void --nvc0_resource_validate(struct nv04_resource *res, uint32_t flags) --{ -- if (likely(res->bo)) { -- if (flags & NOUVEAU_BO_WR) -- res->status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING | -- NOUVEAU_BUFFER_STATUS_DIRTY; -- if (flags & NOUVEAU_BO_RD) -- res->status |= NOUVEAU_BUFFER_STATUS_GPU_READING; -- -- nvc0_resource_fence(res, flags); -- } --} -- - struct nvc0_format { - uint32_t rt; - struct { -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_shader_state.c 2022-02-11 16:24:08.657161261 -0600 -@@ -71,6 +71,7 @@ nvc0_program_sp_start_id(struct nvc0_con - { - struct nouveau_pushbuf *push = nvc0->base.pushbuf; - -+ simple_mtx_assert_locked(&nvc0->screen->state_lock); - if (nvc0->screen->eng3d->oclass < GV100_3D_CLASS) { - BEGIN_NVC0(push, NVC0_3D(SP_START_ID(stage)), 1); - PUSH_DATA (push, prog->code_base); -@@ -338,6 +339,8 @@ nvc0_tfb_validate(struct nvc0_context *n - } - } - } -+ -+ simple_mtx_assert_locked(&nvc0->screen->state_lock); - nvc0->state.tfb = tfb; - - if (!(nvc0->dirty_3d & NVC0_NEW_3D_TFB_TARGETS)) -@@ -364,7 +367,7 @@ nvc0_tfb_validate(struct nvc0_context *n - - if (!targ->clean) - nvc0_hw_query_fifo_wait(nvc0, nvc0_query(targ->pq)); -- nouveau_pushbuf_space(push, 0, 0, 1); -+ PUSH_SPACE_EX(push, 0, 0, 1); - BEGIN_NVC0(push, NVC0_3D(TFB_BUFFER_ENABLE(b)), 5); - PUSH_DATA (push, 1); - PUSH_DATAh(push, buf->address + targ->pipe.buffer_offset); -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_state.c mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_state.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_state.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_state.c 2022-02-11 16:25:08.106073895 -0600 -@@ -635,9 +635,12 @@ nvc0_sp_state_create(struct pipe_context - static void - nvc0_sp_state_delete(struct pipe_context *pipe, void *hwcso) - { -+ struct nvc0_context *nvc0 = nvc0_context(pipe); - struct nvc0_program *prog = (struct nvc0_program *)hwcso; - -+ simple_mtx_lock(&nvc0->screen->state_lock); - nvc0_program_destroy(nvc0_context(pipe), prog); -+ simple_mtx_unlock(&nvc0->screen->state_lock); - - if (prog->pipe.type == PIPE_SHADER_IR_TGSI) - FREE((void *)prog->pipe.tokens); -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_state_validate.c 2022-02-11 16:26:48.061884623 -0600 -@@ -253,7 +253,7 @@ nvc0_validate_fb(struct nvc0_context *nv - PUSH_DATA(push, 0); - PUSH_DATA(push, 0); - -- nvc0_resource_fence(res, NOUVEAU_BO_WR); -+ nvc0_resource_fence(nvc0, res, NOUVEAU_BO_WR); - - assert(!fb->zsbuf); - } -@@ -871,6 +871,7 @@ nvc0_switch_pipe_context(struct nvc0_con - struct nvc0_context *ctx_from = ctx_to->screen->cur_ctx; - unsigned s; - -+ simple_mtx_assert_locked(&ctx_to->screen->state_lock); - if (ctx_from) - ctx_to->state = ctx_from->state; - else -@@ -967,6 +968,8 @@ nvc0_state_validate(struct nvc0_context - int ret; - unsigned i; - -+ simple_mtx_assert_locked(&nvc0->screen->state_lock); -+ - if (nvc0->screen->cur_ctx != nvc0) - nvc0_switch_pipe_context(nvc0); - -@@ -985,7 +988,7 @@ nvc0_state_validate(struct nvc0_context - } - - nouveau_pushbuf_bufctx(nvc0->base.pushbuf, bufctx); -- ret = nouveau_pushbuf_validate(nvc0->base.pushbuf); -+ ret = PUSH_VAL(nvc0->base.pushbuf); - - return !ret; - } -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_surface.c 2022-02-11 16:33:12.692802344 -0600 -@@ -267,7 +267,7 @@ nvc0_resource_copy_region(struct pipe_co - BCTX_REFN(nvc0->bufctx, 2D, nv04_resource(src), RD); - BCTX_REFN(nvc0->bufctx, 2D, nv04_resource(dst), WR); - nouveau_pushbuf_bufctx(nvc0->base.pushbuf, nvc0->bufctx); -- nouveau_pushbuf_validate(nvc0->base.pushbuf); -+ PUSH_VAL(nvc0->base.pushbuf); - - for (; dst_layer < dstz + src_box->depth; ++dst_layer, ++src_layer) { - ret = nvc0_2d_texture_do_copy(nvc0->base.pushbuf, -@@ -348,7 +348,7 @@ nvc0_clear_render_target(struct pipe_con - IMMED_NVC0(push, NVC0_3D(MULTISAMPLE_MODE), 0); - - /* tiled textures don't have to be fenced, they're not mapped directly */ -- nvc0_resource_fence(res, NOUVEAU_BO_WR); -+ nvc0_resource_fence(nvc0, res, NOUVEAU_BO_WR); - } - - if (!render_condition_enabled) -@@ -379,7 +379,7 @@ nvc0_clear_buffer_push_nvc0(struct pipe_ - - nouveau_bufctx_refn(nvc0->bufctx, 0, buf->bo, buf->domain | NOUVEAU_BO_WR); - nouveau_pushbuf_bufctx(push, nvc0->bufctx); -- nouveau_pushbuf_validate(push); -+ PUSH_VAL(push); - - unsigned count = (size + 3) / 4; - unsigned data_words = data_size / 4; -@@ -410,7 +410,7 @@ nvc0_clear_buffer_push_nvc0(struct pipe_ - size -= nr * 4; - } - -- nvc0_resource_validate(buf, NOUVEAU_BO_WR); -+ nvc0_resource_validate(nvc0, buf, NOUVEAU_BO_WR); - - nouveau_bufctx_reset(nvc0->bufctx, 0); - } -@@ -428,7 +428,7 @@ nvc0_clear_buffer_push_nve4(struct pipe_ - - nouveau_bufctx_refn(nvc0->bufctx, 0, buf->bo, buf->domain | NOUVEAU_BO_WR); - nouveau_pushbuf_bufctx(push, nvc0->bufctx); -- nouveau_pushbuf_validate(push); -+ PUSH_VAL(push); - - unsigned count = (size + 3) / 4; - unsigned data_words = data_size / 4; -@@ -457,7 +457,7 @@ nvc0_clear_buffer_push_nve4(struct pipe_ - size -= nr * 4; - } - -- nvc0_resource_validate(buf, NOUVEAU_BO_WR); -+ nvc0_resource_validate(nvc0, buf, NOUVEAU_BO_WR); - - nouveau_bufctx_reset(nvc0->bufctx, 0); - } -@@ -604,7 +604,7 @@ nvc0_clear_buffer(struct pipe_context *p - - IMMED_NVC0(push, NVC0_3D(COND_MODE), nvc0->cond_condmode); - -- nvc0_resource_validate(buf, NOUVEAU_BO_WR); -+ nvc0_resource_validate(nvc0, buf, NOUVEAU_BO_WR); - - if (width * height != elements) { - offset += width * height * data_size; -@@ -700,9 +700,11 @@ nvc0_clear(struct pipe_context *pipe, un - unsigned i, j, k; - uint32_t mode = 0; - -+ simple_mtx_lock(&nvc0->screen->state_lock); -+ - /* don't need NEW_BLEND, COLOR_MASK doesn't affect CLEAR_BUFFERS */ - if (!nvc0_state_validate_3d(nvc0, NVC0_NEW_3D_FRAMEBUFFER)) -- return; -+ goto out; - - if (scissor_state) { - uint32_t minx = scissor_state->minx; -@@ -710,7 +712,7 @@ nvc0_clear(struct pipe_context *pipe, un - uint32_t miny = scissor_state->miny; - uint32_t maxy = MIN2(fb->height, scissor_state->maxy); - if (maxx <= minx || maxy <= miny) -- return; -+ goto out; - - BEGIN_NVC0(push, NVC0_3D(SCREEN_SCISSOR_HORIZ), 2); - PUSH_DATA (push, minx | (maxx - minx) << 16); -@@ -781,6 +783,9 @@ nvc0_clear(struct pipe_context *pipe, un - PUSH_DATA (push, fb->width << 16); - PUSH_DATA (push, fb->height << 16); - } -+ -+out: -+ simple_mtx_unlock(&nvc0->screen->state_lock); - } - - static void -@@ -789,8 +794,10 @@ gm200_evaluate_depth_buffer(struct pipe_ - struct nvc0_context *nvc0 = nvc0_context(pipe); - struct nouveau_pushbuf *push = nvc0->base.pushbuf; - -+ simple_mtx_lock(&nvc0->screen->state_lock); - nvc0_state_validate_3d(nvc0, NVC0_NEW_3D_FRAMEBUFFER); - IMMED_NVC0(push, SUBC_3D(0x11fc), 1); -+ simple_mtx_unlock(&nvc0->screen->state_lock); - } - - -@@ -1327,7 +1334,7 @@ nvc0_blit_3d(struct nvc0_context *nvc0, - NOUVEAU_BO_GART | NOUVEAU_BO_RD, vtxbuf_bo); - BCTX_REFN_bo(nvc0->bufctx_3d, 3D_TEXT, - NV_VRAM_DOMAIN(&screen->base) | NOUVEAU_BO_RD, screen->text); -- nouveau_pushbuf_validate(push); -+ PUSH_VAL(push); - - BEGIN_NVC0(push, NVC0_3D(VERTEX_ARRAY_FETCH(0)), 4); - PUSH_DATA (push, NVC0_3D_VERTEX_ARRAY_FETCH_ENABLE | stride << -@@ -1549,7 +1556,7 @@ nvc0_blit_eng2d(struct nvc0_context *nvc - BCTX_REFN(nvc0->bufctx, 2D, &dst->base, WR); - BCTX_REFN(nvc0->bufctx, 2D, &src->base, RD); - nouveau_pushbuf_bufctx(nvc0->base.pushbuf, nvc0->bufctx); -- if (nouveau_pushbuf_validate(nvc0->base.pushbuf)) -+ if (PUSH_VAL(nvc0->base.pushbuf)) - return; - - for (i = 0; i < info->dst.box.depth; ++i) { -@@ -1589,8 +1596,8 @@ nvc0_blit_eng2d(struct nvc0_context *nvc - PUSH_DATA (push, srcy >> 32); - } - } -- nvc0_resource_validate(&dst->base, NOUVEAU_BO_WR); -- nvc0_resource_validate(&src->base, NOUVEAU_BO_RD); -+ nvc0_resource_validate(nvc0, &dst->base, NOUVEAU_BO_WR); -+ nvc0_resource_validate(nvc0, &src->base, NOUVEAU_BO_RD); - - nouveau_bufctx_reset(nvc0->bufctx, NVC0_BIND_2D); - -@@ -1684,6 +1691,7 @@ nvc0_blit(struct pipe_context *pipe, con - if (info->num_window_rectangles > 0 || info->window_rectangle_include) - eng3d = true; - -+ simple_mtx_lock(&nvc0->screen->state_lock); - if (nvc0->screen->num_occlusion_queries_active) - IMMED_NVC0(push, NVC0_3D(SAMPLECNT_ENABLE), 0); - -@@ -1694,6 +1702,7 @@ nvc0_blit(struct pipe_context *pipe, con - - if (nvc0->screen->num_occlusion_queries_active) - IMMED_NVC0(push, NVC0_3D(SAMPLECNT_ENABLE), 1); -+ simple_mtx_unlock(&nvc0->screen->state_lock); - - NOUVEAU_DRV_STAT(&nvc0->screen->base, tex_blit_count, 1); - } -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_transfer.c 2022-02-11 16:36:06.082194000 -0600 -@@ -32,7 +32,7 @@ nvc0_m2mf_transfer_rect(struct nvc0_cont - nouveau_bufctx_refn(bctx, 0, src->bo, src->domain | NOUVEAU_BO_RD); - nouveau_bufctx_refn(bctx, 0, dst->bo, dst->domain | NOUVEAU_BO_WR); - nouveau_pushbuf_bufctx(push, bctx); -- nouveau_pushbuf_validate(push); -+ PUSH_VAL(push); - - if (nouveau_bo_memtype(src->bo)) { - BEGIN_NVC0(push, NVC0_M2MF(TILING_MODE_IN), 5); -@@ -138,7 +138,7 @@ nve4_m2mf_transfer_rect(struct nvc0_cont - nouveau_bufctx_refn(bctx, 0, dst->bo, dst->domain | NOUVEAU_BO_WR); - nouveau_bufctx_refn(bctx, 0, src->bo, src->domain | NOUVEAU_BO_RD); - nouveau_pushbuf_bufctx(push, bctx); -- nouveau_pushbuf_validate(push); -+ PUSH_VAL(push); - - exec = NVE4_COPY_EXEC_SWIZZLE_ENABLE | NVE4_COPY_EXEC_2D_ENABLE | NVE4_COPY_EXEC_FLUSH | NVE4_COPY_EXEC_COPY_MODE_NON_PIPELINED; - -@@ -207,7 +207,7 @@ nvc0_m2mf_push_linear(struct nouveau_con - - nouveau_bufctx_refn(nvc0->bufctx, 0, dst, domain | NOUVEAU_BO_WR); - nouveau_pushbuf_bufctx(push, nvc0->bufctx); -- nouveau_pushbuf_validate(push); -+ PUSH_VAL(push); - - while (count) { - unsigned nr = MIN2(count, NV04_PFIFO_MAX_PACKET_LEN); -@@ -249,7 +249,7 @@ nve4_p2mf_push_linear(struct nouveau_con - - nouveau_bufctx_refn(nvc0->bufctx, 0, dst, domain | NOUVEAU_BO_WR); - nouveau_pushbuf_bufctx(push, nvc0->bufctx); -- nouveau_pushbuf_validate(push); -+ PUSH_VAL(push); - - while (count) { - unsigned nr = MIN2(count, (NV04_PFIFO_MAX_PACKET_LEN - 1)); -@@ -289,7 +289,7 @@ nvc0_m2mf_copy_linear(struct nouveau_con - nouveau_bufctx_refn(bctx, 0, src, srcdom | NOUVEAU_BO_RD); - nouveau_bufctx_refn(bctx, 0, dst, dstdom | NOUVEAU_BO_WR); - nouveau_pushbuf_bufctx(push, bctx); -- nouveau_pushbuf_validate(push); -+ PUSH_VAL(push); - - while (size) { - unsigned bytes = MIN2(size, 1 << 17); -@@ -327,7 +327,7 @@ nve4_m2mf_copy_linear(struct nouveau_con - nouveau_bufctx_refn(bctx, 0, src, srcdom | NOUVEAU_BO_RD); - nouveau_bufctx_refn(bctx, 0, dst, dstdom | NOUVEAU_BO_WR); - nouveau_pushbuf_bufctx(push, bctx); -- nouveau_pushbuf_validate(push); -+ PUSH_VAL(push); - - BEGIN_NVC0(push, NVE4_COPY(SRC_ADDRESS_HIGH), 4); - PUSH_DATAh(push, src->offset + srcoff); -@@ -362,7 +362,7 @@ nvc0_mt_sync(struct nvc0_context *nvc0, - if (!mt->base.mm) { - uint32_t access = (usage & PIPE_MAP_WRITE) ? - NOUVEAU_BO_WR : NOUVEAU_BO_RD; -- return !nouveau_bo_wait(mt->base.bo, access, nvc0->base.client); -+ return !BO_WAIT(&nvc0->screen->base, mt->base.bo, access, nvc0->base.client); - } - if (usage & PIPE_MAP_WRITE) - return !mt->base.fence || nouveau_fence_wait(mt->base.fence, &nvc0->base.debug); -@@ -388,7 +388,7 @@ nvc0_miptree_transfer_map(struct pipe_co - if (nvc0_mt_transfer_can_map_directly(mt)) { - ret = !nvc0_mt_sync(nvc0, mt, usage); - if (!ret) -- ret = nouveau_bo_map(mt->base.bo, 0, NULL); -+ ret = BO_MAP(nvc0->base.screen, mt->base.bo, 0, NULL); - if (ret && - (usage & PIPE_MAP_DIRECTLY)) - return NULL; -@@ -480,7 +480,7 @@ nvc0_miptree_transfer_map(struct pipe_co - if (usage & PIPE_MAP_WRITE) - flags |= NOUVEAU_BO_WR; - -- ret = nouveau_bo_map(tx->rect[1].bo, flags, nvc0->screen->base.client); -+ ret = BO_MAP(nvc0->base.screen, tx->rect[1].bo, flags, nvc0->screen->base.client); - if (ret) { - pipe_resource_reference(&tx->base.resource, NULL); - nouveau_bo_ref(NULL, &tx->rect[1].bo); -@@ -521,7 +521,7 @@ nvc0_miptree_transfer_unmap(struct pipe_ - NOUVEAU_DRV_STAT(&nvc0->screen->base, tex_transfers_wr, 1); - - /* Allow the copies above to finish executing before freeing the source */ -- nouveau_fence_work(nvc0->screen->base.fence.current, -+ nouveau_fence_work(nvc0->base.fence, - nouveau_fence_unref_bo, tx->rect[1].bo); - } else { - nouveau_bo_ref(NULL, &tx->rect[1].bo); -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_vbo.c 2022-02-11 16:37:55.523785563 -0600 -@@ -462,6 +462,7 @@ nvc0_vertex_arrays_validate(struct nvc0_ - if (update_vertex) { - const unsigned n = MAX2(vertex->num_elements, nvc0->state.num_vtxelts); - -+ simple_mtx_assert_locked(&nvc0->screen->state_lock); - nvc0->state.constant_vbos = const_vbos; - nvc0->state.constant_elts = 0; - nvc0->state.num_vtxelts = vertex->num_elements; -@@ -788,7 +789,7 @@ nvc0_draw_stream_output(struct nvc0_cont - } - - while (num_instances--) { -- nouveau_pushbuf_space(push, 16, 0, 1); -+ PUSH_SPACE_EX(push, 16, 0, 1); - BEGIN_NVC0(push, NVC0_3D(VERTEX_BEGIN_GL), 1); - PUSH_DATA (push, mode); - BEGIN_NVC0(push, NVC0_3D(DRAW_TFB_BASE), 1); -@@ -869,7 +870,7 @@ nvc0_draw_indirect(struct nvc0_context * - pushes = draws; - } - -- nouveau_pushbuf_space(push, 16, 0, pushes + !!buf_count); -+ PUSH_SPACE_EX(push, 16, 0, pushes + !!buf_count); - PUSH_REFN(push, buf->bo, NOUVEAU_BO_RD | buf->domain); - if (buf_count) - PUSH_REFN(push, buf_count->bo, NOUVEAU_BO_RD | buf_count->domain); -@@ -1024,6 +1025,8 @@ nvc0_draw_vbo(struct pipe_context *pipe, - BCTX_REFN_bo(nvc0->bufctx_3d, 3D_TEXT, vram_domain | NOUVEAU_BO_RD, - screen->text); - -+ simple_mtx_lock(&nvc0->screen->state_lock); -+ - nvc0_state_validate_3d(nvc0, ~0); - - if (nvc0->vertprog->vp.need_draw_parameters && (!indirect || indirect->count_from_stream_output)) { -@@ -1131,6 +1134,8 @@ nvc0_draw_vbo(struct pipe_context *pipe, - } - - cleanup: -+ simple_mtx_unlock(&nvc0->screen->state_lock); -+ - push->kick_notify = nvc0_default_kick_notify; - - nvc0_release_user_vbufs(nvc0); -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_vbo_translate.c mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_vbo_translate.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_vbo_translate.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_vbo_translate.c 2022-02-11 16:38:16.159706821 -0600 -@@ -239,7 +239,7 @@ nvc0_push_setup_vertex_array(struct nvc0 - - BCTX_REFN_bo(nvc0->bufctx_3d, 3D_VTX_TMP, NOUVEAU_BO_GART | NOUVEAU_BO_RD, - bo); -- nouveau_pushbuf_validate(push); -+ PUSH_VAL(push); - - return dest; - } -@@ -731,7 +731,7 @@ nvc0_push_upload_vertex_ids(struct push_ - - BCTX_REFN_bo(nvc0->bufctx_3d, 3D_VTX_TMP, NOUVEAU_BO_GART | NOUVEAU_BO_RD, - bo); -- nouveau_pushbuf_validate(push); -+ PUSH_VAL(push); - - if (info->index_size) { - if (!draw->index_bias) { -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_video_bsp.c mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_video_bsp.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_video_bsp.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_video_bsp.c 2022-02-11 16:42:26.561716987 -0600 -@@ -34,10 +34,11 @@ static void dump_comm_bsp(struct comm *c - unsigned - nvc0_decoder_bsp_begin(struct nouveau_vp3_decoder *dec, unsigned comm_seq) - { -+ struct nouveau_screen *screen = nouveau_screen(dec->base.context->screen); - struct nouveau_bo *bsp_bo = dec->bsp_bo[comm_seq % NOUVEAU_VP3_VIDEO_QDEPTH]; - unsigned ret = 0; - -- ret = nouveau_bo_map(bsp_bo, NOUVEAU_BO_WR, dec->client); -+ ret = BO_MAP(screen, bsp_bo, NOUVEAU_BO_WR, dec->client); - if (ret) { - debug_printf("map failed: %i %s\n", ret, strerror(-ret)); - return -1; -@@ -53,6 +54,7 @@ nvc0_decoder_bsp_next(struct nouveau_vp3 - unsigned comm_seq, unsigned num_buffers, - const void *const *data, const unsigned *num_bytes) - { -+ struct nouveau_screen *screen = nouveau_screen(dec->base.context->screen); - struct nouveau_bo *bsp_bo = dec->bsp_bo[comm_seq % NOUVEAU_VP3_VIDEO_QDEPTH]; - struct nouveau_bo *inter_bo = dec->inter_bo[comm_seq & 1]; - uint32_t bsp_size = 0; -@@ -82,7 +84,7 @@ nvc0_decoder_bsp_next(struct nouveau_vp3 - return -1; - } - -- ret = nouveau_bo_map(tmp_bo, NOUVEAU_BO_WR, dec->client); -+ ret = BO_MAP(screen,tmp_bo, NOUVEAU_BO_WR, dec->client); - if (ret) { - debug_printf("map failed: %i %s\n", ret, strerror(-ret)); - return -1; -@@ -114,7 +116,7 @@ nvc0_decoder_bsp_next(struct nouveau_vp3 - return -1; - } - -- ret = nouveau_bo_map(tmp_bo, NOUVEAU_BO_WR, dec->client); -+ ret = BO_MAP(screen, tmp_bo, NOUVEAU_BO_WR, dec->client); - if (ret) { - debug_printf("map failed: %i %s\n", ret, strerror(-ret)); - return -1; -@@ -160,7 +162,7 @@ nvc0_decoder_bsp_end(struct nouveau_vp3_ - - nouveau_vp3_vp_caps(dec, desc, target, comm_seq, vp_caps, is_ref, refs); - -- nouveau_pushbuf_space(push, 32, num_refs, 0); -+ PUSH_SPACE_EX(push, 32, num_refs, 0); - nouveau_pushbuf_refn(push, bo_refs, num_refs); - - bsp_addr = bsp_bo->offset >> 8; -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_video.c mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_video.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_video.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_video.c 2022-02-11 18:09:21.787821149 -0600 -@@ -91,7 +91,8 @@ struct pipe_video_codec * - nvc0_create_decoder(struct pipe_context *context, - const struct pipe_video_codec *templ) - { -- struct nouveau_screen *screen = &((struct nvc0_context *)context)->screen->base; -+ struct nvc0_context *nvc0 = nvc0_context(context); -+ struct nouveau_screen *screen = &nvc0->screen->base; - struct nouveau_vp3_decoder *dec; - struct nouveau_pushbuf **push; - union nouveau_bo_config cfg; -@@ -116,7 +117,7 @@ nvc0_create_decoder(struct pipe_context - dec = CALLOC_STRUCT(nouveau_vp3_decoder); - if (!dec) - return NULL; -- dec->client = screen->client; -+ dec->client = nvc0->base.client; - dec->base = *templ; - nouveau_vp3_decoder_init_common(&dec->base); - -@@ -160,7 +161,7 @@ nvc0_create_decoder(struct pipe_context - data, size, &dec->channel[i]); - - if (!ret) -- ret = nouveau_pushbuf_new(screen->client, dec->channel[i], 4, -+ ret = nouveau_pushbuf_new(nvc0->base.client, dec->channel[i], 4, - 32 * 1024, true, &dec->pushbuf[i]); - if (ret) - break; -@@ -292,13 +293,13 @@ nvc0_create_decoder(struct pipe_context - if (ret) - goto fail; - -- nouveau_bo_map(dec->fence_bo, NOUVEAU_BO_RDWR, screen->client); -+ BO_MAP(dec->fence_bo, NOUVEAU_BO_RDWR, screen->client); - dec->fence_map = dec->fence_bo->map; - dec->fence_map[0] = dec->fence_map[4] = dec->fence_map[8] = 0; - dec->comm = (struct comm *)(dec->fence_map + (COMM_OFFSET/sizeof(*dec->fence_map))); - - /* So lets test if the fence is working? */ -- nouveau_pushbuf_space(push[0], 16, 1, 0); -+ PUSH_SPACE_EX(push[0], 16, 1, 0); - PUSH_REFN (push[0], dec->fence_bo, NOUVEAU_BO_GART|NOUVEAU_BO_RDWR); - BEGIN_NVC0(push[0], SUBC_BSP(0x240), 3); - PUSH_DATAh(push[0], dec->fence_bo->offset); -@@ -309,7 +310,7 @@ nvc0_create_decoder(struct pipe_context - PUSH_DATA (push[0], 0); - PUSH_KICK (push[0]); - -- nouveau_pushbuf_space(push[1], 16, 1, 0); -+ PUSH_SPACE_EX(push[1], 16, 1, 0); - PUSH_REFN (push[1], dec->fence_bo, NOUVEAU_BO_GART|NOUVEAU_BO_RDWR); - BEGIN_NVC0(push[1], SUBC_VP(0x240), 3); - PUSH_DATAh(push[1], (dec->fence_bo->offset + 0x10)); -@@ -320,7 +321,7 @@ nvc0_create_decoder(struct pipe_context - PUSH_DATA (push[1], 0); - PUSH_KICK (push[1]); - -- nouveau_pushbuf_space(push[2], 16, 1, 0); -+ PUSH_SPACE_EX(push[2], 16, 1, 0); - PUSH_REFN (push[2], dec->fence_bo, NOUVEAU_BO_GART|NOUVEAU_BO_RDWR); - BEGIN_NVC0(push[2], SUBC_PPP(0x240), 3); - PUSH_DATAh(push[2], (dec->fence_bo->offset + 0x20)); -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_video_ppp.c mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_video_ppp.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_video_ppp.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_video_ppp.c 2022-02-11 16:42:38.048670313 -0600 -@@ -94,7 +94,7 @@ nvc0_decoder_ppp(struct nouveau_vp3_deco - struct nouveau_pushbuf *push = dec->pushbuf[2]; - unsigned ppp_caps = 0x10; - -- nouveau_pushbuf_space(push, 32, 4, 0); -+ PUSH_SPACE_EX(push, 32, 4, 0); - - switch (codec) { - case PIPE_VIDEO_FORMAT_MPEG12: { -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_video_vp.c mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_video_vp.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nvc0_video_vp.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nvc0_video_vp.c 2022-02-11 16:43:16.978511453 -0600 -@@ -44,7 +44,7 @@ static void dump_comm_vp(struct nouveau_ - - if ((comm->pvp_stage & 0xff) != 0xff) { - unsigned *map; -- int ret = nouveau_bo_map(inter_bo, NOUVEAU_BO_RD|NOUVEAU_BO_NOBLOCK, dec->client); -+ int ret = BO_MAP(inter_bo, NOUVEAU_BO_RD|NOUVEAU_BO_NOBLOCK, dec->client); - assert(ret >= 0); - map = inter_bo->map; - for (i = 0; i < comm->byte_ofs + slice_size; i += 0x10) { -@@ -111,7 +111,7 @@ nvc0_decoder_vp(struct nouveau_vp3_decod - if (!is_ref && (dec->refs[target->valid_ref].decoded_top && dec->refs[target->valid_ref].decoded_bottom)) - nvc0_decoder_kick_ref(dec, target); - -- nouveau_pushbuf_space(push, 32 + codec_extra, num_refs, 0); -+ PUSH_SPACE_EX(push, 32 + codec_extra, num_refs, 0); - - nouveau_pushbuf_refn(push, bo_refs, num_refs); - -diff -Naurp mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nve4_compute.c mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nve4_compute.c ---- mesa-21.3.6.orig/src/gallium/drivers/nouveau/nvc0/nve4_compute.c 2022-02-09 14:10:39.000000000 -0600 -+++ mesa-21.3.6/src/gallium/drivers/nouveau/nvc0/nve4_compute.c 2022-02-11 16:44:39.346172201 -0600 -@@ -545,7 +545,7 @@ nve4_compute_upload_input(struct nvc0_co - struct nv04_resource *res = nv04_resource(info->indirect); - uint32_t offset = res->offset + info->indirect_offset; - -- nouveau_pushbuf_space(push, 32, 0, 1); -+ PUSH_SPACE_EX(push, 32, 0, 1); - PUSH_REFN(push, res->bo, NOUVEAU_BO_RD | res->domain); - - BEGIN_1IC0(push, NVE4_CP(UPLOAD_EXEC), 1 + 8); -@@ -829,7 +829,7 @@ nve4_upload_indirect_desc(struct nouveau - PUSH_DATA (push, length); - PUSH_DATA (push, 1); - -- nouveau_pushbuf_space(push, 32, 0, 1); -+ PUSH_SPACE_EX(push, 32, 0, 1); - PUSH_REFN(push, res->bo, NOUVEAU_BO_RD | res->domain); - - BEGIN_1IC0(push, NVE4_CP(UPLOAD_EXEC), 1 + (length / 4)); -@@ -867,9 +867,10 @@ nve4_launch_grid(struct pipe_context *pi - resident->flags); - } - -+ simple_mtx_lock(&screen->state_lock); - ret = !nve4_state_validate_cp(nvc0, ~0); - if (ret) -- goto out; -+ goto out_unlock; - - if (nvc0->screen->compute->oclass >= GV100_COMPUTE_CLASS) - gv100_compute_setup_launch_desc(nvc0, desc, info); -@@ -923,7 +924,7 @@ nve4_launch_grid(struct pipe_context *pi - } - - /* upload descriptor and flush */ -- nouveau_pushbuf_space(push, 32, 1, 0); -+ PUSH_SPACE_EX(push, 32, 1, 0); - PUSH_REFN(push, screen->text, NV_VRAM_DOMAIN(&screen->base) | NOUVEAU_BO_RD); - BEGIN_NVC0(push, NVE4_CP(LAUNCH_DESC_ADDRESS), 1); - PUSH_DATA (push, desc_gpuaddr >> 8); -@@ -934,6 +935,9 @@ nve4_launch_grid(struct pipe_context *pi - - nvc0_update_compute_invocations_counter(nvc0, info); - -+out_unlock: -+ simple_mtx_unlock(&screen->state_lock); -+ - out: - if (ret) - NOUVEAU_ERR("Failed to launch grid !\n"); -@@ -1031,7 +1035,7 @@ nve4_compute_trap_info(struct nvc0_conte - volatile struct nve4_mp_trap_info *info; - uint8_t *map; - -- ret = nouveau_bo_map(bo, NOUVEAU_BO_RDWR, nvc0->base.client); -+ ret = BO_MAP(bo, NOUVEAU_BO_RDWR, nvc0->base.client); - if (ret) - return; - map = (uint8_t *)bo->map; diff --git a/repo/mesa/mesa.xibuild b/repo/mesa/mesa.xibuild index 45b1ba0..81a3549 100644 --- a/repo/mesa/mesa.xibuild +++ b/repo/mesa/mesa.xibuild @@ -1,17 +1,14 @@ #!/bin/sh -MAKEDEPS="meson ninja python-mako libvdpau llvm libxxf86vm libelf lm-sensors expat wayland-protocols llvm" +MAKEDEPS="meson ninja python-mako libvdpau llvm libxxf86vm libelf lm-sensors expat wayland-protocols llvm libxshmfence libdrm libxrandr" DEPS="xorg-libs libdrm" PKG_VER=22.1.7 SOURCE=https://mesa.freedesktop.org/archive/mesa-$PKG_VER.tar.xz ADDITIONAL=" + 0001-freedreno-Enable-A619.patch 0001-radeonsi-On-Aarch64-force-persistent-buffers-to-GTT.patch - add-use-elf-tls.patch disable-rgb10-by-default.patch - mesa-21.3.7-add_xdemos-1.patch - mesa-21.3.7-nouveau_fixes-1.patch - musl-fix-includes.patch " DESC="An implementation of the OpenGL specification" @@ -20,16 +17,15 @@ prepare () { apply_patches export GALLIUM_DRV="crocus,i915,iris,nouveau,r600,radeonsi,svga,swrast,virgl" - export DRI_DRIVERS="i965,nouveau" + #export DRI_DRIVERS="i965,nouveau" } build () { mkdir build && cd build && - meson --prefix=$XORG_PREFIX \ + meson --prefix=/usr \ --buildtype=release \ - -Ddri-drivers=$DRI_DRIVERS \ -Dgallium-drivers=$GALLIUM_DRV \ -Dplatforms=x11,wayland \ -Dgallium-nine=false \ @@ -43,6 +39,7 @@ build () { -Dvalgrind=disabled \ -Dlibunwind=disabled \ .. && + #-Ddri-drivers=$DRI_DRIVERS \ unset GALLIUM_DRV DRI_DRIVERS && diff --git a/repo/mesa/musl-fix-includes.patch b/repo/mesa/musl-fix-includes.patch deleted file mode 100644 index 8553d44..0000000 --- a/repo/mesa/musl-fix-includes.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/src/util/rand_xor.c b/src/util/rand_xor.c -index 81b64f1ea71..14e6c9d27c3 100644 ---- a/src/util/rand_xor.c -+++ b/src/util/rand_xor.c -@@ -27,6 +27,8 @@ - #if !DETECT_OS_WINDOWS - #if defined(HAVE_GETRANDOM) - #include <sys/random.h> -+#include <sys/types.h> -+#include <sys/stat.h> - #endif - #include <unistd.h> - #include <fcntl.h> |