1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
|
/*
* Copyright 2007 Ben Skeggs
* Copyright 2007 Stephane Marchesin
* Copyright 2007 Jeremy Kolb
* Copyright 2007 Patrice Mandin
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#include "nv_include.h"
#include "hwdefs/nv_object.xml.h"
#include "hwdefs/nv30-40_3d.xml.h"
#include "nv04_accel.h"
typedef struct nv_pict_surface_format {
int pict_fmt;
uint32_t card_fmt;
} nv_pict_surface_format_t;
typedef struct nv_pict_texture_format {
int pict_fmt;
uint32_t card_fmt;
uint32_t card_swz;
} nv_pict_texture_format_t;
typedef struct nv_pict_op {
Bool src_alpha;
Bool dst_alpha;
uint32_t src_card_op;
uint32_t dst_card_op;
} nv_pict_op_t;
typedef struct nv30_exa_state {
Bool have_mask;
struct {
PictTransformPtr transform;
float width;
float height;
} unit[2];
} nv30_exa_state_t;
static nv30_exa_state_t exa_state;
#define NV30EXA_STATE nv30_exa_state_t *state = &exa_state
static nv_pict_surface_format_t
NV30SurfaceFormat[] = {
{ PICT_a8r8g8b8 , 0x148 },
{ PICT_a8b8g8r8 , 0x150 },
{ PICT_x8r8g8b8 , 0x145 },
{ PICT_x8b8g8r8 , 0x14f },
{ PICT_r5g6b5 , 0x143 },
{ PICT_a8 , 0x149 },
{ PICT_x1r5g5b5 , 0x142 },
};
static nv_pict_surface_format_t *
NV30_GetPictSurfaceFormat(int format)
{
int i;
for(i=0;i<sizeof(NV30SurfaceFormat)/sizeof(NV30SurfaceFormat[0]);i++)
{
if (NV30SurfaceFormat[i].pict_fmt == format)
return &NV30SurfaceFormat[i];
}
return NULL;
}
/* should be in nouveau_reg.h at some point.. */
#define NV30_3D_TEX_SWIZZLE_UNIT_S0_X_ZERO 0
#define NV30_3D_TEX_SWIZZLE_UNIT_S0_X_ONE 1
#define NV30_3D_TEX_SWIZZLE_UNIT_S0_X_S1 2
#define NV30_3D_TEX_SWIZZLE_UNIT_S0_X_SHIFT 14
#define NV30_3D_TEX_SWIZZLE_UNIT_S0_Y_SHIFT 12
#define NV30_3D_TEX_SWIZZLE_UNIT_S0_Z_SHIFT 10
#define NV30_3D_TEX_SWIZZLE_UNIT_S0_W_SHIFT 8
#define NV30_3D_TEX_SWIZZLE_UNIT_S1_X_X 3
#define NV30_3D_TEX_SWIZZLE_UNIT_S1_X_Y 2
#define NV30_3D_TEX_SWIZZLE_UNIT_S1_X_Z 1
#define NV30_3D_TEX_SWIZZLE_UNIT_S1_X_W 0
#define NV30_3D_TEX_SWIZZLE_UNIT_S1_X_SHIFT 6
#define NV30_3D_TEX_SWIZZLE_UNIT_S1_Y_SHIFT 4
#define NV30_3D_TEX_SWIZZLE_UNIT_S1_Z_SHIFT 2
#define NV30_3D_TEX_SWIZZLE_UNIT_S1_W_SHIFT 0
#define _(r,tf,ts0x,ts0y,ts0z,ts0w,ts1x,ts1y,ts1z,ts1w) \
{ \
PICT_##r, \
(tf), \
(NV30_3D_TEX_SWIZZLE_UNIT_S0_X_##ts0x << NV30_3D_TEX_SWIZZLE_UNIT_S0_X_SHIFT)|\
(NV30_3D_TEX_SWIZZLE_UNIT_S0_X_##ts0y << NV30_3D_TEX_SWIZZLE_UNIT_S0_Y_SHIFT)|\
(NV30_3D_TEX_SWIZZLE_UNIT_S0_X_##ts0z << NV30_3D_TEX_SWIZZLE_UNIT_S0_Z_SHIFT)|\
(NV30_3D_TEX_SWIZZLE_UNIT_S0_X_##ts0w << NV30_3D_TEX_SWIZZLE_UNIT_S0_W_SHIFT)|\
(NV30_3D_TEX_SWIZZLE_UNIT_S1_X_##ts1x << NV30_3D_TEX_SWIZZLE_UNIT_S1_X_SHIFT)|\
(NV30_3D_TEX_SWIZZLE_UNIT_S1_X_##ts1y << NV30_3D_TEX_SWIZZLE_UNIT_S1_Y_SHIFT)|\
(NV30_3D_TEX_SWIZZLE_UNIT_S1_X_##ts1z << NV30_3D_TEX_SWIZZLE_UNIT_S1_Z_SHIFT)|\
(NV30_3D_TEX_SWIZZLE_UNIT_S1_X_##ts1w << NV30_3D_TEX_SWIZZLE_UNIT_S1_W_SHIFT)\
}
static nv_pict_texture_format_t
NV30TextureFormat[] = {
_(a8r8g8b8, 0x12, S1, S1, S1, S1, X, Y, Z, W),
_(a8b8g8r8, 0x12, S1, S1, S1, S1, Z, Y, X, W),
_(x8r8g8b8, 0x12, S1, S1, S1, ONE, X, Y, Z, W),
_(x8b8g8r8, 0x12, S1, S1, S1, ONE, Z, Y, X, W),
_(a1r5g5b5, 0x10, S1, S1, S1, S1, X, Y, Z, W),
_(x1r5g5b5, 0x10, S1, S1, S1, ONE, X, Y, Z, W),
_(a1b5g5r5, 0x10, S1, S1, S1, S1, Z, Y, X, W),
_(x1b5g5r5, 0x10, S1, S1, S1, ONE, Z, Y, X, W),
_(x4r4g4b4, 0x1d, S1, S1, S1, ONE, X, Y, Z, W),
_(a4r4g4b4, 0x1d, S1, S1, S1, S1, X, Y, Z, W),
_(x4b4g4r4, 0x1d, S1, S1, S1, ONE, Z, Y, X, W),
_(a4b4g4r4, 0x1d, S1, S1, S1, S1, Z, Y, X, W),
_( a8, 0x1b, ZERO, ZERO, ZERO, S1, X, X, X, X),
_( r5g6b5, 0x11, S1, S1, S1, ONE, X, Y, Z, W),
_( b5g6r5, 0x11, S1, S1, S1, ONE, Z, Y, X, W),
};
static nv_pict_texture_format_t *
NV30_GetPictTextureFormat(int format)
{
int i;
for(i=0;i<sizeof(NV30TextureFormat)/sizeof(NV30TextureFormat[0]);i++)
{
if (NV30TextureFormat[i].pict_fmt == format)
return &NV30TextureFormat[i];
}
return NULL;
}
#define NV30_3D_BF_ZERO 0x0000
#define NV30_3D_BF_ONE 0x0001
#define NV30_3D_BF_SRC_COLOR 0x0300
#define NV30_3D_BF_ONE_MINUS_SRC_COLOR 0x0301
#define NV30_3D_BF_SRC_ALPHA 0x0302
#define NV30_3D_BF_ONE_MINUS_SRC_ALPHA 0x0303
#define NV30_3D_BF_DST_ALPHA 0x0304
#define NV30_3D_BF_ONE_MINUS_DST_ALPHA 0x0305
#define NV30_3D_BF_DST_COLOR 0x0306
#define NV30_3D_BF_ONE_MINUS_DST_COLOR 0x0307
#define NV30_3D_BF_ALPHA_SATURATE 0x0308
#define BF(bf) NV30_3D_BF_##bf
static nv_pict_op_t
NV30PictOp[] = {
/* Clear */ { 0, 0, BF( ZERO), BF( ZERO) },
/* Src */ { 0, 0, BF( ONE), BF( ZERO) },
/* Dst */ { 0, 0, BF( ZERO), BF( ONE) },
/* Over */ { 1, 0, BF( ONE), BF(ONE_MINUS_SRC_ALPHA) },
/* OverReverse */ { 0, 1, BF(ONE_MINUS_DST_ALPHA), BF( ONE) },
/* In */ { 0, 1, BF( DST_ALPHA), BF( ZERO) },
/* InReverse */ { 1, 0, BF( ZERO), BF( SRC_ALPHA) },
/* Out */ { 0, 1, BF(ONE_MINUS_DST_ALPHA), BF( ZERO) },
/* OutReverse */ { 1, 0, BF( ZERO), BF(ONE_MINUS_SRC_ALPHA) },
/* Atop */ { 1, 1, BF( DST_ALPHA), BF(ONE_MINUS_SRC_ALPHA) },
/* AtopReverse */ { 1, 1, BF(ONE_MINUS_DST_ALPHA), BF( SRC_ALPHA) },
/* Xor */ { 1, 1, BF(ONE_MINUS_DST_ALPHA), BF(ONE_MINUS_SRC_ALPHA) },
/* Add */ { 0, 0, BF( ONE), BF( ONE) }
};
static nv_pict_op_t *
NV30_GetPictOpRec(int op)
{
if (op >= PictOpSaturate)
return NULL;
#if 0
switch(op)
{
case 0:ErrorF("Op Clear\n");break;
case 1:ErrorF("Op Src\n");break;
case 2:ErrorF("Op Dst\n");break;
case 3:ErrorF("Op Over\n");break;
case 4:ErrorF("Op OverReverse\n");break;
case 5:ErrorF("Op In\n");break;
case 6:ErrorF("Op InReverse\n");break;
case 7:ErrorF("Op Out\n");break;
case 8:ErrorF("Op OutReverse\n");break;
case 9:ErrorF("Op Atop\n");break;
case 10:ErrorF("Op AtopReverse\n");break;
case 11:ErrorF("Op Xor\n");break;
case 12:ErrorF("Op Add\n");break;
}
#endif
return &NV30PictOp[op];
}
static void
NV30_SetupBlend(ScrnInfoPtr pScrn, nv_pict_op_t *blend,
PictFormatShort dest_format, Bool component_alpha)
{
NVPtr pNv = NVPTR(pScrn);
struct nouveau_pushbuf *push = pNv->pushbuf;
uint32_t sblend, dblend;
sblend = blend->src_card_op;
dblend = blend->dst_card_op;
if (blend->dst_alpha) {
if (!PICT_FORMAT_A(dest_format)) {
if (sblend == BF(DST_ALPHA)) {
sblend = BF(ONE);
} else if (sblend == BF(ONE_MINUS_DST_ALPHA)) {
sblend = BF(ZERO);
}
} else if (dest_format == PICT_a8) {
if (sblend == BF(DST_ALPHA)) {
sblend = BF(DST_COLOR);
} else if (sblend == BF(ONE_MINUS_DST_ALPHA)) {
sblend = BF(ONE_MINUS_DST_COLOR);
}
}
}
if (blend->src_alpha && (component_alpha || dest_format == PICT_a8)) {
if (dblend == BF(SRC_ALPHA)) {
dblend = BF(SRC_COLOR);
} else if (dblend == BF(ONE_MINUS_SRC_ALPHA)) {
dblend = BF(ONE_MINUS_SRC_COLOR);
}
}
if (sblend == BF(ONE) && dblend == BF(ZERO)) {
BEGIN_NV04(push, NV30_3D(BLEND_FUNC_ENABLE), 1);
PUSH_DATA (push, 0);
} else {
BEGIN_NV04(push, NV30_3D(BLEND_FUNC_ENABLE), 3);
PUSH_DATA (push, 1);
PUSH_DATA (push, (sblend << 16) | sblend);
PUSH_DATA (push, (dblend << 16) | dblend);
}
}
static Bool
NV30EXATexture(ScrnInfoPtr pScrn, PixmapPtr pPix, PicturePtr pPict, int unit)
{
NVPtr pNv = NVPTR(pScrn);
struct nouveau_pushbuf *push = pNv->pushbuf;
struct nouveau_bo *bo = nouveau_pixmap_bo(pPix);
nv_pict_texture_format_t *fmt;
unsigned reloc = NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD;
uint32_t pitch = exaGetPixmapPitch(pPix);
uint32_t log2h = log2i(pPix->drawable.height);
uint32_t log2w = log2i(pPix->drawable.width);
uint32_t card_filter, card_repeat;
NV30EXA_STATE;
fmt = NV30_GetPictTextureFormat(pPict->format);
if (!fmt)
return FALSE;
card_repeat = 3; /* repeatNone */
if (pPict->filter == PictFilterBilinear)
card_filter = 2;
else
card_filter = 1;
BEGIN_NV04(push, NV30_3D(TEX_OFFSET(unit)), 8);
PUSH_MTHDl(push, NV30_3D(TEX_OFFSET(unit)), bo, 0, reloc);
PUSH_MTHDs(push, NV30_3D(TEX_FORMAT(unit)), bo, (1 << 16) | 8 |
NV30_3D_TEX_FORMAT_DIMS_2D |
(fmt->card_fmt << NV30_3D_TEX_FORMAT_FORMAT__SHIFT) |
(log2w << NV30_3D_TEX_FORMAT_BASE_SIZE_U__SHIFT) |
(log2h << NV30_3D_TEX_FORMAT_BASE_SIZE_V__SHIFT),
reloc, NV30_3D_TEX_FORMAT_DMA0,
NV30_3D_TEX_FORMAT_DMA1);
PUSH_DATA (push, (card_repeat << NV30_3D_TEX_WRAP_S__SHIFT) |
(card_repeat << NV30_3D_TEX_WRAP_T__SHIFT) |
(card_repeat << NV30_3D_TEX_WRAP_R__SHIFT));
PUSH_DATA (push, NV30_3D_TEX_ENABLE_ENABLE);
PUSH_DATA (push, (pitch << NV30_3D_TEX_SWIZZLE_RECT_PITCH__SHIFT ) |
fmt->card_swz);
PUSH_DATA (push, (card_filter << NV30_3D_TEX_FILTER_MIN__SHIFT) |
(card_filter << NV30_3D_TEX_FILTER_MAG__SHIFT) |
0x2000 /* engine lock */);
PUSH_DATA (push, (pPix->drawable.width <<
NV30_3D_TEX_NPOT_SIZE_W__SHIFT) |
pPix->drawable.height);
PUSH_DATA (push, 0x00000000); /* border ARGB */
state->unit[unit].width = (float)pPix->drawable.width;
state->unit[unit].height = (float)pPix->drawable.height;
state->unit[unit].transform = pPict->transform;
return TRUE;
}
static Bool
NV30_SetupSurface(ScrnInfoPtr pScrn, PixmapPtr pPix, PicturePtr pPict)
{
NVPtr pNv = NVPTR(pScrn);
struct nouveau_pushbuf *push = pNv->pushbuf;
struct nouveau_bo *bo = nouveau_pixmap_bo(pPix);
uint32_t pitch = exaGetPixmapPitch(pPix);
nv_pict_surface_format_t *fmt;
fmt = NV30_GetPictSurfaceFormat(pPict->format);
if (!fmt) {
ErrorF("AIII no format\n");
return FALSE;
}
BEGIN_NV04(push, NV30_3D(RT_FORMAT), 3);
PUSH_DATA (push, fmt->card_fmt); /* format */
PUSH_DATA (push, pitch << 16 | pitch);
PUSH_MTHDl(push, NV30_3D(COLOR0_OFFSET), bo, 0,
NOUVEAU_BO_VRAM | NOUVEAU_BO_RDWR);
return TRUE;
}
static Bool
NV30EXACheckCompositeTexture(PicturePtr pPict, PicturePtr pdPict, int op)
{
nv_pict_texture_format_t *fmt;
int w, h;
if (!pPict->pDrawable)
NOUVEAU_FALLBACK("Solid and gradient pictures unsupported\n");
w = pPict->pDrawable->width;
h = pPict->pDrawable->height;
if ((w > 4096) || (h > 4096))
NOUVEAU_FALLBACK("picture too large, %dx%d\n", w, h);
fmt = NV30_GetPictTextureFormat(pPict->format);
if (!fmt)
NOUVEAU_FALLBACK("picture format 0x%08x not supported\n",
pPict->format);
if (pPict->filter != PictFilterNearest &&
pPict->filter != PictFilterBilinear)
NOUVEAU_FALLBACK("filter 0x%x not supported\n", pPict->filter);
if (!(w==1 && h==1) && pPict->repeat && pPict->repeatType != RepeatNone)
NOUVEAU_FALLBACK("repeat 0x%x not supported (surface %dx%d)\n",
pPict->repeatType,w,h);
/* Opengl and Render disagree on what should be sampled outside an XRGB
* texture (with no repeating). Opengl has a hardcoded alpha value of
* 1.0, while render expects 0.0. We assume that clipping is done for
* untranformed sources.
*/
if (NV30PictOp[op].src_alpha && !pPict->repeat &&
pPict->transform && (PICT_FORMAT_A(pPict->format) == 0)
&& (PICT_FORMAT_A(pdPict->format) != 0))
NOUVEAU_FALLBACK("REPEAT_NONE unsupported for XRGB source\n");
return TRUE;
}
Bool
NV30EXACheckComposite(int op, PicturePtr psPict,
PicturePtr pmPict,
PicturePtr pdPict)
{
nv_pict_surface_format_t *fmt;
nv_pict_op_t *opr;
opr = NV30_GetPictOpRec(op);
if (!opr)
NOUVEAU_FALLBACK("unsupported blend op 0x%x\n", op);
fmt = NV30_GetPictSurfaceFormat(pdPict->format);
if (!fmt)
NOUVEAU_FALLBACK("dst picture format 0x%08x not supported\n",
pdPict->format);
if (!NV30EXACheckCompositeTexture(psPict, pdPict, op))
NOUVEAU_FALLBACK("src picture\n");
if (pmPict) {
if (pmPict->componentAlpha &&
PICT_FORMAT_RGB(pmPict->format) &&
opr->src_alpha && opr->src_card_op != BF(ZERO))
NOUVEAU_FALLBACK("mask CA + SA\n");
if (!NV30EXACheckCompositeTexture(pmPict, pdPict, op))
NOUVEAU_FALLBACK("mask picture\n");
}
return TRUE;
}
Bool
NV30EXAPrepareComposite(int op, PicturePtr psPict,
PicturePtr pmPict,
PicturePtr pdPict,
PixmapPtr psPix,
PixmapPtr pmPix,
PixmapPtr pdPix)
{
ScrnInfoPtr pScrn = xf86Screens[psPix->drawable.pScreen->myNum];
NVPtr pNv = NVPTR(pScrn);
nv_pict_op_t *blend = NV30_GetPictOpRec(op);
struct nouveau_pushbuf *push = pNv->pushbuf;
uint32_t fragprog;
NV30EXA_STATE;
if (!PUSH_SPACE(push, 128))
return FALSE;
PUSH_RESET(push);
NV30_SetupBlend(pScrn, blend, pdPict->format,
(pmPict && pmPict->componentAlpha &&
PICT_FORMAT_RGB(pmPict->format)));
if (!NV30_SetupSurface(pScrn, pdPix, pdPict) ||
!NV30EXATexture(pScrn, psPix, psPict, 0))
return FALSE;
if (pmPict) {
if (!NV30EXATexture(pScrn, pmPix, pmPict, 1))
return FALSE;
if (pdPict->format == PICT_a8) {
fragprog = PFP_C_A8;
} else
if (pmPict->componentAlpha && PICT_FORMAT_RGB(pmPict->format)) {
if (blend->src_alpha)
fragprog = PFP_CCASA;
else
fragprog = PFP_CCA;
} else {
fragprog = PFP_C;
}
state->have_mask = TRUE;
} else {
if (pdPict->format == PICT_a8)
fragprog = PFP_S_A8;
else
fragprog = PFP_S;
state->have_mask = FALSE;
}
BEGIN_NV04(push, NV30_3D(FP_ACTIVE_PROGRAM), 1);
PUSH_MTHD (push, NV30_3D(FP_ACTIVE_PROGRAM), pNv->scratch, fragprog,
NOUVEAU_BO_VRAM | NOUVEAU_BO_RD | NOUVEAU_BO_LOW |
NOUVEAU_BO_OR,
NV30_3D_FP_ACTIVE_PROGRAM_DMA0,
NV30_3D_FP_ACTIVE_PROGRAM_DMA1);
BEGIN_NV04(push, NV30_3D(FP_REG_CONTROL), 1);
PUSH_DATA (push, 0x0001000f);
BEGIN_NV04(push, NV30_3D(FP_CONTROL), 1);
PUSH_DATA (push, 0x00000000);
BEGIN_NV04(push, NV30_3D(TEX_UNITS_ENABLE), 1);
PUSH_DATA (push, pmPict ? 3 : 1);
nouveau_pushbuf_bufctx(push, pNv->bufctx);
if (nouveau_pushbuf_validate(push)) {
nouveau_pushbuf_bufctx(push, NULL);
return FALSE;
}
return TRUE;
}
static void
NV30EXATransformCoord(PictTransformPtr t, int x, int y, float sx, float sy,
float *x_ret, float *y_ret)
{
PictVector v;
if (t) {
v.vector[0] = IntToxFixed(x);
v.vector[1] = IntToxFixed(y);
v.vector[2] = xFixed1;
PictureTransformPoint(t, &v);
*x_ret = xFixedToFloat(v.vector[0]);
*y_ret = xFixedToFloat(v.vector[1]);
} else {
*x_ret = (float)x;
*y_ret = (float)y;
}
}
#define CV_OUTm(sx,sy,mx,my,dx,dy) do { \
BEGIN_NV04(push, NV30_3D(VTX_ATTR_2F_X(8)), 4); \
PUSH_DATAf(push, (sx)); PUSH_DATAf(push, (sy)); \
PUSH_DATAf(push, (mx)); PUSH_DATAf(push, (my)); \
BEGIN_NV04(push, NV30_3D(VTX_ATTR_2I(0)), 1); \
PUSH_DATA (push, ((dy)<<16)|(dx)); \
} while(0)
#define CV_OUT(sx,sy,dx,dy) do { \
BEGIN_NV04(push, NV30_3D(VTX_ATTR_2F_X(8)), 2); \
PUSH_DATAf(push, (sx)); PUSH_DATAf(push, (sy)); \
BEGIN_NV04(push, NV30_3D(VTX_ATTR_2I(0)), 1); \
PUSH_DATA (push, ((dy)<<16)|(dx)); \
} while(0)
void
NV30EXAComposite(PixmapPtr pdPix, int srcX , int srcY,
int maskX, int maskY,
int dstX , int dstY,
int width, int height)
{
ScrnInfoPtr pScrn = xf86Screens[pdPix->drawable.pScreen->myNum];
NVPtr pNv = NVPTR(pScrn);
struct nouveau_pushbuf *push = pNv->pushbuf;
float sX0, sX1, sX2, sY0, sY1, sY2;
float mX0, mX1, mX2, mY0, mY1, mY2;
NV30EXA_STATE;
if (!PUSH_SPACE(push, 64))
return;
/* We're drawing a triangle, we need to scissor it to a quad. */
/* The scissors are here for a good reason, we don't get the full
* image, but just a part. */
/* Handling the cliprects is done for us already. */
BEGIN_NV04(push, NV30_3D(SCISSOR_HORIZ), 2);
PUSH_DATA (push, (width << 16) | dstX);
PUSH_DATA (push, (height << 16) | dstY);
BEGIN_NV04(push, NV30_3D(VERTEX_BEGIN_END), 1);
PUSH_DATA (push, NV30_3D_VERTEX_BEGIN_END_TRIANGLES);
NV30EXATransformCoord(state->unit[0].transform,
srcX, srcY - height,
state->unit[0].width,
state->unit[0].height, &sX0, &sY0);
NV30EXATransformCoord(state->unit[0].transform,
srcX, srcY + height,
state->unit[0].width,
state->unit[0].height, &sX1, &sY1);
NV30EXATransformCoord(state->unit[0].transform,
srcX + 2*width, srcY + height,
state->unit[0].width,
state->unit[0].height, &sX2, &sY2);
if (state->have_mask) {
NV30EXATransformCoord(state->unit[1].transform,
maskX, maskY - height,
state->unit[1].width,
state->unit[1].height, &mX0, &mY0);
NV30EXATransformCoord(state->unit[1].transform,
maskX, maskY + height,
state->unit[1].width,
state->unit[1].height, &mX1, &mY1);
NV30EXATransformCoord(state->unit[1].transform,
maskX + 2*width, maskY + height,
state->unit[1].width,
state->unit[1].height, &mX2, &mY2);
CV_OUTm(sX0, sY0, mX0, mY0, dstX, dstY - height);
CV_OUTm(sX1, sY1, mX1, mY1, dstX, dstY + height);
CV_OUTm(sX2, sY2, mX2, mY2, dstX + 2 * width, dstY + height);
} else {
CV_OUT(sX0, sY0, dstX , dstY - height);
CV_OUT(sX1, sY1, dstX , dstY + height);
CV_OUT(sX2, sY2, dstX + 2 * width, dstY + height);
}
BEGIN_NV04(push, NV30_3D(VERTEX_BEGIN_END), 1);
PUSH_DATA (push, 0);
}
void
NV30EXADoneComposite(PixmapPtr pdPix)
{
ScrnInfoPtr pScrn = xf86Screens[pdPix->drawable.pScreen->myNum];
nouveau_pushbuf_bufctx(NVPTR(pScrn)->pushbuf, NULL);
}
Bool
NVAccelInitNV30TCL(ScrnInfoPtr pScrn)
{
NVPtr pNv = NVPTR(pScrn);
struct nouveau_pushbuf *push = pNv->pushbuf;
struct nv04_fifo *fifo = pNv->channel->data;
uint32_t class = 0, chipset;
int i;
NVXVComputeBicubicFilter(pNv->scratch, XV_TABLE, XV_TABLE_SIZE);
#define NV30TCL_CHIPSET_3X_MASK 0x00000003
#define NV35TCL_CHIPSET_3X_MASK 0x000001e0
#define NV30_3D_CHIPSET_3X_MASK 0x00000010
chipset = pNv->dev->chipset;
if ((chipset & 0xf0) != NV_ARCH_30)
return TRUE;
chipset &= 0xf;
if (NV30TCL_CHIPSET_3X_MASK & (1<<chipset))
class = NV30_3D_CLASS;
else if (NV35TCL_CHIPSET_3X_MASK & (1<<chipset))
class = NV35_3D_CLASS;
else if (NV30_3D_CHIPSET_3X_MASK & (1<<chipset))
class = NV34_3D_CLASS;
else {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"NV30EXA: Unknown chipset NV3%1x\n", chipset);
return FALSE;
}
if (nouveau_object_new(pNv->channel, Nv3D, class, NULL, 0, &pNv->Nv3D))
return FALSE;
if (!PUSH_SPACE(push, 256))
return FALSE;
BEGIN_NV04(push, NV01_SUBC(3D, OBJECT), 1);
PUSH_DATA (push, pNv->Nv3D->handle);
BEGIN_NV04(push, NV30_3D(DMA_TEXTURE0), 3);
PUSH_DATA (push, fifo->vram);
PUSH_DATA (push, fifo->gart);
PUSH_DATA (push, fifo->vram);
BEGIN_NV04(push, NV30_3D(DMA_UNK1AC), 1);
PUSH_DATA (push, fifo->vram);
BEGIN_NV04(push, NV30_3D(DMA_COLOR0), 2);
PUSH_DATA (push, fifo->vram);
PUSH_DATA (push, fifo->vram);
BEGIN_NV04(push, NV30_3D(DMA_UNK1B0), 1);
PUSH_DATA (push, fifo->vram);
for (i=1; i<8; i++) {
BEGIN_NV04(push, NV30_3D(VIEWPORT_CLIP_HORIZ(i)), 2);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
}
BEGIN_NV04(push, SUBC_3D(0x220), 1);
PUSH_DATA (push, 1);
BEGIN_NV04(push, SUBC_3D(0x03b0), 1);
PUSH_DATA (push, 0x00100000);
BEGIN_NV04(push, SUBC_3D(0x1454), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, SUBC_3D(0x1d80), 1);
PUSH_DATA (push, 3);
BEGIN_NV04(push, SUBC_3D(0x1450), 1);
PUSH_DATA (push, 0x00030004);
/* NEW */
BEGIN_NV04(push, SUBC_3D(0x1e98), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, SUBC_3D(0x17e0), 3);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0x3f800000);
BEGIN_NV04(push, SUBC_3D(0x1f80), 16);
PUSH_DATA (push, 0); PUSH_DATA (push, 0); PUSH_DATA (push, 0); PUSH_DATA (push, 0);
PUSH_DATA (push, 0); PUSH_DATA (push, 0); PUSH_DATA (push, 0); PUSH_DATA (push, 0);
PUSH_DATA (push, 0x0000ffff);
PUSH_DATA (push, 0); PUSH_DATA (push, 0); PUSH_DATA (push, 0); PUSH_DATA (push, 0);
PUSH_DATA (push, 0); PUSH_DATA (push, 0); PUSH_DATA (push, 0);
BEGIN_NV04(push, SUBC_3D(0x120), 3);
PUSH_DATA (push, 0);
PUSH_DATA (push, 1);
PUSH_DATA (push, 2);
BEGIN_NV04(push, SUBC_BLIT(0x120), 3);
PUSH_DATA (push, 0);
PUSH_DATA (push, 1);
PUSH_DATA (push, 2);
BEGIN_NV04(push, SUBC_3D(0x1d88), 1);
PUSH_DATA (push, 0x00001200);
BEGIN_NV04(push, NV30_3D(MULTISAMPLE_CONTROL), 1);
PUSH_DATA (push, 0xffff0000);
BEGIN_NV04(push, NV30_3D(RC_ENABLE), 1);
PUSH_DATA (push, 0);
/* Attempt to setup a known state.. Probably missing a heap of
* stuff here..
*/
BEGIN_NV04(push, NV30_3D(STENCIL_ENABLE(0)), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV30_3D(STENCIL_ENABLE(1)), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV30_3D(ALPHA_FUNC_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV30_3D(DEPTH_WRITE_ENABLE), 2);
PUSH_DATA (push, 0); /* wr disable */
PUSH_DATA (push, 0); /* test disable */
BEGIN_NV04(push, NV30_3D(COLOR_MASK), 1);
PUSH_DATA (push, 0x01010101); /* TR,TR,TR,TR */
BEGIN_NV04(push, NV30_3D(CULL_FACE_ENABLE), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, NV30_3D(BLEND_FUNC_ENABLE), 5);
PUSH_DATA (push, 0); /* Blend enable */
PUSH_DATA (push, 0); /* Blend src */
PUSH_DATA (push, 0); /* Blend dst */
PUSH_DATA (push, 0x00000000); /* Blend colour */
PUSH_DATA (push, 0x8006); /* FUNC_ADD */
BEGIN_NV04(push, NV30_3D(COLOR_LOGIC_OP_ENABLE), 2);
PUSH_DATA (push, 0);
PUSH_DATA (push, 0x1503 /*GL_COPY*/);
BEGIN_NV04(push, NV30_3D(DITHER_ENABLE), 1);
PUSH_DATA (push, 1);
BEGIN_NV04(push, NV30_3D(SHADE_MODEL), 1);
PUSH_DATA (push, 0x1d01 /*GL_SMOOTH*/);
BEGIN_NV04(push, NV30_3D(POLYGON_OFFSET_FACTOR),2);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
BEGIN_NV04(push, NV30_3D(POLYGON_MODE_FRONT), 2);
PUSH_DATA (push, 0x1b02 /*GL_FILL*/);
PUSH_DATA (push, 0x1b02 /*GL_FILL*/);
/* - Disable texture units
* - Set fragprog to MOVR result.color, fragment.color */
for (i=0;i<4;i++) {
BEGIN_NV04(push, NV30_3D(TEX_ENABLE(i)), 1);
PUSH_DATA (push, 0);
}
/* Polygon stipple */
BEGIN_NV04(push, NV30_3D(POLYGON_STIPPLE_PATTERN(0)), 0x20);
for (i=0;i<0x20;i++)
PUSH_DATA (push, 0xFFFFFFFF);
BEGIN_NV04(push, NV30_3D(DEPTH_RANGE_NEAR), 2);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 1.0);
/* Ok. If you start X with the nvidia driver, kill it, and then
* start X with nouveau you will get black rendering instead of
* what you'd expect. This fixes the problem, and it seems that
* it's not needed between nouveau restarts - which suggests that
* the 3D context (wherever it's stored?) survives somehow.
*/
//BEGIN_NV04(push, SUBC_3D(0x1d60),1);
//PUSH_DATA (push, 0x03008000);
int w=4096;
int h=4096;
int pitch=4096*4;
BEGIN_NV04(push, NV30_3D(RT_HORIZ), 5);
PUSH_DATA (push, w<<16);
PUSH_DATA (push, h<<16);
PUSH_DATA (push, 0x148); /* format */
PUSH_DATA (push, pitch << 16 | pitch);
PUSH_DATA (push, 0x0);
BEGIN_NV04(push, NV30_3D(VIEWPORT_TX_ORIGIN), 1);
PUSH_DATA (push, 0);
BEGIN_NV04(push, SUBC_3D(0x0a00), 2);
PUSH_DATA (push, (w<<16) | 0);
PUSH_DATA (push, (h<<16) | 0);
BEGIN_NV04(push, NV30_3D(VIEWPORT_CLIP_HORIZ(0)), 2);
PUSH_DATA (push, (w-1)<<16);
PUSH_DATA (push, (h-1)<<16);
BEGIN_NV04(push, NV30_3D(SCISSOR_HORIZ), 2);
PUSH_DATA (push, w<<16);
PUSH_DATA (push, h<<16);
BEGIN_NV04(push, NV30_3D(VIEWPORT_HORIZ), 2);
PUSH_DATA (push, w<<16);
PUSH_DATA (push, h<<16);
BEGIN_NV04(push, NV30_3D(VIEWPORT_TRANSLATE_X), 8);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 1.0);
PUSH_DATAf(push, 1.0);
PUSH_DATAf(push, 1.0);
PUSH_DATAf(push, 0.0);
BEGIN_NV04(push, NV30_3D(MODELVIEW_MATRIX(0)), 16);
PUSH_DATAf(push, 1.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 1.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 1.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 1.0);
BEGIN_NV04(push, NV30_3D(PROJECTION_MATRIX(0)), 16);
PUSH_DATAf(push, 1.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 1.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 1.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 0.0);
PUSH_DATAf(push, 1.0);
BEGIN_NV04(push, NV30_3D(SCISSOR_HORIZ), 2);
PUSH_DATA (push, 4096<<16);
PUSH_DATA (push, 4096<<16);
PUSH_DATAu(push, pNv->scratch, PFP_PASS, 1 * 4);
PUSH_DATA (push, 0x01403e81); /* mov r0, a[col0] */
PUSH_DATA (push, 0x1c9dc801);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x3fe1c800);
PUSH_DATAu(push, pNv->scratch, PFP_S, 2 * 4);
PUSH_DATA (push, 0x17009e00); /* tex r0, a[tex0], t[0] */
PUSH_DATA (push, 0x1c9dc801);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x3fe1c800);
PUSH_DATA (push, 0x01401e81); /* mov r0, r0 */
PUSH_DATA (push, 0x1c9dc800);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x0001c800);
PUSH_DATAu(push, pNv->scratch, PFP_S_A8, 2 * 4);
PUSH_DATA (push, 0x17009000); /* tex r0.w, a[tex0], t[0] */
PUSH_DATA (push, 0x1c9dc801);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x3fe1c800);
PUSH_DATA (push, 0x01401e81); /* mov r0, r0.w */
PUSH_DATA (push, 0x1c9dfe00);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x0001c800);
PUSH_DATAu(push, pNv->scratch, PFP_C, 3 * 4);
PUSH_DATA (push, 0x1702b102); /* texc0 r1.w, a[tex1], t[1] */
PUSH_DATA (push, 0x1c9dc801);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x3fe1c800);
PUSH_DATA (push, 0x17009e00); /* tex r0 (ne0.w), a[tex0], t[0] */
PUSH_DATA (push, 0x1ff5c801);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x3fe1c800);
PUSH_DATA (push, 0x02001e81); /* mul r0, r0, r1.w */
PUSH_DATA (push, 0x1c9dc800);
PUSH_DATA (push, 0x0001fe04);
PUSH_DATA (push, 0x0001c800);
PUSH_DATAu(push, pNv->scratch, PFP_C_A8, 3 * 4);
PUSH_DATA (push, 0x1702b102); /* texc0 r1.w, a[tex1], t[1] */
PUSH_DATA (push, 0x1c9dc801);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x3fe1c800);
PUSH_DATA (push, 0x17009000); /* tex r0.w (ne0.w), a[tex0], t[0] */
PUSH_DATA (push, 0x1ff5c801);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x3fe1c800);
PUSH_DATA (push, 0x02001e81); /* mul r0, r0.w, r1.w */
PUSH_DATA (push, 0x1c9dfe00);
PUSH_DATA (push, 0x0001fe04);
PUSH_DATA (push, 0x0001c800);
PUSH_DATAu(push, pNv->scratch, PFP_CCA, 3 * 4);
PUSH_DATA (push, 0x17009f00); /* texc0 r0, a[tex0], t[0] */
PUSH_DATA (push, 0x1c9dc801);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x3fe1c800);
PUSH_DATA (push, 0x1702be02); /* tex r1 (ne0), a[tex1], t[1] */
PUSH_DATA (push, 0x1c95c801);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x3fe1c800);
PUSH_DATA (push, 0x02001e81); /* mul r0, r0, r1 */
PUSH_DATA (push, 0x1c9dc800);
PUSH_DATA (push, 0x0001c804);
PUSH_DATA (push, 0x0001c800);
PUSH_DATAu(push, pNv->scratch, PFP_CCASA, 3 * 4);
PUSH_DATA (push, 0x17009102); /* texc0 r1.w, a[tex0], t[0] */
PUSH_DATA (push, 0x1c9dc801);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x3fe1c800);
PUSH_DATA (push, 0x1702be00); /* tex r0 (ne0.w), a[tex1], t[1] */
PUSH_DATA (push, 0x1ff5c801);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x3fe1c800);
PUSH_DATA (push, 0x02001e81); /* mul r0, r1.w, r0 */
PUSH_DATA (push, 0x1c9dfe04);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x0001c800);
PUSH_DATAu(push, pNv->scratch, PFP_NV12_BILINEAR, 8 * 4);
PUSH_DATA (push, 0x17028200); /* texr r0.x, a[tex0], t[1] */
PUSH_DATA (push, 0x1c9dc801);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x3fe1c800);
PUSH_DATA (push, 0x04000e02); /* madr r1.xyz, r0.x, imm.x, imm.yzww */
PUSH_DATA (push, 0x1c9c0000);
PUSH_DATA (push, 0x00000002);
PUSH_DATA (push, 0x0001f202);
PUSH_DATA (push, 0x3f9507c8); /* { 1.16, -0.87, 0.53, -1.08 } */
PUSH_DATA (push, 0xbf5ee393);
PUSH_DATA (push, 0x3f078fef);
PUSH_DATA (push, 0xbf8a6762);
PUSH_DATA (push, 0x1704ac80); /* texr r0.yz, a[tex1], t[2] */
PUSH_DATA (push, 0x1c9dc801);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x3fe1c800);
PUSH_DATA (push, 0x04000e02); /* madr r1.xyz, r0.y, imm, r1 */
PUSH_DATA (push, 0x1c9cab00);
PUSH_DATA (push, 0x0001c802);
PUSH_DATA (push, 0x0001c804);
PUSH_DATA (push, 0x00000000); /* { 0.00, -0.39, 2.02, 0.00 } */
PUSH_DATA (push, 0xbec890d6);
PUSH_DATA (push, 0x40011687);
PUSH_DATA (push, 0x00000000);
PUSH_DATA (push, 0x04000e81); /* madr r0.xyz, r0.z, imm, r1 */
PUSH_DATA (push, 0x1c9d5500);
PUSH_DATA (push, 0x0001c802);
PUSH_DATA (push, 0x0001c804);
PUSH_DATA (push, 0x3fcc432d); /* { 1.60, -0.81, 0.00, 0.00 } */
PUSH_DATA (push, 0xbf501a37);
PUSH_DATA (push, 0x00000000);
PUSH_DATA (push, 0x00000000);
PUSH_DATAu(push, pNv->scratch, PFP_NV12_BICUBIC, 24 * 4);
PUSH_DATA (push, 0x01008604); /* movr r2.xy, a[tex0] */
PUSH_DATA (push, 0x1c9dc801);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x03000600); /* addr r0.xy, r2, imm.x */
PUSH_DATA (push, 0x1c9dc808);
PUSH_DATA (push, 0x00000002);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x3f000000); /* { 0.50, 0.00, 0.00, 0.00 } */
PUSH_DATA (push, 0x00000000);
PUSH_DATA (push, 0x00000000);
PUSH_DATA (push, 0x00000000);
PUSH_DATA (push, 0x17000e06); /* texr r3.xyz, r0, t[0] */
PUSH_DATA (push, 0x1c9dc800);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x17000e00); /* texr r0.xyz, r0.y, t[0] */
PUSH_DATA (push, 0x1c9caa00);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x02000a02); /* mulr r1.xz, r3.xxyy, imm.xxyy */
PUSH_DATA (push, 0x1c9ca00c);
PUSH_DATA (push, 0x0000a002);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0xbf800000); /* { -1.00, 1.00, 0.00, 0.00 } */
PUSH_DATA (push, 0x3f800000);
PUSH_DATA (push, 0x00000000);
PUSH_DATA (push, 0x00000000);
PUSH_DATA (push, 0x02001402); /* mulr r1.yw, r0.xxyy, imm.xxyy */
PUSH_DATA (push, 0x1c9ca000);
PUSH_DATA (push, 0x0000a002);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0xbf800000); /* { -1.00, 1.00, 0.00, 0.00 } */
PUSH_DATA (push, 0x3f800000);
PUSH_DATA (push, 0x00000000);
PUSH_DATA (push, 0x00000000);
PUSH_DATA (push, 0x03001e04); /* addr r2, r2.xyxy, r1 */
PUSH_DATA (push, 0x1c9c8808);
PUSH_DATA (push, 0x0001c804);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x17020200); /* texr r0.x, r2, t[1] */
PUSH_DATA (push, 0x1c9dc808);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x17020402); /* texr r1.y, r2.xwxw, t[1] */
PUSH_DATA (push, 0x1c9d9808);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x17020202); /* texr r1.x, r2.zyxy, t[1] */
PUSH_DATA (push, 0x1c9c8c08);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x1f400280); /* lrph r0.x, r0.z, r0, r1.y */
PUSH_DATA (push, 0x1c9d5400);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x0000aa04);
PUSH_DATA (push, 0x17020400); /* texr r0.y, r2.zwzz, t[1] */
PUSH_DATA (push, 0x1c9d5c08);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x1f400480); /* lrph r0.y, r0.z, r1.x, r0 */
PUSH_DATA (push, 0x1c9d5400);
PUSH_DATA (push, 0x00000004);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x1f400280); /* lrph r0.x, r3.z, r0, r0.y */
PUSH_DATA (push, 0x1c9d540c);
PUSH_DATA (push, 0x0001c900);
PUSH_DATA (push, 0x0000ab00);
PUSH_DATA (push, 0x04400e80); /* madh r0.xyz, r0.x, imm.x, imm.yzww */
PUSH_DATA (push, 0x1c9c0100);
PUSH_DATA (push, 0x00000002);
PUSH_DATA (push, 0x0001f202);
PUSH_DATA (push, 0x3f9507c8); /* { 1.16, -0.87, 0.53, -1.08 } */
PUSH_DATA (push, 0xbf5ee393);
PUSH_DATA (push, 0x3f078fef);
PUSH_DATA (push, 0xbf8a6762);
PUSH_DATA (push, 0x1704ac02); /* texr r1.yz, a[tex1], t[2] */
PUSH_DATA (push, 0x1c9dc801);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x0001c800);
PUSH_DATA (push, 0x04400e80); /* madh r0.xyz, r1.y, imm, r0 */
PUSH_DATA (push, 0x1c9caa04);
PUSH_DATA (push, 0x0001c802);
PUSH_DATA (push, 0x0001c900);
PUSH_DATA (push, 0x00000000); /* { 0.00, -0.39, 2.02, 0.00 } */
PUSH_DATA (push, 0xbec890d6);
PUSH_DATA (push, 0x40011687);
PUSH_DATA (push, 0x00000000);
PUSH_DATA (push, 0x04400e81); /* madh r0.xyz, r1.z, imm, r0 */
PUSH_DATA (push, 0x1c9d5404);
PUSH_DATA (push, 0x0001c802);
PUSH_DATA (push, 0x0001c900);
PUSH_DATA (push, 0x3fcc432d); /* { 1.60, -0.81, 0.00, 0.00 } */
PUSH_DATA (push, 0xbf501a37);
PUSH_DATA (push, 0x00000000);
PUSH_DATA (push, 0x00000000);
return TRUE;
}
|