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_m2mf_rect drect
, srect
;
225 unsigned nx
= util_format_get_nblocksx(src
->format
, src_box
->width
);
226 unsigned ny
= util_format_get_nblocksy(src
->format
, src_box
->height
);
228 nv50_m2mf_rect_setup(&drect
, dst
, dst_level
, dstx
, dsty
, dstz
);
229 nv50_m2mf_rect_setup(&srect
, src
, src_level
,
230 src_box
->x
, src_box
->y
, src_box
->z
);
232 for (i
= 0; i
< src_box
->depth
; ++i
) {
233 nv50_m2mf_transfer_rect(nv50
, &drect
, &srect
, nx
, ny
);
235 if (nv50_miptree(dst
)->layout_3d
)
238 drect
.base
+= nv50_miptree(dst
)->layer_stride
;
240 if (nv50_miptree(src
)->layout_3d
)
243 srect
.base
+= nv50_miptree(src
)->layer_stride
;
248 assert((src
->format
== dst
->format
) ||
249 (nv50_2d_src_format_faithful(src
->format
) &&
250 nv50_2d_dst_format_faithful(dst
->format
)));
252 BCTX_REFN(nv50
->bufctx
, 2D
, nv04_resource(src
), RD
);
253 BCTX_REFN(nv50
->bufctx
, 2D
, nv04_resource(dst
), WR
);
254 nouveau_pushbuf_bufctx(nv50
->base
.pushbuf
, nv50
->bufctx
);
255 nouveau_pushbuf_validate(nv50
->base
.pushbuf
);
257 for (; dst_layer
< dstz
+ src_box
->depth
; ++dst_layer
, ++src_layer
) {
258 ret
= nv50_2d_texture_do_copy(nv50
->base
.pushbuf
,
259 nv50_miptree(dst
), dst_level
,
260 dstx
, dsty
, dst_layer
,
261 nv50_miptree(src
), src_level
,
262 src_box
->x
, src_box
->y
, src_layer
,
263 src_box
->width
, src_box
->height
);
267 nouveau_bufctx_reset(nv50
->bufctx
, NV50_BIND_2D
);
271 nv50_clear_render_target(struct pipe_context
*pipe
,
272 struct pipe_surface
*dst
,
273 const union pipe_color_union
*color
,
274 unsigned dstx
, unsigned dsty
,
275 unsigned width
, unsigned height
)
277 struct nv50_context
*nv50
= nv50_context(pipe
);
278 struct nouveau_pushbuf
*push
= nv50
->base
.pushbuf
;
279 struct nv50_miptree
*mt
= nv50_miptree(dst
->texture
);
280 struct nv50_surface
*sf
= nv50_surface(dst
);
281 struct nouveau_bo
*bo
= mt
->base
.bo
;
284 BEGIN_NV04(push
, NV50_3D(CLEAR_COLOR(0)), 4);
285 PUSH_DATAf(push
, color
->f
[0]);
286 PUSH_DATAf(push
, color
->f
[1]);
287 PUSH_DATAf(push
, color
->f
[2]);
288 PUSH_DATAf(push
, color
->f
[3]);
290 if (nouveau_pushbuf_space(push
, 32 + sf
->depth
, 1, 0))
293 PUSH_REFN(push
, bo
, mt
->base
.domain
| NOUVEAU_BO_WR
);
295 BEGIN_NV04(push
, NV50_3D(SCREEN_SCISSOR_HORIZ
), 2);
296 PUSH_DATA (push
, ( width
<< 16) | dstx
);
297 PUSH_DATA (push
, (height
<< 16) | dsty
);
298 BEGIN_NV04(push
, NV50_3D(SCISSOR_HORIZ(0)), 2);
299 PUSH_DATA (push
, 8192 << 16);
300 PUSH_DATA (push
, 8192 << 16);
301 nv50
->scissors_dirty
|= 1;
303 BEGIN_NV04(push
, NV50_3D(RT_CONTROL
), 1);
305 BEGIN_NV04(push
, NV50_3D(RT_ADDRESS_HIGH(0)), 5);
306 PUSH_DATAh(push
, mt
->base
.address
+ sf
->offset
);
307 PUSH_DATA (push
, mt
->base
.address
+ sf
->offset
);
308 PUSH_DATA (push
, nv50_format_table
[dst
->format
].rt
);
309 PUSH_DATA (push
, mt
->level
[sf
->base
.u
.tex
.level
].tile_mode
);
310 PUSH_DATA (push
, mt
->layer_stride
>> 2);
311 BEGIN_NV04(push
, NV50_3D(RT_HORIZ(0)), 2);
312 if (nouveau_bo_memtype(bo
))
313 PUSH_DATA(push
, sf
->width
);
315 PUSH_DATA(push
, NV50_3D_RT_HORIZ_LINEAR
| mt
->level
[0].pitch
);
316 PUSH_DATA (push
, sf
->height
);
317 BEGIN_NV04(push
, NV50_3D(RT_ARRAY_MODE
), 1);
319 PUSH_DATA(push
, NV50_3D_RT_ARRAY_MODE_MODE_3D
| 512);
321 PUSH_DATA(push
, 512);
323 if (!nouveau_bo_memtype(bo
)) {
324 BEGIN_NV04(push
, NV50_3D(ZETA_ENABLE
), 1);
328 /* NOTE: only works with D3D clear flag (5097/0x143c bit 4) */
330 BEGIN_NV04(push
, NV50_3D(VIEWPORT_HORIZ(0)), 2);
331 PUSH_DATA (push
, (width
<< 16) | dstx
);
332 PUSH_DATA (push
, (height
<< 16) | dsty
);
334 BEGIN_NI04(push
, NV50_3D(CLEAR_BUFFERS
), sf
->depth
);
335 for (z
= 0; z
< sf
->depth
; ++z
) {
336 PUSH_DATA (push
, 0x3c |
337 (z
<< NV50_3D_CLEAR_BUFFERS_LAYER__SHIFT
));
340 nv50
->dirty
|= NV50_NEW_FRAMEBUFFER
| NV50_NEW_SCISSOR
;
344 nv50_clear_depth_stencil(struct pipe_context
*pipe
,
345 struct pipe_surface
*dst
,
346 unsigned clear_flags
,
349 unsigned dstx
, unsigned dsty
,
350 unsigned width
, unsigned height
)
352 struct nv50_context
*nv50
= nv50_context(pipe
);
353 struct nouveau_pushbuf
*push
= nv50
->base
.pushbuf
;
354 struct nv50_miptree
*mt
= nv50_miptree(dst
->texture
);
355 struct nv50_surface
*sf
= nv50_surface(dst
);
356 struct nouveau_bo
*bo
= mt
->base
.bo
;
360 assert(nouveau_bo_memtype(bo
)); /* ZETA cannot be linear */
362 if (clear_flags
& PIPE_CLEAR_DEPTH
) {
363 BEGIN_NV04(push
, NV50_3D(CLEAR_DEPTH
), 1);
364 PUSH_DATAf(push
, depth
);
365 mode
|= NV50_3D_CLEAR_BUFFERS_Z
;
368 if (clear_flags
& PIPE_CLEAR_STENCIL
) {
369 BEGIN_NV04(push
, NV50_3D(CLEAR_STENCIL
), 1);
370 PUSH_DATA (push
, stencil
& 0xff);
371 mode
|= NV50_3D_CLEAR_BUFFERS_S
;
374 if (nouveau_pushbuf_space(push
, 32 + sf
->depth
, 1, 0))
377 PUSH_REFN(push
, bo
, mt
->base
.domain
| NOUVEAU_BO_WR
);
379 BEGIN_NV04(push
, NV50_3D(SCREEN_SCISSOR_HORIZ
), 2);
380 PUSH_DATA (push
, ( width
<< 16) | dstx
);
381 PUSH_DATA (push
, (height
<< 16) | dsty
);
382 BEGIN_NV04(push
, NV50_3D(SCISSOR_HORIZ(0)), 2);
383 PUSH_DATA (push
, 8192 << 16);
384 PUSH_DATA (push
, 8192 << 16);
385 nv50
->scissors_dirty
|= 1;
387 BEGIN_NV04(push
, NV50_3D(ZETA_ADDRESS_HIGH
), 5);
388 PUSH_DATAh(push
, mt
->base
.address
+ sf
->offset
);
389 PUSH_DATA (push
, mt
->base
.address
+ sf
->offset
);
390 PUSH_DATA (push
, nv50_format_table
[dst
->format
].rt
);
391 PUSH_DATA (push
, mt
->level
[sf
->base
.u
.tex
.level
].tile_mode
);
392 PUSH_DATA (push
, mt
->layer_stride
>> 2);
393 BEGIN_NV04(push
, NV50_3D(ZETA_ENABLE
), 1);
395 BEGIN_NV04(push
, NV50_3D(ZETA_HORIZ
), 3);
396 PUSH_DATA (push
, sf
->width
);
397 PUSH_DATA (push
, sf
->height
);
398 PUSH_DATA (push
, (1 << 16) | 1);
400 BEGIN_NV04(push
, NV50_3D(RT_ARRAY_MODE
), 1);
401 PUSH_DATA (push
, 512);
403 BEGIN_NV04(push
, NV50_3D(VIEWPORT_HORIZ(0)), 2);
404 PUSH_DATA (push
, (width
<< 16) | dstx
);
405 PUSH_DATA (push
, (height
<< 16) | dsty
);
407 BEGIN_NI04(push
, NV50_3D(CLEAR_BUFFERS
), sf
->depth
);
408 for (z
= 0; z
< sf
->depth
; ++z
) {
409 PUSH_DATA (push
, mode
|
410 (z
<< NV50_3D_CLEAR_BUFFERS_LAYER__SHIFT
));
413 nv50
->dirty
|= NV50_NEW_FRAMEBUFFER
| NV50_NEW_SCISSOR
;
417 nv50_clear(struct pipe_context
*pipe
, unsigned buffers
,
418 const union pipe_color_union
*color
,
419 double depth
, unsigned stencil
)
421 struct nv50_context
*nv50
= nv50_context(pipe
);
422 struct nouveau_pushbuf
*push
= nv50
->base
.pushbuf
;
423 struct pipe_framebuffer_state
*fb
= &nv50
->framebuffer
;
427 /* don't need NEW_BLEND, COLOR_MASK doesn't affect CLEAR_BUFFERS */
428 if (!nv50_state_validate(nv50
, NV50_NEW_FRAMEBUFFER
, 9 + (fb
->nr_cbufs
* 2)))
431 /* We have to clear ALL of the layers, not up to the min number of layers
432 * of any attachment. */
433 BEGIN_NV04(push
, NV50_3D(RT_ARRAY_MODE
), 1);
434 PUSH_DATA (push
, (nv50
->rt_array_mode
& NV50_3D_RT_ARRAY_MODE_MODE_3D
) | 512);
436 if (buffers
& PIPE_CLEAR_COLOR
&& fb
->nr_cbufs
) {
437 BEGIN_NV04(push
, NV50_3D(CLEAR_COLOR(0)), 4);
438 PUSH_DATAf(push
, color
->f
[0]);
439 PUSH_DATAf(push
, color
->f
[1]);
440 PUSH_DATAf(push
, color
->f
[2]);
441 PUSH_DATAf(push
, color
->f
[3]);
442 if (buffers
& PIPE_CLEAR_COLOR0
)
444 NV50_3D_CLEAR_BUFFERS_R
| NV50_3D_CLEAR_BUFFERS_G
|
445 NV50_3D_CLEAR_BUFFERS_B
| NV50_3D_CLEAR_BUFFERS_A
;
448 if (buffers
& PIPE_CLEAR_DEPTH
) {
449 BEGIN_NV04(push
, NV50_3D(CLEAR_DEPTH
), 1);
450 PUSH_DATA (push
, fui(depth
));
451 mode
|= NV50_3D_CLEAR_BUFFERS_Z
;
454 if (buffers
& PIPE_CLEAR_STENCIL
) {
455 BEGIN_NV04(push
, NV50_3D(CLEAR_STENCIL
), 1);
456 PUSH_DATA (push
, stencil
& 0xff);
457 mode
|= NV50_3D_CLEAR_BUFFERS_S
;
461 int zs_layers
= 0, color0_layers
= 0;
462 if (fb
->cbufs
[0] && (mode
& 0x3c))
463 color0_layers
= fb
->cbufs
[0]->u
.tex
.last_layer
-
464 fb
->cbufs
[0]->u
.tex
.first_layer
+ 1;
465 if (fb
->zsbuf
&& (mode
& ~0x3c))
466 zs_layers
= fb
->zsbuf
->u
.tex
.last_layer
-
467 fb
->zsbuf
->u
.tex
.first_layer
+ 1;
469 for (j
= 0; j
< MIN2(zs_layers
, color0_layers
); j
++) {
470 BEGIN_NV04(push
, NV50_3D(CLEAR_BUFFERS
), 1);
471 PUSH_DATA(push
, mode
| (j
<< NV50_3D_CLEAR_BUFFERS_LAYER__SHIFT
));
473 for (k
= j
; k
< zs_layers
; k
++) {
474 BEGIN_NV04(push
, NV50_3D(CLEAR_BUFFERS
), 1);
475 PUSH_DATA(push
, (mode
& ~0x3c) | (k
<< NV50_3D_CLEAR_BUFFERS_LAYER__SHIFT
));
477 for (k
= j
; k
< color0_layers
; k
++) {
478 BEGIN_NV04(push
, NV50_3D(CLEAR_BUFFERS
), 1);
479 PUSH_DATA(push
, (mode
& 0x3c) | (k
<< NV50_3D_CLEAR_BUFFERS_LAYER__SHIFT
));
483 for (i
= 1; i
< fb
->nr_cbufs
; i
++) {
484 struct pipe_surface
*sf
= fb
->cbufs
[i
];
485 if (!sf
|| !(buffers
& (PIPE_CLEAR_COLOR0
<< i
)))
487 for (j
= 0; j
<= sf
->u
.tex
.last_layer
- sf
->u
.tex
.first_layer
; j
++) {
488 BEGIN_NV04(push
, NV50_3D(CLEAR_BUFFERS
), 1);
489 PUSH_DATA (push
, (i
<< 6) | 0x3c |
490 (j
<< NV50_3D_CLEAR_BUFFERS_LAYER__SHIFT
));
494 /* restore the array mode */
495 BEGIN_NV04(push
, NV50_3D(RT_ARRAY_MODE
), 1);
496 PUSH_DATA (push
, nv50
->rt_array_mode
);
500 nv50_clear_buffer(struct pipe_context
*pipe
,
501 struct pipe_resource
*res
,
502 unsigned offset
, unsigned size
,
503 const void *data
, int data_size
)
505 struct nv50_context
*nv50
= nv50_context(pipe
);
506 struct nouveau_pushbuf
*push
= nv50
->base
.pushbuf
;
507 struct nv04_resource
*buf
= (struct nv04_resource
*)res
;
508 union pipe_color_union color
;
509 enum pipe_format dst_fmt
;
510 unsigned width
, height
, elements
;
512 assert(res
->target
== PIPE_BUFFER
);
513 assert(nouveau_bo_memtype(buf
->bo
) == 0);
517 dst_fmt
= PIPE_FORMAT_R32G32B32A32_UINT
;
518 memcpy(&color
.ui
, data
, 16);
521 dst_fmt
= PIPE_FORMAT_R32G32_UINT
;
522 memcpy(&color
.ui
, data
, 8);
523 memset(&color
.ui
[2], 0, 8);
526 dst_fmt
= PIPE_FORMAT_R32_UINT
;
527 memcpy(&color
.ui
, data
, 4);
528 memset(&color
.ui
[1], 0, 12);
531 dst_fmt
= PIPE_FORMAT_R16_UINT
;
532 color
.ui
[0] = util_cpu_to_le32(
533 util_le16_to_cpu(*(unsigned short *)data
));
534 memset(&color
.ui
[1], 0, 12);
537 dst_fmt
= PIPE_FORMAT_R8_UINT
;
538 color
.ui
[0] = util_cpu_to_le32(*(unsigned char *)data
);
539 memset(&color
.ui
[1], 0, 12);
542 assert(!"Unsupported element size");
546 assert(size
% data_size
== 0);
548 elements
= size
/ data_size
;
549 height
= (elements
+ 8191) / 8192;
550 width
= elements
/ height
;
552 BEGIN_NV04(push
, NV50_3D(CLEAR_COLOR(0)), 4);
553 PUSH_DATAf(push
, color
.f
[0]);
554 PUSH_DATAf(push
, color
.f
[1]);
555 PUSH_DATAf(push
, color
.f
[2]);
556 PUSH_DATAf(push
, color
.f
[3]);
558 if (nouveau_pushbuf_space(push
, 32, 1, 0))
561 PUSH_REFN(push
, buf
->bo
, buf
->domain
| NOUVEAU_BO_WR
);
563 BEGIN_NV04(push
, NV50_3D(SCREEN_SCISSOR_HORIZ
), 2);
564 PUSH_DATA (push
, width
<< 16);
565 PUSH_DATA (push
, height
<< 16);
566 BEGIN_NV04(push
, NV50_3D(SCISSOR_HORIZ(0)), 2);
567 PUSH_DATA (push
, 8192 << 16);
568 PUSH_DATA (push
, 8192 << 16);
569 nv50
->scissors_dirty
|= 1;
571 BEGIN_NV04(push
, NV50_3D(RT_CONTROL
), 1);
573 BEGIN_NV04(push
, NV50_3D(RT_ADDRESS_HIGH(0)), 5);
574 PUSH_DATAh(push
, buf
->bo
->offset
+ buf
->offset
+ offset
);
575 PUSH_DATA (push
, buf
->bo
->offset
+ buf
->offset
+ offset
);
576 PUSH_DATA (push
, nv50_format_table
[dst_fmt
].rt
);
579 BEGIN_NV04(push
, NV50_3D(RT_HORIZ(0)), 2);
580 PUSH_DATA (push
, NV50_3D_RT_HORIZ_LINEAR
| (width
* data_size
));
581 PUSH_DATA (push
, height
);
582 BEGIN_NV04(push
, NV50_3D(ZETA_ENABLE
), 1);
585 /* NOTE: only works with D3D clear flag (5097/0x143c bit 4) */
587 BEGIN_NV04(push
, NV50_3D(VIEWPORT_HORIZ(0)), 2);
588 PUSH_DATA (push
, (width
<< 16));
589 PUSH_DATA (push
, (height
<< 16));
591 BEGIN_NI04(push
, NV50_3D(CLEAR_BUFFERS
), 1);
592 PUSH_DATA (push
, 0x3c);
594 if (width
* height
!= elements
) {
595 offset
+= width
* height
* data_size
;
596 width
= elements
- width
* height
;
598 BEGIN_NV04(push
, NV50_3D(RT_ADDRESS_HIGH(0)), 2);
599 PUSH_DATAh(push
, buf
->bo
->offset
+ buf
->offset
+ offset
);
600 PUSH_DATA (push
, buf
->bo
->offset
+ buf
->offset
+ offset
);
601 BEGIN_NV04(push
, NV50_3D(RT_HORIZ(0)), 2);
602 PUSH_DATA (push
, NV50_3D_RT_HORIZ_LINEAR
| (width
* data_size
));
603 PUSH_DATA (push
, height
);
604 BEGIN_NI04(push
, NV50_3D(CLEAR_BUFFERS
), 1);
605 PUSH_DATA (push
, 0x3c);
608 nouveau_fence_ref(nv50
->screen
->base
.fence
.current
, &buf
->fence
);
609 nouveau_fence_ref(nv50
->screen
->base
.fence
.current
, &buf
->fence_wr
);
611 nv50
->dirty
|= NV50_NEW_FRAMEBUFFER
| NV50_NEW_SCISSOR
;
614 /* =============================== BLIT CODE ===================================
619 struct nv50_program
*fp
[NV50_BLIT_MAX_TEXTURE_TYPES
][NV50_BLIT_MODES
];
620 struct nv50_program vp
;
622 struct nv50_tsc_entry sampler
[2]; /* nearest, bilinear */
629 struct nv50_context
*nv50
;
630 struct nv50_program
*fp
;
634 uint8_t render_condition_enable
;
635 enum pipe_texture_target target
;
637 struct pipe_framebuffer_state fb
;
638 struct nv50_rasterizer_stateobj
*rast
;
639 struct nv50_program
*vp
;
640 struct nv50_program
*gp
;
641 struct nv50_program
*fp
;
642 unsigned num_textures
[3];
643 unsigned num_samplers
[3];
644 struct pipe_sampler_view
*texture
[2];
645 struct nv50_tsc_entry
*sampler
[2];
646 unsigned min_samples
;
649 struct nv50_rasterizer_stateobj rast
;
653 nv50_blitter_make_vp(struct nv50_blitter
*blit
)
655 static const uint32_t code
[] =
657 0x10000001, 0x0423c788, /* mov b32 o[0x00] s[0x00] */ /* HPOS.x */
658 0x10000205, 0x0423c788, /* mov b32 o[0x04] s[0x04] */ /* HPOS.y */
659 0x10000409, 0x0423c788, /* mov b32 o[0x08] s[0x08] */ /* TEXC.x */
660 0x1000060d, 0x0423c788, /* mov b32 o[0x0c] s[0x0c] */ /* TEXC.y */
661 0x10000811, 0x0423c789, /* mov b32 o[0x10] s[0x10] */ /* TEXC.z */
664 blit
->vp
.type
= PIPE_SHADER_VERTEX
;
665 blit
->vp
.translated
= true;
666 blit
->vp
.code
= (uint32_t *)code
; /* const_cast */
667 blit
->vp
.code_size
= sizeof(code
);
668 blit
->vp
.max_gpr
= 4;
669 blit
->vp
.max_out
= 5;
671 blit
->vp
.out
[0].mask
= 0x3;
672 blit
->vp
.out
[0].sn
= TGSI_SEMANTIC_POSITION
;
673 blit
->vp
.out
[1].hw
= 2;
674 blit
->vp
.out
[1].mask
= 0x7;
675 blit
->vp
.out
[1].sn
= TGSI_SEMANTIC_GENERIC
;
676 blit
->vp
.out
[1].si
= 0;
677 blit
->vp
.vp
.attrs
[0] = 0x73;
678 blit
->vp
.vp
.psiz
= 0x40;
679 blit
->vp
.vp
.edgeflag
= 0x40;
683 nv50_blitter_make_fp(struct pipe_context
*pipe
,
685 enum pipe_texture_target ptarg
)
687 struct ureg_program
*ureg
;
690 struct ureg_dst data
;
692 const unsigned target
= nv50_blit_get_tgsi_texture_target(ptarg
);
694 bool tex_rgbaz
= false;
696 bool cvt_un8
= false;
698 if (mode
!= NV50_BLIT_MODE_PASS
&&
699 mode
!= NV50_BLIT_MODE_Z24X8
&&
700 mode
!= NV50_BLIT_MODE_X8Z24
)
703 if (mode
!= NV50_BLIT_MODE_X24S8
&&
704 mode
!= NV50_BLIT_MODE_S8X24
&&
705 mode
!= NV50_BLIT_MODE_XS
)
708 if (mode
!= NV50_BLIT_MODE_PASS
&&
709 mode
!= NV50_BLIT_MODE_ZS
&&
710 mode
!= NV50_BLIT_MODE_XS
)
713 ureg
= ureg_create(TGSI_PROCESSOR_FRAGMENT
);
717 out
= ureg_DECL_output(ureg
, TGSI_SEMANTIC_COLOR
, 0);
718 tc
= ureg_DECL_fs_input(
719 ureg
, TGSI_SEMANTIC_GENERIC
, 0, TGSI_INTERPOLATE_LINEAR
);
721 if (ptarg
== PIPE_TEXTURE_1D_ARRAY
) {
722 /* Adjust coordinates. Depth is in z, but TEX expects it to be in y. */
723 tc
= ureg_swizzle(tc
, TGSI_SWIZZLE_X
, TGSI_SWIZZLE_Z
,
724 TGSI_SWIZZLE_Z
, TGSI_SWIZZLE_Z
);
727 data
= ureg_DECL_temporary(ureg
);
730 ureg_TEX(ureg
, ureg_writemask(data
, TGSI_WRITEMASK_X
),
731 target
, tc
, ureg_DECL_sampler(ureg
, 1));
732 ureg_MOV(ureg
, ureg_writemask(data
, TGSI_WRITEMASK_Y
),
733 ureg_scalar(ureg_src(data
), TGSI_SWIZZLE_X
));
736 const unsigned mask
= (mode
== NV50_BLIT_MODE_PASS
) ?
737 TGSI_WRITEMASK_XYZW
: TGSI_WRITEMASK_X
;
738 ureg_TEX(ureg
, ureg_writemask(data
, mask
),
739 target
, tc
, ureg_DECL_sampler(ureg
, 0));
743 struct ureg_src mask
;
744 struct ureg_src scale
;
745 struct ureg_dst outz
;
746 struct ureg_dst outs
;
747 struct ureg_dst zdst3
= ureg_writemask(data
, TGSI_WRITEMASK_XYZ
);
748 struct ureg_dst zdst
= ureg_writemask(data
, TGSI_WRITEMASK_X
);
749 struct ureg_dst sdst
= ureg_writemask(data
, TGSI_WRITEMASK_Y
);
750 struct ureg_src zsrc3
= ureg_src(data
);
751 struct ureg_src zsrc
= ureg_scalar(zsrc3
, TGSI_SWIZZLE_X
);
752 struct ureg_src ssrc
= ureg_scalar(zsrc3
, TGSI_SWIZZLE_Y
);
753 struct ureg_src zshuf
;
755 mask
= ureg_imm3u(ureg
, 0x0000ff, 0x00ff00, 0xff0000);
756 scale
= ureg_imm4f(ureg
,
757 1.0f
/ 0x0000ff, 1.0f
/ 0x00ff00, 1.0f
/ 0xff0000,
760 if (mode
== NV50_BLIT_MODE_Z24S8
||
761 mode
== NV50_BLIT_MODE_X24S8
||
762 mode
== NV50_BLIT_MODE_Z24X8
) {
763 outz
= ureg_writemask(out
, TGSI_WRITEMASK_XYZ
);
764 outs
= ureg_writemask(out
, TGSI_WRITEMASK_W
);
765 zshuf
= ureg_src(data
);
767 outz
= ureg_writemask(out
, TGSI_WRITEMASK_YZW
);
768 outs
= ureg_writemask(out
, TGSI_WRITEMASK_X
);
769 zshuf
= ureg_swizzle(zsrc3
, TGSI_SWIZZLE_W
,
770 TGSI_SWIZZLE_X
, TGSI_SWIZZLE_Y
, TGSI_SWIZZLE_Z
);
774 ureg_I2F(ureg
, sdst
, ssrc
);
775 ureg_MUL(ureg
, outs
, ssrc
, ureg_scalar(scale
, TGSI_SWIZZLE_X
));
779 ureg_MUL(ureg
, zdst
, zsrc
, ureg_scalar(scale
, TGSI_SWIZZLE_W
));
780 ureg_F2I(ureg
, zdst
, zsrc
);
781 ureg_AND(ureg
, zdst3
, zsrc
, mask
);
782 ureg_I2F(ureg
, zdst3
, zsrc3
);
783 ureg_MUL(ureg
, zdst3
, zsrc3
, scale
);
784 ureg_MOV(ureg
, outz
, zshuf
);
787 unsigned mask
= TGSI_WRITEMASK_XYZW
;
789 if (mode
!= NV50_BLIT_MODE_PASS
) {
790 mask
&= ~TGSI_WRITEMASK_ZW
;
792 mask
= TGSI_WRITEMASK_X
;
794 mask
= TGSI_WRITEMASK_Y
;
796 ureg_MOV(ureg
, ureg_writemask(out
, mask
), ureg_src(data
));
800 return ureg_create_shader_and_destroy(ureg
, pipe
);
804 nv50_blitter_make_sampler(struct nv50_blitter
*blit
)
806 /* clamp to edge, min/max lod = 0, nearest filtering */
808 blit
->sampler
[0].id
= -1;
810 blit
->sampler
[0].tsc
[0] = NV50_TSC_0_SRGB_CONVERSION_ALLOWED
|
811 (NV50_TSC_WRAP_CLAMP_TO_EDGE
<< NV50_TSC_0_WRAPS__SHIFT
) |
812 (NV50_TSC_WRAP_CLAMP_TO_EDGE
<< NV50_TSC_0_WRAPT__SHIFT
) |
813 (NV50_TSC_WRAP_CLAMP_TO_EDGE
<< NV50_TSC_0_WRAPR__SHIFT
);
814 blit
->sampler
[0].tsc
[1] =
815 NV50_TSC_1_MAGF_NEAREST
| NV50_TSC_1_MINF_NEAREST
| NV50_TSC_1_MIPF_NONE
;
817 /* clamp to edge, min/max lod = 0, bilinear filtering */
819 blit
->sampler
[1].id
= -1;
821 blit
->sampler
[1].tsc
[0] = blit
->sampler
[0].tsc
[0];
822 blit
->sampler
[1].tsc
[1] =
823 NV50_TSC_1_MAGF_LINEAR
| NV50_TSC_1_MINF_LINEAR
| NV50_TSC_1_MIPF_NONE
;
827 nv50_blit_select_mode(const struct pipe_blit_info
*info
)
829 const unsigned mask
= info
->mask
;
831 switch (info
->dst
.resource
->format
) {
832 case PIPE_FORMAT_Z24_UNORM_S8_UINT
:
833 case PIPE_FORMAT_Z24X8_UNORM
:
834 case PIPE_FORMAT_X24S8_UINT
:
835 switch (mask
& PIPE_MASK_ZS
) {
836 case PIPE_MASK_ZS
: return NV50_BLIT_MODE_Z24S8
;
837 case PIPE_MASK_Z
: return NV50_BLIT_MODE_Z24X8
;
839 return NV50_BLIT_MODE_X24S8
;
841 case PIPE_FORMAT_S8_UINT_Z24_UNORM
:
842 case PIPE_FORMAT_X8Z24_UNORM
:
843 case PIPE_FORMAT_S8X24_UINT
:
844 switch (mask
& PIPE_MASK_ZS
) {
845 case PIPE_MASK_ZS
: return NV50_BLIT_MODE_S8Z24
;
846 case PIPE_MASK_Z
: return NV50_BLIT_MODE_X8Z24
;
848 return NV50_BLIT_MODE_S8X24
;
850 case PIPE_FORMAT_Z32_FLOAT
:
851 case PIPE_FORMAT_Z32_FLOAT_S8X24_UINT
:
852 case PIPE_FORMAT_X32_S8X24_UINT
:
853 switch (mask
& PIPE_MASK_ZS
) {
854 case PIPE_MASK_ZS
: return NV50_BLIT_MODE_ZS
;
855 case PIPE_MASK_Z
: return NV50_BLIT_MODE_PASS
;
857 return NV50_BLIT_MODE_XS
;
860 return NV50_BLIT_MODE_PASS
;
865 nv50_blit_select_fp(struct nv50_blitctx
*ctx
, const struct pipe_blit_info
*info
)
867 struct nv50_blitter
*blitter
= ctx
->nv50
->screen
->blitter
;
869 const enum pipe_texture_target ptarg
=
870 nv50_blit_reinterpret_pipe_texture_target(info
->src
.resource
->target
);
872 const unsigned targ
= nv50_blit_texture_type(ptarg
);
873 const unsigned mode
= ctx
->mode
;
875 if (!blitter
->fp
[targ
][mode
]) {
876 pipe_mutex_lock(blitter
->mutex
);
877 if (!blitter
->fp
[targ
][mode
])
878 blitter
->fp
[targ
][mode
] =
879 nv50_blitter_make_fp(&ctx
->nv50
->base
.pipe
, mode
, ptarg
);
880 pipe_mutex_unlock(blitter
->mutex
);
882 ctx
->fp
= blitter
->fp
[targ
][mode
];
886 nv50_blit_set_dst(struct nv50_blitctx
*ctx
,
887 struct pipe_resource
*res
, unsigned level
, unsigned layer
,
888 enum pipe_format format
)
890 struct nv50_context
*nv50
= ctx
->nv50
;
891 struct pipe_context
*pipe
= &nv50
->base
.pipe
;
892 struct pipe_surface templ
;
894 if (util_format_is_depth_or_stencil(format
))
895 templ
.format
= nv50_blit_zeta_to_colour_format(format
);
897 templ
.format
= format
;
899 templ
.u
.tex
.level
= level
;
900 templ
.u
.tex
.first_layer
= templ
.u
.tex
.last_layer
= layer
;
903 templ
.u
.tex
.first_layer
= 0;
904 templ
.u
.tex
.last_layer
=
905 (res
->target
== PIPE_TEXTURE_3D
? res
->depth0
: res
->array_size
) - 1;
908 nv50
->framebuffer
.cbufs
[0] = nv50_miptree_surface_new(pipe
, res
, &templ
);
909 nv50
->framebuffer
.nr_cbufs
= 1;
910 nv50
->framebuffer
.zsbuf
= NULL
;
911 nv50
->framebuffer
.width
= nv50
->framebuffer
.cbufs
[0]->width
;
912 nv50
->framebuffer
.height
= nv50
->framebuffer
.cbufs
[0]->height
;
916 nv50_blit_set_src(struct nv50_blitctx
*blit
,
917 struct pipe_resource
*res
, unsigned level
, unsigned layer
,
918 enum pipe_format format
, const uint8_t filter
)
920 struct nv50_context
*nv50
= blit
->nv50
;
921 struct pipe_context
*pipe
= &nv50
->base
.pipe
;
922 struct pipe_sampler_view templ
;
924 enum pipe_texture_target target
;
926 target
= nv50_blit_reinterpret_pipe_texture_target(res
->target
);
928 templ
.format
= format
;
929 templ
.u
.tex
.first_level
= templ
.u
.tex
.last_level
= level
;
930 templ
.u
.tex
.first_layer
= templ
.u
.tex
.last_layer
= layer
;
931 templ
.swizzle_r
= PIPE_SWIZZLE_RED
;
932 templ
.swizzle_g
= PIPE_SWIZZLE_GREEN
;
933 templ
.swizzle_b
= PIPE_SWIZZLE_BLUE
;
934 templ
.swizzle_a
= PIPE_SWIZZLE_ALPHA
;
937 templ
.u
.tex
.first_layer
= 0;
938 templ
.u
.tex
.last_layer
=
939 (res
->target
== PIPE_TEXTURE_3D
? res
->depth0
: res
->array_size
) - 1;
942 flags
= res
->last_level
? 0 : NV50_TEXVIEW_SCALED_COORDS
;
943 flags
|= NV50_TEXVIEW_ACCESS_RESOLVE
;
944 if (filter
&& res
->nr_samples
== 8)
945 flags
|= NV50_TEXVIEW_FILTER_MSAA8
;
947 nv50
->textures
[2][0] = nv50_create_texture_view(
948 pipe
, res
, &templ
, flags
, target
);
949 nv50
->textures
[2][1] = NULL
;
951 nv50
->num_textures
[0] = nv50
->num_textures
[1] = 0;
952 nv50
->num_textures
[2] = 1;
954 templ
.format
= nv50_zs_to_s_format(format
);
955 if (templ
.format
!= res
->format
) {
956 nv50
->textures
[2][1] = nv50_create_texture_view(
957 pipe
, res
, &templ
, flags
, target
);
958 nv50
->num_textures
[2] = 2;
963 nv50_blitctx_prepare_state(struct nv50_blitctx
*blit
)
965 struct nouveau_pushbuf
*push
= blit
->nv50
->base
.pushbuf
;
967 if (blit
->nv50
->cond_query
&& !blit
->render_condition_enable
) {
968 BEGIN_NV04(push
, NV50_3D(COND_MODE
), 1);
969 PUSH_DATA (push
, NV50_3D_COND_MODE_ALWAYS
);
973 BEGIN_NV04(push
, NV50_3D(COLOR_MASK(0)), 1);
974 PUSH_DATA (push
, blit
->color_mask
);
975 BEGIN_NV04(push
, NV50_3D(BLEND_ENABLE(0)), 1);
977 BEGIN_NV04(push
, NV50_3D(LOGIC_OP_ENABLE
), 1);
980 /* rasterizer state */
981 #ifndef NV50_SCISSORS_CLIPPING
982 BEGIN_NV04(push
, NV50_3D(SCISSOR_ENABLE(0)), 1);
985 BEGIN_NV04(push
, NV50_3D(VERTEX_TWO_SIDE_ENABLE
), 1);
987 BEGIN_NV04(push
, NV50_3D(FRAG_COLOR_CLAMP_EN
), 1);
989 BEGIN_NV04(push
, NV50_3D(MULTISAMPLE_ENABLE
), 1);
991 BEGIN_NV04(push
, NV50_3D(MSAA_MASK(0)), 4);
992 PUSH_DATA (push
, 0xffff);
993 PUSH_DATA (push
, 0xffff);
994 PUSH_DATA (push
, 0xffff);
995 PUSH_DATA (push
, 0xffff);
996 BEGIN_NV04(push
, NV50_3D(POLYGON_MODE_FRONT
), 3);
997 PUSH_DATA (push
, NV50_3D_POLYGON_MODE_FRONT_FILL
);
998 PUSH_DATA (push
, NV50_3D_POLYGON_MODE_BACK_FILL
);
1000 BEGIN_NV04(push
, NV50_3D(CULL_FACE_ENABLE
), 1);
1001 PUSH_DATA (push
, 0);
1002 BEGIN_NV04(push
, NV50_3D(POLYGON_STIPPLE_ENABLE
), 1);
1003 PUSH_DATA (push
, 0);
1004 BEGIN_NV04(push
, NV50_3D(POLYGON_OFFSET_FILL_ENABLE
), 1);
1005 PUSH_DATA (push
, 0);
1008 BEGIN_NV04(push
, NV50_3D(DEPTH_TEST_ENABLE
), 1);
1009 PUSH_DATA (push
, 0);
1010 BEGIN_NV04(push
, NV50_3D(DEPTH_BOUNDS_EN
), 1);
1011 PUSH_DATA (push
, 0);
1012 BEGIN_NV04(push
, NV50_3D(STENCIL_ENABLE
), 1);
1013 PUSH_DATA (push
, 0);
1014 BEGIN_NV04(push
, NV50_3D(ALPHA_TEST_ENABLE
), 1);
1015 PUSH_DATA (push
, 0);
1019 nv50_blitctx_pre_blit(struct nv50_blitctx
*ctx
)
1021 struct nv50_context
*nv50
= ctx
->nv50
;
1022 struct nv50_blitter
*blitter
= nv50
->screen
->blitter
;
1025 ctx
->saved
.fb
.width
= nv50
->framebuffer
.width
;
1026 ctx
->saved
.fb
.height
= nv50
->framebuffer
.height
;
1027 ctx
->saved
.fb
.nr_cbufs
= nv50
->framebuffer
.nr_cbufs
;
1028 ctx
->saved
.fb
.cbufs
[0] = nv50
->framebuffer
.cbufs
[0];
1029 ctx
->saved
.fb
.zsbuf
= nv50
->framebuffer
.zsbuf
;
1031 ctx
->saved
.rast
= nv50
->rast
;
1033 ctx
->saved
.vp
= nv50
->vertprog
;
1034 ctx
->saved
.gp
= nv50
->gmtyprog
;
1035 ctx
->saved
.fp
= nv50
->fragprog
;
1037 ctx
->saved
.min_samples
= nv50
->min_samples
;
1039 nv50
->rast
= &ctx
->rast
;
1041 nv50
->vertprog
= &blitter
->vp
;
1042 nv50
->gmtyprog
= NULL
;
1043 nv50
->fragprog
= ctx
->fp
;
1045 for (s
= 0; s
< 3; ++s
) {
1046 ctx
->saved
.num_textures
[s
] = nv50
->num_textures
[s
];
1047 ctx
->saved
.num_samplers
[s
] = nv50
->num_samplers
[s
];
1049 ctx
->saved
.texture
[0] = nv50
->textures
[2][0];
1050 ctx
->saved
.texture
[1] = nv50
->textures
[2][1];
1051 ctx
->saved
.sampler
[0] = nv50
->samplers
[2][0];
1052 ctx
->saved
.sampler
[1] = nv50
->samplers
[2][1];
1054 nv50
->samplers
[2][0] = &blitter
->sampler
[ctx
->filter
];
1055 nv50
->samplers
[2][1] = &blitter
->sampler
[ctx
->filter
];
1057 nv50
->num_samplers
[0] = nv50
->num_samplers
[1] = 0;
1058 nv50
->num_samplers
[2] = 2;
1060 nv50
->min_samples
= 1;
1062 ctx
->saved
.dirty
= nv50
->dirty
;
1064 nouveau_bufctx_reset(nv50
->bufctx_3d
, NV50_BIND_FB
);
1065 nouveau_bufctx_reset(nv50
->bufctx_3d
, NV50_BIND_TEXTURES
);
1068 NV50_NEW_FRAMEBUFFER
| NV50_NEW_MIN_SAMPLES
|
1069 NV50_NEW_VERTPROG
| NV50_NEW_FRAGPROG
| NV50_NEW_GMTYPROG
|
1070 NV50_NEW_TEXTURES
| NV50_NEW_SAMPLERS
;
1074 nv50_blitctx_post_blit(struct nv50_blitctx
*blit
)
1076 struct nv50_context
*nv50
= blit
->nv50
;
1079 pipe_surface_reference(&nv50
->framebuffer
.cbufs
[0], NULL
);
1081 nv50
->framebuffer
.width
= blit
->saved
.fb
.width
;
1082 nv50
->framebuffer
.height
= blit
->saved
.fb
.height
;
1083 nv50
->framebuffer
.nr_cbufs
= blit
->saved
.fb
.nr_cbufs
;
1084 nv50
->framebuffer
.cbufs
[0] = blit
->saved
.fb
.cbufs
[0];
1085 nv50
->framebuffer
.zsbuf
= blit
->saved
.fb
.zsbuf
;
1087 nv50
->rast
= blit
->saved
.rast
;
1089 nv50
->vertprog
= blit
->saved
.vp
;
1090 nv50
->gmtyprog
= blit
->saved
.gp
;
1091 nv50
->fragprog
= blit
->saved
.fp
;
1093 nv50
->min_samples
= blit
->saved
.min_samples
;
1095 pipe_sampler_view_reference(&nv50
->textures
[2][0], NULL
);
1096 pipe_sampler_view_reference(&nv50
->textures
[2][1], NULL
);
1098 for (s
= 0; s
< 3; ++s
) {
1099 nv50
->num_textures
[s
] = blit
->saved
.num_textures
[s
];
1100 nv50
->num_samplers
[s
] = blit
->saved
.num_samplers
[s
];
1102 nv50
->textures
[2][0] = blit
->saved
.texture
[0];
1103 nv50
->textures
[2][1] = blit
->saved
.texture
[1];
1104 nv50
->samplers
[2][0] = blit
->saved
.sampler
[0];
1105 nv50
->samplers
[2][1] = blit
->saved
.sampler
[1];
1107 if (nv50
->cond_query
&& !blit
->render_condition_enable
)
1108 nv50
->base
.pipe
.render_condition(&nv50
->base
.pipe
, nv50
->cond_query
,
1109 nv50
->cond_cond
, nv50
->cond_mode
);
1111 nouveau_bufctx_reset(nv50
->bufctx_3d
, NV50_BIND_FB
);
1112 nouveau_bufctx_reset(nv50
->bufctx_3d
, NV50_BIND_TEXTURES
);
1114 nv50
->dirty
= blit
->saved
.dirty
|
1115 (NV50_NEW_FRAMEBUFFER
| NV50_NEW_SCISSOR
| NV50_NEW_SAMPLE_MASK
|
1116 NV50_NEW_RASTERIZER
| NV50_NEW_ZSA
| NV50_NEW_BLEND
|
1117 NV50_NEW_TEXTURES
| NV50_NEW_SAMPLERS
|
1118 NV50_NEW_VERTPROG
| NV50_NEW_GMTYPROG
| NV50_NEW_FRAGPROG
);
1119 nv50
->scissors_dirty
|= 1;
1121 nv50
->base
.pipe
.set_min_samples(&nv50
->base
.pipe
, blit
->saved
.min_samples
);
1126 nv50_blit_3d(struct nv50_context
*nv50
, const struct pipe_blit_info
*info
)
1128 struct nv50_blitctx
*blit
= nv50
->blit
;
1129 struct nouveau_pushbuf
*push
= nv50
->base
.pushbuf
;
1130 struct pipe_resource
*src
= info
->src
.resource
;
1131 struct pipe_resource
*dst
= info
->dst
.resource
;
1132 int32_t minx
, maxx
, miny
, maxy
;
1134 float x0
, x1
, y0
, y1
, z
;
1136 float x_range
, y_range
;
1139 blit
->mode
= nv50_blit_select_mode(info
);
1140 blit
->color_mask
= nv50_blit_derive_color_mask(info
);
1141 blit
->filter
= nv50_blit_get_filter(info
);
1142 blit
->render_condition_enable
= info
->render_condition_enable
;
1144 nv50_blit_select_fp(blit
, info
);
1145 nv50_blitctx_pre_blit(blit
);
1147 nv50_blit_set_dst(blit
, dst
, info
->dst
.level
, -1, info
->dst
.format
);
1148 nv50_blit_set_src(blit
, src
, info
->src
.level
, -1, info
->src
.format
,
1151 nv50_blitctx_prepare_state(blit
);
1153 nv50_state_validate(nv50
, ~0, 36);
1155 x_range
= (float)info
->src
.box
.width
/ (float)info
->dst
.box
.width
;
1156 y_range
= (float)info
->src
.box
.height
/ (float)info
->dst
.box
.height
;
1158 tri_x
= 16384 << nv50_miptree(dst
)->ms_x
;
1159 tri_y
= 16384 << nv50_miptree(dst
)->ms_y
;
1161 x0
= (float)info
->src
.box
.x
- x_range
* (float)info
->dst
.box
.x
;
1162 y0
= (float)info
->src
.box
.y
- y_range
* (float)info
->dst
.box
.y
;
1164 x1
= x0
+ tri_x
* x_range
;
1165 y1
= y0
+ tri_y
* y_range
;
1167 x0
*= (float)(1 << nv50_miptree(src
)->ms_x
);
1168 x1
*= (float)(1 << nv50_miptree(src
)->ms_x
);
1169 y0
*= (float)(1 << nv50_miptree(src
)->ms_y
);
1170 y1
*= (float)(1 << nv50_miptree(src
)->ms_y
);
1172 /* XXX: multiply by 6 for cube arrays ? */
1173 dz
= (float)info
->src
.box
.depth
/ (float)info
->dst
.box
.depth
;
1174 z
= (float)info
->src
.box
.z
;
1175 if (nv50_miptree(src
)->layout_3d
)
1178 if (src
->last_level
> 0) {
1179 /* If there are mip maps, GPU always assumes normalized coordinates. */
1180 const unsigned l
= info
->src
.level
;
1181 const float fh
= u_minify(src
->width0
<< nv50_miptree(src
)->ms_x
, l
);
1182 const float fv
= u_minify(src
->height0
<< nv50_miptree(src
)->ms_y
, l
);
1187 if (nv50_miptree(src
)->layout_3d
) {
1188 z
/= u_minify(src
->depth0
, l
);
1189 dz
/= u_minify(src
->depth0
, l
);
1193 BEGIN_NV04(push
, NV50_3D(VIEWPORT_TRANSFORM_EN
), 1);
1194 PUSH_DATA (push
, 0);
1195 BEGIN_NV04(push
, NV50_3D(VIEW_VOLUME_CLIP_CTRL
), 1);
1196 PUSH_DATA (push
, 0x1);
1198 /* Draw a large triangle in screen coordinates covering the whole
1199 * render target, with scissors defining the destination region.
1200 * The vertex is supplied with non-normalized texture coordinates
1201 * arranged in a way to yield the desired offset and scale.
1204 minx
= info
->dst
.box
.x
;
1205 maxx
= info
->dst
.box
.x
+ info
->dst
.box
.width
;
1206 miny
= info
->dst
.box
.y
;
1207 maxy
= info
->dst
.box
.y
+ info
->dst
.box
.height
;
1208 if (info
->scissor_enable
) {
1209 minx
= MAX2(minx
, info
->scissor
.minx
);
1210 maxx
= MIN2(maxx
, info
->scissor
.maxx
);
1211 miny
= MAX2(miny
, info
->scissor
.miny
);
1212 maxy
= MIN2(maxy
, info
->scissor
.maxy
);
1214 BEGIN_NV04(push
, NV50_3D(SCISSOR_HORIZ(0)), 2);
1215 PUSH_DATA (push
, (maxx
<< 16) | minx
);
1216 PUSH_DATA (push
, (maxy
<< 16) | miny
);
1218 for (i
= 0; i
< info
->dst
.box
.depth
; ++i
, z
+= dz
) {
1219 if (info
->dst
.box
.z
+ i
) {
1220 BEGIN_NV04(push
, NV50_3D(LAYER
), 1);
1221 PUSH_DATA (push
, info
->dst
.box
.z
+ i
);
1223 PUSH_SPACE(push
, 32);
1224 BEGIN_NV04(push
, NV50_3D(VERTEX_BEGIN_GL
), 1);
1225 PUSH_DATA (push
, NV50_3D_VERTEX_BEGIN_GL_PRIMITIVE_TRIANGLES
);
1226 BEGIN_NV04(push
, NV50_3D(VTX_ATTR_3F_X(1)), 3);
1227 PUSH_DATAf(push
, x0
);
1228 PUSH_DATAf(push
, y0
);
1229 PUSH_DATAf(push
, z
);
1230 BEGIN_NV04(push
, NV50_3D(VTX_ATTR_2F_X(0)), 2);
1231 PUSH_DATAf(push
, 0.0f
);
1232 PUSH_DATAf(push
, 0.0f
);
1233 BEGIN_NV04(push
, NV50_3D(VTX_ATTR_3F_X(1)), 3);
1234 PUSH_DATAf(push
, x1
);
1235 PUSH_DATAf(push
, y0
);
1236 PUSH_DATAf(push
, z
);
1237 BEGIN_NV04(push
, NV50_3D(VTX_ATTR_2F_X(0)), 2);
1238 PUSH_DATAf(push
, tri_x
);
1239 PUSH_DATAf(push
, 0.0f
);
1240 BEGIN_NV04(push
, NV50_3D(VTX_ATTR_3F_X(1)), 3);
1241 PUSH_DATAf(push
, x0
);
1242 PUSH_DATAf(push
, y1
);
1243 PUSH_DATAf(push
, z
);
1244 BEGIN_NV04(push
, NV50_3D(VTX_ATTR_2F_X(0)), 2);
1245 PUSH_DATAf(push
, 0.0f
);
1246 PUSH_DATAf(push
, tri_y
);
1247 BEGIN_NV04(push
, NV50_3D(VERTEX_END_GL
), 1);
1248 PUSH_DATA (push
, 0);
1250 if (info
->dst
.box
.z
+ info
->dst
.box
.depth
- 1) {
1251 BEGIN_NV04(push
, NV50_3D(LAYER
), 1);
1252 PUSH_DATA (push
, 0);
1255 /* re-enable normally constant state */
1257 BEGIN_NV04(push
, NV50_3D(VIEWPORT_TRANSFORM_EN
), 1);
1258 PUSH_DATA (push
, 1);
1260 nv50_blitctx_post_blit(blit
);
1264 nv50_blit_eng2d(struct nv50_context
*nv50
, const struct pipe_blit_info
*info
)
1266 struct nouveau_pushbuf
*push
= nv50
->base
.pushbuf
;
1267 struct nv50_miptree
*dst
= nv50_miptree(info
->dst
.resource
);
1268 struct nv50_miptree
*src
= nv50_miptree(info
->src
.resource
);
1269 const int32_t srcx_adj
= info
->src
.box
.width
< 0 ? -1 : 0;
1270 const int32_t srcy_adj
= info
->src
.box
.height
< 0 ? -1 : 0;
1271 const int32_t dz
= info
->dst
.box
.z
;
1272 const int32_t sz
= info
->src
.box
.z
;
1273 uint32_t dstw
, dsth
;
1276 int64_t du_dx
, dv_dy
;
1279 uint32_t mask
= nv50_blit_eng2d_get_mask(info
);
1282 mode
= nv50_blit_get_filter(info
) ?
1283 NV50_2D_BLIT_CONTROL_FILTER_BILINEAR
:
1284 NV50_2D_BLIT_CONTROL_FILTER_POINT_SAMPLE
;
1285 mode
|= (src
->base
.base
.nr_samples
> dst
->base
.base
.nr_samples
) ?
1286 NV50_2D_BLIT_CONTROL_ORIGIN_CORNER
: NV50_2D_BLIT_CONTROL_ORIGIN_CENTER
;
1288 du_dx
= ((int64_t)info
->src
.box
.width
<< 32) / info
->dst
.box
.width
;
1289 dv_dy
= ((int64_t)info
->src
.box
.height
<< 32) / info
->dst
.box
.height
;
1291 b
= info
->dst
.format
== info
->src
.format
;
1292 nv50_2d_texture_set(push
, 1, dst
, info
->dst
.level
, dz
, info
->dst
.format
, b
);
1293 nv50_2d_texture_set(push
, 0, src
, info
->src
.level
, sz
, info
->src
.format
, b
);
1295 if (info
->scissor_enable
) {
1296 BEGIN_NV04(push
, NV50_2D(CLIP_X
), 5);
1297 PUSH_DATA (push
, info
->scissor
.minx
<< dst
->ms_x
);
1298 PUSH_DATA (push
, info
->scissor
.miny
<< dst
->ms_y
);
1299 PUSH_DATA (push
, (info
->scissor
.maxx
- info
->scissor
.minx
) << dst
->ms_x
);
1300 PUSH_DATA (push
, (info
->scissor
.maxy
- info
->scissor
.miny
) << dst
->ms_y
);
1301 PUSH_DATA (push
, 1); /* enable */
1304 if (nv50
->cond_query
&& info
->render_condition_enable
) {
1305 BEGIN_NV04(push
, NV50_2D(COND_MODE
), 1);
1306 PUSH_DATA (push
, nv50
->cond_condmode
);
1309 if (mask
!= 0xffffffff) {
1310 BEGIN_NV04(push
, NV50_2D(ROP
), 1);
1311 PUSH_DATA (push
, 0xca); /* DPSDxax */
1312 BEGIN_NV04(push
, NV50_2D(PATTERN_COLOR_FORMAT
), 1);
1313 PUSH_DATA (push
, NV50_2D_PATTERN_COLOR_FORMAT_A8R8G8B8
);
1314 BEGIN_NV04(push
, NV50_2D(PATTERN_BITMAP_COLOR(0)), 4);
1315 PUSH_DATA (push
, 0x00000000);
1316 PUSH_DATA (push
, mask
);
1317 PUSH_DATA (push
, 0xffffffff);
1318 PUSH_DATA (push
, 0xffffffff);
1319 BEGIN_NV04(push
, NV50_2D(OPERATION
), 1);
1320 PUSH_DATA (push
, NV50_2D_OPERATION_ROP
);
1322 if (info
->src
.format
!= info
->dst
.format
) {
1323 if (info
->src
.format
== PIPE_FORMAT_R8_UNORM
||
1324 info
->src
.format
== PIPE_FORMAT_R16_UNORM
||
1325 info
->src
.format
== PIPE_FORMAT_R16_FLOAT
||
1326 info
->src
.format
== PIPE_FORMAT_R32_FLOAT
) {
1327 mask
= 0xffff0000; /* also makes condition for OPERATION reset true */
1328 BEGIN_NV04(push
, NV50_2D(BETA4
), 2);
1329 PUSH_DATA (push
, mask
);
1330 PUSH_DATA (push
, NV50_2D_OPERATION_SRCCOPY_PREMULT
);
1334 if (src
->ms_x
> dst
->ms_x
|| src
->ms_y
> dst
->ms_y
) {
1335 /* ms_x is always >= ms_y */
1336 du_dx
<<= src
->ms_x
- dst
->ms_x
;
1337 dv_dy
<<= src
->ms_y
- dst
->ms_y
;
1339 du_dx
>>= dst
->ms_x
- src
->ms_x
;
1340 dv_dy
>>= dst
->ms_y
- src
->ms_y
;
1343 srcx
= (int64_t)(info
->src
.box
.x
+ srcx_adj
) << (src
->ms_x
+ 32);
1344 srcy
= (int64_t)(info
->src
.box
.y
+ srcy_adj
) << (src
->ms_y
+ 32);
1346 if (src
->base
.base
.nr_samples
> dst
->base
.base
.nr_samples
) {
1347 /* center src coorinates for proper MS resolve filtering */
1348 srcx
+= (int64_t)1 << (src
->ms_x
+ 31);
1349 srcy
+= (int64_t)1 << (src
->ms_y
+ 31);
1352 dstx
= info
->dst
.box
.x
<< dst
->ms_x
;
1353 dsty
= info
->dst
.box
.y
<< dst
->ms_y
;
1355 dstw
= info
->dst
.box
.width
<< dst
->ms_x
;
1356 dsth
= info
->dst
.box
.height
<< dst
->ms_y
;
1360 srcx
-= du_dx
* dstx
;
1365 srcy
-= dv_dy
* dsty
;
1369 BEGIN_NV04(push
, NV50_2D(BLIT_CONTROL
), 1);
1370 PUSH_DATA (push
, mode
);
1371 BEGIN_NV04(push
, NV50_2D(BLIT_DST_X
), 4);
1372 PUSH_DATA (push
, dstx
);
1373 PUSH_DATA (push
, dsty
);
1374 PUSH_DATA (push
, dstw
);
1375 PUSH_DATA (push
, dsth
);
1376 BEGIN_NV04(push
, NV50_2D(BLIT_DU_DX_FRACT
), 4);
1377 PUSH_DATA (push
, du_dx
);
1378 PUSH_DATA (push
, du_dx
>> 32);
1379 PUSH_DATA (push
, dv_dy
);
1380 PUSH_DATA (push
, dv_dy
>> 32);
1382 BCTX_REFN(nv50
->bufctx
, 2D
, &dst
->base
, WR
);
1383 BCTX_REFN(nv50
->bufctx
, 2D
, &src
->base
, RD
);
1384 nouveau_pushbuf_bufctx(nv50
->base
.pushbuf
, nv50
->bufctx
);
1385 if (nouveau_pushbuf_validate(nv50
->base
.pushbuf
))
1388 for (i
= 0; i
< info
->dst
.box
.depth
; ++i
) {
1390 /* no scaling in z-direction possible for eng2d blits */
1391 if (dst
->layout_3d
) {
1392 BEGIN_NV04(push
, NV50_2D(DST_LAYER
), 1);
1393 PUSH_DATA (push
, info
->dst
.box
.z
+ i
);
1395 const unsigned z
= info
->dst
.box
.z
+ i
;
1396 const uint64_t address
= dst
->base
.address
+
1397 dst
->level
[info
->dst
.level
].offset
+
1398 z
* dst
->layer_stride
;
1399 BEGIN_NV04(push
, NV50_2D(DST_ADDRESS_HIGH
), 2);
1400 PUSH_DATAh(push
, address
);
1401 PUSH_DATA (push
, address
);
1403 if (src
->layout_3d
) {
1404 /* not possible because of depth tiling */
1407 const unsigned z
= info
->src
.box
.z
+ i
;
1408 const uint64_t address
= src
->base
.address
+
1409 src
->level
[info
->src
.level
].offset
+
1410 z
* src
->layer_stride
;
1411 BEGIN_NV04(push
, NV50_2D(SRC_ADDRESS_HIGH
), 2);
1412 PUSH_DATAh(push
, address
);
1413 PUSH_DATA (push
, address
);
1415 BEGIN_NV04(push
, NV50_2D(BLIT_SRC_Y_INT
), 1); /* trigger */
1416 PUSH_DATA (push
, srcy
>> 32);
1418 BEGIN_NV04(push
, NV50_2D(BLIT_SRC_X_FRACT
), 4);
1419 PUSH_DATA (push
, srcx
);
1420 PUSH_DATA (push
, srcx
>> 32);
1421 PUSH_DATA (push
, srcy
);
1422 PUSH_DATA (push
, srcy
>> 32);
1425 nv50_bufctx_fence(nv50
->bufctx
, false);
1427 nouveau_bufctx_reset(nv50
->bufctx
, NV50_BIND_2D
);
1429 if (info
->scissor_enable
) {
1430 BEGIN_NV04(push
, NV50_2D(CLIP_ENABLE
), 1);
1431 PUSH_DATA (push
, 0);
1433 if (mask
!= 0xffffffff) {
1434 BEGIN_NV04(push
, NV50_2D(OPERATION
), 1);
1435 PUSH_DATA (push
, NV50_2D_OPERATION_SRCCOPY
);
1437 if (nv50
->cond_query
&& info
->render_condition_enable
) {
1438 BEGIN_NV04(push
, NV50_2D(COND_MODE
), 1);
1439 PUSH_DATA (push
, NV50_2D_COND_MODE_ALWAYS
);
1444 nv50_blit(struct pipe_context
*pipe
, const struct pipe_blit_info
*info
)
1446 struct nv50_context
*nv50
= nv50_context(pipe
);
1447 struct nouveau_pushbuf
*push
= nv50
->base
.pushbuf
;
1450 if (util_format_is_depth_or_stencil(info
->dst
.resource
->format
)) {
1451 if (!(info
->mask
& PIPE_MASK_ZS
))
1453 if (info
->dst
.resource
->format
== PIPE_FORMAT_Z32_FLOAT
||
1454 info
->dst
.resource
->format
== PIPE_FORMAT_Z32_FLOAT_S8X24_UINT
)
1456 if (info
->filter
!= PIPE_TEX_FILTER_NEAREST
)
1459 if (!(info
->mask
& PIPE_MASK_RGBA
))
1461 if (info
->mask
!= PIPE_MASK_RGBA
)
1465 if (nv50_miptree(info
->src
.resource
)->layout_3d
) {
1468 if (info
->src
.box
.depth
!= info
->dst
.box
.depth
) {
1470 debug_printf("blit: cannot filter array or cube textures in z direction");
1473 if (!eng3d
&& info
->dst
.format
!= info
->src
.format
) {
1474 if (!nv50_2d_dst_format_faithful(info
->dst
.format
) ||
1475 !nv50_2d_src_format_faithful(info
->src
.format
)) {
1478 if (!nv50_2d_src_format_faithful(info
->src
.format
)) {
1479 if (!util_format_is_luminance(info
->src
.format
)) {
1480 if (util_format_is_intensity(info
->src
.format
))
1483 if (!nv50_2d_dst_format_ops_supported(info
->dst
.format
))
1486 eng3d
= !nv50_2d_format_supported(info
->src
.format
);
1489 if (util_format_is_luminance_alpha(info
->src
.format
))
1493 if (info
->src
.resource
->nr_samples
== 8 &&
1494 info
->dst
.resource
->nr_samples
<= 1)
1497 /* FIXME: can't make this work with eng2d anymore */
1498 if ((info
->src
.resource
->nr_samples
| 1) !=
1499 (info
->dst
.resource
->nr_samples
| 1))
1502 /* FIXME: find correct src coordinate adjustments */
1503 if ((info
->src
.box
.width
!= info
->dst
.box
.width
&&
1504 info
->src
.box
.width
!= -info
->dst
.box
.width
) ||
1505 (info
->src
.box
.height
!= info
->dst
.box
.height
&&
1506 info
->src
.box
.height
!= -info
->dst
.box
.height
))
1509 if (nv50
->screen
->num_occlusion_queries_active
) {
1510 BEGIN_NV04(push
, NV50_3D(SAMPLECNT_ENABLE
), 1);
1511 PUSH_DATA (push
, 0);
1515 nv50_blit_eng2d(nv50
, info
);
1517 nv50_blit_3d(nv50
, info
);
1519 if (nv50
->screen
->num_occlusion_queries_active
) {
1520 BEGIN_NV04(push
, NV50_3D(SAMPLECNT_ENABLE
), 1);
1521 PUSH_DATA (push
, 1);
1526 nv50_flush_resource(struct pipe_context
*ctx
,
1527 struct pipe_resource
*resource
)
1532 nv50_blitter_create(struct nv50_screen
*screen
)
1534 screen
->blitter
= CALLOC_STRUCT(nv50_blitter
);
1535 if (!screen
->blitter
) {
1536 NOUVEAU_ERR("failed to allocate blitter struct\n");
1540 pipe_mutex_init(screen
->blitter
->mutex
);
1542 nv50_blitter_make_vp(screen
->blitter
);
1543 nv50_blitter_make_sampler(screen
->blitter
);
1549 nv50_blitter_destroy(struct nv50_screen
*screen
)
1551 struct nv50_blitter
*blitter
= screen
->blitter
;
1554 for (i
= 0; i
< NV50_BLIT_MAX_TEXTURE_TYPES
; ++i
) {
1555 for (m
= 0; m
< NV50_BLIT_MODES
; ++m
) {
1556 struct nv50_program
*prog
= blitter
->fp
[i
][m
];
1558 nv50_program_destroy(NULL
, prog
);
1559 FREE((void *)prog
->pipe
.tokens
);
1569 nv50_blitctx_create(struct nv50_context
*nv50
)
1571 nv50
->blit
= CALLOC_STRUCT(nv50_blitctx
);
1573 NOUVEAU_ERR("failed to allocate blit context\n");
1577 nv50
->blit
->nv50
= nv50
;
1579 nv50
->blit
->rast
.pipe
.half_pixel_center
= 1;
1585 nv50_init_surface_functions(struct nv50_context
*nv50
)
1587 struct pipe_context
*pipe
= &nv50
->base
.pipe
;
1589 pipe
->resource_copy_region
= nv50_resource_copy_region
;
1590 pipe
->blit
= nv50_blit
;
1591 pipe
->flush_resource
= nv50_flush_resource
;
1592 pipe
->clear_render_target
= nv50_clear_render_target
;
1593 pipe
->clear_depth_stencil
= nv50_clear_depth_stencil
;
1594 pipe
->clear_buffer
= nv50_clear_buffer
;