/*************************************************************************************************/
/*!
   	@file		pp_sse_texture_nearest.h
	@author 	Fanzo
*/
/*************************************************************************************************/
#pragma		once

///////////////////////////////////////////////////////////////////////////////////////////////////
//include files
//=================================================================================================
// const
//=================================================================================================
///////////////////////////////
// b


///////////////////////////////
// w













///////////////////////////////
// dw
























///////////////////////////////
// ps













//=================================================================================================
// convert
//=================================================================================================
///////////////////////////////////////////////////////////
// 

///////////////////////////////////////////////////////////
//dw 




///////////////////////////////////////////////////////////
//w






///////////////////////////////////////////////////////////
//b






//=================================================================================================
// cmpadd
//=================================================================================================









//=================================================================================================
// cmpsub
//=================================================================================================









//=================================================================================================
// cmpset
//=================================================================================================









//=================================================================================================
// not
//=================================================================================================

//=================================================================================================
// cmpadd , cmpsub
//=================================================================================================




//=================================================================================================
// set
//=================================================================================================









//=================================================================================================
// set
//=================================================================================================









//=================================================================================================
// rotate
//=================================================================================================
////////////////////////
//ps






////////////////////////
//dw






////////////////////////
//w








////////////////////////
//b
















//=================================================================================================
// fill
//=================================================================================================
////////////////////////
//ps




////////////////////////
//dw




////////////////////////
//w










////////////////////////
//b


















//=================================================================================================
// Load
//=================================================================================================




//=================================================================================================
// Load
//=================================================================================================
//=================================================================================================
// loop
//=================================================================================================
///////////////////////////////////////////////////////////////////////////////////////////////////
// Loop



///////////////////////////////////////////////////////////////////////////////////////////////////
// LoopCount

/*=================================================================================================
[ pixelformat ]
0 <= a <= 255   0 <= r <= 255   0 <= g <= 255   0 <= b <= 255  
0 <= aa <= 255   0 <= ar <= 255   0 <= ag <= 255   0 <= ab <= 255
rgb			byte	[-,r,g,b]
rgba		byte	[a,r,g,b]
a			byte	[a,-,-,-]
wrgb		word	[-,r,g,b]
wrgba		word	[a,r,g,b]
wa			word	[a,-,-,-]
drgb		dword	[-,r,g,b]
drgba		dword	[a,r,g,b]
da			dword	[a,-,-,-]
frgb		float	[-,r,g,b]
frgba		float	[a,r,g,b]
fa			float	[a,-,-,-]

rgb2		[ - , - , rgb,rgb]
rgb4		[rgb,rgb,rgb,rgb]
rgba2		[-,-,rgba,rgba]
rgba4		[rgba,rgba,rgba,rgba]
wrgb2		[wrgb,wrgb]
wrgba2		[wrgba,wrgba]
=================================================================================================*/

//=================================================================================================
// misc
//=================================================================================================
///////////////////////////////////////////////////////////////////////////////////////////////////
//sc_color




//=================================================================================================
// color to
//=================================================================================================
// wrgb

// wrgba

// wa

// frgb

// frgba

// fa

//=================================================================================================
// misc
//=================================================================================================
///////////////////////////////////////////////////////////////////////////////////////////////////
// a to aaaa

///////////////////////////////////////////////////////////////////////////////////////////////////
// a to aaaa


//=================================================================================================
// convert
//=================================================================================================
///////////////////////////////////////////////////////////////////////////////////////////////////
//rgb_to

// rgb

// rgba

// a

// wrgb

// wrgba

// wa

// drgb

// drgba

// da

// frgb

// frgba

// fa

///////////////////////////////////////////////////////////////////////////////////////////////////
//rgba_to

// rgb

// rgba

// a

// wrgb

// wrgba

// wa

// drgb

// drgba

// da

// frgb

// frgba

// fa

///////////////////////////////////////////////////////////////////////////////////////////////////
//wrgb_to

// rgb

// rgba

// a

// wrgb

// wrgba

// wa

// drgb

// drgba

// da

// frgb

// frgba

// fa

///////////////////////////////////////////////////////////////////////////////////////////////////
//wrgba_to

// rgb

// rgba

// a

// wrgb

// wrgba

// wa

// drgb

// drgba

// da

// frgb

// frgba

// fa

///////////////////////////////////////////////////////////////////////////////////////////////////
//drgb_to

// rgb

// rgba

// a

// wrgb

// wrgba

// wa

// drgb

// drgba

// da

// frgb

// frgba

// fa

///////////////////////////////////////////////////////////////////////////////////////////////////
//drgba_to

// rgb

// rgba

// a

// wrgb

// wrgba

