<commit_before>#include "pipe/p_state.h"
#include "pipe/p_defines.h"
#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_memory.h"
#include "util/u_math.h"
#include "util/u_staging.h"
#include "state_tracker/drm_driver.h"
#include "nouveau/nouveau_winsys.h"
#include "nouveau/nouveau_screen.h"
#include "nvfx_screen.h"
#include "nvfx_resource.h"
#include "nvfx_transfer.h"

static void
nvfx_miptree_choose_format(struct nvfx_miptree *mt)
{
	struct pipe_resource *pt = &mt->base.base;
	unsigned uniform_pitch = 0;
	static int no_swizzle = -1;
	if(no_swizzle < 0)
		no_swizzle = debug_get_bool_option("NOUVEAU_NO_SWIZZLE", FALSE);

	/* Non-uniform pitch textures must be POT */
	if (pt->width0 & (pt->width0 - 1) ||
	    pt->height0 & (pt->height0 - 1) ||
	    pt->depth0 & (pt->depth0 - 1)
	    )
		uniform_pitch = 1;

	/* All texture formats except compressed ones can be swizzled
	 * Unsure about depth, let's prevent swizzling for now
	 */
	if (
		(pt->bind & (PIPE_BIND_SCANOUT | PIPE_BIND_DISPLAY_TARGET))
		|| (pt->usage & PIPE_USAGE_DYNAMIC) || (pt->usage & PIPE_USAGE_STAGING)
		|| util_format_is_depth_or_stencil(pt->format)
		|| util_format_is_compressed(pt->format)
		// disable swizzled textures on NV04-NV20 as our current drivers don't fully support that
		// TODO: hardware should support them, fix the drivers and reenable
		|| nouveau_screen(pt->screen)->device->chipset < 0x30
		|| no_swizzle

		// disable swizzling for non-RGBA 2D because our current 2D code can't handle anything
		// else correctly, and even that is semi-broken
		|| pt->target != PIPE_TEXTURE_2D
		|| (pt->format != PIPE_FORMAT_B8G8R8A8_UNORM && pt->format != PIPE_FORMAT_B8G8R8X8_UNORM)
	)
		mt->base.base.flags |= NVFX_RESOURCE_FLAG_LINEAR;
<commit_msg>nvfx: new 2D: enable swizzling for all surfaces<commit_after>#include "pipe/p_state.h"
#include "pipe/p_defines.h"
#include "util/u_inlines.h"
#include "util/u_format.h"
#include "util/u_memory.h"
#include "util/u_math.h"
#include "util/u_staging.h"
#include "state_tracker/drm_driver.h"
#include "nouveau/nouveau_winsys.h"
#include "nouveau/nouveau_screen.h"
#include "nvfx_screen.h"
#include "nvfx_resource.h"
#include "nvfx_transfer.h"

static void
nvfx_miptree_choose_format(struct nvfx_miptree *mt)
{
	struct pipe_resource *pt = &mt->base.base;
	unsigned uniform_pitch = 0;
	static int no_swizzle = -1;
	if(no_swizzle < 0)
		no_swizzle = debug_get_bool_option("NV40_NO_SWIZZLE", FALSE); /* this will break things on nv30 */

	if (!util_is_pot(pt->width0) ||
	    !util_is_pot(pt->height0) ||
	    !util_is_pot(pt->depth0)
	    )
		uniform_pitch = 1;

	if (
		(pt->bind & (PIPE_BIND_SCANOUT | PIPE_BIND_DISPLAY_TARGET))
		|| (pt->usage & PIPE_USAGE_DYNAMIC) || (pt->usage & PIPE_USAGE_STAGING)
		|| util_format_is_compressed(pt->format)
		|| no_swizzle
	)
		mt->base.base.flags |= NVFX_RESOURCE_FLAG_LINEAR;

{'fraction_non_alphanumeric': 0.13421418636995827, 'fraction_numerical': 0.014951321279554937, 'mean_word_length': 4.788732394366197, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4655560', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1155, 'n_words': 224}