From 78654a396749accb67307f91b6a8cc7e922f83cd Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Oct 30 2018 05:01:09 +0000 Subject: import mesa-18.0.5-3.el7 --- diff --git a/.gitignore b/.gitignore index 0fcb908..ef2c689 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/mesa-20171019.tar.xz +SOURCES/mesa-18.0.5.tar.xz diff --git a/.mesa.metadata b/.mesa.metadata index 22afd08..a7a554b 100644 --- a/.mesa.metadata +++ b/.mesa.metadata @@ -1 +1 @@ -7ec79a2e38091d819744f3fbf40d5fcb42d792fb SOURCES/mesa-20171019.tar.xz +116b35ae962e04326a4d61eab66b16108a7e33f0 SOURCES/mesa-18.0.5.tar.xz diff --git a/SOURCES/0001-intel-Add-more-Coffee-Lake-PCI-IDs.patch b/SOURCES/0001-intel-Add-more-Coffee-Lake-PCI-IDs.patch deleted file mode 100644 index e2d25df..0000000 --- a/SOURCES/0001-intel-Add-more-Coffee-Lake-PCI-IDs.patch +++ /dev/null @@ -1,45 +0,0 @@ -From fe668b5c155aee4443dde0748065241e09293302 Mon Sep 17 00:00:00 2001 -From: Anuj Phogat -Date: Fri, 5 Jan 2018 09:17:36 -0800 -Subject: [PATCH] intel: Add more Coffee Lake PCI IDs - -More Coffee Lake PCI IDs have been added to the spec. - -Signed-off-by: Anuj Phogat -Reviewed-by: Rodrigo Vivi ---- - include/pci_ids/i965_pci_ids.h | 10 +++++++++- - 1 file changed, 9 insertions(+), 1 deletion(-) - -diff --git a/include/pci_ids/i965_pci_ids.h b/include/pci_ids/i965_pci_ids.h -index 0dd01a4..9616f7d 100644 ---- a/include/pci_ids/i965_pci_ids.h -+++ b/include/pci_ids/i965_pci_ids.h -@@ -167,15 +167,23 @@ CHIPSET(0x3184, glk, "Intel(R) HD Graphics (Geminilake)") - CHIPSET(0x3185, glk_2x6, "Intel(R) HD Graphics (Geminilake 2x6)") - CHIPSET(0x3E90, cfl_gt1, "Intel(R) HD Graphics (Coffeelake 2x6 GT1)") - CHIPSET(0x3E93, cfl_gt1, "Intel(R) HD Graphics (Coffeelake 2x6 GT1)") -+CHIPSET(0x3E99, cfl_gt1, "Intel(R) HD Graphics (Coffeelake 2x6 GT1)") -+CHIPSET(0x3EA1, cfl_gt1, "Intel(R) HD Graphics (Coffeelake 2x6 GT1)") -+CHIPSET(0x3EA4, cfl_gt1, "Intel(R) HD Graphics (Coffeelake 2x6 GT1)") - CHIPSET(0x3E91, cfl_gt2, "Intel(R) HD Graphics (Coffeelake 3x8 GT2)") - CHIPSET(0x3E92, cfl_gt2, "Intel(R) HD Graphics (Coffeelake 3x8 GT2)") - CHIPSET(0x3E96, cfl_gt2, "Intel(R) HD Graphics (Coffeelake 3x8 GT2)") -+CHIPSET(0x3E9A, cfl_gt2, "Intel(R) HD Graphics (Coffeelake 3x8 GT2)") - CHIPSET(0x3E9B, cfl_gt2, "Intel(R) HD Graphics (Coffeelake 3x8 GT2)") - CHIPSET(0x3E94, cfl_gt2, "Intel(R) HD Graphics (Coffeelake 3x8 GT2)") -+CHIPSET(0x3EA0, cfl_gt2, "Intel(R) HD Graphics (Coffeelake 3x8 GT2)") -+CHIPSET(0x3EA3, cfl_gt2, "Intel(R) HD Graphics (Coffeelake 3x8 GT2)") -+CHIPSET(0x3EA9, cfl_gt2, "Intel(R) HD Graphics (Coffeelake 3x8 GT2)") -+CHIPSET(0x3EA2, cfl_gt3, "Intel(R) HD Graphics (Coffeelake 3x8 GT3)") -+CHIPSET(0x3EA5, cfl_gt3, "Intel(R) HD Graphics (Coffeelake 3x8 GT3)") - CHIPSET(0x3EA6, cfl_gt3, "Intel(R) HD Graphics (Coffeelake 3x8 GT3)") - CHIPSET(0x3EA7, cfl_gt3, "Intel(R) HD Graphics (Coffeelake 3x8 GT3)") - CHIPSET(0x3EA8, cfl_gt3, "Intel(R) HD Graphics (Coffeelake 3x8 GT3)") --CHIPSET(0x3EA5, cfl_gt3, "Intel(R) HD Graphics (Coffeelake 3x8 GT3)") - CHIPSET(0x5A49, cnl_2x8, "Intel(R) HD Graphics (Cannonlake 2x8 GT0.5)") - CHIPSET(0x5A4A, cnl_2x8, "Intel(R) HD Graphics (Cannonlake 2x8 GT0.5)") - CHIPSET(0x5A41, cnl_3x8, "Intel(R) HD Graphics (Cannonlake 3x8 GT1)") --- -2.9.5 - diff --git a/SOURCES/0001-intel-blorp-Use-mocs.tex-for-depth-stencil.patch b/SOURCES/0001-intel-blorp-Use-mocs.tex-for-depth-stencil.patch deleted file mode 100644 index 69eee59..0000000 --- a/SOURCES/0001-intel-blorp-Use-mocs.tex-for-depth-stencil.patch +++ /dev/null @@ -1,33 +0,0 @@ -From d284bd93e387019b34796b6d8e7a985d60590157 Mon Sep 17 00:00:00 2001 -From: Jason Ekstrand -Date: Fri, 3 Nov 2017 14:31:51 -0700 -Subject: [PATCH 1/5] intel/blorp: Use mocs.tex for depth stencil - -Cc: "17.3" -Tested-by: Lyude Paul -Reviewed-by: Kenneth Graunke -Signed-off-by: Lyude ---- - src/intel/blorp/blorp_genX_exec.h | 6 +----- - 1 file changed, 1 insertion(+), 5 deletions(-) - -diff --git a/src/intel/blorp/blorp_genX_exec.h b/src/intel/blorp/blorp_genX_exec.h -index 93534169ef..565acca929 100644 ---- a/src/intel/blorp/blorp_genX_exec.h -+++ b/src/intel/blorp/blorp_genX_exec.h -@@ -1364,11 +1364,7 @@ blorp_emit_depth_stencil_config(struct blorp_batch *batch, - return; - - struct isl_depth_stencil_hiz_emit_info info = { --#if GEN_GEN >= 7 -- .mocs = 1, /* GEN7_MOCS_L3 */ --#else -- .mocs = 0, --#endif -+ .mocs = batch->blorp->mocs.tex, - }; - - if (params->depth.enabled) { --- -2.14.3 - diff --git a/SOURCES/0001-mesa-Squash-merge-of-S3TC-support.patch b/SOURCES/0001-mesa-Squash-merge-of-S3TC-support.patch deleted file mode 100644 index 1b4433b..0000000 --- a/SOURCES/0001-mesa-Squash-merge-of-S3TC-support.patch +++ /dev/null @@ -1,2492 +0,0 @@ -From aff9c0e3d29983f90438dd4006e6f2654c878fd4 Mon Sep 17 00:00:00 2001 -From: Matt Turner -Date: Wed, 27 Sep 2017 19:58:28 -0700 -Subject: [PATCH] mesa: Squash merge of S3TC support - -(cherry picked from commit 04396a134f003aece573df593acfa1ab4418ffe8) -(cherry picked from commit f7daa737d17df6d0a847e5c61e48d25e598671f4) -(cherry picked from commit 7ce9999166f24996d24d56d3effcae181d401111) -(cherry picked from commit 82c54c4fdc8495d7522c782141c080314459690a) -(cherry picked from commit fb5338c4b77db70ea26b0745cff1cb3e330a5139) -(cherry picked from commit 34cf3c43beed2fafb4512e921f39c818478f86d7) -(cherry picked from commit 78c6221f18ab451f2e57bc61852595a60f82e3cb) -(cherry picked from commit c5d508028454f42923aee1ea1ab876f01f680ae7) -(cherry picked from commit f6c56e07fc5a8e81fd90688c9fee239f18c3480e) -(cherry picked from commit 3a8a5e77e8f992aaa3539e060885138c2fcddad1) -(cherry picked from commit dc546a7bb3fae1d597e5a22d9527540ec4f072c8) -(cherry picked from commit c17c47207b96172ca9c85a16f7fb7f1d3ea959d8) -(cherry picked from commit 8d02abd0feaaef28a35d89903bd534a7f27c38d7) -(cherry picked from commit 74b5568978968f580b9809135198db1015bc55b7) ---- - configure.ac | 4 +- - src/gallium/auxiliary/util/u_format.c | 2 +- - src/gallium/auxiliary/util/u_format_s3tc.c | 133 +-- - src/gallium/auxiliary/util/u_format_s3tc.h | 6 - - src/gallium/drivers/freedreno/freedreno_screen.c | 2 - - src/gallium/drivers/i915/i915_screen.c | 2 - - src/gallium/drivers/llvmpipe/lp_screen.c | 6 - - src/gallium/drivers/llvmpipe/lp_test_format.c | 7 - - src/gallium/drivers/nouveau/nouveau_screen.c | 2 - - src/gallium/drivers/r300/r300_screen.c | 3 +- - src/gallium/drivers/r300/r300_texture.c | 4 - - src/gallium/drivers/r600/r600_state_common.c | 4 - - src/gallium/drivers/radeon/r600_pipe_common.c | 1 - - src/gallium/drivers/radeonsi/si_state.c | 4 - - src/gallium/drivers/softpipe/sp_screen.c | 6 - - src/gallium/drivers/swr/swr_screen.cpp | 6 - - src/gallium/drivers/virgl/virgl_screen.c | 5 +- - src/gallium/include/state_tracker/st_api.h | 1 - - src/gallium/state_trackers/dri/dri_screen.c | 16 - - src/gallium/state_trackers/osmesa/osmesa.c | 1 - - src/gallium/tests/unit/u_format_test.c | 7 - - src/mesa/Makefile.sources | 1 - - src/mesa/SConscript | 4 - - src/mesa/drivers/dri/common/xmlpool/t_options.h | 5 - - src/mesa/drivers/dri/i915/intel_extensions.c | 5 +- - src/mesa/drivers/dri/i915/intel_screen.c | 1 - - src/mesa/drivers/dri/i965/intel_extensions.c | 4 +- - src/mesa/drivers/dri/i965/intel_screen.c | 2 - - src/mesa/drivers/dri/nouveau/nv10_context.c | 6 +- - src/mesa/drivers/dri/nouveau/nv20_context.c | 6 +- - src/mesa/drivers/dri/r200/r200_context.c | 10 +- - src/mesa/drivers/dri/radeon/radeon_context.c | 10 +- - src/mesa/drivers/dri/radeon/radeon_screen.c | 2 - - src/mesa/main/context.c | 2 - - src/mesa/main/dlopen.h | 97 --- - src/mesa/main/extensions.c | 6 +- - src/mesa/main/mtypes.h | 3 - - src/mesa/main/texcompress_s3tc.c | 269 ++---- - src/mesa/main/texcompress_s3tc.h | 3 - - src/mesa/main/texcompress_s3tc_tmp.h | 989 +++++++++++++++++++++++ - src/mesa/main/texformat.c | 14 +- - src/mesa/main/teximage.c | 32 - - src/mesa/state_tracker/st_context.c | 2 +- - src/mesa/state_tracker/st_extensions.c | 8 +- - src/mesa/state_tracker/st_extensions.h | 3 +- - src/mesa/state_tracker/st_format.c | 4 +- - src/mesa/state_tracker/st_manager.c | 2 +- - 47 files changed, 1083 insertions(+), 629 deletions(-) - delete mode 100644 src/mesa/main/dlopen.h - create mode 100644 src/mesa/main/texcompress_s3tc_tmp.h - -diff --git a/configure.ac b/configure.ac -index 49dd002502..cdce1ea8b1 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -862,9 +862,9 @@ AC_LINK_IFELSE([AC_LANG_SOURCE([[ - - dnl Check to see if dlopen is in default libraries (like Solaris, which - dnl has it in libc), or if libdl is needed to get it. --AC_CHECK_FUNC([dlopen], [DEFINES="$DEFINES -DHAVE_DLOPEN"], -+AC_CHECK_FUNC([dlopen], [], - [AC_CHECK_LIB([dl], [dlopen], -- [DEFINES="$DEFINES -DHAVE_DLOPEN"; DLOPEN_LIBS="-ldl"])]) -+ [DLOPEN_LIBS="-ldl"])]) - AC_SUBST([DLOPEN_LIBS]) - - dnl Check if that library also has dladdr -diff --git a/src/gallium/auxiliary/util/u_format.c b/src/gallium/auxiliary/util/u_format.c -index 3d281905ce..0fc3231654 100644 ---- a/src/gallium/auxiliary/util/u_format.c -+++ b/src/gallium/auxiliary/util/u_format.c -@@ -238,7 +238,7 @@ util_format_is_subsampled_422(enum pipe_format format) - boolean - util_format_is_supported(enum pipe_format format, unsigned bind) - { -- if (util_format_is_s3tc(format) && !util_format_s3tc_enabled) { -+ if (format >= PIPE_FORMAT_COUNT) { - return FALSE; - } - -diff --git a/src/gallium/auxiliary/util/u_format_s3tc.c b/src/gallium/auxiliary/util/u_format_s3tc.c -index 8c4f2150be..3f755e5363 100644 ---- a/src/gallium/auxiliary/util/u_format_s3tc.c -+++ b/src/gallium/auxiliary/util/u_format_s3tc.c -@@ -28,136 +28,15 @@ - #include "u_format.h" - #include "u_format_s3tc.h" - #include "util/format_srgb.h" -+#include "../../../mesa/main/texcompress_s3tc_tmp.h" - - --#if defined(_WIN32) || defined(WIN32) --#define DXTN_LIBNAME "dxtn.dll" --#elif defined(__CYGWIN__) --#define DXTN_LIBNAME "cygtxc_dxtn.dll" --#elif defined(__APPLE__) --#define DXTN_LIBNAME "libtxc_dxtn.dylib" --#else --#define DXTN_LIBNAME "libtxc_dxtn.so" --#endif -+util_format_dxtn_fetch_t util_format_dxt1_rgb_fetch = (util_format_dxtn_fetch_t)fetch_2d_texel_rgb_dxt1; -+util_format_dxtn_fetch_t util_format_dxt1_rgba_fetch = (util_format_dxtn_fetch_t)fetch_2d_texel_rgba_dxt1; -+util_format_dxtn_fetch_t util_format_dxt3_rgba_fetch = (util_format_dxtn_fetch_t)fetch_2d_texel_rgba_dxt3; -+util_format_dxtn_fetch_t util_format_dxt5_rgba_fetch = (util_format_dxtn_fetch_t)fetch_2d_texel_rgba_dxt5; - -- --static void --util_format_dxt1_rgb_fetch_stub(int src_stride, -- const uint8_t *src, -- int col, int row, -- uint8_t *dst) --{ -- assert(0); --} -- -- --static void --util_format_dxt1_rgba_fetch_stub(int src_stride, -- const uint8_t *src, -- int col, int row, -- uint8_t *dst ) --{ -- assert(0); --} -- -- --static void --util_format_dxt3_rgba_fetch_stub(int src_stride, -- const uint8_t *src, -- int col, int row, -- uint8_t *dst ) --{ -- assert(0); --} -- -- --static void --util_format_dxt5_rgba_fetch_stub(int src_stride, -- const uint8_t *src, -- int col, int row, -- uint8_t *dst ) --{ -- assert(0); --} -- -- --static void --util_format_dxtn_pack_stub(int src_comps, -- int width, int height, -- const uint8_t *src, -- enum util_format_dxtn dst_format, -- uint8_t *dst, -- int dst_stride) --{ -- assert(0); --} -- -- --boolean util_format_s3tc_enabled = FALSE; -- --util_format_dxtn_fetch_t util_format_dxt1_rgb_fetch = util_format_dxt1_rgb_fetch_stub; --util_format_dxtn_fetch_t util_format_dxt1_rgba_fetch = util_format_dxt1_rgba_fetch_stub; --util_format_dxtn_fetch_t util_format_dxt3_rgba_fetch = util_format_dxt3_rgba_fetch_stub; --util_format_dxtn_fetch_t util_format_dxt5_rgba_fetch = util_format_dxt5_rgba_fetch_stub; -- --util_format_dxtn_pack_t util_format_dxtn_pack = util_format_dxtn_pack_stub; -- -- --void --util_format_s3tc_init(void) --{ -- static boolean first_time = TRUE; -- struct util_dl_library *library = NULL; -- util_dl_proc fetch_2d_texel_rgb_dxt1; -- util_dl_proc fetch_2d_texel_rgba_dxt1; -- util_dl_proc fetch_2d_texel_rgba_dxt3; -- util_dl_proc fetch_2d_texel_rgba_dxt5; -- util_dl_proc tx_compress_dxtn; -- -- if (!first_time) -- return; -- first_time = FALSE; -- -- if (util_format_s3tc_enabled) -- return; -- -- library = util_dl_open(DXTN_LIBNAME); -- if (!library) { -- debug_printf("couldn't open " DXTN_LIBNAME ", software DXTn " -- "compression/decompression unavailable\n"); -- return; -- } -- -- fetch_2d_texel_rgb_dxt1 = -- util_dl_get_proc_address(library, "fetch_2d_texel_rgb_dxt1"); -- fetch_2d_texel_rgba_dxt1 = -- util_dl_get_proc_address(library, "fetch_2d_texel_rgba_dxt1"); -- fetch_2d_texel_rgba_dxt3 = -- util_dl_get_proc_address(library, "fetch_2d_texel_rgba_dxt3"); -- fetch_2d_texel_rgba_dxt5 = -- util_dl_get_proc_address(library, "fetch_2d_texel_rgba_dxt5"); -- tx_compress_dxtn = -- util_dl_get_proc_address(library, "tx_compress_dxtn"); -- -- if (!util_format_dxt1_rgb_fetch || -- !util_format_dxt1_rgba_fetch || -- !util_format_dxt3_rgba_fetch || -- !util_format_dxt5_rgba_fetch || -- !util_format_dxtn_pack) { -- debug_printf("couldn't reference all symbols in " DXTN_LIBNAME -- ", software DXTn compression/decompression " -- "unavailable\n"); -- util_dl_close(library); -- return; -- } -- -- util_format_dxt1_rgb_fetch = (util_format_dxtn_fetch_t)fetch_2d_texel_rgb_dxt1; -- util_format_dxt1_rgba_fetch = (util_format_dxtn_fetch_t)fetch_2d_texel_rgba_dxt1; -- util_format_dxt3_rgba_fetch = (util_format_dxtn_fetch_t)fetch_2d_texel_rgba_dxt3; -- util_format_dxt5_rgba_fetch = (util_format_dxtn_fetch_t)fetch_2d_texel_rgba_dxt5; -- util_format_dxtn_pack = (util_format_dxtn_pack_t)tx_compress_dxtn; -- util_format_s3tc_enabled = TRUE; --} -+util_format_dxtn_pack_t util_format_dxtn_pack = (util_format_dxtn_pack_t)tx_compress_dxtn; - - - /* -diff --git a/src/gallium/auxiliary/util/u_format_s3tc.h b/src/gallium/auxiliary/util/u_format_s3tc.h -index ae20010cdf..6f188c67f9 100644 ---- a/src/gallium/auxiliary/util/u_format_s3tc.h -+++ b/src/gallium/auxiliary/util/u_format_s3tc.h -@@ -58,8 +58,6 @@ typedef void - uint8_t *dst, - int dst_stride); - --extern boolean util_format_s3tc_enabled; -- - extern util_format_dxtn_fetch_t util_format_dxt1_rgb_fetch; - extern util_format_dxtn_fetch_t util_format_dxt1_rgba_fetch; - extern util_format_dxtn_fetch_t util_format_dxt3_rgba_fetch; -@@ -69,10 +67,6 @@ extern util_format_dxtn_pack_t util_format_dxtn_pack; - - - void --util_format_s3tc_init(void); -- -- --void - util_format_dxt1_rgb_unpack_rgba_8unorm(uint8_t *dst_row, unsigned dst_stride, const uint8_t *src_row, unsigned src_stride, unsigned width, unsigned height); - - void -diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c -index a915d65ee0..59402ef3f6 100644 ---- a/src/gallium/drivers/freedreno/freedreno_screen.c -+++ b/src/gallium/drivers/freedreno/freedreno_screen.c -@@ -875,8 +875,6 @@ fd_screen_create(struct fd_device *dev) - - slab_create_parent(&screen->transfer_pool, sizeof(struct fd_transfer), 16); - -- util_format_s3tc_init(); -- - return pscreen; - - fail: -diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c -index 4ad98e2a08..b5675e417c 100644 ---- a/src/gallium/drivers/i915/i915_screen.c -+++ b/src/gallium/drivers/i915/i915_screen.c -@@ -621,7 +621,5 @@ i915_screen_create(struct i915_winsys *iws) - - i915_debug_init(is); - -- util_format_s3tc_init(); -- - return &is->base; - } -diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c -index e98e30d50a..3ec68a5771 100644 ---- a/src/gallium/drivers/llvmpipe/lp_screen.c -+++ b/src/gallium/drivers/llvmpipe/lp_screen.c -@@ -528,10 +528,6 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen, - format != PIPE_FORMAT_ETC1_RGB8) - return FALSE; - -- if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) { -- return util_format_s3tc_enabled; -- } -- - /* - * Everything can be supported by u_format - * (those without fetch_rgba_float might be not but shouldn't hit that) -@@ -682,7 +678,5 @@ llvmpipe_create_screen(struct sw_winsys *winsys) - } - (void) mtx_init(&screen->rast_mutex, mtx_plain); - -- util_format_s3tc_init(); -- - return &screen->base; - } -diff --git a/src/gallium/drivers/llvmpipe/lp_test_format.c b/src/gallium/drivers/llvmpipe/lp_test_format.c -index 9b16162131..e9a6e01fdc 100644 ---- a/src/gallium/drivers/llvmpipe/lp_test_format.c -+++ b/src/gallium/drivers/llvmpipe/lp_test_format.c -@@ -357,8 +357,6 @@ test_all(unsigned verbose, FILE *fp) - enum pipe_format format; - boolean success = TRUE; - -- util_format_s3tc_init(); -- - #if USE_TEXTURE_CACHE - cache_ptr = align_malloc(sizeof(struct lp_build_format_cache), 16); - #endif -@@ -383,11 +381,6 @@ test_all(unsigned verbose, FILE *fp) - if (util_format_is_pure_integer(format)) - continue; - -- if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC && -- !util_format_s3tc_enabled) { -- continue; -- } -- - /* only have util fetch func for etc1 */ - if (format_desc->layout == UTIL_FORMAT_LAYOUT_ETC && - format != PIPE_FORMAT_ETC1_RGB8) { -diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c -index 13b76d7681..ea68809c6e 100644 ---- a/src/gallium/drivers/nouveau/nouveau_screen.c -+++ b/src/gallium/drivers/nouveau/nouveau_screen.c -@@ -242,8 +242,6 @@ nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) - - nouveau_disk_cache_create(screen); - -- util_format_s3tc_init(); -- - screen->lowmem_bindings = PIPE_BIND_GLOBAL; /* gallium limit */ - screen->vidmem_bindings = - PIPE_BIND_RENDER_TARGET | PIPE_BIND_DEPTH_STENCIL | -diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c -index 5cdb24871c..82d7183b9e 100644 ---- a/src/gallium/drivers/r300/r300_screen.c -+++ b/src/gallium/drivers/r300/r300_screen.c -@@ -127,7 +127,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param) - - /* r300 cannot do swizzling of compressed textures. Supported otherwise. */ - case PIPE_CAP_TEXTURE_SWIZZLE: -- return util_format_s3tc_enabled ? r300screen->caps.dxtc_swizzle : 1; -+ return r300screen->caps.dxtc_swizzle; - - /* We don't support color clamping on r500, so that we can use color - * intepolators for generic varyings. */ -@@ -762,7 +762,6 @@ struct pipe_screen* r300_screen_create(struct radeon_winsys *rws, unsigned flags - - slab_create_parent(&r300screen->pool_transfers, sizeof(struct pipe_transfer), 64); - -- util_format_s3tc_init(); - (void) mtx_init(&r300screen->cmask_mutex, mtx_plain); - - return &r300screen->screen; -diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c -index cdf9ccb973..87632fcbb4 100644 ---- a/src/gallium/drivers/r300/r300_texture.c -+++ b/src/gallium/drivers/r300/r300_texture.c -@@ -251,10 +251,6 @@ uint32_t r300_translate_texformat(enum pipe_format format, - - /* S3TC formats. */ - if (desc->layout == UTIL_FORMAT_LAYOUT_S3TC) { -- if (!util_format_s3tc_enabled) { -- return ~0; /* Unsupported. */ -- } -- - switch (format) { - case PIPE_FORMAT_DXT1_RGB: - case PIPE_FORMAT_DXT1_RGBA: -diff --git a/src/gallium/drivers/r600/r600_state_common.c b/src/gallium/drivers/r600/r600_state_common.c -index 4c97efa73b..306b3c0abb 100644 ---- a/src/gallium/drivers/r600/r600_state_common.c -+++ b/src/gallium/drivers/r600/r600_state_common.c -@@ -2403,10 +2403,6 @@ uint32_t r600_translate_texformat(struct pipe_screen *screen, - } - - if (desc->layout == UTIL_FORMAT_LAYOUT_S3TC) { -- if (!util_format_s3tc_enabled) { -- goto out_unknown; -- } -- - switch (format) { - case PIPE_FORMAT_DXT1_RGB: - case PIPE_FORMAT_DXT1_RGBA: -diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c -index b02203c3c1..a3c6ed0a22 100644 ---- a/src/gallium/drivers/radeon/r600_pipe_common.c -+++ b/src/gallium/drivers/radeon/r600_pipe_common.c -@@ -1408,7 +1408,6 @@ bool r600_common_screen_init(struct r600_common_screen *rscreen, - 1 << util_logbase2(rscreen->force_aniso)); - } - -- util_format_s3tc_init(); - (void) mtx_init(&rscreen->aux_context_lock, mtx_plain); - (void) mtx_init(&rscreen->gpu_load_mutex, mtx_plain); - -diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c -index c610103032..931c326b49 100644 ---- a/src/gallium/drivers/radeonsi/si_state.c -+++ b/src/gallium/drivers/radeonsi/si_state.c -@@ -1525,10 +1525,6 @@ static uint32_t si_translate_texformat(struct pipe_screen *screen, - if (!enable_compressed_formats) - goto out_unknown; - -- if (!util_format_s3tc_enabled) { -- goto out_unknown; -- } -- - switch (format) { - case PIPE_FORMAT_DXT1_RGB: - case PIPE_FORMAT_DXT1_RGBA: -diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c -index 5c96a14c80..6aa6beb1ad 100644 ---- a/src/gallium/drivers/softpipe/sp_screen.c -+++ b/src/gallium/drivers/softpipe/sp_screen.c -@@ -455,10 +455,6 @@ softpipe_is_format_supported( struct pipe_screen *screen, - * All other operations (sampling, transfer, etc). - */ - -- if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) { -- return util_format_s3tc_enabled; -- } -- - /* - * Everything else should be supported by u_format. - */ -@@ -585,8 +581,6 @@ softpipe_create_screen(struct sw_winsys *winsys) - screen->base.get_compute_param = softpipe_get_compute_param; - screen->use_llvm = debug_get_option_use_llvm(); - -- util_format_s3tc_init(); -- - softpipe_init_screen_texture_funcs(&screen->base); - softpipe_init_screen_fence_funcs(&screen->base); - -diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp -index 952ae0c77a..d4f4ee8da1 100644 ---- a/src/gallium/drivers/swr/swr_screen.cpp -+++ b/src/gallium/drivers/swr/swr_screen.cpp -@@ -147,10 +147,6 @@ swr_is_format_supported(struct pipe_screen *_screen, - return FALSE; - } - -- if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) { -- return util_format_s3tc_enabled; -- } -- - return TRUE; - } - -@@ -1140,8 +1136,6 @@ swr_create_screen_internal(struct sw_winsys *winsys) - - swr_fence_init(&screen->base); - -- util_format_s3tc_init(); -- - swr_validate_env_options(screen); - - return &screen->base; -diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c -index 5df08407d7..c8c29d0812 100644 ---- a/src/gallium/drivers/virgl/virgl_screen.c -+++ b/src/gallium/drivers/virgl/virgl_screen.c -@@ -480,9 +480,7 @@ virgl_is_format_supported( struct pipe_screen *screen, - */ - - if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC) { -- if (util_format_s3tc_enabled) -- goto out_lookup; -- return FALSE; -+ goto out_lookup; - } - if (format_desc->layout == UTIL_FORMAT_LAYOUT_RGTC) { - goto out_lookup; -@@ -606,6 +604,5 @@ virgl_create_screen(struct virgl_winsys *vws) - - slab_create_parent(&screen->texture_transfer_pool, sizeof(struct virgl_transfer), 16); - -- util_format_s3tc_init(); - return &screen->base; - } -diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h -index bc62a69da3..fe9fb1816a 100644 ---- a/src/gallium/include/state_tracker/st_api.h -+++ b/src/gallium/include/state_tracker/st_api.h -@@ -246,7 +246,6 @@ struct st_config_options - boolean disable_shader_bit_encoding; - boolean force_glsl_extensions_warn; - unsigned force_glsl_version; -- boolean force_s3tc_enable; - boolean allow_glsl_extension_directive_midshader; - boolean allow_glsl_builtin_variable_redeclaration; - boolean allow_higher_compat_version; -diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c -index 6bd479074f..09af6a6234 100644 ---- a/src/gallium/state_trackers/dri/dri_screen.c -+++ b/src/gallium/state_trackers/dri/dri_screen.c -@@ -62,7 +62,6 @@ const __DRIconfigOptionsExtension gallium_config_options = { - DRI_CONF_SECTION_END - - DRI_CONF_SECTION_QUALITY -- DRI_CONF_FORCE_S3TC_ENABLE("false") - DRI_CONF_PP_CELSHADE(0) - DRI_CONF_PP_NORED(0) - DRI_CONF_PP_NOGREEN(0) -@@ -109,8 +108,6 @@ dri_fill_st_options(struct dri_screen *screen) - driQueryOptionb(optionCache, "force_glsl_extensions_warn"); - options->force_glsl_version = - driQueryOptioni(optionCache, "force_glsl_version"); -- options->force_s3tc_enable = -- driQueryOptionb(optionCache, "force_s3tc_enable"); - options->allow_glsl_extension_directive_midshader = - driQueryOptionb(optionCache, "allow_glsl_extension_directive_midshader"); - options->allow_glsl_builtin_variable_redeclaration = -@@ -564,19 +561,6 @@ dri_init_screen_helper(struct dri_screen *screen, - else - screen->target = PIPE_TEXTURE_RECT; - -- /* Handle force_s3tc_enable. */ -- if (!util_format_s3tc_enabled && screen->options.force_s3tc_enable) { -- /* Ensure libtxc_dxtn has been loaded if available. -- * Forcing S3TC on before calling this would prevent loading -- * the library. -- * This is just a precaution, the driver should have called it -- * already. -- */ -- util_format_s3tc_init(); -- -- util_format_s3tc_enabled = TRUE; -- } -- - dri_postprocessing_init(screen); - - screen->st_api->query_versions(screen->st_api, &screen->base, -diff --git a/src/gallium/state_trackers/osmesa/osmesa.c b/src/gallium/state_trackers/osmesa/osmesa.c -index 751d255c54..2f9558db31 100644 ---- a/src/gallium/state_trackers/osmesa/osmesa.c -+++ b/src/gallium/state_trackers/osmesa/osmesa.c -@@ -688,7 +688,6 @@ OSMesaCreateContextAttribs(const int *attribList, OSMesaContext sharelist) - attribs.options.disable_blend_func_extended = FALSE; - attribs.options.disable_glsl_line_continuations = FALSE; - attribs.options.disable_shader_bit_encoding = FALSE; -- attribs.options.force_s3tc_enable = FALSE; - attribs.options.force_glsl_version = 0; - - osmesa_init_st_visual(&attribs.visual, -diff --git a/src/gallium/tests/unit/u_format_test.c b/src/gallium/tests/unit/u_format_test.c -index 69d6c7dd3a..6de581fd04 100644 ---- a/src/gallium/tests/unit/u_format_test.c -+++ b/src/gallium/tests/unit/u_format_test.c -@@ -722,11 +722,6 @@ test_all(void) - assert(format_desc->block.height <= UTIL_FORMAT_MAX_UNPACKED_HEIGHT); - assert(format_desc->block.width <= UTIL_FORMAT_MAX_UNPACKED_WIDTH); - -- if (format_desc->layout == UTIL_FORMAT_LAYOUT_S3TC && -- !util_format_s3tc_enabled) { -- continue; -- } -- - # define TEST_ONE_FUNC(name) \ - if (format_desc->name) { \ - if (!test_one_func(format_desc, &test_format_##name, #name)) { \ -@@ -758,8 +753,6 @@ int main(int argc, char **argv) - { - boolean success; - -- util_format_s3tc_init(); -- - success = test_all(); - - return success ? 0 : 1; -diff --git a/src/mesa/Makefile.sources b/src/mesa/Makefile.sources -index 86fbf3974e..bc93ded3db 100644 ---- a/src/mesa/Makefile.sources -+++ b/src/mesa/Makefile.sources -@@ -67,7 +67,6 @@ MAIN_FILES = \ - main/depth.h \ - main/dlist.c \ - main/dlist.h \ -- main/dlopen.h \ - main/drawpix.c \ - main/drawpix.h \ - main/drawtex.c \ -diff --git a/src/mesa/SConscript b/src/mesa/SConscript -index b63e15a3f0..ba98ad4323 100644 ---- a/src/mesa/SConscript -+++ b/src/mesa/SConscript -@@ -31,10 +31,6 @@ if env['platform'] == 'windows': - if not env['gles']: - # prevent _glapi_* from being declared __declspec(dllimport) - env.Append(CPPDEFINES = ['_GLAPI_NO_EXPORTS']) --else: -- env.Append(CPPDEFINES = [ -- ('HAVE_DLOPEN', '1'), -- ]) - - # parse Makefile.sources - source_lists = env.ParseSourceList('Makefile.sources') -diff --git a/src/mesa/drivers/dri/common/xmlpool/t_options.h b/src/mesa/drivers/dri/common/xmlpool/t_options.h -index e308839aa7..afe342df07 100644 ---- a/src/mesa/drivers/dri/common/xmlpool/t_options.h -+++ b/src/mesa/drivers/dri/common/xmlpool/t_options.h -@@ -172,11 +172,6 @@ DRI_CONF_OPT_BEGIN_B(no_neg_lod_bias, def) \ - DRI_CONF_DESC(en,gettext("Forbid negative texture LOD bias")) \ - DRI_CONF_OPT_END - --#define DRI_CONF_FORCE_S3TC_ENABLE(def) \ --DRI_CONF_OPT_BEGIN_B(force_s3tc_enable, def) \ -- DRI_CONF_DESC(en,gettext("Enable S3TC texture compression even if software support is not available")) \ --DRI_CONF_OPT_END -- - #define DRI_CONF_PRECISE_TRIG(def) \ - DRI_CONF_OPT_BEGIN_B(precise_trig, def) \ - DRI_CONF_DESC(en,gettext("Prefer accuracy over performance in trig functions")) \ -diff --git a/src/mesa/drivers/dri/i915/intel_extensions.c b/src/mesa/drivers/dri/i915/intel_extensions.c -index 4f2c6fa34e..c85bd787fe 100644 ---- a/src/mesa/drivers/dri/i915/intel_extensions.c -+++ b/src/mesa/drivers/dri/i915/intel_extensions.c -@@ -100,9 +100,6 @@ intelInitExtensions(struct gl_context *ctx) - ctx->Extensions.ARB_occlusion_query = true; - } - -- if (intel->ctx.Mesa_DXTn -- || driQueryOptionb(&intel->optionCache, "force_s3tc_enable")) -- ctx->Extensions.EXT_texture_compression_s3tc = true; -- -+ ctx->Extensions.EXT_texture_compression_s3tc = true; - ctx->Extensions.ANGLE_texture_compression_dxt = true; - } -diff --git a/src/mesa/drivers/dri/i915/intel_screen.c b/src/mesa/drivers/dri/i915/intel_screen.c -index 863f6ef7ec..c223133363 100644 ---- a/src/mesa/drivers/dri/i915/intel_screen.c -+++ b/src/mesa/drivers/dri/i915/intel_screen.c -@@ -67,7 +67,6 @@ DRI_CONF_BEGIN - - DRI_CONF_SECTION_END - DRI_CONF_SECTION_QUALITY -- DRI_CONF_FORCE_S3TC_ENABLE("false") - DRI_CONF_SECTION_END - DRI_CONF_SECTION_DEBUG - DRI_CONF_NO_RAST("false") -diff --git a/src/mesa/drivers/dri/i965/intel_extensions.c b/src/mesa/drivers/dri/i965/intel_extensions.c -index b91bbdc8d9..4fe97a0ce7 100644 ---- a/src/mesa/drivers/dri/i965/intel_extensions.c -+++ b/src/mesa/drivers/dri/i965/intel_extensions.c -@@ -297,8 +297,6 @@ intelInitExtensions(struct gl_context *ctx) - if (ctx->API != API_OPENGL_CORE) - ctx->Extensions.ARB_color_buffer_float = true; - -- if (ctx->Mesa_DXTn || driQueryOptionb(&brw->optionCache, "force_s3tc_enable")) -- ctx->Extensions.EXT_texture_compression_s3tc = true; -- -+ ctx->Extensions.EXT_texture_compression_s3tc = true; - ctx->Extensions.ANGLE_texture_compression_dxt = true; - } -diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c -index 5adb8ef1f6..e60f9fb10a 100644 ---- a/src/mesa/drivers/dri/i965/intel_screen.c -+++ b/src/mesa/drivers/dri/i965/intel_screen.c -@@ -69,8 +69,6 @@ DRI_CONF_BEGIN - DRI_CONF_SECTION_END - - DRI_CONF_SECTION_QUALITY -- DRI_CONF_FORCE_S3TC_ENABLE("false") -- - DRI_CONF_PRECISE_TRIG("false") - - DRI_CONF_OPT_BEGIN(clamp_max_samples, int, -1) -diff --git a/src/mesa/drivers/dri/nouveau/nv10_context.c b/src/mesa/drivers/dri/nouveau/nv10_context.c -index 7a86ba2358..be2178fb79 100644 ---- a/src/mesa/drivers/dri/nouveau/nv10_context.c -+++ b/src/mesa/drivers/dri/nouveau/nv10_context.c -@@ -451,10 +451,8 @@ nv10_context_create(struct nouveau_screen *screen, gl_api api, - ctx->Extensions.EXT_texture_env_dot3 = true; - ctx->Extensions.NV_fog_distance = true; - ctx->Extensions.NV_texture_rectangle = true; -- if (ctx->Mesa_DXTn) { -- ctx->Extensions.EXT_texture_compression_s3tc = true; -- ctx->Extensions.ANGLE_texture_compression_dxt = true; -- } -+ ctx->Extensions.EXT_texture_compression_s3tc = true; -+ ctx->Extensions.ANGLE_texture_compression_dxt = true; - - /* GL constants. */ - ctx->Const.MaxTextureLevels = 12; -diff --git a/src/mesa/drivers/dri/nouveau/nv20_context.c b/src/mesa/drivers/dri/nouveau/nv20_context.c -index ec638c036b..0ab2db0b08 100644 ---- a/src/mesa/drivers/dri/nouveau/nv20_context.c -+++ b/src/mesa/drivers/dri/nouveau/nv20_context.c -@@ -462,10 +462,8 @@ nv20_context_create(struct nouveau_screen *screen, gl_api api, - ctx->Extensions.EXT_texture_env_dot3 = true; - ctx->Extensions.NV_fog_distance = true; - ctx->Extensions.NV_texture_rectangle = true; -- if (ctx->Mesa_DXTn) { -- ctx->Extensions.EXT_texture_compression_s3tc = true; -- ctx->Extensions.ANGLE_texture_compression_dxt = true; -- } -+ ctx->Extensions.EXT_texture_compression_s3tc = true; -+ ctx->Extensions.ANGLE_texture_compression_dxt = true; - - /* GL constants. */ - ctx->Const.MaxTextureCoordUnits = NV20_TEXTURE_UNITS; -diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c -index 5a7f33499b..de15d520fe 100644 ---- a/src/mesa/drivers/dri/r200/r200_context.c -+++ b/src/mesa/drivers/dri/r200/r200_context.c -@@ -362,14 +362,8 @@ GLboolean r200CreateContext( gl_api api, - others get the bit ordering right but don't actually do YUV-RGB conversion */ - ctx->Extensions.MESA_ycbcr_texture = true; - } -- if (rmesa->radeon.glCtx.Mesa_DXTn) { -- ctx->Extensions.EXT_texture_compression_s3tc = true; -- ctx->Extensions.ANGLE_texture_compression_dxt = true; -- } -- else if (driQueryOptionb (&rmesa->radeon.optionCache, "force_s3tc_enable")) { -- ctx->Extensions.EXT_texture_compression_s3tc = true; -- ctx->Extensions.ANGLE_texture_compression_dxt = true; -- } -+ ctx->Extensions.EXT_texture_compression_s3tc = true; -+ ctx->Extensions.ANGLE_texture_compression_dxt = true; - - #if 0 - r200InitDriverFuncs( ctx ); -diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c -index 5ef3467ac1..e84b544c19 100644 ---- a/src/mesa/drivers/dri/radeon/radeon_context.c -+++ b/src/mesa/drivers/dri/radeon/radeon_context.c -@@ -310,14 +310,8 @@ r100CreateContext( gl_api api, - ctx->Extensions.NV_texture_rectangle = true; - ctx->Extensions.OES_EGL_image = true; - -- if (rmesa->radeon.glCtx.Mesa_DXTn) { -- ctx->Extensions.EXT_texture_compression_s3tc = true; -- ctx->Extensions.ANGLE_texture_compression_dxt = true; -- } -- else if (driQueryOptionb (&rmesa->radeon.optionCache, "force_s3tc_enable")) { -- ctx->Extensions.EXT_texture_compression_s3tc = true; -- ctx->Extensions.ANGLE_texture_compression_dxt = true; -- } -+ ctx->Extensions.EXT_texture_compression_s3tc = true; -+ ctx->Extensions.ANGLE_texture_compression_dxt = true; - - /* XXX these should really go right after _mesa_init_driver_functions() */ - radeon_fbo_init(&rmesa->radeon); -diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c -index 0f072aff20..4192283fee 100644 ---- a/src/mesa/drivers/dri/radeon/radeon_screen.c -+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c -@@ -86,7 +86,6 @@ DRI_CONF_BEGIN - DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB) - DRI_CONF_DEF_MAX_ANISOTROPY(1.0,"1.0,2.0,4.0,8.0,16.0") - DRI_CONF_NO_NEG_LOD_BIAS("false") -- DRI_CONF_FORCE_S3TC_ENABLE("false") - DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER) - DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC) - DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF) -@@ -113,7 +112,6 @@ DRI_CONF_BEGIN - DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB) - DRI_CONF_DEF_MAX_ANISOTROPY(1.0,"1.0,2.0,4.0,8.0,16.0") - DRI_CONF_NO_NEG_LOD_BIAS("false") -- DRI_CONF_FORCE_S3TC_ENABLE("false") - DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER) - DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC) - DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF) -diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c -index 3aabdc92bb..1a15016e7a 100644 ---- a/src/mesa/main/context.c -+++ b/src/mesa/main/context.c -@@ -861,8 +861,6 @@ init_attrib_groups(struct gl_context *ctx) - if (!_mesa_init_texture( ctx )) - return GL_FALSE; - -- _mesa_init_texture_s3tc( ctx ); -- - /* Miscellaneous */ - ctx->NewState = _NEW_ALL; - ctx->NewDriverState = ~0; -diff --git a/src/mesa/main/dlopen.h b/src/mesa/main/dlopen.h -deleted file mode 100644 -index 4d20ff2c7c..0000000000 ---- a/src/mesa/main/dlopen.h -+++ /dev/null -@@ -1,97 +0,0 @@ --/* -- * Mesa 3-D graphics library -- * -- * Copyright (C) 1999-2008 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 -- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -- * OTHER DEALINGS IN THE SOFTWARE. -- */ -- -- --#ifndef DLOPEN_H --#define DLOPEN_H -- --/** -- * Wrapper functions for dlopen(), dlsym(), dlclose(). -- * Note that the #ifdef tests for various environments should be expanded. -- */ -- --#if defined(HAVE_DLOPEN) --#include --#endif --#if defined(_WIN32) --#include --#endif -- --typedef void (*GenericFunc)(void); -- --/** -- * Wrapper for dlopen(). -- * Note that 'flags' isn't used at this time. -- */ --static inline void * --_mesa_dlopen(const char *libname, int flags) --{ --#if defined(HAVE_DLOPEN) -- flags = RTLD_LAZY | RTLD_GLOBAL; /* Overriding flags at this time */ -- return dlopen(libname, flags); --#elif defined(_WIN32) -- return LoadLibraryA(libname); --#else -- return NULL; --#endif --} -- --/** -- * Wrapper for dlsym() that does a cast to a generic function type, -- * rather than a void *. This reduces the number of warnings that are -- * generated. -- */ --static inline GenericFunc --_mesa_dlsym(void *handle, const char *fname) --{ -- union { -- void *v; -- GenericFunc f; -- } u; --#if defined(HAVE_DLOPEN) -- u.v = dlsym(handle, fname); --#elif defined(_WIN32) -- u.v = (void *) GetProcAddress(handle, fname); --#else -- u.v = NULL; --#endif -- return u.f; --} -- --/** -- * Wrapper for dlclose(). -- */ --static inline void --_mesa_dlclose(void *handle) --{ --#if defined(HAVE_DLOPEN) -- dlclose(handle); --#elif defined(_WIN32) -- FreeLibrary(handle); --#else -- (void) handle; --#endif --} -- --#endif -diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c -index 62a731675d..46083001d2 100644 ---- a/src/mesa/main/extensions.c -+++ b/src/mesa/main/extensions.c -@@ -176,10 +176,8 @@ _mesa_enable_sw_extensions(struct gl_context *ctx) - ctx->Extensions.EXT_gpu_program_parameters = GL_TRUE; - ctx->Extensions.OES_standard_derivatives = GL_TRUE; - ctx->Extensions.TDFX_texture_compression_FXT1 = GL_TRUE; -- if (ctx->Mesa_DXTn) { -- ctx->Extensions.ANGLE_texture_compression_dxt = GL_TRUE; -- ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE; -- } -+ ctx->Extensions.ANGLE_texture_compression_dxt = GL_TRUE; -+ ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE; - } - - /** -diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h -index 0cb002469b..f4641b9c68 100644 ---- a/src/mesa/main/mtypes.h -+++ b/src/mesa/main/mtypes.h -@@ -4958,9 +4958,6 @@ struct gl_context - */ - GLboolean HasConfig; - -- /** software compression/decompression supported or not */ -- GLboolean Mesa_DXTn; -- - GLboolean TextureFormatSupported[MESA_FORMAT_COUNT]; - - GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */ -diff --git a/src/mesa/main/texcompress_s3tc.c b/src/mesa/main/texcompress_s3tc.c -index 992ad058bf..1c6cbba892 100644 ---- a/src/mesa/main/texcompress_s3tc.c -+++ b/src/mesa/main/texcompress_s3tc.c -@@ -31,91 +31,17 @@ - - #include "glheader.h" - #include "imports.h" --#include "dlopen.h" - #include "image.h" - #include "macros.h" - #include "mtypes.h" - #include "texcompress.h" - #include "texcompress_s3tc.h" -+#include "texcompress_s3tc_tmp.h" - #include "texstore.h" - #include "format_unpack.h" - #include "util/format_srgb.h" - - --#if defined(_WIN32) || defined(WIN32) --#define DXTN_LIBNAME "dxtn.dll" --#define RTLD_LAZY 0 --#define RTLD_GLOBAL 0 --#elif defined(__CYGWIN__) --#define DXTN_LIBNAME "cygtxc_dxtn.dll" --#else --#define DXTN_LIBNAME "libtxc_dxtn.so" --#endif -- --typedef void (*dxtFetchTexelFuncExt)( GLint srcRowstride, const GLubyte *pixdata, GLint col, GLint row, GLvoid *texelOut ); -- --static dxtFetchTexelFuncExt fetch_ext_rgb_dxt1 = NULL; --static dxtFetchTexelFuncExt fetch_ext_rgba_dxt1 = NULL; --static dxtFetchTexelFuncExt fetch_ext_rgba_dxt3 = NULL; --static dxtFetchTexelFuncExt fetch_ext_rgba_dxt5 = NULL; -- --typedef void (*dxtCompressTexFuncExt)(GLint srccomps, GLint width, -- GLint height, const GLubyte *srcPixData, -- GLenum destformat, GLubyte *dest, -- GLint dstRowStride); -- --static dxtCompressTexFuncExt ext_tx_compress_dxtn = NULL; -- --static void *dxtlibhandle = NULL; -- -- --void --_mesa_init_texture_s3tc( struct gl_context *ctx ) --{ -- /* called during context initialization */ -- ctx->Mesa_DXTn = GL_FALSE; -- if (!dxtlibhandle) { -- dxtlibhandle = _mesa_dlopen(DXTN_LIBNAME, 0); -- if (!dxtlibhandle) { -- _mesa_warning(ctx, "couldn't open " DXTN_LIBNAME ", software DXTn " -- "compression/decompression unavailable"); -- } -- else { -- /* the fetch functions are not per context! Might be problematic... */ -- fetch_ext_rgb_dxt1 = (dxtFetchTexelFuncExt) -- _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgb_dxt1"); -- fetch_ext_rgba_dxt1 = (dxtFetchTexelFuncExt) -- _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt1"); -- fetch_ext_rgba_dxt3 = (dxtFetchTexelFuncExt) -- _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt3"); -- fetch_ext_rgba_dxt5 = (dxtFetchTexelFuncExt) -- _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt5"); -- ext_tx_compress_dxtn = (dxtCompressTexFuncExt) -- _mesa_dlsym(dxtlibhandle, "tx_compress_dxtn"); -- -- if (!fetch_ext_rgb_dxt1 || -- !fetch_ext_rgba_dxt1 || -- !fetch_ext_rgba_dxt3 || -- !fetch_ext_rgba_dxt5 || -- !ext_tx_compress_dxtn) { -- _mesa_warning(ctx, "couldn't reference all symbols in " -- DXTN_LIBNAME ", software DXTn compression/decompression " -- "unavailable"); -- fetch_ext_rgb_dxt1 = NULL; -- fetch_ext_rgba_dxt1 = NULL; -- fetch_ext_rgba_dxt3 = NULL; -- fetch_ext_rgba_dxt5 = NULL; -- ext_tx_compress_dxtn = NULL; -- _mesa_dlclose(dxtlibhandle); -- dxtlibhandle = NULL; -- } -- } -- } -- if (dxtlibhandle) { -- ctx->Mesa_DXTn = GL_TRUE; -- } --} -- - /** - * Store user's image in rgb_dxt1 format. - */ -@@ -158,14 +84,9 @@ _mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS) - - dst = dstSlices[0]; - -- if (ext_tx_compress_dxtn) { -- (*ext_tx_compress_dxtn)(3, srcWidth, srcHeight, pixels, -- GL_COMPRESSED_RGB_S3TC_DXT1_EXT, -- dst, dstRowStride); -- } -- else { -- _mesa_warning(ctx, "external dxt library not available: texstore_rgb_dxt1"); -- } -+ tx_compress_dxtn(3, srcWidth, srcHeight, pixels, -+ GL_COMPRESSED_RGB_S3TC_DXT1_EXT, -+ dst, dstRowStride); - - free((void *) tempImage); - -@@ -216,14 +137,9 @@ _mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS) - - dst = dstSlices[0]; - -- if (ext_tx_compress_dxtn) { -- (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, -- GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, -- dst, dstRowStride); -- } -- else { -- _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt1"); -- } -+ tx_compress_dxtn(4, srcWidth, srcHeight, pixels, -+ GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, -+ dst, dstRowStride); - - free((void*) tempImage); - -@@ -273,14 +189,9 @@ _mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS) - - dst = dstSlices[0]; - -- if (ext_tx_compress_dxtn) { -- (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, -- GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, -- dst, dstRowStride); -- } -- else { -- _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt3"); -- } -+ tx_compress_dxtn(4, srcWidth, srcHeight, pixels, -+ GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, -+ dst, dstRowStride); - - free((void *) tempImage); - -@@ -330,14 +241,9 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS) - - dst = dstSlices[0]; - -- if (ext_tx_compress_dxtn) { -- (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, -- GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, -- dst, dstRowStride); -- } -- else { -- _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt5"); -- } -+ tx_compress_dxtn(4, srcWidth, srcHeight, pixels, -+ GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, -+ dst, dstRowStride); - - free((void *) tempImage); - -@@ -345,85 +251,52 @@ _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS) - } - - --/** Report problem with dxt texture decompression, once */ --static void --problem(const char *func) --{ -- static GLboolean warned = GL_FALSE; -- if (!warned) { -- _mesa_debug(NULL, "attempted to decode DXT texture without " -- "library available: %s\n", func); -- warned = GL_TRUE; -- } --} -- -- - static void - fetch_rgb_dxt1(const GLubyte *map, - GLint rowStride, GLint i, GLint j, GLfloat *texel) - { -- if (fetch_ext_rgb_dxt1) { -- GLubyte tex[4]; -- fetch_ext_rgb_dxt1(rowStride, map, i, j, tex); -- texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]); -- texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]); -- texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]); -- texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]); -- } -- else { -- problem("rgb_dxt1"); -- } -+ GLubyte tex[4]; -+ fetch_2d_texel_rgb_dxt1(rowStride, map, i, j, tex); -+ texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]); -+ texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]); -+ texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]); -+ texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]); - } - - static void - fetch_rgba_dxt1(const GLubyte *map, - GLint rowStride, GLint i, GLint j, GLfloat *texel) - { -- if (fetch_ext_rgba_dxt1) { -- GLubyte tex[4]; -- fetch_ext_rgba_dxt1(rowStride, map, i, j, tex); -- texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]); -- texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]); -- texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]); -- texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]); -- } -- else { -- problem("rgba_dxt1"); -- } -+ GLubyte tex[4]; -+ fetch_2d_texel_rgba_dxt1(rowStride, map, i, j, tex); -+ texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]); -+ texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]); -+ texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]); -+ texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]); - } - - static void - fetch_rgba_dxt3(const GLubyte *map, - GLint rowStride, GLint i, GLint j, GLfloat *texel) - { -- if (fetch_ext_rgba_dxt3) { -- GLubyte tex[4]; -- fetch_ext_rgba_dxt3(rowStride, map, i, j, tex); -- texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]); -- texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]); -- texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]); -- texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]); -- } -- else { -- problem("rgba_dxt3"); -- } -+ GLubyte tex[4]; -+ fetch_2d_texel_rgba_dxt3(rowStride, map, i, j, tex); -+ texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]); -+ texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]); -+ texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]); -+ texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]); - } - - static void - fetch_rgba_dxt5(const GLubyte *map, - GLint rowStride, GLint i, GLint j, GLfloat *texel) - { -- if (fetch_ext_rgba_dxt5) { -- GLubyte tex[4]; -- fetch_ext_rgba_dxt5(rowStride, map, i, j, tex); -- texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]); -- texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]); -- texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]); -- texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]); -- } -- else { -- problem("rgba_dxt5"); -- } -+ GLubyte tex[4]; -+ fetch_2d_texel_rgba_dxt5(rowStride, map, i, j, tex); -+ texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]); -+ texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]); -+ texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]); -+ texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]); - } - - -@@ -431,68 +304,48 @@ static void - fetch_srgb_dxt1(const GLubyte *map, - GLint rowStride, GLint i, GLint j, GLfloat *texel) - { -- if (fetch_ext_rgb_dxt1) { -- GLubyte tex[4]; -- fetch_ext_rgb_dxt1(rowStride, map, i, j, tex); -- texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(tex[RCOMP]); -- texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(tex[GCOMP]); -- texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(tex[BCOMP]); -- texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]); -- } -- else { -- problem("srgb_dxt1"); -- } -+ GLubyte tex[4]; -+ fetch_2d_texel_rgb_dxt1(rowStride, map, i, j, tex); -+ texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(tex[RCOMP]); -+ texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(tex[GCOMP]); -+ texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(tex[BCOMP]); -+ texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]); - } - - static void - fetch_srgba_dxt1(const GLubyte *map, - GLint rowStride, GLint i, GLint j, GLfloat *texel) - { -- if (fetch_ext_rgba_dxt1) { -- GLubyte tex[4]; -- fetch_ext_rgba_dxt1(rowStride, map, i, j, tex); -- texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(tex[RCOMP]); -- texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(tex[GCOMP]); -- texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(tex[BCOMP]); -- texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]); -- } -- else { -- problem("srgba_dxt1"); -- } -+ GLubyte tex[4]; -+ fetch_2d_texel_rgba_dxt1(rowStride, map, i, j, tex); -+ texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(tex[RCOMP]); -+ texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(tex[GCOMP]); -+ texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(tex[BCOMP]); -+ texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]); - } - - static void - fetch_srgba_dxt3(const GLubyte *map, - GLint rowStride, GLint i, GLint j, GLfloat *texel) - { -- if (fetch_ext_rgba_dxt3) { -- GLubyte tex[4]; -- fetch_ext_rgba_dxt3(rowStride, map, i, j, tex); -- texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(tex[RCOMP]); -- texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(tex[GCOMP]); -- texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(tex[BCOMP]); -- texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]); -- } -- else { -- problem("srgba_dxt3"); -- } -+ GLubyte tex[4]; -+ fetch_2d_texel_rgba_dxt3(rowStride, map, i, j, tex); -+ texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(tex[RCOMP]); -+ texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(tex[GCOMP]); -+ texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(tex[BCOMP]); -+ texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]); - } - - static void - fetch_srgba_dxt5(const GLubyte *map, - GLint rowStride, GLint i, GLint j, GLfloat *texel) - { -- if (fetch_ext_rgba_dxt5) { -- GLubyte tex[4]; -- fetch_ext_rgba_dxt5(rowStride, map, i, j, tex); -- texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(tex[RCOMP]); -- texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(tex[GCOMP]); -- texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(tex[BCOMP]); -- texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]); -- } -- else { -- problem("srgba_dxt5"); -- } -+ GLubyte tex[4]; -+ fetch_2d_texel_rgba_dxt5(rowStride, map, i, j, tex); -+ texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(tex[RCOMP]); -+ texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(tex[GCOMP]); -+ texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(tex[BCOMP]); -+ texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]); - } - - -diff --git a/src/mesa/main/texcompress_s3tc.h b/src/mesa/main/texcompress_s3tc.h -index 438b71fe33..0dbb5fc537 100644 ---- a/src/mesa/main/texcompress_s3tc.h -+++ b/src/mesa/main/texcompress_s3tc.h -@@ -44,9 +44,6 @@ extern GLboolean - _mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS); - - --extern void --_mesa_init_texture_s3tc(struct gl_context *ctx); -- - extern compressed_fetch_func - _mesa_get_dxt_fetch_func(mesa_format format); - -diff --git a/src/mesa/main/texcompress_s3tc_tmp.h b/src/mesa/main/texcompress_s3tc_tmp.h -new file mode 100644 -index 0000000000..61630f2475 ---- /dev/null -+++ b/src/mesa/main/texcompress_s3tc_tmp.h -@@ -0,0 +1,989 @@ -+/* -+ * libtxc_dxtn -+ * Version: 1.0 -+ * -+ * Copyright (C) 2004 Roland Scheidegger 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. -+ */ -+ -+#ifdef __APPLE__ -+#include -+#else -+#include -+#endif -+ -+typedef GLubyte GLchan; -+#define UBYTE_TO_CHAN(b) (b) -+#define CHAN_MAX 255 -+#define RCOMP 0 -+#define GCOMP 1 -+#define BCOMP 2 -+#define ACOMP 3 -+ -+#define EXP5TO8R(packedcol) \ -+ ((((packedcol) >> 8) & 0xf8) | (((packedcol) >> 13) & 0x7)) -+ -+#define EXP6TO8G(packedcol) \ -+ ((((packedcol) >> 3) & 0xfc) | (((packedcol) >> 9) & 0x3)) -+ -+#define EXP5TO8B(packedcol) \ -+ ((((packedcol) << 3) & 0xf8) | (((packedcol) >> 2) & 0x7)) -+ -+#define EXP4TO8(col) \ -+ ((col) | ((col) << 4)) -+ -+/* inefficient. To be efficient, it would be necessary to decode 16 pixels at once */ -+ -+static void dxt135_decode_imageblock ( const GLubyte *img_block_src, -+ GLint i, GLint j, GLuint dxt_type, GLvoid *texel ) { -+ GLchan *rgba = (GLchan *) texel; -+ const GLushort color0 = img_block_src[0] | (img_block_src[1] << 8); -+ const GLushort color1 = img_block_src[2] | (img_block_src[3] << 8); -+ const GLuint bits = img_block_src[4] | (img_block_src[5] << 8) | -+ (img_block_src[6] << 16) | (img_block_src[7] << 24); -+ /* What about big/little endian? */ -+ GLubyte bit_pos = 2 * (j * 4 + i) ; -+ GLubyte code = (GLubyte) ((bits >> bit_pos) & 3); -+ -+ rgba[ACOMP] = CHAN_MAX; -+ switch (code) { -+ case 0: -+ rgba[RCOMP] = UBYTE_TO_CHAN( EXP5TO8R(color0) ); -+ rgba[GCOMP] = UBYTE_TO_CHAN( EXP6TO8G(color0) ); -+ rgba[BCOMP] = UBYTE_TO_CHAN( EXP5TO8B(color0) ); -+ break; -+ case 1: -+ rgba[RCOMP] = UBYTE_TO_CHAN( EXP5TO8R(color1) ); -+ rgba[GCOMP] = UBYTE_TO_CHAN( EXP6TO8G(color1) ); -+ rgba[BCOMP] = UBYTE_TO_CHAN( EXP5TO8B(color1) ); -+ break; -+ case 2: -+ if ((dxt_type > 1) || (color0 > color1)) { -+ rgba[RCOMP] = UBYTE_TO_CHAN( ((EXP5TO8R(color0) * 2 + EXP5TO8R(color1)) / 3) ); -+ rgba[GCOMP] = UBYTE_TO_CHAN( ((EXP6TO8G(color0) * 2 + EXP6TO8G(color1)) / 3) ); -+ rgba[BCOMP] = UBYTE_TO_CHAN( ((EXP5TO8B(color0) * 2 + EXP5TO8B(color1)) / 3) ); -+ } -+ else { -+ rgba[RCOMP] = UBYTE_TO_CHAN( ((EXP5TO8R(color0) + EXP5TO8R(color1)) / 2) ); -+ rgba[GCOMP] = UBYTE_TO_CHAN( ((EXP6TO8G(color0) + EXP6TO8G(color1)) / 2) ); -+ rgba[BCOMP] = UBYTE_TO_CHAN( ((EXP5TO8B(color0) + EXP5TO8B(color1)) / 2) ); -+ } -+ break; -+ case 3: -+ if ((dxt_type > 1) || (color0 > color1)) { -+ rgba[RCOMP] = UBYTE_TO_CHAN( ((EXP5TO8R(color0) + EXP5TO8R(color1) * 2) / 3) ); -+ rgba[GCOMP] = UBYTE_TO_CHAN( ((EXP6TO8G(color0) + EXP6TO8G(color1) * 2) / 3) ); -+ rgba[BCOMP] = UBYTE_TO_CHAN( ((EXP5TO8B(color0) + EXP5TO8B(color1) * 2) / 3) ); -+ } -+ else { -+ rgba[RCOMP] = 0; -+ rgba[GCOMP] = 0; -+ rgba[BCOMP] = 0; -+ if (dxt_type == 1) rgba[ACOMP] = UBYTE_TO_CHAN(0); -+ } -+ break; -+ default: -+ /* CANNOT happen (I hope) */ -+ break; -+ } -+} -+ -+ -+static void fetch_2d_texel_rgb_dxt1(GLint srcRowStride, const GLubyte *pixdata, -+ GLint i, GLint j, GLvoid *texel) -+{ -+ /* Extract the (i,j) pixel from pixdata and return it -+ * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. -+ */ -+ -+ const GLubyte *blksrc = (pixdata + ((srcRowStride + 3) / 4 * (j / 4) + (i / 4)) * 8); -+ dxt135_decode_imageblock(blksrc, (i&3), (j&3), 0, texel); -+} -+ -+ -+static void fetch_2d_texel_rgba_dxt1(GLint srcRowStride, const GLubyte *pixdata, -+ GLint i, GLint j, GLvoid *texel) -+{ -+ /* Extract the (i,j) pixel from pixdata and return it -+ * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. -+ */ -+ -+ const GLubyte *blksrc = (pixdata + ((srcRowStride + 3) / 4 * (j / 4) + (i / 4)) * 8); -+ dxt135_decode_imageblock(blksrc, (i&3), (j&3), 1, texel); -+} -+ -+static void fetch_2d_texel_rgba_dxt3(GLint srcRowStride, const GLubyte *pixdata, -+ GLint i, GLint j, GLvoid *texel) { -+ -+ /* Extract the (i,j) pixel from pixdata and return it -+ * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. -+ */ -+ -+ GLchan *rgba = (GLchan *) texel; -+ const GLubyte *blksrc = (pixdata + ((srcRowStride + 3) / 4 * (j / 4) + (i / 4)) * 16); -+ const GLubyte anibble = (blksrc[((j&3) * 4 + (i&3)) / 2] >> (4 * (i&1))) & 0xf; -+ dxt135_decode_imageblock(blksrc + 8, (i&3), (j&3), 2, texel); -+ rgba[ACOMP] = UBYTE_TO_CHAN( (GLubyte)(EXP4TO8(anibble)) ); -+} -+ -+static void fetch_2d_texel_rgba_dxt5(GLint srcRowStride, const GLubyte *pixdata, -+ GLint i, GLint j, GLvoid *texel) { -+ -+ /* Extract the (i,j) pixel from pixdata and return it -+ * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP]. -+ */ -+ -+ GLchan *rgba = (GLchan *) texel; -+ const GLubyte *blksrc = (pixdata + ((srcRowStride + 3) / 4 * (j / 4) + (i / 4)) * 16); -+ const GLubyte alpha0 = blksrc[0]; -+ const GLubyte alpha1 = blksrc[1]; -+ const GLubyte bit_pos = ((j&3) * 4 + (i&3)) * 3; -+ const GLubyte acodelow = blksrc[2 + bit_pos / 8]; -+ const GLubyte acodehigh = blksrc[3 + bit_pos / 8]; -+ const GLubyte code = (acodelow >> (bit_pos & 0x7) | -+ (acodehigh << (8 - (bit_pos & 0x7)))) & 0x7; -+ dxt135_decode_imageblock(blksrc + 8, (i&3), (j&3), 2, texel); -+ if (code == 0) -+ rgba[ACOMP] = UBYTE_TO_CHAN( alpha0 ); -+ else if (code == 1) -+ rgba[ACOMP] = UBYTE_TO_CHAN( alpha1 ); -+ else if (alpha0 > alpha1) -+ rgba[ACOMP] = UBYTE_TO_CHAN( ((alpha0 * (8 - code) + (alpha1 * (code - 1))) / 7) ); -+ else if (code < 6) -+ rgba[ACOMP] = UBYTE_TO_CHAN( ((alpha0 * (6 - code) + (alpha1 * (code - 1))) / 5) ); -+ else if (code == 6) -+ rgba[ACOMP] = 0; -+ else -+ rgba[ACOMP] = CHAN_MAX; -+} -+ -+ -+/* weights used for error function, basically weights (unsquared 2/4/1) according to rgb->luminance conversion -+ not sure if this really reflects visual perception */ -+#define REDWEIGHT 4 -+#define GREENWEIGHT 16 -+#define BLUEWEIGHT 1 -+ -+#define ALPHACUT 127 -+ -+static void fancybasecolorsearch( GLubyte *blkaddr, GLubyte srccolors[4][4][4], GLubyte *bestcolor[2], -+ GLint numxpixels, GLint numypixels, GLint type, GLboolean haveAlpha) -+{ -+ /* use same luminance-weighted distance metric to determine encoding as for finding the base colors */ -+ -+ /* TODO could also try to find a better encoding for the 3-color-encoding type, this really should be done -+ if it's rgba_dxt1 and we have alpha in the block, currently even values which will be mapped to black -+ due to their alpha value will influence the result */ -+ GLint i, j, colors, z; -+ GLuint pixerror, pixerrorred, pixerrorgreen, pixerrorblue, pixerrorbest; -+ GLint colordist, blockerrlin[2][3]; -+ GLubyte nrcolor[2]; -+ GLint pixerrorcolorbest[3]; -+ GLubyte enc = 0; -+ GLubyte cv[4][4]; -+ GLubyte testcolor[2][3]; -+ -+/* fprintf(stderr, "color begin 0 r/g/b %d/%d/%d, 1 r/g/b %d/%d/%d\n", -+ bestcolor[0][0], bestcolor[0][1], bestcolor[0][2], bestcolor[1][0], bestcolor[1][1], bestcolor[1][2]);*/ -+ if (((bestcolor[0][0] & 0xf8) << 8 | (bestcolor[0][1] & 0xfc) << 3 | bestcolor[0][2] >> 3) < -+ ((bestcolor[1][0] & 0xf8) << 8 | (bestcolor[1][1] & 0xfc) << 3 | bestcolor[1][2] >> 3)) { -+ testcolor[0][0] = bestcolor[0][0]; -+ testcolor[0][1] = bestcolor[0][1]; -+ testcolor[0][2] = bestcolor[0][2]; -+ testcolor[1][0] = bestcolor[1][0]; -+ testcolor[1][1] = bestcolor[1][1]; -+ testcolor[1][2] = bestcolor[1][2]; -+ } -+ else { -+ testcolor[1][0] = bestcolor[0][0]; -+ testcolor[1][1] = bestcolor[0][1]; -+ testcolor[1][2] = bestcolor[0][2]; -+ testcolor[0][0] = bestcolor[1][0]; -+ testcolor[0][1] = bestcolor[1][1]; -+ testcolor[0][2] = bestcolor[1][2]; -+ } -+ -+ for (i = 0; i < 3; i ++) { -+ cv[0][i] = testcolor[0][i]; -+ cv[1][i] = testcolor[1][i]; -+ cv[2][i] = (testcolor[0][i] * 2 + testcolor[1][i]) / 3; -+ cv[3][i] = (testcolor[0][i] + testcolor[1][i] * 2) / 3; -+ } -+ -+ blockerrlin[0][0] = 0; -+ blockerrlin[0][1] = 0; -+ blockerrlin[0][2] = 0; -+ blockerrlin[1][0] = 0; -+ blockerrlin[1][1] = 0; -+ blockerrlin[1][2] = 0; -+ -+ nrcolor[0] = 0; -+ nrcolor[1] = 0; -+ -+ for (j = 0; j < numypixels; j++) { -+ for (i = 0; i < numxpixels; i++) { -+ pixerrorbest = 0xffffffff; -+ for (colors = 0; colors < 4; colors++) { -+ colordist = srccolors[j][i][0] - (cv[colors][0]); -+ pixerror = colordist * colordist * REDWEIGHT; -+ pixerrorred = colordist; -+ colordist = srccolors[j][i][1] - (cv[colors][1]); -+ pixerror += colordist * colordist * GREENWEIGHT; -+ pixerrorgreen = colordist; -+ colordist = srccolors[j][i][2] - (cv[colors][2]); -+ pixerror += colordist * colordist * BLUEWEIGHT; -+ pixerrorblue = colordist; -+ if (pixerror < pixerrorbest) { -+ enc = colors; -+ pixerrorbest = pixerror; -+ pixerrorcolorbest[0] = pixerrorred; -+ pixerrorcolorbest[1] = pixerrorgreen; -+ pixerrorcolorbest[2] = pixerrorblue; -+ } -+ } -+ if (enc == 0) { -+ for (z = 0; z < 3; z++) { -+ blockerrlin[0][z] += 3 * pixerrorcolorbest[z]; -+ } -+ nrcolor[0] += 3; -+ } -+ else if (enc == 2) { -+ for (z = 0; z < 3; z++) { -+ blockerrlin[0][z] += 2 * pixerrorcolorbest[z]; -+ } -+ nrcolor[0] += 2; -+ for (z = 0; z < 3; z++) { -+ blockerrlin[1][z] += 1 * pixerrorcolorbest[z]; -+ } -+ nrcolor[1] += 1; -+ } -+ else if (enc == 3) { -+ for (z = 0; z < 3; z++) { -+ blockerrlin[0][z] += 1 * pixerrorcolorbest[z]; -+ } -+ nrcolor[0] += 1; -+ for (z = 0; z < 3; z++) { -+ blockerrlin[1][z] += 2 * pixerrorcolorbest[z]; -+ } -+ nrcolor[1] += 2; -+ } -+ else if (enc == 1) { -+ for (z = 0; z < 3; z++) { -+ blockerrlin[1][z] += 3 * pixerrorcolorbest[z]; -+ } -+ nrcolor[1] += 3; -+ } -+ } -+ } -+ if (nrcolor[0] == 0) nrcolor[0] = 1; -+ if (nrcolor[1] == 0) nrcolor[1] = 1; -+ for (j = 0; j < 2; j++) { -+ for (i = 0; i < 3; i++) { -+ GLint newvalue = testcolor[j][i] + blockerrlin[j][i] / nrcolor[j]; -+ if (newvalue <= 0) -+ testcolor[j][i] = 0; -+ else if (newvalue >= 255) -+ testcolor[j][i] = 255; -+ else testcolor[j][i] = newvalue; -+ } -+ } -+ -+ if ((abs(testcolor[0][0] - testcolor[1][0]) < 8) && -+ (abs(testcolor[0][1] - testcolor[1][1]) < 4) && -+ (abs(testcolor[0][2] - testcolor[1][2]) < 8)) { -+ /* both colors are so close they might get encoded as the same 16bit values */ -+ GLubyte coldiffred, coldiffgreen, coldiffblue, coldiffmax, factor, ind0, ind1; -+ -+ coldiffred = abs(testcolor[0][0] - testcolor[1][0]); -+ coldiffgreen = 2 * abs(testcolor[0][1] - testcolor[1][1]); -+ coldiffblue = abs(testcolor[0][2] - testcolor[1][2]); -+ coldiffmax = coldiffred; -+ if (coldiffmax < coldiffgreen) coldiffmax = coldiffgreen; -+ if (coldiffmax < coldiffblue) coldiffmax = coldiffblue; -+ if (coldiffmax > 0) { -+ if (coldiffmax > 4) factor = 2; -+ else if (coldiffmax > 2) factor = 3; -+ else factor = 4; -+ /* Won't do much if the color value is near 255... */ -+ /* argh so many ifs */ -+ if (testcolor[1][1] >= testcolor[0][1]) { -+ ind1 = 1; ind0 = 0; -+ } -+ else { -+ ind1 = 0; ind0 = 1; -+ } -+ if ((testcolor[ind1][1] + factor * coldiffgreen) <= 255) -+ testcolor[ind1][1] += factor * coldiffgreen; -+ else testcolor[ind1][1] = 255; -+ if ((testcolor[ind1][0] - testcolor[ind0][1]) > 0) { -+ if ((testcolor[ind1][0] + factor * coldiffred) <= 255) -+ testcolor[ind1][0] += factor * coldiffred; -+ else testcolor[ind1][0] = 255; -+ } -+ else { -+ if ((testcolor[ind0][0] + factor * coldiffred) <= 255) -+ testcolor[ind0][0] += factor * coldiffred; -+ else testcolor[ind0][0] = 255; -+ } -+ if ((testcolor[ind1][2] - testcolor[ind0][2]) > 0) { -+ if ((testcolor[ind1][2] + factor * coldiffblue) <= 255) -+ testcolor[ind1][2] += factor * coldiffblue; -+ else testcolor[ind1][2] = 255; -+ } -+ else { -+ if ((testcolor[ind0][2] + factor * coldiffblue) <= 255) -+ testcolor[ind0][2] += factor * coldiffblue; -+ else testcolor[ind0][2] = 255; -+ } -+ } -+ } -+ -+ if (((testcolor[0][0] & 0xf8) << 8 | (testcolor[0][1] & 0xfc) << 3 | testcolor[0][2] >> 3) < -+ ((testcolor[1][0] & 0xf8) << 8 | (testcolor[1][1] & 0xfc) << 3 | testcolor[1][2]) >> 3) { -+ for (i = 0; i < 3; i++) { -+ bestcolor[0][i] = testcolor[0][i]; -+ bestcolor[1][i] = testcolor[1][i]; -+ } -+ } -+ else { -+ for (i = 0; i < 3; i++) { -+ bestcolor[0][i] = testcolor[1][i]; -+ bestcolor[1][i] = testcolor[0][i]; -+ } -+ } -+ -+/* fprintf(stderr, "color end 0 r/g/b %d/%d/%d, 1 r/g/b %d/%d/%d\n", -+ bestcolor[0][0], bestcolor[0][1], bestcolor[0][2], bestcolor[1][0], bestcolor[1][1], bestcolor[1][2]);*/ -+} -+ -+ -+ -+static void storedxtencodedblock( GLubyte *blkaddr, GLubyte srccolors[4][4][4], GLubyte *bestcolor[2], -+ GLint numxpixels, GLint numypixels, GLuint type, GLboolean haveAlpha) -+{ -+ /* use same luminance-weighted distance metric to determine encoding as for finding the base colors */ -+ -+ GLint i, j, colors; -+ GLuint testerror, testerror2, pixerror, pixerrorbest; -+ GLint colordist; -+ GLushort color0, color1, tempcolor; -+ GLuint bits = 0, bits2 = 0; -+ GLubyte *colorptr; -+ GLubyte enc = 0; -+ GLubyte cv[4][4]; -+ -+ bestcolor[0][0] = bestcolor[0][0] & 0xf8; -+ bestcolor[0][1] = bestcolor[0][1] & 0xfc; -+ bestcolor[0][2] = bestcolor[0][2] & 0xf8; -+ bestcolor[1][0] = bestcolor[1][0] & 0xf8; -+ bestcolor[1][1] = bestcolor[1][1] & 0xfc; -+ bestcolor[1][2] = bestcolor[1][2] & 0xf8; -+ -+ color0 = bestcolor[0][0] << 8 | bestcolor[0][1] << 3 | bestcolor[0][2] >> 3; -+ color1 = bestcolor[1][0] << 8 | bestcolor[1][1] << 3 | bestcolor[1][2] >> 3; -+ if (color0 < color1) { -+ tempcolor = color0; color0 = color1; color1 = tempcolor; -+ colorptr = bestcolor[0]; bestcolor[0] = bestcolor[1]; bestcolor[1] = colorptr; -+ } -+ -+ -+ for (i = 0; i < 3; i++) { -+ cv[0][i] = bestcolor[0][i]; -+ cv[1][i] = bestcolor[1][i]; -+ cv[2][i] = (bestcolor[0][i] * 2 + bestcolor[1][i]) / 3; -+ cv[3][i] = (bestcolor[0][i] + bestcolor[1][i] * 2) / 3; -+ } -+ -+ testerror = 0; -+ for (j = 0; j < numypixels; j++) { -+ for (i = 0; i < numxpixels; i++) { -+ pixerrorbest = 0xffffffff; -+ for (colors = 0; colors < 4; colors++) { -+ colordist = srccolors[j][i][0] - cv[colors][0]; -+ pixerror = colordist * colordist * REDWEIGHT; -+ colordist = srccolors[j][i][1] - cv[colors][1]; -+ pixerror += colordist * colordist * GREENWEIGHT; -+ colordist = srccolors[j][i][2] - cv[colors][2]; -+ pixerror += colordist * colordist * BLUEWEIGHT; -+ if (pixerror < pixerrorbest) { -+ pixerrorbest = pixerror; -+ enc = colors; -+ } -+ } -+ testerror += pixerrorbest; -+ bits |= enc << (2 * (j * 4 + i)); -+ } -+ } -+ /* some hw might disagree but actually decoding should always use 4-color encoding -+ for non-dxt1 formats */ -+ if (type == GL_COMPRESSED_RGB_S3TC_DXT1_EXT || type == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) { -+ for (i = 0; i < 3; i++) { -+ cv[2][i] = (bestcolor[0][i] + bestcolor[1][i]) / 2; -+ /* this isn't used. Looks like the black color constant can only be used -+ with RGB_DXT1 if I read the spec correctly (note though that the radeon gpu disagrees, -+ it will decode 3 to black even with DXT3/5), and due to how the color searching works -+ it won't get used even then */ -+ cv[3][i] = 0; -+ } -+ testerror2 = 0; -+ for (j = 0; j < numypixels; j++) { -+ for (i = 0; i < numxpixels; i++) { -+ pixerrorbest = 0xffffffff; -+ if ((type == GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) && (srccolors[j][i][3] <= ALPHACUT)) { -+ enc = 3; -+ pixerrorbest = 0; /* don't calculate error */ -+ } -+ else { -+ /* we're calculating the same what we have done already for colors 0-1 above... */ -+ for (colors = 0; colors < 3; colors++) { -+ colordist = srccolors[j][i][0] - cv[colors][0]; -+ pixerror = colordist * colordist * REDWEIGHT; -+ colordist = srccolors[j][i][1] - cv[colors][1]; -+ pixerror += colordist * colordist * GREENWEIGHT; -+ colordist = srccolors[j][i][2] - cv[colors][2]; -+ pixerror += colordist * colordist * BLUEWEIGHT; -+ if (pixerror < pixerrorbest) { -+ pixerrorbest = pixerror; -+ /* need to exchange colors later */ -+ if (colors > 1) enc = colors; -+ else enc = colors ^ 1; -+ } -+ } -+ } -+ testerror2 += pixerrorbest; -+ bits2 |= enc << (2 * (j * 4 + i)); -+ } -+ } -+ } else { -+ testerror2 = 0xffffffff; -+ } -+ -+ /* finally we're finished, write back colors and bits */ -+ if ((testerror > testerror2) || (haveAlpha)) { -+ *blkaddr++ = color1 & 0xff; -+ *blkaddr++ = color1 >> 8; -+ *blkaddr++ = color0 & 0xff; -+ *blkaddr++ = color0 >> 8; -+ *blkaddr++ = bits2 & 0xff; -+ *blkaddr++ = ( bits2 >> 8) & 0xff; -+ *blkaddr++ = ( bits2 >> 16) & 0xff; -+ *blkaddr = bits2 >> 24; -+ } -+ else { -+ *blkaddr++ = color0 & 0xff; -+ *blkaddr++ = color0 >> 8; -+ *blkaddr++ = color1 & 0xff; -+ *blkaddr++ = color1 >> 8; -+ *blkaddr++ = bits & 0xff; -+ *blkaddr++ = ( bits >> 8) & 0xff; -+ *blkaddr++ = ( bits >> 16) & 0xff; -+ *blkaddr = bits >> 24; -+ } -+} -+ -+static void encodedxtcolorblockfaster( GLubyte *blkaddr, GLubyte srccolors[4][4][4], -+ GLint numxpixels, GLint numypixels, GLuint type ) -+{ -+/* simplistic approach. We need two base colors, simply use the "highest" and the "lowest" color -+ present in the picture as base colors */ -+ -+ /* define lowest and highest color as shortest and longest vector to 0/0/0, though the -+ vectors are weighted similar to their importance in rgb-luminance conversion -+ doesn't work too well though... -+ This seems to be a rather difficult problem */ -+ -+ GLubyte *bestcolor[2]; -+ GLubyte basecolors[2][3]; -+ GLubyte i, j; -+ GLuint lowcv, highcv, testcv; -+ GLboolean haveAlpha = GL_FALSE; -+ -+ lowcv = highcv = srccolors[0][0][0] * srccolors[0][0][0] * REDWEIGHT + -+ srccolors[0][0][1] * srccolors[0][0][1] * GREENWEIGHT + -+ srccolors[0][0][2] * srccolors[0][0][2] * BLUEWEIGHT; -+ bestcolor[0] = bestcolor[1] = srccolors[0][0]; -+ for (j = 0; j < numypixels; j++) { -+ for (i = 0; i < numxpixels; i++) { -+ /* don't use this as a base color if the pixel will get black/transparent anyway */ -+ if ((type != GL_COMPRESSED_RGBA_S3TC_DXT1_EXT) || (srccolors[j][i][3] > ALPHACUT)) { -+ testcv = srccolors[j][i][0] * srccolors[j][i][0] * REDWEIGHT + -+ srccolors[j][i][1] * srccolors[j][i][1] * GREENWEIGHT + -+ srccolors[j][i][2] * srccolors[j][i][2] * BLUEWEIGHT; -+ if (testcv > highcv) { -+ highcv = testcv; -+ bestcolor[1] = srccolors[j][i]; -+ } -+ else if (testcv < lowcv) { -+ lowcv = testcv; -+ bestcolor[0] = srccolors[j][i]; -+ } -+ } -+ else haveAlpha = GL_TRUE; -+ } -+ } -+ /* make sure the original color values won't get touched... */ -+ for (j = 0; j < 2; j++) { -+ for (i = 0; i < 3; i++) { -+ basecolors[j][i] = bestcolor[j][i]; -+ } -+ } -+ bestcolor[0] = basecolors[0]; -+ bestcolor[1] = basecolors[1]; -+ -+ /* try to find better base colors */ -+ fancybasecolorsearch(blkaddr, srccolors, bestcolor, numxpixels, numypixels, type, haveAlpha); -+ /* find the best encoding for these colors, and store the result */ -+ storedxtencodedblock(blkaddr, srccolors, bestcolor, numxpixels, numypixels, type, haveAlpha); -+} -+ -+static void writedxt5encodedalphablock( GLubyte *blkaddr, GLubyte alphabase1, GLubyte alphabase2, -+ GLubyte alphaenc[16]) -+{ -+ *blkaddr++ = alphabase1; -+ *blkaddr++ = alphabase2; -+ *blkaddr++ = alphaenc[0] | (alphaenc[1] << 3) | ((alphaenc[2] & 3) << 6); -+ *blkaddr++ = (alphaenc[2] >> 2) | (alphaenc[3] << 1) | (alphaenc[4] << 4) | ((alphaenc[5] & 1) << 7); -+ *blkaddr++ = (alphaenc[5] >> 1) | (alphaenc[6] << 2) | (alphaenc[7] << 5); -+ *blkaddr++ = alphaenc[8] | (alphaenc[9] << 3) | ((alphaenc[10] & 3) << 6); -+ *blkaddr++ = (alphaenc[10] >> 2) | (alphaenc[11] << 1) | (alphaenc[12] << 4) | ((alphaenc[13] & 1) << 7); -+ *blkaddr++ = (alphaenc[13] >> 1) | (alphaenc[14] << 2) | (alphaenc[15] << 5); -+} -+ -+static void encodedxt5alpha(GLubyte *blkaddr, GLubyte srccolors[4][4][4], -+ GLint numxpixels, GLint numypixels) -+{ -+ GLubyte alphabase[2], alphause[2]; -+ GLshort alphatest[2]; -+ GLuint alphablockerror1, alphablockerror2, alphablockerror3; -+ GLubyte i, j, aindex, acutValues[7]; -+ GLubyte alphaenc1[16], alphaenc2[16], alphaenc3[16]; -+ GLboolean alphaabsmin = GL_FALSE; -+ GLboolean alphaabsmax = GL_FALSE; -+ GLshort alphadist; -+ -+ /* find lowest and highest alpha value in block, alphabase[0] lowest, alphabase[1] highest */ -+ alphabase[0] = 0xff; alphabase[1] = 0x0; -+ for (j = 0; j < numypixels; j++) { -+ for (i = 0; i < numxpixels; i++) { -+ if (srccolors[j][i][3] == 0) -+ alphaabsmin = GL_TRUE; -+ else if (srccolors[j][i][3] == 255) -+ alphaabsmax = GL_TRUE; -+ else { -+ if (srccolors[j][i][3] > alphabase[1]) -+ alphabase[1] = srccolors[j][i][3]; -+ if (srccolors[j][i][3] < alphabase[0]) -+ alphabase[0] = srccolors[j][i][3]; -+ } -+ } -+ } -+ -+ -+ if ((alphabase[0] > alphabase[1]) && !(alphaabsmin && alphaabsmax)) { /* one color, either max or min */ -+ /* shortcut here since it is a very common case (and also avoids later problems) */ -+ /* || (alphabase[0] == alphabase[1] && !alphaabsmin && !alphaabsmax) */ -+ /* could also thest for alpha0 == alpha1 (and not min/max), but probably not common, so don't bother */ -+ -+ *blkaddr++ = srccolors[0][0][3]; -+ blkaddr++; -+ *blkaddr++ = 0; -+ *blkaddr++ = 0; -+ *blkaddr++ = 0; -+ *blkaddr++ = 0; -+ *blkaddr++ = 0; -+ *blkaddr++ = 0; -+/* fprintf(stderr, "enc0 used\n");*/ -+ return; -+ } -+ -+ /* find best encoding for alpha0 > alpha1 */ -+ /* it's possible this encoding is better even if both alphaabsmin and alphaabsmax are true */ -+ alphablockerror1 = 0x0; -+ alphablockerror2 = 0xffffffff; -+ alphablockerror3 = 0xffffffff; -+ if (alphaabsmin) alphause[0] = 0; -+ else alphause[0] = alphabase[0]; -+ if (alphaabsmax) alphause[1] = 255; -+ else alphause[1] = alphabase[1]; -+ /* calculate the 7 cut values, just the middle between 2 of the computed alpha values */ -+ for (aindex = 0; aindex < 7; aindex++) { -+ /* don't forget here is always rounded down */ -+ acutValues[aindex] = (alphause[0] * (2*aindex + 1) + alphause[1] * (14 - (2*aindex + 1))) / 14; -+ } -+ -+ for (j = 0; j < numypixels; j++) { -+ for (i = 0; i < numxpixels; i++) { -+ /* maybe it's overkill to have the most complicated calculation just for the error -+ calculation which we only need to figure out if encoding1 or encoding2 is better... */ -+ if (srccolors[j][i][3] > acutValues[0]) { -+ alphaenc1[4*j + i] = 0; -+ alphadist = srccolors[j][i][3] - alphause[1]; -+ } -+ else if (srccolors[j][i][3] > acutValues[1]) { -+ alphaenc1[4*j + i] = 2; -+ alphadist = srccolors[j][i][3] - (alphause[1] * 6 + alphause[0] * 1) / 7; -+ } -+ else if (srccolors[j][i][3] > acutValues[2]) { -+ alphaenc1[4*j + i] = 3; -+ alphadist = srccolors[j][i][3] - (alphause[1] * 5 + alphause[0] * 2) / 7; -+ } -+ else if (srccolors[j][i][3] > acutValues[3]) { -+ alphaenc1[4*j + i] = 4; -+ alphadist = srccolors[j][i][3] - (alphause[1] * 4 + alphause[0] * 3) / 7; -+ } -+ else if (srccolors[j][i][3] > acutValues[4]) { -+ alphaenc1[4*j + i] = 5; -+ alphadist = srccolors[j][i][3] - (alphause[1] * 3 + alphause[0] * 4) / 7; -+ } -+ else if (srccolors[j][i][3] > acutValues[5]) { -+ alphaenc1[4*j + i] = 6; -+ alphadist = srccolors[j][i][3] - (alphause[1] * 2 + alphause[0] * 5) / 7; -+ } -+ else if (srccolors[j][i][3] > acutValues[6]) { -+ alphaenc1[4*j + i] = 7; -+ alphadist = srccolors[j][i][3] - (alphause[1] * 1 + alphause[0] * 6) / 7; -+ } -+ else { -+ alphaenc1[4*j + i] = 1; -+ alphadist = srccolors[j][i][3] - alphause[0]; -+ } -+ alphablockerror1 += alphadist * alphadist; -+ } -+ } -+/* for (i = 0; i < 16; i++) { -+ fprintf(stderr, "%d ", alphaenc1[i]); -+ } -+ fprintf(stderr, "cutVals "); -+ for (i = 0; i < 8; i++) { -+ fprintf(stderr, "%d ", acutValues[i]); -+ } -+ fprintf(stderr, "srcVals "); -+ for (j = 0; j < numypixels; j++) -+ for (i = 0; i < numxpixels; i++) { -+ fprintf(stderr, "%d ", srccolors[j][i][3]); -+ } -+ -+ fprintf(stderr, "\n"); -+ }*/ -+ /* it's not very likely this encoding is better if both alphaabsmin and alphaabsmax -+ are false but try it anyway */ -+ if (alphablockerror1 >= 32) { -+ -+ /* don't bother if encoding is already very good, this condition should also imply -+ we have valid alphabase colors which we absolutely need (alphabase[0] <= alphabase[1]) */ -+ alphablockerror2 = 0; -+ for (aindex = 0; aindex < 5; aindex++) { -+ /* don't forget here is always rounded down */ -+ acutValues[aindex] = (alphabase[0] * (10 - (2*aindex + 1)) + alphabase[1] * (2*aindex + 1)) / 10; -+ } -+ for (j = 0; j < numypixels; j++) { -+ for (i = 0; i < numxpixels; i++) { -+ /* maybe it's overkill to have the most complicated calculation just for the error -+ calculation which we only need to figure out if encoding1 or encoding2 is better... */ -+ if (srccolors[j][i][3] == 0) { -+ alphaenc2[4*j + i] = 6; -+ alphadist = 0; -+ } -+ else if (srccolors[j][i][3] == 255) { -+ alphaenc2[4*j + i] = 7; -+ alphadist = 0; -+ } -+ else if (srccolors[j][i][3] <= acutValues[0]) { -+ alphaenc2[4*j + i] = 0; -+ alphadist = srccolors[j][i][3] - alphabase[0]; -+ } -+ else if (srccolors[j][i][3] <= acutValues[1]) { -+ alphaenc2[4*j + i] = 2; -+ alphadist = srccolors[j][i][3] - (alphabase[0] * 4 + alphabase[1] * 1) / 5; -+ } -+ else if (srccolors[j][i][3] <= acutValues[2]) { -+ alphaenc2[4*j + i] = 3; -+ alphadist = srccolors[j][i][3] - (alphabase[0] * 3 + alphabase[1] * 2) / 5; -+ } -+ else if (srccolors[j][i][3] <= acutValues[3]) { -+ alphaenc2[4*j + i] = 4; -+ alphadist = srccolors[j][i][3] - (alphabase[0] * 2 + alphabase[1] * 3) / 5; -+ } -+ else if (srccolors[j][i][3] <= acutValues[4]) { -+ alphaenc2[4*j + i] = 5; -+ alphadist = srccolors[j][i][3] - (alphabase[0] * 1 + alphabase[1] * 4) / 5; -+ } -+ else { -+ alphaenc2[4*j + i] = 1; -+ alphadist = srccolors[j][i][3] - alphabase[1]; -+ } -+ alphablockerror2 += alphadist * alphadist; -+ } -+ } -+ -+ -+ /* skip this if the error is already very small -+ this encoding is MUCH better on average than #2 though, but expensive! */ -+ if ((alphablockerror2 > 96) && (alphablockerror1 > 96)) { -+ GLshort blockerrlin1 = 0; -+ GLshort blockerrlin2 = 0; -+ GLubyte nralphainrangelow = 0; -+ GLubyte nralphainrangehigh = 0; -+ alphatest[0] = 0xff; -+ alphatest[1] = 0x0; -+ /* if we have large range it's likely there are values close to 0/255, try to map them to 0/255 */ -+ for (j = 0; j < numypixels; j++) { -+ for (i = 0; i < numxpixels; i++) { -+ if ((srccolors[j][i][3] > alphatest[1]) && (srccolors[j][i][3] < (255 -(alphabase[1] - alphabase[0]) / 28))) -+ alphatest[1] = srccolors[j][i][3]; -+ if ((srccolors[j][i][3] < alphatest[0]) && (srccolors[j][i][3] > (alphabase[1] - alphabase[0]) / 28)) -+ alphatest[0] = srccolors[j][i][3]; -+ } -+ } -+ /* shouldn't happen too often, don't really care about those degenerated cases */ -+ if (alphatest[1] <= alphatest[0]) { -+ alphatest[0] = 1; -+ alphatest[1] = 254; -+/* fprintf(stderr, "only 1 or 0 colors for encoding!\n");*/ -+ } -+ for (aindex = 0; aindex < 5; aindex++) { -+ /* don't forget here is always rounded down */ -+ acutValues[aindex] = (alphatest[0] * (10 - (2*aindex + 1)) + alphatest[1] * (2*aindex + 1)) / 10; -+ } -+ -+ /* find the "average" difference between the alpha values and the next encoded value. -+ This is then used to calculate new base values. -+ Should there be some weighting, i.e. those values closer to alphatest[x] have more weight, -+ since they will see more improvement, and also because the values in the middle are somewhat -+ likely to get no improvement at all (because the base values might move in different directions)? -+ OTOH it would mean the values in the middle are even less likely to get an improvement -+ */ -+ for (j = 0; j < numypixels; j++) { -+ for (i = 0; i < numxpixels; i++) { -+ if (srccolors[j][i][3] <= alphatest[0] / 2) { -+ } -+ else if (srccolors[j][i][3] > ((255 + alphatest[1]) / 2)) { -+ } -+ else if (srccolors[j][i][3] <= acutValues[0]) { -+ blockerrlin1 += (srccolors[j][i][3] - alphatest[0]); -+ nralphainrangelow += 1; -+ } -+ else if (srccolors[j][i][3] <= acutValues[1]) { -+ blockerrlin1 += (srccolors[j][i][3] - (alphatest[0] * 4 + alphatest[1] * 1) / 5); -+ blockerrlin2 += (srccolors[j][i][3] - (alphatest[0] * 4 + alphatest[1] * 1) / 5); -+ nralphainrangelow += 1; -+ nralphainrangehigh += 1; -+ } -+ else if (srccolors[j][i][3] <= acutValues[2]) { -+ blockerrlin1 += (srccolors[j][i][3] - (alphatest[0] * 3 + alphatest[1] * 2) / 5); -+ blockerrlin2 += (srccolors[j][i][3] - (alphatest[0] * 3 + alphatest[1] * 2) / 5); -+ nralphainrangelow += 1; -+ nralphainrangehigh += 1; -+ } -+ else if (srccolors[j][i][3] <= acutValues[3]) { -+ blockerrlin1 += (srccolors[j][i][3] - (alphatest[0] * 2 + alphatest[1] * 3) / 5); -+ blockerrlin2 += (srccolors[j][i][3] - (alphatest[0] * 2 + alphatest[1] * 3) / 5); -+ nralphainrangelow += 1; -+ nralphainrangehigh += 1; -+ } -+ else if (srccolors[j][i][3] <= acutValues[4]) { -+ blockerrlin1 += (srccolors[j][i][3] - (alphatest[0] * 1 + alphatest[1] * 4) / 5); -+ blockerrlin2 += (srccolors[j][i][3] - (alphatest[0] * 1 + alphatest[1] * 4) / 5); -+ nralphainrangelow += 1; -+ nralphainrangehigh += 1; -+ } -+ else { -+ blockerrlin2 += (srccolors[j][i][3] - alphatest[1]); -+ nralphainrangehigh += 1; -+ } -+ } -+ } -+ /* shouldn't happen often, needed to avoid div by zero */ -+ if (nralphainrangelow == 0) nralphainrangelow = 1; -+ if (nralphainrangehigh == 0) nralphainrangehigh = 1; -+ alphatest[0] = alphatest[0] + (blockerrlin1 / nralphainrangelow); -+/* fprintf(stderr, "block err lin low %d, nr %d\n", blockerrlin1, nralphainrangelow); -+ fprintf(stderr, "block err lin high %d, nr %d\n", blockerrlin2, nralphainrangehigh);*/ -+ /* again shouldn't really happen often... */ -+ if (alphatest[0] < 0) { -+ alphatest[0] = 0; -+/* fprintf(stderr, "adj alpha base val to 0\n");*/ -+ } -+ alphatest[1] = alphatest[1] + (blockerrlin2 / nralphainrangehigh); -+ if (alphatest[1] > 255) { -+ alphatest[1] = 255; -+/* fprintf(stderr, "adj alpha base val to 255\n");*/ -+ } -+ -+ alphablockerror3 = 0; -+ for (aindex = 0; aindex < 5; aindex++) { -+ /* don't forget here is always rounded down */ -+ acutValues[aindex] = (alphatest[0] * (10 - (2*aindex + 1)) + alphatest[1] * (2*aindex + 1)) / 10; -+ } -+ for (j = 0; j < numypixels; j++) { -+ for (i = 0; i < numxpixels; i++) { -+ /* maybe it's overkill to have the most complicated calculation just for the error -+ calculation which we only need to figure out if encoding1 or encoding2 is better... */ -+ if (srccolors[j][i][3] <= alphatest[0] / 2) { -+ alphaenc3[4*j + i] = 6; -+ alphadist = srccolors[j][i][3]; -+ } -+ else if (srccolors[j][i][3] > ((255 + alphatest[1]) / 2)) { -+ alphaenc3[4*j + i] = 7; -+ alphadist = 255 - srccolors[j][i][3]; -+ } -+ else if (srccolors[j][i][3] <= acutValues[0]) { -+ alphaenc3[4*j + i] = 0; -+ alphadist = srccolors[j][i][3] - alphatest[0]; -+ } -+ else if (srccolors[j][i][3] <= acutValues[1]) { -+ alphaenc3[4*j + i] = 2; -+ alphadist = srccolors[j][i][3] - (alphatest[0] * 4 + alphatest[1] * 1) / 5; -+ } -+ else if (srccolors[j][i][3] <= acutValues[2]) { -+ alphaenc3[4*j + i] = 3; -+ alphadist = srccolors[j][i][3] - (alphatest[0] * 3 + alphatest[1] * 2) / 5; -+ } -+ else if (srccolors[j][i][3] <= acutValues[3]) { -+ alphaenc3[4*j + i] = 4; -+ alphadist = srccolors[j][i][3] - (alphatest[0] * 2 + alphatest[1] * 3) / 5; -+ } -+ else if (srccolors[j][i][3] <= acutValues[4]) { -+ alphaenc3[4*j + i] = 5; -+ alphadist = srccolors[j][i][3] - (alphatest[0] * 1 + alphatest[1] * 4) / 5; -+ } -+ else { -+ alphaenc3[4*j + i] = 1; -+ alphadist = srccolors[j][i][3] - alphatest[1]; -+ } -+ alphablockerror3 += alphadist * alphadist; -+ } -+ } -+ } -+ } -+ /* write the alpha values and encoding back. */ -+ if ((alphablockerror1 <= alphablockerror2) && (alphablockerror1 <= alphablockerror3)) { -+/* if (alphablockerror1 > 96) fprintf(stderr, "enc1 used, error %d\n", alphablockerror1);*/ -+ writedxt5encodedalphablock( blkaddr, alphause[1], alphause[0], alphaenc1 ); -+ } -+ else if (alphablockerror2 <= alphablockerror3) { -+/* if (alphablockerror2 > 96) fprintf(stderr, "enc2 used, error %d\n", alphablockerror2);*/ -+ writedxt5encodedalphablock( blkaddr, alphabase[0], alphabase[1], alphaenc2 ); -+ } -+ else { -+/* fprintf(stderr, "enc3 used, error %d\n", alphablockerror3);*/ -+ writedxt5encodedalphablock( blkaddr, (GLubyte)alphatest[0], (GLubyte)alphatest[1], alphaenc3 ); -+ } -+} -+ -+static void extractsrccolors( GLubyte srcpixels[4][4][4], const GLchan *srcaddr, -+ GLint srcRowStride, GLint numxpixels, GLint numypixels, GLint comps) -+{ -+ GLubyte i, j, c; -+ const GLchan *curaddr; -+ for (j = 0; j < numypixels; j++) { -+ curaddr = srcaddr + j * srcRowStride * comps; -+ for (i = 0; i < numxpixels; i++) { -+ for (c = 0; c < comps; c++) { -+ srcpixels[j][i][c] = *curaddr++ / (CHAN_MAX / 255); -+ } -+ } -+ } -+} -+ -+ -+static void tx_compress_dxtn(GLint srccomps, GLint width, GLint height, const GLubyte *srcPixData, -+ GLenum destFormat, GLubyte *dest, GLint dstRowStride) -+{ -+ GLubyte *blkaddr = dest; -+ GLubyte srcpixels[4][4][4]; -+ const GLchan *srcaddr = srcPixData; -+ GLint numxpixels, numypixels; -+ GLint i, j; -+ GLint dstRowDiff; -+ -+ switch (destFormat) { -+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: -+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: -+ /* hmm we used to get called without dstRowStride... */ -+ dstRowDiff = dstRowStride >= (width * 2) ? dstRowStride - (((width + 3) & ~3) * 2) : 0; -+/* fprintf(stderr, "dxt1 tex width %d tex height %d dstRowStride %d\n", -+ width, height, dstRowStride); */ -+ for (j = 0; j < height; j += 4) { -+ if (height > j + 3) numypixels = 4; -+ else numypixels = height - j; -+ srcaddr = srcPixData + j * width * srccomps; -+ for (i = 0; i < width; i += 4) { -+ if (width > i + 3) numxpixels = 4; -+ else numxpixels = width - i; -+ extractsrccolors(srcpixels, srcaddr, width, numxpixels, numypixels, srccomps); -+ encodedxtcolorblockfaster(blkaddr, srcpixels, numxpixels, numypixels, destFormat); -+ srcaddr += srccomps * numxpixels; -+ blkaddr += 8; -+ } -+ blkaddr += dstRowDiff; -+ } -+ break; -+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: -+ dstRowDiff = dstRowStride >= (width * 4) ? dstRowStride - (((width + 3) & ~3) * 4) : 0; -+/* fprintf(stderr, "dxt3 tex width %d tex height %d dstRowStride %d\n", -+ width, height, dstRowStride); */ -+ for (j = 0; j < height; j += 4) { -+ if (height > j + 3) numypixels = 4; -+ else numypixels = height - j; -+ srcaddr = srcPixData + j * width * srccomps; -+ for (i = 0; i < width; i += 4) { -+ if (width > i + 3) numxpixels = 4; -+ else numxpixels = width - i; -+ extractsrccolors(srcpixels, srcaddr, width, numxpixels, numypixels, srccomps); -+ *blkaddr++ = (srcpixels[0][0][3] >> 4) | (srcpixels[0][1][3] & 0xf0); -+ *blkaddr++ = (srcpixels[0][2][3] >> 4) | (srcpixels[0][3][3] & 0xf0); -+ *blkaddr++ = (srcpixels[1][0][3] >> 4) | (srcpixels[1][1][3] & 0xf0); -+ *blkaddr++ = (srcpixels[1][2][3] >> 4) | (srcpixels[1][3][3] & 0xf0); -+ *blkaddr++ = (srcpixels[2][0][3] >> 4) | (srcpixels[2][1][3] & 0xf0); -+ *blkaddr++ = (srcpixels[2][2][3] >> 4) | (srcpixels[2][3][3] & 0xf0); -+ *blkaddr++ = (srcpixels[3][0][3] >> 4) | (srcpixels[3][1][3] & 0xf0); -+ *blkaddr++ = (srcpixels[3][2][3] >> 4) | (srcpixels[3][3][3] & 0xf0); -+ encodedxtcolorblockfaster(blkaddr, srcpixels, numxpixels, numypixels, destFormat); -+ srcaddr += srccomps * numxpixels; -+ blkaddr += 8; -+ } -+ blkaddr += dstRowDiff; -+ } -+ break; -+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: -+ dstRowDiff = dstRowStride >= (width * 4) ? dstRowStride - (((width + 3) & ~3) * 4) : 0; -+/* fprintf(stderr, "dxt5 tex width %d tex height %d dstRowStride %d\n", -+ width, height, dstRowStride); */ -+ for (j = 0; j < height; j += 4) { -+ if (height > j + 3) numypixels = 4; -+ else numypixels = height - j; -+ srcaddr = srcPixData + j * width * srccomps; -+ for (i = 0; i < width; i += 4) { -+ if (width > i + 3) numxpixels = 4; -+ else numxpixels = width - i; -+ extractsrccolors(srcpixels, srcaddr, width, numxpixels, numypixels, srccomps); -+ encodedxt5alpha(blkaddr, srcpixels, numxpixels, numypixels); -+ encodedxtcolorblockfaster(blkaddr + 8, srcpixels, numxpixels, numypixels, destFormat); -+ srcaddr += srccomps * numxpixels; -+ blkaddr += 16; -+ } -+ blkaddr += dstRowDiff; -+ } -+ break; -+ default: -+ assert(false); -+ return; -+ } -+} -diff --git a/src/mesa/main/texformat.c b/src/mesa/main/texformat.c -index baa3988f0a..3f8e7a49a2 100644 ---- a/src/mesa/main/texformat.c -+++ b/src/mesa/main/texformat.c -@@ -249,9 +249,7 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, - * 1D ARRAY textures in S3TC format. - */ - if (target != GL_TEXTURE_1D && target != GL_TEXTURE_1D_ARRAY) { -- if (ctx->Mesa_DXTn) -- RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_DXT1); -- RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_FXT1); -+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGB_DXT1); - } - RETURN_IF_SUPPORTED(MESA_FORMAT_BGR_UNORM8); - RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8X8_UNORM); -@@ -260,9 +258,7 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, - case GL_COMPRESSED_RGBA_ARB: - /* We don't use texture compression for 1D and 1D array textures. */ - if (target != GL_TEXTURE_1D && target != GL_TEXTURE_1D_ARRAY) { -- if (ctx->Mesa_DXTn) -- RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_DXT3); /* Not rgba_dxt1, see spec */ -- RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_FXT1); -+ RETURN_IF_SUPPORTED(MESA_FORMAT_RGBA_DXT3); /* Not rgba_dxt1, see spec */ - } - RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_UNORM); - RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_UNORM); -@@ -502,15 +498,13 @@ _mesa_choose_tex_format(struct gl_context *ctx, GLenum target, - RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB); - break; - case GL_COMPRESSED_SRGB_EXT: -- if (ctx->Mesa_DXTn) -- RETURN_IF_SUPPORTED(MESA_FORMAT_SRGB_DXT1); -+ RETURN_IF_SUPPORTED(MESA_FORMAT_SRGB_DXT1); - RETURN_IF_SUPPORTED(MESA_FORMAT_BGR_SRGB8); - RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB); - RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB); - break; - case GL_COMPRESSED_SRGB_ALPHA_EXT: -- if (ctx->Mesa_DXTn) -- RETURN_IF_SUPPORTED(MESA_FORMAT_SRGBA_DXT3); /* Not srgba_dxt1, see spec */ -+ RETURN_IF_SUPPORTED(MESA_FORMAT_SRGBA_DXT3); /* Not srgba_dxt1, see spec */ - RETURN_IF_SUPPORTED(MESA_FORMAT_A8B8G8R8_SRGB); - RETURN_IF_SUPPORTED(MESA_FORMAT_B8G8R8A8_SRGB); - RETURN_IF_SUPPORTED(MESA_FORMAT_A8R8G8B8_SRGB); -diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c -index 5509d808cd..1d6da393c2 100644 ---- a/src/mesa/main/teximage.c -+++ b/src/mesa/main/teximage.c -@@ -2765,38 +2765,6 @@ _mesa_choose_texture_format(struct gl_context *ctx, - } - } - -- /* If the application requested compression to an S3TC format but we don't -- * have the DXTn library, force a generic compressed format instead. -- */ -- if (internalFormat != format && format != GL_NONE) { -- const GLenum before = internalFormat; -- -- switch (internalFormat) { -- case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: -- if (!ctx->Mesa_DXTn) -- internalFormat = GL_COMPRESSED_RGB; -- break; -- case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: -- case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: -- case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: -- if (!ctx->Mesa_DXTn) -- internalFormat = GL_COMPRESSED_RGBA; -- break; -- default: -- break; -- } -- -- if (before != internalFormat) { -- _mesa_warning(ctx, -- "DXT compression requested (%s), " -- "but libtxc_dxtn library not installed. Using %s " -- "instead.", -- _mesa_enum_to_string(before), -- _mesa_enum_to_string(internalFormat)); -- } -- } -- -- /* choose format from scratch */ - f = ctx->Driver.ChooseTextureFormat(ctx, target, internalFormat, - format, type); - assert(f != MESA_FORMAT_NONE); -diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c -index 381ff9dae0..b96313e2aa 100644 ---- a/src/mesa/state_tracker/st_context.c -+++ b/src/mesa/state_tracker/st_context.c -@@ -405,7 +405,7 @@ st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe, - /* GL limits and extensions */ - st_init_limits(pipe->screen, &ctx->Const, &ctx->Extensions); - st_init_extensions(pipe->screen, &ctx->Const, -- &ctx->Extensions, &st->options, ctx->Mesa_DXTn); -+ &ctx->Extensions, &st->options); - - if (st_have_perfmon(st)) { - ctx->Extensions.AMD_performance_monitor = GL_TRUE; -diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c -index 74193cc492..65b6bd34aa 100644 ---- a/src/mesa/state_tracker/st_extensions.c -+++ b/src/mesa/state_tracker/st_extensions.c -@@ -569,8 +569,7 @@ get_max_samples_for_formats(struct pipe_screen *screen, - void st_init_extensions(struct pipe_screen *screen, - struct gl_constants *consts, - struct gl_extensions *extensions, -- struct st_config_options *options, -- boolean has_lib_dxtc) -+ struct st_config_options *options) - { - unsigned i; - GLboolean *extension_table = (GLboolean *) extensions; -@@ -960,11 +959,6 @@ void st_init_extensions(struct pipe_screen *screen, - - /* Below are the cases which cannot be moved into tables easily. */ - -- if (!has_lib_dxtc && !options->force_s3tc_enable) { -- extensions->EXT_texture_compression_s3tc = GL_FALSE; -- extensions->ANGLE_texture_compression_dxt = GL_FALSE; -- } -- - if (screen->get_shader_param(screen, PIPE_SHADER_TESS_CTRL, - PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0) { - extensions->ARB_tessellation_shader = GL_TRUE; -diff --git a/src/mesa/state_tracker/st_extensions.h b/src/mesa/state_tracker/st_extensions.h -index faff11fd5d..951185caa3 100644 ---- a/src/mesa/state_tracker/st_extensions.h -+++ b/src/mesa/state_tracker/st_extensions.h -@@ -40,8 +40,7 @@ extern void st_init_limits(struct pipe_screen *screen, - extern void st_init_extensions(struct pipe_screen *screen, - struct gl_constants *consts, - struct gl_extensions *extensions, -- struct st_config_options *options, -- boolean has_lib_dxtc); -+ struct st_config_options *options); - - - #endif /* ST_EXTENSIONS_H */ -diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c -index 012f1a4015..4d0b4265b7 100644 ---- a/src/mesa/state_tracker/st_format.c -+++ b/src/mesa/state_tracker/st_format.c -@@ -2275,13 +2275,13 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target, - } - - pFormat = st_choose_format(st, internalFormat, format, type, -- pTarget, 0, bindings, ctx->Mesa_DXTn); -+ pTarget, 0, bindings, GL_TRUE); - - if (pFormat == PIPE_FORMAT_NONE && !is_renderbuffer) { - /* try choosing format again, this time without render target bindings */ - pFormat = st_choose_format(st, internalFormat, format, type, - pTarget, 0, PIPE_BIND_SAMPLER_VIEW, -- ctx->Mesa_DXTn); -+ GL_TRUE); - } - - if (pFormat == PIPE_FORMAT_NONE) { -diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c -index 5ad0816184..999e1230cb 100644 ---- a/src/mesa/state_tracker/st_manager.c -+++ b/src/mesa/state_tracker/st_manager.c -@@ -1137,7 +1137,7 @@ get_version(struct pipe_screen *screen, - _mesa_init_extensions(&extensions); - - st_init_limits(screen, &consts, &extensions); -- st_init_extensions(screen, &consts, &extensions, options, GL_TRUE); -+ st_init_extensions(screen, &consts, &extensions, options); - - return _mesa_get_version(&extensions, &consts, api); - } --- -2.13.5 - diff --git a/SOURCES/0001-pkgconfig-Fix-gl.pc-when-glvnd-is-enabled.patch b/SOURCES/0001-pkgconfig-Fix-gl.pc-when-glvnd-is-enabled.patch new file mode 100644 index 0000000..39930b7 --- /dev/null +++ b/SOURCES/0001-pkgconfig-Fix-gl.pc-when-glvnd-is-enabled.patch @@ -0,0 +1,29 @@ +From 7c137cfbffb4962b4e080052ef05cfb2266e758a Mon Sep 17 00:00:00 2001 +From: Adam Jackson +Date: Tue, 29 May 2018 09:47:35 -0400 +Subject: [PATCH] pkgconfig: Fix gl.pc when glvnd is enabled + +GL_LIB expands to GLX_mesa, but applications should not link against +that. -lGL is never wrong, just hardcode it. + +Signed-off-by: Adam Jackson +--- + src/mesa/gl.pc.in | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/mesa/gl.pc.in b/src/mesa/gl.pc.in +index 181724b97b..8c7b7da8d7 100644 +--- a/src/mesa/gl.pc.in ++++ b/src/mesa/gl.pc.in +@@ -7,7 +7,7 @@ Name: gl + Description: Mesa OpenGL library + Requires.private: @GL_PC_REQ_PRIV@ + Version: @PACKAGE_VERSION@ +-Libs: -L${libdir} -l@GL_LIB@ ++Libs: -L${libdir} -lGL + Libs.private: @GL_PC_LIB_PRIV@ + Cflags: -I${includedir} @GL_PC_CFLAGS@ + glx_tls: @GLX_TLS@ +-- +2.17.0 + diff --git a/SOURCES/0002-anv-blorp-Add-a-device-parameter-to-blorp_surf_for_a.patch b/SOURCES/0002-anv-blorp-Add-a-device-parameter-to-blorp_surf_for_a.patch deleted file mode 100644 index 013e866..0000000 --- a/SOURCES/0002-anv-blorp-Add-a-device-parameter-to-blorp_surf_for_a.patch +++ /dev/null @@ -1,182 +0,0 @@ -From ee170635c5be54cf644ef5c8d4574f30764e244f Mon Sep 17 00:00:00 2001 -From: Jason Ekstrand -Date: Fri, 3 Nov 2017 15:18:45 -0700 -Subject: [PATCH 2/5] anv/blorp: Add a device parameter to - blorp_surf_for_anv_image - -Cc: "17.3" -Tested-by: Lyude Paul -Reviewed-by: Kenneth Graunke -Signed-off-by: Lyude ---- - src/intel/vulkan/anv_blorp.c | 54 ++++++++++++++++++++++++++++---------------- - 1 file changed, 34 insertions(+), 20 deletions(-) - -diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c -index 79f5234c55..c00d38b52c 100644 ---- a/src/intel/vulkan/anv_blorp.c -+++ b/src/intel/vulkan/anv_blorp.c -@@ -176,7 +176,8 @@ get_blorp_surf_for_anv_buffer(struct anv_device *device, - } - - static void --get_blorp_surf_for_anv_image(const struct anv_image *image, -+get_blorp_surf_for_anv_image(const struct anv_device *device, -+ const struct anv_image *image, - VkImageAspectFlags aspect, - enum isl_aux_usage aux_usage, - struct blorp_surf *blorp_surf) -@@ -257,9 +258,11 @@ void anv_CmdCopyImage( - VkImageAspectFlagBits aspect = (1 << a); - - struct blorp_surf src_surf, dst_surf; -- get_blorp_surf_for_anv_image(src_image, aspect, src_image->aux_usage, -+ get_blorp_surf_for_anv_image(cmd_buffer->device, -+ src_image, aspect, src_image->aux_usage, - &src_surf); -- get_blorp_surf_for_anv_image(dst_image, aspect, dst_image->aux_usage, -+ get_blorp_surf_for_anv_image(cmd_buffer->device, -+ dst_image, aspect, dst_image->aux_usage, - &dst_surf); - - for (unsigned i = 0; i < layer_count; i++) { -@@ -308,8 +311,8 @@ copy_buffer_to_image(struct anv_cmd_buffer *cmd_buffer, - for (unsigned r = 0; r < regionCount; r++) { - const VkImageAspectFlags aspect = pRegions[r].imageSubresource.aspectMask; - -- get_blorp_surf_for_anv_image(anv_image, aspect, anv_image->aux_usage, -- &image.surf); -+ get_blorp_surf_for_anv_image(cmd_buffer->device, anv_image, aspect, -+ anv_image->aux_usage, &image.surf); - image.offset = - anv_sanitize_image_offset(anv_image->type, pRegions[r].imageOffset); - image.level = pRegions[r].imageSubresource.mipLevel; -@@ -454,9 +457,11 @@ void anv_CmdBlitImage( - const VkImageSubresourceLayers *src_res = &pRegions[r].srcSubresource; - const VkImageSubresourceLayers *dst_res = &pRegions[r].dstSubresource; - -- get_blorp_surf_for_anv_image(src_image, src_res->aspectMask, -+ get_blorp_surf_for_anv_image(cmd_buffer->device, -+ src_image, src_res->aspectMask, - src_image->aux_usage, &src); -- get_blorp_surf_for_anv_image(dst_image, dst_res->aspectMask, -+ get_blorp_surf_for_anv_image(cmd_buffer->device, -+ dst_image, dst_res->aspectMask, - dst_image->aux_usage, &dst); - - struct anv_format src_format = -@@ -832,7 +837,8 @@ void anv_CmdClearColorImage( - blorp_batch_init(&cmd_buffer->device->blorp, &batch, cmd_buffer, 0); - - struct blorp_surf surf; -- get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_COLOR_BIT, -+ get_blorp_surf_for_anv_image(cmd_buffer->device, -+ image, VK_IMAGE_ASPECT_COLOR_BIT, - image->aux_usage, &surf); - - for (unsigned r = 0; r < rangeCount; r++) { -@@ -885,14 +891,16 @@ void anv_CmdClearDepthStencilImage( - - struct blorp_surf depth, stencil; - if (image->aspects & VK_IMAGE_ASPECT_DEPTH_BIT) { -- get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_DEPTH_BIT, -+ get_blorp_surf_for_anv_image(cmd_buffer->device, -+ image, VK_IMAGE_ASPECT_DEPTH_BIT, - ISL_AUX_USAGE_NONE, &depth); - } else { - memset(&depth, 0, sizeof(depth)); - } - - if (image->aspects & VK_IMAGE_ASPECT_STENCIL_BIT) { -- get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_STENCIL_BIT, -+ get_blorp_surf_for_anv_image(cmd_buffer->device, -+ image, VK_IMAGE_ASPECT_STENCIL_BIT, - ISL_AUX_USAGE_NONE, &stencil); - } else { - memset(&stencil, 0, sizeof(stencil)); -@@ -1212,7 +1220,8 @@ anv_cmd_buffer_clear_subpass(struct anv_cmd_buffer *cmd_buffer) - struct anv_image_view *iview = fb->attachments[a]; - const struct anv_image *image = iview->image; - struct blorp_surf surf; -- get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_COLOR_BIT, -+ get_blorp_surf_for_anv_image(cmd_buffer->device, image, -+ VK_IMAGE_ASPECT_COLOR_BIT, - att_state->aux_usage, &surf); - - if (att_state->fast_clear) { -@@ -1359,7 +1368,8 @@ anv_cmd_buffer_clear_subpass(struct anv_cmd_buffer *cmd_buffer) - } - - static void --resolve_image(struct blorp_batch *batch, -+resolve_image(struct anv_device *device, -+ struct blorp_batch *batch, - const struct anv_image *src_image, - enum isl_aux_usage src_aux_usage, - uint32_t src_level, uint32_t src_layer, -@@ -1380,9 +1390,9 @@ resolve_image(struct blorp_batch *batch, - VkImageAspectFlagBits aspect = 1 << a; - - struct blorp_surf src_surf, dst_surf; -- get_blorp_surf_for_anv_image(src_image, aspect, -+ get_blorp_surf_for_anv_image(device, src_image, aspect, - src_aux_usage, &src_surf); -- get_blorp_surf_for_anv_image(dst_image, aspect, -+ get_blorp_surf_for_anv_image(device, dst_image, aspect, - dst_aux_usage, &dst_surf); - - blorp_blit(batch, -@@ -1422,7 +1432,7 @@ void anv_CmdResolveImage( - anv_get_layerCount(dst_image, &pRegions[r].dstSubresource); - - for (uint32_t layer = 0; layer < layer_count; layer++) { -- resolve_image(&batch, -+ resolve_image(cmd_buffer->device, &batch, - src_image, src_image->aux_usage, - pRegions[r].srcSubresource.mipLevel, - pRegions[r].srcSubresource.baseArrayLayer + layer, -@@ -1456,7 +1466,8 @@ anv_image_fast_clear(struct anv_cmd_buffer *cmd_buffer, - blorp_batch_init(&cmd_buffer->device->blorp, &batch, cmd_buffer, 0); - - struct blorp_surf surf; -- get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_COLOR_BIT, -+ get_blorp_surf_for_anv_image(cmd_buffer->device, image, -+ VK_IMAGE_ASPECT_COLOR_BIT, - image->aux_usage == ISL_AUX_USAGE_NONE ? - ISL_AUX_USAGE_CCS_D : image->aux_usage, - &surf); -@@ -1553,7 +1564,8 @@ anv_cmd_buffer_resolve_subpass(struct anv_cmd_buffer *cmd_buffer) - - assert(src_iview->aspect_mask == dst_iview->aspect_mask); - -- resolve_image(&batch, src_iview->image, src_aux_usage, -+ resolve_image(cmd_buffer->device, &batch, -+ src_iview->image, src_aux_usage, - src_iview->isl.base_level, - src_iview->isl.base_array_layer, - dst_iview->image, dst_aux_usage, -@@ -1590,8 +1602,9 @@ anv_gen8_hiz_op_resolve(struct anv_cmd_buffer *cmd_buffer, - blorp_batch_init(&cmd_buffer->device->blorp, &batch, cmd_buffer, 0); - - struct blorp_surf surf; -- get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_DEPTH_BIT, -- ISL_AUX_USAGE_NONE, &surf); -+ get_blorp_surf_for_anv_image(cmd_buffer->device, image, -+ VK_IMAGE_ASPECT_DEPTH_BIT, ISL_AUX_USAGE_NONE, -+ &surf); - - /* Manually add the aux HiZ surf */ - surf.aux_surf = &image->aux_surface.isl, -@@ -1634,7 +1647,8 @@ anv_ccs_resolve(struct anv_cmd_buffer * const cmd_buffer, - BLORP_BATCH_PREDICATE_ENABLE); - - struct blorp_surf surf; -- get_blorp_surf_for_anv_image(image, VK_IMAGE_ASPECT_COLOR_BIT, -+ get_blorp_surf_for_anv_image(cmd_buffer->device, image, -+ VK_IMAGE_ASPECT_COLOR_BIT, - image->aux_usage == ISL_AUX_USAGE_CCS_E ? - ISL_AUX_USAGE_CCS_E : ISL_AUX_USAGE_CCS_D, - &surf); --- -2.14.3 - diff --git a/SOURCES/0003-blorp-Turn-anv_CmdCopyBuffer-into-a-blorp_buffer_cop.patch b/SOURCES/0003-blorp-Turn-anv_CmdCopyBuffer-into-a-blorp_buffer_cop.patch deleted file mode 100644 index f38b276..0000000 --- a/SOURCES/0003-blorp-Turn-anv_CmdCopyBuffer-into-a-blorp_buffer_cop.patch +++ /dev/null @@ -1,312 +0,0 @@ -From d9266ae66c9db12a9c2578a33bbd5ebd131b489f Mon Sep 17 00:00:00 2001 -From: Kenneth Graunke -Date: Mon, 28 Aug 2017 15:57:20 -0700 -Subject: [PATCH 3/5] blorp: Turn anv_CmdCopyBuffer into a blorp_buffer_copy() - helper. - -I want to be able to copy between buffer objects using BLORP in the i965 -driver. Anvil already had code to do this, in a reasonably efficient -manner - first using large bpp copies, then smaller bpp copies. - -This patch moves that logic into BLORP as blorp_buffer_copy(), so we -can use it in both drivers. - -Reviewed-by: Jason Ekstrand -Signed-off-by: Lyude ---- - src/intel/blorp/blorp.h | 6 +++ - src/intel/blorp/blorp_blit.c | 119 +++++++++++++++++++++++++++++++++++++++++++ - src/intel/vulkan/anv_blorp.c | 117 +++++++----------------------------------- - 3 files changed, 143 insertions(+), 99 deletions(-) - -diff --git a/src/intel/blorp/blorp.h b/src/intel/blorp/blorp.h -index d19920e87f..e712b4fbb3 100644 ---- a/src/intel/blorp/blorp.h -+++ b/src/intel/blorp/blorp.h -@@ -133,6 +133,12 @@ blorp_copy(struct blorp_batch *batch, - uint32_t dst_x, uint32_t dst_y, - uint32_t src_width, uint32_t src_height); - -+void -+blorp_buffer_copy(struct blorp_batch *batch, -+ struct blorp_address src, -+ struct blorp_address dst, -+ uint64_t size); -+ - void - blorp_fast_clear(struct blorp_batch *batch, - const struct blorp_surf *surf, enum isl_format format, -diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c -index 35008cbbb0..b012a0a0b3 100644 ---- a/src/intel/blorp/blorp_blit.c -+++ b/src/intel/blorp/blorp_blit.c -@@ -2513,3 +2513,122 @@ blorp_copy(struct blorp_batch *batch, - - do_blorp_blit(batch, ¶ms, &wm_prog_key, &coords); - } -+ -+static enum isl_format -+isl_format_for_size(unsigned size_B) -+{ -+ switch (size_B) { -+ case 1: return ISL_FORMAT_R8_UINT; -+ case 2: return ISL_FORMAT_R8G8_UINT; -+ case 4: return ISL_FORMAT_R8G8B8A8_UINT; -+ case 8: return ISL_FORMAT_R16G16B16A16_UINT; -+ case 16: return ISL_FORMAT_R32G32B32A32_UINT; -+ default: -+ unreachable("Not a power-of-two format size"); -+ } -+} -+ -+/** -+ * Returns the greatest common divisor of a and b that is a power of two. -+ */ -+static uint64_t -+gcd_pow2_u64(uint64_t a, uint64_t b) -+{ -+ assert(a > 0 || b > 0); -+ -+ unsigned a_log2 = ffsll(a) - 1; -+ unsigned b_log2 = ffsll(b) - 1; -+ -+ /* If either a or b is 0, then a_log2 or b_log2 till be UINT_MAX in which -+ * case, the MIN2() will take the other one. If both are 0 then we will -+ * hit the assert above. -+ */ -+ return 1 << MIN2(a_log2, b_log2); -+} -+ -+static void -+do_buffer_copy(struct blorp_batch *batch, -+ struct blorp_address *src, -+ struct blorp_address *dst, -+ int width, int height, int block_size) -+{ -+ /* The actual format we pick doesn't matter as blorp will throw it away. -+ * The only thing that actually matters is the size. -+ */ -+ enum isl_format format = isl_format_for_size(block_size); -+ -+ UNUSED bool ok; -+ struct isl_surf surf; -+ ok = isl_surf_init(batch->blorp->isl_dev, &surf, -+ .dim = ISL_SURF_DIM_2D, -+ .format = format, -+ .width = width, -+ .height = height, -+ .depth = 1, -+ .levels = 1, -+ .array_len = 1, -+ .samples = 1, -+ .row_pitch = width * block_size, -+ .usage = ISL_SURF_USAGE_TEXTURE_BIT | -+ ISL_SURF_USAGE_RENDER_TARGET_BIT, -+ .tiling_flags = ISL_TILING_LINEAR_BIT); -+ assert(ok); -+ -+ struct blorp_surf src_blorp_surf = { -+ .surf = &surf, -+ .addr = *src, -+ }; -+ -+ struct blorp_surf dst_blorp_surf = { -+ .surf = &surf, -+ .addr = *dst, -+ }; -+ -+ blorp_copy(batch, &src_blorp_surf, 0, 0, &dst_blorp_surf, 0, 0, -+ 0, 0, 0, 0, width, height); -+} -+ -+/* This is maximum possible width/height our HW can handle */ -+#define MAX_SURFACE_DIM (1ull << 14) -+ -+void -+blorp_buffer_copy(struct blorp_batch *batch, -+ struct blorp_address src, -+ struct blorp_address dst, -+ uint64_t size) -+{ -+ uint64_t copy_size = size; -+ -+ /* First, we compute the biggest format that can be used with the -+ * given offsets and size. -+ */ -+ int bs = 16; -+ bs = gcd_pow2_u64(bs, src.offset); -+ bs = gcd_pow2_u64(bs, dst.offset); -+ bs = gcd_pow2_u64(bs, size); -+ -+ /* First, we make a bunch of max-sized copies */ -+ uint64_t max_copy_size = MAX_SURFACE_DIM * MAX_SURFACE_DIM * bs; -+ while (copy_size >= max_copy_size) { -+ do_buffer_copy(batch, &src, &dst, MAX_SURFACE_DIM, MAX_SURFACE_DIM, bs); -+ copy_size -= max_copy_size; -+ src.offset += max_copy_size; -+ dst.offset += max_copy_size; -+ } -+ -+ /* Now make a max-width copy */ -+ uint64_t height = copy_size / (MAX_SURFACE_DIM * bs); -+ assert(height < MAX_SURFACE_DIM); -+ if (height != 0) { -+ uint64_t rect_copy_size = height * MAX_SURFACE_DIM * bs; -+ do_buffer_copy(batch, &src, &dst, MAX_SURFACE_DIM, height, bs); -+ copy_size -= rect_copy_size; -+ src.offset += rect_copy_size; -+ dst.offset += rect_copy_size; -+ } -+ -+ /* Finally, make a small copy to finish it off */ -+ if (copy_size != 0) { -+ do_buffer_copy(batch, &src, &dst, copy_size / bs, 1, bs); -+ } -+} -diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c -index c00d38b52c..3a64b60178 100644 ---- a/src/intel/vulkan/anv_blorp.c -+++ b/src/intel/vulkan/anv_blorp.c -@@ -546,56 +546,6 @@ isl_format_for_size(unsigned size_B) - } - } - --static void --do_buffer_copy(struct blorp_batch *batch, -- struct anv_bo *src, uint64_t src_offset, -- struct anv_bo *dst, uint64_t dst_offset, -- int width, int height, int block_size) --{ -- struct anv_device *device = batch->blorp->driver_ctx; -- -- /* The actual format we pick doesn't matter as blorp will throw it away. -- * The only thing that actually matters is the size. -- */ -- enum isl_format format = isl_format_for_size(block_size); -- -- UNUSED bool ok; -- struct isl_surf surf; -- ok = isl_surf_init(&device->isl_dev, &surf, -- .dim = ISL_SURF_DIM_2D, -- .format = format, -- .width = width, -- .height = height, -- .depth = 1, -- .levels = 1, -- .array_len = 1, -- .samples = 1, -- .row_pitch = width * block_size, -- .usage = ISL_SURF_USAGE_TEXTURE_BIT | -- ISL_SURF_USAGE_RENDER_TARGET_BIT, -- .tiling_flags = ISL_TILING_LINEAR_BIT); -- assert(ok); -- -- struct blorp_surf src_blorp_surf = { -- .surf = &surf, -- .addr = { -- .buffer = src, -- .offset = src_offset, -- }, -- }; -- -- struct blorp_surf dst_blorp_surf = { -- .surf = &surf, -- .addr = { -- .buffer = dst, -- .offset = dst_offset, -- }, -- }; -- -- blorp_copy(batch, &src_blorp_surf, 0, 0, &dst_blorp_surf, 0, 0, -- 0, 0, 0, 0, width, height); --} -- - /** - * Returns the greatest common divisor of a and b that is a power of two. - */ -@@ -632,48 +582,16 @@ void anv_CmdCopyBuffer( - blorp_batch_init(&cmd_buffer->device->blorp, &batch, cmd_buffer, 0); - - for (unsigned r = 0; r < regionCount; r++) { -- uint64_t src_offset = src_buffer->offset + pRegions[r].srcOffset; -- uint64_t dst_offset = dst_buffer->offset + pRegions[r].dstOffset; -- uint64_t copy_size = pRegions[r].size; -- -- /* First, we compute the biggest format that can be used with the -- * given offsets and size. -- */ -- int bs = 16; -- bs = gcd_pow2_u64(bs, src_offset); -- bs = gcd_pow2_u64(bs, dst_offset); -- bs = gcd_pow2_u64(bs, pRegions[r].size); -- -- /* First, we make a bunch of max-sized copies */ -- uint64_t max_copy_size = MAX_SURFACE_DIM * MAX_SURFACE_DIM * bs; -- while (copy_size >= max_copy_size) { -- do_buffer_copy(&batch, src_buffer->bo, src_offset, -- dst_buffer->bo, dst_offset, -- MAX_SURFACE_DIM, MAX_SURFACE_DIM, bs); -- copy_size -= max_copy_size; -- src_offset += max_copy_size; -- dst_offset += max_copy_size; -- } -- -- /* Now make a max-width copy */ -- uint64_t height = copy_size / (MAX_SURFACE_DIM * bs); -- assert(height < MAX_SURFACE_DIM); -- if (height != 0) { -- uint64_t rect_copy_size = height * MAX_SURFACE_DIM * bs; -- do_buffer_copy(&batch, src_buffer->bo, src_offset, -- dst_buffer->bo, dst_offset, -- MAX_SURFACE_DIM, height, bs); -- copy_size -= rect_copy_size; -- src_offset += rect_copy_size; -- dst_offset += rect_copy_size; -- } -+ struct blorp_address src = { -+ .buffer = src_buffer->bo, -+ .offset = src_buffer->offset + pRegions[r].srcOffset, -+ }; -+ struct blorp_address dst = { -+ .buffer = dst_buffer->bo, -+ .offset = dst_buffer->offset + pRegions[r].dstOffset, -+ }; - -- /* Finally, make a small copy to finish it off */ -- if (copy_size != 0) { -- do_buffer_copy(&batch, src_buffer->bo, src_offset, -- dst_buffer->bo, dst_offset, -- copy_size / bs, 1, bs); -- } -+ blorp_buffer_copy(&batch, src, dst, pRegions[r].size); - } - - blorp_batch_finish(&batch); -@@ -715,15 +633,16 @@ void anv_CmdUpdateBuffer( - - anv_state_flush(cmd_buffer->device, tmp_data); - -- int bs = 16; -- bs = gcd_pow2_u64(bs, dstOffset); -- bs = gcd_pow2_u64(bs, copy_size); -+ struct blorp_address src = { -+ .buffer = &cmd_buffer->device->dynamic_state_pool.block_pool.bo, -+ .offset = tmp_data.offset, -+ }; -+ struct blorp_address dst = { -+ .buffer = dst_buffer->bo, -+ .offset = dst_buffer->offset + dstOffset, -+ }; - -- do_buffer_copy(&batch, -- &cmd_buffer->device->dynamic_state_pool.block_pool.bo, -- tmp_data.offset, -- dst_buffer->bo, dst_buffer->offset + dstOffset, -- copy_size / bs, 1, bs); -+ blorp_buffer_copy(&batch, src, dst, copy_size); - - dataSize -= copy_size; - dstOffset += copy_size; --- -2.14.3 - diff --git a/SOURCES/0004-intel-blorp-Make-the-MOCS-setting-part-of-blorp_addr.patch b/SOURCES/0004-intel-blorp-Make-the-MOCS-setting-part-of-blorp_addr.patch deleted file mode 100644 index 97073a2..0000000 --- a/SOURCES/0004-intel-blorp-Make-the-MOCS-setting-part-of-blorp_addr.patch +++ /dev/null @@ -1,288 +0,0 @@ -From f70d7f3f4600febac0a6d1f62e14230eace8a67b Mon Sep 17 00:00:00 2001 -From: Jason Ekstrand -Date: Fri, 3 Nov 2017 15:20:08 -0700 -Subject: [PATCH 4/5] intel/blorp: Make the MOCS setting part of blorp_address - -This makes our MOCS settings significantly more flexible. - -Cc: "17.3" -Tested-by: Lyude Paul -Reviewed-by: Kenneth Graunke -Signed-off-by: Lyude ---- - src/intel/blorp/blorp.h | 7 +------ - src/intel/blorp/blorp_genX_exec.h | 16 +++++++-------- - src/intel/vulkan/anv_blorp.c | 11 +++++++--- - src/intel/vulkan/genX_blorp_exec.c | 1 + - src/mesa/drivers/dri/i965/brw_blorp.c | 31 +++++++++++++++-------------- - src/mesa/drivers/dri/i965/genX_blorp_exec.c | 10 ++++++++++ - 6 files changed, 43 insertions(+), 33 deletions(-) - -diff --git a/src/intel/blorp/blorp.h b/src/intel/blorp/blorp.h -index e712b4fbb3..ac45828a42 100644 ---- a/src/intel/blorp/blorp.h -+++ b/src/intel/blorp/blorp.h -@@ -45,12 +45,6 @@ struct blorp_context { - - const struct brw_compiler *compiler; - -- struct { -- uint32_t tex; -- uint32_t rb; -- uint32_t vb; -- } mocs; -- - bool (*lookup_shader)(struct blorp_context *blorp, - const void *key, uint32_t key_size, - uint32_t *kernel_out, void *prog_data_out); -@@ -95,6 +89,7 @@ struct blorp_address { - uint32_t read_domains; - uint32_t write_domain; - uint32_t offset; -+ uint32_t mocs; - }; - - struct blorp_surf -diff --git a/src/intel/blorp/blorp_genX_exec.h b/src/intel/blorp/blorp_genX_exec.h -index 565acca929..d0f0299d17 100644 ---- a/src/intel/blorp/blorp_genX_exec.h -+++ b/src/intel/blorp/blorp_genX_exec.h -@@ -269,7 +269,7 @@ blorp_emit_vertex_buffers(struct blorp_batch *batch, - vb[0].VertexBufferIndex = 0; - vb[0].BufferPitch = 3 * sizeof(float); - #if GEN_GEN >= 6 -- vb[0].VertexBufferMOCS = batch->blorp->mocs.vb; -+ vb[0].VertexBufferMOCS = vb[0].BufferStartingAddress.mocs; - #endif - #if GEN_GEN >= 7 - vb[0].AddressModifyEnable = true; -@@ -290,7 +290,7 @@ blorp_emit_vertex_buffers(struct blorp_batch *batch, - vb[1].VertexBufferIndex = 1; - vb[1].BufferPitch = 0; - #if GEN_GEN >= 6 -- vb[1].VertexBufferMOCS = batch->blorp->mocs.vb; -+ vb[1].VertexBufferMOCS = vb[1].BufferStartingAddress.mocs; - #endif - #if GEN_GEN >= 7 - vb[1].AddressModifyEnable = true; -@@ -1235,13 +1235,11 @@ blorp_emit_surface_state(struct blorp_batch *batch, - write_disable_mask |= ISL_CHANNEL_ALPHA_BIT; - } - -- const uint32_t mocs = -- is_render_target ? batch->blorp->mocs.rb : batch->blorp->mocs.tex; -- - isl_surf_fill_state(batch->blorp->isl_dev, state, - .surf = &surf, .view = &surface->view, - .aux_surf = &surface->aux_surf, .aux_usage = aux_usage, -- .mocs = mocs, .clear_color = surface->clear_color, -+ .mocs = surface->addr.mocs, -+ .clear_color = surface->clear_color, - .write_disables = write_disable_mask); - - blorp_surface_reloc(batch, state_offset + isl_dev->ss.addr_offset, -@@ -1363,14 +1361,14 @@ blorp_emit_depth_stencil_config(struct blorp_batch *batch, - if (dw == NULL) - return; - -- struct isl_depth_stencil_hiz_emit_info info = { -- .mocs = batch->blorp->mocs.tex, -- }; -+ struct isl_depth_stencil_hiz_emit_info info = { }; - - if (params->depth.enabled) { - info.view = ¶ms->depth.view; -+ info.mocs = params->depth.addr.mocs; - } else if (params->stencil.enabled) { - info.view = ¶ms->stencil.view; -+ info.mocs = params->stencil.addr.mocs; - } - - if (params->depth.enabled) { -diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c -index 3a64b60178..b7e9524a24 100644 ---- a/src/intel/vulkan/anv_blorp.c -+++ b/src/intel/vulkan/anv_blorp.c -@@ -92,9 +92,6 @@ anv_device_init_blorp(struct anv_device *device) - anv_pipeline_cache_init(&device->blorp_shader_cache, device, true); - blorp_init(&device->blorp, device, &device->isl_dev); - device->blorp.compiler = device->instance->physicalDevice.compiler; -- device->blorp.mocs.tex = device->default_mocs; -- device->blorp.mocs.rb = device->default_mocs; -- device->blorp.mocs.vb = device->default_mocs; - device->blorp.lookup_shader = lookup_blorp_shader; - device->blorp.upload_shader = upload_blorp_shader; - switch (device->info.gen) { -@@ -156,6 +153,7 @@ get_blorp_surf_for_anv_buffer(struct anv_device *device, - .addr = { - .buffer = buffer->bo, - .offset = buffer->offset + offset, -+ .mocs = device->default_mocs, - }, - }; - -@@ -194,6 +192,7 @@ get_blorp_surf_for_anv_image(const struct anv_device *device, - .addr = { - .buffer = image->bo, - .offset = image->offset + surface->offset, -+ .mocs = device->default_mocs, - }, - }; - -@@ -202,6 +201,7 @@ get_blorp_surf_for_anv_image(const struct anv_device *device, - blorp_surf->aux_addr = (struct blorp_address) { - .buffer = image->bo, - .offset = image->offset + image->aux_surface.offset, -+ .mocs = device->default_mocs, - }; - blorp_surf->aux_usage = aux_usage; - } -@@ -585,10 +585,12 @@ void anv_CmdCopyBuffer( - struct blorp_address src = { - .buffer = src_buffer->bo, - .offset = src_buffer->offset + pRegions[r].srcOffset, -+ .mocs = cmd_buffer->device->default_mocs, - }; - struct blorp_address dst = { - .buffer = dst_buffer->bo, - .offset = dst_buffer->offset + pRegions[r].dstOffset, -+ .mocs = cmd_buffer->device->default_mocs, - }; - - blorp_buffer_copy(&batch, src, dst, pRegions[r].size); -@@ -636,10 +638,12 @@ void anv_CmdUpdateBuffer( - struct blorp_address src = { - .buffer = &cmd_buffer->device->dynamic_state_pool.block_pool.bo, - .offset = tmp_data.offset, -+ .mocs = cmd_buffer->device->default_mocs, - }; - struct blorp_address dst = { - .buffer = dst_buffer->bo, - .offset = dst_buffer->offset + dstOffset, -+ .mocs = cmd_buffer->device->default_mocs, - }; - - blorp_buffer_copy(&batch, src, dst, copy_size); -@@ -1530,6 +1534,7 @@ anv_gen8_hiz_op_resolve(struct anv_cmd_buffer *cmd_buffer, - surf.aux_addr = (struct blorp_address) { - .buffer = image->bo, - .offset = image->offset + image->aux_surface.offset, -+ .mocs = cmd_buffer->device->default_mocs, - }; - surf.aux_usage = ISL_AUX_USAGE_HIZ; - -diff --git a/src/intel/vulkan/genX_blorp_exec.c b/src/intel/vulkan/genX_blorp_exec.c -index f041fc71b5..b4b05c7022 100644 ---- a/src/intel/vulkan/genX_blorp_exec.c -+++ b/src/intel/vulkan/genX_blorp_exec.c -@@ -134,6 +134,7 @@ blorp_alloc_vertex_buffer(struct blorp_batch *batch, uint32_t size, - *addr = (struct blorp_address) { - .buffer = &cmd_buffer->device->dynamic_state_pool.block_pool.bo, - .offset = vb_state.offset, -+ .mocs = cmd_buffer->device->default_mocs, - }; - - return vb_state.map; -diff --git a/src/mesa/drivers/dri/i965/brw_blorp.c b/src/mesa/drivers/dri/i965/brw_blorp.c -index eb08de438d..2b7d960f0c 100644 ---- a/src/mesa/drivers/dri/i965/brw_blorp.c -+++ b/src/mesa/drivers/dri/i965/brw_blorp.c -@@ -82,15 +82,9 @@ brw_blorp_init(struct brw_context *brw) - brw->blorp.exec = gen5_blorp_exec; - break; - case 6: -- brw->blorp.mocs.tex = 0; -- brw->blorp.mocs.rb = 0; -- brw->blorp.mocs.vb = 0; - brw->blorp.exec = gen6_blorp_exec; - break; - case 7: -- brw->blorp.mocs.tex = GEN7_MOCS_L3; -- brw->blorp.mocs.rb = GEN7_MOCS_L3; -- brw->blorp.mocs.vb = GEN7_MOCS_L3; - if (brw->is_haswell) { - brw->blorp.exec = gen75_blorp_exec; - } else { -@@ -98,21 +92,12 @@ brw_blorp_init(struct brw_context *brw) - } - break; - case 8: -- brw->blorp.mocs.tex = BDW_MOCS_WB; -- brw->blorp.mocs.rb = BDW_MOCS_PTE; -- brw->blorp.mocs.vb = BDW_MOCS_WB; - brw->blorp.exec = gen8_blorp_exec; - break; - case 9: -- brw->blorp.mocs.tex = SKL_MOCS_WB; -- brw->blorp.mocs.rb = SKL_MOCS_PTE; -- brw->blorp.mocs.vb = SKL_MOCS_WB; - brw->blorp.exec = gen9_blorp_exec; - break; - case 10: -- brw->blorp.mocs.tex = CNL_MOCS_WB; -- brw->blorp.mocs.rb = CNL_MOCS_PTE; -- brw->blorp.mocs.vb = CNL_MOCS_WB; - brw->blorp.exec = gen10_blorp_exec; - break; - default: -@@ -123,6 +108,20 @@ brw_blorp_init(struct brw_context *brw) - brw->blorp.upload_shader = brw_blorp_upload_shader; - } - -+static uint32_t tex_mocs[] = { -+ [7] = GEN7_MOCS_L3, -+ [8] = BDW_MOCS_WB, -+ [9] = SKL_MOCS_WB, -+ [10] = CNL_MOCS_WB, -+}; -+ -+static uint32_t rb_mocs[] = { -+ [7] = GEN7_MOCS_L3, -+ [8] = BDW_MOCS_PTE, -+ [9] = SKL_MOCS_PTE, -+ [10] = CNL_MOCS_PTE, -+}; -+ - static void - blorp_surf_for_miptree(struct brw_context *brw, - struct blorp_surf *surf, -@@ -155,6 +154,7 @@ blorp_surf_for_miptree(struct brw_context *brw, - .read_domains = is_render_target ? I915_GEM_DOMAIN_RENDER : - I915_GEM_DOMAIN_SAMPLER, - .write_domain = is_render_target ? I915_GEM_DOMAIN_RENDER : 0, -+ .mocs = is_render_target ? rb_mocs[devinfo->gen] : tex_mocs[devinfo->gen], - }; - - surf->aux_usage = aux_usage; -@@ -184,6 +184,7 @@ blorp_surf_for_miptree(struct brw_context *brw, - .read_domains = is_render_target ? I915_GEM_DOMAIN_RENDER : - I915_GEM_DOMAIN_SAMPLER, - .write_domain = is_render_target ? I915_GEM_DOMAIN_RENDER : 0, -+ .mocs = surf->addr.mocs, - }; - - if (mt->mcs_buf) { -diff --git a/src/mesa/drivers/dri/i965/genX_blorp_exec.c b/src/mesa/drivers/dri/i965/genX_blorp_exec.c -index 62d5c4a792..74c1add281 100644 ---- a/src/mesa/drivers/dri/i965/genX_blorp_exec.c -+++ b/src/mesa/drivers/dri/i965/genX_blorp_exec.c -@@ -145,6 +145,16 @@ blorp_alloc_vertex_buffer(struct blorp_batch *batch, uint32_t size, - .read_domains = I915_GEM_DOMAIN_VERTEX, - .write_domain = 0, - .offset = offset, -+ -+#if GEN_GEN == 10 -+ .mocs = CNL_MOCS_WB, -+#elif GEN_GEN == 9 -+ .mocs = SKL_MOCS_WB, -+#elif GEN_GEN == 8 -+ .mocs = BDW_MOCS_WB, -+#elif GEN_GEN == 7 -+ .mocs = GEN7_MOCS_L3, -+#endif - }; - - return data; --- -2.14.3 - diff --git a/SOURCES/0005-i965-Use-PTE-MOCS-for-all-external-buffers.patch b/SOURCES/0005-i965-Use-PTE-MOCS-for-all-external-buffers.patch deleted file mode 100644 index 367e04a..0000000 --- a/SOURCES/0005-i965-Use-PTE-MOCS-for-all-external-buffers.patch +++ /dev/null @@ -1,136 +0,0 @@ -From 066ea39ce113d8fe1992a6892f7094a6dfae6242 Mon Sep 17 00:00:00 2001 -From: Jason Ekstrand -Date: Fri, 3 Nov 2017 15:26:17 -0700 -Subject: [PATCH 5/5] i965: Use PTE MOCS for all external buffers - -We were already using PTE for all render targets in case one happened to -get scanned out. However, this still wasn't 100% correct because there -are still possibly cases where we may want to texture from an external -buffer even though we don't know the caching mode. This can happen, for -instance, on buffers imported from another GPU via prime. - -Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101691 -Cc: "17.3" -Tested-by: Lyude Paul -Reviewed-by: Kenneth Graunke -Signed-off-by: Lyude ---- - src/mesa/drivers/dri/i965/brw_blorp.c | 7 ++++--- - src/mesa/drivers/dri/i965/brw_wm_surface_state.c | 23 ++++++++++++++++------- - 2 files changed, 20 insertions(+), 10 deletions(-) - -diff --git a/src/mesa/drivers/dri/i965/brw_blorp.c b/src/mesa/drivers/dri/i965/brw_blorp.c -index 2b7d960f0c..48b3da7375 100644 ---- a/src/mesa/drivers/dri/i965/brw_blorp.c -+++ b/src/mesa/drivers/dri/i965/brw_blorp.c -@@ -108,14 +108,14 @@ brw_blorp_init(struct brw_context *brw) - brw->blorp.upload_shader = brw_blorp_upload_shader; - } - --static uint32_t tex_mocs[] = { -+static uint32_t wb_mocs[] = { - [7] = GEN7_MOCS_L3, - [8] = BDW_MOCS_WB, - [9] = SKL_MOCS_WB, - [10] = CNL_MOCS_WB, - }; - --static uint32_t rb_mocs[] = { -+static uint32_t pte_mocs[] = { - [7] = GEN7_MOCS_L3, - [8] = BDW_MOCS_PTE, - [9] = SKL_MOCS_PTE, -@@ -154,7 +154,8 @@ blorp_surf_for_miptree(struct brw_context *brw, - .read_domains = is_render_target ? I915_GEM_DOMAIN_RENDER : - I915_GEM_DOMAIN_SAMPLER, - .write_domain = is_render_target ? I915_GEM_DOMAIN_RENDER : 0, -- .mocs = is_render_target ? rb_mocs[devinfo->gen] : tex_mocs[devinfo->gen], -+ .mocs = (is_render_target || mt->bo->external) ? pte_mocs[devinfo->gen] : -+ wb_mocs[devinfo->gen], - }; - - surf->aux_usage = aux_usage; -diff --git a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c -index 17e760c329..87f1aa379d 100644 ---- a/src/mesa/drivers/dri/i965/brw_wm_surface_state.c -+++ b/src/mesa/drivers/dri/i965/brw_wm_surface_state.c -@@ -60,20 +60,28 @@ enum { - INTEL_AUX_BUFFER_DISABLED = 1 << 1, - }; - --uint32_t tex_mocs[] = { -+uint32_t wb_mocs[] = { - [7] = GEN7_MOCS_L3, - [8] = BDW_MOCS_WB, - [9] = SKL_MOCS_WB, - [10] = CNL_MOCS_WB, - }; - --uint32_t rb_mocs[] = { -+uint32_t pte_mocs[] = { - [7] = GEN7_MOCS_L3, - [8] = BDW_MOCS_PTE, - [9] = SKL_MOCS_PTE, - [10] = CNL_MOCS_PTE, - }; - -+static uint32_t -+get_tex_mocs(const struct brw_context *brw, struct brw_bo *bo) -+{ -+ const struct gen_device_info *devinfo = &brw->screen->devinfo; -+ -+ return (bo && bo->external ? pte_mocs : wb_mocs)[devinfo->gen]; -+} -+ - static void - get_isl_surf(struct brw_context *brw, struct intel_mipmap_tree *mt, - GLenum target, struct isl_view *view, -@@ -244,7 +252,7 @@ brw_update_renderbuffer_surface(struct brw_context *brw, - - uint32_t offset; - brw_emit_surface_state(brw, mt, mt->target, view, aux_usage, -- rb_mocs[brw->gen], -+ pte_mocs[brw->gen], - &offset, surf_index, - I915_GEM_DOMAIN_RENDER, - I915_GEM_DOMAIN_RENDER); -@@ -589,7 +597,7 @@ brw_update_texture_surface(struct gl_context *ctx, - aux_usage = ISL_AUX_USAGE_NONE; - - brw_emit_surface_state(brw, mt, mt->target, view, aux_usage, -- tex_mocs[brw->gen], -+ get_tex_mocs(brw, mt->bo), - surf_offset, surf_index, - I915_GEM_DOMAIN_SAMPLER, 0); - } -@@ -615,7 +623,7 @@ brw_emit_buffer_surface_state(struct brw_context *brw, - .size = buffer_size, - .format = surface_format, - .stride = pitch, -- .mocs = tex_mocs[brw->gen]); -+ .mocs = get_tex_mocs(brw, bo)); - - if (bo) { - brw_emit_reloc(&brw->batch, *out_offset + brw->isl_dev.ss.addr_offset, -@@ -1164,7 +1172,7 @@ update_renderbuffer_read_surfaces(struct brw_context *brw) - aux_usage = ISL_AUX_USAGE_NONE; - - brw_emit_surface_state(brw, irb->mt, target, view, aux_usage, -- tex_mocs[brw->gen], -+ get_tex_mocs(brw, irb->mt->bo), - surf_offset, surf_index, - I915_GEM_DOMAIN_SAMPLER, 0); - -@@ -1657,7 +1665,8 @@ update_image_surface(struct brw_context *brw, - view.base_array_layer, - view.array_len)); - brw_emit_surface_state(brw, mt, mt->target, view, -- ISL_AUX_USAGE_NONE, tex_mocs[brw->gen], -+ ISL_AUX_USAGE_NONE, -+ get_tex_mocs(brw, mt->bo), - surf_offset, surf_index, - I915_GEM_DOMAIN_SAMPLER, - access == GL_READ_ONLY ? 0 : --- -2.14.3 - diff --git a/SOURCES/dri-sw-xshm-support.patch b/SOURCES/dri-sw-xshm-support.patch new file mode 100644 index 0000000..33700e8 --- /dev/null +++ b/SOURCES/dri-sw-xshm-support.patch @@ -0,0 +1,1690 @@ +diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h +index 34a5c9fb01a..6e6d62a5142 100644 +--- a/include/GL/internal/dri_interface.h ++++ b/include/GL/internal/dri_interface.h +@@ -565,7 +565,7 @@ struct __DRIdamageExtensionRec { + * SWRast Loader extension. + */ + #define __DRI_SWRAST_LOADER "DRI_SWRastLoader" +-#define __DRI_SWRAST_LOADER_VERSION 3 ++#define __DRI_SWRAST_LOADER_VERSION 4 + struct __DRIswrastLoaderExtensionRec { + __DRIextension base; + +@@ -607,6 +607,24 @@ struct __DRIswrastLoaderExtensionRec { + void (*getImage2)(__DRIdrawable *readable, + int x, int y, int width, int height, int stride, + char *data, void *loaderPrivate); ++ ++ /** ++ * Put shm image to drawable ++ * ++ * \since 4 ++ */ ++ void (*putImageShm)(__DRIdrawable *drawable, int op, ++ int x, int y, int width, int height, int stride, ++ int shmid, char *shmaddr, unsigned offset, ++ void *loaderPrivate); ++ /** ++ * Get shm image from readable ++ * ++ * \since 4 ++ */ ++ void (*getImageShm)(__DRIdrawable *readable, ++ int x, int y, int width, int height, ++ int shmid, void *loaderPrivate); + }; + + /** +diff --git a/src/gallium/auxiliary/renderonly/renderonly.c b/src/gallium/auxiliary/renderonly/renderonly.c +index d31f458845c..f83910a9404 100644 +--- a/src/gallium/auxiliary/renderonly/renderonly.c ++++ b/src/gallium/auxiliary/renderonly/renderonly.c +@@ -98,7 +98,7 @@ renderonly_create_kms_dumb_buffer_for_resource(struct pipe_resource *rsc, + + /* fill in winsys handle */ + memset(out_handle, 0, sizeof(*out_handle)); +- out_handle->type = DRM_API_HANDLE_TYPE_FD; ++ out_handle->type = WINSYS_HANDLE_TYPE_FD; + out_handle->stride = create_dumb.pitch; + + err = drmPrimeHandleToFD(ro->kms_fd, create_dumb.handle, O_CLOEXEC, +@@ -130,7 +130,7 @@ renderonly_create_gpu_import_for_resource(struct pipe_resource *rsc, + boolean status; + int fd, err; + struct winsys_handle handle = { +- .type = DRM_API_HANDLE_TYPE_FD ++ .type = WINSYS_HANDLE_TYPE_FD + }; + + scanout = CALLOC_STRUCT(renderonly_scanout); +diff --git a/src/gallium/auxiliary/renderonly/renderonly.h b/src/gallium/auxiliary/renderonly/renderonly.h +index 6a89c29e2ef..a8d6a686ed4 100644 +--- a/src/gallium/auxiliary/renderonly/renderonly.h ++++ b/src/gallium/auxiliary/renderonly/renderonly.h +@@ -85,7 +85,7 @@ renderonly_get_handle(struct renderonly_scanout *scanout, + if (!scanout) + return FALSE; + +- assert(handle->type == DRM_API_HANDLE_TYPE_KMS); ++ assert(handle->type == WINSYS_HANDLE_TYPE_KMS); + handle->handle = scanout->handle; + handle->stride = scanout->stride; + +diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri.c b/src/gallium/auxiliary/vl/vl_winsys_dri.c +index 79ebf750cdb..bb1ff504886 100644 +--- a/src/gallium/auxiliary/vl/vl_winsys_dri.c ++++ b/src/gallium/auxiliary/vl/vl_winsys_dri.c +@@ -231,7 +231,7 @@ vl_dri2_screen_texture_from_drawable(struct vl_screen *vscreen, void *drawable) + } + + memset(&dri2_handle, 0, sizeof(dri2_handle)); +- dri2_handle.type = DRM_API_HANDLE_TYPE_SHARED; ++ dri2_handle.type = WINSYS_HANDLE_TYPE_SHARED; + dri2_handle.handle = back_left->name; + dri2_handle.stride = back_left->pitch; + +diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c b/src/gallium/auxiliary/vl/vl_winsys_dri3.c +index 8251087f3f9..8e3c4a0e04d 100644 +--- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c ++++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c +@@ -271,7 +271,7 @@ dri3_alloc_back_buffer(struct vl_dri3_screen *scrn) + pixmap_buffer_texture = buffer->texture; + } + memset(&whandle, 0, sizeof(whandle)); +- whandle.type= DRM_API_HANDLE_TYPE_FD; ++ whandle.type= WINSYS_HANDLE_TYPE_FD; + usage = PIPE_HANDLE_USAGE_EXPLICIT_FLUSH | PIPE_HANDLE_USAGE_READ; + scrn->base.pscreen->resource_get_handle(scrn->base.pscreen, NULL, + pixmap_buffer_texture, &whandle, +@@ -492,7 +492,7 @@ dri3_get_front_buffer(struct vl_dri3_screen *scrn) + goto free_reply; + + memset(&whandle, 0, sizeof(whandle)); +- whandle.type = DRM_API_HANDLE_TYPE_FD; ++ whandle.type = WINSYS_HANDLE_TYPE_FD; + whandle.handle = (unsigned)fds[0]; + whandle.stride = bp_reply->stride; + memset(&templ, 0, sizeof(templ)); +diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c b/src/gallium/drivers/etnaviv/etnaviv_resource.c +index d70152e082d..cf870a3ed76 100644 +--- a/src/gallium/drivers/etnaviv/etnaviv_resource.c ++++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c +@@ -250,7 +250,7 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned layout, + if (!scanout) + return NULL; + +- assert(handle.type == DRM_API_HANDLE_TYPE_FD); ++ assert(handle.type == WINSYS_HANDLE_TYPE_FD); + handle.modifier = modifier; + rsc = etna_resource(pscreen->resource_from_handle(pscreen, templat, + &handle, +@@ -596,16 +596,16 @@ etna_resource_get_handle(struct pipe_screen *pscreen, + handle->stride = rsc->levels[0].stride; + handle->modifier = layout_to_modifier(rsc->layout); + +- if (handle->type == DRM_API_HANDLE_TYPE_SHARED) { ++ if (handle->type == WINSYS_HANDLE_TYPE_SHARED) { + return etna_bo_get_name(rsc->bo, &handle->handle) == 0; +- } else if (handle->type == DRM_API_HANDLE_TYPE_KMS) { ++ } else if (handle->type == WINSYS_HANDLE_TYPE_KMS) { + if (renderonly_get_handle(scanout, handle)) { + return TRUE; + } else { + handle->handle = etna_bo_handle(rsc->bo); + return TRUE; + } +- } else if (handle->type == DRM_API_HANDLE_TYPE_FD) { ++ } else if (handle->type == WINSYS_HANDLE_TYPE_FD) { + handle->handle = etna_bo_dmabuf(rsc->bo); + return TRUE; + } else { +diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c b/src/gallium/drivers/etnaviv/etnaviv_screen.c +index c72793920ab..1997e9f85db 100644 +--- a/src/gallium/drivers/etnaviv/etnaviv_screen.c ++++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c +@@ -842,9 +842,9 @@ etna_screen_bo_from_handle(struct pipe_screen *pscreen, + struct etna_screen *screen = etna_screen(pscreen); + struct etna_bo *bo; + +- if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { ++ if (whandle->type == WINSYS_HANDLE_TYPE_SHARED) { + bo = etna_bo_from_name(screen->dev, whandle->handle); +- } else if (whandle->type == DRM_API_HANDLE_TYPE_FD) { ++ } else if (whandle->type == WINSYS_HANDLE_TYPE_FD) { + bo = etna_bo_from_dmabuf(screen->dev, whandle->handle); + } else { + DBG("Attempt to import unsupported handle type %d", whandle->type); +diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c +index b68685989ca..e0f769a63cd 100644 +--- a/src/gallium/drivers/freedreno/freedreno_screen.c ++++ b/src/gallium/drivers/freedreno/freedreno_screen.c +@@ -731,12 +731,12 @@ fd_screen_bo_get_handle(struct pipe_screen *pscreen, + { + whandle->stride = stride; + +- if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { ++ if (whandle->type == WINSYS_HANDLE_TYPE_SHARED) { + return fd_bo_get_name(bo, &whandle->handle) == 0; +- } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) { ++ } else if (whandle->type == WINSYS_HANDLE_TYPE_KMS) { + whandle->handle = fd_bo_handle(bo); + return TRUE; +- } else if (whandle->type == DRM_API_HANDLE_TYPE_FD) { ++ } else if (whandle->type == WINSYS_HANDLE_TYPE_FD) { + whandle->handle = fd_bo_dmabuf(bo); + return TRUE; + } else { +@@ -751,11 +751,11 @@ fd_screen_bo_from_handle(struct pipe_screen *pscreen, + struct fd_screen *screen = fd_screen(pscreen); + struct fd_bo *bo; + +- if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { ++ if (whandle->type == WINSYS_HANDLE_TYPE_SHARED) { + bo = fd_bo_from_name(screen->dev, whandle->handle); +- } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) { ++ } else if (whandle->type == WINSYS_HANDLE_TYPE_KMS) { + bo = fd_bo_from_handle(screen->dev, whandle->handle, 0); +- } else if (whandle->type == DRM_API_HANDLE_TYPE_FD) { ++ } else if (whandle->type == WINSYS_HANDLE_TYPE_FD) { + bo = fd_bo_from_dmabuf(screen->dev, whandle->handle); + } else { + DBG("Attempt to import unsupported handle type %d", whandle->type); +diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c +index c144b39b2dd..c97b707955c 100644 +--- a/src/gallium/drivers/nouveau/nouveau_screen.c ++++ b/src/gallium/drivers/nouveau/nouveau_screen.c +@@ -102,14 +102,14 @@ nouveau_screen_bo_from_handle(struct pipe_screen *pscreen, + return NULL; + } + +- if (whandle->type != DRM_API_HANDLE_TYPE_SHARED && +- whandle->type != DRM_API_HANDLE_TYPE_FD) { ++ if (whandle->type != WINSYS_HANDLE_TYPE_SHARED && ++ whandle->type != WINSYS_HANDLE_TYPE_FD) { + debug_printf("%s: attempt to import unsupported handle type %d\n", + __FUNCTION__, whandle->type); + return NULL; + } + +- if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) ++ if (whandle->type == WINSYS_HANDLE_TYPE_SHARED) + ret = nouveau_bo_name_ref(dev, whandle->handle, &bo); + else + ret = nouveau_bo_prime_handle_ref(dev, whandle->handle, &bo); +@@ -133,12 +133,12 @@ nouveau_screen_bo_get_handle(struct pipe_screen *pscreen, + { + whandle->stride = stride; + +- if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { ++ if (whandle->type == WINSYS_HANDLE_TYPE_SHARED) { + return nouveau_bo_name_get(bo, &whandle->handle) == 0; +- } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) { ++ } else if (whandle->type == WINSYS_HANDLE_TYPE_KMS) { + whandle->handle = bo->handle; + return true; +- } else if (whandle->type == DRM_API_HANDLE_TYPE_FD) { ++ } else if (whandle->type == WINSYS_HANDLE_TYPE_FD) { + return nouveau_bo_set_prime(bo, (int *)&whandle->handle) == 0; + } else { + return false; +diff --git a/src/gallium/drivers/radeon/r600_texture.c b/src/gallium/drivers/radeon/r600_texture.c +index 36eff40949f..a9c7b46b7b3 100644 +--- a/src/gallium/drivers/radeon/r600_texture.c ++++ b/src/gallium/drivers/radeon/r600_texture.c +@@ -699,7 +699,7 @@ static boolean r600_texture_get_handle(struct pipe_screen* screen, + if (sscreen->ws->buffer_is_suballocated(res->buf) || + rtex->surface.tile_swizzle || + (rtex->resource.flags & RADEON_FLAG_NO_INTERPROCESS_SHARING && +- whandle->type != DRM_API_HANDLE_TYPE_KMS)) { ++ whandle->type != WINSYS_HANDLE_TYPE_KMS)) { + assert(!res->b.is_shared); + r600_reallocate_texture_inplace(rctx, rtex, + PIPE_BIND_SHARED, false); +diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c +index cdcbcc917e0..58b6a42d4fd 100644 +--- a/src/gallium/drivers/vc4/vc4_resource.c ++++ b/src/gallium/drivers/vc4/vc4_resource.c +@@ -406,7 +406,7 @@ vc4_resource_get_handle(struct pipe_screen *pscreen, + whandle->modifier = DRM_FORMAT_MOD_LINEAR; + + switch (whandle->type) { +- case DRM_API_HANDLE_TYPE_SHARED: ++ case WINSYS_HANDLE_TYPE_SHARED: + if (screen->ro) { + /* This could probably be supported, assuming that a + * control node was used for pl111. +@@ -416,12 +416,12 @@ vc4_resource_get_handle(struct pipe_screen *pscreen, + } + + return vc4_bo_flink(rsc->bo, &whandle->handle); +- case DRM_API_HANDLE_TYPE_KMS: ++ case WINSYS_HANDLE_TYPE_KMS: + if (screen->ro && renderonly_get_handle(rsc->scanout, whandle)) + return TRUE; + whandle->handle = rsc->bo->handle; + return TRUE; +- case DRM_API_HANDLE_TYPE_FD: ++ case WINSYS_HANDLE_TYPE_FD: + /* FDs are cross-device, so we can export directly from vc4. + */ + whandle->handle = vc4_bo_get_dmabuf(rsc->bo); +@@ -716,11 +716,11 @@ vc4_resource_from_handle(struct pipe_screen *pscreen, + } + + switch (whandle->type) { +- case DRM_API_HANDLE_TYPE_SHARED: ++ case WINSYS_HANDLE_TYPE_SHARED: + rsc->bo = vc4_bo_open_name(screen, + whandle->handle, whandle->stride); + break; +- case DRM_API_HANDLE_TYPE_FD: ++ case WINSYS_HANDLE_TYPE_FD: + rsc->bo = vc4_bo_open_dmabuf(screen, + whandle->handle, whandle->stride); + break; +diff --git a/src/gallium/drivers/vc5/vc5_resource.c b/src/gallium/drivers/vc5/vc5_resource.c +index a9cc27127f0..9754d3d6024 100644 +--- a/src/gallium/drivers/vc5/vc5_resource.c ++++ b/src/gallium/drivers/vc5/vc5_resource.c +@@ -314,12 +314,12 @@ vc5_resource_get_handle(struct pipe_screen *pscreen, + bo->private = false; + + switch (whandle->type) { +- case DRM_API_HANDLE_TYPE_SHARED: ++ case WINSYS_HANDLE_TYPE_SHARED: + return vc5_bo_flink(bo, &whandle->handle); +- case DRM_API_HANDLE_TYPE_KMS: ++ case WINSYS_HANDLE_TYPE_KMS: + whandle->handle = bo->handle; + return TRUE; +- case DRM_API_HANDLE_TYPE_FD: ++ case WINSYS_HANDLE_TYPE_FD: + whandle->handle = vc5_bo_get_dmabuf(bo); + return whandle->handle != -1; + } +@@ -592,11 +592,11 @@ vc5_resource_from_handle(struct pipe_screen *pscreen, + } + + switch (whandle->type) { +- case DRM_API_HANDLE_TYPE_SHARED: ++ case WINSYS_HANDLE_TYPE_SHARED: + rsc->bo = vc5_bo_open_name(screen, + whandle->handle, whandle->stride); + break; +- case DRM_API_HANDLE_TYPE_FD: ++ case WINSYS_HANDLE_TYPE_FD: + rsc->bo = vc5_bo_open_dmabuf(screen, + whandle->handle, whandle->stride); + break; +diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h +index 101e229088b..8fd81a4e9a9 100644 +--- a/src/gallium/include/pipe/p_screen.h ++++ b/src/gallium/include/pipe/p_screen.h +@@ -191,7 +191,7 @@ struct pipe_screen { + * another process by first creating a pipe texture and then calling + * resource_get_handle. + * +- * NOTE: in the case of DRM_API_HANDLE_TYPE_FD handles, the caller ++ * NOTE: in the case of WINSYS_HANDLE_TYPE_FD handles, the caller + * retains ownership of the FD. (This is consistent with + * EGL_EXT_image_dma_buf_import) + * +@@ -238,7 +238,7 @@ struct pipe_screen { + * the resource into a format compatible for sharing. The use case is + * OpenGL-OpenCL interop. The context parameter is allowed to be NULL. + * +- * NOTE: in the case of DRM_API_HANDLE_TYPE_FD handles, the caller ++ * NOTE: in the case of WINSYS_HANDLE_TYPE_FD handles, the caller + * takes ownership of the FD. (This is consistent with + * EGL_MESA_image_dma_buf_export) + * +@@ -389,7 +389,7 @@ struct pipe_screen { + * Then the underlying memory object is then exported through interfaces + * compatible with EXT_external_resources. + * +- * Note: For DRM_API_HANDLE_TYPE_FD handles, the caller retains ownership ++ * Note: For WINSYS_HANDLE_TYPE_FD handles, the caller retains ownership + * of the fd. + * + * \param handle A handle representing the memory object to import +diff --git a/src/gallium/include/state_tracker/drisw_api.h b/src/gallium/include/state_tracker/drisw_api.h +index 03d5ee405a4..e365ab81f18 100644 +--- a/src/gallium/include/state_tracker/drisw_api.h ++++ b/src/gallium/include/state_tracker/drisw_api.h +@@ -2,6 +2,7 @@ + #define _DRISW_API_H_ + + #include "pipe/p_compiler.h" ++#include "sw_winsys.h" + + struct pipe_screen; + struct dri_drawable; +@@ -18,6 +19,9 @@ struct drisw_loader_funcs + void *data, unsigned width, unsigned height); + void (*put_image2) (struct dri_drawable *dri_drawable, + void *data, int x, int y, unsigned width, unsigned height, unsigned stride); ++ void (*put_image_shm) (struct dri_drawable *dri_drawable, ++ int shmid, char *shmaddr, unsigned offset, ++ int x, int y, unsigned width, unsigned height, unsigned stride); + }; + + #endif +diff --git a/src/gallium/include/state_tracker/drm_driver.h b/src/gallium/include/state_tracker/drm_driver.h +index f188b5a7d4c..19cd19f26e1 100644 +--- a/src/gallium/include/state_tracker/drm_driver.h ++++ b/src/gallium/include/state_tracker/drm_driver.h +@@ -4,58 +4,13 @@ + + #include "pipe/p_compiler.h" + ++#include "winsys_handle.h" ++ + struct pipe_screen; + struct pipe_screen_config; + struct pipe_context; + struct pipe_resource; + +-#define DRM_API_HANDLE_TYPE_SHARED 0 +-#define DRM_API_HANDLE_TYPE_KMS 1 +-#define DRM_API_HANDLE_TYPE_FD 2 +- +- +-/** +- * For use with pipe_screen::{texture_from_handle|texture_get_handle}. +- */ +-struct winsys_handle +-{ +- /** +- * Input for texture_from_handle, valid values are +- * DRM_API_HANDLE_TYPE_SHARED or DRM_API_HANDLE_TYPE_FD. +- * Input to texture_get_handle, +- * to select handle for kms, flink, or prime. +- */ +- unsigned type; +- /** +- * Input for texture_get_handle, allows to export the offset +- * of a specific layer of an array texture. +- */ +- unsigned layer; +- /** +- * Input to texture_from_handle. +- * Output for texture_get_handle. +- */ +- unsigned handle; +- /** +- * Input to texture_from_handle. +- * Output for texture_get_handle. +- */ +- unsigned stride; +- /** +- * Input to texture_from_handle. +- * Output for texture_get_handle. +- */ +- unsigned offset; +- +- /** +- * Input to resource_from_handle. +- * Output from resource_get_handle. +- */ +- uint64_t modifier; +-}; +- +- +- + /** + * Configuration queries. + */ +diff --git a/src/gallium/include/state_tracker/sw_winsys.h b/src/gallium/include/state_tracker/sw_winsys.h +index 0b792cd0ce4..cd5838ad1d8 100644 +--- a/src/gallium/include/state_tracker/sw_winsys.h ++++ b/src/gallium/include/state_tracker/sw_winsys.h +@@ -37,14 +37,13 @@ + + #include "pipe/p_compiler.h" /* for boolean */ + #include "pipe/p_format.h" +- ++#include "state_tracker/winsys_handle.h" + + #ifdef __cplusplus + extern "C" { + #endif + + +-struct winsys_handle; + struct pipe_screen; + struct pipe_context; + struct pipe_resource; +diff --git a/src/gallium/include/state_tracker/winsys_handle.h b/src/gallium/include/state_tracker/winsys_handle.h +new file mode 100644 +index 00000000000..167c1a937fd +--- /dev/null ++++ b/src/gallium/include/state_tracker/winsys_handle.h +@@ -0,0 +1,58 @@ ++ ++#ifndef _WINSYS_HANDLE_H_ ++#define _WINSYS_HANDLE_H_ ++ ++#ifdef __cplusplus ++extern "C" { ++#endif ++ ++#define WINSYS_HANDLE_TYPE_SHARED 0 ++#define WINSYS_HANDLE_TYPE_KMS 1 ++#define WINSYS_HANDLE_TYPE_FD 2 ++#define WINSYS_HANDLE_TYPE_SHMID 3 ++ ++/** ++ * For use with pipe_screen::{texture_from_handle|texture_get_handle}. ++ */ ++struct winsys_handle ++{ ++ /** ++ * Input for texture_from_handle, valid values are ++ * WINSYS_HANDLE_TYPE_SHARED or WINSYS_HANDLE_TYPE_FD. ++ * Input to texture_get_handle, ++ * to select handle for kms, flink, or prime. ++ */ ++ unsigned type; ++ /** ++ * Input for texture_get_handle, allows to export the offset ++ * of a specific layer of an array texture. ++ */ ++ unsigned layer; ++ /** ++ * Input to texture_from_handle. ++ * Output for texture_get_handle. ++ */ ++ unsigned handle; ++ /** ++ * Input to texture_from_handle. ++ * Output for texture_get_handle. ++ */ ++ unsigned stride; ++ /** ++ * Input to texture_from_handle. ++ * Output for texture_get_handle. ++ */ ++ unsigned offset; ++ ++ /** ++ * Input to resource_from_handle. ++ * Output from resource_get_handle. ++ */ ++ uint64_t modifier; ++}; ++ ++#ifdef __cplusplus ++} ++#endif ++ ++#endif /* _WINSYS_HANDLE_H_ */ +diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c +index 2c3a6e0d194..aa219377069 100644 +--- a/src/gallium/state_trackers/dri/dri2.c ++++ b/src/gallium/state_trackers/dri/dri2.c +@@ -584,9 +584,9 @@ dri2_allocate_buffer(__DRIscreen *sPriv, + + memset(&whandle, 0, sizeof(whandle)); + if (screen->can_share_buffer) +- whandle.type = DRM_API_HANDLE_TYPE_SHARED; ++ whandle.type = WINSYS_HANDLE_TYPE_SHARED; + else +- whandle.type = DRM_API_HANDLE_TYPE_KMS; ++ whandle.type = WINSYS_HANDLE_TYPE_KMS; + + screen->base.screen->resource_get_handle(screen->base.screen, NULL, + buffer->resource, &whandle, +@@ -772,9 +772,9 @@ dri2_allocate_textures(struct dri_context *ctx, + whandle.offset = 0; + whandle.modifier = DRM_FORMAT_MOD_INVALID; + if (screen->can_share_buffer) +- whandle.type = DRM_API_HANDLE_TYPE_SHARED; ++ whandle.type = WINSYS_HANDLE_TYPE_SHARED; + else +- whandle.type = DRM_API_HANDLE_TYPE_KMS; ++ whandle.type = WINSYS_HANDLE_TYPE_KMS; + drawable->textures[statt] = + screen->base.screen->resource_from_handle(screen->base.screen, + &templ, &whandle, +@@ -1032,7 +1032,7 @@ dri2_create_image_from_name(__DRIscreen *_screen, + enum pipe_format pf; + + memset(&whandle, 0, sizeof(whandle)); +- whandle.type = DRM_API_HANDLE_TYPE_SHARED; ++ whandle.type = WINSYS_HANDLE_TYPE_SHARED; + whandle.handle = name; + whandle.modifier = DRM_FORMAT_MOD_INVALID; + +@@ -1091,7 +1091,7 @@ dri2_create_image_from_fd(__DRIscreen *_screen, + goto exit; + } + +- whandles[i].type = DRM_API_HANDLE_TYPE_FD; ++ whandles[i].type = WINSYS_HANDLE_TYPE_FD; + whandles[i].handle = (unsigned)fds[i]; + whandles[i].stride = (unsigned)strides[i]; + whandles[i].offset = (unsigned)offsets[i]; +@@ -1231,35 +1231,35 @@ dri2_query_image(__DRIimage *image, int attrib, int *value) + + switch (attrib) { + case __DRI_IMAGE_ATTRIB_STRIDE: +- whandle.type = DRM_API_HANDLE_TYPE_KMS; ++ whandle.type = WINSYS_HANDLE_TYPE_KMS; + if (!image->texture->screen->resource_get_handle(image->texture->screen, + NULL, image->texture, &whandle, usage)) + return GL_FALSE; + *value = whandle.stride; + return GL_TRUE; + case __DRI_IMAGE_ATTRIB_OFFSET: +- whandle.type = DRM_API_HANDLE_TYPE_KMS; ++ whandle.type = WINSYS_HANDLE_TYPE_KMS; + if (!image->texture->screen->resource_get_handle(image->texture->screen, + NULL, image->texture, &whandle, usage)) + return GL_FALSE; + *value = whandle.offset; + return GL_TRUE; + case __DRI_IMAGE_ATTRIB_HANDLE: +- whandle.type = DRM_API_HANDLE_TYPE_KMS; ++ whandle.type = WINSYS_HANDLE_TYPE_KMS; + if (!image->texture->screen->resource_get_handle(image->texture->screen, + NULL, image->texture, &whandle, usage)) + return GL_FALSE; + *value = whandle.handle; + return GL_TRUE; + case __DRI_IMAGE_ATTRIB_NAME: +- whandle.type = DRM_API_HANDLE_TYPE_SHARED; ++ whandle.type = WINSYS_HANDLE_TYPE_SHARED; + if (!image->texture->screen->resource_get_handle(image->texture->screen, + NULL, image->texture, &whandle, usage)) + return GL_FALSE; + *value = whandle.handle; + return GL_TRUE; + case __DRI_IMAGE_ATTRIB_FD: +- whandle.type= DRM_API_HANDLE_TYPE_FD; ++ whandle.type= WINSYS_HANDLE_TYPE_FD; + if (!image->texture->screen->resource_get_handle(image->texture->screen, + NULL, image->texture, &whandle, usage)) + return GL_FALSE; +@@ -1287,7 +1287,7 @@ dri2_query_image(__DRIimage *image, int attrib, int *value) + *value = 1; + return GL_TRUE; + case __DRI_IMAGE_ATTRIB_MODIFIER_UPPER: +- whandle.type = DRM_API_HANDLE_TYPE_KMS; ++ whandle.type = WINSYS_HANDLE_TYPE_KMS; + whandle.modifier = DRM_FORMAT_MOD_INVALID; + if (!image->texture->screen->resource_get_handle(image->texture->screen, + NULL, image->texture, &whandle, usage)) +@@ -1297,7 +1297,7 @@ dri2_query_image(__DRIimage *image, int attrib, int *value) + *value = (whandle.modifier >> 32) & 0xffffffff; + return GL_TRUE; + case __DRI_IMAGE_ATTRIB_MODIFIER_LOWER: +- whandle.type = DRM_API_HANDLE_TYPE_KMS; ++ whandle.type = WINSYS_HANDLE_TYPE_KMS; + whandle.modifier = DRM_FORMAT_MOD_INVALID; + if (!image->texture->screen->resource_get_handle(image->texture->screen, + NULL, image->texture, &whandle, usage)) +@@ -1377,7 +1377,7 @@ dri2_from_names(__DRIscreen *screen, int width, int height, int format, + return NULL; + + memset(&whandle, 0, sizeof(whandle)); +- whandle.type = DRM_API_HANDLE_TYPE_SHARED; ++ whandle.type = WINSYS_HANDLE_TYPE_SHARED; + whandle.handle = names[0]; + whandle.stride = strides[0]; + whandle.offset = offsets[0]; +@@ -1909,7 +1909,7 @@ dri2_interop_export_object(__DRIcontext *_ctx, + } + + memset(&whandle, 0, sizeof(whandle)); +- whandle.type = DRM_API_HANDLE_TYPE_FD; ++ whandle.type = WINSYS_HANDLE_TYPE_FD; + + success = screen->resource_get_handle(screen, st->pipe, res, &whandle, + usage); +diff --git a/src/gallium/state_trackers/dri/drisw.c b/src/gallium/state_trackers/dri/drisw.c +index eb5752386dc..e24fcba3869 100644 +--- a/src/gallium/state_trackers/dri/drisw.c ++++ b/src/gallium/state_trackers/dri/drisw.c +@@ -26,14 +26,6 @@ + * + **************************************************************************/ + +-/* TODO: +- * +- * xshm / EGLImage: +- * +- * Allow the loaders to use the XSHM extension. It probably requires callbacks +- * for createImage/destroyImage similar to DRI2 getBuffers. +- */ +- + #include "util/u_format.h" + #include "util/u_memory.h" + #include "util/u_inlines.h" +@@ -86,6 +78,19 @@ put_image2(__DRIdrawable *dPriv, void *data, int x, int y, + data, dPriv->loaderPrivate); + } + ++static inline void ++put_image_shm(__DRIdrawable *dPriv, int shmid, char *shmaddr, ++ unsigned offset, int x, int y, ++ unsigned width, unsigned height, unsigned stride) ++{ ++ __DRIscreen *sPriv = dPriv->driScreenPriv; ++ const __DRIswrastLoaderExtension *loader = sPriv->swrast_loader; ++ ++ loader->putImageShm(dPriv, __DRI_SWRAST_IMAGE_OP_SWAP, ++ x, y, width, height, stride, ++ shmid, shmaddr, offset, dPriv->loaderPrivate); ++} ++ + static inline void + get_image(__DRIdrawable *dPriv, int x, int y, int width, int height, void *data) + { +@@ -112,6 +117,26 @@ get_image2(__DRIdrawable *dPriv, int x, int y, int width, int height, int stride + data, dPriv->loaderPrivate); + } + ++static inline bool ++get_image_shm(__DRIdrawable *dPriv, int x, int y, int width, int height, ++ struct pipe_resource *res) ++{ ++ __DRIscreen *sPriv = dPriv->driScreenPriv; ++ const __DRIswrastLoaderExtension *loader = sPriv->swrast_loader; ++ struct winsys_handle whandle; ++ ++ whandle.type = WINSYS_HANDLE_TYPE_SHMID; ++ ++ if (loader->base.version < 4 || !loader->getImageShm) ++ return FALSE; ++ ++ if (!res->screen->resource_get_handle(res->screen, NULL, res, &whandle, PIPE_HANDLE_USAGE_WRITE)) ++ return FALSE; ++ ++ loader->getImageShm(dPriv, x, y, width, height, whandle.handle, dPriv->loaderPrivate); ++ return TRUE; ++} ++ + static void + drisw_update_drawable_info(struct dri_drawable *drawable) + { +@@ -152,6 +177,17 @@ drisw_put_image2(struct dri_drawable *drawable, + put_image2(dPriv, data, x, y, width, height, stride); + } + ++static inline void ++drisw_put_image_shm(struct dri_drawable *drawable, ++ int shmid, char *shmaddr, unsigned offset, ++ int x, int y, unsigned width, unsigned height, ++ unsigned stride) ++{ ++ __DRIdrawable *dPriv = drawable->dPriv; ++ ++ put_image_shm(dPriv, shmid, shmaddr, offset, x, y, width, height, stride); ++} ++ + static inline void + drisw_present_texture(__DRIdrawable *dPriv, + struct pipe_resource *ptex, struct pipe_box *sub_box) +@@ -348,7 +384,8 @@ drisw_update_tex_buffer(struct dri_drawable *drawable, + x, y, w, h, &transfer); + + /* Copy the Drawable content to the mapped texture buffer */ +- get_image(dPriv, x, y, w, h, map); ++ if (!get_image_shm(dPriv, x, y, w, h, res)) ++ get_image(dPriv, x, y, w, h, map); + + /* The pipe transfer has a pitch rounded up to the nearest 64 pixels. + get_image() has a pitch rounded up to 4 bytes. */ +@@ -394,6 +431,7 @@ static struct drisw_loader_funcs drisw_lf = { + static const __DRIconfig ** + drisw_init_screen(__DRIscreen * sPriv) + { ++ const __DRIswrastLoaderExtension *loader = sPriv->swrast_loader; + const __DRIconfig **configs; + struct dri_screen *screen; + struct pipe_screen *pscreen = NULL; +@@ -409,6 +447,10 @@ drisw_init_screen(__DRIscreen * sPriv) + + sPriv->driverPrivate = (void *)screen; + sPriv->extensions = drisw_screen_extensions; ++ if (loader->base.version >= 4) { ++ if (loader->putImageShm) ++ drisw_lf.put_image_shm = drisw_put_image_shm; ++ } + + if (pipe_loader_sw_probe_dri(&screen->dev, &drisw_lf)) { + dri_init_options(screen); +diff --git a/src/gallium/state_trackers/nine/swapchain9.c b/src/gallium/state_trackers/nine/swapchain9.c +index f24a7d05437..7cf5c54bfa8 100644 +--- a/src/gallium/state_trackers/nine/swapchain9.c ++++ b/src/gallium/state_trackers/nine/swapchain9.c +@@ -96,7 +96,7 @@ D3DWindowBuffer_create(struct NineSwapChain9 *This, + HRESULT hr; + + memset(&whandle, 0, sizeof(whandle)); +- whandle.type = DRM_API_HANDLE_TYPE_FD; ++ whandle.type = WINSYS_HANDLE_TYPE_FD; + This->screen->resource_get_handle(This->screen, pipe, resource, + &whandle, + for_frontbuffer_reading ? +diff --git a/src/gallium/state_trackers/va/buffer.c b/src/gallium/state_trackers/va/buffer.c +index deaeb1939fe..42ec9730fc1 100644 +--- a/src/gallium/state_trackers/va/buffer.c ++++ b/src/gallium/state_trackers/va/buffer.c +@@ -305,7 +305,7 @@ vlVaAcquireBufferHandle(VADriverContextP ctx, VABufferID buf_id, + drv->pipe->flush(drv->pipe, NULL, 0); + + memset(&whandle, 0, sizeof(whandle)); +- whandle.type = DRM_API_HANDLE_TYPE_FD; ++ whandle.type = WINSYS_HANDLE_TYPE_FD; + + if (!screen->resource_get_handle(screen, drv->pipe, + buf->derived_surface.resource, +diff --git a/src/gallium/state_trackers/va/surface.c b/src/gallium/state_trackers/va/surface.c +index f9412ce52e6..432480c458a 100644 +--- a/src/gallium/state_trackers/va/surface.c ++++ b/src/gallium/state_trackers/va/surface.c +@@ -569,7 +569,7 @@ suface_from_external_memory(VADriverContextP ctx, vlVaSurface *surface, + res_templ.usage = PIPE_USAGE_DEFAULT; + + memset(&whandle, 0, sizeof(struct winsys_handle)); +- whandle.type = DRM_API_HANDLE_TYPE_FD; ++ whandle.type = WINSYS_HANDLE_TYPE_FD; + whandle.handle = memory_attibute->buffers[index]; + whandle.stride = memory_attibute->pitches[index]; + +@@ -1034,7 +1034,7 @@ vlVaExportSurfaceHandle(VADriverContextP ctx, + } + + memset(&whandle, 0, sizeof(whandle)); +- whandle.type = DRM_API_HANDLE_TYPE_FD; ++ whandle.type = WINSYS_HANDLE_TYPE_FD; + + if (!screen->resource_get_handle(screen, drv->pipe, resource, + &whandle, usage)) { +diff --git a/src/gallium/state_trackers/vdpau/output.c b/src/gallium/state_trackers/vdpau/output.c +index 8ef826836c1..6ef7a404474 100644 +--- a/src/gallium/state_trackers/vdpau/output.c ++++ b/src/gallium/state_trackers/vdpau/output.c +@@ -805,7 +805,7 @@ VdpStatus vlVdpOutputSurfaceDMABuf(VdpOutputSurface surface, + vlsurface->device->context->flush(vlsurface->device->context, NULL, 0); + + memset(&whandle, 0, sizeof(struct winsys_handle)); +- whandle.type = DRM_API_HANDLE_TYPE_FD; ++ whandle.type = WINSYS_HANDLE_TYPE_FD; + + pscreen = vlsurface->surface->texture->screen; + if (!pscreen->resource_get_handle(pscreen, vlsurface->device->context, +diff --git a/src/gallium/state_trackers/vdpau/surface.c b/src/gallium/state_trackers/vdpau/surface.c +index 012d3036411..95bab8790db 100644 +--- a/src/gallium/state_trackers/vdpau/surface.c ++++ b/src/gallium/state_trackers/vdpau/surface.c +@@ -526,7 +526,7 @@ VdpStatus vlVdpVideoSurfaceDMABuf(VdpVideoSurface surface, + } + + memset(&whandle, 0, sizeof(struct winsys_handle)); +- whandle.type = DRM_API_HANDLE_TYPE_FD; ++ whandle.type = WINSYS_HANDLE_TYPE_FD; + whandle.layer = surf->u.tex.first_layer; + + pscreen = surf->texture->screen; +diff --git a/src/gallium/state_trackers/xa/xa_tracker.c b/src/gallium/state_trackers/xa/xa_tracker.c +index 03a3abf6835..3d268a17750 100644 +--- a/src/gallium/state_trackers/xa/xa_tracker.c ++++ b/src/gallium/state_trackers/xa/xa_tracker.c +@@ -311,12 +311,12 @@ handle_type(enum xa_handle_type type) + { + switch (type) { + case xa_handle_type_kms: +- return DRM_API_HANDLE_TYPE_KMS; ++ return WINSYS_HANDLE_TYPE_KMS; + case xa_handle_type_fd: +- return DRM_API_HANDLE_TYPE_FD; ++ return WINSYS_HANDLE_TYPE_FD; + case xa_handle_type_shared: + default: +- return DRM_API_HANDLE_TYPE_SHARED; ++ return WINSYS_HANDLE_TYPE_SHARED; + } + } + +@@ -404,7 +404,7 @@ xa_surface_from_handle(struct xa_tracker *xa, + uint32_t handle, uint32_t stride) + { + return xa_surface_from_handle2(xa, width, height, depth, stype, xa_format, +- DRM_API_HANDLE_TYPE_SHARED, flags, handle, ++ WINSYS_HANDLE_TYPE_SHARED, flags, handle, + stride); + } + +diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c +index 544403ac84f..b680be7c6ff 100644 +--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c ++++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c +@@ -1275,10 +1275,10 @@ static struct pb_buffer *amdgpu_bo_from_handle(struct radeon_winsys *rws, + } + + switch (whandle->type) { +- case DRM_API_HANDLE_TYPE_SHARED: ++ case WINSYS_HANDLE_TYPE_SHARED: + type = amdgpu_bo_handle_type_gem_flink_name; + break; +- case DRM_API_HANDLE_TYPE_FD: ++ case WINSYS_HANDLE_TYPE_FD: + type = amdgpu_bo_handle_type_dma_buf_fd; + break; + default: +@@ -1362,13 +1362,13 @@ static bool amdgpu_bo_get_handle(struct pb_buffer *buffer, + bo->u.real.use_reusable_pool = false; + + switch (whandle->type) { +- case DRM_API_HANDLE_TYPE_SHARED: ++ case WINSYS_HANDLE_TYPE_SHARED: + type = amdgpu_bo_handle_type_gem_flink_name; + break; +- case DRM_API_HANDLE_TYPE_FD: ++ case WINSYS_HANDLE_TYPE_FD: + type = amdgpu_bo_handle_type_dma_buf_fd; + break; +- case DRM_API_HANDLE_TYPE_KMS: ++ case WINSYS_HANDLE_TYPE_KMS: + type = amdgpu_bo_handle_type_kms; + break; + default: +diff --git a/src/gallium/winsys/i915/drm/i915_drm_buffer.c b/src/gallium/winsys/i915/drm/i915_drm_buffer.c +index 890f7dc2833..509984ac6ac 100644 +--- a/src/gallium/winsys/i915/drm/i915_drm_buffer.c ++++ b/src/gallium/winsys/i915/drm/i915_drm_buffer.c +@@ -98,7 +98,7 @@ i915_drm_buffer_from_handle(struct i915_winsys *iws, + struct i915_drm_buffer *buf; + uint32_t tile = 0, swizzle = 0; + +- if ((whandle->type != DRM_API_HANDLE_TYPE_SHARED) && (whandle->type != DRM_API_HANDLE_TYPE_FD)) ++ if ((whandle->type != WINSYS_HANDLE_TYPE_SHARED) && (whandle->type != WINSYS_HANDLE_TYPE_FD)) + return NULL; + + if (whandle->offset != 0) +@@ -110,9 +110,9 @@ i915_drm_buffer_from_handle(struct i915_winsys *iws, + + buf->magic = 0xDEAD1337; + +- if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) ++ if (whandle->type == WINSYS_HANDLE_TYPE_SHARED) + buf->bo = drm_intel_bo_gem_create_from_name(idws->gem_manager, "gallium3d_from_handle", whandle->handle); +- else if (whandle->type == DRM_API_HANDLE_TYPE_FD) { ++ else if (whandle->type == WINSYS_HANDLE_TYPE_FD) { + int fd = (int) whandle->handle; + buf->bo = drm_intel_bo_gem_create_from_prime(idws->gem_manager, fd, height * whandle->stride); + } +@@ -143,7 +143,7 @@ i915_drm_buffer_get_handle(struct i915_winsys *iws, + { + struct i915_drm_buffer *buf = i915_drm_buffer(buffer); + +- if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { ++ if (whandle->type == WINSYS_HANDLE_TYPE_SHARED) { + if (!buf->flinked) { + if (drm_intel_bo_flink(buf->bo, &buf->flink)) + return FALSE; +@@ -151,9 +151,9 @@ i915_drm_buffer_get_handle(struct i915_winsys *iws, + } + + whandle->handle = buf->flink; +- } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) { ++ } else if (whandle->type == WINSYS_HANDLE_TYPE_KMS) { + whandle->handle = buf->bo->handle; +- } else if (whandle->type == DRM_API_HANDLE_TYPE_FD) { ++ } else if (whandle->type == WINSYS_HANDLE_TYPE_FD) { + int fd; + + if (drm_intel_bo_gem_export_to_prime(buf->bo, &fd)) +diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c +index fc95a98620b..6ed23530ab0 100644 +--- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c ++++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c +@@ -1124,10 +1124,10 @@ static struct pb_buffer *radeon_winsys_bo_from_handle(struct radeon_winsys *rws, + * The list of pairs is guarded by a mutex, of course. */ + mtx_lock(&ws->bo_handles_mutex); + +- if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { ++ if (whandle->type == WINSYS_HANDLE_TYPE_SHARED) { + /* First check if there already is an existing bo for the handle. */ + bo = util_hash_table_get(ws->bo_names, (void*)(uintptr_t)whandle->handle); +- } else if (whandle->type == DRM_API_HANDLE_TYPE_FD) { ++ } else if (whandle->type == WINSYS_HANDLE_TYPE_FD) { + /* We must first get the GEM handle, as fds are unreliable keys */ + r = drmPrimeFDToHandle(ws->fd, whandle->handle, &handle); + if (r) +@@ -1151,7 +1151,7 @@ static struct pb_buffer *radeon_winsys_bo_from_handle(struct radeon_winsys *rws, + goto fail; + } + +- if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { ++ if (whandle->type == WINSYS_HANDLE_TYPE_SHARED) { + struct drm_gem_open open_arg = {}; + memset(&open_arg, 0, sizeof(open_arg)); + /* Open the BO. */ +@@ -1163,7 +1163,7 @@ static struct pb_buffer *radeon_winsys_bo_from_handle(struct radeon_winsys *rws, + handle = open_arg.handle; + size = open_arg.size; + bo->flink_name = whandle->handle; +- } else if (whandle->type == DRM_API_HANDLE_TYPE_FD) { ++ } else if (whandle->type == WINSYS_HANDLE_TYPE_FD) { + size = lseek(whandle->handle, 0, SEEK_END); + /* + * Could check errno to determine whether the kernel is new enough, but +@@ -1268,7 +1268,7 @@ static bool radeon_winsys_bo_get_handle(struct pb_buffer *buffer, + + bo->u.real.use_reusable_pool = false; + +- if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { ++ if (whandle->type == WINSYS_HANDLE_TYPE_SHARED) { + if (!bo->flink_name) { + flink.handle = bo->handle; + +@@ -1283,9 +1283,9 @@ static bool radeon_winsys_bo_get_handle(struct pb_buffer *buffer, + mtx_unlock(&ws->bo_handles_mutex); + } + whandle->handle = bo->flink_name; +- } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) { ++ } else if (whandle->type == WINSYS_HANDLE_TYPE_KMS) { + whandle->handle = bo->handle; +- } else if (whandle->type == DRM_API_HANDLE_TYPE_FD) { ++ } else if (whandle->type == WINSYS_HANDLE_TYPE_FD) { + if (drmPrimeHandleToFD(ws->fd, bo->handle, DRM_CLOEXEC, (int*)&whandle->handle)) + return false; + } +diff --git a/src/gallium/winsys/svga/drm/vmw_screen_dri.c b/src/gallium/winsys/svga/drm/vmw_screen_dri.c +index 2a0ac7b3337..76f29e2aced 100644 +--- a/src/gallium/winsys/svga/drm/vmw_screen_dri.c ++++ b/src/gallium/winsys/svga/drm/vmw_screen_dri.c +@@ -234,11 +234,11 @@ vmw_drm_surface_from_handle(struct svga_winsys_screen *sws, + } + + switch (whandle->type) { +- case DRM_API_HANDLE_TYPE_SHARED: +- case DRM_API_HANDLE_TYPE_KMS: ++ case WINSYS_HANDLE_TYPE_SHARED: ++ case WINSYS_HANDLE_TYPE_KMS: + handle = whandle->handle; + break; +- case DRM_API_HANDLE_TYPE_FD: ++ case WINSYS_HANDLE_TYPE_FD: + ret = drmPrimeFDToHandle(vws->ioctl.drm_fd, whandle->handle, + &handle); + if (ret) { +@@ -263,7 +263,7 @@ vmw_drm_surface_from_handle(struct svga_winsys_screen *sws, + /* + * Need to close the handle we got from prime. + */ +- if (whandle->type == DRM_API_HANDLE_TYPE_FD) ++ if (whandle->type == WINSYS_HANDLE_TYPE_FD) + vmw_ioctl_surface_destroy(vws, handle); + + if (ret) { +@@ -340,11 +340,11 @@ vmw_drm_surface_get_handle(struct svga_winsys_screen *sws, + whandle->offset = 0; + + switch (whandle->type) { +- case DRM_API_HANDLE_TYPE_SHARED: +- case DRM_API_HANDLE_TYPE_KMS: ++ case WINSYS_HANDLE_TYPE_SHARED: ++ case WINSYS_HANDLE_TYPE_KMS: + whandle->handle = vsrf->sid; + break; +- case DRM_API_HANDLE_TYPE_FD: ++ case WINSYS_HANDLE_TYPE_FD: + ret = drmPrimeHandleToFD(vws->ioctl.drm_fd, vsrf->sid, DRM_CLOEXEC, + (int *)&whandle->handle); + if (ret) { +diff --git a/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c b/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c +index 62a2af6d650..16dd5c8593a 100644 +--- a/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c ++++ b/src/gallium/winsys/svga/drm/vmw_screen_ioctl.c +@@ -290,13 +290,13 @@ vmw_ioctl_surface_req(const struct vmw_winsys_screen *vws, + int ret; + + switch(whandle->type) { +- case DRM_API_HANDLE_TYPE_SHARED: +- case DRM_API_HANDLE_TYPE_KMS: ++ case WINSYS_HANDLE_TYPE_SHARED: ++ case WINSYS_HANDLE_TYPE_KMS: + *needs_unref = FALSE; + req->handle_type = DRM_VMW_HANDLE_LEGACY; + req->sid = whandle->handle; + break; +- case DRM_API_HANDLE_TYPE_FD: ++ case WINSYS_HANDLE_TYPE_FD: + if (!vws->ioctl.have_drm_2_6) { + uint32_t handle; + +diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c b/src/gallium/winsys/sw/dri/dri_sw_winsys.c +index 00849985d6b..8335e52200f 100644 +--- a/src/gallium/winsys/sw/dri/dri_sw_winsys.c ++++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c +@@ -26,6 +26,9 @@ + * + **************************************************************************/ + ++#include ++#include ++ + #include "pipe/p_compiler.h" + #include "pipe/p_format.h" + #include "util/u_inlines.h" +@@ -45,6 +48,7 @@ struct dri_sw_displaytarget + unsigned stride; + + unsigned map_flags; ++ int shmid; + void *data; + void *mapped; + const void *front_private; +@@ -79,6 +83,25 @@ dri_sw_is_displaytarget_format_supported( struct sw_winsys *ws, + return TRUE; + } + ++static char * ++alloc_shm(struct dri_sw_displaytarget *dri_sw_dt, unsigned size) ++{ ++ char *addr; ++ ++ dri_sw_dt->shmid = shmget(IPC_PRIVATE, size, IPC_CREAT|0777); ++ if (dri_sw_dt->shmid < 0) ++ return NULL; ++ ++ addr = (char *) shmat(dri_sw_dt->shmid, 0, 0); ++ /* mark the segment immediately for deletion to avoid leaks */ ++ shmctl(dri_sw_dt->shmid, IPC_RMID, 0); ++ ++ if (addr == (char *) -1) ++ return NULL; ++ ++ return addr; ++} ++ + static struct sw_displaytarget * + dri_sw_displaytarget_create(struct sw_winsys *winsys, + unsigned tex_usage, +@@ -88,6 +111,7 @@ dri_sw_displaytarget_create(struct sw_winsys *winsys, + const void *front_private, + unsigned *stride) + { ++ struct dri_sw_winsys *ws = dri_sw_winsys(winsys); + struct dri_sw_displaytarget *dri_sw_dt; + unsigned nblocksy, size, format_stride; + +@@ -106,7 +130,13 @@ dri_sw_displaytarget_create(struct sw_winsys *winsys, + nblocksy = util_format_get_nblocksy(format, height); + size = dri_sw_dt->stride * nblocksy; + +- dri_sw_dt->data = align_malloc(size, alignment); ++ dri_sw_dt->shmid = -1; ++ if (ws->lf->put_image_shm) ++ dri_sw_dt->data = alloc_shm(dri_sw_dt, size); ++ ++ if(!dri_sw_dt->data) ++ dri_sw_dt->data = align_malloc(size, alignment); ++ + if(!dri_sw_dt->data) + goto no_data; + +@@ -125,7 +155,12 @@ dri_sw_displaytarget_destroy(struct sw_winsys *ws, + { + struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt); + +- align_free(dri_sw_dt->data); ++ if (dri_sw_dt->shmid >= 0) { ++ shmdt(dri_sw_dt->data); ++ shmctl(dri_sw_dt->shmid, IPC_RMID, 0); ++ } else { ++ align_free(dri_sw_dt->data); ++ } + + FREE(dri_sw_dt); + } +@@ -174,7 +209,15 @@ dri_sw_displaytarget_get_handle(struct sw_winsys *winsys, + struct sw_displaytarget *dt, + struct winsys_handle *whandle) + { +- assert(0); ++ struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt); ++ ++ if (whandle->type == WINSYS_HANDLE_TYPE_SHMID) { ++ if (dri_sw_dt->shmid < 0) ++ return FALSE; ++ whandle->handle = dri_sw_dt->shmid; ++ return TRUE; ++ } ++ + return FALSE; + } + +@@ -187,25 +230,38 @@ dri_sw_displaytarget_display(struct sw_winsys *ws, + struct dri_sw_winsys *dri_sw_ws = dri_sw_winsys(ws); + struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt); + struct dri_drawable *dri_drawable = (struct dri_drawable *)context_private; +- unsigned width, height; ++ unsigned width, height, x = 0, y = 0; + unsigned blsize = util_format_get_blocksize(dri_sw_dt->format); ++ unsigned offset = 0; ++ void *data = dri_sw_dt->data; + + /* Set the width to 'stride / cpp'. + * + * PutImage correctly clips to the width of the dst drawable. + */ +- width = dri_sw_dt->stride / blsize; +- +- height = dri_sw_dt->height; +- + if (box) { +- void *data; +- data = (char *)dri_sw_dt->data + (dri_sw_dt->stride * box->y) + box->x * blsize; +- dri_sw_ws->lf->put_image2(dri_drawable, data, +- box->x, box->y, box->width, box->height, dri_sw_dt->stride); ++ offset = (dri_sw_dt->stride * box->y) + box->x * blsize; ++ data += offset; ++ x = box->x; ++ y = box->y; ++ width = box->width; ++ height = box->height; + } else { +- dri_sw_ws->lf->put_image(dri_drawable, dri_sw_dt->data, width, height); ++ width = dri_sw_dt->stride / blsize; ++ height = dri_sw_dt->height; + } ++ ++ if (dri_sw_dt->shmid != -1) { ++ dri_sw_ws->lf->put_image_shm(dri_drawable, dri_sw_dt->shmid, dri_sw_dt->data, offset, ++ x, y, width, height, dri_sw_dt->stride); ++ return; ++ } ++ ++ if (box) ++ dri_sw_ws->lf->put_image2(dri_drawable, data, ++ x, y, width, height, dri_sw_dt->stride); ++ else ++ dri_sw_ws->lf->put_image(dri_drawable, data, width, height); + } + + static void +diff --git a/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c b/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c +index 22e1c936ac5..2df5f589e48 100644 +--- a/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c ++++ b/src/gallium/winsys/sw/kms-dri/kms_dri_sw_winsys.c +@@ -292,8 +292,8 @@ kms_sw_displaytarget_from_handle(struct sw_winsys *ws, + struct kms_sw_winsys *kms_sw = kms_sw_winsys(ws); + struct kms_sw_displaytarget *kms_sw_dt; + +- assert(whandle->type == DRM_API_HANDLE_TYPE_KMS || +- whandle->type == DRM_API_HANDLE_TYPE_FD); ++ assert(whandle->type == WINSYS_HANDLE_TYPE_KMS || ++ whandle->type == WINSYS_HANDLE_TYPE_FD); + + if (whandle->offset != 0) { + DEBUG_PRINT("KMS-DEBUG: attempt to import unsupported winsys offset %d\n", +@@ -302,7 +302,7 @@ kms_sw_displaytarget_from_handle(struct sw_winsys *ws, + } + + switch(whandle->type) { +- case DRM_API_HANDLE_TYPE_FD: ++ case WINSYS_HANDLE_TYPE_FD: + kms_sw_dt = kms_sw_displaytarget_add_from_prime(kms_sw, whandle->handle, + templ->width0, + templ->height0, +@@ -310,7 +310,7 @@ kms_sw_displaytarget_from_handle(struct sw_winsys *ws, + if (kms_sw_dt) + *stride = kms_sw_dt->stride; + return (struct sw_displaytarget *)kms_sw_dt; +- case DRM_API_HANDLE_TYPE_KMS: ++ case WINSYS_HANDLE_TYPE_KMS: + kms_sw_dt = kms_sw_displaytarget_find_and_ref(kms_sw, whandle->handle); + if (kms_sw_dt) { + *stride = kms_sw_dt->stride; +@@ -334,12 +334,12 @@ kms_sw_displaytarget_get_handle(struct sw_winsys *winsys, + struct kms_sw_displaytarget *kms_sw_dt = kms_sw_displaytarget(dt); + + switch(whandle->type) { +- case DRM_API_HANDLE_TYPE_KMS: ++ case WINSYS_HANDLE_TYPE_KMS: + whandle->handle = kms_sw_dt->handle; + whandle->stride = kms_sw_dt->stride; + whandle->offset = 0; + return TRUE; +- case DRM_API_HANDLE_TYPE_FD: ++ case WINSYS_HANDLE_TYPE_FD: + if (!drmPrimeHandleToFD(kms_sw->fd, kms_sw_dt->handle, + DRM_CLOEXEC, (int*)&whandle->handle)) { + whandle->stride = kms_sw_dt->stride; +diff --git a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c +index 71e652ebf31..cd16413bb8e 100644 +--- a/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c ++++ b/src/gallium/winsys/virgl/drm/virgl_drm_winsys.c +@@ -398,7 +398,7 @@ virgl_drm_winsys_resource_create_handle(struct virgl_winsys *qws, + + mtx_lock(&qdws->bo_handles_mutex); + +- if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { ++ if (whandle->type == WINSYS_HANDLE_TYPE_SHARED) { + res = util_hash_table_get(qdws->bo_names, (void*)(uintptr_t)handle); + if (res) { + struct virgl_hw_res *r = NULL; +@@ -407,7 +407,7 @@ virgl_drm_winsys_resource_create_handle(struct virgl_winsys *qws, + } + } + +- if (whandle->type == DRM_API_HANDLE_TYPE_FD) { ++ if (whandle->type == WINSYS_HANDLE_TYPE_FD) { + int r; + r = drmPrimeFDToHandle(qdws->fd, whandle->handle, &handle); + if (r) { +@@ -428,7 +428,7 @@ virgl_drm_winsys_resource_create_handle(struct virgl_winsys *qws, + if (!res) + goto done; + +- if (whandle->type == DRM_API_HANDLE_TYPE_FD) { ++ if (whandle->type == WINSYS_HANDLE_TYPE_FD) { + res->bo_handle = handle; + } else { + fprintf(stderr, "gem open handle %d\n", handle); +@@ -478,7 +478,7 @@ static boolean virgl_drm_winsys_resource_get_handle(struct virgl_winsys *qws, + if (!res) + return FALSE; + +- if (whandle->type == DRM_API_HANDLE_TYPE_SHARED) { ++ if (whandle->type == WINSYS_HANDLE_TYPE_SHARED) { + if (!res->flinked) { + memset(&flink, 0, sizeof(flink)); + flink.handle = res->bo_handle; +@@ -494,9 +494,9 @@ static boolean virgl_drm_winsys_resource_get_handle(struct virgl_winsys *qws, + mtx_unlock(&qdws->bo_handles_mutex); + } + whandle->handle = res->flink; +- } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) { ++ } else if (whandle->type == WINSYS_HANDLE_TYPE_KMS) { + whandle->handle = res->bo_handle; +- } else if (whandle->type == DRM_API_HANDLE_TYPE_FD) { ++ } else if (whandle->type == WINSYS_HANDLE_TYPE_FD) { + if (drmPrimeHandleToFD(qdws->fd, res->bo_handle, DRM_CLOEXEC, (int*)&whandle->handle)) + return FALSE; + mtx_lock(&qdws->bo_handles_mutex); +diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c +index df2467a5c2d..a2777100a32 100644 +--- a/src/glx/drisw_glx.c ++++ b/src/glx/drisw_glx.c +@@ -28,10 +28,12 @@ + #include + #include "dri_common.h" + #include "drisw_priv.h" ++#include ++#include + + static Bool +-XCreateDrawable(struct drisw_drawable * pdp, +- Display * dpy, XID drawable, int visualid) ++XCreateGCs(struct drisw_drawable * pdp, ++ Display * dpy, XID drawable, int visualid) + { + XGCValues gcvalues; + long visMask; +@@ -56,15 +58,78 @@ XCreateDrawable(struct drisw_drawable * pdp, + if (!pdp->visinfo || num_visuals == 0) + return False; + +- /* create XImage */ +- pdp->ximage = XCreateImage(dpy, +- pdp->visinfo->visual, +- pdp->visinfo->depth, +- ZPixmap, 0, /* format, offset */ +- NULL, /* data */ +- 0, 0, /* width, height */ +- 32, /* bitmap_pad */ +- 0); /* bytes_per_line */ ++ return True; ++} ++ ++static int xshm_error = 0; ++static int xshm_opcode = -1; ++ ++/** ++ * Catches potential Xlib errors. ++ */ ++static int ++handle_xerror(Display *dpy, XErrorEvent *event) ++{ ++ (void) dpy; ++ ++ assert(xshm_opcode != -1); ++ if (event->request_code != xshm_opcode || ++ event->minor_code != X_ShmAttach) ++ return 0; ++ ++ xshm_error = 1; ++ return 0; ++} ++ ++static Bool ++XCreateDrawable(struct drisw_drawable * pdp, int shmid, Display * dpy) ++{ ++ if (pdp->ximage) { ++ XDestroyImage(pdp->ximage); ++ pdp->ximage = NULL; ++ } ++ ++ if (!xshm_error && shmid >= 0) { ++ pdp->shminfo.shmid = shmid; ++ pdp->ximage = XShmCreateImage(dpy, ++ pdp->visinfo->visual, ++ pdp->visinfo->depth, ++ ZPixmap, /* format */ ++ NULL, /* data */ ++ &pdp->shminfo, /* shminfo */ ++ 0, 0); /* width, height */ ++ if (pdp->ximage != NULL) { ++ int (*old_handler)(Display *, XErrorEvent *); ++ ++ /* dispatch pending errors */ ++ XSync(dpy, False); ++ ++ old_handler = XSetErrorHandler(handle_xerror); ++ /* This may trigger the X protocol error we're ready to catch: */ ++ XShmAttach(dpy, &pdp->shminfo); ++ XSync(dpy, False); ++ ++ if (xshm_error) { ++ /* we are on a remote display, this error is normal, don't print it */ ++ XDestroyImage(pdp->ximage); ++ pdp->ximage = NULL; ++ } ++ ++ (void) XSetErrorHandler(old_handler); ++ } ++ } ++ ++ if (pdp->ximage == NULL) { ++ pdp->shminfo.shmid = -1; ++ pdp->ximage = XCreateImage(dpy, ++ pdp->visinfo->visual, ++ pdp->visinfo->depth, ++ ZPixmap, 0, /* format, offset */ ++ NULL, /* data */ ++ 0, 0, /* width, height */ ++ 32, /* bitmap_pad */ ++ 0); /* bytes_per_line */ ++ } + + /** + * swrast does not handle 24-bit depth with 24 bpp, so let X do the +@@ -79,7 +144,9 @@ XCreateDrawable(struct drisw_drawable * pdp, + static void + XDestroyDrawable(struct drisw_drawable * pdp, Display * dpy, XID drawable) + { +- XDestroyImage(pdp->ximage); ++ if (pdp->ximage) ++ XDestroyImage(pdp->ximage); ++ + free(pdp->visinfo); + + XFreeGC(dpy, pdp->gc); +@@ -133,9 +200,9 @@ bytes_per_line(unsigned pitch_bits, unsigned mul) + } + + static void +-swrastPutImage2(__DRIdrawable * draw, int op, ++swrastXPutImage(__DRIdrawable * draw, int op, + int x, int y, int w, int h, int stride, +- char *data, void *loaderPrivate) ++ int shmid, char *data, void *loaderPrivate) + { + struct drisw_drawable *pdp = loaderPrivate; + __GLXDRIdrawable *pdraw = &(pdp->base); +@@ -144,6 +211,11 @@ swrastPutImage2(__DRIdrawable * draw, int op, + XImage *ximage; + GC gc; + ++ if (!pdp->ximage || shmid != pdp->shminfo.shmid) { ++ if (!XCreateDrawable(pdp, shmid, dpy)) ++ return; ++ } ++ + switch (op) { + case __DRI_SWRAST_IMAGE_OP_DRAW: + gc = pdp->gc; +@@ -156,24 +228,52 @@ swrastPutImage2(__DRIdrawable * draw, int op, + } + + drawable = pdraw->xDrawable; +- + ximage = pdp->ximage; +- ximage->data = data; +- ximage->width = w; +- ximage->height = h; + ximage->bytes_per_line = stride ? stride : bytes_per_line(w * ximage->bits_per_pixel, 32); ++ ximage->data = data; + +- XPutImage(dpy, drawable, gc, ximage, 0, 0, x, y, w, h); +- ++ if (pdp->shminfo.shmid >= 0) { ++ ximage->width = ximage->bytes_per_line / ((ximage->bits_per_pixel + 7)/ 8); ++ ximage->height = h; ++ XShmPutImage(dpy, drawable, gc, ximage, 0, 0, x, y, w, h, False); ++ XSync(dpy, False); ++ } else { ++ ximage->width = w; ++ ximage->height = h; ++ XPutImage(dpy, drawable, gc, ximage, 0, 0, x, y, w, h); ++ } + ximage->data = NULL; + } + ++static void ++swrastPutImageShm(__DRIdrawable * draw, int op, ++ int x, int y, int w, int h, int stride, ++ int shmid, char *shmaddr, unsigned offset, ++ void *loaderPrivate) ++{ ++ struct drisw_drawable *pdp = loaderPrivate; ++ ++ pdp->shminfo.shmaddr = shmaddr; ++ swrastXPutImage(draw, op, x, y, w, h, stride, shmid, ++ shmaddr + offset, loaderPrivate); ++} ++ ++static void ++swrastPutImage2(__DRIdrawable * draw, int op, ++ int x, int y, int w, int h, int stride, ++ char *data, void *loaderPrivate) ++{ ++ swrastXPutImage(draw, op, x, y, w, h, stride, -1, ++ data, loaderPrivate); ++} ++ + static void + swrastPutImage(__DRIdrawable * draw, int op, + int x, int y, int w, int h, + char *data, void *loaderPrivate) + { +- swrastPutImage2(draw, op, x, y, w, h, 0, data, loaderPrivate); ++ swrastXPutImage(draw, op, x, y, w, h, 0, -1, ++ data, loaderPrivate); + } + + static void +@@ -187,6 +287,11 @@ swrastGetImage2(__DRIdrawable * read, + Drawable readable; + XImage *ximage; + ++ if (!prp->ximage || prp->shminfo.shmid >= 0) { ++ if (!XCreateDrawable(prp, -1, dpy)) ++ return; ++ } ++ + readable = pread->xDrawable; + + ximage = prp->ximage; +@@ -208,6 +313,49 @@ swrastGetImage(__DRIdrawable * read, + swrastGetImage2(read, x, y, w, h, 0, data, loaderPrivate); + } + ++static void ++swrastGetImageShm(__DRIdrawable * read, ++ int x, int y, int w, int h, ++ int shmid, void *loaderPrivate) ++{ ++ struct drisw_drawable *prp = loaderPrivate; ++ __GLXDRIdrawable *pread = &(prp->base); ++ Display *dpy = pread->psc->dpy; ++ Drawable readable; ++ XImage *ximage; ++ ++ if (!prp->ximage || shmid != prp->shminfo.shmid) { ++ if (!XCreateDrawable(prp, shmid, dpy)) ++ return; ++ } ++ readable = pread->xDrawable; ++ ++ ximage = prp->ximage; ++ ximage->data = prp->shminfo.shmaddr; /* no offset */ ++ ximage->width = w; ++ ximage->height = h; ++ ximage->bytes_per_line = bytes_per_line(w * ximage->bits_per_pixel, 32); ++ ++ XShmGetImage(dpy, readable, ximage, x, y, ~0L); ++} ++ ++static const __DRIswrastLoaderExtension swrastLoaderExtension_shm = { ++ .base = {__DRI_SWRAST_LOADER, 4 }, ++ ++ .getDrawableInfo = swrastGetDrawableInfo, ++ .putImage = swrastPutImage, ++ .getImage = swrastGetImage, ++ .putImage2 = swrastPutImage2, ++ .getImage2 = swrastGetImage2, ++ .putImageShm = swrastPutImageShm, ++ .getImageShm = swrastGetImageShm, ++}; ++ ++static const __DRIextension *loader_extensions_shm[] = { ++ &swrastLoaderExtension_shm.base, ++ NULL ++}; ++ + static const __DRIswrastLoaderExtension swrastLoaderExtension = { + .base = {__DRI_SWRAST_LOADER, 3 }, + +@@ -218,7 +366,7 @@ static const __DRIswrastLoaderExtension swrastLoaderExtension = { + .getImage2 = swrastGetImage2, + }; + +-static const __DRIextension *loader_extensions[] = { ++static const __DRIextension *loader_extensions_noshm[] = { + &swrastLoaderExtension.base, + NULL + }; +@@ -527,7 +675,7 @@ driswCreateDrawable(struct glx_screen *base, XID xDrawable, + pdp->base.drawable = drawable; + pdp->base.psc = &psc->base; + +- ret = XCreateDrawable(pdp, psc->base.dpy, xDrawable, modes->visualID); ++ ret = XCreateGCs(pdp, psc->base.dpy, xDrawable, modes->visualID); + if (!ret) { + free(pdp); + return NULL; +@@ -661,6 +809,14 @@ driswBindExtensions(struct drisw_screen *psc, const __DRIextension **extensions) + } + } + ++static int ++check_xshm(Display *dpy) ++{ ++ int ignore; ++ ++ return XQueryExtension(dpy, "MIT-SHM", &xshm_opcode, &ignore, &ignore); ++} ++ + static struct glx_screen * + driswCreateScreen(int screen, struct glx_display *priv) + { +@@ -670,6 +826,7 @@ driswCreateScreen(int screen, struct glx_display *priv) + struct drisw_screen *psc; + struct glx_config *configs = NULL, *visuals = NULL; + int i; ++ const __DRIextension **loader_extensions_local; + + psc = calloc(1, sizeof *psc); + if (psc == NULL) +@@ -688,6 +845,11 @@ driswCreateScreen(int screen, struct glx_display *priv) + if (extensions == NULL) + goto handle_error; + ++ if (!check_xshm(psc->base.dpy)) ++ loader_extensions_local = loader_extensions_noshm; ++ else ++ loader_extensions_local = loader_extensions_shm; ++ + for (i = 0; extensions[i]; i++) { + if (strcmp(extensions[i]->name, __DRI_CORE) == 0) + psc->core = (__DRIcoreExtension *) extensions[i]; +@@ -704,12 +866,12 @@ driswCreateScreen(int screen, struct glx_display *priv) + + if (psc->swrast->base.version >= 4) { + psc->driScreen = +- psc->swrast->createNewScreen2(screen, loader_extensions, ++ psc->swrast->createNewScreen2(screen, loader_extensions_local, + extensions, + &driver_configs, psc); + } else { + psc->driScreen = +- psc->swrast->createNewScreen(screen, loader_extensions, ++ psc->swrast->createNewScreen(screen, loader_extensions_local, + &driver_configs, psc); + } + if (psc->driScreen == NULL) { +diff --git a/src/glx/drisw_priv.h b/src/glx/drisw_priv.h +index 5d479003114..a670da2d33b 100644 +--- a/src/glx/drisw_priv.h ++++ b/src/glx/drisw_priv.h +@@ -23,6 +23,8 @@ + * SOFTWARE. + */ + ++#include ++ + struct drisw_display + { + __GLXDRIdisplay base; +@@ -62,6 +64,7 @@ struct drisw_drawable + __DRIdrawable *driDrawable; + XVisualInfo *visinfo; + XImage *ximage; ++ XShmSegmentInfo shminfo; + }; + + _X_HIDDEN int +diff --git a/src/mesa/state_tracker/st_cb_memoryobjects.c b/src/mesa/state_tracker/st_cb_memoryobjects.c +index 63a8c2a0e00..39174bc9f75 100644 +--- a/src/mesa/state_tracker/st_cb_memoryobjects.c ++++ b/src/mesa/state_tracker/st_cb_memoryobjects.c +@@ -65,7 +65,7 @@ st_import_memoryobj_fd(struct gl_context *ctx, + struct pipe_screen *screen = pipe->screen; + struct winsys_handle whandle; + +- whandle.type = DRM_API_HANDLE_TYPE_FD; ++ whandle.type = WINSYS_HANDLE_TYPE_FD; + whandle.handle = fd; + whandle.offset = 0; + whandle.layer = 0; +diff --git a/src/mesa/state_tracker/st_vdpau.c b/src/mesa/state_tracker/st_vdpau.c +index eb61aef1116..d0b9cfbf4f8 100644 +--- a/src/mesa/state_tracker/st_vdpau.c ++++ b/src/mesa/state_tracker/st_vdpau.c +@@ -127,7 +127,7 @@ st_vdpau_resource_from_description(struct gl_context *ctx, + templ.usage = PIPE_USAGE_DEFAULT; + + memset(&whandle, 0, sizeof(whandle)); +- whandle.type = DRM_API_HANDLE_TYPE_FD; ++ whandle.type = WINSYS_HANDLE_TYPE_FD; + whandle.handle = desc->handle; + whandle.offset = desc->offset; + whandle.stride = desc->stride; diff --git a/SOURCES/fix-timeout-warnings.patch b/SOURCES/fix-timeout-warnings.patch new file mode 100644 index 0000000..e0c7bf7 --- /dev/null +++ b/SOURCES/fix-timeout-warnings.patch @@ -0,0 +1,39 @@ +diff -up mesa-20180530/src/gallium/drivers/r600/Makefile.am.dma mesa-20180530/src/gallium/drivers/r600/Makefile.am +--- mesa-20180530/src/gallium/drivers/r600/Makefile.am.dma 2018-07-19 10:24:26.110829986 +1000 ++++ mesa-20180530/src/gallium/drivers/r600/Makefile.am 2018-07-19 10:24:44.569297131 +1000 +@@ -10,7 +10,8 @@ AM_CFLAGS = \ + $(GALLIUM_DRIVER_CFLAGS) \ + $(RADEON_CFLAGS) \ + $(LIBELF_CFLAGS) \ +- -I$(top_srcdir)/src/amd/common ++ -I$(top_srcdir)/src/amd/common \ ++ -Wstrict-overflow=0 + + AM_CXXFLAGS = \ + $(GALLIUM_DRIVER_CXXFLAGS) \ +diff -up mesa-20180530/src/gallium/winsys/virgl/drm/Makefile.am.dma mesa-20180530/src/gallium/winsys/virgl/drm/Makefile.am +--- mesa-20180530/src/gallium/winsys/virgl/drm/Makefile.am.dma 2018-07-19 10:25:13.089018307 +1000 ++++ mesa-20180530/src/gallium/winsys/virgl/drm/Makefile.am 2018-07-19 10:25:34.775566694 +1000 +@@ -26,7 +26,8 @@ include $(top_srcdir)/src/gallium/Automa + AM_CFLAGS = \ + -I$(top_srcdir)/src/gallium/drivers \ + $(GALLIUM_WINSYS_CFLAGS) \ +- $(LIBDRM_CFLAGS) ++ $(LIBDRM_CFLAGS) \ ++ -Wstrict-overflow=0 + + noinst_LTLIBRARIES = libvirgldrm.la + +diff -up mesa-20180530/src/gallium/winsys/virgl/vtest/Makefile.am.dma mesa-20180530/src/gallium/winsys/virgl/vtest/Makefile.am +--- mesa-20180530/src/gallium/winsys/virgl/vtest/Makefile.am.dma 2018-07-19 10:25:48.521914297 +1000 ++++ mesa-20180530/src/gallium/winsys/virgl/vtest/Makefile.am 2018-07-19 10:26:05.622346714 +1000 +@@ -25,7 +25,8 @@ include $(top_srcdir)/src/gallium/Automa + + AM_CFLAGS = \ + -I$(top_srcdir)/src/gallium/drivers \ +- $(GALLIUM_WINSYS_CFLAGS) ++ $(GALLIUM_WINSYS_CFLAGS) \ ++ -Wstrict-overflow=0 + + noinst_LTLIBRARIES = libvirglvtest.la + diff --git a/SOURCES/make-git-snapshot.sh b/SOURCES/make-git-snapshot.sh index 0d774f8..4d1f635 100755 --- a/SOURCES/make-git-snapshot.sh +++ b/SOURCES/make-git-snapshot.sh @@ -15,11 +15,11 @@ DIRNAME=mesa-$( date +%Y%m%d ) echo REF ${REF:+--reference $REF} echo DIRNAME $DIRNAME -echo HEAD ${1:-17.2} +echo HEAD ${1:-18.0} rm -rf $DIRNAME -git clone --depth 1 ${REF:+--reference $REF} --branch 17.2 \ +git clone --depth 1 ${REF:+--reference $REF} --branch 18.0 \ git://git.freedesktop.org/git/mesa/mesa $DIRNAME GIT_DIR=$DIRNAME/.git git archive --format=tar --prefix=$DIRNAME/ ${1:-HEAD} \ diff --git a/SOURCES/mesa-17.3-final.patch b/SOURCES/mesa-17.3-final.patch deleted file mode 100644 index b1e75b5..0000000 --- a/SOURCES/mesa-17.3-final.patch +++ /dev/null @@ -1,194 +0,0 @@ -diff --git a/VERSION b/VERSION -index d3b2c4f..afbe633 100644 ---- a/VERSION -+++ b/VERSION -@@ -1 +1 @@ --17.2.2 -+17.2.3 -diff --git a/docs/relnotes/17.2.3.html b/docs/relnotes/17.2.3.html -new file mode 100644 -index 0000000..6e2aea6 ---- /dev/null -+++ b/docs/relnotes/17.2.3.html -@@ -0,0 +1,181 @@ -+ -+ -+ -+ -+ Mesa Release Notes -+ -+ -+ -+ -+
-+

The Mesa 3D Graphics Library

-+
-+ -+ -+
-+ -+

Mesa 17.2.3 Release Notes / October 19, 2017

-+ -+

-+Mesa 17.2.3 is a bug fix release which fixes bugs found since the 17.2.2 release. -+

-+

-+Mesa 17.2.3 implements the OpenGL 4.5 API, but the version reported by -+glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) / -+glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver being used. -+Some drivers don't support all the features required in OpenGL 4.5. OpenGL -+4.5 is only available if requested at context creation -+because compatibility contexts are not supported. -+

-+ -+ -+

SHA256 checksums

-+
-+fb305eecfeec1fd771fdc96fff973c51871f7bd35fd2bd56cacc27b4b8823220  mesa-17.2.3.tar.gz
-+a0b0ec8f7b24dd044d7ab30a8c7e6d3767521e245f88d4ed5dd93315dc56f837  mesa-17.2.3.tar.xz
-+
-+ -+ -+

New features

-+

None

-+ -+ -+

Bug fixes

-+ -+
    -+ -+
  • Bug 101832 - [PATCH][regression][bisect] Xorg fails to start after f50aa21456d82c8cb6fbaa565835f1acc1720a5d
  • -+ -+
  • Bug 102852 - Scons: Support the new Scons 3.0.0
  • -+ -+
  • Bug 102940 - Regression: Vulkan KMS rendering crashes since 17.2
  • -+ -+
-+ -+ -+

Changes

-+ -+

Alex Smith (1):

-+
    -+
  • radv: Add R16G16B16A16_SNORM fast clear support
  • -+
-+ -+

Bas Nieuwenhuizen (2):

-+
    -+
  • nir/spirv: Allow loop breaks in a switch body.
  • -+
  • radv: Only set the MTYPE flags on GFX9+.
  • -+
-+ -+

Ben Crocker (4):

-+
    -+
  • gallivm: fix typo in debug_printf message
  • -+
  • gallivm: allow additional llc options
  • -+
  • gallivm/ppc64le: adjust VSX code generation control.
  • -+
  • gallivm/ppc64le: allow environmental control of Altivec code generation
  • -+
-+ -+

Daniel Stone (2):

-+
    -+
  • egl/wayland: Check queryImage return for wl_buffer
  • -+
  • egl/wayland: Don't use dmabuf with no modifiers
  • -+
-+ -+

Dave Airlie (2):

-+
    -+
  • radv: emit fmuladd instead of fma to llvm.
  • -+
  • radv: lower ffma in nir.
  • -+
-+ -+

Emil Velikov (6):

-+
    -+
  • cherry-ignore: add "anv: Remove unreachable cases from isl_format_for_size"
  • -+
  • cherry-ignore: add "anv/wsi: Allocate enough memory for the entire image"
  • -+
  • swr/rast: do not crash on NULL strings returned by getenv
  • -+
  • wayland-drm: use a copy of the wayland_drm_callbacks struct
  • -+
  • eglmesaext: add forward declaration for struct wl_buffers
  • -+
  • Update version to 17.2.3
  • -+
-+ -+

Eric Engestrom (1):

-+
    -+
  • scons: use python3-compatible print()
  • -+
-+ -+

Ilia Mirkin (2):

-+
    -+
  • nv50/ir: fix 64-bit integer shifts
  • -+
  • nv50,nvc0: fix push hint logic in presence of a start offset
  • -+
-+ -+

Jason Ekstrand (6):

-+
    -+
  • intel/compiler: Don't cmod propagate into a saturated operation
  • -+
  • intel/compiler: Don't propagate cmod into integer multiplies
  • -+
  • glsl/blob: Return false from ensure_can_read on overrun
  • -+
  • glsl/blob: Return false from grow_to_fit if we've ever failed
  • -+
  • nir/opcodes: Fix constant-folding of ufind_msb
  • -+
  • nir: Get rid of the variable on vote intrinsics
  • -+
-+ -+

Juan A. Suarez Romero (1):

-+
    -+
  • docs: add sha256 checksums for 17.2.2
  • -+
-+ -+

Józef Kucia (3):

-+
    -+
  • anv: Fix vkCmdFillBuffer()
  • -+
  • spirv: Fix SpvOpAtomicISub
  • -+
  • anv: Do not assert() on VK_ATTACHMENT_UNUSED
  • -+
-+ -+

Leo Liu (3):

-+
    -+
  • st/va: use pipe transfer_map to map upload buffer
  • -+
  • st/vdpau: don't re-allocate interlaced buffer with packed YUV format
  • -+
  • st/va: don't re-allocate interlaced buffer with pakced format
  • -+
-+ -+

Lionel Landwerlin (4):

-+
    -+
  • intel: compiler: vec4: add missing default 0 lod
  • -+
  • anv/cmd_buffer: fix push descriptors with set > 0
  • -+
  • anv/cmd_buffer: Reset state in cmd_buffer_destroy
  • -+
  • anv: bo_cache: allow importing a BO larger than needed
  • -+
-+ -+

Marek Olšák (3):

-+
    -+
  • mesa: fix texture updates for ATI_fragment_shader
  • -+
  • st/mesa: don't use pipe_surface for passing information about EGLImage
  • -+
  • glsl_to_tgsi: fix instruction order for bindless textures
  • -+
-+ -+

Nicolai Hähnle (14):

-+
    -+
  • st/glsl_to_tgsi: fix conditional assignments to packed shader outputs
  • -+
  • amd/common: fix build_cube_select
  • -+
  • radeonsi/gfx9: fix geometry shaders without output vertices
  • -+
  • util/queue: fix a race condition in the fence code
  • -+
  • glsl/lower_instruction: handle denorms and overflow in ldexp correctly
  • -+
  • radeonsi: move current_rast_prim to r600_common_context
  • -+
  • radeonsi: don't discard points and lines
  • -+
  • radeonsi: deduce rast_prim correctly for tessellation point mode
  • -+
  • radeonsi: fix maximum advertised point size / line width
  • -+
  • st/mesa: don't clobber glGetInternalformat* buffer for GL_NUM_SAMPLE_COUNTS
  • -+
  • st/glsl_to_tgsi: fix indirect access to 64-bit integer
  • -+
  • st/glsl_to_tgsi: fix a use-after-free in merge_two_dsts
  • -+
  • radeonsi: clamp depth comparison value only for fixed point formats
  • -+
  • radeonsi: clamp border colors for upgraded depth textures
  • -+
-+ -+

Rob Clark (2):

-+
    -+
  • freedreno/a5xx: align height to GMEM
  • -+
  • freedreno/a5xx: fix missing restore state
  • -+
-+ -+ -+
-+ -+ diff --git a/SOURCES/mesa-8.0-llvmpipe-shmget.patch b/SOURCES/mesa-8.0-llvmpipe-shmget.patch deleted file mode 100644 index 347ad16..0000000 --- a/SOURCES/mesa-8.0-llvmpipe-shmget.patch +++ /dev/null @@ -1,156 +0,0 @@ -diff -up mesa-20120424/src/gallium/state_trackers/dri/sw/drisw.c.jx mesa-20120424/src/gallium/state_trackers/dri/sw/drisw.c ---- mesa-20120424/src/gallium/state_trackers/dri/sw/drisw.c.jx 2012-04-24 07:37:03.000000000 -0400 -+++ mesa-20120424/src/gallium/state_trackers/dri/sw/drisw.c 2012-05-16 13:30:36.596312047 -0400 -@@ -252,8 +252,6 @@ drisw_update_tex_buffer(struct dri_drawa - struct pipe_transfer *transfer; - char *map; - int x, y, w, h; -- int ximage_stride, line; -- int cpp = util_format_get_blocksize(res->format); - - get_drawable_info(dPriv, &x, &y, &w, &h); - -@@ -266,14 +264,6 @@ drisw_update_tex_buffer(struct dri_drawa - /* Copy the Drawable content to the mapped texture buffer */ - get_image(dPriv, x, y, w, h, map); - -- /* The pipe transfer has a pitch rounded up to the nearest 64 pixels. */ -- ximage_stride = w * cpp; -- for (line = h-1; line; --line) { -- memmove(&map[line * transfer->stride], -- &map[line * ximage_stride], -- ximage_stride); -- } -- - pipe_transfer_unmap(pipe, transfer); - pipe_transfer_destroy(pipe, transfer); - } -diff -up mesa-20120424/src/glx/drisw_glx.c.jx mesa-20120424/src/glx/drisw_glx.c ---- mesa-20120424/src/glx/drisw_glx.c.jx 2012-04-24 07:37:03.000000000 -0400 -+++ mesa-20120424/src/glx/drisw_glx.c 2012-05-16 13:29:25.087965268 -0400 -@@ -24,6 +24,9 @@ - #if defined(GLX_DIRECT_RENDERING) && !defined(GLX_USE_APPLEGL) - - #include -+#include -+#include -+#include - #include "glxclient.h" - #include - #include "dri_common.h" -@@ -206,6 +209,96 @@ swrastPutImage(__DRIdrawable * draw, int - ximage->data = NULL; - } - -+static int shm_error; -+ -+static int -+shm_handler(Display *d, XErrorEvent *e) -+{ -+ shm_error = 1; -+ return 0; -+} -+ -+static int -+align(int value, int alignment) -+{ -+ return (value + alignment - 1) & ~(alignment - 1); -+} -+ -+/* -+ * Slight fast path. Short of changing how texture memory is allocated, we -+ * have two options for getting the pixels out. GetImage is clamped by the -+ * server's write buffer size, so you end up doing lots of relatively small -+ * requests (128k each or so), with two memcpys: down into the kernel, and -+ * then back up. ShmGetImage is one big blit into the shm segment (which -+ * could be GPU DMA, in principle) and then another one here. -+ */ -+static Bool -+swrastShmGetImage(__DRIdrawable *read, char *data, struct drisw_drawable *prp) -+{ -+ __GLXDRIdrawable *pread = &(prp->base); -+ Display *dpy = pread->psc->dpy; -+ XImage *ximage = prp->ximage; -+ unsigned long image_size = ximage->height * ximage->bytes_per_line; -+ Bool ret = 0; -+ XShmSegmentInfo seg = { 0, -1, (void *)-1, 0 }; -+ int (*old_handler)(Display *, XErrorEvent *); -+ -+ if (!XShmQueryExtension(dpy)) -+ goto out; -+ -+ /* image setup */ -+ seg.shmid = shmget(IPC_PRIVATE, image_size, IPC_CREAT | 0777); -+ if (seg.shmid < 0) -+ goto out; -+ -+ seg.shmaddr = shmat(seg.shmid, NULL, 0); -+ if (seg.shmaddr == (void *)-1) -+ goto out; -+ -+ XSync(dpy, 0); -+ old_handler = XSetErrorHandler(shm_handler); -+ XShmAttach(dpy, &seg); -+ XSync(dpy, 0); -+ XSetErrorHandler(old_handler); -+ if (shm_error) -+ goto out; -+ -+ ximage->data = seg.shmaddr; -+ ximage->obdata = &seg; -+ if (!XShmGetImage(dpy, pread->xDrawable, ximage, 0, 0, -1)) -+ goto out; -+ -+ /* -+ * ShmGetImage doesn't actually pay attention to ->bytes_per_line. -+ * We have to compensate for this somewhere since llvmpipe's natural -+ * tile width is 64. Do it here so we don't have to undo it with a -+ * bunch of memmove in the driver. -+ */ -+ do { -+ int i; -+ char *src = ximage->data; -+ int dst_width = align(ximage->width * ximage->bits_per_pixel / 8, 256); -+ -+ for (i = 0; i < ximage->height; i++) { -+ memcpy(data, src, ximage->bytes_per_line); -+ data += dst_width; -+ src += ximage->bytes_per_line; -+ } -+ } while (0); -+ ret = 1; -+ -+out: -+ ximage->obdata = NULL; -+ ximage->data = NULL; -+ shm_error = 0; -+ XShmDetach(dpy, &seg); -+ if (seg.shmaddr != (void *)-1) -+ shmdt(seg.shmaddr); -+ if (seg.shmid > -1) -+ shmctl(seg.shmid, IPC_RMID, NULL); -+ return ret; -+} -+ - static void - swrastGetImage(__DRIdrawable * read, - int x, int y, int w, int h, -@@ -220,11 +313,17 @@ swrastGetImage(__DRIdrawable * read, - readable = pread->xDrawable; - - ximage = prp->ximage; -- ximage->data = data; - ximage->width = w; - ximage->height = h; - ximage->bytes_per_line = bytes_per_line(w * ximage->bits_per_pixel, 32); - -+ /* XXX check dimensions, if any caller ever sub-images */ -+ if (swrastShmGetImage(read, data, prp)) -+ return; -+ -+ /* shm failed, fall back to protocol */ -+ ximage->data = data; -+ - XGetSubImage(dpy, readable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0); - - ximage->data = NULL; diff --git a/SPECS/mesa.spec b/SPECS/mesa.spec index e676192..1b7ce7e 100644 --- a/SPECS/mesa.spec +++ b/SPECS/mesa.spec @@ -55,19 +55,19 @@ %define _default_patch_fuzz 2 -%define gitdate 20171019 +#define gitdate 20180530 #% define snapshot Summary: Mesa graphics libraries Name: mesa -Version: 17.2.3 -Release: 8.%{gitdate}%{?dist} +Version: 18.0.5 +Release: 3%{?dist} License: MIT Group: System Environment/Libraries URL: http://www.mesa3d.org -# Source0: MesaLib-%{version}.tar.xz -Source0: %{name}-%{gitdate}.tar.xz +Source0: mesa-%{version}.tar.xz +#Source0: %{name}-%{gitdate}.tar.xz Source1: sanitize-tarball.sh Source2: make-release-tarball.sh Source3: make-git-snapshot.sh @@ -77,23 +77,16 @@ Source3: make-git-snapshot.sh # Fedora opts to ignore the optional part of clause 2 and treat that code as 2 clause BSD. Source4: Mesa-MLAA-License-Clarification-Email.txt -Patch0: mesa-17.3-final.patch Patch1: nv50-fix-build.patch -Patch2: 0001-mesa-Squash-merge-of-S3TC-support.patch -Patch9: mesa-8.0-llvmpipe-shmget.patch +# backport of dri sw xshm support to help qxl +Patch2: dri-sw-xshm-support.patch + +# fix some timeout mismatch warnings (backport from upstream) +Patch3: fix-timeout-warnings.patch Patch12: mesa-8.0.1-fix-16bpp.patch Patch15: mesa-9.2-hardware-float.patch Patch20: mesa-10.2-evergreen-big-endian.patch - -# For bz1503861, fix visual artifacts on DRI PRIME offloading -# Feel free to drop these patches during the next mesa rebase (>17.2.3) -Patch30: 0001-intel-blorp-Use-mocs.tex-for-depth-stencil.patch -Patch31: 0002-anv-blorp-Add-a-device-parameter-to-blorp_surf_for_a.patch -Patch32: 0003-blorp-Turn-anv_CmdCopyBuffer-into-a-blorp_buffer_cop.patch -Patch33: 0004-intel-blorp-Make-the-MOCS-setting-part-of-blorp_addr.patch -Patch34: 0005-i965-Use-PTE-MOCS-for-all-external-buffers.patch - -Patch40: 0001-intel-Add-more-Coffee-Lake-PCI-IDs.patch +Patch21: 0001-pkgconfig-Fix-gl.pc-when-glvnd-is-enabled.patch BuildRequires: pkgconfig autoconf automake libtool %if %{with_hardware} @@ -119,7 +112,7 @@ BuildRequires: python-mako BuildRequires: gettext %if 0%{?with_llvm} %if 0%{?with_private_llvm} -BuildRequires: llvm-private-devel >= 5.0 +BuildRequires: llvm-private-devel >= 6.0 %else BuildRequires: llvm-devel >= 3.0 %endif @@ -133,11 +126,12 @@ BuildRequires: pkgconfig(wayland-client) >= 1.11 BuildRequires: pkgconfig(wayland-server) >= 1.11 BuildRequires: pkgconfig(wayland-protocols) >= 1.8.0 %endif -BuildRequires: mesa-libGL-devel +# BuildRequires: mesa-libGL-devel %if 0%{?with_vdpau} BuildRequires: libvdpau-devel %endif BuildRequires: zlib-devel +BuildRequires: libglvnd-devel %description Mesa @@ -148,6 +142,7 @@ Group: System Environment/Libraries Provides: libGL Requires: mesa-libglapi = %{version}-%{release} Requires: libdrm >= 2.4.83 +Requires: libglvnd-glx%{?_isa} >= 1:1.0.1-0.7 %description libGL Mesa libGL runtime library. @@ -156,6 +151,7 @@ Mesa libGL runtime library. Summary: Mesa libEGL runtime libraries Group: System Environment/Libraries Requires: mesa-libgbm = %{version}-%{release} +Requires: libglvnd-egl%{?_isa} %description libEGL Mesa libEGL runtime libraries @@ -164,6 +160,7 @@ Mesa libEGL runtime libraries Summary: Mesa libGLES runtime libraries Group: System Environment/Libraries Requires: mesa-libglapi = %{version}-%{release} +Requires: libglvnd-gles%{?_isa} %description libGLES Mesa GLES runtime libraries @@ -200,6 +197,7 @@ Summary: Mesa libGL development package Group: Development/Libraries Requires: mesa-libGL = %{version}-%{release} Requires: gl-manpages +Requires: libglvnd-devel%{?_isa} Provides: libGL-devel %description libGL-devel @@ -209,6 +207,7 @@ Mesa libGL development package Summary: Mesa libEGL development package Group: Development/Libraries Requires: mesa-libEGL = %{version}-%{release} +Requires: libglvnd-devel%{?_isa} Provides: khrplatform-devel = %{version}-%{release} Obsoletes: khrplatform-devel < %{version}-%{release} @@ -219,6 +218,7 @@ Mesa libEGL development package Summary: Mesa libGLES development package Group: Development/Libraries Requires: mesa-libGLES = %{version}-%{release} +Requires: libglvnd-devel%{?_isa} %description libGLES-devel Mesa libGLES development package @@ -321,35 +321,19 @@ The drivers with support for the Vulkan API. %endif %prep -#setup -q -n Mesa-%{version}%{?snapshot} -%setup -q -n mesa-%{gitdate} +%setup -q -n mesa-%{version}%{?snapshot} +#setup -q -n mesa-%{gitdate} # make sure you run sanitize-tarball.sh on mesa source tarball or next line will exit grep -q ^/ src/gallium/auxiliary/vl/vl_decoder.c && exit 1 -%patch0 -p1 -b .mesa17.2.3 %patch1 -p1 -b .nv50rtti -%patch2 -p1 -b .s3tc - -# this fastpath is: -# - broken with swrast classic -# - broken on 24bpp -# - not a huge win anyway -# - ABI-broken wrt upstream -# - eventually obsoleted by vgem -# -# dear ajax: fix this one way or the other -#patch9 -p1 -b .shmget +%patch2 -p1 -b .xshm +%patch3 -p1 -b .timeout + #patch12 -p1 -b .16bpp %patch15 -p1 -b .hwfloat #patch20 -p1 -b .egbe - -%patch30 -p1 -b .bz1503861_patch1 -%patch31 -p1 -b .bz1503861_patch2 -%patch32 -p1 -b .bz1503861_patch3 -%patch33 -p1 -b .bz1503861_patch4 -%patch34 -p1 -b .bz1503861_patch5 - -%patch40 -p1 -b .cfl_ids +%patch21 -p1 -b .glpc %if 0%{with_private_llvm} sed -i 's/\[llvm-config\]/\[llvm-private-config-%{__isa_bits}\]/g' configure.ac @@ -383,6 +367,7 @@ export CXXFLAGS="$RPM_OPT_FLAGS -fno-rtti -fno-exceptions" %configure \ %{?asm_flags} \ + --enable-libglvnd \ --enable-selinux \ --enable-osmesa \ --with-dri-driverdir=%{_libdir}/dri \ @@ -410,9 +395,6 @@ export CXXFLAGS="$RPM_OPT_FLAGS -fno-rtti -fno-exceptions" %endif %{?dri_drivers} -# this seems to be neccessary for s390 -make -C src/mesa/drivers/dri/common/xmlpool/ - make %{?_smp_mflags} MKDEP=/bin/true %install @@ -433,6 +415,17 @@ rm -f $RPM_BUILD_ROOT%{_sysconfdir}/drirc # libvdpau opens the versioned name, don't bother including the unversioned rm -f $RPM_BUILD_ROOT%{_libdir}/vdpau/*.so +# likewise glvnd +rm -f %{buildroot}%{_libdir}/libGLX_mesa.so +rm -f %{buildroot}%{_libdir}/libEGL_mesa.so +# XXX can we just not build this +rm -f %{buildroot}%{_libdir}/libGLES* + +# XXX wayland-egl? + +# glvnd needs a default provider for indirect rendering where it cannot +# determine the vendor +ln -s %{_libdir}/libGLX_mesa.so.0 %{buildroot}%{_libdir}/libGLX_system.so.0 # strip out useless headers rm -f $RPM_BUILD_ROOT%{_includedir}/GL/w*.h @@ -479,18 +472,17 @@ rm -rf $RPM_BUILD_ROOT %files libGL %defattr(-,root,root,-) -%{_libdir}/libGL.so.1 -%{_libdir}/libGL.so.1.* +%{_libdir}/libGLX_mesa.so.0* +%{_libdir}/libGLX_system.so.0* %files libEGL %defattr(-,root,root,-) -%{_libdir}/libEGL.so.1 -%{_libdir}/libEGL.so.1.* +%{_datadir}/glvnd/egl_vendor.d/50_mesa.json +%{_libdir}/libEGL_mesa.so.0* %files libGLES %defattr(-,root,root,-) -%{_libdir}/libGLESv2.so.2 -%{_libdir}/libGLESv2.so.2.* +# no files, all provided by libglvnd %files filesystem %defattr(-,root,root,-) @@ -569,7 +561,6 @@ rm -rf $RPM_BUILD_ROOT %dir %{_includedir}/GL/internal %{_includedir}/GL/internal/dri_interface.h %{_libdir}/pkgconfig/dri.pc -%{_libdir}/libGL.so %{_libdir}/libglapi.so %{_libdir}/pkgconfig/gl.pc @@ -584,7 +575,6 @@ rm -rf $RPM_BUILD_ROOT %dir %{_includedir}/KHR %{_includedir}/KHR/khrplatform.h %{_libdir}/pkgconfig/egl.pc -%{_libdir}/libEGL.so %files libGLES-devel %defattr(-,root,root,-) @@ -599,7 +589,6 @@ rm -rf $RPM_BUILD_ROOT %{_includedir}/GLES3/gl32.h %{_includedir}/GLES3/gl3ext.h %{_libdir}/pkgconfig/glesv2.pc -%{_libdir}/libGLESv2.so %files libOSMesa %defattr(-,root,root,-) @@ -670,6 +659,32 @@ rm -rf $RPM_BUILD_ROOT %endif %changelog +* Tue Jul 24 2018 Dave Airlie - 18.0.5-3 +- rename fedora to system in glvnd fallback + +* Thu Jul 19 2018 Dave Airlie - 18.0.5-2 +- Fix timeout overflow warnings (backport from upstream + virgl) + +* Wed Jun 20 2018 Adam Jackson - 18.0.5-1 +- Mesa 18.0.5 + +* Wed May 30 2018 Dave Airlie - 18.0.3-5.20180508 +- Fix gl.pc when using glvnd +- Fix subpackage dependencies for glvnd + +* Fri May 25 2018 Adam Jackson - 18.0.3-2.20180508 +- Use glvnd + +* Tue May 08 2018 Dave Airlie 18.0.3-1.20180508 +- rebase to 18.0.3 + +* Wed Apr 18 2018 Adam Jackson - 17.2.3-9 +- Rebuild for new llvm + * Mon Jan 15 2018 Dave Airlie - 17.2.3-8.20171019 - Add missing Intel CFL ids.