// wa

// drgb

// drgba

// da

// frgb

// frgba

// fa

///////////////////////////////////////////////////////////////////////////////////////////////////
//frgb_to

// rgb

// rgba

// a

// wrgb

// wrgba

// wa

// drgb

// drgba

// da

// frgb

// frgba

// fa

///////////////////////////////////////////////////////////////////////////////////////////////////
//frgba_to

// rgb

// rgba

// a

// wrgb

// wrgba

// wa

// drgb

// drgba

// da

// frgb

// frgba

// fa

///////////////////////////////////////////////////////////////////////////////////////////////////
//a_to

// rgb

// rgba

// a

// wrgb

// wrgba

// wa

// drgb

// drgba

// da

// frgb

// frgba

// fa

///////////////////////////////////////////////////////////////////////////////////////////////////
//fa_to

// a

// wa

// da

// fa

///////////////////////////////////////////////////////////////////////////////////////////////////
//wa_to

// a

// wa

// da

// fa

//=================================================================================================
// mul alpha
//=================================================================================================
// wrgb

// wrgba

// wa

// frgb

// frgba

// fa

//=================================================================================================
// convert pack
//=================================================================================================
///////////////////////////////////////////////////////////////////////////////////////////////////
//

///////////////////////////////////////////////////////////////
// rgb

// rgb->rgb2

// rgb2->rgb

// rgb2->rgb4

// rgb4->rgb2

// rgb2->wrgb2

// wrgb2->rgb2

///////////////////////////////////////////////////////////////
// rgba

// rgba->rgba2

// rgba2->rgba

// rgba2->rgba4

// rgba4->rgba2

// rgba2->wrgba2

// wrgba2->rgba2

// wrgba->wrgba2

// wrgba2->wrgba

//=================================================================================================
// load var
//=================================================================================================

// rgb

// rgba

// frgb

// frgba

// wrgb

// wrgba

// drgb

// drgba

//=================================================================================================
// load addr
//=================================================================================================

// rgb

// rgba

// a

//=================================================================================================
// load addr index
//=================================================================================================

// rgb

// rgba

// a


//=================================================================================================
// load addr index
//=================================================================================================

// rgb

// rgba

//=================================================================================================
// load addr byteindex
//=================================================================================================

// rgb

// rgba

//=================================================================================================
// store var
//=================================================================================================

// rgb

// rgba

// frgb

// frgba

// wrgb

// wrgba

// drgb

// drgba

//=================================================================================================
// store addr
//=================================================================================================

// rgb

// rgba

// a

//=================================================================================================
// store addr index
//=================================================================================================

// rgb

// rgba

//=================================================================================================
// add pixel size
//=================================================================================================

// rgb

// rgba

// a

// rgb

// rgba

// rgba

//=================================================================================================
// sub pixel size
//=================================================================================================

// rgb

// rgba

// a

// rgb

// rgba

// rgba

//=================================================================================================
// pixoffset_to_byteoffset
//=================================================================================================


//=================================================================================================
// load addr color16
//=================================================================================================
/*
	destformat	= rgb , rgba , rgbaaa , wrgb , wrgba , wrgbaaa , drgb , drgba , drgbaaa
	srcformat	= rgb , rgba , rgbaaa
	src_pitchbyte_dw4_var	= pitch , pitch , pitch , pitch
	color_var	= color_var_00 , color_var_10 , color_var_20 , color_var_30 , ... , color_var_33
	alpha_var	= alpha_var_00 , alpha_var_10 , alpha_var_20 , alpha_var_30 , ... , alpha_var_33
	x_dw4_xmm	= x3 : x2 : x1 : x0
	y_dw4_xmm	= y3 : y2 : y1 : y0
	w_dw4_xmm	= w : w : w : w
*/

//=================================================================================================
// add pixel
//=================================================================================================
// wrgb

// wrgba

// wa

//=================================================================================================
// shift pixel
//=================================================================================================
// wrgb

// wrgba

// wa

//=================================================================================================
// gradation linear w
//=================================================================================================
//-------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------

//=================================================================================================
// gradation linear f
//=================================================================================================
//-------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------
/*=================================================================================================
[ uvformat ]
fuv		[ 0 , u , 0 , v ]
duv		[ 0 , u , 0 , v ]
wuv		[ 0 , 0 , 0 , u , 0 , 0 , v ]

=================================================================================================*/

//=================================================================================================
// convert
//=================================================================================================
//-------------------------------------------------------------------------------------------------
//fuv to wuv with repeat

//-------------------------------------------------------------------------------------------------
//fuv to wuv with clamp

//-------------------------------------------------------------------------------------------------
//dxy to offset

