2 * Copyright 2009 Advanced Micro Devices, Inc.
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 (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
24 * Alex Deucher <alexander.deucher@amd.com>
26 * ------------------------ This file is DEPRECATED! -------------------------
29 #include <drm/radeon_drm.h>
30 #include "radeon_drv.h"
32 #include "r600_blit_shaders.h"
34 /* 23 bits of float fractional data */
35 #define I2F_FRAC_BITS 23
36 #define I2F_MASK ((1 << I2F_FRAC_BITS) - 1)
39 * Converts unsigned integer into 32-bit IEEE floating point representation.
40 * Will be exact from 0 to 2^24. Above that, we round towards zero
41 * as the fractional bits will not fit in a float. (It would be better to
42 * round towards even as the fpu does, but that is slower.)
44 static __pure
uint32_t int2float(uint32_t x
)
46 uint32_t msb
, exponent
, fraction
;
51 /* Get location of the most significant bit */
55 * Use a rotate instead of a shift because that works both leftwards
56 * and rightwards due to the mod(32) behaviour. This means we don't
57 * need to check to see if we are above 2^24 or not.
59 fraction
= ror32(x
, (msb
- I2F_FRAC_BITS
) & 0x1f) & I2F_MASK
;
60 exponent
= (127 + msb
) << I2F_FRAC_BITS
;
62 return fraction
+ exponent
;
65 #define DI_PT_RECTLIST 0x11
66 #define DI_INDEX_SIZE_16_BIT 0x0
67 #define DI_SRC_SEL_AUTO_INDEX 0x2
71 #define FMT_8_8_8_8 0x1a
73 #define COLOR_5_6_5 0x8
74 #define COLOR_8_8_8_8 0x1a
77 set_render_target(drm_radeon_private_t
*dev_priv
, int format
, int w
, int h
, u64 gpu_addr
)
88 cb_color_info
= ((format
<< 2) | (1 << 27));
90 slice
= ((w
* h
) / 64) - 1;
92 if (((dev_priv
->flags
& RADEON_FAMILY_MASK
) > CHIP_R600
) &&
93 ((dev_priv
->flags
& RADEON_FAMILY_MASK
) < CHIP_RV770
)) {
95 OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG
, 1));
96 OUT_RING((R600_CB_COLOR0_BASE
- R600_SET_CONTEXT_REG_OFFSET
) >> 2);
97 OUT_RING(gpu_addr
>> 8);
98 OUT_RING(CP_PACKET3(R600_IT_SURFACE_BASE_UPDATE
, 0));
102 OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG
, 1));
103 OUT_RING((R600_CB_COLOR0_BASE
- R600_SET_CONTEXT_REG_OFFSET
) >> 2);
104 OUT_RING(gpu_addr
>> 8);
107 OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG
, 1));
108 OUT_RING((R600_CB_COLOR0_SIZE
- R600_SET_CONTEXT_REG_OFFSET
) >> 2);
109 OUT_RING((pitch
<< 0) | (slice
<< 10));
111 OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG
, 1));
112 OUT_RING((R600_CB_COLOR0_VIEW
- R600_SET_CONTEXT_REG_OFFSET
) >> 2);
115 OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG
, 1));
116 OUT_RING((R600_CB_COLOR0_INFO
- R600_SET_CONTEXT_REG_OFFSET
) >> 2);
117 OUT_RING(cb_color_info
);
119 OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG
, 1));
120 OUT_RING((R600_CB_COLOR0_TILE
- R600_SET_CONTEXT_REG_OFFSET
) >> 2);
123 OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG
, 1));
124 OUT_RING((R600_CB_COLOR0_FRAG
- R600_SET_CONTEXT_REG_OFFSET
) >> 2);
127 OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG
, 1));
128 OUT_RING((R600_CB_COLOR0_MASK
- R600_SET_CONTEXT_REG_OFFSET
) >> 2);
135 cp_set_surface_sync(drm_radeon_private_t
*dev_priv
,
136 u32 sync_type
, u32 size
, u64 mc_addr
)
142 if (size
== 0xffffffff)
143 cp_coher_size
= 0xffffffff;
145 cp_coher_size
= ((size
+ 255) >> 8);
148 OUT_RING(CP_PACKET3(R600_IT_SURFACE_SYNC
, 3));
150 OUT_RING(cp_coher_size
);
151 OUT_RING((mc_addr
>> 8));
152 OUT_RING(10); /* poll interval */
157 set_shaders(struct drm_device
*dev
)
159 drm_radeon_private_t
*dev_priv
= dev
->dev_private
;
163 uint32_t sq_pgm_resources
;
168 vs
= (u32
*) ((char *)dev
->agp_buffer_map
->handle
+ dev_priv
->blit_vb
->offset
);
169 ps
= (u32
*) ((char *)dev
->agp_buffer_map
->handle
+ dev_priv
->blit_vb
->offset
+ 256);
171 for (i
= 0; i
< r6xx_vs_size
; i
++)
172 vs
[i
] = cpu_to_le32(r6xx_vs
[i
]);
173 for (i
= 0; i
< r6xx_ps_size
; i
++)
174 ps
[i
] = cpu_to_le32(r6xx_ps
[i
]);
176 dev_priv
->blit_vb
->used
= 512;
178 gpu_addr
= dev_priv
->gart_buffers_offset
+ dev_priv
->blit_vb
->offset
;
180 /* setup shader regs */
181 sq_pgm_resources
= (1 << 0);
185 OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG
, 1));
186 OUT_RING((R600_SQ_PGM_START_VS
- R600_SET_CONTEXT_REG_OFFSET
) >> 2);
187 OUT_RING(gpu_addr
>> 8);
189 OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG
, 1));
190 OUT_RING((R600_SQ_PGM_RESOURCES_VS
- R600_SET_CONTEXT_REG_OFFSET
) >> 2);
191 OUT_RING(sq_pgm_resources
);
193 OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG
, 1));
194 OUT_RING((R600_SQ_PGM_CF_OFFSET_VS
- R600_SET_CONTEXT_REG_OFFSET
) >> 2);
198 OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG
, 1));
199 OUT_RING((R600_SQ_PGM_START_PS
- R600_SET_CONTEXT_REG_OFFSET
) >> 2);
200 OUT_RING((gpu_addr
+ 256) >> 8);
202 OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG
, 1));
203 OUT_RING((R600_SQ_PGM_RESOURCES_PS
- R600_SET_CONTEXT_REG_OFFSET
) >> 2);
204 OUT_RING(sq_pgm_resources
| (1 << 28));
206 OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG
, 1));
207 OUT_RING((R600_SQ_PGM_EXPORTS_PS
- R600_SET_CONTEXT_REG_OFFSET
) >> 2);
210 OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG
, 1));
211 OUT_RING((R600_SQ_PGM_CF_OFFSET_PS
- R600_SET_CONTEXT_REG_OFFSET
) >> 2);
215 cp_set_surface_sync(dev_priv
,
216 R600_SH_ACTION_ENA
, 512, gpu_addr
);
220 set_vtx_resource(drm_radeon_private_t
*dev_priv
, u64 gpu_addr
)
222 uint32_t sq_vtx_constant_word2
;
226 sq_vtx_constant_word2
= (((gpu_addr
>> 32) & 0xff) | (16 << 8));
228 sq_vtx_constant_word2
|= (2 << 30);
232 OUT_RING(CP_PACKET3(R600_IT_SET_RESOURCE
, 7));
234 OUT_RING(gpu_addr
& 0xffffffff);
236 OUT_RING(sq_vtx_constant_word2
);
240 OUT_RING(R600_SQ_TEX_VTX_VALID_BUFFER
<< 30);
243 if (((dev_priv
->flags
& RADEON_FAMILY_MASK
) == CHIP_RV610
) ||
244 ((dev_priv
->flags
& RADEON_FAMILY_MASK
) == CHIP_RV620
) ||
245 ((dev_priv
->flags
& RADEON_FAMILY_MASK
) == CHIP_RS780
) ||
246 ((dev_priv
->flags
& RADEON_FAMILY_MASK
) == CHIP_RS880
) ||
247 ((dev_priv
->flags
& RADEON_FAMILY_MASK
) == CHIP_RV710
))
248 cp_set_surface_sync(dev_priv
,
249 R600_TC_ACTION_ENA
, 48, gpu_addr
);
251 cp_set_surface_sync(dev_priv
,
252 R600_VC_ACTION_ENA
, 48, gpu_addr
);
256 set_tex_resource(drm_radeon_private_t
*dev_priv
,
257 int format
, int w
, int h
, int pitch
, u64 gpu_addr
)
259 uint32_t sq_tex_resource_word0
, sq_tex_resource_word1
, sq_tex_resource_word4
;
266 sq_tex_resource_word0
= (1 << 0);
267 sq_tex_resource_word0
|= ((((pitch
>> 3) - 1) << 8) |
270 sq_tex_resource_word1
= (format
<< 26);
271 sq_tex_resource_word1
|= ((h
- 1) << 0);
273 sq_tex_resource_word4
= ((1 << 14) |
280 OUT_RING(CP_PACKET3(R600_IT_SET_RESOURCE
, 7));
282 OUT_RING(sq_tex_resource_word0
);
283 OUT_RING(sq_tex_resource_word1
);
284 OUT_RING(gpu_addr
>> 8);
285 OUT_RING(gpu_addr
>> 8);
286 OUT_RING(sq_tex_resource_word4
);
288 OUT_RING(R600_SQ_TEX_VTX_VALID_TEXTURE
<< 30);
294 set_scissors(drm_radeon_private_t
*dev_priv
, int x1
, int y1
, int x2
, int y2
)
300 OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG
, 2));
301 OUT_RING((R600_PA_SC_SCREEN_SCISSOR_TL
- R600_SET_CONTEXT_REG_OFFSET
) >> 2);
302 OUT_RING((x1
<< 0) | (y1
<< 16));
303 OUT_RING((x2
<< 0) | (y2
<< 16));
305 OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG
, 2));
306 OUT_RING((R600_PA_SC_GENERIC_SCISSOR_TL
- R600_SET_CONTEXT_REG_OFFSET
) >> 2);
307 OUT_RING((x1
<< 0) | (y1
<< 16) | (1 << 31));
308 OUT_RING((x2
<< 0) | (y2
<< 16));
310 OUT_RING(CP_PACKET3(R600_IT_SET_CONTEXT_REG
, 2));
311 OUT_RING((R600_PA_SC_WINDOW_SCISSOR_TL
- R600_SET_CONTEXT_REG_OFFSET
) >> 2);
312 OUT_RING((x1
<< 0) | (y1
<< 16) | (1 << 31));
313 OUT_RING((x2
<< 0) | (y2
<< 16));
318 draw_auto(drm_radeon_private_t
*dev_priv
)
324 OUT_RING(CP_PACKET3(R600_IT_SET_CONFIG_REG
, 1));
325 OUT_RING((R600_VGT_PRIMITIVE_TYPE
- R600_SET_CONFIG_REG_OFFSET
) >> 2);
326 OUT_RING(DI_PT_RECTLIST
);
328 OUT_RING(CP_PACKET3(R600_IT_INDEX_TYPE
, 0));
330 OUT_RING((2 << 2) | DI_INDEX_SIZE_16_BIT
);
332 OUT_RING(DI_INDEX_SIZE_16_BIT
);
335 OUT_RING(CP_PACKET3(R600_IT_NUM_INSTANCES
, 0));
338 OUT_RING(CP_PACKET3(R600_IT_DRAW_INDEX_AUTO
, 1));
340 OUT_RING(DI_SRC_SEL_AUTO_INDEX
);
347 set_default_state(drm_radeon_private_t
*dev_priv
)
350 u32 sq_config
, sq_gpr_resource_mgmt_1
, sq_gpr_resource_mgmt_2
;
351 u32 sq_thread_resource_mgmt
, sq_stack_resource_mgmt_1
, sq_stack_resource_mgmt_2
;
352 int num_ps_gprs
, num_vs_gprs
, num_temp_gprs
, num_gs_gprs
, num_es_gprs
;
353 int num_ps_threads
, num_vs_threads
, num_gs_threads
, num_es_threads
;
354 int num_ps_stack_entries
, num_vs_stack_entries
, num_gs_stack_entries
, num_es_stack_entries
;
357 switch ((dev_priv
->flags
& RADEON_FAMILY_MASK
)) {
364 num_ps_threads
= 136;
368 num_ps_stack_entries
= 128;
369 num_vs_stack_entries
= 128;
370 num_gs_stack_entries
= 0;
371 num_es_stack_entries
= 0;
380 num_ps_threads
= 144;
384 num_ps_stack_entries
= 40;
385 num_vs_stack_entries
= 40;
386 num_gs_stack_entries
= 32;
387 num_es_stack_entries
= 16;
399 num_ps_threads
= 136;
403 num_ps_stack_entries
= 40;
404 num_vs_stack_entries
= 40;
405 num_gs_stack_entries
= 32;
406 num_es_stack_entries
= 16;
414 num_ps_threads
= 136;
418 num_ps_stack_entries
= 40;
419 num_vs_stack_entries
= 40;
420 num_gs_stack_entries
= 32;
421 num_es_stack_entries
= 16;
429 num_ps_threads
= 188;
433 num_ps_stack_entries
= 256;
434 num_vs_stack_entries
= 256;
435 num_gs_stack_entries
= 0;
436 num_es_stack_entries
= 0;
445 num_ps_threads
= 188;
449 num_ps_stack_entries
= 128;
450 num_vs_stack_entries
= 128;
451 num_gs_stack_entries
= 0;
452 num_es_stack_entries
= 0;
460 num_ps_threads
= 144;
464 num_ps_stack_entries
= 128;
465 num_vs_stack_entries
= 128;
466 num_gs_stack_entries
= 0;
467 num_es_stack_entries
= 0;
471 if (((dev_priv
->flags
& RADEON_FAMILY_MASK
) == CHIP_RV610
) ||
472 ((dev_priv
->flags
& RADEON_FAMILY_MASK
) == CHIP_RV620
) ||
473 ((dev_priv
->flags
& RADEON_FAMILY_MASK
) == CHIP_RS780
) ||
474 ((dev_priv
->flags
& RADEON_FAMILY_MASK
) == CHIP_RS880
) ||
475 ((dev_priv
->flags
& RADEON_FAMILY_MASK
) == CHIP_RV710
))
478 sq_config
= R600_VC_ENABLE
;
480 sq_config
|= (R600_DX9_CONSTS
|
481 R600_ALU_INST_PREFER_VECTOR
|
487 sq_gpr_resource_mgmt_1
= (R600_NUM_PS_GPRS(num_ps_gprs
) |
488 R600_NUM_VS_GPRS(num_vs_gprs
) |
489 R600_NUM_CLAUSE_TEMP_GPRS(num_temp_gprs
));
490 sq_gpr_resource_mgmt_2
= (R600_NUM_GS_GPRS(num_gs_gprs
) |
491 R600_NUM_ES_GPRS(num_es_gprs
));
492 sq_thread_resource_mgmt
= (R600_NUM_PS_THREADS(num_ps_threads
) |
493 R600_NUM_VS_THREADS(num_vs_threads
) |
494 R600_NUM_GS_THREADS(num_gs_threads
) |
495 R600_NUM_ES_THREADS(num_es_threads
));
496 sq_stack_resource_mgmt_1
= (R600_NUM_PS_STACK_ENTRIES(num_ps_stack_entries
) |
497 R600_NUM_VS_STACK_ENTRIES(num_vs_stack_entries
));
498 sq_stack_resource_mgmt_2
= (R600_NUM_GS_STACK_ENTRIES(num_gs_stack_entries
) |
499 R600_NUM_ES_STACK_ENTRIES(num_es_stack_entries
));
501 if ((dev_priv
->flags
& RADEON_FAMILY_MASK
) >= CHIP_RV770
) {
502 BEGIN_RING(r7xx_default_size
+ 10);
503 for (i
= 0; i
< r7xx_default_size
; i
++)
504 OUT_RING(r7xx_default_state
[i
]);
506 BEGIN_RING(r6xx_default_size
+ 10);
507 for (i
= 0; i
< r6xx_default_size
; i
++)
508 OUT_RING(r6xx_default_state
[i
]);
510 OUT_RING(CP_PACKET3(R600_IT_EVENT_WRITE
, 0));
511 OUT_RING(R600_CACHE_FLUSH_AND_INV_EVENT
);
513 OUT_RING(CP_PACKET3(R600_IT_SET_CONFIG_REG
, 6));
514 OUT_RING((R600_SQ_CONFIG
- R600_SET_CONFIG_REG_OFFSET
) >> 2);
516 OUT_RING(sq_gpr_resource_mgmt_1
);
517 OUT_RING(sq_gpr_resource_mgmt_2
);
518 OUT_RING(sq_thread_resource_mgmt
);
519 OUT_RING(sq_stack_resource_mgmt_1
);
520 OUT_RING(sq_stack_resource_mgmt_2
);
524 static int r600_nomm_get_vb(struct drm_device
*dev
)
526 drm_radeon_private_t
*dev_priv
= dev
->dev_private
;
527 dev_priv
->blit_vb
= radeon_freelist_get(dev
);
528 if (!dev_priv
->blit_vb
) {
529 DRM_ERROR("Unable to allocate vertex buffer for blit\n");
535 static void r600_nomm_put_vb(struct drm_device
*dev
)
537 drm_radeon_private_t
*dev_priv
= dev
->dev_private
;
539 dev_priv
->blit_vb
->used
= 0;
540 radeon_cp_discard_buffer(dev
, dev_priv
->blit_vb
->file_priv
->master
, dev_priv
->blit_vb
);
543 static void *r600_nomm_get_vb_ptr(struct drm_device
*dev
)
545 drm_radeon_private_t
*dev_priv
= dev
->dev_private
;
546 return (((char *)dev
->agp_buffer_map
->handle
+
547 dev_priv
->blit_vb
->offset
+ dev_priv
->blit_vb
->used
));
551 r600_prepare_blit_copy(struct drm_device
*dev
, struct drm_file
*file_priv
)
553 drm_radeon_private_t
*dev_priv
= dev
->dev_private
;
557 ret
= r600_nomm_get_vb(dev
);
561 dev_priv
->blit_vb
->file_priv
= file_priv
;
563 set_default_state(dev_priv
);
571 r600_done_blit_copy(struct drm_device
*dev
)
573 drm_radeon_private_t
*dev_priv
= dev
->dev_private
;
578 OUT_RING(CP_PACKET3(R600_IT_EVENT_WRITE
, 0));
579 OUT_RING(R600_CACHE_FLUSH_AND_INV_EVENT
);
580 /* wait for 3D idle clean */
581 OUT_RING(CP_PACKET3(R600_IT_SET_CONFIG_REG
, 1));
582 OUT_RING((R600_WAIT_UNTIL
- R600_SET_CONFIG_REG_OFFSET
) >> 2);
583 OUT_RING(RADEON_WAIT_3D_IDLE
| RADEON_WAIT_3D_IDLECLEAN
);
588 r600_nomm_put_vb(dev
);
592 r600_blit_copy(struct drm_device
*dev
,
593 uint64_t src_gpu_addr
, uint64_t dst_gpu_addr
,
596 drm_radeon_private_t
*dev_priv
= dev
->dev_private
;
601 vb
= r600_nomm_get_vb_ptr(dev
);
603 if ((size_bytes
& 3) || (src_gpu_addr
& 3) || (dst_gpu_addr
& 3)) {
607 int cur_size
= size_bytes
;
608 int src_x
= src_gpu_addr
& 255;
609 int dst_x
= dst_gpu_addr
& 255;
611 src_gpu_addr
= src_gpu_addr
& ~255;
612 dst_gpu_addr
= dst_gpu_addr
& ~255;
614 if (!src_x
&& !dst_x
) {
615 h
= (cur_size
/ max_bytes
);
621 cur_size
= max_bytes
;
623 if (cur_size
> max_bytes
)
624 cur_size
= max_bytes
;
625 if (cur_size
> (max_bytes
- dst_x
))
626 cur_size
= (max_bytes
- dst_x
);
627 if (cur_size
> (max_bytes
- src_x
))
628 cur_size
= (max_bytes
- src_x
);
631 if ((dev_priv
->blit_vb
->used
+ 48) > dev_priv
->blit_vb
->total
) {
633 r600_nomm_put_vb(dev
);
634 r600_nomm_get_vb(dev
);
635 if (!dev_priv
->blit_vb
)
638 vb
= r600_nomm_get_vb_ptr(dev
);
641 vb
[0] = int2float(dst_x
);
643 vb
[2] = int2float(src_x
);
646 vb
[4] = int2float(dst_x
);
647 vb
[5] = int2float(h
);
648 vb
[6] = int2float(src_x
);
649 vb
[7] = int2float(h
);
651 vb
[8] = int2float(dst_x
+ cur_size
);
652 vb
[9] = int2float(h
);
653 vb
[10] = int2float(src_x
+ cur_size
);
654 vb
[11] = int2float(h
);
657 set_tex_resource(dev_priv
, FMT_8
,
658 src_x
+ cur_size
, h
, src_x
+ cur_size
,
661 cp_set_surface_sync(dev_priv
,
662 R600_TC_ACTION_ENA
, (src_x
+ cur_size
* h
), src_gpu_addr
);
665 set_render_target(dev_priv
, COLOR_8
,
670 set_scissors(dev_priv
, dst_x
, 0, dst_x
+ cur_size
, h
);
672 /* Vertex buffer setup */
673 vb_addr
= dev_priv
->gart_buffers_offset
+
674 dev_priv
->blit_vb
->offset
+
675 dev_priv
->blit_vb
->used
;
676 set_vtx_resource(dev_priv
, vb_addr
);
681 cp_set_surface_sync(dev_priv
,
682 R600_CB_ACTION_ENA
| R600_CB0_DEST_BASE_ENA
,
683 cur_size
* h
, dst_gpu_addr
);
686 dev_priv
->blit_vb
->used
+= 12 * 4;
688 src_gpu_addr
+= cur_size
* h
;
689 dst_gpu_addr
+= cur_size
* h
;
690 size_bytes
-= cur_size
* h
;
693 max_bytes
= 8192 * 4;
696 int cur_size
= size_bytes
;
697 int src_x
= (src_gpu_addr
& 255);
698 int dst_x
= (dst_gpu_addr
& 255);
700 src_gpu_addr
= src_gpu_addr
& ~255;
701 dst_gpu_addr
= dst_gpu_addr
& ~255;
703 if (!src_x
&& !dst_x
) {
704 h
= (cur_size
/ max_bytes
);
710 cur_size
= max_bytes
;
712 if (cur_size
> max_bytes
)
713 cur_size
= max_bytes
;
714 if (cur_size
> (max_bytes
- dst_x
))
715 cur_size
= (max_bytes
- dst_x
);
716 if (cur_size
> (max_bytes
- src_x
))
717 cur_size
= (max_bytes
- src_x
);
720 if ((dev_priv
->blit_vb
->used
+ 48) > dev_priv
->blit_vb
->total
) {
721 r600_nomm_put_vb(dev
);
722 r600_nomm_get_vb(dev
);
723 if (!dev_priv
->blit_vb
)
727 vb
= r600_nomm_get_vb_ptr(dev
);
730 vb
[0] = int2float(dst_x
/ 4);
732 vb
[2] = int2float(src_x
/ 4);
735 vb
[4] = int2float(dst_x
/ 4);
736 vb
[5] = int2float(h
);
737 vb
[6] = int2float(src_x
/ 4);
738 vb
[7] = int2float(h
);
740 vb
[8] = int2float((dst_x
+ cur_size
) / 4);
741 vb
[9] = int2float(h
);
742 vb
[10] = int2float((src_x
+ cur_size
) / 4);
743 vb
[11] = int2float(h
);
746 set_tex_resource(dev_priv
, FMT_8_8_8_8
,
747 (src_x
+ cur_size
) / 4,
748 h
, (src_x
+ cur_size
) / 4,
751 cp_set_surface_sync(dev_priv
,
752 R600_TC_ACTION_ENA
, (src_x
+ cur_size
* h
), src_gpu_addr
);
755 set_render_target(dev_priv
, COLOR_8_8_8_8
,
756 (dst_x
+ cur_size
) / 4, h
,
760 set_scissors(dev_priv
, (dst_x
/ 4), 0, (dst_x
+ cur_size
/ 4), h
);
762 /* Vertex buffer setup */
763 vb_addr
= dev_priv
->gart_buffers_offset
+
764 dev_priv
->blit_vb
->offset
+
765 dev_priv
->blit_vb
->used
;
766 set_vtx_resource(dev_priv
, vb_addr
);
771 cp_set_surface_sync(dev_priv
,
772 R600_CB_ACTION_ENA
| R600_CB0_DEST_BASE_ENA
,
773 cur_size
* h
, dst_gpu_addr
);
776 dev_priv
->blit_vb
->used
+= 12 * 4;
778 src_gpu_addr
+= cur_size
* h
;
779 dst_gpu_addr
+= cur_size
* h
;
780 size_bytes
-= cur_size
* h
;
786 r600_blit_swap(struct drm_device
*dev
,
787 uint64_t src_gpu_addr
, uint64_t dst_gpu_addr
,
788 int sx
, int sy
, int dx
, int dy
,
789 int w
, int h
, int src_pitch
, int dst_pitch
, int cpp
)
791 drm_radeon_private_t
*dev_priv
= dev
->dev_private
;
792 int cb_format
, tex_format
;
793 int sx2
, sy2
, dx2
, dy2
;
797 if ((dev_priv
->blit_vb
->used
+ 48) > dev_priv
->blit_vb
->total
) {
799 r600_nomm_put_vb(dev
);
800 r600_nomm_get_vb(dev
);
801 if (!dev_priv
->blit_vb
)
806 vb
= r600_nomm_get_vb_ptr(dev
);
813 vb
[0] = int2float(dx
);
814 vb
[1] = int2float(dy
);
815 vb
[2] = int2float(sx
);
816 vb
[3] = int2float(sy
);
818 vb
[4] = int2float(dx
);
819 vb
[5] = int2float(dy2
);
820 vb
[6] = int2float(sx
);
821 vb
[7] = int2float(sy2
);
823 vb
[8] = int2float(dx2
);
824 vb
[9] = int2float(dy2
);
825 vb
[10] = int2float(sx2
);
826 vb
[11] = int2float(sy2
);
830 cb_format
= COLOR_8_8_8_8
;
831 tex_format
= FMT_8_8_8_8
;
834 cb_format
= COLOR_5_6_5
;
835 tex_format
= FMT_5_6_5
;
844 set_tex_resource(dev_priv
, tex_format
,
846 sy2
, src_pitch
/ cpp
,
849 cp_set_surface_sync(dev_priv
,
850 R600_TC_ACTION_ENA
, src_pitch
* sy2
, src_gpu_addr
);
853 set_render_target(dev_priv
, cb_format
,
854 dst_pitch
/ cpp
, dy2
,
858 set_scissors(dev_priv
, dx
, dy
, dx2
, dy2
);
860 /* Vertex buffer setup */
861 vb_addr
= dev_priv
->gart_buffers_offset
+
862 dev_priv
->blit_vb
->offset
+
863 dev_priv
->blit_vb
->used
;
864 set_vtx_resource(dev_priv
, vb_addr
);
869 cp_set_surface_sync(dev_priv
,
870 R600_CB_ACTION_ENA
| R600_CB0_DEST_BASE_ENA
,
871 dst_pitch
* dy2
, dst_gpu_addr
);
873 dev_priv
->blit_vb
->used
+= 12 * 4;