1 /**************************************************************************
3 * Copyright 2009 Ben Skeggs
4 * Copyright 2009 Younes Manton
5 * Copyright 2010 Luca Barbieri
8 * Permission is hereby granted, free of charge, to any person obtaining
9 * a copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sub license, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
18 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS, AUTHORS
20 * AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
23 * USE OR OTHER DEALINGS IN THE SOFTWARE.
25 * The above copyright notice and this permission notice (including the
26 * next paragraph) shall be included in all copies or substantial portions
29 **************************************************************************/
31 /* this code has no Mesa or Gallium dependency and can be reused in the classic Mesa driver or DDX */
36 struct nv04_2d_context
;
37 struct nouveau_channel
;
40 // NOTE: all functions taking this as a parameter will CLOBBER it (except for ->bo)
42 struct nouveau_bo
* bo
;
44 unsigned pitch
; // 0 -> swizzled
45 unsigned bpps
; // bpp shift (0, 1, 2; 3, 4 for fp/compressed)
46 unsigned one_bits
; // number of high bits read and written as ones (for "no-alpha" optimization)
52 nv04_region_try_to_linearize(struct nv04_region
* rgn
)
58 if(rgn
->h
<= 1 || rgn
->w
<= 2)
59 rgn
->pitch
= rgn
->w
<< rgn
->bpps
;
63 if(rgn
->h
<= 2 && rgn
->w
<= 2)
65 rgn
->pitch
= rgn
->w
<< rgn
->bpps
;
66 rgn
->offset
+= rgn
->z
* rgn
->h
* rgn
->pitch
;
72 nv04_memcpy(struct nv04_2d_context
*ctx
,
73 struct nouveau_bo
* dstbo
, int dstoff
,
74 struct nouveau_bo
* srcbo
, int srcoff
,
78 nv04_region_begin(struct nv04_region
* rgn
, unsigned w
, unsigned h
);
81 nv04_region_end(struct nv04_region
* rgn
, unsigned w
, unsigned h
);
84 nv04_2d_context_takedown(struct nv04_2d_context
*pctx
);
86 struct nv04_2d_context
*
87 nv04_2d_context_init(struct nouveau_channel
* chan
);
90 nv04_region_copy_cpu(struct nv04_region
* dst
, struct nv04_region
* src
, int w
, int h
);
93 nv04_region_fill_cpu(struct nv04_region
* dst
, int w
, int h
, unsigned value
);
96 nv04_region_copy_2d(struct nv04_2d_context
*ctx
,
97 struct nv04_region
* dst
, struct nv04_region
* src
,
99 int dst_to_gpu
, int src_on_gpu
);
102 nv04_region_fill_2d(struct nv04_2d_context
*ctx
,
103 struct nv04_region
*dst
,