//-------------------------------------------------------------------------------------------------
// duv to dxy repeat

//-------------------------------------------------------------------------------------------------
// duv to dxy clamp

//-------------------------------------------------------------------------------------------------
// dxy to wxy2 repeat

//-------------------------------------------------------------------------------------------------
// dxy to wxy2 clamp

//-------------------------------------------------------------------------------------------------
// dxy to wxy4 repeat

//-------------------------------------------------------------------------------------------------
// dxy to wxy4 clamp

#pragma pack( push , 8 )		//set align

namespace icubic
{
//=================================================================================================
// texture nearest m
//=================================================================================================

//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_repeat_rgb_rgb
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgb() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		cvtps2dq	xmm4 , xmm4
		pand		xmm4 , const_dw_0_0xFFFF_0_0xFFFF
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_repeat_rgb_rgba
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgba() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		cvtps2dq	xmm4 , xmm4
		pand		xmm4 , const_dw_0_0xFFFF_0_0xFFFF
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_repeat_rgb_a
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_a() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		cvtps2dq	xmm4 , xmm4
		pand		xmm4 , const_dw_0_0xFFFF_0_0xFFFF
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		mov		ecx , 0
		mov		cl , [ edx ]
		movd	xmm0 , ecx
		punpcklbw	xmm0 , xmm0
		punpcklbw	xmm0 , xmm0
		punpcklbw	xmm0 , const_b_0
		pmullw		xmm0 , sc_color_wrgba
		psrlw		xmm0 , 8
		packuswb	xmm0 , const_dw_0
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_repeat_rgba_rgb
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgb() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		cvtps2dq	xmm4 , xmm4
		pand		xmm4 , const_dw_0_0xFFFF_0_0xFFFF
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		por			xmm0 , const_b_scala_0xFF
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_repeat_rgba_rgba
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgba() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		cvtps2dq	xmm4 , xmm4
		pand		xmm4 , const_dw_0_0xFFFF_0_0xFFFF
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_repeat_rgba_a
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_a() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		cvtps2dq	xmm4 , xmm4
		pand		xmm4 , const_dw_0_0xFFFF_0_0xFFFF
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		mov		ecx , 0
		mov		cl , [ edx ]
		movd	xmm0 , ecx
		punpcklbw	xmm0 , xmm0
		punpcklbw	xmm0 , xmm0
		punpcklbw	xmm0 , const_b_0
		pmullw		xmm0 , sc_color_wrgba
		psrlw		xmm0 , 8
		packuswb	xmm0 , const_dw_0
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_repeat_a_rgb
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgb() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		cvtps2dq	xmm4 , xmm4
		pand		xmm4 , const_dw_0_0xFFFF_0_0xFFFF
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		movaps		xmm0 , const_b_scala_0xFF
		movd	ecx , xmm0
		mov		[ eax ] , cl
		add		eax , 1
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_repeat_a_rgba
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgba() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		cvtps2dq	xmm4 , xmm4
		pand		xmm4 , const_dw_0_0xFFFF_0_0xFFFF
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		movd	ecx , xmm0
		mov		[ eax ] , cl
		add		eax , 1
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_repeat_a_a
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_a() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		cvtps2dq	xmm4 , xmm4
		pand		xmm4 , const_dw_0_0xFFFF_0_0xFFFF
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		mov		ecx , 0
		mov		cl , [ edx ]
		movd	xmm0 , ecx
		movd	ecx , xmm0
		mov		[ eax ] , cl
		add		eax , 1
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}

