<commit_before>#include "nvfx_context.h"

static boolean
nvfx_state_viewport_validate(struct nvfx_context *nvfx)
{
	struct pipe_viewport_state *vpt = &nvfx->viewport;
	struct nouveau_stateobj *so;

	if (nvfx->state.hw[NVFX_STATE_VIEWPORT] &&
	    !(nvfx->dirty & NVFX_NEW_VIEWPORT))
		return FALSE;

	so = so_new(2, 9, 0);
	so_method(so, nvfx->screen->eng3d,
		  NV34TCL_VIEWPORT_TRANSLATE_X, 8);
	if(nvfx->render_mode == HW) {
		so_data  (so, fui(vpt->translate[0]));
		so_data  (so, fui(vpt->translate[1]));
		so_data  (so, fui(vpt->translate[2]));
		so_data  (so, fui(vpt->translate[3]));
		so_data  (so, fui(vpt->scale[0]));
		so_data  (so, fui(vpt->scale[1]));
		so_data  (so, fui(vpt->scale[2]));
		so_data  (so, fui(vpt->scale[3]));
		so_method(so, nvfx->screen->eng3d, 0x1d78, 1);
		so_data  (so, 1);
	} else {
		so_data  (so, fui(0.0f));
		so_data  (so, fui(0.0f));
		so_data  (so, fui(0.0f));
		so_data  (so, fui(0.0f));
		so_data  (so, fui(1.0f));
		so_data  (so, fui(1.0f));
		so_data  (so, fui(1.0f));
		so_data  (so, fui(1.0f));
		so_method(so, nvfx->screen->eng3d, 0x1d78, 1);
		so_data  (so, nvfx->is_nv4x ? 0x110 : 1);
	}

	so_ref(so, &nvfx->state.hw[NVFX_STATE_VIEWPORT]);
	so_ref(NULL, &so);
	return TRUE;
}

struct nvfx_state_entry nvfx_state_viewport = {
	.validate = nvfx_state_viewport_validate,
	.dirty = {
		.pipe = NVFX_NEW_VIEWPORT,
		.hw = NVFX_STATE_VIEWPORT
	}
};<commit_msg>nvfx: fix/workaround nv3x hwtnl issues<commit_after>#include "nvfx_context.h"

/* Having this depend on FB and RAST looks wrong, but it seems
   necessary to make this work on nv3x
   TODO: find the right fix
*/

static boolean
nvfx_state_viewport_validate(struct nvfx_context *nvfx)
{
	struct pipe_viewport_state *vpt = &nvfx->viewport;
	struct nouveau_stateobj *so;

	so = so_new(2, 9, 0);
	so_method(so, nvfx->screen->eng3d,
		  NV34TCL_VIEWPORT_TRANSLATE_X, 8);
	if(nvfx->render_mode == HW) {
		so_data  (so, fui(vpt->translate[0]));
		so_data  (so, fui(vpt->translate[1]));
		so_data  (so, fui(vpt->translate[2]));
		so_data  (so, fui(vpt->translate[3]));
		so_data  (so, fui(vpt->scale[0]));
		so_data  (so, fui(vpt->scale[1]));
		so_data  (so, fui(vpt->scale[2]));
		so_data  (so, fui(vpt->scale[3]));
		so_method(so, nvfx->screen->eng3d, 0x1d78, 1);
		so_data  (so, 1);
	} else {
		so_data  (so, fui(0.0f));
		so_data  (so, fui(0.0f));
		so_data  (so, fui(0.0f));
		so_data  (so, fui(0.0f));
		so_data  (so, fui(1.0f));
		so_data  (so, fui(1.0f));
		so_data  (so, fui(1.0f));
		so_data  (so, fui(1.0f));
		so_method(so, nvfx->screen->eng3d, 0x1d78, 1);
		so_data  (so, nvfx->is_nv4x ? 0x110 : 1);
	}

	so_ref(so, &nvfx->state.hw[NVFX_STATE_VIEWPORT]);
	so_ref(NULL, &so);
	return TRUE;
}

struct nvfx_state_entry nvfx_state_viewport = {
	.validate = nvfx_state_viewport_validate,
	.dirty = {
		.pipe = NVFX_NEW_VIEWPORT | NVFX_NEW_FB | NVFX_NEW_RAST,
		.hw = NVFX_STATE_VIEWPORT
	}
};
{'fraction_non_alphanumeric': 0.17880566102865034, 'fraction_numerical': 0.035208836727649295, 'mean_word_length': 4.337016574585635, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 41, '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': '5992662', 'n_tokens_mistral': 1454, 'n_tokens_neox': 1366, 'n_words': 246}