diff --git a/0001-Fix-linkage-against-shared-glapi.patch b/0001-Fix-linkage-against-shared-glapi.patch index 7f8f716..bc70028 100644 --- a/0001-Fix-linkage-against-shared-glapi.patch +++ b/0001-Fix-linkage-against-shared-glapi.patch @@ -20,7 +20,7 @@ index 5d39486..04add87 100644 + $(top_builddir)/src/mapi/shared-glapi/libglapi.la \ $(SHARED_GLAPI_LIB) \ $(OSMESA_LIB_DEPS) \ - $(CLOCK_LIB) + $(CLOCK_LIB) \ -- 2.9.3 diff --git a/0001-mesa-Squash-merge-of-S3TC-support.patch b/0001-mesa-Squash-merge-of-S3TC-support.patch new file mode 100644 index 0000000..1b4433b --- /dev/null +++ b/0001-mesa-Squash-merge-of-S3TC-support.patch @@ -0,0 +1,2492 @@ +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/mesa-7.1-vc4-fixes.patch b/mesa-7.1-vc4-fixes.patch deleted file mode 100644 index 7bbefa7..0000000 --- a/mesa-7.1-vc4-fixes.patch +++ /dev/null @@ -1,1450 +0,0 @@ -From de31fe81a869c80b3cc08cb648640cf617e0d09c Mon Sep 17 00:00:00 2001 -From: Eric Anholt -Date: Thu, 15 Jun 2017 16:52:22 -0700 -Subject: [PATCH] vc4: Switch back to using a local copy of vc4_drm.h. - -Needing to get our uapi header from libdrm has only complicated things. -Follow intel's lead and drop our requirement for it. - -Generated from 056f4f02abb7e9e4a0cf0cda0211586df5e43842 of drm-misc-next - -(cherry picked from commit 1facea3486e3dd4e4a6cf561a725b9c4312ca58a) ---- - configure.ac | 2 - - src/gallium/drivers/vc4/Makefile.am | 3 +- - src/gallium/drivers/vc4/Makefile.sources | 1 + - src/gallium/drivers/vc4/drm_fourcc.h | 379 +++++++++++++++++++++++++++++++ - src/gallium/drivers/vc4/vc4_drm.h | 318 ++++++++++++++++++++++++++ - 5 files changed, 699 insertions(+), 4 deletions(-) - create mode 100644 src/gallium/drivers/vc4/drm_fourcc.h - create mode 100644 src/gallium/drivers/vc4/vc4_drm.h - -diff --git a/configure.ac b/configure.ac -index b069f54155..81258715b5 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -79,7 +79,6 @@ LIBDRM_INTEL_REQUIRED=2.4.75 - LIBDRM_NVVIEUX_REQUIRED=2.4.66 - LIBDRM_NOUVEAU_REQUIRED=2.4.66 - LIBDRM_FREEDRENO_REQUIRED=2.4.74 --LIBDRM_VC4_REQUIRED=2.4.69 - LIBDRM_ETNAVIV_REQUIRED=2.4.80 - - dnl Versions for external dependencies -@@ -2495,7 +2494,6 @@ if test -n "$with_gallium_drivers"; then - ;; - xvc4) - HAVE_GALLIUM_VC4=yes -- PKG_CHECK_MODULES([VC4], [libdrm >= $LIBDRM_VC4_REQUIRED libdrm_vc4 >= $LIBDRM_VC4_REQUIRED]) - require_libdrm "vc4" - - PKG_CHECK_MODULES([SIMPENROSE], [simpenrose], -diff --git a/src/gallium/drivers/vc4/Makefile.am b/src/gallium/drivers/vc4/Makefile.am -index b361a0c588..f6b87b2261 100644 ---- a/src/gallium/drivers/vc4/Makefile.am -+++ b/src/gallium/drivers/vc4/Makefile.am -@@ -29,7 +29,6 @@ endif - AM_CFLAGS = \ - -I$(top_builddir)/src/compiler/nir \ - $(LIBDRM_CFLAGS) \ -- $(VC4_CFLAGS) \ - $(GALLIUM_DRIVER_CFLAGS) \ - $(SIM_CFLAGS) \ - $(VALGRIND_CFLAGS) \ -@@ -38,7 +37,7 @@ AM_CFLAGS = \ - noinst_LTLIBRARIES = libvc4.la - - libvc4_la_SOURCES = $(C_SOURCES) --libvc4_la_LIBADD = $(SIM_LIB) $(VC4_LIBS) -+libvc4_la_LIBADD = $(SIM_LIB) - libvc4_la_LDFLAGS = $(SIM_LDFLAGS) - - noinst_LTLIBRARIES += libvc4_neon.la -diff --git a/src/gallium/drivers/vc4/Makefile.sources b/src/gallium/drivers/vc4/Makefile.sources -index 10de343612..cb04cc9c0a 100644 ---- a/src/gallium/drivers/vc4/Makefile.sources -+++ b/src/gallium/drivers/vc4/Makefile.sources -@@ -14,6 +14,7 @@ C_SOURCES := \ - vc4_context.c \ - vc4_context.h \ - vc4_draw.c \ -+ vc4_drm.h \ - vc4_emit.c \ - vc4_fence.c \ - vc4_formats.c \ -diff --git a/src/gallium/drivers/vc4/drm_fourcc.h b/src/gallium/drivers/vc4/drm_fourcc.h -new file mode 100644 -index 0000000000..7586c46f68 ---- /dev/null -+++ b/src/gallium/drivers/vc4/drm_fourcc.h -@@ -0,0 +1,379 @@ -+/* -+ * Copyright 2011 Intel Corporation -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a -+ * copy of this software and associated documentation files (the "Software"), -+ * to deal in the Software without restriction, including without limitation -+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, -+ * and/or sell copies of the Software, and to permit persons to whom the -+ * Software is furnished to do so, subject to the following conditions: -+ * -+ * The above copyright notice and this permission notice (including the next -+ * paragraph) shall be included in all copies or substantial portions of the -+ * Software. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS 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 DRM_FOURCC_H -+#define DRM_FOURCC_H -+ -+#include "drm.h" -+ -+#if defined(__cplusplus) -+extern "C" { -+#endif -+ -+#define fourcc_code(a, b, c, d) ((__u32)(a) | ((__u32)(b) << 8) | \ -+ ((__u32)(c) << 16) | ((__u32)(d) << 24)) -+ -+#define DRM_FORMAT_BIG_ENDIAN (1<<31) /* format is big endian instead of little endian */ -+ -+/* color index */ -+#define DRM_FORMAT_C8 fourcc_code('C', '8', ' ', ' ') /* [7:0] C */ -+ -+/* 8 bpp Red */ -+#define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') /* [7:0] R */ -+ -+/* 16 bpp Red */ -+#define DRM_FORMAT_R16 fourcc_code('R', '1', '6', ' ') /* [15:0] R little endian */ -+ -+/* 16 bpp RG */ -+#define DRM_FORMAT_RG88 fourcc_code('R', 'G', '8', '8') /* [15:0] R:G 8:8 little endian */ -+#define DRM_FORMAT_GR88 fourcc_code('G', 'R', '8', '8') /* [15:0] G:R 8:8 little endian */ -+ -+/* 32 bpp RG */ -+#define DRM_FORMAT_RG1616 fourcc_code('R', 'G', '3', '2') /* [31:0] R:G 16:16 little endian */ -+#define DRM_FORMAT_GR1616 fourcc_code('G', 'R', '3', '2') /* [31:0] G:R 16:16 little endian */ -+ -+/* 8 bpp RGB */ -+#define DRM_FORMAT_RGB332 fourcc_code('R', 'G', 'B', '8') /* [7:0] R:G:B 3:3:2 */ -+#define DRM_FORMAT_BGR233 fourcc_code('B', 'G', 'R', '8') /* [7:0] B:G:R 2:3:3 */ -+ -+/* 16 bpp RGB */ -+#define DRM_FORMAT_XRGB4444 fourcc_code('X', 'R', '1', '2') /* [15:0] x:R:G:B 4:4:4:4 little endian */ -+#define DRM_FORMAT_XBGR4444 fourcc_code('X', 'B', '1', '2') /* [15:0] x:B:G:R 4:4:4:4 little endian */ -+#define DRM_FORMAT_RGBX4444 fourcc_code('R', 'X', '1', '2') /* [15:0] R:G:B:x 4:4:4:4 little endian */ -+#define DRM_FORMAT_BGRX4444 fourcc_code('B', 'X', '1', '2') /* [15:0] B:G:R:x 4:4:4:4 little endian */ -+ -+#define DRM_FORMAT_ARGB4444 fourcc_code('A', 'R', '1', '2') /* [15:0] A:R:G:B 4:4:4:4 little endian */ -+#define DRM_FORMAT_ABGR4444 fourcc_code('A', 'B', '1', '2') /* [15:0] A:B:G:R 4:4:4:4 little endian */ -+#define DRM_FORMAT_RGBA4444 fourcc_code('R', 'A', '1', '2') /* [15:0] R:G:B:A 4:4:4:4 little endian */ -+#define DRM_FORMAT_BGRA4444 fourcc_code('B', 'A', '1', '2') /* [15:0] B:G:R:A 4:4:4:4 little endian */ -+ -+#define DRM_FORMAT_XRGB1555 fourcc_code('X', 'R', '1', '5') /* [15:0] x:R:G:B 1:5:5:5 little endian */ -+#define DRM_FORMAT_XBGR1555 fourcc_code('X', 'B', '1', '5') /* [15:0] x:B:G:R 1:5:5:5 little endian */ -+#define DRM_FORMAT_RGBX5551 fourcc_code('R', 'X', '1', '5') /* [15:0] R:G:B:x 5:5:5:1 little endian */ -+#define DRM_FORMAT_BGRX5551 fourcc_code('B', 'X', '1', '5') /* [15:0] B:G:R:x 5:5:5:1 little endian */ -+ -+#define DRM_FORMAT_ARGB1555 fourcc_code('A', 'R', '1', '5') /* [15:0] A:R:G:B 1:5:5:5 little endian */ -+#define DRM_FORMAT_ABGR1555 fourcc_code('A', 'B', '1', '5') /* [15:0] A:B:G:R 1:5:5:5 little endian */ -+#define DRM_FORMAT_RGBA5551 fourcc_code('R', 'A', '1', '5') /* [15:0] R:G:B:A 5:5:5:1 little endian */ -+#define DRM_FORMAT_BGRA5551 fourcc_code('B', 'A', '1', '5') /* [15:0] B:G:R:A 5:5:5:1 little endian */ -+ -+#define DRM_FORMAT_RGB565 fourcc_code('R', 'G', '1', '6') /* [15:0] R:G:B 5:6:5 little endian */ -+#define DRM_FORMAT_BGR565 fourcc_code('B', 'G', '1', '6') /* [15:0] B:G:R 5:6:5 little endian */ -+ -+/* 24 bpp RGB */ -+#define DRM_FORMAT_RGB888 fourcc_code('R', 'G', '2', '4') /* [23:0] R:G:B little endian */ -+#define DRM_FORMAT_BGR888 fourcc_code('B', 'G', '2', '4') /* [23:0] B:G:R little endian */ -+ -+/* 32 bpp RGB */ -+#define DRM_FORMAT_XRGB8888 fourcc_code('X', 'R', '2', '4') /* [31:0] x:R:G:B 8:8:8:8 little endian */ -+#define DRM_FORMAT_XBGR8888 fourcc_code('X', 'B', '2', '4') /* [31:0] x:B:G:R 8:8:8:8 little endian */ -+#define DRM_FORMAT_RGBX8888 fourcc_code('R', 'X', '2', '4') /* [31:0] R:G:B:x 8:8:8:8 little endian */ -+#define DRM_FORMAT_BGRX8888 fourcc_code('B', 'X', '2', '4') /* [31:0] B:G:R:x 8:8:8:8 little endian */ -+ -+#define DRM_FORMAT_ARGB8888 fourcc_code('A', 'R', '2', '4') /* [31:0] A:R:G:B 8:8:8:8 little endian */ -+#define DRM_FORMAT_ABGR8888 fourcc_code('A', 'B', '2', '4') /* [31:0] A:B:G:R 8:8:8:8 little endian */ -+#define DRM_FORMAT_RGBA8888 fourcc_code('R', 'A', '2', '4') /* [31:0] R:G:B:A 8:8:8:8 little endian */ -+#define DRM_FORMAT_BGRA8888 fourcc_code('B', 'A', '2', '4') /* [31:0] B:G:R:A 8:8:8:8 little endian */ -+ -+#define DRM_FORMAT_XRGB2101010 fourcc_code('X', 'R', '3', '0') /* [31:0] x:R:G:B 2:10:10:10 little endian */ -+#define DRM_FORMAT_XBGR2101010 fourcc_code('X', 'B', '3', '0') /* [31:0] x:B:G:R 2:10:10:10 little endian */ -+#define DRM_FORMAT_RGBX1010102 fourcc_code('R', 'X', '3', '0') /* [31:0] R:G:B:x 10:10:10:2 little endian */ -+#define DRM_FORMAT_BGRX1010102 fourcc_code('B', 'X', '3', '0') /* [31:0] B:G:R:x 10:10:10:2 little endian */ -+ -+#define DRM_FORMAT_ARGB2101010 fourcc_code('A', 'R', '3', '0') /* [31:0] A:R:G:B 2:10:10:10 little endian */ -+#define DRM_FORMAT_ABGR2101010 fourcc_code('A', 'B', '3', '0') /* [31:0] A:B:G:R 2:10:10:10 little endian */ -+#define DRM_FORMAT_RGBA1010102 fourcc_code('R', 'A', '3', '0') /* [31:0] R:G:B:A 10:10:10:2 little endian */ -+#define DRM_FORMAT_BGRA1010102 fourcc_code('B', 'A', '3', '0') /* [31:0] B:G:R:A 10:10:10:2 little endian */ -+ -+/* packed YCbCr */ -+#define DRM_FORMAT_YUYV fourcc_code('Y', 'U', 'Y', 'V') /* [31:0] Cr0:Y1:Cb0:Y0 8:8:8:8 little endian */ -+#define DRM_FORMAT_YVYU fourcc_code('Y', 'V', 'Y', 'U') /* [31:0] Cb0:Y1:Cr0:Y0 8:8:8:8 little endian */ -+#define DRM_FORMAT_UYVY fourcc_code('U', 'Y', 'V', 'Y') /* [31:0] Y1:Cr0:Y0:Cb0 8:8:8:8 little endian */ -+#define DRM_FORMAT_VYUY fourcc_code('V', 'Y', 'U', 'Y') /* [31:0] Y1:Cb0:Y0:Cr0 8:8:8:8 little endian */ -+ -+#define DRM_FORMAT_AYUV fourcc_code('A', 'Y', 'U', 'V') /* [31:0] A:Y:Cb:Cr 8:8:8:8 little endian */ -+ -+/* -+ * 2 plane RGB + A -+ * index 0 = RGB plane, same format as the corresponding non _A8 format has -+ * index 1 = A plane, [7:0] A -+ */ -+#define DRM_FORMAT_XRGB8888_A8 fourcc_code('X', 'R', 'A', '8') -+#define DRM_FORMAT_XBGR8888_A8 fourcc_code('X', 'B', 'A', '8') -+#define DRM_FORMAT_RGBX8888_A8 fourcc_code('R', 'X', 'A', '8') -+#define DRM_FORMAT_BGRX8888_A8 fourcc_code('B', 'X', 'A', '8') -+#define DRM_FORMAT_RGB888_A8 fourcc_code('R', '8', 'A', '8') -+#define DRM_FORMAT_BGR888_A8 fourcc_code('B', '8', 'A', '8') -+#define DRM_FORMAT_RGB565_A8 fourcc_code('R', '5', 'A', '8') -+#define DRM_FORMAT_BGR565_A8 fourcc_code('B', '5', 'A', '8') -+ -+/* -+ * 2 plane YCbCr -+ * index 0 = Y plane, [7:0] Y -+ * index 1 = Cr:Cb plane, [15:0] Cr:Cb little endian -+ * or -+ * index 1 = Cb:Cr plane, [15:0] Cb:Cr little endian -+ */ -+#define DRM_FORMAT_NV12 fourcc_code('N', 'V', '1', '2') /* 2x2 subsampled Cr:Cb plane */ -+#define DRM_FORMAT_NV21 fourcc_code('N', 'V', '2', '1') /* 2x2 subsampled Cb:Cr plane */ -+#define DRM_FORMAT_NV16 fourcc_code('N', 'V', '1', '6') /* 2x1 subsampled Cr:Cb plane */ -+#define DRM_FORMAT_NV61 fourcc_code('N', 'V', '6', '1') /* 2x1 subsampled Cb:Cr plane */ -+#define DRM_FORMAT_NV24 fourcc_code('N', 'V', '2', '4') /* non-subsampled Cr:Cb plane */ -+#define DRM_FORMAT_NV42 fourcc_code('N', 'V', '4', '2') /* non-subsampled Cb:Cr plane */ -+ -+/* -+ * 3 plane YCbCr -+ * index 0: Y plane, [7:0] Y -+ * index 1: Cb plane, [7:0] Cb -+ * index 2: Cr plane, [7:0] Cr -+ * or -+ * index 1: Cr plane, [7:0] Cr -+ * index 2: Cb plane, [7:0] Cb -+ */ -+#define DRM_FORMAT_YUV410 fourcc_code('Y', 'U', 'V', '9') /* 4x4 subsampled Cb (1) and Cr (2) planes */ -+#define DRM_FORMAT_YVU410 fourcc_code('Y', 'V', 'U', '9') /* 4x4 subsampled Cr (1) and Cb (2) planes */ -+#define DRM_FORMAT_YUV411 fourcc_code('Y', 'U', '1', '1') /* 4x1 subsampled Cb (1) and Cr (2) planes */ -+#define DRM_FORMAT_YVU411 fourcc_code('Y', 'V', '1', '1') /* 4x1 subsampled Cr (1) and Cb (2) planes */ -+#define DRM_FORMAT_YUV420 fourcc_code('Y', 'U', '1', '2') /* 2x2 subsampled Cb (1) and Cr (2) planes */ -+#define DRM_FORMAT_YVU420 fourcc_code('Y', 'V', '1', '2') /* 2x2 subsampled Cr (1) and Cb (2) planes */ -+#define DRM_FORMAT_YUV422 fourcc_code('Y', 'U', '1', '6') /* 2x1 subsampled Cb (1) and Cr (2) planes */ -+#define DRM_FORMAT_YVU422 fourcc_code('Y', 'V', '1', '6') /* 2x1 subsampled Cr (1) and Cb (2) planes */ -+#define DRM_FORMAT_YUV444 fourcc_code('Y', 'U', '2', '4') /* non-subsampled Cb (1) and Cr (2) planes */ -+#define DRM_FORMAT_YVU444 fourcc_code('Y', 'V', '2', '4') /* non-subsampled Cr (1) and Cb (2) planes */ -+ -+ -+/* -+ * Format Modifiers: -+ * -+ * Format modifiers describe, typically, a re-ordering or modification -+ * of the data in a plane of an FB. This can be used to express tiled/ -+ * swizzled formats, or compression, or a combination of the two. -+ * -+ * The upper 8 bits of the format modifier are a vendor-id as assigned -+ * below. The lower 56 bits are assigned as vendor sees fit. -+ */ -+ -+/* Vendor Ids: */ -+#define DRM_FORMAT_MOD_NONE 0 -+#define DRM_FORMAT_MOD_VENDOR_NONE 0 -+#define DRM_FORMAT_MOD_VENDOR_INTEL 0x01 -+#define DRM_FORMAT_MOD_VENDOR_AMD 0x02 -+#define DRM_FORMAT_MOD_VENDOR_NV 0x03 -+#define DRM_FORMAT_MOD_VENDOR_SAMSUNG 0x04 -+#define DRM_FORMAT_MOD_VENDOR_QCOM 0x05 -+#define DRM_FORMAT_MOD_VENDOR_VIVANTE 0x06 -+#define DRM_FORMAT_MOD_VENDOR_BROADCOM 0x07 -+/* add more to the end as needed */ -+ -+#define fourcc_mod_code(vendor, val) \ -+ ((((__u64)DRM_FORMAT_MOD_VENDOR_## vendor) << 56) | (val & 0x00ffffffffffffffULL)) -+ -+/* -+ * Format Modifier tokens: -+ * -+ * When adding a new token please document the layout with a code comment, -+ * similar to the fourcc codes above. drm_fourcc.h is considered the -+ * authoritative source for all of these. -+ */ -+ -+/* -+ * Linear Layout -+ * -+ * Just plain linear layout. Note that this is different from no specifying any -+ * modifier (e.g. not setting DRM_MODE_FB_MODIFIERS in the DRM_ADDFB2 ioctl), -+ * which tells the driver to also take driver-internal information into account -+ * and so might actually result in a tiled framebuffer. -+ */ -+#define DRM_FORMAT_MOD_LINEAR fourcc_mod_code(NONE, 0) -+ -+/* Intel framebuffer modifiers */ -+ -+/* -+ * Intel X-tiling layout -+ * -+ * This is a tiled layout using 4Kb tiles (except on gen2 where the tiles 2Kb) -+ * in row-major layout. Within the tile bytes are laid out row-major, with -+ * a platform-dependent stride. On top of that the memory can apply -+ * platform-depending swizzling of some higher address bits into bit6. -+ * -+ * This format is highly platforms specific and not useful for cross-driver -+ * sharing. It exists since on a given platform it does uniquely identify the -+ * layout in a simple way for i915-specific userspace. -+ */ -+#define I915_FORMAT_MOD_X_TILED fourcc_mod_code(INTEL, 1) -+ -+/* -+ * Intel Y-tiling layout -+ * -+ * This is a tiled layout using 4Kb tiles (except on gen2 where the tiles 2Kb) -+ * in row-major layout. Within the tile bytes are laid out in OWORD (16 bytes) -+ * chunks column-major, with a platform-dependent height. On top of that the -+ * memory can apply platform-depending swizzling of some higher address bits -+ * into bit6. -+ * -+ * This format is highly platforms specific and not useful for cross-driver -+ * sharing. It exists since on a given platform it does uniquely identify the -+ * layout in a simple way for i915-specific userspace. -+ */ -+#define I915_FORMAT_MOD_Y_TILED fourcc_mod_code(INTEL, 2) -+ -+/* -+ * Intel Yf-tiling layout -+ * -+ * This is a tiled layout using 4Kb tiles in row-major layout. -+ * Within the tile pixels are laid out in 16 256 byte units / sub-tiles which -+ * are arranged in four groups (two wide, two high) with column-major layout. -+ * Each group therefore consits out of four 256 byte units, which are also laid -+ * out as 2x2 column-major. -+ * 256 byte units are made out of four 64 byte blocks of pixels, producing -+ * either a square block or a 2:1 unit. -+ * 64 byte blocks of pixels contain four pixel rows of 16 bytes, where the width -+ * in pixel depends on the pixel depth. -+ */ -+#define I915_FORMAT_MOD_Yf_TILED fourcc_mod_code(INTEL, 3) -+ -+/* -+ * Tiled, NV12MT, grouped in 64 (pixels) x 32 (lines) -sized macroblocks -+ * -+ * Macroblocks are laid in a Z-shape, and each pixel data is following the -+ * standard NV12 style. -+ * As for NV12, an image is the result of two frame buffers: one for Y, -+ * one for the interleaved Cb/Cr components (1/2 the height of the Y buffer). -+ * Alignment requirements are (for each buffer): -+ * - multiple of 128 pixels for the width -+ * - multiple of 32 pixels for the height -+ * -+ * For more information: see https://linuxtv.org/downloads/v4l-dvb-apis/re32.html -+ */ -+#define DRM_FORMAT_MOD_SAMSUNG_64_32_TILE fourcc_mod_code(SAMSUNG, 1) -+ -+/* Vivante framebuffer modifiers */ -+ -+/* -+ * Vivante 4x4 tiling layout -+ * -+ * This is a simple tiled layout using tiles of 4x4 pixels in a row-major -+ * layout. -+ */ -+#define DRM_FORMAT_MOD_VIVANTE_TILED fourcc_mod_code(VIVANTE, 1) -+ -+/* -+ * Vivante 64x64 super-tiling layout -+ * -+ * This is a tiled layout using 64x64 pixel super-tiles, where each super-tile -+ * contains 8x4 groups of 2x4 tiles of 4x4 pixels (like above) each, all in row- -+ * major layout. -+ * -+ * For more information: see -+ * https://github.com/etnaviv/etna_viv/blob/master/doc/hardware.md#texture-tiling -+ */ -+#define DRM_FORMAT_MOD_VIVANTE_SUPER_TILED fourcc_mod_code(VIVANTE, 2) -+ -+/* -+ * Vivante 4x4 tiling layout for dual-pipe -+ * -+ * Same as the 4x4 tiling layout, except every second 4x4 pixel tile starts at a -+ * different base address. Offsets from the base addresses are therefore halved -+ * compared to the non-split tiled layout. -+ */ -+#define DRM_FORMAT_MOD_VIVANTE_SPLIT_TILED fourcc_mod_code(VIVANTE, 3) -+ -+/* -+ * Vivante 64x64 super-tiling layout for dual-pipe -+ * -+ * Same as the 64x64 super-tiling layout, except every second 4x4 pixel tile -+ * starts at a different base address. Offsets from the base addresses are -+ * therefore halved compared to the non-split super-tiled layout. -+ */ -+#define DRM_FORMAT_MOD_VIVANTE_SPLIT_SUPER_TILED fourcc_mod_code(VIVANTE, 4) -+ -+/* NVIDIA Tegra frame buffer modifiers */ -+ -+/* -+ * Some modifiers take parameters, for example the number of vertical GOBs in -+ * a block. Reserve the lower 32 bits for parameters -+ */ -+#define __fourcc_mod_tegra_mode_shift 32 -+#define fourcc_mod_tegra_code(val, params) \ -+ fourcc_mod_code(NV, ((((__u64)val) << __fourcc_mod_tegra_mode_shift) | params)) -+#define fourcc_mod_tegra_mod(m) \ -+ (m & ~((1ULL << __fourcc_mod_tegra_mode_shift) - 1)) -+#define fourcc_mod_tegra_param(m) \ -+ (m & ((1ULL << __fourcc_mod_tegra_mode_shift) - 1)) -+ -+/* -+ * Tegra Tiled Layout, used by Tegra 2, 3 and 4. -+ * -+ * Pixels are arranged in simple tiles of 16 x 16 bytes. -+ */ -+#define NV_FORMAT_MOD_TEGRA_TILED fourcc_mod_tegra_code(1, 0) -+ -+/* -+ * Tegra 16Bx2 Block Linear layout, used by TK1/TX1 -+ * -+ * Pixels are arranged in 64x8 Groups Of Bytes (GOBs). GOBs are then stacked -+ * vertically by a power of 2 (1 to 32 GOBs) to form a block. -+ * -+ * Within a GOB, data is ordered as 16B x 2 lines sectors laid in Z-shape. -+ * -+ * Parameter 'v' is the log2 encoding of the number of GOBs stacked vertically. -+ * Valid values are: -+ * -+ * 0 == ONE_GOB -+ * 1 == TWO_GOBS -+ * 2 == FOUR_GOBS -+ * 3 == EIGHT_GOBS -+ * 4 == SIXTEEN_GOBS -+ * 5 == THIRTYTWO_GOBS -+ * -+ * Chapter 20 "Pixel Memory Formats" of the Tegra X1 TRM describes this format -+ * in full detail. -+ */ -+#define NV_FORMAT_MOD_TEGRA_16BX2_BLOCK(v) fourcc_mod_tegra_code(2, v) -+ -+/* -+ * Broadcom VC4 "T" format -+ * -+ * This is the primary layout that the V3D GPU can texture from (it -+ * can't do linear). The T format has: -+ * -+ * - 64b utiles of pixels in a raster-order grid according to cpp. It's 4x4 -+ * pixels at 32 bit depth. -+ * -+ * - 1k subtiles made of a 4x4 raster-order grid of 64b utiles (so usually -+ * 16x16 pixels). -+ * -+ * - 4k tiles made of a 2x2 grid of 1k subtiles (so usually 32x32 pixels). On -+ * even 4k tile rows, they're arranged as (BL, TL, TR, BR), and on odd rows -+ * they're (TR, BR, BL, TL), where bottom left is start of memory. -+ * -+ * - an image made of 4k tiles in rows either left-to-right (even rows of 4k -+ * tiles) or right-to-left (odd rows of 4k tiles). -+ */ -+#define DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED fourcc_mod_code(BROADCOM, 1) -+ -+#if defined(__cplusplus) -+} -+#endif -+ -+#endif /* DRM_FOURCC_H */ -diff --git a/src/gallium/drivers/vc4/vc4_drm.h b/src/gallium/drivers/vc4/vc4_drm.h -new file mode 100644 -index 0000000000..0caeaf3a1f ---- /dev/null -+++ b/src/gallium/drivers/vc4/vc4_drm.h -@@ -0,0 +1,318 @@ -+/* -+ * Copyright © 2014-2015 Broadcom -+ * -+ * Permission is hereby granted, free of charge, to any person obtaining a -+ * copy of this software and associated documentation files (the "Software"), -+ * to deal in the Software without restriction, including without limitation -+ * the rights to use, copy, modify, merge, publish, distribute, sublicense, -+ * and/or sell copies of the Software, and to permit persons to whom the -+ * Software is furnished to do so, subject to the following conditions: -+ * -+ * The above copyright notice and this permission notice (including the next -+ * paragraph) shall be included in all copies or substantial portions of the -+ * Software. -+ * -+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -+ * IN THE SOFTWARE. -+ */ -+ -+#ifndef _VC4_DRM_H_ -+#define _VC4_DRM_H_ -+ -+#include "drm.h" -+ -+#if defined(__cplusplus) -+extern "C" { -+#endif -+ -+#define DRM_VC4_SUBMIT_CL 0x00 -+#define DRM_VC4_WAIT_SEQNO 0x01 -+#define DRM_VC4_WAIT_BO 0x02 -+#define DRM_VC4_CREATE_BO 0x03 -+#define DRM_VC4_MMAP_BO 0x04 -+#define DRM_VC4_CREATE_SHADER_BO 0x05 -+#define DRM_VC4_GET_HANG_STATE 0x06 -+#define DRM_VC4_GET_PARAM 0x07 -+#define DRM_VC4_SET_TILING 0x08 -+#define DRM_VC4_GET_TILING 0x09 -+ -+#define DRM_IOCTL_VC4_SUBMIT_CL DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_SUBMIT_CL, struct drm_vc4_submit_cl) -+#define DRM_IOCTL_VC4_WAIT_SEQNO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_WAIT_SEQNO, struct drm_vc4_wait_seqno) -+#define DRM_IOCTL_VC4_WAIT_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_WAIT_BO, struct drm_vc4_wait_bo) -+#define DRM_IOCTL_VC4_CREATE_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_CREATE_BO, struct drm_vc4_create_bo) -+#define DRM_IOCTL_VC4_MMAP_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_MMAP_BO, struct drm_vc4_mmap_bo) -+#define DRM_IOCTL_VC4_CREATE_SHADER_BO DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_CREATE_SHADER_BO, struct drm_vc4_create_shader_bo) -+#define DRM_IOCTL_VC4_GET_HANG_STATE DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_GET_HANG_STATE, struct drm_vc4_get_hang_state) -+#define DRM_IOCTL_VC4_GET_PARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_GET_PARAM, struct drm_vc4_get_param) -+#define DRM_IOCTL_VC4_SET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_SET_TILING, struct drm_vc4_set_tiling) -+#define DRM_IOCTL_VC4_GET_TILING DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_GET_TILING, struct drm_vc4_get_tiling) -+ -+struct drm_vc4_submit_rcl_surface { -+ __u32 hindex; /* Handle index, or ~0 if not present. */ -+ __u32 offset; /* Offset to start of buffer. */ -+ /* -+ * Bits for either render config (color_write) or load/store packet. -+ * Bits should all be 0 for MSAA load/stores. -+ */ -+ __u16 bits; -+ -+#define VC4_SUBMIT_RCL_SURFACE_READ_IS_FULL_RES (1 << 0) -+ __u16 flags; -+}; -+ -+/** -+ * struct drm_vc4_submit_cl - ioctl argument for submitting commands to the 3D -+ * engine. -+ * -+ * Drivers typically use GPU BOs to store batchbuffers / command lists and -+ * their associated state. However, because the VC4 lacks an MMU, we have to -+ * do validation of memory accesses by the GPU commands. If we were to store -+ * our commands in BOs, we'd need to do uncached readback from them to do the -+ * validation process, which is too expensive. Instead, userspace accumulates -+ * commands and associated state in plain memory, then the kernel copies the -+ * data to its own address space, and then validates and stores it in a GPU -+ * BO. -+ */ -+struct drm_vc4_submit_cl { -+ /* Pointer to the binner command list. -+ * -+ * This is the first set of commands executed, which runs the -+ * coordinate shader to determine where primitives land on the screen, -+ * then writes out the state updates and draw calls necessary per tile -+ * to the tile allocation BO. -+ */ -+ __u64 bin_cl; -+ -+ /* Pointer to the shader records. -+ * -+ * Shader records are the structures read by the hardware that contain -+ * pointers to uniforms, shaders, and vertex attributes. The -+ * reference to the shader record has enough information to determine -+ * how many pointers are necessary (fixed number for shaders/uniforms, -+ * and an attribute count), so those BO indices into bo_handles are -+ * just stored as __u32s before each shader record passed in. -+ */ -+ __u64 shader_rec; -+ -+ /* Pointer to uniform data and texture handles for the textures -+ * referenced by the shader. -+ * -+ * For each shader state record, there is a set of uniform data in the -+ * order referenced by the record (FS, VS, then CS). Each set of -+ * uniform data has a __u32 index into bo_handles per texture -+ * sample operation, in the order the QPU_W_TMUn_S writes appear in -+ * the program. Following the texture BO handle indices is the actual -+ * uniform data. -+ * -+ * The individual uniform state blocks don't have sizes passed in, -+ * because the kernel has to determine the sizes anyway during shader -+ * code validation. -+ */ -+ __u64 uniforms; -+ __u64 bo_handles; -+ -+ /* Size in bytes of the binner command list. */ -+ __u32 bin_cl_size; -+ /* Size in bytes of the set of shader records. */ -+ __u32 shader_rec_size; -+ /* Number of shader records. -+ * -+ * This could just be computed from the contents of shader_records and -+ * the address bits of references to them from the bin CL, but it -+ * keeps the kernel from having to resize some allocations it makes. -+ */ -+ __u32 shader_rec_count; -+ /* Size in bytes of the uniform state. */ -+ __u32 uniforms_size; -+ -+ /* Number of BO handles passed in (size is that times 4). */ -+ __u32 bo_handle_count; -+ -+ /* RCL setup: */ -+ __u16 width; -+ __u16 height; -+ __u8 min_x_tile; -+ __u8 min_y_tile; -+ __u8 max_x_tile; -+ __u8 max_y_tile; -+ struct drm_vc4_submit_rcl_surface color_read; -+ struct drm_vc4_submit_rcl_surface color_write; -+ struct drm_vc4_submit_rcl_surface zs_read; -+ struct drm_vc4_submit_rcl_surface zs_write; -+ struct drm_vc4_submit_rcl_surface msaa_color_write; -+ struct drm_vc4_submit_rcl_surface msaa_zs_write; -+ __u32 clear_color[2]; -+ __u32 clear_z; -+ __u8 clear_s; -+ -+ __u32 pad:24; -+ -+#define VC4_SUBMIT_CL_USE_CLEAR_COLOR (1 << 0) -+ __u32 flags; -+ -+ /* Returned value of the seqno of this render job (for the -+ * wait ioctl). -+ */ -+ __u64 seqno; -+}; -+ -+/** -+ * struct drm_vc4_wait_seqno - ioctl argument for waiting for -+ * DRM_VC4_SUBMIT_CL completion using its returned seqno. -+ * -+ * timeout_ns is the timeout in nanoseconds, where "0" means "don't -+ * block, just return the status." -+ */ -+struct drm_vc4_wait_seqno { -+ __u64 seqno; -+ __u64 timeout_ns; -+}; -+ -+/** -+ * struct drm_vc4_wait_bo - ioctl argument for waiting for -+ * completion of the last DRM_VC4_SUBMIT_CL on a BO. -+ * -+ * This is useful for cases where multiple processes might be -+ * rendering to a BO and you want to wait for all rendering to be -+ * completed. -+ */ -+struct drm_vc4_wait_bo { -+ __u32 handle; -+ __u32 pad; -+ __u64 timeout_ns; -+}; -+ -+/** -+ * struct drm_vc4_create_bo - ioctl argument for creating VC4 BOs. -+ * -+ * There are currently no values for the flags argument, but it may be -+ * used in a future extension. -+ */ -+struct drm_vc4_create_bo { -+ __u32 size; -+ __u32 flags; -+ /** Returned GEM handle for the BO. */ -+ __u32 handle; -+ __u32 pad; -+}; -+ -+/** -+ * struct drm_vc4_mmap_bo - ioctl argument for mapping VC4 BOs. -+ * -+ * This doesn't actually perform an mmap. Instead, it returns the -+ * offset you need to use in an mmap on the DRM device node. This -+ * means that tools like valgrind end up knowing about the mapped -+ * memory. -+ * -+ * There are currently no values for the flags argument, but it may be -+ * used in a future extension. -+ */ -+struct drm_vc4_mmap_bo { -+ /** Handle for the object being mapped. */ -+ __u32 handle; -+ __u32 flags; -+ /** offset into the drm node to use for subsequent mmap call. */ -+ __u64 offset; -+}; -+ -+/** -+ * struct drm_vc4_create_shader_bo - ioctl argument for creating VC4 -+ * shader BOs. -+ * -+ * Since allowing a shader to be overwritten while it's also being -+ * executed from would allow privlege escalation, shaders must be -+ * created using this ioctl, and they can't be mmapped later. -+ */ -+struct drm_vc4_create_shader_bo { -+ /* Size of the data argument. */ -+ __u32 size; -+ /* Flags, currently must be 0. */ -+ __u32 flags; -+ -+ /* Pointer to the data. */ -+ __u64 data; -+ -+ /** Returned GEM handle for the BO. */ -+ __u32 handle; -+ /* Pad, must be 0. */ -+ __u32 pad; -+}; -+ -+struct drm_vc4_get_hang_state_bo { -+ __u32 handle; -+ __u32 paddr; -+ __u32 size; -+ __u32 pad; -+}; -+ -+/** -+ * struct drm_vc4_hang_state - ioctl argument for collecting state -+ * from a GPU hang for analysis. -+*/ -+struct drm_vc4_get_hang_state { -+ /** Pointer to array of struct drm_vc4_get_hang_state_bo. */ -+ __u64 bo; -+ /** -+ * On input, the size of the bo array. Output is the number -+ * of bos to be returned. -+ */ -+ __u32 bo_count; -+ -+ __u32 start_bin, start_render; -+ -+ __u32 ct0ca, ct0ea; -+ __u32 ct1ca, ct1ea; -+ __u32 ct0cs, ct1cs; -+ __u32 ct0ra0, ct1ra0; -+ -+ __u32 bpca, bpcs; -+ __u32 bpoa, bpos; -+ -+ __u32 vpmbase; -+ -+ __u32 dbge; -+ __u32 fdbgo; -+ __u32 fdbgb; -+ __u32 fdbgr; -+ __u32 fdbgs; -+ __u32 errstat; -+ -+ /* Pad that we may save more registers into in the future. */ -+ __u32 pad[16]; -+}; -+ -+#define DRM_VC4_PARAM_V3D_IDENT0 0 -+#define DRM_VC4_PARAM_V3D_IDENT1 1 -+#define DRM_VC4_PARAM_V3D_IDENT2 2 -+#define DRM_VC4_PARAM_SUPPORTS_BRANCHES 3 -+#define DRM_VC4_PARAM_SUPPORTS_ETC1 4 -+#define DRM_VC4_PARAM_SUPPORTS_THREADED_FS 5 -+ -+struct drm_vc4_get_param { -+ __u32 param; -+ __u32 pad; -+ __u64 value; -+}; -+ -+struct drm_vc4_get_tiling { -+ __u32 handle; -+ __u32 flags; -+ __u64 modifier; -+}; -+ -+struct drm_vc4_set_tiling { -+ __u32 handle; -+ __u32 flags; -+ __u64 modifier; -+}; -+ -+#if defined(__cplusplus) -+} -+#endif -+ -+#endif /* _VC4_DRM_H_ */ -From 0670340bc6730e3de453e064b8a883a829900945 Mon Sep 17 00:00:00 2001 -From: Eric Anholt -Date: Mon, 8 May 2017 16:43:06 -0700 -Subject: [PATCH] vc4: Drop the u_resource_vtbl no-op layer. - -We only ever attached one vtbl, so it was a waste of space and -indirections. - -(cherry picked from commit 76e4ab57158de8a568572f1acb1d679ce8abb288) ---- - src/gallium/drivers/vc4/vc4_resource.c | 50 +++++++++++++++------------------ - src/gallium/drivers/vc4/vc4_resource.h | 2 +- - src/gallium/drivers/vc4/vc4_simulator.c | 4 +-- - src/gallium/drivers/vc4/vc4_state.c | 4 +-- - 4 files changed, 27 insertions(+), 33 deletions(-) - -diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c -index 596f73dfbf..3b326adbdc 100644 ---- a/src/gallium/drivers/vc4/vc4_resource.c -+++ b/src/gallium/drivers/vc4/vc4_resource.c -@@ -39,7 +39,7 @@ static bool miptree_debug = false; - static bool - vc4_resource_bo_alloc(struct vc4_resource *rsc) - { -- struct pipe_resource *prsc = &rsc->base.b; -+ struct pipe_resource *prsc = &rsc->base; - struct pipe_screen *pscreen = prsc->screen; - struct vc4_bo *bo; - -@@ -379,8 +379,10 @@ vc4_resource_destroy(struct pipe_screen *pscreen, - - static boolean - vc4_resource_get_handle(struct pipe_screen *pscreen, -+ struct pipe_context *pctx, - struct pipe_resource *prsc, -- struct winsys_handle *handle) -+ struct winsys_handle *handle, -+ unsigned usage) - { - struct vc4_resource *rsc = vc4_resource(prsc); - -@@ -388,18 +390,10 @@ vc4_resource_get_handle(struct pipe_screen *pscreen, - handle); - } - --static const struct u_resource_vtbl vc4_resource_vtbl = { -- .resource_get_handle = vc4_resource_get_handle, -- .resource_destroy = vc4_resource_destroy, -- .transfer_map = vc4_resource_transfer_map, -- .transfer_flush_region = u_default_transfer_flush_region, -- .transfer_unmap = vc4_resource_transfer_unmap, --}; -- - static void - vc4_setup_slices(struct vc4_resource *rsc) - { -- struct pipe_resource *prsc = &rsc->base.b; -+ struct pipe_resource *prsc = &rsc->base; - uint32_t width = prsc->width0; - uint32_t height = prsc->height0; - if (prsc->format == PIPE_FORMAT_ETC1_RGB8) { -@@ -502,14 +496,13 @@ vc4_resource_setup(struct pipe_screen *pscreen, - struct vc4_resource *rsc = CALLOC_STRUCT(vc4_resource); - if (!rsc) - return NULL; -- struct pipe_resource *prsc = &rsc->base.b; -+ struct pipe_resource *prsc = &rsc->base; - - *prsc = *tmpl; - - pipe_reference_init(&prsc->reference, 1); - prsc->screen = pscreen; - -- rsc->base.vtbl = &vc4_resource_vtbl; - if (prsc->nr_samples <= 1) - rsc->cpp = util_format_get_blocksize(tmpl->format); - else -@@ -543,7 +536,7 @@ vc4_resource_create(struct pipe_screen *pscreen, - const struct pipe_resource *tmpl) - { - struct vc4_resource *rsc = vc4_resource_setup(pscreen, tmpl); -- struct pipe_resource *prsc = &rsc->base.b; -+ struct pipe_resource *prsc = &rsc->base; - - /* We have to make shared be untiled, since we don't have any way to - * communicate metadata about tiling currently. -@@ -579,7 +572,7 @@ vc4_resource_from_handle(struct pipe_screen *pscreen, - unsigned usage) - { - struct vc4_resource *rsc = vc4_resource_setup(pscreen, tmpl); -- struct pipe_resource *prsc = &rsc->base.b; -+ struct pipe_resource *prsc = &rsc->base; - struct vc4_resource_slice *slice = &rsc->slices[0]; - uint32_t expected_stride = - align(prsc->width0, vc4_utile_width(rsc->cpp)) * rsc->cpp; -@@ -925,16 +918,16 @@ vc4_update_shadow_baselevel_texture(struct pipe_context *pctx, - return; - - perf_debug("Updating %dx%d@%d shadow texture due to %s\n", -- orig->base.b.width0, orig->base.b.height0, -+ orig->base.width0, orig->base.height0, - view->u.tex.first_level, - view->u.tex.first_level ? "base level" : "raster layout"); - -- for (int i = 0; i <= shadow->base.b.last_level; i++) { -- unsigned width = u_minify(shadow->base.b.width0, i); -- unsigned height = u_minify(shadow->base.b.height0, i); -+ for (int i = 0; i <= shadow->base.last_level; i++) { -+ unsigned width = u_minify(shadow->base.width0, i); -+ unsigned height = u_minify(shadow->base.height0, i); - struct pipe_blit_info info = { - .dst = { -- .resource = &shadow->base.b, -+ .resource = &shadow->base, - .level = i, - .box = { - .x = 0, -@@ -944,10 +937,10 @@ vc4_update_shadow_baselevel_texture(struct pipe_context *pctx, - .height = height, - .depth = 1, - }, -- .format = shadow->base.b.format, -+ .format = shadow->base.format, - }, - .src = { -- .resource = &orig->base.b, -+ .resource = &orig->base, - .level = view->u.tex.first_level + i, - .box = { - .x = 0, -@@ -957,7 +950,7 @@ vc4_update_shadow_baselevel_texture(struct pipe_context *pctx, - .height = height, - .depth = 1, - }, -- .format = orig->base.b.format, -+ .format = orig->base.format, - }, - .mask = ~0, - }; -@@ -999,7 +992,7 @@ vc4_get_shadow_index_buffer(struct pipe_context *pctx, - if (ib->user_buffer) { - src = ib->user_buffer; - } else { -- src = pipe_buffer_map_range(pctx, &orig->base.b, -+ src = pipe_buffer_map_range(pctx, &orig->base, - ib->offset, - count * 4, - PIPE_TRANSFER_READ, &src_transfer); -@@ -1022,16 +1015,17 @@ vc4_resource_screen_init(struct pipe_screen *pscreen) - { - pscreen->resource_create = vc4_resource_create; - pscreen->resource_from_handle = vc4_resource_from_handle; -- pscreen->resource_get_handle = u_resource_get_handle_vtbl; - pscreen->resource_destroy = u_resource_destroy_vtbl; -+ pscreen->resource_get_handle = vc4_resource_get_handle; -+ pscreen->resource_destroy = vc4_resource_destroy; - } - - void - vc4_resource_context_init(struct pipe_context *pctx) - { -- pctx->transfer_map = u_transfer_map_vtbl; -- pctx->transfer_flush_region = u_transfer_flush_region_vtbl; -- pctx->transfer_unmap = u_transfer_unmap_vtbl; -+ pctx->transfer_map = vc4_resource_transfer_map; -+ pctx->transfer_flush_region = u_default_transfer_flush_region; -+ pctx->transfer_unmap = vc4_resource_transfer_unmap; - pctx->buffer_subdata = u_default_buffer_subdata; - pctx->texture_subdata = u_default_texture_subdata; - pctx->create_surface = vc4_create_surface; -diff --git a/src/gallium/drivers/vc4/vc4_resource.h b/src/gallium/drivers/vc4/vc4_resource.h -index 27aa4e8728..1a771ff299 100644 ---- a/src/gallium/drivers/vc4/vc4_resource.h -+++ b/src/gallium/drivers/vc4/vc4_resource.h -@@ -52,7 +52,7 @@ struct vc4_surface { - }; - - struct vc4_resource { -- struct u_resource base; -+ struct pipe_resource base; - struct vc4_bo *bo; - struct vc4_resource_slice slices[VC4_MAX_MIP_LEVELS]; - uint32_t cube_map_stride; -diff --git a/src/gallium/drivers/vc4/vc4_simulator.c b/src/gallium/drivers/vc4/vc4_simulator.c -index 9565c49efb..ab701ab560 100644 ---- a/src/gallium/drivers/vc4/vc4_simulator.c -+++ b/src/gallium/drivers/vc4/vc4_simulator.c -@@ -387,7 +387,7 @@ vc4_simulator_flush(struct vc4_context *vc4, - ctex->bo->size); - #endif - -- for (int y = 0; y < ctex->base.b.height0; y++) { -+ for (int y = 0; y < ctex->base.height0; y++) { - memcpy(ctex->bo->map + y * sim_stride, - csim_bo->winsys_map + y * winsys_stride, - row_len); -@@ -448,7 +448,7 @@ vc4_simulator_flush(struct vc4_context *vc4, - } - - if (ctex && csim_bo->winsys_map) { -- for (int y = 0; y < ctex->base.b.height0; y++) { -+ for (int y = 0; y < ctex->base.height0; y++) { - memcpy(csim_bo->winsys_map + y * winsys_stride, - ctex->bo->map + y * sim_stride, - row_len); -diff --git a/src/gallium/drivers/vc4/vc4_state.c b/src/gallium/drivers/vc4/vc4_state.c -index 2e00104e45..31ec19bcbe 100644 ---- a/src/gallium/drivers/vc4/vc4_state.c -+++ b/src/gallium/drivers/vc4/vc4_state.c -@@ -575,7 +575,7 @@ vc4_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc, - (cso->u.tex.first_level != cso->u.tex.last_level)) || - rsc->vc4_format == VC4_TEXTURE_TYPE_RGBA32R) { - struct vc4_resource *shadow_parent = vc4_resource(prsc); -- struct pipe_resource tmpl = shadow_parent->base.b; -+ struct pipe_resource tmpl = shadow_parent->base; - struct vc4_resource *clone; - - tmpl.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET; -@@ -590,7 +590,7 @@ vc4_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc, - } - rsc = vc4_resource(prsc); - clone = vc4_resource(prsc); -- clone->shadow_parent = &shadow_parent->base.b; -+ clone->shadow_parent = &shadow_parent->base; - /* Flag it as needing update of the contents from the parent. */ - clone->writes = shadow_parent->writes - 1; - -From 64a91342aeb0c4a795f2184e22b15cf3079fc6ca Mon Sep 17 00:00:00 2001 -From: Eric Anholt -Date: Mon, 8 May 2017 16:46:59 -0700 -Subject: [PATCH] vc4: Drop pointless indirections around BO import/export. - -I've since found them to be more confusing by adding indirections than -clarifying by screening off resources from the handle/fd import/export -process. - -(cherry picked from commit 50e78cd04f6b40c4cf02774861380d843b00ebb9) ---- - src/gallium/drivers/vc4/vc4_resource.c | 57 +++++++++++++++++++++++++++++----- - src/gallium/drivers/vc4/vc4_screen.c | 54 -------------------------------- - src/gallium/drivers/vc4/vc4_screen.h | 7 ----- - 3 files changed, 49 insertions(+), 69 deletions(-) - -diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c -index 3b326adbdc..7c868b39ec 100644 ---- a/src/gallium/drivers/vc4/vc4_resource.c -+++ b/src/gallium/drivers/vc4/vc4_resource.c -@@ -381,13 +381,31 @@ static boolean - vc4_resource_get_handle(struct pipe_screen *pscreen, - struct pipe_context *pctx, - struct pipe_resource *prsc, -- struct winsys_handle *handle, -+ struct winsys_handle *whandle, - unsigned usage) - { - struct vc4_resource *rsc = vc4_resource(prsc); - -- return vc4_screen_bo_get_handle(pscreen, rsc->bo, rsc->slices[0].stride, -- handle); -+ whandle->stride = rsc->slices[0].stride; -+ -+ /* If we're passing some reference to our BO out to some other part of -+ * the system, then we can't do any optimizations about only us being -+ * the ones seeing it (like BO caching or shadow update avoidance). -+ */ -+ rsc->bo->private = false; -+ -+ switch (whandle->type) { -+ case DRM_API_HANDLE_TYPE_SHARED: -+ return vc4_bo_flink(rsc->bo, &whandle->handle); -+ case DRM_API_HANDLE_TYPE_KMS: -+ whandle->handle = rsc->bo->handle; -+ return TRUE; -+ case DRM_API_HANDLE_TYPE_FD: -+ whandle->handle = vc4_bo_get_dmabuf(rsc->bo); -+ return whandle->handle != -1; -+ } -+ -+ return FALSE; - } - - static void -@@ -568,9 +586,10 @@ vc4_resource_create(struct pipe_screen *pscreen, - static struct pipe_resource * - vc4_resource_from_handle(struct pipe_screen *pscreen, - const struct pipe_resource *tmpl, -- struct winsys_handle *handle, -+ struct winsys_handle *whandle, - unsigned usage) - { -+ struct vc4_screen *screen = vc4_screen(pscreen); - struct vc4_resource *rsc = vc4_resource_setup(pscreen, tmpl); - struct pipe_resource *prsc = &rsc->base; - struct vc4_resource_slice *slice = &rsc->slices[0]; -@@ -580,7 +599,7 @@ vc4_resource_from_handle(struct pipe_screen *pscreen, - if (!rsc) - return NULL; - -- if (handle->stride != expected_stride) { -+ if (whandle->stride != expected_stride) { - static bool warned = false; - if (!warned) { - warned = true; -@@ -589,18 +608,40 @@ vc4_resource_from_handle(struct pipe_screen *pscreen, - "unsupported stride %d instead of %d\n", - prsc->width0, prsc->height0, - util_format_short_name(prsc->format), -- handle->stride, -+ whandle->stride, - expected_stride); - } - goto fail; - } - - rsc->tiled = false; -- rsc->bo = vc4_screen_bo_from_handle(pscreen, handle); -+ -+ if (whandle->offset != 0) { -+ fprintf(stderr, -+ "Attempt to import unsupported winsys offset %u\n", -+ whandle->offset); -+ return NULL; -+ } -+ -+ switch (whandle->type) { -+ case DRM_API_HANDLE_TYPE_SHARED: -+ rsc->bo = vc4_bo_open_name(screen, -+ whandle->handle, whandle->stride); -+ break; -+ case DRM_API_HANDLE_TYPE_FD: -+ rsc->bo = vc4_bo_open_dmabuf(screen, -+ whandle->handle, whandle->stride); -+ break; -+ default: -+ fprintf(stderr, -+ "Attempt to import unsupported handle type %d\n", -+ whandle->type); -+ } -+ - if (!rsc->bo) - goto fail; - -- slice->stride = handle->stride; -+ slice->stride = whandle->stride; - slice->tiling = VC4_TILING_FORMAT_LINEAR; - - rsc->vc4_format = get_resource_texture_format(prsc); -diff --git a/src/gallium/drivers/vc4/vc4_screen.c b/src/gallium/drivers/vc4/vc4_screen.c -index 27d23dc964..405a13f16e 100644 ---- a/src/gallium/drivers/vc4/vc4_screen.c -+++ b/src/gallium/drivers/vc4/vc4_screen.c -@@ -654,57 +654,3 @@ vc4_screen_create(int fd) - ralloc_free(pscreen); - return NULL; - } -- --boolean --vc4_screen_bo_get_handle(struct pipe_screen *pscreen, -- struct vc4_bo *bo, -- unsigned stride, -- struct winsys_handle *whandle) --{ -- whandle->stride = stride; -- -- /* If we're passing some reference to our BO out to some other part of -- * the system, then we can't do any optimizations about only us being -- * the ones seeing it (like BO caching or shadow update avoidance). -- */ -- bo->private = false; -- -- switch (whandle->type) { -- case DRM_API_HANDLE_TYPE_SHARED: -- return vc4_bo_flink(bo, &whandle->handle); -- case DRM_API_HANDLE_TYPE_KMS: -- whandle->handle = bo->handle; -- return TRUE; -- case DRM_API_HANDLE_TYPE_FD: -- whandle->handle = vc4_bo_get_dmabuf(bo); -- return whandle->handle != -1; -- } -- -- return FALSE; --} -- --struct vc4_bo * --vc4_screen_bo_from_handle(struct pipe_screen *pscreen, -- struct winsys_handle *whandle) --{ -- struct vc4_screen *screen = vc4_screen(pscreen); -- -- if (whandle->offset != 0) { -- fprintf(stderr, -- "Attempt to import unsupported winsys offset %u\n", -- whandle->offset); -- return NULL; -- } -- -- switch (whandle->type) { -- case DRM_API_HANDLE_TYPE_SHARED: -- return vc4_bo_open_name(screen, whandle->handle, whandle->stride); -- case DRM_API_HANDLE_TYPE_FD: -- return vc4_bo_open_dmabuf(screen, whandle->handle, whandle->stride); -- default: -- fprintf(stderr, -- "Attempt to import unsupported handle type %d\n", -- whandle->type); -- return NULL; -- } --} -diff --git a/src/gallium/drivers/vc4/vc4_screen.h b/src/gallium/drivers/vc4/vc4_screen.h -index 34d15381ae..0f80ffb346 100644 ---- a/src/gallium/drivers/vc4/vc4_screen.h -+++ b/src/gallium/drivers/vc4/vc4_screen.h -@@ -102,13 +102,6 @@ vc4_screen(struct pipe_screen *screen) - } - - struct pipe_screen *vc4_screen_create(int fd); --boolean vc4_screen_bo_get_handle(struct pipe_screen *pscreen, -- struct vc4_bo *bo, -- unsigned stride, -- struct winsys_handle *whandle); --struct vc4_bo * --vc4_screen_bo_from_handle(struct pipe_screen *pscreen, -- struct winsys_handle *whandle); - - const void * - vc4_screen_get_compiler_options(struct pipe_screen *pscreen, -From 427bd8275b9d4bb7a52d4e0dd4881a91a96c9c5b Mon Sep 17 00:00:00 2001 -From: Eric Anholt -Date: Mon, 5 Jun 2017 14:50:26 -0700 -Subject: [PATCH] vc4: Set shareable BOs as T tiled if possible. - -X11 and GL compositor performance on VC4 has been terrible because of our -SHARED-usage buffers all being forced to linear. This swaps SHARED && -!LINEAR buffers over to being tiled. - -This is an expected win for all GL compositors during rendering (a full -copy of each shared texture per draw call), allows X11 to be used with -decent performance without a GL compositor, and improves X11 windowed -swapbuffers performance as well. It also halves the memory usage of -shared buffers that get textured from. The only cost should be idle -systems with a scanout-only buffer that isn't flagged as LINEAR, in which -case the memory bandwidth cost of scanout goes up ~25%. - -(cherry picked from commit ba654a2fc194f38262a290c378f581fbf280efe2) ---- - src/gallium/drivers/vc4/vc4_bufmgr.c | 7 +++ - src/gallium/drivers/vc4/vc4_resource.c | 108 ++++++++++++++++++++++---------- - src/gallium/drivers/vc4/vc4_simulator.c | 8 +++ - 3 files changed, 90 insertions(+), 33 deletions(-) - -diff --git a/src/gallium/drivers/vc4/vc4_bufmgr.c b/src/gallium/drivers/vc4/vc4_bufmgr.c -index 12af7f8a9e..25e95ff3c5 100644 ---- a/src/gallium/drivers/vc4/vc4_bufmgr.c -+++ b/src/gallium/drivers/vc4/vc4_bufmgr.c -@@ -27,6 +27,7 @@ - #include - #include - #include -+#include - - #include "util/u_hash_table.h" - #include "util/u_memory.h" -@@ -282,6 +283,12 @@ vc4_bo_last_unreference_locked_timed(struct vc4_bo *bo, time_t time) - return; - } - -+ struct drm_vc4_set_tiling set_tiling = { -+ .handle = bo->handle, -+ .modifier = DRM_FORMAT_MOD_NONE, -+ }; -+ (void)vc4_ioctl(screen->fd, DRM_IOCTL_VC4_SET_TILING, &set_tiling); -+ - if (cache->size_list_size <= page_index) { - struct list_head *new_list = - ralloc_array(screen, struct list_head, page_index + 1); -diff --git a/src/gallium/drivers/vc4/vc4_resource.c b/src/gallium/drivers/vc4/vc4_resource.c -index 7c868b39ec..eb462707a7 100644 ---- a/src/gallium/drivers/vc4/vc4_resource.c -+++ b/src/gallium/drivers/vc4/vc4_resource.c -@@ -29,10 +29,12 @@ - #include "util/u_surface.h" - #include "util/u_upload_mgr.h" - -+#include "vc4_drm.h" - #include "vc4_screen.h" - #include "vc4_context.h" - #include "vc4_resource.h" - #include "vc4_tiling.h" -+#include "drm_fourcc.h" - - static bool miptree_debug = false; - -@@ -553,30 +555,67 @@ struct pipe_resource * - vc4_resource_create(struct pipe_screen *pscreen, - const struct pipe_resource *tmpl) - { -+ struct vc4_screen *screen = vc4_screen(pscreen); - struct vc4_resource *rsc = vc4_resource_setup(pscreen, tmpl); - struct pipe_resource *prsc = &rsc->base; - -- /* We have to make shared be untiled, since we don't have any way to -- * communicate metadata about tiling currently. -+ /* Use a tiled layout if we can, for better 3D performance. */ -+ rsc->tiled = true; -+ -+ /* VBOs/PBOs are untiled (and 1 height). */ -+ if (tmpl->target == PIPE_BUFFER) -+ rsc->tiled = false; -+ -+ /* MSAA buffers are linear. */ -+ if (tmpl->nr_samples > 1) -+ rsc->tiled = false; -+ -+ /* Cursors are always linear, and the user can request linear as -+ * well. - */ -- if (tmpl->target == PIPE_BUFFER || -- tmpl->nr_samples > 1 || -- (tmpl->bind & (PIPE_BIND_SCANOUT | -- PIPE_BIND_LINEAR | -- PIPE_BIND_SHARED | -- PIPE_BIND_CURSOR))) { -+ if (tmpl->bind & (PIPE_BIND_LINEAR | -+ PIPE_BIND_CURSOR)) { - rsc->tiled = false; -- } else { -- rsc->tiled = true; - } - -- if (tmpl->target != PIPE_BUFFER) -- rsc->vc4_format = get_resource_texture_format(prsc); -+ /* No shared objects with LT format -- the kernel only has T-format -+ * metadata. LT objects are small enough it's not worth the trouble -+ * to give them metadata to tile. -+ */ -+ if ((tmpl->bind & PIPE_BIND_SHARED) && -+ vc4_size_is_lt(prsc->width0, prsc->height0, rsc->cpp)) { -+ rsc->tiled = false; -+ } - - vc4_setup_slices(rsc); - if (!vc4_resource_bo_alloc(rsc)) - goto fail; - -+ if (tmpl->bind & PIPE_BIND_SHARED) { -+ assert(rsc->slices[0].tiling == VC4_TILING_FORMAT_T); -+ -+ struct drm_vc4_set_tiling set_tiling = { -+ .handle = rsc->bo->handle, -+ .modifier = DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED, -+ }; -+ int ret = vc4_ioctl(screen->fd, -+ DRM_IOCTL_VC4_SET_TILING, -+ &set_tiling); -+ -+ /* If we hit this, we're probably on an old kernel. Fall back -+ * to linear. -+ */ -+ if (ret != 0) { -+ rsc->tiled = false; -+ vc4_setup_slices(rsc); -+ if (!vc4_resource_bo_alloc(rsc)) -+ goto fail; -+ } -+ } -+ -+ if (tmpl->target != PIPE_BUFFER) -+ rsc->vc4_format = get_resource_texture_format(prsc); -+ - return prsc; - fail: - vc4_resource_destroy(pscreen, prsc); -@@ -593,29 +632,10 @@ vc4_resource_from_handle(struct pipe_screen *pscreen, - struct vc4_resource *rsc = vc4_resource_setup(pscreen, tmpl); - struct pipe_resource *prsc = &rsc->base; - struct vc4_resource_slice *slice = &rsc->slices[0]; -- uint32_t expected_stride = -- align(prsc->width0, vc4_utile_width(rsc->cpp)) * rsc->cpp; - - if (!rsc) - return NULL; - -- if (whandle->stride != expected_stride) { -- static bool warned = false; -- if (!warned) { -- warned = true; -- fprintf(stderr, -- "Attempting to import %dx%d %s with " -- "unsupported stride %d instead of %d\n", -- prsc->width0, prsc->height0, -- util_format_short_name(prsc->format), -- whandle->stride, -- expected_stride); -- } -- goto fail; -- } -- -- rsc->tiled = false; -- - if (whandle->offset != 0) { - fprintf(stderr, - "Attempt to import unsupported winsys offset %u\n", -@@ -641,10 +661,17 @@ vc4_resource_from_handle(struct pipe_screen *pscreen, - if (!rsc->bo) - goto fail; - -- slice->stride = whandle->stride; -- slice->tiling = VC4_TILING_FORMAT_LINEAR; -+ struct drm_vc4_get_tiling get_tiling = { -+ .handle = rsc->bo->handle, -+ }; -+ int ret = vc4_ioctl(screen->fd, DRM_IOCTL_VC4_GET_TILING, &get_tiling); -+ if (ret == 0 && -+ get_tiling.modifier == DRM_FORMAT_MOD_BROADCOM_VC4_T_TILED) { -+ rsc->tiled = true; -+ } - - rsc->vc4_format = get_resource_texture_format(prsc); -+ vc4_setup_slices(rsc); - - if (miptree_debug) { - fprintf(stderr, -@@ -655,6 +682,21 @@ vc4_resource_from_handle(struct pipe_screen *pscreen, - slice->stride, slice->offset); - } - -+ if (whandle->stride != rsc->slices[0].stride) { -+ static bool warned = false; -+ if (!warned) { -+ warned = true; -+ fprintf(stderr, -+ "Attempting to import %dx%d %s with " -+ "unsupported stride %d instead of %d\n", -+ prsc->width0, prsc->height0, -+ util_format_short_name(prsc->format), -+ whandle->stride, -+ rsc->slices[0].stride); -+ } -+ goto fail; -+ } -+ - return prsc; - - fail: -diff --git a/src/gallium/drivers/vc4/vc4_simulator.c b/src/gallium/drivers/vc4/vc4_simulator.c -index ab701ab560..bd063a8432 100644 ---- a/src/gallium/drivers/vc4/vc4_simulator.c -+++ b/src/gallium/drivers/vc4/vc4_simulator.c -@@ -658,9 +658,17 @@ vc4_simulator_ioctl(int fd, unsigned long request, void *args) - case DRM_IOCTL_GEM_CLOSE: - return vc4_simulator_gem_close_ioctl(fd, args); - -+ case DRM_IOCTL_VC4_GET_TILING: -+ case DRM_IOCTL_VC4_SET_TILING: -+ /* Disable these for now, since the sharing with i965 requires -+ * linear buffers. -+ */ -+ return -1; -+ - case DRM_IOCTL_GEM_OPEN: - case DRM_IOCTL_GEM_FLINK: - return drmIoctl(fd, request, args); -+ - default: - fprintf(stderr, "Unknown ioctl 0x%08x\n", (int)request); - abort(); diff --git a/mesa-7.1.2-etnaviv-fixes.patch b/mesa-7.1.2-etnaviv-fixes.patch deleted file mode 100644 index cdaba29..0000000 --- a/mesa-7.1.2-etnaviv-fixes.patch +++ /dev/null @@ -1,122 +0,0 @@ -From patchwork Thu Jun 8 16:25:34 2017 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Subject: [Mesa-dev,1/2] etnaviv: fix varying interpolation -From: Lucas Stach -X-Patchwork-Id: 160584 -Message-Id: <20170608162535.2198-1-l.stach@pengutronix.de> -To: mesa-dev@lists.freedesktop.org -Cc: graphics@pengutronix.de, etnaviv@lists.freedesktop.org, - patchwork-lst@pengutronix.de -Date: Thu, 8 Jun 2017 18:25:34 +0200 - -It seems that newer cores don't use the PA_ATTRIBUTES to decide if the -varying should bypass the flat shading, but derive this from the component -use. This fixes flat shading on GC880+. - -VARYING_COMPONENT_USE_POINTCOORD is a bit of a misnomer now, as it isn't -only used for pointcoords, but missing a better name I left it as-is. - -Signed-off-by: Lucas Stach ---- - src/gallium/drivers/etnaviv/etnaviv_compiler.c | 24 ++++++++++-------------- - 1 file changed, 10 insertions(+), 14 deletions(-) - -diff --git a/src/gallium/drivers/etnaviv/etnaviv_compiler.c b/src/gallium/drivers/etnaviv/etnaviv_compiler.c -index eafb511bb813..2605924613c7 100644 ---- a/src/gallium/drivers/etnaviv/etnaviv_compiler.c -+++ b/src/gallium/drivers/etnaviv/etnaviv_compiler.c -@@ -2552,6 +2552,7 @@ etna_link_shader(struct etna_shader_link_info *info, - const struct etna_shader_inout *fsio = &fs->infile.reg[idx]; - const struct etna_shader_inout *vsio = etna_shader_vs_lookup(vs, fsio); - struct etna_varying *varying; -+ bool interpolate = fsio->semantic.Name != TGSI_SEMANTIC_COLOR; - - assert(fsio->reg > 0 && fsio->reg <= ARRAY_SIZE(info->varyings)); - -@@ -2561,28 +2562,23 @@ etna_link_shader(struct etna_shader_link_info *info, - varying = &info->varyings[fsio->reg - 1]; - varying->num_components = fsio->num_components; - -- if (fsio->semantic.Name == TGSI_SEMANTIC_COLOR) /* colors affected by flat shading */ -+ if (!interpolate) /* colors affected by flat shading */ - varying->pa_attributes = 0x200; - else /* texture coord or other bypasses flat shading */ - varying->pa_attributes = 0x2f1; - -- if (fsio->semantic.Name == TGSI_SEMANTIC_PCOORD) { -- varying->use[0] = VARYING_COMPONENT_USE_POINTCOORD_X; -- varying->use[1] = VARYING_COMPONENT_USE_POINTCOORD_Y; -- varying->use[2] = VARYING_COMPONENT_USE_USED; -- varying->use[3] = VARYING_COMPONENT_USE_USED; -- varying->reg = 0; /* replaced by point coord -- doesn't matter */ -+ varying->use[0] = interpolate ? VARYING_COMPONENT_USE_POINTCOORD_X : VARYING_COMPONENT_USE_USED; -+ varying->use[1] = interpolate ? VARYING_COMPONENT_USE_POINTCOORD_Y : VARYING_COMPONENT_USE_USED; -+ varying->use[2] = VARYING_COMPONENT_USE_USED; -+ varying->use[3] = VARYING_COMPONENT_USE_USED; -+ varying->reg = vsio->reg; /* replaced by point coord -- doesn't matter */ -+ -+ -+ if (fsio->semantic.Name == TGSI_SEMANTIC_PCOORD) - continue; -- } - - if (vsio == NULL) - return true; /* not found -- link error */ -- -- varying->use[0] = VARYING_COMPONENT_USE_USED; -- varying->use[1] = VARYING_COMPONENT_USE_USED; -- varying->use[2] = VARYING_COMPONENT_USE_USED; -- varying->use[3] = VARYING_COMPONENT_USE_USED; -- varying->reg = vsio->reg; - } - - assert(info->num_varyings == fs->infile.num_reg); -From patchwork Thu Jun 8 16:25:35 2017 -Content-Type: text/plain; charset="utf-8" -MIME-Version: 1.0 -Content-Transfer-Encoding: 7bit -Subject: [Mesa-dev,2/2] etnaviv: remove flat shading workaround -From: Lucas Stach -X-Patchwork-Id: 160585 -Message-Id: <20170608162535.2198-2-l.stach@pengutronix.de> -To: mesa-dev@lists.freedesktop.org -Cc: graphics@pengutronix.de, etnaviv@lists.freedesktop.org, - patchwork-lst@pengutronix.de -Date: Thu, 8 Jun 2017 18:25:35 +0200 - -It turned out not to be a hardware bug, but the shader compiler -emitting wrong varying component use information. With that fixed -we can turn flat shading back on. - -Signed-off-by: Lucas Stach -Reviewed-by: Philipp Zabel ---- - src/gallium/drivers/etnaviv/etnaviv_rasterizer.c | 6 +----- - 1 file changed, 1 insertion(+), 5 deletions(-) - -diff --git a/src/gallium/drivers/etnaviv/etnaviv_rasterizer.c b/src/gallium/drivers/etnaviv/etnaviv_rasterizer.c -index 4990fd180257..56f2735e8a18 100644 ---- a/src/gallium/drivers/etnaviv/etnaviv_rasterizer.c -+++ b/src/gallium/drivers/etnaviv/etnaviv_rasterizer.c -@@ -38,10 +38,6 @@ etna_rasterizer_state_create(struct pipe_context *pctx, - struct etna_rasterizer_state *cs; - struct etna_context *ctx = etna_context(pctx); - -- /* Disregard flatshading on GC880+, as a HW bug there seem to disable all -- * varying interpolation if it's enabled */ -- bool flatshade = ctx->screen->model < 880 ? so->flatshade : false; -- - if (so->fill_front != so->fill_back) - DBG("Different front and back fill mode not supported"); - -@@ -51,7 +47,7 @@ etna_rasterizer_state_create(struct pipe_context *pctx, - - cs->base = *so; - -- cs->PA_CONFIG = (flatshade ? VIVS_PA_CONFIG_SHADE_MODEL_FLAT : VIVS_PA_CONFIG_SHADE_MODEL_SMOOTH) | -+ cs->PA_CONFIG = (so->flatshade ? VIVS_PA_CONFIG_SHADE_MODEL_FLAT : VIVS_PA_CONFIG_SHADE_MODEL_SMOOTH) | - translate_cull_face(so->cull_face, so->front_ccw) | - translate_polygon_mode(so->fill_front) | - COND(so->point_quad_rasterization, VIVS_PA_CONFIG_POINT_SPRITE_ENABLE) | diff --git a/mesa-7.1.2-etnaviv-upstream-fixes.patch b/mesa-7.1.2-etnaviv-upstream-fixes.patch deleted file mode 100644 index a3ceabf..0000000 --- a/mesa-7.1.2-etnaviv-upstream-fixes.patch +++ /dev/null @@ -1,640 +0,0 @@ -From f8a39914586de004759ea9cbda1335bdf0790cdc Mon Sep 17 00:00:00 2001 -From: Lucas Stach -Date: Wed, 10 May 2017 18:01:06 +0200 -Subject: [PATCH 0479/1430] etnaviv: apply feature overrides in one central - location - -This way we can just test the feature bits and don't need to spread -the debug overrides to all locations touching a feature. - -Signed-off-by: Lucas Stach -Reviewed-By: Wladimir J. van der Laan -Reviewed-by: Christian Gmeiner ---- - src/gallium/drivers/etnaviv/etnaviv_clear_blit.c | 6 ++---- - src/gallium/drivers/etnaviv/etnaviv_resource.c | 2 +- - src/gallium/drivers/etnaviv/etnaviv_screen.c | 10 ++++++++++ - src/gallium/drivers/etnaviv/etnaviv_surface.c | 2 +- - src/gallium/drivers/etnaviv/etnaviv_zsa.c | 9 +++++---- - 5 files changed, 19 insertions(+), 10 deletions(-) - -diff --git a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c -index 528b57389d..ae1c586288 100644 ---- a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c -+++ b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c -@@ -111,8 +111,7 @@ etna_blit_clear_color(struct pipe_context *pctx, struct pipe_surface *dst, - if (surf->surf.ts_size) { /* TS: use precompiled clear command */ - ctx->framebuffer.TS_COLOR_CLEAR_VALUE = new_clear_value; - -- if (!DBG_ENABLED(ETNA_DBG_NO_AUTODISABLE) && -- VIV_FEATURE(ctx->screen, chipMinorFeatures1, AUTO_DISABLE)) { -+ if (VIV_FEATURE(ctx->screen, chipMinorFeatures1, AUTO_DISABLE)) { - /* Set number of color tiles to be filled */ - etna_set_state(ctx->stream, VIVS_TS_COLOR_AUTO_DISABLE_COUNT, - surf->surf.padded_width * surf->surf.padded_height / 16); -@@ -171,8 +170,7 @@ etna_blit_clear_zs(struct pipe_context *pctx, struct pipe_surface *dst, - if (surf->surf.ts_size) { /* TS: use precompiled clear command */ - /* Set new clear depth value */ - ctx->framebuffer.TS_DEPTH_CLEAR_VALUE = new_clear_value; -- if (!DBG_ENABLED(ETNA_DBG_NO_AUTODISABLE) && -- VIV_FEATURE(ctx->screen, chipMinorFeatures1, AUTO_DISABLE)) { -+ if (VIV_FEATURE(ctx->screen, chipMinorFeatures1, AUTO_DISABLE)) { - /* Set number of depth tiles to be filled */ - etna_set_state(ctx->stream, VIVS_TS_DEPTH_AUTO_DISABLE_COUNT, - surf->surf.padded_width * surf->surf.padded_height / 16); -diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c b/src/gallium/drivers/etnaviv/etnaviv_resource.c -index 26f2ed7334..103b53c1c3 100644 ---- a/src/gallium/drivers/etnaviv/etnaviv_resource.c -+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c -@@ -247,7 +247,7 @@ etna_resource_create(struct pipe_screen *pscreen, - layout = ETNA_LAYOUT_LINEAR; - } else if (templat->target != PIPE_BUFFER) { - bool want_multitiled = false; -- bool want_supertiled = screen->specs.can_supertile && !DBG_ENABLED(ETNA_DBG_NO_SUPERTILE); -+ bool want_supertiled = screen->specs.can_supertile; - - /* When this GPU supports single-buffer rendering, don't ever enable - * multi-tiling. This replicates the blob behavior on GC3000. -diff --git a/src/gallium/drivers/etnaviv/etnaviv_screen.c b/src/gallium/drivers/etnaviv/etnaviv_screen.c -index d8a970b910..9f1b44922a 100644 ---- a/src/gallium/drivers/etnaviv/etnaviv_screen.c -+++ b/src/gallium/drivers/etnaviv/etnaviv_screen.c -@@ -831,6 +831,16 @@ etna_screen_create(struct etna_device *dev, struct etna_gpu *gpu, - if (!etna_get_specs(screen)) - goto fail; - -+ /* apply debug options that disable individual features */ -+ if (DBG_ENABLED(ETNA_DBG_NO_EARLY_Z)) -+ screen->features[viv_chipFeatures] |= chipFeatures_NO_EARLY_Z; -+ if (DBG_ENABLED(ETNA_DBG_NO_TS)) -+ screen->features[viv_chipFeatures] &= ~chipFeatures_FAST_CLEAR; -+ if (DBG_ENABLED(ETNA_DBG_NO_AUTODISABLE)) -+ screen->features[viv_chipMinorFeatures1] &= ~chipMinorFeatures1_AUTO_DISABLE; -+ if (DBG_ENABLED(ETNA_DBG_NO_SUPERTILE)) -+ screen->specs.can_supertile = 0; -+ - pscreen->destroy = etna_screen_destroy; - pscreen->get_param = etna_screen_get_param; - pscreen->get_paramf = etna_screen_get_paramf; -diff --git a/src/gallium/drivers/etnaviv/etnaviv_surface.c b/src/gallium/drivers/etnaviv/etnaviv_surface.c -index 1db9b40a51..4b95f6575a 100644 ---- a/src/gallium/drivers/etnaviv/etnaviv_surface.c -+++ b/src/gallium/drivers/etnaviv/etnaviv_surface.c -@@ -66,7 +66,7 @@ etna_create_surface(struct pipe_context *pctx, struct pipe_resource *prsc, - - if (VIV_FEATURE(ctx->screen, chipFeatures, FAST_CLEAR) && - VIV_FEATURE(ctx->screen, chipMinorFeatures0, MC20) && -- !DBG_ENABLED(ETNA_DBG_NO_TS) && !rsc->ts_bo && -+ !rsc->ts_bo && - (rsc->levels[level].padded_width & ETNA_RS_WIDTH_MASK) == 0 && - (rsc->levels[level].padded_height & ETNA_RS_HEIGHT_MASK) == 0) { - etna_screen_resource_alloc_ts(pctx->screen, rsc); -diff --git a/src/gallium/drivers/etnaviv/etnaviv_zsa.c b/src/gallium/drivers/etnaviv/etnaviv_zsa.c -index 7caba279b3..22c2020fe5 100644 ---- a/src/gallium/drivers/etnaviv/etnaviv_zsa.c -+++ b/src/gallium/drivers/etnaviv/etnaviv_zsa.c -@@ -27,13 +27,17 @@ - #include "etnaviv_zsa.h" - - #include "etnaviv_context.h" -+#include "etnaviv_screen.h" - #include "etnaviv_translate.h" - #include "util/u_memory.h" - -+#include "hw/common.xml.h" -+ - void * - etna_zsa_state_create(struct pipe_context *pctx, - const struct pipe_depth_stencil_alpha_state *so) - { -+ struct etna_context *ctx = etna_context(pctx); - struct etna_zsa_state *cs = CALLOC_STRUCT(etna_zsa_state); - - if (!cs) -@@ -42,7 +46,7 @@ etna_zsa_state_create(struct pipe_context *pctx, - cs->base = *so; - - /* XXX does stencil[0] / stencil[1] order depend on rs->front_ccw? */ -- bool early_z = true; -+ bool early_z = !VIV_FEATURE(ctx->screen, chipFeatures, NO_EARLY_Z); - bool disable_zs = - (!so->depth.enabled || so->depth.func == PIPE_FUNC_ALWAYS) && - !so->depth.writemask; -@@ -88,9 +92,6 @@ etna_zsa_state_create(struct pipe_context *pctx, - if (so->depth.enabled == false || so->depth.func == PIPE_FUNC_ALWAYS) - early_z = false; - -- if (DBG_ENABLED(ETNA_DBG_NO_EARLY_Z)) -- early_z = false; -- - /* compare funcs have 1 to 1 mapping */ - cs->PE_DEPTH_CONFIG = - VIVS_PE_DEPTH_CONFIG_DEPTH_FUNC(so->depth.enabled ? so->depth.func --- -2.13.0 - -From ba0b7de7e36a5032c709ce1f9b36706bdbba5097 Mon Sep 17 00:00:00 2001 -From: Lucas Stach -Date: Wed, 10 May 2017 18:01:07 +0200 -Subject: [PATCH 0480/1430] etnaviv: clean up sampler view reference counting - -Use the proper pipe_resource_reference function instead of -rolling our own. - -Signed-off-by: Lucas Stach -Reviewed-by: Christian Gmeiner ---- - src/gallium/drivers/etnaviv/etnaviv_texture.c | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/src/gallium/drivers/etnaviv/etnaviv_texture.c b/src/gallium/drivers/etnaviv/etnaviv_texture.c -index 3a842381ac..6f77af286f 100644 ---- a/src/gallium/drivers/etnaviv/etnaviv_texture.c -+++ b/src/gallium/drivers/etnaviv/etnaviv_texture.c -@@ -182,9 +182,9 @@ etna_create_sampler_view(struct pipe_context *pctx, struct pipe_resource *prsc, - } - - sv->base = *so; -- pipe_reference(NULL, &prsc->reference); -- sv->base.texture = prsc; -- sv->base.reference.count = 1; -+ pipe_reference_init(&sv->base.reference, 1); -+ sv->base.texture = NULL; -+ pipe_resource_reference(&sv->base.texture, prsc); - sv->base.context = pctx; - - /* merged with sampler state */ --- -2.13.0 - -From cb16d9103480687c414519bed5256217c9e7aaad Mon Sep 17 00:00:00 2001 -From: Philipp Zabel -Date: Wed, 10 May 2017 18:01:08 +0200 -Subject: [PATCH 0481/1430] etnaviv: increment the resource seqno in - resource_changed - -Just increment the resource seqno instead of setting the texture -seqno to be lower by one than the resource seqno. - -Signed-off-by: Philipp Zabel -Signed-off-by: Lucas Stach -Reviewed-By: Wladimir J. van der Laan -Reviewed-by: Christian Gmeiner ---- - src/gallium/drivers/etnaviv/etnaviv_resource.c | 6 +----- - 1 file changed, 1 insertion(+), 5 deletions(-) - -diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c b/src/gallium/drivers/etnaviv/etnaviv_resource.c -index 103b53c1c3..1341e1ea23 100644 ---- a/src/gallium/drivers/etnaviv/etnaviv_resource.c -+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c -@@ -286,11 +286,7 @@ etna_resource_changed(struct pipe_screen *pscreen, struct pipe_resource *prsc) - { - struct etna_resource *res = etna_resource(prsc); - -- /* Make sure texture is older than the imported renderable buffer, -- * so etna_update_sampler_source will copy the pixel data again. -- */ -- if (res->texture) -- etna_resource(res->texture)->seqno = res->seqno - 1; -+ res->seqno++; - } - - static void --- -2.13.0 -From a276c32a08bd41ceb8fd9b604ba9ac8229d59b64 Mon Sep 17 00:00:00 2001 -From: Lucas Stach -Date: Thu, 18 May 2017 15:37:02 +0200 -Subject: [PATCH 1243/1430] etnaviv: slim down resource waiting - -cpu_prep() already does all the required waiting, so the only thing that -needs to be done is flushing the commandstream, if a GPU write is pending. - -Signed-off-by: Lucas Stach -Reviewed-by: Wladimir J. van der Laan ---- - src/gallium/drivers/etnaviv/etnaviv_clear_blit.c | 5 +++-- - src/gallium/drivers/etnaviv/etnaviv_resource.c | 16 ---------------- - src/gallium/drivers/etnaviv/etnaviv_resource.h | 3 --- - src/gallium/drivers/etnaviv/etnaviv_transfer.c | 5 +++-- - 4 files changed, 6 insertions(+), 23 deletions(-) - -diff --git a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c -index ae1c586288..ea416bf192 100644 ---- a/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c -+++ b/src/gallium/drivers/etnaviv/etnaviv_clear_blit.c -@@ -528,8 +528,9 @@ etna_try_rs_blit(struct pipe_context *pctx, - - manual: - if (src->layout == ETNA_LAYOUT_TILED && dst->layout == ETNA_LAYOUT_TILED) { -- etna_resource_wait(pctx, dst); -- etna_resource_wait(pctx, src); -+ if ((src->status & ETNA_PENDING_WRITE) || -+ (dst->status & ETNA_PENDING_WRITE)) -+ pctx->flush(pctx, NULL, 0); - return etna_manual_blit(dst, dst_lev, dst_offset, src, src_lev, src_offset, blit_info); - } - -diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c b/src/gallium/drivers/etnaviv/etnaviv_resource.c -index 1341e1ea23..9aa1aa617a 100644 ---- a/src/gallium/drivers/etnaviv/etnaviv_resource.c -+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c -@@ -429,22 +429,6 @@ etna_resource_used(struct etna_context *ctx, struct pipe_resource *prsc, - } - - void --etna_resource_wait(struct pipe_context *pctx, struct etna_resource *rsc) --{ -- if (rsc->status & ETNA_PENDING_WRITE) { -- struct pipe_fence_handle *fence; -- struct pipe_screen *pscreen = pctx->screen; -- -- pctx->flush(pctx, &fence, 0); -- -- if (!pscreen->fence_finish(pscreen, pctx, fence, 5000000000ULL)) -- BUG("fence timed out (hung GPU?)"); -- -- pscreen->fence_reference(pscreen, &fence, NULL); -- } --} -- --void - etna_resource_screen_init(struct pipe_screen *pscreen) - { - pscreen->can_create_resource = etna_screen_can_create_resource; -diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.h b/src/gallium/drivers/etnaviv/etnaviv_resource.h -index a8d42ee1a0..913316f193 100644 ---- a/src/gallium/drivers/etnaviv/etnaviv_resource.h -+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.h -@@ -124,9 +124,6 @@ void - etna_resource_used(struct etna_context *ctx, struct pipe_resource *prsc, - enum etna_resource_status status); - --void --etna_resource_wait(struct pipe_context *ctx, struct etna_resource *rsc); -- - static inline void - resource_read(struct etna_context *ctx, struct pipe_resource *prsc) - { -diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c b/src/gallium/drivers/etnaviv/etnaviv_transfer.c -index 4809b04ff9..269bd498f8 100644 ---- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c -+++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c -@@ -199,8 +199,9 @@ etna_transfer_map(struct pipe_context *pctx, struct pipe_resource *prsc, - /* Always sync if we have the temporary resource. The PIPE_TRANSFER_READ - * case could be optimised if we knew whether the resource has outstanding - * rendering. */ -- if (usage & PIPE_TRANSFER_READ || trans->rsc) -- etna_resource_wait(pctx, rsc); -+ if ((usage & PIPE_TRANSFER_READ || trans->rsc) && -+ rsc->status & ETNA_PENDING_WRITE) -+ pctx->flush(pctx, NULL, 0); - - /* XXX we don't handle PIPE_TRANSFER_FLUSH_EXPLICIT; this flag can be ignored - * when mapping in-place, --- -2.13.0 - -From c3b2c7a75f1ef6306d0218d92564319d22cfc8fe Mon Sep 17 00:00:00 2001 -From: Lucas Stach -Date: Thu, 18 May 2017 18:20:12 +0200 -Subject: [PATCH 1244/1430] etnaviv: honor PIPE_TRANSFER_UNSYNCHRONIZED flag - -This gets rid of quite a bit of CPU/GPU sync on frequent vertex buffer -uploads and I haven't seen any of the issues mentioned in the comment, -so this one seems stale. - -Ignore the flag if there exists a temporary resource, as those ones are -never busy. - -Signed-off-by: Lucas Stach -Reviewed-by: Wladimir J. van der Laan ---- - src/gallium/drivers/etnaviv/etnaviv_transfer.c | 35 +++++++++++++++++--------- - 1 file changed, 23 insertions(+), 12 deletions(-) - -diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c b/src/gallium/drivers/etnaviv/etnaviv_transfer.c -index 269bd498f8..4ead6dff7f 100644 ---- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c -+++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c -@@ -70,6 +70,10 @@ etna_transfer_unmap(struct pipe_context *pctx, struct pipe_transfer *ptrans) - if (rsc->texture && !etna_resource_newer(rsc, etna_resource(rsc->texture))) - rsc = etna_resource(rsc->texture); /* switch to using the texture resource */ - -+ /* -+ * Temporary resources are always pulled into the CPU domain, must push them -+ * back into GPU domain before the RS execs the blit to the base resource. -+ */ - if (trans->rsc) - etna_bo_cpu_fini(etna_resource(trans->rsc)->bo); - -@@ -114,7 +118,12 @@ etna_transfer_unmap(struct pipe_context *pctx, struct pipe_transfer *ptrans) - } - } - -- if (!trans->rsc) -+ /* -+ * Transfers without a temporary are only pulled into the CPU domain if they -+ * are not mapped unsynchronized. If they are, must push them back into GPU -+ * domain after CPU access is finished. -+ */ -+ if (!trans->rsc && !(ptrans->usage & PIPE_TRANSFER_UNSYNCHRONIZED)) - etna_bo_cpu_fini(rsc->bo); - - pipe_resource_reference(&trans->rsc, NULL); -@@ -260,19 +269,21 @@ etna_transfer_map(struct pipe_context *pctx, struct pipe_resource *prsc, - (rsc->layout == ETNA_LAYOUT_TILED && - util_format_is_compressed(prsc->format)); - -- /* Ignore PIPE_TRANSFER_UNSYNCHRONIZED and PIPE_TRANSFER_DONTBLOCK here. -- * It appears that Gallium operates the index/vertex buffers in a -- * circular fashion, and the CPU can catch up with the GPU and starts -- * overwriting yet-to-be-processed entries, causing rendering corruption. */ -- uint32_t prep_flags = 0; -+ /* -+ * Pull resources into the CPU domain. Only skipped for unsynchronized -+ * transfers without a temporary resource. -+ */ -+ if (trans->rsc || !(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) { -+ uint32_t prep_flags = 0; - -- if (usage & PIPE_TRANSFER_READ) -- prep_flags |= DRM_ETNA_PREP_READ; -- if (usage & PIPE_TRANSFER_WRITE) -- prep_flags |= DRM_ETNA_PREP_WRITE; -+ if (usage & PIPE_TRANSFER_READ) -+ prep_flags |= DRM_ETNA_PREP_READ; -+ if (usage & PIPE_TRANSFER_WRITE) -+ prep_flags |= DRM_ETNA_PREP_WRITE; - -- if (etna_bo_cpu_prep(rsc->bo, prep_flags)) -- goto fail_prep; -+ if (etna_bo_cpu_prep(rsc->bo, prep_flags)) -+ goto fail_prep; -+ } - - /* map buffer object */ - void *mapped = etna_bo_map(rsc->bo); --- -2.13.0 - -From 6e628ee3f3cd250d58f1b49fc0b53db58cd8eeea Mon Sep 17 00:00:00 2001 -From: Lucas Stach -Date: Thu, 18 May 2017 16:30:02 +0200 -Subject: [PATCH 1245/1430] etnaviv: don't read back resource if transfer - discards contents - -Reduces bandwidth usage of transfers which discard the buffer contents, -as well as skipping unnecessary command stream flushes and CPU/GPU -synchronization. - -Signed-off-by: Lucas Stach -Reviewed-by: Wladimir J. van der Laan ---- - src/gallium/drivers/etnaviv/etnaviv_transfer.c | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c b/src/gallium/drivers/etnaviv/etnaviv_transfer.c -index 4ead6dff7f..707029865a 100644 ---- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c -+++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c -@@ -197,7 +197,9 @@ etna_transfer_map(struct pipe_context *pctx, struct pipe_resource *prsc, - return NULL; - } - -- etna_copy_resource(pctx, trans->rsc, prsc, level, trans->rsc->last_level); -+ if (!(usage & PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE)) -+ etna_copy_resource(pctx, trans->rsc, prsc, level, -+ trans->rsc->last_level); - - /* Switch to using the temporary resource instead */ - rsc = etna_resource(trans->rsc); --- -2.13.0 - -From d4e6de9e385579d49cd5f51e643d0141c81b5604 Mon Sep 17 00:00:00 2001 -From: Lucas Stach -Date: Thu, 18 May 2017 16:44:18 +0200 -Subject: [PATCH 1246/1430] etnaviv: simplify transfer tiling handling - -There is no need to special case compressed resources, as they are already -marked as linear on allocation. With that out of the way, there is room to -cut down on the number of if clauses used. - -Signed-off-by: Lucas Stach -Reviewed-by: Wladimir J. van der Laan ---- - src/gallium/drivers/etnaviv/etnaviv_transfer.c | 70 +++++++++++--------------- - 1 file changed, 29 insertions(+), 41 deletions(-) - -diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c b/src/gallium/drivers/etnaviv/etnaviv_transfer.c -index 707029865a..8a18dbb8fc 100644 ---- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c -+++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c -@@ -89,21 +89,19 @@ etna_transfer_unmap(struct pipe_context *pctx, struct pipe_transfer *ptrans) - struct etna_resource_level *res_level = &rsc->levels[ptrans->level]; - void *mapped = etna_bo_map(rsc->bo) + res_level->offset; - -- if (rsc->layout == ETNA_LAYOUT_LINEAR || rsc->layout == ETNA_LAYOUT_TILED) { -- if (rsc->layout == ETNA_LAYOUT_TILED && !util_format_is_compressed(rsc->base.format)) { -- etna_texture_tile( -- mapped + ptrans->box.z * res_level->layer_stride, -- trans->staging, ptrans->box.x, ptrans->box.y, -- res_level->stride, ptrans->box.width, ptrans->box.height, -- ptrans->stride, util_format_get_blocksize(rsc->base.format)); -- } else { /* non-tiled or compressed format */ -- util_copy_box(mapped, rsc->base.format, res_level->stride, -- res_level->layer_stride, ptrans->box.x, -- ptrans->box.y, ptrans->box.z, ptrans->box.width, -- ptrans->box.height, ptrans->box.depth, -- trans->staging, ptrans->stride, -- ptrans->layer_stride, 0, 0, 0 /* src x,y,z */); -- } -+ if (rsc->layout == ETNA_LAYOUT_TILED) { -+ etna_texture_tile( -+ mapped + ptrans->box.z * res_level->layer_stride, -+ trans->staging, ptrans->box.x, ptrans->box.y, -+ res_level->stride, ptrans->box.width, ptrans->box.height, -+ ptrans->stride, util_format_get_blocksize(rsc->base.format)); -+ } else if (rsc->layout == ETNA_LAYOUT_LINEAR) { -+ util_copy_box(mapped, rsc->base.format, res_level->stride, -+ res_level->layer_stride, ptrans->box.x, -+ ptrans->box.y, ptrans->box.z, ptrans->box.width, -+ ptrans->box.height, ptrans->box.depth, -+ trans->staging, ptrans->stride, -+ ptrans->layer_stride, 0, 0, 0 /* src x,y,z */); - } else { - BUG("unsupported tiling %i", rsc->layout); - } -@@ -264,13 +262,6 @@ etna_transfer_map(struct pipe_context *pctx, struct pipe_resource *prsc, - PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE is set. - */ - -- /* No need to allocate a buffer for copying if the resource is not in use, -- * and no tiling is needed, can just return a direct pointer. -- */ -- bool in_place = rsc->layout == ETNA_LAYOUT_LINEAR || -- (rsc->layout == ETNA_LAYOUT_TILED && -- util_format_is_compressed(prsc->format)); -- - /* - * Pull resources into the CPU domain. Only skipped for unsynchronized - * transfers without a temporary resource. -@@ -294,7 +285,7 @@ etna_transfer_map(struct pipe_context *pctx, struct pipe_resource *prsc, - - *out_transfer = ptrans; - -- if (in_place) { -+ if (rsc->layout == ETNA_LAYOUT_LINEAR) { - ptrans->stride = res_level->stride; - ptrans->layer_stride = res_level->layer_stride; - -@@ -321,24 +312,21 @@ etna_transfer_map(struct pipe_context *pctx, struct pipe_resource *prsc, - goto fail; - - if (usage & PIPE_TRANSFER_READ) { -- /* untile or copy resource for reading */ -- if (rsc->layout == ETNA_LAYOUT_LINEAR || rsc->layout == ETNA_LAYOUT_TILED) { -- if (rsc->layout == ETNA_LAYOUT_TILED && !util_format_is_compressed(rsc->base.format)) { -- etna_texture_untile(trans->staging, -- mapped + ptrans->box.z * res_level->layer_stride, -- ptrans->box.x, ptrans->box.y, res_level->stride, -- ptrans->box.width, ptrans->box.height, ptrans->stride, -- util_format_get_blocksize(rsc->base.format)); -- } else { /* non-tiled or compressed format */ -- util_copy_box(trans->staging, rsc->base.format, ptrans->stride, -- ptrans->layer_stride, 0, 0, 0, /* dst x,y,z */ -- ptrans->box.width, ptrans->box.height, -- ptrans->box.depth, mapped, res_level->stride, -- res_level->layer_stride, ptrans->box.x, -- ptrans->box.y, ptrans->box.z); -- } -- } else /* TODO supertiling */ -- { -+ if (rsc->layout == ETNA_LAYOUT_TILED) { -+ etna_texture_untile(trans->staging, -+ mapped + ptrans->box.z * res_level->layer_stride, -+ ptrans->box.x, ptrans->box.y, res_level->stride, -+ ptrans->box.width, ptrans->box.height, ptrans->stride, -+ util_format_get_blocksize(rsc->base.format)); -+ } else if (rsc->layout == ETNA_LAYOUT_LINEAR) { -+ util_copy_box(trans->staging, rsc->base.format, ptrans->stride, -+ ptrans->layer_stride, 0, 0, 0, /* dst x,y,z */ -+ ptrans->box.width, ptrans->box.height, -+ ptrans->box.depth, mapped, res_level->stride, -+ res_level->layer_stride, ptrans->box.x, -+ ptrans->box.y, ptrans->box.z); -+ } else { -+ /* TODO supertiling */ - BUG("unsupported tiling %i for reading", rsc->layout); - } - } --- -2.13.0 - -From 0f888ad4be32d1c66e2749feacb8b88def03fac9 Mon Sep 17 00:00:00 2001 -From: Lucas Stach -Date: Thu, 18 May 2017 17:05:02 +0200 -Subject: [PATCH 1247/1430] etnaviv: upgrade DISCARD_RANGE to - DISCARD_WHOLE_RESOURCE if possible - -Stolen from VC4. As we don't do any fancy reallocation tricks yet, it's -possible to upgrade also coherent mappings and shared resources. - -Signed-off-by: Lucas Stach -Reviewed-by: Wladimir J. van der Laan ---- - src/gallium/drivers/etnaviv/etnaviv_transfer.c | 14 ++++++++++++++ - 1 file changed, 14 insertions(+) - -diff --git a/src/gallium/drivers/etnaviv/etnaviv_transfer.c b/src/gallium/drivers/etnaviv/etnaviv_transfer.c -index 8a18dbb8fc..27e1be1957 100644 ---- a/src/gallium/drivers/etnaviv/etnaviv_transfer.c -+++ b/src/gallium/drivers/etnaviv/etnaviv_transfer.c -@@ -157,6 +157,20 @@ etna_transfer_map(struct pipe_context *pctx, struct pipe_resource *prsc, - - assert(level <= prsc->last_level); - -+ /* Upgrade DISCARD_RANGE to WHOLE_RESOURCE if the whole resource is -+ * being mapped. If we add buffer reallocation to avoid CPU/GPU sync this -+ * check needs to be extended to coherent mappings and shared resources. -+ */ -+ if ((usage & PIPE_TRANSFER_DISCARD_RANGE) && -+ !(usage & PIPE_TRANSFER_UNSYNCHRONIZED) && -+ prsc->last_level == 0 && -+ prsc->width0 == box->width && -+ prsc->height0 == box->height && -+ prsc->depth0 == box->depth && -+ prsc->array_size == 1) { -+ usage |= PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE; -+ } -+ - if (rsc->texture && !etna_resource_newer(rsc, etna_resource(rsc->texture))) { - /* We have a texture resource which is the same age or newer than the - * render resource. Use the texture resource, which avoids bouncing --- -2.13.0 - -From f25390afa49f51fadaafed70a890093f96e7a02d Mon Sep 17 00:00:00 2001 -From: Lucas Stach -Date: Sun, 4 Jun 2017 06:24:20 +0200 -Subject: [PATCH 1248/1430] etnaviv: don't flush resource to self without TS - -A resolve to self is only necessary if the resource is fast cleared, so -there is never a need to do so if there is no TS allocated. - -Signed-off-by: Lucas Stach -Reviewed-by: Wladimir J. van der Laan ---- - src/gallium/drivers/etnaviv/etnaviv_resource.h | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.h b/src/gallium/drivers/etnaviv/etnaviv_resource.h -index 913316f193..3507e5ccec 100644 ---- a/src/gallium/drivers/etnaviv/etnaviv_resource.h -+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.h -@@ -102,7 +102,7 @@ etna_resource_older(struct etna_resource *a, struct etna_resource *b) - static inline bool - etna_resource_needs_flush(struct etna_resource *res) - { -- return (int)(res->seqno - res->flush_seqno) > 0; -+ return res->ts_bo && ((int)(res->seqno - res->flush_seqno) > 0); - } - - /* is the resource only used on the sampler? */ --- -2.13.0 - -From 978e6876f1cd8ccc8850a5665e9619a3e29b731e Mon Sep 17 00:00:00 2001 -From: Lucas Stach -Date: Mon, 15 May 2017 17:06:41 +0200 -Subject: [PATCH 1249/1430] etnaviv: flush resource when binding as sampler - view - -As TS is also allowed on sampler resources, we need to make sure to resolve -to self when binding the resource as a texture, to avoid stale content -being sampled. - -Signed-off-by: Lucas Stach ---- - src/gallium/drivers/etnaviv/etnaviv_texture.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/src/gallium/drivers/etnaviv/etnaviv_texture.c b/src/gallium/drivers/etnaviv/etnaviv_texture.c -index 6f77af286f..df77829078 100644 ---- a/src/gallium/drivers/etnaviv/etnaviv_texture.c -+++ b/src/gallium/drivers/etnaviv/etnaviv_texture.c -@@ -120,6 +120,9 @@ etna_update_sampler_source(struct pipe_sampler_view *view) - etna_copy_resource(view->context, res->texture, view->texture, 0, - view->texture->last_level); - etna_resource(res->texture)->seqno = res->seqno; -+ } else if (etna_resource_needs_flush(res)) { -+ etna_copy_resource(view->context, view->texture, view->texture, 0, 0); -+ res->flush_seqno = res->seqno; - } - } - --- -2.13.0 - diff --git a/mesa.spec b/mesa.spec index 9d4618a..d603abd 100644 --- a/mesa.spec +++ b/mesa.spec @@ -54,12 +54,12 @@ %global sanitize 1 -#global rctag rc4 +#global rctag rc6 Name: mesa Summary: Mesa graphics libraries -Version: 17.1.7 -Release: 1%{?rctag:.%{rctag}}%{?dist} +Version: 17.2.2 +Release: 2%{?rctag:.%{rctag}}%{?dist} License: MIT URL: http://www.mesa3d.org @@ -71,6 +71,9 @@ Source2: vl_mpeg12_decoder.c # Fedora opts to ignore the optional part of clause 2 and treat that code as 2 clause BSD. Source3: Mesa-MLAA-License-Clarification-Email.txt +# https://cgit.freedesktop.org/~ajax/mesa/log/?h=mesa-17.2-s3tc +Patch0: 0001-mesa-Squash-merge-of-S3TC-support.patch + Patch1: 0001-llvm-SONAME-without-version.patch Patch2: 0002-hardware-gloat.patch Patch3: 0003-evergreen-big-endian.patch @@ -78,13 +81,10 @@ Patch4: 0004-bigendian-assert.patch # glvnd support patches # non-upstreamed ones -Patch13: glvnd-fix-gl-dot-pc.patch -Patch14: 0001-Fix-linkage-against-shared-glapi.patch +Patch10: glvnd-fix-gl-dot-pc.patch +Patch11: 0001-Fix-linkage-against-shared-glapi.patch # backport from upstream -Patch51: mesa-7.1.2-etnaviv-upstream-fixes.patch -Patch52: mesa-7.1.2-etnaviv-fixes.patch -Patch53: mesa-7.1-vc4-fixes.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -123,6 +123,7 @@ BuildRequires: bison flex %if %{with wayland} BuildRequires: pkgconfig(wayland-client) BuildRequires: pkgconfig(wayland-server) +BuildRequires: pkgconfig(wayland-protocols) %endif %if 0%{?with_vdpau} BuildRequires: libvdpau-devel @@ -375,6 +376,10 @@ Headers for development with the Vulkan API. cp %{SOURCE3} docs/ +# this is a hack for S3TC support. r200_screen.c is symlinked to +# radeon_screen.c in git, but is its own file in the tarball. +cp -f src/mesa/drivers/dri/{radeon,r200}/radeon_screen.c + %build autoreconf -vfi @@ -683,8 +688,35 @@ popd %endif %changelog -* Tue Aug 22 2017 Peter Robinson 7.1.7-1 -- Update to 17.1.7 +* Tue Oct 03 2017 Adam Jackson - 17.2.2-2 +- Backport S3TC support from master + +* Tue Oct 3 2017 Peter Robinson 17.2.2-1 +- Update to 17.2.2 GA + +* Wed Sep 20 2017 Peter Robinson 17.2.1-1 +- Update to 17.2.1 GA + +* Mon Sep 11 2017 Peter Robinson 17.2.0-2 +- Add upstream patch for glibc xlocale.h change (fdo bz 102454) + +* Tue Sep 5 2017 Peter Robinson 17.2.0-1 +- Update to 17.2.0 GA + +* Thu Aug 31 2017 Peter Robinson 17.2.0-0.3.rc6 +- Update to 17.2.0-rc6 + +* Tue Aug 22 2017 Peter Robinson 17.2.0-0.2.rc5 +- Update to 17.2.0-rc5 + +* Sun Aug 13 2017 Peter Robinson 17.2.0-0.1.rc4 +- Update to 17.2.0-rc4 + +* Thu Aug 03 2017 Fedora Release Engineering - 17.1.5-1.2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Wed Jul 26 2017 Fedora Release Engineering - 17.1.5-1.1 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild * Mon Jul 17 2017 Peter Robinson 7.1.5-1 - Update to 17.1.5 diff --git a/sources b/sources index d7151b1..4b84cf1 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (mesa-17.1.7.tar.xz) = a1cb22b78c74572bef720c132294a028413402520260afff3d46e79f8837dce35aafd8675a8d6834574a4a15ded3611f06dddd5a9fc5882a6dcedab63d0b3e35 +SHA512 (mesa-17.2.2.tar.xz) = 641342c68989b8d801c37e668b012d3b7c4ad43d8ca01b74f8cbb3a1ec25b7390f69fe7ebc84b29dab1c6a4ac01c882ec9fd4a6b331505629461bdbbe6aa3f7e