//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_clamp_rgb_rgb
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgb() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		maxps		xmm4 , const_f_0
		minps		xmm4 , const_f_0_0xFFFF_0_0xFFFF
		cvtps2dq	xmm4 , xmm4
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_clamp_rgb_rgba
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgba() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		maxps		xmm4 , const_f_0
		minps		xmm4 , const_f_0_0xFFFF_0_0xFFFF
		cvtps2dq	xmm4 , xmm4
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_clamp_rgb_a
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_a() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		maxps		xmm4 , const_f_0
		minps		xmm4 , const_f_0_0xFFFF_0_0xFFFF
		cvtps2dq	xmm4 , xmm4
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		mov		ecx , 0
		mov		cl , [ edx ]
		movd	xmm0 , ecx
		punpcklbw	xmm0 , xmm0
		punpcklbw	xmm0 , xmm0
		punpcklbw	xmm0 , const_b_0
		pmullw		xmm0 , sc_color_wrgba
		psrlw		xmm0 , 8
		packuswb	xmm0 , const_dw_0
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_clamp_rgba_rgb
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgb() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		maxps		xmm4 , const_f_0
		minps		xmm4 , const_f_0_0xFFFF_0_0xFFFF
		cvtps2dq	xmm4 , xmm4
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		por			xmm0 , const_b_scala_0xFF
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_clamp_rgba_rgba
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgba() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		maxps		xmm4 , const_f_0
		minps		xmm4 , const_f_0_0xFFFF_0_0xFFFF
		cvtps2dq	xmm4 , xmm4
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_clamp_rgba_a
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_a() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		maxps		xmm4 , const_f_0
		minps		xmm4 , const_f_0_0xFFFF_0_0xFFFF
		cvtps2dq	xmm4 , xmm4
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		mov		ecx , 0
		mov		cl , [ edx ]
		movd	xmm0 , ecx
		punpcklbw	xmm0 , xmm0
		punpcklbw	xmm0 , xmm0
		punpcklbw	xmm0 , const_b_0
		pmullw		xmm0 , sc_color_wrgba
		psrlw		xmm0 , 8
		packuswb	xmm0 , const_dw_0
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_clamp_a_rgb
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgb() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		maxps		xmm4 , const_f_0
		minps		xmm4 , const_f_0_0xFFFF_0_0xFFFF
		cvtps2dq	xmm4 , xmm4
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		movaps		xmm0 , const_b_scala_0xFF
		movd	ecx , xmm0
		mov		[ eax ] , cl
		add		eax , 1
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_clamp_a_rgba
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgba() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		maxps		xmm4 , const_f_0
		minps		xmm4 , const_f_0_0xFFFF_0_0xFFFF
		cvtps2dq	xmm4 , xmm4
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		movd	ecx , xmm0
		mov		[ eax ] , cl
		add		eax , 1
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_clamp_a_a
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_a() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		maxps		xmm4 , const_f_0
		minps		xmm4 , const_f_0_0xFFFF_0_0xFFFF
		cvtps2dq	xmm4 , xmm4
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		mov		ecx , 0
		mov		cl , [ edx ]
		movd	xmm0 , ecx
		movd	ecx , xmm0
		mov		[ eax ] , cl
		add		eax , 1
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}

