aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/nvfx/nv04_2d_loops.h
blob: 3a6787c07179eebf33dcfab67b5dcc28dfbc8332 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef T
{
	if(dst->bpps == 0)
#define T uint8_t
#include "nv04_2d_loops.h"
#undef T
	else if(dst->bpps == 1)
#define T uint16_t
#include "nv04_2d_loops.h"
#undef T
	else if(dst->bpps == 2)
#define T uint32_t
#include "nv04_2d_loops.h"
#undef T
	else
		assert(0);
}
#else
#ifdef SWIZZLED_COPY_LOOPS
{
	if(!dst->pitch)
	{
		if(!src->pitch)
		{
			LOOP_Y
			{
				T* pdst = (T*)mdst + dswy[iy];
				T* psrc = (T*)msrc + sswy[iy];
				LOOP_X
				{
					assert((char*)&psrc[sswx[ix] + 1] <= ((char*)src->bo->map + src->bo->size));
					assert((char*)&pdst[dswx[ix] + 1] <= ((char*)dst->bo->map + dst->bo->size));
					pdst[dswx[ix]] = psrc[sswx[ix]];
				}
			}
		}
		else
		{
			T* psrc = (T*)(msrc + ((dir > 0) ? src->y : (src->y + h - 1)) * src->pitch) + src->x;
			LOOP_Y
			{
				T* pdst = (T*)mdst + dswy[iy];
				LOOP_X
				{
					assert((char*)&psrc[ix + 1] <= ((char*)src->bo->map + src->bo->size));
					assert((char*)&pdst[dswx[ix] + 1] <= ((char*)dst->bo->map + dst->bo->size));
					pdst[dswx[ix]] = psrc[ix];
				}
				psrc = (T*)((char*)psrc + dir * src->pitch);
			}
		}
	}
	else
	{
		T* pdst = (T*)(mdst + ((dir > 0) ? dst->y : (dst->y + h - 1)) * dst->pitch) + dst->x;
		LOOP_Y
		{
			T* psrc = (T*)msrc + sswy[iy];
			LOOP_X
			{
				assert((char*)&psrc[sswx[ix] + 1] <= ((char*)src->bo->map + src->bo->size));
				assert((char*)&pdst[ix + 1] <= ((char*)dst->bo->map + dst->bo->size));
				pdst[ix] = psrc[sswx[ix]];
			}
			pdst = (T*)((char*)pdst + dir * dst->pitch);
		}
	}
}
#endif
#endif