2 * Copyright 2008 Ben Skeggs
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
25 #include "pipe/p_defines.h"
27 #include "util/u_inlines.h"
28 #include "util/u_pack_color.h"
29 #include "util/u_format.h"
30 #include "util/u_surface.h"
32 #include "tgsi/tgsi_ureg.h"
34 #include "os/os_thread.h"
36 #include "nv50/nv50_context.h"
37 #include "nv50/nv50_resource.h"
39 #include "nv50/nv50_defs.xml.h"
40 #include "nv50/nv50_texture.xml.h"
42 /* these are used in nv50_blit.h */
43 #define NV50_ENG2D_SUPPORTED_FORMATS 0xff0843e080608409ULL
44 #define NV50_ENG2D_NOCONVERT_FORMATS 0x0008402000000000ULL
45 #define NV50_ENG2D_LUMINANCE_FORMATS 0x0008402000000000ULL
46 #define NV50_ENG2D_INTENSITY_FORMATS 0x0000000000000000ULL
47 #define NV50_ENG2D_OPERATION_FORMATS 0x060001c000608000ULL
49 #define NOUVEAU_DRIVER 0x50
50 #include "nv50/nv50_blit.h"
53 nv50_2d_format(enum pipe_format format
, bool dst
, bool dst_src_equal
)
55 uint8_t id
= nv50_format_table
[format
].rt
;
57 /* Hardware values for color formats range from 0xc0 to 0xff,
58 * but the 2D engine doesn't support all of them.
60 if ((id
>= 0xc0) && (NV50_ENG2D_SUPPORTED_FORMATS
& (1ULL << (id
- 0xc0))))
62 assert(dst_src_equal
);
64 switch (util_format_get_blocksize(format
)) {
66 return NV50_SURFACE_FORMAT_R8_UNORM
;
68 return NV50_SURFACE_FORMAT_R16_UNORM
;
70 return NV50_SURFACE_FORMAT_BGRA8_UNORM
;
72 return NV50_SURFACE_FORMAT_RGBA16_FLOAT
;
74 return NV50_SURFACE_FORMAT_RGBA32_FLOAT
;
81 nv50_2d_texture_set(struct nouveau_pushbuf
*push
, int dst
,
82 struct nv50_miptree
*mt
, unsigned level
, unsigned layer
,
83 enum pipe_format pformat
, bool dst_src_pformat_equal
)
85 struct nouveau_bo
*bo
= mt
->base
.bo
;
86 uint32_t width
, height
, depth
;
88 uint32_t mthd
= dst
? NV50_2D_DST_FORMAT
: NV50_2D_SRC_FORMAT
;
89 uint32_t offset
= mt
->level
[level
].offset
;
91 format
= nv50_2d_format(pformat
, dst
, dst_src_pformat_equal
);
93 NOUVEAU_ERR("invalid/unsupported surface format: %s\n",
94 util_format_name(pformat
));
98 width
= u_minify(mt
->base
.base
.width0
, level
) << mt
->ms_x
;
99 height
= u_minify(mt
->base
.base
.height0
, level
) << mt
->ms_y
;
100 depth
= u_minify(mt
->base
.base
.depth0
, level
);
102 offset
= mt
->level
[level
].offset
;
103 if (!mt
->layout_3d
) {
104 offset
+= mt
->layer_stride
* layer
;
109 offset
+= nv50_mt_zslice_offset(mt
, level
, layer
);
113 if (!nouveau_bo_memtype(bo
)) {
114 BEGIN_NV04(push
, SUBC_2D(mthd
), 2);
115 PUSH_DATA (push
, format
);
117 BEGIN_NV04(push
, SUBC_2D(mthd
+ 0x14), 5);
118 PUSH_DATA (push
, mt
->level
[level
].pitch
);
119 PUSH_DATA (push
, width
);
120 PUSH_DATA (push
, height
);
121 PUSH_DATAh(push
, mt
->base
.address
+ offset
);
122 PUSH_DATA (push
, mt
->base
.address
+ offset
);
124 BEGIN_NV04(push
, SUBC_2D(mthd
), 5);
125 PUSH_DATA (push
, format
);
127 PUSH_DATA (push
, mt
->level
[level
].tile_mode
);
128 PUSH_DATA (push
, depth
);
129 PUSH_DATA (push
, layer
);
130 BEGIN_NV04(push
, SUBC_2D(mthd
+ 0x18), 4);
131 PUSH_DATA (push
, width
);
132 PUSH_DATA (push
, height
);
133 PUSH_DATAh(push
, mt
->base
.address
+ offset
);
134 PUSH_DATA (push
, mt
->base
.address
+ offset
);
139 BEGIN_NV04(push
, SUBC_2D(NV50_2D_CLIP_X
), 4);
142 PUSH_DATA (push
, width
);
143 PUSH_DATA (push
, height
);
150 nv50_2d_texture_do_copy(struct nouveau_pushbuf
*push
,
151 struct nv50_miptree
*dst
, unsigned dst_level
,
152 unsigned dx
, unsigned dy
, unsigned dz
,
153 struct nv50_miptree
*src
, unsigned src_level
,
154 unsigned sx
, unsigned sy
, unsigned sz
,
155 unsigned w
, unsigned h
)
157 const enum pipe_format dfmt
= dst
->base
.base
.format
;
158 const enum pipe_format sfmt
= src
->base
.base
.format
;
160 bool eqfmt
= dfmt
== sfmt
;
162 if (!PUSH_SPACE(push
, 2 * 16 + 32))
165 ret
= nv50_2d_texture_set(push
, 1, dst
, dst_level
, dz
, dfmt
, eqfmt
);
169 ret
= nv50_2d_texture_set(push
, 0, src
, src_level
, sz
, sfmt
, eqfmt
);
173 BEGIN_NV04(push
, NV50_2D(BLIT_CONTROL
), 1);
174 PUSH_DATA (push
, NV50_2D_BLIT_CONTROL_FILTER_POINT_SAMPLE
);
175 BEGIN_NV04(push
, NV50_2D(BLIT_DST_X
), 4);
176 PUSH_DATA (push
, dx
<< dst
->ms_x
);
177 PUSH_DATA (push
, dy
<< dst
->ms_y
);
178 PUSH_DATA (push
, w
<< dst
->ms_x
);
179 PUSH_DATA (push
, h
<< dst
->ms_y
);
180 BEGIN_NV04(push
, NV50_2D(BLIT_DU_DX_FRACT
), 4);
185 BEGIN_NV04(push
, NV50_2D(BLIT_SRC_X_FRACT
), 4);
187 PUSH_DATA (push
, sx
<< src
->ms_x
);
189 PUSH_DATA (push
, sy
<< src
->ms_y
);
195 nv50_resource_copy_region(struct pipe_context
*pipe
,
196 struct pipe_resource
*dst
, unsigned dst_level
,
197 unsigned dstx
, unsigned dsty
, unsigned dstz
,
198 struct pipe_resource
*src
, unsigned src_level
,
199 const struct pipe_box
*src_box
)
201 struct nv50_context
*nv50
= nv50_context(pipe
);
204 unsigned dst_layer
= dstz
, src_layer
= src_box
->z
;
206 if (dst
->target
== PIPE_BUFFER
&& src
->target
== PIPE_BUFFER
) {
207 nouveau_copy_buffer(&nv50
->base
,
208 nv04_resource(dst
), dstx
,
209 nv04_resource(src
), src_box
->x
, src_box
->width
);
213 /* 0 and 1 are equal, only supporting 0/1, 2, 4 and 8 */
214 assert((src
->nr_samples
| 1) == (dst
->nr_samples
| 1));
216 m2mf
= (src
->format
== dst
->format
) ||
217 (util_format_get_blocksizebits(src
->format
) ==
218 util_format_get_blocksizebits(dst
->format
));
220 nv04_resource(dst
)->status
|= NOUVEAU_BUFFER_STATUS_GPU_WRITING
;
223 struct nv50_miptree
*src_mt
= nv50_miptree(src
);
224 struct nv50_miptree
*dst_mt
= nv50_miptree(dst
);
225 struct nv50_m2mf_rect drect
, srect
;
227 unsigned nx
= util_format_get_nblocksx(src
->format
, src_box
->width
)
229 unsigned ny
= util_format_get_nblocksy(src
->format
, src_box
->height
)
232 nv50_m2mf_rect_setup(&drect
, dst
, dst_level
, dstx
, dsty
, dstz
);
233 nv50_m2mf_rect_setup(&srect
, src
, src_level
,
234 src_box
->x
, src_box
->y
, src_box
->z
);
236 for (i
= 0; i
< src_box
->depth
; ++i
) {
237 nv50_m2mf_transfer_rect(nv50
, &drect
, &srect
, nx
, ny
);
239 if (dst_mt
->layout_3d
)
242 drect
.base
+= dst_mt
->layer_stride
;
244 if (src_mt
->layout_3d
)
247 srect
.base
+= src_mt
->layer_stride
;
252 assert((src
->format
== dst
->format
) ||
253 (nv50_2d_src_format_faithful(src
->format
) &&
254 nv50_2d_dst_format_faithful(dst
->format
)));
256 BCTX_REFN(nv50
->bufctx
, 2D
, nv04_resource(src
), RD
);
257 BCTX_REFN(nv50
->bufctx
, 2D
, nv04_resource(dst
), WR
);
258 nouveau_pushbuf_bufctx(nv50
->base
.pushbuf
, nv50
->bufctx
);
259 nouveau_pushbuf_validate(nv50
->base
.pushbuf
);
261 for (; dst_layer
< dstz
+ src_box
->depth
; ++dst_layer
, ++src_layer
) {
262 ret
= nv50_2d_texture_do_copy(nv50
->base
.pushbuf
,
263 nv50_miptree(dst
), dst_level
,
264 dstx
, dsty
, dst_layer
,
265 nv50_miptree(src
), src_level
,
266 src_box
->x
, src_box
->y
, src_layer
,
267 src_box
->width
, src_box
->height
);
271 nouveau_bufctx_reset(nv50
->bufctx
, NV50_BIND_2D
);
275 nv50_clear_render_target(struct pipe_context
*pipe
,
276 struct pipe_surface
*dst
,
277 const union pipe_color_union
*color
,
278 unsigned dstx
, unsigned dsty
,
279 unsigned width
, unsigned height
)
281 struct nv50_context
*nv50
= nv50_context(pipe
);
282 struct nouveau_pushbuf
*push
= nv50
->base
.pushbuf
;
283 struct nv50_miptree
*mt
= nv50_miptree(dst
->texture
);
284 struct nv50_surface
*sf
= nv50_surface(dst
);
285 struct nouveau_bo
*bo
= mt
->base
.bo
;
288 BEGIN_NV04(push
, NV50_3D(CLEAR_COLOR(0)), 4);
289 PUSH_DATAf(push
, color
->f
[0]);
290 PUSH_DATAf(push
, color
->f
[1]);
291 PUSH_DATAf(push
, color
->f
[2]);
292 PUSH_DATAf(push
, color
->f
[3]);
294 if (nouveau_pushbuf_space(push
, 32 + sf
->depth
, 1, 0))
297 PUSH_REFN(push
, bo
, mt
->base
.domain
| NOUVEAU_BO_WR
);
299 BEGIN_NV04(push
, NV50_3D(SCREEN_SCISSOR_HORIZ
), 2);
300 PUSH_DATA (push
, ( width
<< 16) | dstx
);
301 PUSH_DATA (push
, (height
<< 16) | dsty
);
302 BEGIN_NV04(push
, NV50_3D(SCISSOR_HORIZ(0)), 2);
303 PUSH_DATA (push
, 8192 << 16);
304 PUSH_DATA (push
, 8192 << 16);
305 nv50
->scissors_dirty
|= 1;
307 BEGIN_NV04(push
, NV50_3D(RT_CONTROL
), 1);
309 BEGIN_NV04(push
, NV50_3D(RT_ADDRESS_HIGH(0)), 5);
310 PUSH_DATAh(push
, mt
->base
.address
+ sf
->offset
);
311 PUSH_DATA (push
, mt
->base
.address
+ sf
->offset
);
312 PUSH_DATA (push
, nv50_format_table
[dst
->format
].rt
);
313 PUSH_DATA (push
, mt
->level
[sf
->base
.u
.tex
.level
].tile_mode
);
314 PUSH_DATA (push
, mt
->layer_stride
>> 2);
315 BEGIN_NV04(push
, NV50_3D(RT_HORIZ(0)), 2);
316 if (nouveau_bo_memtype(bo
))
317 PUSH_DATA(push
, sf
->width
);
319 PUSH_DATA(push
, NV50_3D_RT_HORIZ_LINEAR
| mt
->level
[0].pitch
);
320 PUSH_DATA (push
, sf
->height
);
321 BEGIN_NV04(push
, NV50_3D(RT_ARRAY_MODE
), 1);
323 PUSH_DATA(push
, NV50_3D_RT_ARRAY_MODE_MODE_3D
| 512);
325 PUSH_DATA(push
, 512);
327 if (!nouveau_bo_memtype(bo
)) {
328 BEGIN_NV04(push
, NV50_3D(ZETA_ENABLE
), 1);
332 /* NOTE: only works with D3D clear flag (5097/0x143c bit 4) */
334 BEGIN_NV04(push
, NV50_3D(VIEWPORT_HORIZ(0)), 2);
335 PUSH_DATA (push
, (width
<< 16) | dstx
);
336 PUSH_DATA (push
, (height
<< 16) | dsty
);
338 BEGIN_NI04(push
, NV50_3D(CLEAR_BUFFERS
), sf
->depth
);
339 for (z
= 0; z
< sf
->depth
; ++z
) {
340 PUSH_DATA (push
, 0x3c |
341 (z
<< NV50_3D_CLEAR_BUFFERS_LAYER__SHIFT
));
344 nv50
->dirty
|= NV50_NEW_FRAMEBUFFER
| NV50_NEW_SCISSOR
;
348 nv50_clear_depth_stencil(struct pipe_context
*pipe
,
349 struct pipe_surface
*dst
,
350 unsigned clear_flags
,
353 unsigned dstx
, unsigned dsty
,
354 unsigned width
, unsigned height
)
356 struct nv50_context
*nv50
= nv50_context(pipe
);
357 struct nouveau_pushbuf
*push
= nv50
->base
.pushbuf
;
358 struct nv50_miptree
*mt
= nv50_miptree(dst
->texture
);
359 struct nv50_surface
*sf
= nv50_surface(dst
);
360 struct nouveau_bo
*bo
= mt
->base
.bo
;
364 assert(nouveau_bo_memtype(bo
)); /* ZETA cannot be linear */
366 if (clear_flags
& PIPE_CLEAR_DEPTH
) {
367 BEGIN_NV04(push
, NV50_3D(CLEAR_DEPTH
), 1);
368 PUSH_DATAf(push
, depth
);
369 mode
|= NV50_3D_CLEAR_BUFFERS_Z
;
372 if (clear_flags
& PIPE_CLEAR_STENCIL
) {
373 BEGIN_NV04(push
, NV50_3D(CLEAR_STENCIL
), 1);
374 PUSH_DATA (push
, stencil
& 0xff);
375 mode
|= NV50_3D_CLEAR_BUFFERS_S
;
378 if (nouveau_pushbuf_space(push
, 32 + sf
->depth
, 1, 0))
381 PUSH_REFN(push
, bo
, mt
->base
.domain
| NOUVEAU_BO_WR
);
383 BEGIN_NV04(push
, NV50_3D(SCREEN_SCISSOR_HORIZ
), 2);
384 PUSH_DATA (push
, ( width
<< 16) | dstx
);
385 PUSH_DATA (push
, (height
<< 16) | dsty
);
386 BEGIN_NV04(push
, NV50_3D(SCISSOR_HORIZ(0)), 2);
387 PUSH_DATA (push
, 8192 << 16);
388 PUSH_DATA (push
, 8192 << 16);
389 nv50
->scissors_dirty
|= 1;
391 BEGIN_NV04(push
, NV50_3D(ZETA_ADDRESS_HIGH
), 5);
392 PUSH_DATAh(push
, mt
->base
.address
+ sf
->offset
);
393 PUSH_DATA (push
, mt
->base
.address
+ sf
->offset
);
394 PUSH_DATA (push
, nv50_format_table
[dst
->format
].rt
);
395 PUSH_DATA (push
, mt
->level
[sf
->base
.u
.tex
.level
].tile_mode
);
396 PUSH_DATA (push
, mt
->layer_stride
>> 2);
397 BEGIN_NV04(push
, NV50_3D(ZETA_ENABLE
), 1);
399 BEGIN_NV04(push
, NV50_3D(ZETA_HORIZ
), 3);
400 PUSH_DATA (push
, sf
->width
);
401 PUSH_DATA (push
, sf
->height
);
402 PUSH_DATA (push
, (1 << 16) | 1);
404 BEGIN_NV04(push
, NV50_3D(RT_ARRAY_MODE
), 1);
405 PUSH_DATA (push
, 512);
407 BEGIN_NV04(push
, NV50_3D(VIEWPORT_HORIZ(0)), 2);
408 PUSH_DATA (push
, (width
<< 16) | dstx
);
409 PUSH_DATA (push
, (height
<< 16) | dsty
);
411 BEGIN_NI04(push
, NV50_3D(CLEAR_BUFFERS
), sf
->depth
);
412 for (z
= 0; z
< sf
->depth
; ++z
) {
413 PUSH_DATA (push
, mode
|
414 (z
<< NV50_3D_CLEAR_BUFFERS_LAYER__SHIFT
));
417 nv50
->dirty
|= NV50_NEW_FRAMEBUFFER
| NV50_NEW_SCISSOR
;
421 nv50_clear(struct pipe_context
*pipe
, unsigned buffers
,
422 const union pipe_color_union
*color
,
423 double depth
, unsigned stencil
)
425 struct nv50_context
*nv50
= nv50_context(pipe
);
426 struct nouveau_pushbuf
*push
= nv50
->base
.pushbuf
;
427 struct pipe_framebuffer_state
*fb
= &nv50
->framebuffer
;
431 /* don't need NEW_BLEND, COLOR_MASK doesn't affect CLEAR_BUFFERS */
432 if (!nv50_state_validate(nv50
, NV50_NEW_FRAMEBUFFER
, 9 + (fb
->nr_cbufs
* 2)))
435 /* We have to clear ALL of the layers, not up to the min number of layers
436 * of any attachment. */
437 BEGIN_NV04(push
, NV50_3D(RT_ARRAY_MODE
), 1);
438 PUSH_DATA (push
, (nv50
->rt_array_mode
& NV50_3D_RT_ARRAY_MODE_MODE_3D
) | 512);
440 if (buffers
& PIPE_CLEAR_COLOR
&& fb
->nr_cbufs
) {
441 BEGIN_NV04(push
, NV50_3D(CLEAR_COLOR(0)), 4);
442 PUSH_DATAf(push
, color
->f
[0]);
443 PUSH_DATAf(push
, color
->f
[1]);
444 PUSH_DATAf(push
, color
->f
[2]);
445 PUSH_DATAf(push
, color
->f
[3]);
446 if (buffers
& PIPE_CLEAR_COLOR0
)
448 NV50_3D_CLEAR_BUFFERS_R
| NV50_3D_CLEAR_BUFFERS_G
|
449 NV50_3D_CLEAR_BUFFERS_B
| NV50_3D_CLEAR_BUFFERS_A
;
452 if (buffers
& PIPE_CLEAR_DEPTH
) {
453 BEGIN_NV04(push
, NV50_3D(CLEAR_DEPTH
), 1);
454 PUSH_DATA (push
, fui(depth
));
455 mode
|= NV50_3D_CLEAR_BUFFERS_Z
;
458 if (buffers
& PIPE_CLEAR_STENCIL
) {
459 BEGIN_NV04(push
, NV50_3D(CLEAR_STENCIL
), 1);
460 PUSH_DATA (push
, stencil
& 0xff);
461 mode
|= NV50_3D_CLEAR_BUFFERS_S
;
465 int zs_layers
= 0, color0_layers
= 0;
466 if (fb
->cbufs
[0] && (mode
& 0x3c))
467 color0_layers
= fb
->cbufs
[0]->u
.tex
.last_layer
-
468 fb
->cbufs
[0]->u
.tex
.first_layer
+ 1;
469 if (fb
->zsbuf
&& (mode
& ~0x3c))
470 zs_layers
= fb
->zsbuf
->u
.tex
.last_layer
-
471 fb
->zsbuf
->u
.tex
.first_layer
+ 1;
473 for (j
= 0; j
< MIN2(zs_layers
, color0_layers
); j
++) {
474 BEGIN_NV04(push
, NV50_3D(CLEAR_BUFFERS
), 1);
475 PUSH_DATA(push
, mode
| (j
<< NV50_3D_CLEAR_BUFFERS_LAYER__SHIFT
));
477 for (k
= j
; k
< zs_layers
; k
++) {
478 BEGIN_NV04(push
, NV50_3D(CLEAR_BUFFERS
), 1);
479 PUSH_DATA(push
, (mode
& ~0x3c) | (k
<< NV50_3D_CLEAR_BUFFERS_LAYER__SHIFT
));
481 for (k
= j
; k
< color0_layers
; k
++) {
482 BEGIN_NV04(push
, NV50_3D(CLEAR_BUFFERS
), 1);
483 PUSH_DATA(push
, (mode
& 0x3c) | (k
<< NV50_3D_CLEAR_BUFFERS_LAYER__SHIFT
));
487 for (i
= 1; i
< fb
->nr_cbufs
; i
++) {
488 struct pipe_surface
*sf
= fb
->cbufs
[i
];
489 if (!sf
|| !(buffers
& (PIPE_CLEAR_COLOR0
<< i
)))
491 for (j
= 0; j
<= sf
->u
.tex
.last_layer
- sf
->u
.tex
.first_layer
; j
++) {
492 BEGIN_NV04(push
, NV50_3D(CLEAR_BUFFERS
), 1);
493 PUSH_DATA (push
, (i
<< 6) | 0x3c |
494 (j
<< NV50_3D_CLEAR_BUFFERS_LAYER__SHIFT
));
498 /* restore the array mode */
499 BEGIN_NV04(push
, NV50_3D(RT_ARRAY_MODE
), 1);
500 PUSH_DATA (push
, nv50
->rt_array_mode
);
504 nv50_clear_buffer(struct pipe_context
*pipe
,
505 struct pipe_resource
*res
,
506 unsigned offset
, unsigned size
,
507 const void *data
, int data_size
)
509 struct nv50_context
*nv50
= nv50_context(pipe
);
510 struct nouveau_pushbuf
*push
= nv50
->base
.pushbuf
;
511 struct nv04_resource
*buf
= (struct nv04_resource
*)res
;
512 union pipe_color_union color
;
513 enum pipe_format dst_fmt
;
514 unsigned width
, height
, elements
;
516 assert(res
->target
== PIPE_BUFFER
);
517 assert(nouveau_bo_memtype(buf
->bo
) == 0);
521 dst_fmt
= PIPE_FORMAT_R32G32B32A32_UINT
;
522 memcpy(&color
.ui
, data
, 16);
525 dst_fmt
= PIPE_FORMAT_R32G32_UINT
;
526 memcpy(&color
.ui
, data
, 8);
527 memset(&color
.ui
[2], 0, 8);
530 dst_fmt
= PIPE_FORMAT_R32_UINT
;
531 memcpy(&color
.ui
, data
, 4);
532 memset(&color
.ui
[1], 0, 12);
535 dst_fmt
= PIPE_FORMAT_R16_UINT
;
536 color
.ui
[0] = util_cpu_to_le32(
537 util_le16_to_cpu(*(unsigned short *)data
));
538 memset(&color
.ui
[1], 0, 12);
541 dst_fmt
= PIPE_FORMAT_R8_UINT
;
542 color
.ui
[0] = util_cpu_to_le32(*(unsigned char *)data
);
543 memset(&color
.ui
[1], 0, 12);
546 assert(!"Unsupported element size");
550 assert(size
% data_size
== 0);
552 elements
= size
/ data_size
;
553 height
= (elements
+ 8191) / 8192;
554 width
= elements
/ height
;
556 BEGIN_NV04(push
, NV50_3D(CLEAR_COLOR(0)), 4);
557 PUSH_DATAf(push
, color
.f
[0]);
558 PUSH_DATAf(push
, color
.f
[1]);
559 PUSH_DATAf(push
, color
.f
[2]);
560 PUSH_DATAf(push
, color
.f
[3]);
562 if (nouveau_pushbuf_space(push
, 32, 1, 0))
565 PUSH_REFN(push
, buf
->bo
, buf
->domain
| NOUVEAU_BO_WR
);
567 BEGIN_NV04(push
, NV50_3D(SCREEN_SCISSOR_HORIZ
), 2);
568 PUSH_DATA (push
, width
<< 16);
569 PUSH_DATA (push
, height
<< 16);
570 BEGIN_NV04(push
, NV50_3D(SCISSOR_HORIZ(0)), 2);
571 PUSH_DATA (push
, 8192 << 16);
572 PUSH_DATA (push
, 8192 << 16);
573 nv50
->scissors_dirty
|= 1;
575 BEGIN_NV04(push
, NV50_3D(RT_CONTROL
), 1);
577 BEGIN_NV04(push
, NV50_3D(RT_ADDRESS_HIGH(0)), 5);
578 PUSH_DATAh(push
, buf
->bo
->offset
+ buf
->offset
+ offset
);
579 PUSH_DATA (push
, buf
->bo
->offset
+ buf
->offset
+ offset
);
580 PUSH_DATA (push
, nv50_format_table
[dst_fmt
].rt
);
583 BEGIN_NV04(push
, NV50_3D(RT_HORIZ(0)), 2);
584 PUSH_DATA (push
, NV50_3D_RT_HORIZ_LINEAR
| (width
* data_size
));
585 PUSH_DATA (push
, height
);
586 BEGIN_NV04(push
, NV50_3D(ZETA_ENABLE
), 1);
589 /* NOTE: only works with D3D clear flag (5097/0x143c bit 4) */
591 BEGIN_NV04(push
, NV50_3D(VIEWPORT_HORIZ(0)), 2);
592 PUSH_DATA (push
, (width
<< 16));
593 PUSH_DATA (push
, (height
<< 16));
595 BEGIN_NI04(push
, NV50_3D(CLEAR_BUFFERS
), 1);
596 PUSH_DATA (push
, 0x3c);
598 if (width
* height
!= elements
) {
599 offset
+= width
* height
* data_size
;
600 width
= elements
- width
* height
;
602 BEGIN_NV04(push
, NV50_3D(RT_ADDRESS_HIGH(0)), 2);
603 PUSH_DATAh(push
, buf
->bo
->offset
+ buf
->offset
+ offset
);
604 PUSH_DATA (push
, buf
->bo
->offset
+ buf
->offset
+ offset
);
605 BEGIN_NV04(push
, NV50_3D(RT_HORIZ(0)), 2);
606 PUSH_DATA (push
, NV50_3D_RT_HORIZ_LINEAR
| (width
* data_size
));
607 PUSH_DATA (push
, height
);
608 BEGIN_NI04(push
, NV50_3D(CLEAR_BUFFERS
), 1);
609 PUSH_DATA (push
, 0x3c);
612 nouveau_fence_ref(nv50
->screen
->base
.fence
.current
, &buf
->fence
);
613 nouveau_fence_ref(nv50
->screen
->base
.fence
.current
, &buf
->fence_wr
);
615 nv50
->dirty
|= NV50_NEW_FRAMEBUFFER
| NV50_NEW_SCISSOR
;
618 /* =============================== BLIT CODE ===================================
623 struct nv50_program
*fp
[NV50_BLIT_MAX_TEXTURE_TYPES
][NV50_BLIT_MODES
];
624 struct nv50_program vp
;
626 struct nv50_tsc_entry sampler
[2]; /* nearest, bilinear */
633 struct nv50_context
*nv50
;
634 struct nv50_program
*fp
;
638 uint8_t render_condition_enable
;
639 enum pipe_texture_target target
;
641 struct pipe_framebuffer_state fb
;
642 struct nv50_rasterizer_stateobj
*rast
;
643 struct nv50_program
*vp
;
644 struct nv50_program
*gp
;
645 struct nv50_program
*fp
;
646 unsigned num_textures
[3];
647 unsigned num_samplers
[3];
648 struct pipe_sampler_view
*texture
[2];
649 struct nv50_tsc_entry
*sampler
[2];
650 unsigned min_samples
;
653 struct nv50_rasterizer_stateobj rast
;
657 nv50_blitter_make_vp(struct nv50_blitter
*blit
)
659 static const uint32_t code
[] =
661 0x10000001, 0x0423c788, /* mov b32 o[0x00] s[0x00] */ /* HPOS.x */
662 0x10000205, 0x0423c788, /* mov b32 o[0x04] s[0x04] */ /* HPOS.y */
663 0x10000409, 0x0423c788, /* mov b32 o[0x08] s[0x08] */ /* TEXC.x */
664 0x1000060d, 0x0423c788, /* mov b32 o[0x0c] s[0x0c] */ /* TEXC.y */
665 0x10000811, 0x0423c789, /* mov b32 o[0x10] s[0x10] */ /* TEXC.z */
668 blit
->vp
.type
= PIPE_SHADER_VERTEX
;
669 blit
->vp
.translated
= true;
670 blit
->vp
.code
= (uint32_t *)code
; /* const_cast */
671 blit
->vp
.code_size
= sizeof(code
);
672 blit
->vp
.max_gpr
= 4;
673 blit
->vp
.max_out
= 5;
675 blit
->vp
.out
[0].mask
= 0x3;
676 blit
->vp
.out
[0].sn
= TGSI_SEMANTIC_POSITION
;
677 blit
->vp
.out
[1].hw
= 2;
678 blit
->vp
.out
[1].mask
= 0x7;
679 blit
->vp
.out
[1].sn
= TGSI_SEMANTIC_GENERIC
;
680 blit
->vp
.out
[1].si
= 0;
681 blit
->vp
.vp
.attrs
[0] = 0x73;
682 blit
->vp
.vp
.psiz
= 0x40;
683 blit
->vp
.vp
.edgeflag
= 0x40;
687 nv50_blitter_make_fp(struct pipe_context
*pipe
,
689 enum pipe_texture_target ptarg
)
691 struct ureg_program
*ureg
;
694 struct ureg_dst data
;
696 const unsigned target
= nv50_blit_get_tgsi_texture_target(ptarg
);
698 bool tex_rgbaz
= false;
700 bool cvt_un8
= false;
702 if (mode
!= NV50_BLIT_MODE_PASS
&&
703 mode
!= NV50_BLIT_MODE_Z24X8
&&
704 mode
!= NV50_BLIT_MODE_X8Z24
)
707 if (mode
!= NV50_BLIT_MODE_X24S8
&&
708 mode
!= NV50_BLIT_MODE_S8X24
&&
709 mode
!= NV50_BLIT_MODE_XS
)
712 if (mode
!= NV50_BLIT_MODE_PASS
&&
713 mode
!= NV50_BLIT_MODE_ZS
&&
714 mode
!= NV50_BLIT_MODE_XS
)
717 ureg
= ureg_create(TGSI_PROCESSOR_FRAGMENT
);
721 out
= ureg_DECL_output(ureg
, TGSI_SEMANTIC_COLOR
, 0);
722 tc
= ureg_DECL_fs_input(
723 ureg
, TGSI_SEMANTIC_GENERIC
, 0, TGSI_INTERPOLATE_LINEAR
);
725 if (ptarg
== PIPE_TEXTURE_1D_ARRAY
) {
726 /* Adjust coordinates. Depth is in z, but TEX expects it to be in y. */
727 tc
= ureg_swizzle(tc
, TGSI_SWIZZLE_X
, TGSI_SWIZZLE_Z
,
728 TGSI_SWIZZLE_Z
, TGSI_SWIZZLE_Z
);
731 data
= ureg_DECL_temporary(ureg
);
734 ureg_TEX(ureg
, ureg_writemask(data
, TGSI_WRITEMASK_X
),
735 target
, tc
, ureg_DECL_sampler(ureg
, 1));
736 ureg_MOV(ureg
, ureg_writemask(data
, TGSI_WRITEMASK_Y
),
737 ureg_scalar(ureg_src(data
), TGSI_SWIZZLE_X
));
740 const unsigned mask
= (mode
== NV50_BLIT_MODE_PASS
) ?
741 TGSI_WRITEMASK_XYZW
: TGSI_WRITEMASK_X
;
742 ureg_TEX(ureg
, ureg_writemask(data
, mask
),
743 target
, tc
, ureg_DECL_sampler(ureg
, 0));
747 struct ureg_src mask
;
748 struct ureg_src scale
;
749 struct ureg_dst outz
;
750 struct ureg_dst outs
;
751 struct ureg_dst zdst3
= ureg_writemask(data
, TGSI_WRITEMASK_XYZ
);
752 struct ureg_dst zdst
= ureg_writemask(data
, TGSI_WRITEMASK_X
);
753 struct ureg_dst sdst
= ureg_writemask(data
, TGSI_WRITEMASK_Y
);
754 struct ureg_src zsrc3
= ureg_src(data
);
755 struct ureg_src zsrc
= ureg_scalar(zsrc3
, TGSI_SWIZZLE_X
);
756 struct ureg_src ssrc
= ureg_scalar(zsrc3
, TGSI_SWIZZLE_Y
);
757 struct ureg_src zshuf
;
759 mask
= ureg_imm3u(ureg
, 0x0000ff, 0x00ff00, 0xff0000);
760 scale
= ureg_imm4f(ureg
,
761 1.0f
/ 0x0000ff, 1.0f
/ 0x00ff00, 1.0f
/ 0xff0000,
764 if (mode
== NV50_BLIT_MODE_Z24S8
||
765 mode
== NV50_BLIT_MODE_X24S8
||
766 mode
== NV50_BLIT_MODE_Z24X8
) {
767 outz
= ureg_writemask(out
, TGSI_WRITEMASK_XYZ
);
768 outs
= ureg_writemask(out
, TGSI_WRITEMASK_W
);
769 zshuf
= ureg_src(data
);
771 outz
= ureg_writemask(out
, TGSI_WRITEMASK_YZW
);
772 outs
= ureg_writemask(out
, TGSI_WRITEMASK_X
);
773 zshuf
= ureg_swizzle(zsrc3
, TGSI_SWIZZLE_W
,
774 TGSI_SWIZZLE_X
, TGSI_SWIZZLE_Y
, TGSI_SWIZZLE_Z
);
778 ureg_I2F(ureg
, sdst
, ssrc
);
779 ureg_MUL(ureg
, outs
, ssrc
, ureg_scalar(scale
, TGSI_SWIZZLE_X
));
783 ureg_MUL(ureg
, zdst
, zsrc
, ureg_scalar(scale
, TGSI_SWIZZLE_W
));
784 ureg_F2I(ureg
, zdst
, zsrc
);
785 ureg_AND(ureg
, zdst3
, zsrc
, mask
);
786 ureg_I2F(ureg
, zdst3
, zsrc3
);
787 ureg_MUL(ureg
, zdst3
, zsrc3
, scale
);
788 ureg_MOV(ureg
, outz
, zshuf
);
791 unsigned mask
= TGSI_WRITEMASK_XYZW
;
793 if (mode
!= NV50_BLIT_MODE_PASS
) {
794 mask
&= ~TGSI_WRITEMASK_ZW
;
796 mask
= TGSI_WRITEMASK_X
;
798 mask
= TGSI_WRITEMASK_Y
;
800 ureg_MOV(ureg
, ureg_writemask(out
, mask
), ureg_src(data
));
804 return ureg_create_shader_and_destroy(ureg
, pipe
);
808 nv50_blitter_make_sampler(struct nv50_blitter
*blit
)
810 /* clamp to edge, min/max lod = 0, nearest filtering */
812 blit
->sampler
[0].id
= -1;
814 blit
->sampler
[0].tsc
[0] = NV50_TSC_0_SRGB_CONVERSION_ALLOWED
|
815 (NV50_TSC_WRAP_CLAMP_TO_EDGE
<< NV50_TSC_0_WRAPS__SHIFT
) |
816 (NV50_TSC_WRAP_CLAMP_TO_EDGE
<< NV50_TSC_0_WRAPT__SHIFT
) |
817 (NV50_TSC_WRAP_CLAMP_TO_EDGE
<< NV50_TSC_0_WRAPR__SHIFT
);
818 blit
->sampler
[0].tsc
[1] =
819 NV50_TSC_1_MAGF_NEAREST
| NV50_TSC_1_MINF_NEAREST
| NV50_TSC_1_MIPF_NONE
;
821 /* clamp to edge, min/max lod = 0, bilinear filtering */
823 blit
->sampler
[1].id
= -1;
825 blit
->sampler
[1].tsc
[0] = blit
->sampler
[0].tsc
[0];
826 blit
->sampler
[1].tsc
[1] =
827 NV50_TSC_1_MAGF_LINEAR
| NV50_TSC_1_MINF_LINEAR
| NV50_TSC_1_MIPF_NONE
;
831 nv50_blit_select_mode(const struct pipe_blit_info
*info
)
833 const unsigned mask
= info
->mask
;
835 switch (info
->dst
.resource
->format
) {
836 case PIPE_FORMAT_Z24_UNORM_S8_UINT
:
837 case PIPE_FORMAT_Z24X8_UNORM
:
838 case PIPE_FORMAT_X24S8_UINT
:
839 switch (mask
& PIPE_MASK_ZS
) {
840 case PIPE_MASK_ZS
: return NV50_BLIT_MODE_Z24S8
;
841 case PIPE_MASK_Z
: return NV50_BLIT_MODE_Z24X8
;
843 return NV50_BLIT_MODE_X24S8
;
845 case PIPE_FORMAT_S8_UINT_Z24_UNORM
:
846 case PIPE_FORMAT_X8Z24_UNORM
:
847 case PIPE_FORMAT_S8X24_UINT
:
848 switch (mask
& PIPE_MASK_ZS
) {
849 case PIPE_MASK_ZS
: return NV50_BLIT_MODE_S8Z24
;
850 case PIPE_MASK_Z
: return NV50_BLIT_MODE_X8Z24
;
852 return NV50_BLIT_MODE_S8X24
;
854 case PIPE_FORMAT_Z32_FLOAT
:
855 case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT
:
856 case PIPE_FORMAT_X32_S8X24_UINT
:
857 switch (mask
& PIPE_MASK_ZS
) {
858 case PIPE_MASK_ZS
: return NV50_BLIT_MODE_ZS
;
859 case PIPE_MASK_Z
: return NV50_BLIT_MODE_PASS
;
861 return NV50_BLIT_MODE_XS
;
864 return NV50_BLIT_MODE_PASS
;
869 nv50_blit_select_fp(struct nv50_blitctx
*ctx
, const struct pipe_blit_info
*info
)
871 struct nv50_blitter
*blitter
= ctx
->nv50
->screen
->blitter
;
873 const enum pipe_texture_target ptarg
=
874 nv50_blit_reinterpret_pipe_texture_target(info
->src
.resource
->target
);
876 const unsigned targ
= nv50_blit_texture_type(ptarg
);
877 const unsigned mode
= ctx
->mode
;
879 if (!blitter
->fp
[targ
][mode
]) {
880 pipe_mutex_lock(blitter
->mutex
);
881 if (!blitter
->fp
[targ
][mode
])
882 blitter
->fp
[targ
][mode
] =
883 nv50_blitter_make_fp(&ctx
->nv50
->base
.pipe
, mode
, ptarg
);
884 pipe_mutex_unlock(blitter
->mutex
);
886 ctx
->fp
= blitter
->fp
[targ
][mode
];
890 nv50_blit_set_dst(struct nv50_blitctx
*ctx
,
891 struct pipe_resource
*res
, unsigned level
, unsigned layer
,
892 enum pipe_format format
)
894 struct nv50_context
*nv50
= ctx
->nv50
;
895 struct pipe_context
*pipe
= &nv50
->base
.pipe
;
896 struct pipe_surface templ
;
898 if (util_format_is_depth_or_stencil(format
))
899 templ
.format
= nv50_blit_zeta_to_colour_format(format
);
901 templ
.format
= format
;
903 templ
.u
.tex
.level
= level
;
904 templ
.u
.tex
.first_layer
= templ
.u
.tex
.last_layer
= layer
;
907 templ
.u
.tex
.first_layer
= 0;
908 templ
.u
.tex
.last_layer
=
909 (res
->target
== PIPE_TEXTURE_3D
? res
->depth0
: res
->array_size
) - 1;
912 nv50
->framebuffer
.cbufs
[0] = nv50_miptree_surface_new(pipe
, res
, &templ
);
913 nv50
->framebuffer
.nr_cbufs
= 1;
914 nv50
->framebuffer
.zsbuf
= NULL
;
915 nv50
->framebuffer
.width
= nv50
->framebuffer
.cbufs
[0]->width
;
916 nv50
->framebuffer
.height
= nv50
->framebuffer
.cbufs
[0]->height
;
920 nv50_blit_set_src(struct nv50_blitctx
*blit
,
921 struct pipe_resource
*res
, unsigned level
, unsigned layer
,
922 enum pipe_format format
, const uint8_t filter
)
924 struct nv50_context
*nv50
= blit
->nv50
;
925 struct pipe_context
*pipe
= &nv50
->base
.pipe
;
926 struct pipe_sampler_view templ
;
928 enum pipe_texture_target target
;
930 target
= nv50_blit_reinterpret_pipe_texture_target(res
->target
);
932 templ
.format
= format
;
933 templ
.u
.tex
.first_level
= templ
.u
.tex
.last_level
= level
;
934 templ
.u
.tex
.first_layer
= templ
.u
.tex
.last_layer
= layer
;
935 templ
.swizzle_r
= PIPE_SWIZZLE_RED
;
936 templ
.swizzle_g
= PIPE_SWIZZLE_GREEN
;
937 templ
.swizzle_b
= PIPE_SWIZZLE_BLUE
;
938 templ
.swizzle_a
= PIPE_SWIZZLE_ALPHA
;
941 templ
.u
.tex
.first_layer
= 0;
942 templ
.u
.tex
.last_layer
=
943 (res
->target
== PIPE_TEXTURE_3D
? res
->depth0
: res
->array_size
) - 1;
946 flags
= res
->last_level
? 0 : NV50_TEXVIEW_SCALED_COORDS
;
947 flags
|= NV50_TEXVIEW_ACCESS_RESOLVE
;
948 if (filter
&& res
->nr_samples
== 8)
949 flags
|= NV50_TEXVIEW_FILTER_MSAA8
;
951 nv50
->textures
[2][0] = nv50_create_texture_view(
952 pipe
, res
, &templ
, flags
, target
);
953 nv50
->textures
[2][1] = NULL
;
955 nv50
->num_textures
[0] = nv50
->num_textures
[1] = 0;
956 nv50
->num_textures
[2] = 1;
958 templ
.format
= nv50_zs_to_s_format(format
);
959 if (templ
.format
!= res
->format
) {
960 nv50
->textures
[2][1] = nv50_create_texture_view(
961 pipe
, res
, &templ
, flags
, target
);
962 nv50
->num_textures
[2] = 2;
967 nv50_blitctx_prepare_state(struct nv50_blitctx
*blit
)
969 struct nouveau_pushbuf
*push
= blit
->nv50
->base
.pushbuf
;
971 if (blit
->nv50
->cond_query
&& !blit
->render_condition_enable
) {
972 BEGIN_NV04(push
, NV50_3D(COND_MODE
), 1);
973 PUSH_DATA (push
, NV50_3D_COND_MODE_ALWAYS
);
977 BEGIN_NV04(push
, NV50_3D(COLOR_MASK(0)), 1);
978 PUSH_DATA (push
, blit
->color_mask
);
979 BEGIN_NV04(push
, NV50_3D(BLEND_ENABLE(0)), 1);
981 BEGIN_NV04(push
, NV50_3D(LOGIC_OP_ENABLE
), 1);
984 /* rasterizer state */
985 #ifndef NV50_SCISSORS_CLIPPING
986 BEGIN_NV04(push
, NV50_3D(SCISSOR_ENABLE(0)), 1);
989 BEGIN_NV04(push
, NV50_3D(VERTEX_TWO_SIDE_ENABLE
), 1);
991 BEGIN_NV04(push
, NV50_3D(FRAG_COLOR_CLAMP_EN
), 1);
993 BEGIN_NV04(push
, NV50_3D(MULTISAMPLE_ENABLE
), 1);
995 BEGIN_NV04(push
, NV50_3D(MSAA_MASK(0)), 4);
996 PUSH_DATA (push
, 0xffff);
997 PUSH_DATA (push
, 0xffff);
998 PUSH_DATA (push
, 0xffff);
999 PUSH_DATA (push
, 0xffff);
1000 BEGIN_NV04(push
, NV50_3D(POLYGON_MODE_FRONT
), 3);
1001 PUSH_DATA (push
, NV50_3D_POLYGON_MODE_FRONT_FILL
);
1002 PUSH_DATA (push
, NV50_3D_POLYGON_MODE_BACK_FILL
);
1003 PUSH_DATA (push
, 0);
1004 BEGIN_NV04(push
, NV50_3D(CULL_FACE_ENABLE
), 1);
1005 PUSH_DATA (push
, 0);
1006 BEGIN_NV04(push
, NV50_3D(POLYGON_STIPPLE_ENABLE
), 1);
1007 PUSH_DATA (push
, 0);
1008 BEGIN_NV04(push
, NV50_3D(POLYGON_OFFSET_FILL_ENABLE
), 1);
1009 PUSH_DATA (push
, 0);
1012 BEGIN_NV04(push
, NV50_3D(DEPTH_TEST_ENABLE
), 1);
1013 PUSH_DATA (push
, 0);
1014 BEGIN_NV04(push
, NV50_3D(DEPTH_BOUNDS_EN
), 1);
1015 PUSH_DATA (push
, 0);
1016 BEGIN_NV04(push
, NV50_3D(STENCIL_ENABLE
), 1);
1017 PUSH_DATA (push
, 0);
1018 BEGIN_NV04(push
, NV50_3D(ALPHA_TEST_ENABLE
), 1);
1019 PUSH_DATA (push
, 0);
1023 nv50_blitctx_pre_blit(struct nv50_blitctx
*ctx
)
1025 struct nv50_context
*nv50
= ctx
->nv50
;
1026 struct nv50_blitter
*blitter
= nv50
->screen
->blitter
;
1029 ctx
->saved
.fb
.width
= nv50
->framebuffer
.width
;
1030 ctx
->saved
.fb
.height
= nv50
->framebuffer
.height
;
1031 ctx
->saved
.fb
.nr_cbufs
= nv50
->framebuffer
.nr_cbufs
;
1032 ctx
->saved
.fb
.cbufs
[0] = nv50
->framebuffer
.cbufs
[0];
1033 ctx
->saved
.fb
.zsbuf
= nv50
->framebuffer
.zsbuf
;
1035 ctx
->saved
.rast
= nv50
->rast
;
1037 ctx
->saved
.vp
= nv50
->vertprog
;
1038 ctx
->saved
.gp
= nv50
->gmtyprog
;
1039 ctx
->saved
.fp
= nv50
->fragprog
;
1041 ctx
->saved
.min_samples
= nv50
->min_samples
;
1043 nv50
->rast
= &ctx
->rast
;
1045 nv50
->vertprog
= &blitter
->vp
;
1046 nv50
->gmtyprog
= NULL
;
1047 nv50
->fragprog
= ctx
->fp
;
1049 for (s
= 0; s
< 3; ++s
) {
1050 ctx
->saved
.num_textures
[s
] = nv50
->num_textures
[s
];
1051 ctx
->saved
.num_samplers
[s
] = nv50
->num_samplers
[s
];
1053 ctx
->saved
.texture
[0] = nv50
->textures
[2][0];
1054 ctx
->saved
.texture
[1] = nv50
->textures
[2][1];
1055 ctx
->saved
.sampler
[0] = nv50
->samplers
[2][0];
1056 ctx
->saved
.sampler
[1] = nv50
->samplers
[2][1];
1058 nv50
->samplers
[2][0] = &blitter
->sampler
[ctx
->filter
];
1059 nv50
->samplers
[2][1] = &blitter
->sampler
[ctx
->filter
];
1061 nv50
->num_samplers
[0] = nv50
->num_samplers
[1] = 0;
1062 nv50
->num_samplers
[2] = 2;
1064 nv50
->min_samples
= 1;
1066 ctx
->saved
.dirty
= nv50
->dirty
;
1068 nouveau_bufctx_reset(nv50
->bufctx_3d
, NV50_BIND_FB
);
1069 nouveau_bufctx_reset(nv50
->bufctx_3d
, NV50_BIND_TEXTURES
);
1072 NV50_NEW_FRAMEBUFFER
| NV50_NEW_MIN_SAMPLES
|
1073 NV50_NEW_VERTPROG
| NV50_NEW_FRAGPROG
| NV50_NEW_GMTYPROG
|
1074 NV50_NEW_TEXTURES
| NV50_NEW_SAMPLERS
;
1078 nv50_blitctx_post_blit(struct nv50_blitctx
*blit
)
1080 struct nv50_context
*nv50
= blit
->nv50
;
1083 pipe_surface_reference(&nv50
->framebuffer
.cbufs
[0], NULL
);
1085 nv50
->framebuffer
.width
= blit
->saved
.fb
.width
;
1086 nv50
->framebuffer
.height
= blit
->saved
.fb
.height
;
1087 nv50
->framebuffer
.nr_cbufs
= blit
->saved
.fb
.nr_cbufs
;
1088 nv50
->framebuffer
.cbufs
[0] = blit
->saved
.fb
.cbufs
[0];
1089 nv50
->framebuffer
.zsbuf
= blit
->saved
.fb
.zsbuf
;
1091 nv50
->rast
= blit
->saved
.rast
;
1093 nv50
->vertprog
= blit
->saved
.vp
;
1094 nv50
->gmtyprog
= blit
->saved
.gp
;
1095 nv50
->fragprog
= blit
->saved
.fp
;
1097 nv50
->min_samples
= blit
->saved
.min_samples
;
1099 pipe_sampler_view_reference(&nv50
->textures
[2][0], NULL
);
1100 pipe_sampler_view_reference(&nv50
->textures
[2][1], NULL
);
1102 for (s
= 0; s
< 3; ++s
) {
1103 nv50
->num_textures
[s
] = blit
->saved
.num_textures
[s
];
1104 nv50
->num_samplers
[s
] = blit
->saved
.num_samplers
[s
];
1106 nv50
->textures
[2][0] = blit
->saved
.texture
[0];
1107 nv50
->textures
[2][1] = blit
->saved
.texture
[1];
1108 nv50
->samplers
[2][0] = blit
->saved
.sampler
[0];
1109 nv50
->samplers
[2][1] = blit
->saved
.sampler
[1];
1111 if (nv50
->cond_query
&& !blit
->render_condition_enable
)
1112 nv50
->base
.pipe
.render_condition(&nv50
->base
.pipe
, nv50
->cond_query
,
1113 nv50
->cond_cond
, nv50
->cond_mode
);
1115 nouveau_bufctx_reset(nv50
->bufctx_3d
, NV50_BIND_FB
);
1116 nouveau_bufctx_reset(nv50
->bufctx_3d
, NV50_BIND_TEXTURES
);
1118 nv50
->dirty
= blit
->saved
.dirty
|
1119 (NV50_NEW_FRAMEBUFFER
| NV50_NEW_SCISSOR
| NV50_NEW_SAMPLE_MASK
|
1120 NV50_NEW_RASTERIZER
| NV50_NEW_ZSA
| NV50_NEW_BLEND
|
1121 NV50_NEW_TEXTURES
| NV50_NEW_SAMPLERS
|
1122 NV50_NEW_VERTPROG
| NV50_NEW_GMTYPROG
| NV50_NEW_FRAGPROG
);
1123 nv50
->scissors_dirty
|= 1;
1125 nv50
->base
.pipe
.set_min_samples(&nv50
->base
.pipe
, blit
->saved
.min_samples
);
1130 nv50_blit_3d(struct nv50_context
*nv50
, const struct pipe_blit_info
*info
)
1132 struct nv50_blitctx
*blit
= nv50
->blit
;
1133 struct nouveau_pushbuf
*push
= nv50
->base
.pushbuf
;
1134 struct pipe_resource
*src
= info
->src
.resource
;
1135 struct pipe_resource
*dst
= info
->dst
.resource
;
1136 int32_t minx
, maxx
, miny
, maxy
;
1138 float x0
, x1
, y0
, y1
, z
;
1140 float x_range
, y_range
;
1143 blit
->mode
= nv50_blit_select_mode(info
);
1144 blit
->color_mask
= nv50_blit_derive_color_mask(info
);
1145 blit
->filter
= nv50_blit_get_filter(info
);
1146 blit
->render_condition_enable
= info
->render_condition_enable
;
1148 nv50_blit_select_fp(blit
, info
);
1149 nv50_blitctx_pre_blit(blit
);
1151 nv50_blit_set_dst(blit
, dst
, info
->dst
.level
, -1, info
->dst
.format
);
1152 nv50_blit_set_src(blit
, src
, info
->src
.level
, -1, info
->src
.format
,
1155 nv50_blitctx_prepare_state(blit
);
1157 nv50_state_validate(nv50
, ~0, 36);
1159 x_range
= (float)info
->src
.box
.width
/ (float)info
->dst
.box
.width
;
1160 y_range
= (float)info
->src
.box
.height
/ (float)info
->dst
.box
.height
;
1162 tri_x
= 16384 << nv50_miptree(dst
)->ms_x
;
1163 tri_y
= 16384 << nv50_miptree(dst
)->ms_y
;
1165 x0
= (float)info
->src
.box
.x
- x_range
* (float)info
->dst
.box
.x
;
1166 y0
= (float)info
->src
.box
.y
- y_range
* (float)info
->dst
.box
.y
;
1168 x1
= x0
+ tri_x
* x_range
;
1169 y1
= y0
+ tri_y
* y_range
;
1171 x0
*= (float)(1 << nv50_miptree(src
)->ms_x
);
1172 x1
*= (float)(1 << nv50_miptree(src
)->ms_x
);
1173 y0
*= (float)(1 << nv50_miptree(src
)->ms_y
);
1174 y1
*= (float)(1 << nv50_miptree(src
)->ms_y
);
1176 /* XXX: multiply by 6 for cube arrays ? */
1177 dz
= (float)info
->src
.box
.depth
/ (float)info
->dst
.box
.depth
;
1178 z
= (float)info
->src
.box
.z
;
1179 if (nv50_miptree(src
)->layout_3d
)
1182 if (src
->last_level
> 0) {
1183 /* If there are mip maps, GPU always assumes normalized coordinates. */
1184 const unsigned l
= info
->src
.level
;
1185 const float fh
= u_minify(src
->width0
<< nv50_miptree(src
)->ms_x
, l
);
1186 const float fv
= u_minify(src
->height0
<< nv50_miptree(src
)->ms_y
, l
);
1191 if (nv50_miptree(src
)->layout_3d
) {
1192 z
/= u_minify(src
->depth0
, l
);
1193 dz
/= u_minify(src
->depth0
, l
);
1197 BEGIN_NV04(push
, NV50_3D(VIEWPORT_TRANSFORM_EN
), 1);
1198 PUSH_DATA (push
, 0);
1199 BEGIN_NV04(push
, NV50_3D(VIEW_VOLUME_CLIP_CTRL
), 1);
1200 PUSH_DATA (push
, 0x1);
1202 /* Draw a large triangle in screen coordinates covering the whole
1203 * render target, with scissors defining the destination region.
1204 * The vertex is supplied with non-normalized texture coordinates
1205 * arranged in a way to yield the desired offset and scale.
1208 minx
= info
->dst
.box
.x
;
1209 maxx
= info
->dst
.box
.x
+ info
->dst
.box
.width
;
1210 miny
= info
->dst
.box
.y
;
1211 maxy
= info
->dst
.box
.y
+ info
->dst
.box
.height
;
1212 if (info
->scissor_enable
) {
1213 minx
= MAX2(minx
, info
->scissor
.minx
);
1214 maxx
= MIN2(maxx
, info
->scissor
.maxx
);
1215 miny
= MAX2(miny
, info
->scissor
.miny
);
1216 maxy
= MIN2(maxy
, info
->scissor
.maxy
);
1218 BEGIN_NV04(push
, NV50_3D(SCISSOR_HORIZ(0)), 2);
1219 PUSH_DATA (push
, (maxx
<< 16) | minx
);
1220 PUSH_DATA (push
, (maxy
<< 16) | miny
);
1222 for (i
= 0; i
< info
->dst
.box
.depth
; ++i
, z
+= dz
) {
1223 if (info
->dst
.box
.z
+ i
) {
1224 BEGIN_NV04(push
, NV50_3D(LAYER
), 1);
1225 PUSH_DATA (push
, info
->dst
.box
.z
+ i
);
1227 PUSH_SPACE(push
, 32);
1228 BEGIN_NV04(push
, NV50_3D(VERTEX_BEGIN_GL
), 1);
1229 PUSH_DATA (push
, NV50_3D_VERTEX_BEGIN_GL_PRIMITIVE_TRIANGLES
);
1230 BEGIN_NV04(push
, NV50_3D(VTX_ATTR_3F_X(1)), 3);
1231 PUSH_DATAf(push
, x0
);
1232 PUSH_DATAf(push
, y0
);
1233 PUSH_DATAf(push
, z
);
1234 BEGIN_NV04(push
, NV50_3D(VTX_ATTR_2F_X(0)), 2);
1235 PUSH_DATAf(push
, 0.0f
);
1236 PUSH_DATAf(push
, 0.0f
);
1237 BEGIN_NV04(push
, NV50_3D(VTX_ATTR_3F_X(1)), 3);
1238 PUSH_DATAf(push
, x1
);
1239 PUSH_DATAf(push
, y0
);
1240 PUSH_DATAf(push
, z
);
1241 BEGIN_NV04(push
, NV50_3D(VTX_ATTR_2F_X(0)), 2);
1242 PUSH_DATAf(push
, tri_x
);
1243 PUSH_DATAf(push
, 0.0f
);
1244 BEGIN_NV04(push
, NV50_3D(VTX_ATTR_3F_X(1)), 3);
1245 PUSH_DATAf(push
, x0
);
1246 PUSH_DATAf(push
, y1
);
1247 PUSH_DATAf(push
, z
);
1248 BEGIN_NV04(push
, NV50_3D(VTX_ATTR_2F_X(0)), 2);
1249 PUSH_DATAf(push
, 0.0f
);
1250 PUSH_DATAf(push
, tri_y
);
1251 BEGIN_NV04(push
, NV50_3D(VERTEX_END_GL
), 1);
1252 PUSH_DATA (push
, 0);
1254 if (info
->dst
.box
.z
+ info
->dst
.box
.depth
- 1) {
1255 BEGIN_NV04(push
, NV50_3D(LAYER
), 1);
1256 PUSH_DATA (push
, 0);
1259 /* re-enable normally constant state */
1261 BEGIN_NV04(push
, NV50_3D(VIEWPORT_TRANSFORM_EN
), 1);
1262 PUSH_DATA (push
, 1);
1264 nv50_blitctx_post_blit(blit
);
1268 nv50_blit_eng2d(struct nv50_context
*nv50
, const struct pipe_blit_info
*info
)
1270 struct nouveau_pushbuf
*push
= nv50
->base
.pushbuf
;
1271 struct nv50_miptree
*dst
= nv50_miptree(info
->dst
.resource
);
1272 struct nv50_miptree
*src
= nv50_miptree(info
->src
.resource
);
1273 const int32_t srcx_adj
= info
->src
.box
.width
< 0 ? -1 : 0;
1274 const int32_t srcy_adj
= info
->src
.box
.height
< 0 ? -1 : 0;
1275 const int32_t dz
= info
->dst
.box
.z
;
1276 const int32_t sz
= info
->src
.box
.z
;
1277 uint32_t dstw
, dsth
;
1280 int64_t du_dx
, dv_dy
;
1283 uint32_t mask
= nv50_blit_eng2d_get_mask(info
);
1286 mode
= nv50_blit_get_filter(info
) ?
1287 NV50_2D_BLIT_CONTROL_FILTER_BILINEAR
:
1288 NV50_2D_BLIT_CONTROL_FILTER_POINT_SAMPLE
;
1289 mode
|= (src
->base
.base
.nr_samples
> dst
->base
.base
.nr_samples
) ?
1290 NV50_2D_BLIT_CONTROL_ORIGIN_CORNER
: NV50_2D_BLIT_CONTROL_ORIGIN_CENTER
;
1292 du_dx
= ((int64_t)info
->src
.box
.width
<< 32) / info
->dst
.box
.width
;
1293 dv_dy
= ((int64_t)info
->src
.box
.height
<< 32) / info
->dst
.box
.height
;
1295 b
= info
->dst
.format
== info
->src
.format
;
1296 nv50_2d_texture_set(push
, 1, dst
, info
->dst
.level
, dz
, info
->dst
.format
, b
);
1297 nv50_2d_texture_set(push
, 0, src
, info
->src
.level
, sz
, info
->src
.format
, b
);
1299 if (info
->scissor_enable
) {
1300 BEGIN_NV04(push
, NV50_2D(CLIP_X
), 5);
1301 PUSH_DATA (push
, info
->scissor
.minx
<< dst
->ms_x
);
1302 PUSH_DATA (push
, info
->scissor
.miny
<< dst
->ms_y
);
1303 PUSH_DATA (push
, (info
->scissor
.maxx
- info
->scissor
.minx
) << dst
->ms_x
);
1304 PUSH_DATA (push
, (info
->scissor
.maxy
- info
->scissor
.miny
) << dst
->ms_y
);
1305 PUSH_DATA (push
, 1); /* enable */
1308 if (nv50
->cond_query
&& info
->render_condition_enable
) {
1309 BEGIN_NV04(push
, NV50_2D(COND_MODE
), 1);
1310 PUSH_DATA (push
, nv50
->cond_condmode
);
1313 if (mask
!= 0xffffffff) {
1314 BEGIN_NV04(push
, NV50_2D(ROP
), 1);
1315 PUSH_DATA (push
, 0xca); /* DPSDxax */
1316 BEGIN_NV04(push
, NV50_2D(PATTERN_COLOR_FORMAT
), 1);
1317 PUSH_DATA (push
, NV50_2D_PATTERN_COLOR_FORMAT_A8R8G8B8
);
1318 BEGIN_NV04(push
, NV50_2D(PATTERN_BITMAP_COLOR(0)), 4);
1319 PUSH_DATA (push
, 0x00000000);
1320 PUSH_DATA (push
, mask
);
1321 PUSH_DATA (push
, 0xffffffff);
1322 PUSH_DATA (push
, 0xffffffff);
1323 BEGIN_NV04(push
, NV50_2D(OPERATION
), 1);
1324 PUSH_DATA (push
, NV50_2D_OPERATION_ROP
);
1326 if (info
->src
.format
!= info
->dst
.format
) {
1327 if (info
->src
.format
== PIPE_FORMAT_R8_UNORM
||
1328 info
->src
.format
== PIPE_FORMAT_R16_UNORM
||
1329 info
->src
.format
== PIPE_FORMAT_R16_FLOAT
||
1330 info
->src
.format
== PIPE_FORMAT_R32_FLOAT
) {
1331 mask
= 0xffff0000; /* also makes condition for OPERATION reset true */
1332 BEGIN_NV04(push
, NV50_2D(BETA4
), 2);
1333 PUSH_DATA (push
, mask
);
1334 PUSH_DATA (push
, NV50_2D_OPERATION_SRCCOPY_PREMULT
);
1338 if (src
->ms_x
> dst
->ms_x
|| src
->ms_y
> dst
->ms_y
) {
1339 /* ms_x is always >= ms_y */
1340 du_dx
<<= src
->ms_x
- dst
->ms_x
;
1341 dv_dy
<<= src
->ms_y
- dst
->ms_y
;
1343 du_dx
>>= dst
->ms_x
- src
->ms_x
;
1344 dv_dy
>>= dst
->ms_y
- src
->ms_y
;
1347 srcx
= (int64_t)(info
->src
.box
.x
+ srcx_adj
) << (src
->ms_x
+ 32);
1348 srcy
= (int64_t)(info
->src
.box
.y
+ srcy_adj
) << (src
->ms_y
+ 32);
1350 if (src
->base
.base
.nr_samples
> dst
->base
.base
.nr_samples
) {
1351 /* center src coorinates for proper MS resolve filtering */
1352 srcx
+= (int64_t)1 << (src
->ms_x
+ 31);
1353 srcy
+= (int64_t)1 << (src
->ms_y
+ 31);
1356 dstx
= info
->dst
.box
.x
<< dst
->ms_x
;
1357 dsty
= info
->dst
.box
.y
<< dst
->ms_y
;
1359 dstw
= info
->dst
.box
.width
<< dst
->ms_x
;
1360 dsth
= info
->dst
.box
.height
<< dst
->ms_y
;
1364 srcx
-= du_dx
* dstx
;
1369 srcy
-= dv_dy
* dsty
;
1373 BEGIN_NV04(push
, NV50_2D(BLIT_CONTROL
), 1);
1374 PUSH_DATA (push
, mode
);
1375 BEGIN_NV04(push
, NV50_2D(BLIT_DST_X
), 4);
1376 PUSH_DATA (push
, dstx
);
1377 PUSH_DATA (push
, dsty
);
1378 PUSH_DATA (push
, dstw
);
1379 PUSH_DATA (push
, dsth
);
1380 BEGIN_NV04(push
, NV50_2D(BLIT_DU_DX_FRACT
), 4);
1381 PUSH_DATA (push
, du_dx
);
1382 PUSH_DATA (push
, du_dx
>> 32);
1383 PUSH_DATA (push
, dv_dy
);
1384 PUSH_DATA (push
, dv_dy
>> 32);
1386 BCTX_REFN(nv50
->bufctx
, 2D
, &dst
->base
, WR
);
1387 BCTX_REFN(nv50
->bufctx
, 2D
, &src
->base
, RD
);
1388 nouveau_pushbuf_bufctx(nv50
->base
.pushbuf
, nv50
->bufctx
);
1389 if (nouveau_pushbuf_validate(nv50
->base
.pushbuf
))
1392 for (i
= 0; i
< info
->dst
.box
.depth
; ++i
) {
1394 /* no scaling in z-direction possible for eng2d blits */
1395 if (dst
->layout_3d
) {
1396 BEGIN_NV04(push
, NV50_2D(DST_LAYER
), 1);
1397 PUSH_DATA (push
, info
->dst
.box
.z
+ i
);
1399 const unsigned z
= info
->dst
.box
.z
+ i
;
1400 const uint64_t address
= dst
->base
.address
+
1401 dst
->level
[info
->dst
.level
].offset
+
1402 z
* dst
->layer_stride
;
1403 BEGIN_NV04(push
, NV50_2D(DST_ADDRESS_HIGH
), 2);
1404 PUSH_DATAh(push
, address
);
1405 PUSH_DATA (push
, address
);
1407 if (src
->layout_3d
) {
1408 /* not possible because of depth tiling */
1411 const unsigned z
= info
->src
.box
.z
+ i
;
1412 const uint64_t address
= src
->base
.address
+
1413 src
->level
[info
->src
.level
].offset
+
1414 z
* src
->layer_stride
;
1415 BEGIN_NV04(push
, NV50_2D(SRC_ADDRESS_HIGH
), 2);
1416 PUSH_DATAh(push
, address
);
1417 PUSH_DATA (push
, address
);
1419 BEGIN_NV04(push
, NV50_2D(BLIT_SRC_Y_INT
), 1); /* trigger */
1420 PUSH_DATA (push
, srcy
>> 32);
1422 BEGIN_NV04(push
, NV50_2D(BLIT_SRC_X_FRACT
), 4);
1423 PUSH_DATA (push
, srcx
);
1424 PUSH_DATA (push
, srcx
>> 32);
1425 PUSH_DATA (push
, srcy
);
1426 PUSH_DATA (push
, srcy
>> 32);
1429 nv50_bufctx_fence(nv50
->bufctx
, false);
1431 nouveau_bufctx_reset(nv50
->bufctx
, NV50_BIND_2D
);
1433 if (info
->scissor_enable
) {
1434 BEGIN_NV04(push
, NV50_2D(CLIP_ENABLE
), 1);
1435 PUSH_DATA (push
, 0);
1437 if (mask
!= 0xffffffff) {
1438 BEGIN_NV04(push
, NV50_2D(OPERATION
), 1);
1439 PUSH_DATA (push
, NV50_2D_OPERATION_SRCCOPY
);
1441 if (nv50
->cond_query
&& info
->render_condition_enable
) {
1442 BEGIN_NV04(push
, NV50_2D(COND_MODE
), 1);
1443 PUSH_DATA (push
, NV50_2D_COND_MODE_ALWAYS
);
1448 nv50_blit(struct pipe_context
*pipe
, const struct pipe_blit_info
*info
)
1450 struct nv50_context
*nv50
= nv50_context(pipe
);
1451 struct nouveau_pushbuf
*push
= nv50
->base
.pushbuf
;
1454 if (util_format_is_depth_or_stencil(info
->dst
.resource
->format
)) {
1455 if (!(info
->mask
& PIPE_MASK_ZS
))
1457 if (info
->dst
.resource
->format
== PIPE_FORMAT_Z32_FLOAT
||
1458 info
->dst
.resource
->format
== PIPE_FORMAT_Z32_FLOAT_S8X24_UINT
)
1460 if (info
->filter
!= PIPE_TEX_FILTER_NEAREST
)
1463 if (!(info
->mask
& PIPE_MASK_RGBA
))
1465 if (info
->mask
!= PIPE_MASK_RGBA
)
1469 if (nv50_miptree(info
->src
.resource
)->layout_3d
) {
1472 if (info
->src
.box
.depth
!= info
->dst
.box
.depth
) {
1474 debug_printf("blit: cannot filter array or cube textures in z direction");
1477 if (!eng3d
&& info
->dst
.format
!= info
->src
.format
) {
1478 if (!nv50_2d_dst_format_faithful(info
->dst
.format
) ||
1479 !nv50_2d_src_format_faithful(info
->src
.format
)) {
1482 if (!nv50_2d_src_format_faithful(info
->src
.format
)) {
1483 if (!util_format_is_luminance(info
->src
.format
)) {
1484 if (util_format_is_intensity(info
->src
.format
))
1487 if (!nv50_2d_dst_format_ops_supported(info
->dst
.format
))
1490 eng3d
= !nv50_2d_format_supported(info
->src
.format
);
1493 if (util_format_is_luminance_alpha(info
->src
.format
))
1497 if (info
->src
.resource
->nr_samples
== 8 &&
1498 info
->dst
.resource
->nr_samples
<= 1)
1501 /* FIXME: can't make this work with eng2d anymore */
1502 if ((info
->src
.resource
->nr_samples
| 1) !=
1503 (info
->dst
.resource
->nr_samples
| 1))
1506 /* FIXME: find correct src coordinate adjustments */
1507 if ((info
->src
.box
.width
!= info
->dst
.box
.width
&&
1508 info
->src
.box
.width
!= -info
->dst
.box
.width
) ||
1509 (info
->src
.box
.height
!= info
->dst
.box
.height
&&
1510 info
->src
.box
.height
!= -info
->dst
.box
.height
))
1513 if (nv50
->screen
->num_occlusion_queries_active
) {
1514 BEGIN_NV04(push
, NV50_3D(SAMPLECNT_ENABLE
), 1);
1515 PUSH_DATA (push
, 0);
1519 nv50_blit_eng2d(nv50
, info
);
1521 nv50_blit_3d(nv50
, info
);
1523 if (nv50
->screen
->num_occlusion_queries_active
) {
1524 BEGIN_NV04(push
, NV50_3D(SAMPLECNT_ENABLE
), 1);
1525 PUSH_DATA (push
, 1);
1530 nv50_flush_resource(struct pipe_context
*ctx
,
1531 struct pipe_resource
*resource
)
1536 nv50_blitter_create(struct nv50_screen
*screen
)
1538 screen
->blitter
= CALLOC_STRUCT(nv50_blitter
);
1539 if (!screen
->blitter
) {
1540 NOUVEAU_ERR("failed to allocate blitter struct\n");
1544 pipe_mutex_init(screen
->blitter
->mutex
);
1546 nv50_blitter_make_vp(screen
->blitter
);
1547 nv50_blitter_make_sampler(screen
->blitter
);
1553 nv50_blitter_destroy(struct nv50_screen
*screen
)
1555 struct nv50_blitter
*blitter
= screen
->blitter
;
1558 for (i
= 0; i
< NV50_BLIT_MAX_TEXTURE_TYPES
; ++i
) {
1559 for (m
= 0; m
< NV50_BLIT_MODES
; ++m
) {
1560 struct nv50_program
*prog
= blitter
->fp
[i
][m
];
1562 nv50_program_destroy(NULL
, prog
);
1563 FREE((void *)prog
->pipe
.tokens
);
1573 nv50_blitctx_create(struct nv50_context
*nv50
)
1575 nv50
->blit
= CALLOC_STRUCT(nv50_blitctx
);
1577 NOUVEAU_ERR("failed to allocate blit context\n");
1581 nv50
->blit
->nv50
= nv50
;
1583 nv50
->blit
->rast
.pipe
.half_pixel_center
= 1;
1589 nv50_init_surface_functions(struct nv50_context
*nv50
)
1591 struct pipe_context
*pipe
= &nv50
->base
.pipe
;
1593 pipe
->resource_copy_region
= nv50_resource_copy_region
;
1594 pipe
->blit
= nv50_blit
;
1595 pipe
->flush_resource
= nv50_flush_resource
;
1596 pipe
->clear_render_target
= nv50_clear_render_target
;
1597 pipe
->clear_depth_stencil
= nv50_clear_depth_stencil
;
1598 pipe
->clear_buffer
= nv50_clear_buffer
;