//=================================================================================================
// texture nearest m
//=================================================================================================
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_alpha_repeat_rgb_rgb
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color , 
		const pp_alpha&	alpha
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	static const __m128	const_w_scala_0xFF = sse_set_w( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );
	__m128	sc_alpha_waaaa = sse_set_uw( 0 , 0 , 0 , 0 , alpha.a , alpha.a , alpha.a , alpha.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgb() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		cvtps2dq	xmm4 , xmm4
		pand		xmm4 , const_dw_0_0xFFFF_0_0xFFFF
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		punpcklbw	xmm0 , const_b_0
		pmullw		xmm0 , sc_alpha_waaaa
		psrlw		xmm0 , 8
		packuswb	xmm0 , const_dw_0
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_alpha_repeat_rgb_rgba
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color , 
		const pp_alpha&	alpha
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	static const __m128	const_w_scala_0xFF = sse_set_w( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );
	__m128	sc_alpha_waaaa = sse_set_uw( 0 , 0 , 0 , 0 , alpha.a , alpha.a , alpha.a , alpha.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgba() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		cvtps2dq	xmm4 , xmm4
		pand		xmm4 , const_dw_0_0xFFFF_0_0xFFFF
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		punpcklbw	xmm0 , const_b_0
		pmullw		xmm0 , sc_alpha_waaaa
		psrlw		xmm0 , 8
		packuswb	xmm0 , const_dw_0
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_alpha_repeat_rgb_a
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color , 
		const pp_alpha&	alpha
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	static const __m128	const_w_scala_0xFF = sse_set_w( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );
	__m128	sc_alpha_waaaa = sse_set_uw( 0 , 0 , 0 , 0 , alpha.a , alpha.a , alpha.a , alpha.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_a() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		cvtps2dq	xmm4 , xmm4
		pand		xmm4 , const_dw_0_0xFFFF_0_0xFFFF
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		mov		ecx , 0
		mov		cl , [ edx ]
		movd	xmm0 , ecx
		punpcklbw	xmm0 , xmm0
		punpcklbw	xmm0 , xmm0
		punpcklbw	xmm0 , const_b_0
		pmullw		xmm0 , sc_color_wrgba
		psrlw		xmm0 , 8
		pmullw		xmm0 , sc_alpha_waaaa
		psrlw		xmm0 , 8
		packuswb	xmm0 , const_dw_0
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_alpha_repeat_rgba_rgb
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color , 
		const pp_alpha&	alpha
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	static const __m128	const_w_scala_0xFF = sse_set_w( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );
	__m128	sc_alpha_waaaa = sse_set_uw( 0 , 0 , 0 , 0 , alpha.a , alpha.a , alpha.a , alpha.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgb() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		cvtps2dq	xmm4 , xmm4
		pand		xmm4 , const_dw_0_0xFFFF_0_0xFFFF
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		por			xmm0 , const_b_scala_0xFF
		punpcklbw	xmm0 , const_b_0
		pmullw		xmm0 , sc_alpha_waaaa
		psrlw		xmm0 , 8
		packuswb	xmm0 , const_dw_0
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_alpha_repeat_rgba_rgba
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color , 
		const pp_alpha&	alpha
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	static const __m128	const_w_scala_0xFF = sse_set_w( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );
	__m128	sc_alpha_waaaa = sse_set_uw( 0 , 0 , 0 , 0 , alpha.a , alpha.a , alpha.a , alpha.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgba() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		cvtps2dq	xmm4 , xmm4
		pand		xmm4 , const_dw_0_0xFFFF_0_0xFFFF
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		punpcklbw	xmm0 , const_b_0
		pmullw		xmm0 , sc_alpha_waaaa
		psrlw		xmm0 , 8
		packuswb	xmm0 , const_dw_0
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_alpha_repeat_rgba_a
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color , 
		const pp_alpha&	alpha
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	static const __m128	const_w_scala_0xFF = sse_set_w( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );
	__m128	sc_alpha_waaaa = sse_set_uw( 0 , 0 , 0 , 0 , alpha.a , alpha.a , alpha.a , alpha.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_a() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		cvtps2dq	xmm4 , xmm4
		pand		xmm4 , const_dw_0_0xFFFF_0_0xFFFF
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		mov		ecx , 0
		mov		cl , [ edx ]
		movd	xmm0 , ecx
		punpcklbw	xmm0 , xmm0
		punpcklbw	xmm0 , xmm0
		punpcklbw	xmm0 , const_b_0
		pmullw		xmm0 , sc_color_wrgba
		psrlw		xmm0 , 8
		pmullw		xmm0 , sc_alpha_waaaa
		psrlw		xmm0 , 8
		packuswb	xmm0 , const_dw_0
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_alpha_repeat_a_rgb
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color , 
		const pp_alpha&	alpha
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	static const __m128	const_w_scala_0xFF = sse_set_w( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );
	__m128	sc_alpha_waaaa = sse_set_uw( 0 , 0 , 0 , 0 , alpha.a , alpha.a , alpha.a , alpha.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgb() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		cvtps2dq	xmm4 , xmm4
		pand		xmm4 , const_dw_0_0xFFFF_0_0xFFFF
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		movaps		xmm0 , const_w_scala_0xFF
		pmullw		xmm0 , sc_alpha_waaaa
		psrlw		xmm0 , 8
		movd	ecx , xmm0
		mov		[ eax ] , cl
		add		eax , 1
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_alpha_repeat_a_rgba
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color , 
		const pp_alpha&	alpha
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	static const __m128	const_w_scala_0xFF = sse_set_w( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );
	__m128	sc_alpha_waaaa = sse_set_uw( 0 , 0 , 0 , 0 , alpha.a , alpha.a , alpha.a , alpha.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgba() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		cvtps2dq	xmm4 , xmm4
		pand		xmm4 , const_dw_0_0xFFFF_0_0xFFFF
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		punpcklbw	xmm0 , const_b_0
		pmullw		xmm0 , sc_alpha_waaaa
		psrlw		xmm0 , 8
		movd	ecx , xmm0
		mov		[ eax ] , cl
		add		eax , 1
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_alpha_repeat_a_a
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color , 
		const pp_alpha&	alpha
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	static const __m128	const_w_scala_0xFF = sse_set_w( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );
	__m128	sc_alpha_waaaa = sse_set_uw( 0 , 0 , 0 , 0 , alpha.a , alpha.a , alpha.a , alpha.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_a() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		cvtps2dq	xmm4 , xmm4
		pand		xmm4 , const_dw_0_0xFFFF_0_0xFFFF
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		mov		ecx , 0
		mov		cl , [ edx ]
		movd	xmm0 , ecx
		punpcklbw	xmm0 , const_b_0
		pmullw		xmm0 , sc_alpha_waaaa
		psrlw		xmm0 , 8
		movd	ecx , xmm0
		mov		[ eax ] , cl
		add		eax , 1
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}

//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_alpha_clamp_rgb_rgb
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color , 
		const pp_alpha&	alpha
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	static const __m128	const_w_scala_0xFF = sse_set_w( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );
	__m128	sc_alpha_waaaa = sse_set_uw( 0 , 0 , 0 , 0 , alpha.a , alpha.a , alpha.a , alpha.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgb() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		maxps		xmm4 , const_f_0
		minps		xmm4 , const_f_0_0xFFFF_0_0xFFFF
		cvtps2dq	xmm4 , xmm4
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		punpcklbw	xmm0 , const_b_0
		pmullw		xmm0 , sc_alpha_waaaa
		psrlw		xmm0 , 8
		packuswb	xmm0 , const_dw_0
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_alpha_clamp_rgb_rgba
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color , 
		const pp_alpha&	alpha
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	static const __m128	const_w_scala_0xFF = sse_set_w( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );
	__m128	sc_alpha_waaaa = sse_set_uw( 0 , 0 , 0 , 0 , alpha.a , alpha.a , alpha.a , alpha.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgba() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		maxps		xmm4 , const_f_0
		minps		xmm4 , const_f_0_0xFFFF_0_0xFFFF
		cvtps2dq	xmm4 , xmm4
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		punpcklbw	xmm0 , const_b_0
		pmullw		xmm0 , sc_alpha_waaaa
		psrlw		xmm0 , 8
		packuswb	xmm0 , const_dw_0
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_alpha_clamp_rgb_a
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color , 
		const pp_alpha&	alpha
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	static const __m128	const_w_scala_0xFF = sse_set_w( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );
	__m128	sc_alpha_waaaa = sse_set_uw( 0 , 0 , 0 , 0 , alpha.a , alpha.a , alpha.a , alpha.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_a() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		maxps		xmm4 , const_f_0
		minps		xmm4 , const_f_0_0xFFFF_0_0xFFFF
		cvtps2dq	xmm4 , xmm4
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		mov		ecx , 0
		mov		cl , [ edx ]
		movd	xmm0 , ecx
		punpcklbw	xmm0 , xmm0
		punpcklbw	xmm0 , xmm0
		punpcklbw	xmm0 , const_b_0
		pmullw		xmm0 , sc_color_wrgba
		psrlw		xmm0 , 8
		pmullw		xmm0 , sc_alpha_waaaa
		psrlw		xmm0 , 8
		packuswb	xmm0 , const_dw_0
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_alpha_clamp_rgba_rgb
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color , 
		const pp_alpha&	alpha
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	static const __m128	const_w_scala_0xFF = sse_set_w( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );
	__m128	sc_alpha_waaaa = sse_set_uw( 0 , 0 , 0 , 0 , alpha.a , alpha.a , alpha.a , alpha.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgb() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		maxps		xmm4 , const_f_0
		minps		xmm4 , const_f_0_0xFFFF_0_0xFFFF
		cvtps2dq	xmm4 , xmm4
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		por			xmm0 , const_b_scala_0xFF
		punpcklbw	xmm0 , const_b_0
		pmullw		xmm0 , sc_alpha_waaaa
		psrlw		xmm0 , 8
		packuswb	xmm0 , const_dw_0
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_alpha_clamp_rgba_rgba
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color , 
		const pp_alpha&	alpha
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	static const __m128	const_w_scala_0xFF = sse_set_w( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );
	__m128	sc_alpha_waaaa = sse_set_uw( 0 , 0 , 0 , 0 , alpha.a , alpha.a , alpha.a , alpha.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgba() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		maxps		xmm4 , const_f_0
		minps		xmm4 , const_f_0_0xFFFF_0_0xFFFF
		cvtps2dq	xmm4 , xmm4
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		punpcklbw	xmm0 , const_b_0
		pmullw		xmm0 , sc_alpha_waaaa
		psrlw		xmm0 , 8
		packuswb	xmm0 , const_dw_0
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_alpha_clamp_rgba_a
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color , 
		const pp_alpha&	alpha
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	static const __m128	const_w_scala_0xFF = sse_set_w( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );
	__m128	sc_alpha_waaaa = sse_set_uw( 0 , 0 , 0 , 0 , alpha.a , alpha.a , alpha.a , alpha.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_a() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		maxps		xmm4 , const_f_0
		minps		xmm4 , const_f_0_0xFFFF_0_0xFFFF
		cvtps2dq	xmm4 , xmm4
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		mov		ecx , 0
		mov		cl , [ edx ]
		movd	xmm0 , ecx
		punpcklbw	xmm0 , xmm0
		punpcklbw	xmm0 , xmm0
		punpcklbw	xmm0 , const_b_0
		pmullw		xmm0 , sc_color_wrgba
		psrlw		xmm0 , 8
		pmullw		xmm0 , sc_alpha_waaaa
		psrlw		xmm0 , 8
		packuswb	xmm0 , const_dw_0
		movd	[ eax ] , xmm0
		add		eax , 4
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_alpha_clamp_a_rgb
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color , 
		const pp_alpha&	alpha
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	static const __m128	const_w_scala_0xFF = sse_set_w( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );
	__m128	sc_alpha_waaaa = sse_set_uw( 0 , 0 , 0 , 0 , alpha.a , alpha.a , alpha.a , alpha.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgb() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		maxps		xmm4 , const_f_0
		minps		xmm4 , const_f_0_0xFFFF_0_0xFFFF
		cvtps2dq	xmm4 , xmm4
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		movaps		xmm0 , const_w_scala_0xFF
		pmullw		xmm0 , sc_alpha_waaaa
		psrlw		xmm0 , 8
		movd	ecx , xmm0
		mov		[ eax ] , cl
		add		eax , 1
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_alpha_clamp_a_rgba
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color , 
		const pp_alpha&	alpha
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	static const __m128	const_w_scala_0xFF = sse_set_w( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );
	__m128	sc_alpha_waaaa = sse_set_uw( 0 , 0 , 0 , 0 , alpha.a , alpha.a , alpha.a , alpha.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_rgba() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		maxps		xmm4 , const_f_0
		minps		xmm4 , const_f_0_0xFFFF_0_0xFFFF
		cvtps2dq	xmm4 , xmm4
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		movd	xmm0 , [ edx ]
		punpcklbw	xmm0 , const_b_0
		pmullw		xmm0 , sc_alpha_waaaa
		psrlw		xmm0 , 8
		movd	ecx , xmm0
		mov		[ eax ] , cl
		add		eax , 1
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m_alpha_clamp_a_a
		(
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color , 
		const pp_alpha&	alpha
		)
{
	static const __m128	const_dw_0_0xFFFF_0_0xFFFF = sse_set_dw( 0 , 0xFFFF , 0 , 0xFFFF );
	static const __m128	const_f_0_0xFFFF_0_0xFFFF = sse_set_ps( 0.0f ,  (float)0xFFFF ,  0.0f ,  (float)0xFFFF );
	static const __m128	const_f_0 = sse_set_ps( 0.0f , 0.0f , 0.0f , 0.0f );
	static const __m128	const_f_0x10000 = sse_set_ps( 65536.0f , 65536.0f , 65536.0f , 65536.0f );
	static const __m128	const_b_scala_0xFF = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	static const __m128	const_dw_0 = sse_set_dw( 0 , 0 , 0 , 0 );
	static const __m128	const_b_0 = sse_set_ub( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 );
	static const __m128	const_w_scala_0xFF = sse_set_w( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0xFF );
	__m128	sc_color_wrgba = sse_set_uw( 0 , 0 , 0 , 0 , ((uint32)b_color.b * (uint32)b_color.a) >> 8 , ((uint32)b_color.g * (uint32)b_color.a) >> 8 , ((uint32)b_color.r * (uint32)b_color.a) >> 8 , b_color.a );
	__m128	sc_alpha_waaaa = sse_set_uw( 0 , 0 , 0 , 0 , alpha.a , alpha.a , alpha.a , alpha.a );

	float	du	= ( ttu - ssu ) / (float)len;
	float	dv	= ( ttv - ssv ) / (float)len;
	__m128	duv = sse_set_ps( 0 , du , 0 , dv );
	__m128	suv = sse_set_ps( 0 , ssu + du / 2.0f  , 0 , ssv + dv / 2.0f );
	__m128	wh	= sse_set_dw( 0 , src_w , 0 , src_h );
	__m128	pixbyte_pitch	= sse_set_dw( 0 , PixelSize_a() , 0 , src_pitchbyte );
	_asm
	{
		mov		eax , dest
		movaps	xmm3 , suv
	len_loop_start:
		dec		len
		jl		len_loop_end
			movaps		xmm4 , xmm3
		mulps		xmm4 , const_f_0x10000
		maxps		xmm4 , const_f_0
		minps		xmm4 , const_f_0_0xFFFF_0_0xFFFF
		cvtps2dq	xmm4 , xmm4
			pmuludq		xmm4 , wh
			psrld		xmm4 , 16
		pmuludq		xmm4 , pixbyte_pitch
		movaps		xmm5 , xmm4
		shufps		xmm4 , xmm4 , 0x4E
		paddd		xmm4 , xmm5
			movd		edx , xmm4
			add			edx , src
		mov		ecx , 0
		mov		cl , [ edx ]
		movd	xmm0 , ecx
		punpcklbw	xmm0 , const_b_0
		pmullw		xmm0 , sc_alpha_waaaa
		psrlw		xmm0 , 8
		movd	ecx , xmm0
		mov		[ eax ] , cl
		add		eax , 1
			addps		xmm3 , duv
		jmp		len_loop_start
	len_loop_end:
	}
}

//=================================================================================================
//!	texture nearest
//!	@retval			---
//-------------------------------------------------------------------------------------------------
cb_inline
void pp_sse_texture_nearest_m
		(
		pp_format		destformat , 
		void*			dest , 
		int32			len , 
		float			ssu , 
		float			ssv , 
		float			ttu , 
		float			ttv , 
		pp_format		srcformat , 
		const void*		src , 
		int32			src_pitchbyte , 
		int16			src_w , 
		int16			src_h , 
		const pp_color&	b_color , 
		const pp_alpha&	alpha , 
		pp_wraptype		wrap
		)
{
	typedef void (*func)( void* , int32 , float , float , float , float , const void* , int32 , int16 , int16 , const pp_color& );
	typedef void (*func_a)( void* , int32 , float , float , float , float , const void* , int32 , int16 , int16 , const pp_color& , const pp_alpha& );
	static
	func	funclist[2][4][4] = 
	{
		{
			{
			pp_sse_texture_nearest_m_repeat_rgb_rgb , 
			pp_sse_texture_nearest_m_repeat_rgb_rgba , 
			pp_sse_texture_nearest_m_repeat_rgb_a , 
			} , 
			{
			pp_sse_texture_nearest_m_repeat_rgba_rgb , 
			pp_sse_texture_nearest_m_repeat_rgba_rgba , 
			pp_sse_texture_nearest_m_repeat_rgba_a , 
			} , 
			{
			pp_sse_texture_nearest_m_repeat_a_rgb , 
			pp_sse_texture_nearest_m_repeat_a_rgba , 
			pp_sse_texture_nearest_m_repeat_a_a , 
			} , 
		} , 
		{
			{
			pp_sse_texture_nearest_m_clamp_rgb_rgb , 
			pp_sse_texture_nearest_m_clamp_rgb_rgba , 
			pp_sse_texture_nearest_m_clamp_rgb_a , 
			} , 
			{
			pp_sse_texture_nearest_m_clamp_rgba_rgb , 
			pp_sse_texture_nearest_m_clamp_rgba_rgba , 
			pp_sse_texture_nearest_m_clamp_rgba_a , 
			} , 
			{
			pp_sse_texture_nearest_m_clamp_a_rgb , 
			pp_sse_texture_nearest_m_clamp_a_rgba , 
			pp_sse_texture_nearest_m_clamp_a_a , 
			} , 
		} , 
	};
	static
	func_a	funclist_a[2][4][4] = 
	{
		{
			{
			pp_sse_texture_nearest_m_alpha_repeat_rgb_rgb , 
			pp_sse_texture_nearest_m_alpha_repeat_rgb_rgba , 
			pp_sse_texture_nearest_m_alpha_repeat_rgb_a , 
			} , 
			{
			pp_sse_texture_nearest_m_alpha_repeat_rgba_rgb , 
			pp_sse_texture_nearest_m_alpha_repeat_rgba_rgba , 
			pp_sse_texture_nearest_m_alpha_repeat_rgba_a , 
			} , 
			{
			pp_sse_texture_nearest_m_alpha_repeat_a_rgb , 
			pp_sse_texture_nearest_m_alpha_repeat_a_rgba , 
			pp_sse_texture_nearest_m_alpha_repeat_a_a , 
			} , 
		} , 
		{
			{
			pp_sse_texture_nearest_m_alpha_clamp_rgb_rgb , 
			pp_sse_texture_nearest_m_alpha_clamp_rgb_rgba , 
			pp_sse_texture_nearest_m_alpha_clamp_rgb_a , 
			} , 
			{
			pp_sse_texture_nearest_m_alpha_clamp_rgba_rgb , 
			pp_sse_texture_nearest_m_alpha_clamp_rgba_rgba , 
			pp_sse_texture_nearest_m_alpha_clamp_rgba_a , 
			} , 
			{
			pp_sse_texture_nearest_m_alpha_clamp_a_rgb , 
			pp_sse_texture_nearest_m_alpha_clamp_a_rgba , 
			pp_sse_texture_nearest_m_alpha_clamp_a_a , 
			} , 
		} , 
	};
	if( alpha.a == 256 )
		( funclist[ wrap ][ destformat ][ srcformat ] )( dest , len , ssu , ssv , ttu , ttv , src , src_pitchbyte , src_w , src_h , b_color );
	else
		( funclist_a[ wrap ][ destformat ][ srcformat ] )( dest , len , ssu , ssv , ttu , ttv , src , src_pitchbyte , src_w , src_h , b_color , alpha );
}

};	//namespace

//using namespace icubic;		

#pragma pack( pop )			//release align
