~ubuntu-branches/ubuntu/raring/xserver-xorg-video-intel/raring

« back to all changes in this revision

Viewing changes to src/sna/gen6_render.c

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2013-01-08 17:58:48 UTC
  • mfrom: (1.4.28)
  • Revision ID: package-import@ubuntu.com-20130108175848-98g6sbzeepup1kgw
Tags: 2:2.20.17-0ubuntu1
Merge from unreleased debian git.

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
 
43
43
#include "brw/brw.h"
44
44
#include "gen6_render.h"
 
45
#include "gen4_vertex.h"
45
46
 
46
47
#define NO_COMPOSITE 0
47
48
#define NO_COMPOSITE_SPANS 0
947
948
        state->last_primitive = sna->kgem.nbatch;
948
949
}
949
950
 
950
 
static void gen6_vertex_flush(struct sna *sna)
951
 
{
952
 
        assert(sna->render_state.gen6.vertex_offset);
953
 
 
954
 
        DBG(("%s[%x] = %d\n", __FUNCTION__,
955
 
             4*sna->render_state.gen6.vertex_offset,
956
 
             sna->render.vertex_index - sna->render.vertex_start));
957
 
        sna->kgem.batch[sna->render_state.gen6.vertex_offset] =
958
 
                sna->render.vertex_index - sna->render.vertex_start;
959
 
        sna->render_state.gen6.vertex_offset = 0;
960
 
}
961
 
 
962
 
static int gen6_vertex_finish(struct sna *sna)
963
 
{
964
 
        struct kgem_bo *bo;
965
 
        unsigned int i;
966
 
 
967
 
        DBG(("%s: used=%d / %d\n", __FUNCTION__,
968
 
             sna->render.vertex_used, sna->render.vertex_size));
969
 
        assert(sna->render.vertex_used);
970
 
        assert(sna->render.nvertex_reloc);
971
 
 
972
 
        /* Note: we only need dword alignment (currently) */
973
 
 
974
 
        bo = sna->render.vbo;
975
 
        if (bo) {
976
 
                if (sna->render_state.gen6.vertex_offset)
977
 
                        gen6_vertex_flush(sna);
978
 
 
979
 
                for (i = 0; i < sna->render.nvertex_reloc; i++) {
980
 
                        DBG(("%s: reloc[%d] = %d\n", __FUNCTION__,
981
 
                             i, sna->render.vertex_reloc[i]));
982
 
 
983
 
                        sna->kgem.batch[sna->render.vertex_reloc[i]] =
984
 
                                kgem_add_reloc(&sna->kgem,
985
 
                                               sna->render.vertex_reloc[i], bo,
986
 
                                               I915_GEM_DOMAIN_VERTEX << 16,
987
 
                                               0);
988
 
                }
989
 
 
990
 
                sna->render.nvertex_reloc = 0;
991
 
                sna->render.vertex_used = 0;
992
 
                sna->render.vertex_index = 0;
993
 
                sna->render.vbo = NULL;
994
 
                sna->render_state.gen6.vb_id = 0;
995
 
 
996
 
                kgem_bo_destroy(&sna->kgem, bo);
997
 
        }
998
 
 
999
 
        sna->render.vertices = NULL;
1000
 
        sna->render.vbo = kgem_create_linear(&sna->kgem,
1001
 
                                             256*1024, CREATE_GTT_MAP);
1002
 
        if (sna->render.vbo)
1003
 
                sna->render.vertices = kgem_bo_map(&sna->kgem, sna->render.vbo);
1004
 
        if (sna->render.vertices == NULL) {
1005
 
                if (sna->render.vbo)
1006
 
                        kgem_bo_destroy(&sna->kgem, sna->render.vbo);
1007
 
                sna->render.vbo = NULL;
1008
 
                return 0;
1009
 
        }
1010
 
 
1011
 
        DBG(("%s: create vbo handle=%d\n", __FUNCTION__, sna->render.vbo->handle));
1012
 
 
1013
 
        kgem_bo_sync__cpu(&sna->kgem, sna->render.vbo);
1014
 
        if (sna->render.vertex_used) {
1015
 
                DBG(("%s: copying initial buffer x %d to handle=%d\n",
1016
 
                     __FUNCTION__,
1017
 
                     sna->render.vertex_used,
1018
 
                     sna->render.vbo->handle));
1019
 
                memcpy(sna->render.vertices,
1020
 
                       sna->render.vertex_data,
1021
 
                       sizeof(float)*sna->render.vertex_used);
1022
 
        }
1023
 
        sna->render.vertex_size = 64 * 1024 - 1;
1024
 
        return sna->render.vertex_size - sna->render.vertex_used;
1025
 
}
1026
 
 
1027
 
static void gen6_vertex_close(struct sna *sna)
1028
 
{
1029
 
        struct kgem_bo *bo, *free_bo = NULL;
1030
 
        unsigned int i, delta = 0;
1031
 
 
1032
 
        assert(sna->render_state.gen6.vertex_offset == 0);
1033
 
 
1034
 
        if (!sna->render_state.gen6.vb_id)
1035
 
                return;
1036
 
 
1037
 
        DBG(("%s: used=%d, vbo active? %d\n",
1038
 
             __FUNCTION__, sna->render.vertex_used, sna->render.vbo ? sna->render.vbo->handle : 0));
1039
 
 
1040
 
        bo = sna->render.vbo;
1041
 
        if (bo) {
1042
 
                if (sna->render.vertex_size - sna->render.vertex_used < 64) {
1043
 
                        DBG(("%s: discarding vbo (full), handle=%d\n", __FUNCTION__, sna->render.vbo->handle));
1044
 
                        sna->render.vbo = NULL;
1045
 
                        sna->render.vertices = sna->render.vertex_data;
1046
 
                        sna->render.vertex_size = ARRAY_SIZE(sna->render.vertex_data);
1047
 
                        free_bo = bo;
1048
 
                }
1049
 
        } else {
1050
 
                if (sna->kgem.nbatch + sna->render.vertex_used <= sna->kgem.surface) {
1051
 
                        DBG(("%s: copy to batch: %d @ %d\n", __FUNCTION__,
1052
 
                             sna->render.vertex_used, sna->kgem.nbatch));
1053
 
                        memcpy(sna->kgem.batch + sna->kgem.nbatch,
1054
 
                               sna->render.vertex_data,
1055
 
                               sna->render.vertex_used * 4);
1056
 
                        delta = sna->kgem.nbatch * 4;
1057
 
                        bo = NULL;
1058
 
                        sna->kgem.nbatch += sna->render.vertex_used;
1059
 
                } else {
1060
 
                        bo = kgem_create_linear(&sna->kgem,
1061
 
                                                4*sna->render.vertex_used, 0);
1062
 
                        if (bo && !kgem_bo_write(&sna->kgem, bo,
1063
 
                                                 sna->render.vertex_data,
1064
 
                                                 4*sna->render.vertex_used)) {
1065
 
                                kgem_bo_destroy(&sna->kgem, bo);
1066
 
                                bo = NULL;
1067
 
                        }
1068
 
                        DBG(("%s: new vbo: %d\n", __FUNCTION__,
1069
 
                             sna->render.vertex_used));
1070
 
                        free_bo = bo;
1071
 
                }
1072
 
        }
1073
 
 
1074
 
        assert(sna->render.nvertex_reloc);
1075
 
        for (i = 0; i < sna->render.nvertex_reloc; i++) {
1076
 
                DBG(("%s: reloc[%d] = %d\n", __FUNCTION__,
1077
 
                     i, sna->render.vertex_reloc[i]));
1078
 
 
1079
 
                sna->kgem.batch[sna->render.vertex_reloc[i]] =
1080
 
                        kgem_add_reloc(&sna->kgem,
1081
 
                                       sna->render.vertex_reloc[i], bo,
1082
 
                                       I915_GEM_DOMAIN_VERTEX << 16,
1083
 
                                       delta);
1084
 
        }
1085
 
        sna->render.nvertex_reloc = 0;
1086
 
 
1087
 
        if (sna->render.vbo == NULL) {
1088
 
                sna->render.vertex_used = 0;
1089
 
                sna->render.vertex_index = 0;
1090
 
                assert(sna->render.vertices == sna->render.vertex_data);
1091
 
                assert(sna->render.vertex_size == ARRAY_SIZE(sna->render.vertex_data));
1092
 
        }
1093
 
 
1094
 
        if (free_bo)
1095
 
                kgem_bo_destroy(&sna->kgem, free_bo);
1096
 
}
1097
 
 
1098
951
typedef struct gen6_surface_state_padded {
1099
952
        struct gen6_surface_state state;
1100
953
        char pad[32 - sizeof(struct gen6_surface_state)];
1248
1101
        ss[4] = 0;
1249
1102
        ss[5] = is_scanout ? 0 : 3 << 16;
1250
1103
 
1251
 
        kgem_bo_set_binding(bo, format, offset | is_scanout << 31);
 
1104
        kgem_bo_set_binding(bo, format | is_scanout << 31, offset);
1252
1105
 
1253
1106
        DBG(("[%x] bind bo(handle=%d, addr=%d), format=%d, width=%d, height=%d, pitch=%d, tiling=%d -> %s\n",
1254
1107
             offset, bo->handle, ss[1],
1258
1111
        return offset * sizeof(uint32_t);
1259
1112
}
1260
1113
 
1261
 
fastcall static void
1262
 
gen6_emit_composite_primitive_solid(struct sna *sna,
1263
 
                                    const struct sna_composite_op *op,
1264
 
                                    const struct sna_composite_rectangles *r)
1265
 
{
1266
 
        float *v;
1267
 
        union {
1268
 
                struct sna_coordinate p;
1269
 
                float f;
1270
 
        } dst;
1271
 
 
1272
 
        DBG(("%s: [%d+9] = (%d, %d)x(%d, %d)\n", __FUNCTION__,
1273
 
             sna->render.vertex_used, r->dst.x, r->dst.y, r->width, r->height));
1274
 
 
1275
 
        v = sna->render.vertices + sna->render.vertex_used;
1276
 
        sna->render.vertex_used += 9;
1277
 
        assert(sna->render.vertex_used <= sna->render.vertex_size);
1278
 
        assert(!too_large(op->dst.x + r->dst.x + r->width,
1279
 
                          op->dst.y + r->dst.y + r->height));
1280
 
 
1281
 
        dst.p.x = r->dst.x + r->width;
1282
 
        dst.p.y = r->dst.y + r->height;
1283
 
        v[0] = dst.f;
1284
 
        dst.p.x = r->dst.x;
1285
 
        v[3] = dst.f;
1286
 
        dst.p.y = r->dst.y;
1287
 
        v[6] = dst.f;
1288
 
 
1289
 
        v[5] = v[2] = v[1] = 1.;
1290
 
        v[8] = v[7] = v[4] = 0.;
1291
 
}
1292
 
 
1293
 
fastcall static void
1294
 
gen6_emit_composite_primitive_identity_source(struct sna *sna,
1295
 
                                              const struct sna_composite_op *op,
1296
 
                                              const struct sna_composite_rectangles *r)
1297
 
{
1298
 
        union {
1299
 
                struct sna_coordinate p;
1300
 
                float f;
1301
 
        } dst;
1302
 
        float *v;
1303
 
 
1304
 
        v = sna->render.vertices + sna->render.vertex_used;
1305
 
        sna->render.vertex_used += 9;
1306
 
 
1307
 
        dst.p.x = r->dst.x + r->width;
1308
 
        dst.p.y = r->dst.y + r->height;
1309
 
        v[0] = dst.f;
1310
 
        dst.p.x = r->dst.x;
1311
 
        v[3] = dst.f;
1312
 
        dst.p.y = r->dst.y;
1313
 
        v[6] = dst.f;
1314
 
 
1315
 
        v[7] = v[4] = (r->src.x + op->src.offset[0]) * op->src.scale[0];
1316
 
        v[1] = v[4] + r->width * op->src.scale[0];
1317
 
 
1318
 
        v[8] = (r->src.y + op->src.offset[1]) * op->src.scale[1];
1319
 
        v[5] = v[2] = v[8] + r->height * op->src.scale[1];
1320
 
}
1321
 
 
1322
 
fastcall static void
1323
 
gen6_emit_composite_primitive_simple_source(struct sna *sna,
1324
 
                                            const struct sna_composite_op *op,
1325
 
                                            const struct sna_composite_rectangles *r)
1326
 
{
1327
 
        float *v;
1328
 
        union {
1329
 
                struct sna_coordinate p;
1330
 
                float f;
1331
 
        } dst;
1332
 
 
1333
 
        float xx = op->src.transform->matrix[0][0];
1334
 
        float x0 = op->src.transform->matrix[0][2];
1335
 
        float yy = op->src.transform->matrix[1][1];
1336
 
        float y0 = op->src.transform->matrix[1][2];
1337
 
        float sx = op->src.scale[0];
1338
 
        float sy = op->src.scale[1];
1339
 
        int16_t tx = op->src.offset[0];
1340
 
        int16_t ty = op->src.offset[1];
1341
 
 
1342
 
        v = sna->render.vertices + sna->render.vertex_used;
1343
 
        sna->render.vertex_used += 3*3;
1344
 
 
1345
 
        dst.p.x = r->dst.x + r->width;
1346
 
        dst.p.y = r->dst.y + r->height;
1347
 
        v[0] = dst.f;
1348
 
        v[1] = ((r->src.x + r->width + tx) * xx + x0) * sx;
1349
 
        v[5] = v[2] = ((r->src.y + r->height + ty) * yy + y0) * sy;
1350
 
 
1351
 
        dst.p.x = r->dst.x;
1352
 
        v[3] = dst.f;
1353
 
        v[7] = v[4] = ((r->src.x + tx) * xx + x0) * sx;
1354
 
 
1355
 
        dst.p.y = r->dst.y;
1356
 
        v[6] = dst.f;
1357
 
        v[8] = ((r->src.y + ty) * yy + y0) * sy;
1358
 
}
1359
 
 
1360
 
fastcall static void
1361
 
gen6_emit_composite_primitive_affine_source(struct sna *sna,
1362
 
                                            const struct sna_composite_op *op,
1363
 
                                            const struct sna_composite_rectangles *r)
1364
 
{
1365
 
        union {
1366
 
                struct sna_coordinate p;
1367
 
                float f;
1368
 
        } dst;
1369
 
        float *v;
1370
 
 
1371
 
        v = sna->render.vertices + sna->render.vertex_used;
1372
 
        sna->render.vertex_used += 9;
1373
 
 
1374
 
        dst.p.x = r->dst.x + r->width;
1375
 
        dst.p.y = r->dst.y + r->height;
1376
 
        v[0] = dst.f;
1377
 
        _sna_get_transformed_coordinates(op->src.offset[0] + r->src.x + r->width,
1378
 
                                         op->src.offset[1] + r->src.y + r->height,
1379
 
                                         op->src.transform,
1380
 
                                         &v[1], &v[2]);
1381
 
        v[1] *= op->src.scale[0];
1382
 
        v[2] *= op->src.scale[1];
1383
 
 
1384
 
        dst.p.x = r->dst.x;
1385
 
        v[3] = dst.f;
1386
 
        _sna_get_transformed_coordinates(op->src.offset[0] + r->src.x,
1387
 
                                         op->src.offset[1] + r->src.y + r->height,
1388
 
                                         op->src.transform,
1389
 
                                         &v[4], &v[5]);
1390
 
        v[4] *= op->src.scale[0];
1391
 
        v[5] *= op->src.scale[1];
1392
 
 
1393
 
        dst.p.y = r->dst.y;
1394
 
        v[6] = dst.f;
1395
 
        _sna_get_transformed_coordinates(op->src.offset[0] + r->src.x,
1396
 
                                         op->src.offset[1] + r->src.y,
1397
 
                                         op->src.transform,
1398
 
                                         &v[7], &v[8]);
1399
 
        v[7] *= op->src.scale[0];
1400
 
        v[8] *= op->src.scale[1];
1401
 
}
1402
 
 
1403
 
fastcall static void
1404
 
gen6_emit_composite_primitive_identity_mask(struct sna *sna,
1405
 
                                            const struct sna_composite_op *op,
1406
 
                                            const struct sna_composite_rectangles *r)
1407
 
{
1408
 
        union {
1409
 
                struct sna_coordinate p;
1410
 
                float f;
1411
 
        } dst;
1412
 
        float msk_x, msk_y;
1413
 
        float w, h;
1414
 
        float *v;
1415
 
 
1416
 
        msk_x = r->mask.x + op->mask.offset[0];
1417
 
        msk_y = r->mask.y + op->mask.offset[1];
1418
 
        w = r->width;
1419
 
        h = r->height;
1420
 
 
1421
 
        v = sna->render.vertices + sna->render.vertex_used;
1422
 
        sna->render.vertex_used += 15;
1423
 
 
1424
 
        dst.p.x = r->dst.x + r->width;
1425
 
        dst.p.y = r->dst.y + r->height;
1426
 
        v[0] = dst.f;
1427
 
        v[3] = (msk_x + w) * op->mask.scale[0];
1428
 
        v[9] = v[4] = (msk_y + h) * op->mask.scale[1];
1429
 
 
1430
 
        dst.p.x = r->dst.x;
1431
 
        v[5] = dst.f;
1432
 
        v[13] = v[8] = msk_x * op->mask.scale[0];
1433
 
 
1434
 
        dst.p.y = r->dst.y;
1435
 
        v[10] = dst.f;
1436
 
        v[14] = msk_y * op->mask.scale[1];
1437
 
 
1438
 
        v[7] = v[2] = v[1] = 1;
1439
 
        v[12] = v[11] = v[6] = 0;
1440
 
}
1441
 
 
1442
 
fastcall static void
1443
 
gen6_emit_composite_primitive_identity_source_mask(struct sna *sna,
1444
 
                                                   const struct sna_composite_op *op,
1445
 
                                                   const struct sna_composite_rectangles *r)
1446
 
{
1447
 
        union {
1448
 
                struct sna_coordinate p;
1449
 
                float f;
1450
 
        } dst;
1451
 
        float src_x, src_y;
1452
 
        float msk_x, msk_y;
1453
 
        float w, h;
1454
 
        float *v;
1455
 
 
1456
 
        src_x = r->src.x + op->src.offset[0];
1457
 
        src_y = r->src.y + op->src.offset[1];
1458
 
        msk_x = r->mask.x + op->mask.offset[0];
1459
 
        msk_y = r->mask.y + op->mask.offset[1];
1460
 
        w = r->width;
1461
 
        h = r->height;
1462
 
 
1463
 
        v = sna->render.vertices + sna->render.vertex_used;
1464
 
        sna->render.vertex_used += 15;
1465
 
 
1466
 
        dst.p.x = r->dst.x + r->width;
1467
 
        dst.p.y = r->dst.y + r->height;
1468
 
        v[0] = dst.f;
1469
 
        v[1] = (src_x + w) * op->src.scale[0];
1470
 
        v[2] = (src_y + h) * op->src.scale[1];
1471
 
        v[3] = (msk_x + w) * op->mask.scale[0];
1472
 
        v[4] = (msk_y + h) * op->mask.scale[1];
1473
 
 
1474
 
        dst.p.x = r->dst.x;
1475
 
        v[5] = dst.f;
1476
 
        v[6] = src_x * op->src.scale[0];
1477
 
        v[7] = v[2];
1478
 
        v[8] = msk_x * op->mask.scale[0];
1479
 
        v[9] = v[4];
1480
 
 
1481
 
        dst.p.y = r->dst.y;
1482
 
        v[10] = dst.f;
1483
 
        v[11] = v[6];
1484
 
        v[12] = src_y * op->src.scale[1];
1485
 
        v[13] = v[8];
1486
 
        v[14] = msk_y * op->mask.scale[1];
1487
 
}
1488
 
 
1489
 
inline static void
1490
 
gen6_emit_composite_texcoord(struct sna *sna,
1491
 
                             const struct sna_composite_channel *channel,
1492
 
                             int16_t x, int16_t y)
1493
 
{
1494
 
        x += channel->offset[0];
1495
 
        y += channel->offset[1];
1496
 
 
1497
 
        if (channel->is_affine) {
1498
 
                float s, t;
1499
 
 
1500
 
                sna_get_transformed_coordinates(x, y,
1501
 
                                                channel->transform,
1502
 
                                                &s, &t);
1503
 
                OUT_VERTEX_F(s * channel->scale[0]);
1504
 
                OUT_VERTEX_F(t * channel->scale[1]);
1505
 
        } else {
1506
 
                float s, t, w;
1507
 
 
1508
 
                sna_get_transformed_coordinates_3d(x, y,
1509
 
                                                   channel->transform,
1510
 
                                                   &s, &t, &w);
1511
 
                OUT_VERTEX_F(s * channel->scale[0]);
1512
 
                OUT_VERTEX_F(t * channel->scale[1]);
1513
 
                OUT_VERTEX_F(w);
1514
 
        }
1515
 
}
1516
 
 
1517
 
static void
1518
 
gen6_emit_composite_vertex(struct sna *sna,
1519
 
                           const struct sna_composite_op *op,
1520
 
                           int16_t srcX, int16_t srcY,
1521
 
                           int16_t mskX, int16_t mskY,
1522
 
                           int16_t dstX, int16_t dstY)
1523
 
{
1524
 
        OUT_VERTEX(dstX, dstY);
1525
 
        gen6_emit_composite_texcoord(sna, &op->src, srcX, srcY);
1526
 
        gen6_emit_composite_texcoord(sna, &op->mask, mskX, mskY);
1527
 
}
1528
 
 
1529
 
fastcall static void
1530
 
gen6_emit_composite_primitive(struct sna *sna,
1531
 
                              const struct sna_composite_op *op,
1532
 
                              const struct sna_composite_rectangles *r)
1533
 
{
1534
 
        gen6_emit_composite_vertex(sna, op,
1535
 
                                   r->src.x + r->width,  r->src.y + r->height,
1536
 
                                   r->mask.x + r->width, r->mask.y + r->height,
1537
 
                                   r->dst.x + r->width, r->dst.y + r->height);
1538
 
        gen6_emit_composite_vertex(sna, op,
1539
 
                                   r->src.x,  r->src.y + r->height,
1540
 
                                   r->mask.x, r->mask.y + r->height,
1541
 
                                   r->dst.x,  r->dst.y + r->height);
1542
 
        gen6_emit_composite_vertex(sna, op,
1543
 
                                   r->src.x,  r->src.y,
1544
 
                                   r->mask.x, r->mask.y,
1545
 
                                   r->dst.x,  r->dst.y);
1546
 
}
1547
 
 
1548
1114
static void gen6_emit_vertex_buffer(struct sna *sna,
1549
1115
                                    const struct sna_composite_op *op)
1550
1116
{
1558
1124
        OUT_BATCH(~0); /* max address: disabled */
1559
1125
        OUT_BATCH(0);
1560
1126
 
1561
 
        sna->render_state.gen6.vb_id |= 1 << id;
 
1127
        sna->render.vb_id |= 1 << id;
1562
1128
}
1563
1129
 
1564
1130
static void gen6_emit_primitive(struct sna *sna)
1568
1134
                     __FUNCTION__,
1569
1135
                     sna->render.vertex_start,
1570
1136
                     sna->render.vertex_index));
1571
 
                sna->render_state.gen6.vertex_offset = sna->kgem.nbatch - 5;
 
1137
                sna->render.vertex_offset = sna->kgem.nbatch - 5;
1572
1138
                return;
1573
1139
        }
1574
1140
 
1577
1143
                  _3DPRIM_RECTLIST << GEN6_3DPRIMITIVE_TOPOLOGY_SHIFT |
1578
1144
                  0 << 9 |
1579
1145
                  4);
1580
 
        sna->render_state.gen6.vertex_offset = sna->kgem.nbatch;
 
1146
        sna->render.vertex_offset = sna->kgem.nbatch;
1581
1147
        OUT_BATCH(0);   /* vertex count, to be filled in later */
1582
1148
        OUT_BATCH(sna->render.vertex_index);
1583
1149
        OUT_BATCH(1);   /* single instance */
1597
1163
        int ndwords;
1598
1164
 
1599
1165
        ndwords = op->need_magic_ca_pass ? 60 : 6;
1600
 
        if ((sna->render_state.gen6.vb_id & id) == 0)
 
1166
        if ((sna->render.vb_id & id) == 0)
1601
1167
                ndwords += 5;
1602
1168
        if (!kgem_check_batch(&sna->kgem, ndwords))
1603
1169
                return false;
1604
1170
 
1605
 
        if ((sna->render_state.gen6.vb_id & id) == 0)
 
1171
        if ((sna->render.vb_id & id) == 0)
1606
1172
                gen6_emit_vertex_buffer(sna, op);
1607
1173
 
1608
1174
        gen6_emit_primitive(sna);
1614
1180
{
1615
1181
        if (!kgem_check_batch(&sna->kgem, op->need_magic_ca_pass ? 65 : 5))
1616
1182
                return 0;
1617
 
        if (!kgem_check_exec(&sna->kgem, 1))
 
1183
        if (!kgem_check_exec(&sna->kgem, 2))
1618
1184
                return 0;
1619
 
        if (!kgem_check_reloc(&sna->kgem, 2))
 
1185
        if (!kgem_check_reloc(&sna->kgem, 4))
1620
1186
                return 0;
1621
1187
 
1622
1188
        if (op->need_magic_ca_pass && sna->render.vbo)
1623
1189
                return 0;
1624
1190
 
1625
 
        return gen6_vertex_finish(sna);
 
1191
        return gen4_vertex_finish(sna);
1626
1192
}
1627
1193
 
1628
1194
inline static int gen6_get_rectangles(struct sna *sna,
1642
1208
                        goto flush;
1643
1209
        }
1644
1210
 
1645
 
        if (unlikely(sna->render_state.gen6.vertex_offset == 0 &&
 
1211
        if (unlikely(sna->render.vertex_offset == 0 &&
1646
1212
                     !gen6_rectangle_begin(sna, op)))
1647
1213
                goto flush;
1648
1214
 
1654
1220
        return want;
1655
1221
 
1656
1222
flush:
1657
 
        if (sna->render_state.gen6.vertex_offset) {
1658
 
                gen6_vertex_flush(sna);
 
1223
        if (sna->render.vertex_offset) {
 
1224
                gen4_vertex_flush(sna);
1659
1225
                gen6_magic_ca_pass(sna, op);
1660
1226
        }
1661
1227
        _kgem_submit(&sna->kgem);
1680
1246
        return table;
1681
1247
}
1682
1248
 
1683
 
static uint32_t
1684
 
gen6_choose_composite_vertex_buffer(const struct sna_composite_op *op)
1685
 
{
1686
 
        int id = 2 + !op->is_affine;
1687
 
        if (op->mask.bo)
1688
 
                id |= id << 2;
1689
 
        assert(id > 0 && id < 16);
1690
 
        return id;
1691
 
}
1692
 
 
1693
1249
static bool
1694
1250
gen6_get_batch(struct sna *sna, const struct sna_composite_op *op)
1695
1251
{
1754
1310
static void
1755
1311
gen6_align_vertex(struct sna *sna, const struct sna_composite_op *op)
1756
1312
{
1757
 
        assert (sna->render_state.gen6.vertex_offset == 0);
 
1313
        assert (sna->render.vertex_offset == 0);
1758
1314
        if (op->floats_per_vertex != sna->render_state.gen6.floats_per_vertex) {
1759
1315
                if (sna->render.vertex_size - sna->render.vertex_used < 2*op->floats_per_rect)
1760
 
                        /* XXX propagate failure */
1761
 
                        gen6_vertex_finish(sna);
 
1316
                        gen4_vertex_finish(sna);
1762
1317
 
1763
1318
                DBG(("aligning vertex: was %d, now %d floats per vertex, %d->%d\n",
1764
1319
                     sna->render_state.gen6.floats_per_vertex,
1976
1531
                  RegionPtr dstRegion,
1977
1532
                  short src_w, short src_h,
1978
1533
                  short drw_w, short drw_h,
 
1534
                  short dx, short dy,
1979
1535
                  PixmapPtr pixmap)
1980
1536
{
1981
1537
        struct sna_composite_op tmp;
1982
 
        int nbox, dxo, dyo, pix_xoff, pix_yoff;
 
1538
        int nbox, pix_xoff, pix_yoff;
1983
1539
        float src_scale_x, src_scale_y;
1984
1540
        struct sna_pixmap *priv;
1985
1541
        unsigned filter;
2047
1603
        pix_yoff = 0;
2048
1604
#endif
2049
1605
 
2050
 
        dxo = dstRegion->extents.x1;
2051
 
        dyo = dstRegion->extents.y1;
2052
 
 
2053
1606
        /* Use normalized texture coordinates */
2054
1607
        src_scale_x = ((float)src_w / frame->width) / (float)drw_w;
2055
1608
        src_scale_y = ((float)src_h / frame->height) / (float)drw_h;
2067
1620
                gen6_get_rectangles(sna, &tmp, 1, gen6_emit_video_state);
2068
1621
 
2069
1622
                OUT_VERTEX(r.x2, r.y2);
2070
 
                OUT_VERTEX_F((box->x2 - dxo) * src_scale_x);
2071
 
                OUT_VERTEX_F((box->y2 - dyo) * src_scale_y);
 
1623
                OUT_VERTEX_F((box->x2 - dx) * src_scale_x);
 
1624
                OUT_VERTEX_F((box->y2 - dy) * src_scale_y);
2072
1625
 
2073
1626
                OUT_VERTEX(r.x1, r.y2);
2074
 
                OUT_VERTEX_F((box->x1 - dxo) * src_scale_x);
2075
 
                OUT_VERTEX_F((box->y2 - dyo) * src_scale_y);
 
1627
                OUT_VERTEX_F((box->x1 - dx) * src_scale_x);
 
1628
                OUT_VERTEX_F((box->y2 - dy) * src_scale_y);
2076
1629
 
2077
1630
                OUT_VERTEX(r.x1, r.y1);
2078
 
                OUT_VERTEX_F((box->x1 - dxo) * src_scale_x);
2079
 
                OUT_VERTEX_F((box->y1 - dyo) * src_scale_y);
 
1631
                OUT_VERTEX_F((box->x1 - dx) * src_scale_x);
 
1632
                OUT_VERTEX_F((box->y1 - dy) * src_scale_y);
2080
1633
 
2081
1634
                if (!DAMAGE_IS_ALL(priv->gpu_damage)) {
2082
1635
                        sna_damage_add_box(&priv->gpu_damage, &r);
2086
1639
        }
2087
1640
        priv->clear = false;
2088
1641
 
2089
 
        gen6_vertex_flush(sna);
 
1642
        gen4_vertex_flush(sna);
2090
1643
        return true;
2091
1644
}
2092
1645
 
2336
1889
{
2337
1890
        DBG(("%s\n", __FUNCTION__));
2338
1891
 
2339
 
        if (sna->render_state.gen6.vertex_offset) {
2340
 
                gen6_vertex_flush(sna);
 
1892
        if (sna->render.vertex_offset) {
 
1893
                gen4_vertex_flush(sna);
2341
1894
                gen6_magic_ca_pass(sna, op);
2342
1895
        }
2343
1896
 
2404
1957
        return sna->kgem.ring != KGEM_RENDER;
2405
1958
}
2406
1959
 
2407
 
static bool can_switch_to_blt(struct sna *sna)
 
1960
inline static bool can_switch_to_blt(struct sna *sna)
2408
1961
{
2409
 
        if (sna->kgem.ring == KGEM_BLT)
 
1962
        if (sna->kgem.ring != KGEM_RENDER)
2410
1963
                return true;
2411
1964
 
2412
1965
        if (NO_RING_SWITCH)
2415
1968
        if (!sna->kgem.has_semaphores)
2416
1969
                return false;
2417
1970
 
2418
 
        return (sna->kgem.mode == KGEM_NONE ||
2419
 
                kgem_ring_is_idle(&sna->kgem, KGEM_BLT));
 
1971
        return kgem_ring_is_idle(&sna->kgem, KGEM_BLT);
2420
1972
}
2421
1973
 
2422
1974
static inline bool untiled_tlb_miss(struct kgem_bo *bo)
2424
1976
        return bo->tiling == I915_TILING_NONE && bo->pitch >= 4096;
2425
1977
}
2426
1978
 
2427
 
static bool prefer_blt_bo(struct sna *sna, struct kgem_bo *bo)
 
1979
static int prefer_blt_bo(struct sna *sna, struct kgem_bo *bo)
2428
1980
{
2429
 
        return untiled_tlb_miss(bo) && bo->pitch < MAXSHORT;
 
1981
        if (bo->rq)
 
1982
                return RQ_IS_BLT(bo->rq) ? 1 : -1;
 
1983
 
 
1984
        return bo->tiling == I915_TILING_NONE;
2430
1985
}
2431
1986
 
2432
1987
static bool
2668
2223
        if (sna->kgem.ring == KGEM_BLT)
2669
2224
                return true;
2670
2225
 
 
2226
        if (untiled_tlb_miss(tmp->dst.bo) ||
 
2227
            untiled_tlb_miss(tmp->src.bo))
 
2228
                return true;
 
2229
 
2671
2230
        if (!prefer_blt_ring(sna))
2672
2231
                return false;
2673
2232
 
2674
 
        return (prefer_blt_bo(sna, tmp->dst.bo) ||
2675
 
                prefer_blt_bo(sna, tmp->src.bo));
 
2233
        return (prefer_blt_bo(sna, tmp->dst.bo) >= 0 &&
 
2234
                prefer_blt_bo(sna, tmp->src.bo) >= 0);
2676
2235
}
2677
2236
 
2678
2237
static bool
2753
2312
        tmp->mask.filter = SAMPLER_FILTER_NEAREST;
2754
2313
        tmp->mask.repeat = SAMPLER_EXTEND_NONE;
2755
2314
 
2756
 
        tmp->prim_emit = gen6_emit_composite_primitive;
2757
2315
        if (mask) {
2758
2316
                if (mask->componentAlpha && PICT_FORMAT_RGB(mask->format)) {
2759
2317
                        tmp->has_component_alpha = true;
2793
2351
                }
2794
2352
 
2795
2353
                tmp->is_affine &= tmp->mask.is_affine;
2796
 
 
2797
 
                if (tmp->src.transform == NULL && tmp->mask.transform == NULL) {
2798
 
                        if (tmp->src.is_solid)
2799
 
                                tmp->prim_emit = gen6_emit_composite_primitive_identity_mask;
2800
 
                        else
2801
 
                                tmp->prim_emit = gen6_emit_composite_primitive_identity_source_mask;
2802
 
                }
2803
 
 
2804
 
                tmp->floats_per_vertex = 5 + 2 * !tmp->is_affine;
2805
 
        } else {
2806
 
                if (tmp->src.is_solid) {
2807
 
                        DBG(("%s: choosing gen6_emit_composite_primitive_solid\n",
2808
 
                             __FUNCTION__));
2809
 
                        tmp->prim_emit = gen6_emit_composite_primitive_solid;
2810
 
                        if (tmp->src.is_opaque && op == PictOpOver)
2811
 
                                tmp->op = PictOpSrc;
2812
 
                } else if (tmp->src.transform == NULL) {
2813
 
                        DBG(("%s: choosing gen6_emit_composite_primitive_identity_source\n",
2814
 
                             __FUNCTION__));
2815
 
                        tmp->prim_emit = gen6_emit_composite_primitive_identity_source;
2816
 
                } else if (tmp->src.is_affine) {
2817
 
                        if (tmp->src.transform->matrix[0][1] == 0 &&
2818
 
                            tmp->src.transform->matrix[1][0] == 0) {
2819
 
                                tmp->src.scale[0] /= tmp->src.transform->matrix[2][2];
2820
 
                                tmp->src.scale[1] /= tmp->src.transform->matrix[2][2];
2821
 
                                DBG(("%s: choosing gen6_emit_composite_primitive_simple_source\n",
2822
 
                                     __FUNCTION__));
2823
 
                                tmp->prim_emit = gen6_emit_composite_primitive_simple_source;
2824
 
                        } else {
2825
 
                                DBG(("%s: choosing gen6_emit_composite_primitive_affine_source\n",
2826
 
                                     __FUNCTION__));
2827
 
                                tmp->prim_emit = gen6_emit_composite_primitive_affine_source;
2828
 
                        }
2829
 
                }
2830
 
 
2831
 
                tmp->floats_per_vertex = 3 + !tmp->is_affine;
2832
2354
        }
2833
 
        tmp->floats_per_rect = 3 * tmp->floats_per_vertex;
 
2355
        gen4_choose_composite_emitter(tmp);
2834
2356
 
2835
2357
        tmp->u.gen6.flags =
2836
2358
                GEN6_SET_FLAGS(SAMPLER_OFFSET(tmp->src.filter,
2844
2366
                                                            tmp->mask.bo != NULL,
2845
2367
                                                            tmp->has_component_alpha,
2846
2368
                                                            tmp->is_affine),
2847
 
                               gen6_choose_composite_vertex_buffer(tmp));
 
2369
                               gen4_choose_composite_vertex_buffer(tmp));
2848
2370
 
2849
2371
        tmp->blt   = gen6_render_composite_blt;
2850
2372
        tmp->box   = gen6_render_composite_box;
2880
2402
}
2881
2403
 
2882
2404
#if !NO_COMPOSITE_SPANS
2883
 
inline static void
2884
 
gen6_emit_composite_texcoord_affine(struct sna *sna,
2885
 
                                    const struct sna_composite_channel *channel,
2886
 
                                    int16_t x, int16_t y)
2887
 
{
2888
 
        float t[2];
2889
 
 
2890
 
        sna_get_transformed_coordinates(x + channel->offset[0],
2891
 
                                        y + channel->offset[1],
2892
 
                                        channel->transform,
2893
 
                                        &t[0], &t[1]);
2894
 
        OUT_VERTEX_F(t[0] * channel->scale[0]);
2895
 
        OUT_VERTEX_F(t[1] * channel->scale[1]);
2896
 
}
2897
 
 
2898
 
inline static void
2899
 
gen6_emit_composite_spans_vertex(struct sna *sna,
2900
 
                                 const struct sna_composite_spans_op *op,
2901
 
                                 int16_t x, int16_t y)
2902
 
{
2903
 
        OUT_VERTEX(x, y);
2904
 
        gen6_emit_composite_texcoord(sna, &op->base.src, x, y);
2905
 
}
2906
 
 
2907
 
fastcall static void
2908
 
gen6_emit_composite_spans_primitive(struct sna *sna,
2909
 
                                    const struct sna_composite_spans_op *op,
2910
 
                                    const BoxRec *box,
2911
 
                                    float opacity)
2912
 
{
2913
 
        gen6_emit_composite_spans_vertex(sna, op, box->x2, box->y2);
2914
 
        OUT_VERTEX_F(opacity);
2915
 
 
2916
 
        gen6_emit_composite_spans_vertex(sna, op, box->x1, box->y2);
2917
 
        OUT_VERTEX_F(opacity);
2918
 
 
2919
 
        gen6_emit_composite_spans_vertex(sna, op, box->x1, box->y1);
2920
 
        OUT_VERTEX_F(opacity);
2921
 
}
2922
 
 
2923
 
fastcall static void
2924
 
gen6_emit_composite_spans_solid(struct sna *sna,
2925
 
                                const struct sna_composite_spans_op *op,
2926
 
                                const BoxRec *box,
2927
 
                                float opacity)
2928
 
{
2929
 
        OUT_VERTEX(box->x2, box->y2);
2930
 
        OUT_VERTEX_F(1); OUT_VERTEX_F(1);
2931
 
        OUT_VERTEX_F(opacity);
2932
 
 
2933
 
        OUT_VERTEX(box->x1, box->y2);
2934
 
        OUT_VERTEX_F(0); OUT_VERTEX_F(1);
2935
 
        OUT_VERTEX_F(opacity);
2936
 
 
2937
 
        OUT_VERTEX(box->x1, box->y1);
2938
 
        OUT_VERTEX_F(0); OUT_VERTEX_F(0);
2939
 
        OUT_VERTEX_F(opacity);
2940
 
}
2941
 
 
2942
 
fastcall static void
2943
 
gen6_emit_composite_spans_identity(struct sna *sna,
2944
 
                                   const struct sna_composite_spans_op *op,
2945
 
                                   const BoxRec *box,
2946
 
                                   float opacity)
2947
 
{
2948
 
        float *v;
2949
 
        union {
2950
 
                struct sna_coordinate p;
2951
 
                float f;
2952
 
        } dst;
2953
 
 
2954
 
        float sx = op->base.src.scale[0];
2955
 
        float sy = op->base.src.scale[1];
2956
 
        int16_t tx = op->base.src.offset[0];
2957
 
        int16_t ty = op->base.src.offset[1];
2958
 
 
2959
 
        v = sna->render.vertices + sna->render.vertex_used;
2960
 
        sna->render.vertex_used += 3*4;
2961
 
        assert(sna->render.vertex_used <= sna->render.vertex_size);
2962
 
 
2963
 
        dst.p.x = box->x2;
2964
 
        dst.p.y = box->y2;
2965
 
        v[0] = dst.f;
2966
 
        v[1] = (box->x2 + tx) * sx;
2967
 
        v[6] = v[2] = (box->y2 + ty) * sy;
2968
 
 
2969
 
        dst.p.x = box->x1;
2970
 
        v[4] = dst.f;
2971
 
        v[9] = v[5] = (box->x1 + tx) * sx;
2972
 
 
2973
 
        dst.p.y = box->y1;
2974
 
        v[8] = dst.f;
2975
 
        v[10] = (box->y1 + ty) * sy;
2976
 
 
2977
 
        v[11] = v[7] = v[3] = opacity;
2978
 
}
2979
 
 
2980
 
fastcall static void
2981
 
gen6_emit_composite_spans_simple(struct sna *sna,
2982
 
                                 const struct sna_composite_spans_op *op,
2983
 
                                 const BoxRec *box,
2984
 
                                 float opacity)
2985
 
{
2986
 
        float *v;
2987
 
        union {
2988
 
                struct sna_coordinate p;
2989
 
                float f;
2990
 
        } dst;
2991
 
 
2992
 
        float xx = op->base.src.transform->matrix[0][0];
2993
 
        float x0 = op->base.src.transform->matrix[0][2];
2994
 
        float yy = op->base.src.transform->matrix[1][1];
2995
 
        float y0 = op->base.src.transform->matrix[1][2];
2996
 
        float sx = op->base.src.scale[0];
2997
 
        float sy = op->base.src.scale[1];
2998
 
        int16_t tx = op->base.src.offset[0];
2999
 
        int16_t ty = op->base.src.offset[1];
3000
 
 
3001
 
        v = sna->render.vertices + sna->render.vertex_used;
3002
 
        sna->render.vertex_used += 3*4;
3003
 
        assert(sna->render.vertex_used <= sna->render.vertex_size);
3004
 
 
3005
 
        dst.p.x = box->x2;
3006
 
        dst.p.y = box->y2;
3007
 
        v[0] = dst.f;
3008
 
        v[1] = ((box->x2 + tx) * xx + x0) * sx;
3009
 
        v[6] = v[2] = ((box->y2 + ty) * yy + y0) * sy;
3010
 
 
3011
 
        dst.p.x = box->x1;
3012
 
        v[4] = dst.f;
3013
 
        v[9] = v[5] = ((box->x1 + tx) * xx + x0) * sx;
3014
 
 
3015
 
        dst.p.y = box->y1;
3016
 
        v[8] = dst.f;
3017
 
        v[10] = ((box->y1 + ty) * yy + y0) * sy;
3018
 
 
3019
 
        v[11] = v[7] = v[3] = opacity;
3020
 
}
3021
 
 
3022
 
fastcall static void
3023
 
gen6_emit_composite_spans_affine(struct sna *sna,
3024
 
                                 const struct sna_composite_spans_op *op,
3025
 
                                 const BoxRec *box,
3026
 
                                 float opacity)
3027
 
{
3028
 
        OUT_VERTEX(box->x2, box->y2);
3029
 
        gen6_emit_composite_texcoord_affine(sna, &op->base.src,
3030
 
                                            box->x2, box->y2);
3031
 
        OUT_VERTEX_F(opacity);
3032
 
 
3033
 
        OUT_VERTEX(box->x1, box->y2);
3034
 
        gen6_emit_composite_texcoord_affine(sna, &op->base.src,
3035
 
                                            box->x1, box->y2);
3036
 
        OUT_VERTEX_F(opacity);
3037
 
 
3038
 
        OUT_VERTEX(box->x1, box->y1);
3039
 
        gen6_emit_composite_texcoord_affine(sna, &op->base.src,
3040
 
                                            box->x1, box->y1);
3041
 
        OUT_VERTEX_F(opacity);
3042
 
}
3043
 
 
3044
2405
fastcall static void
3045
2406
gen6_render_composite_spans_box(struct sna *sna,
3046
2407
                                const struct sna_composite_spans_op *op,
3095
2456
{
3096
2457
        DBG(("%s()\n", __FUNCTION__));
3097
2458
 
3098
 
        if (sna->render_state.gen6.vertex_offset)
3099
 
                gen6_vertex_flush(sna);
 
2459
        if (sna->render.vertex_offset)
 
2460
                gen4_vertex_flush(sna);
3100
2461
 
3101
2462
        if (op->base.src.bo)
3102
2463
                kgem_bo_destroy(&sna->kgem, op->base.src.bo);
3128
2489
        }
3129
2490
 
3130
2491
        if ((flags & COMPOSITE_SPANS_RECTILINEAR) == 0) {
3131
 
                if ((flags & COMPOSITE_SPANS_INPLACE_HINT) == 0) {
3132
 
                        struct sna_pixmap *priv = sna_pixmap_from_drawable(dst->pDrawable);
3133
 
                        assert(priv);
3134
 
 
3135
 
                        if ((priv->cpu_bo && kgem_bo_is_busy(priv->cpu_bo)) ||
3136
 
                            (priv->gpu_bo && kgem_bo_is_busy(priv->gpu_bo))) {
3137
 
                                return true;
3138
 
                        }
3139
 
                }
 
2492
                struct sna_pixmap *priv = sna_pixmap_from_drawable(dst->pDrawable);
 
2493
                assert(priv);
 
2494
 
 
2495
                if (priv->cpu_bo && kgem_bo_is_busy(priv->cpu_bo))
 
2496
                        return true;
 
2497
 
 
2498
                if ((flags & COMPOSITE_SPANS_INPLACE_HINT) == 0 &&
 
2499
                    priv->gpu_bo && kgem_bo_is_busy(priv->gpu_bo))
 
2500
                        return true;
3140
2501
 
3141
2502
                DBG(("%s: fallback, non-rectilinear spans to idle bo\n",
3142
2503
                     __FUNCTION__));
3195
2556
        tmp->base.is_affine = tmp->base.src.is_affine;
3196
2557
        tmp->base.need_magic_ca_pass = false;
3197
2558
 
3198
 
        tmp->prim_emit = gen6_emit_composite_spans_primitive;
3199
 
        if (tmp->base.src.is_solid) {
3200
 
                tmp->prim_emit = gen6_emit_composite_spans_solid;
3201
 
        } else if (tmp->base.src.transform == NULL) {
3202
 
                tmp->prim_emit = gen6_emit_composite_spans_identity;
3203
 
        } else if (tmp->base.is_affine) {
3204
 
                if (tmp->base.src.transform->matrix[0][1] == 0 &&
3205
 
                    tmp->base.src.transform->matrix[1][0] == 0) {
3206
 
                        tmp->base.src.scale[0] /= tmp->base.src.transform->matrix[2][2];
3207
 
                        tmp->base.src.scale[1] /= tmp->base.src.transform->matrix[2][2];
3208
 
                        tmp->prim_emit = gen6_emit_composite_spans_simple;
3209
 
                } else
3210
 
                        tmp->prim_emit = gen6_emit_composite_spans_affine;
3211
 
        }
3212
 
        tmp->base.floats_per_vertex = 4 + !tmp->base.is_affine;
3213
 
        tmp->base.floats_per_rect = 3 * tmp->base.floats_per_vertex;
 
2559
        gen4_choose_spans_emitter(tmp);
3214
2560
 
3215
2561
        tmp->base.u.gen6.flags =
3216
2562
                GEN6_SET_FLAGS(SAMPLER_OFFSET(tmp->base.src.filter,
3219
2565
                                              SAMPLER_EXTEND_PAD),
3220
2566
                               gen6_get_blend(tmp->base.op, false, tmp->base.dst.format),
3221
2567
                               GEN6_WM_KERNEL_OPACITY | !tmp->base.is_affine,
3222
 
                               1 << 2 | (2+!tmp->base.is_affine));
 
2568
                               gen4_choose_spans_vertex_buffer(&tmp->base));
3223
2569
 
3224
2570
        tmp->box   = gen6_render_composite_spans_box;
3225
2571
        tmp->boxes = gen6_render_composite_spans_boxes;
3297
2643
        if (src_bo == dst_bo && can_switch_to_blt(sna))
3298
2644
                return true;
3299
2645
 
3300
 
        return ((flags & COPY_LAST && sna->kgem.ring != KGEM_RENDER) ||
3301
 
                prefer_blt_bo(sna, src_bo) ||
3302
 
                prefer_blt_bo(sna, dst_bo));
 
2646
        if ((flags & COPY_LAST && sna->kgem.ring != KGEM_RENDER))
 
2647
                return true;
 
2648
 
 
2649
        if (untiled_tlb_miss(src_bo) ||
 
2650
            untiled_tlb_miss(dst_bo))
 
2651
                return true;
 
2652
 
 
2653
        return (prefer_blt_bo(sna, src_bo) >= 0 &&
 
2654
                prefer_blt_bo(sna, dst_bo) >= 0);
3303
2655
}
3304
2656
 
3305
2657
inline static void boxes_extents(const BoxRec *box, int n, BoxRec *extents)
3530
2882
                } while (--n_this_time);
3531
2883
        } while (n);
3532
2884
 
3533
 
        gen6_vertex_flush(sna);
 
2885
        gen4_vertex_flush(sna);
3534
2886
        sna_render_composite_redirect_done(sna, &tmp);
3535
2887
        if (tmp.src.bo != src_bo)
3536
2888
                kgem_bo_destroy(&sna->kgem, tmp.src.bo);
3577
2929
{
3578
2930
        DBG(("%s()\n", __FUNCTION__));
3579
2931
 
3580
 
        if (sna->render_state.gen6.vertex_offset)
3581
 
                gen6_vertex_flush(sna);
 
2932
        if (sna->render.vertex_offset)
 
2933
                gen4_vertex_flush(sna);
3582
2934
}
3583
2935
 
3584
2936
static bool
3697
3049
        if (PREFER_RENDER)
3698
3050
                return PREFER_RENDER < 0;
3699
3051
 
 
3052
        if (untiled_tlb_miss(bo))
 
3053
                return true;
 
3054
 
3700
3055
        return (can_switch_to_blt(sna) ||
3701
3056
                prefer_blt_ring(sna) ||
3702
 
                untiled_tlb_miss(bo));
 
3057
                prefer_blt_bo(sna, bo) >= 0);
3703
3058
}
3704
3059
 
3705
3060
static bool
3830
3185
                } while (--n_this_time);
3831
3186
        } while (n);
3832
3187
 
3833
 
        gen6_vertex_flush(sna);
 
3188
        gen4_vertex_flush(sna);
3834
3189
        kgem_bo_destroy(&sna->kgem, tmp.src.bo);
3835
3190
        sna_render_composite_redirect_done(sna, &tmp);
3836
3191
        return true;
3923
3278
{
3924
3279
        DBG(("%s()\n", __FUNCTION__));
3925
3280
 
3926
 
        if (sna->render_state.gen6.vertex_offset)
3927
 
                gen6_vertex_flush(sna);
 
3281
        if (sna->render.vertex_offset)
 
3282
                gen4_vertex_flush(sna);
3928
3283
        kgem_bo_destroy(&sna->kgem, op->base.src.bo);
3929
3284
}
3930
3285
 
4078
3433
        v[7] = v[2]  = v[3]  = 1;
4079
3434
        v[6] = v[10] = v[11] = 0;
4080
3435
 
4081
 
        gen6_vertex_flush(sna);
 
3436
        gen4_vertex_flush(sna);
4082
3437
        kgem_bo_destroy(&sna->kgem, tmp.src.bo);
4083
3438
 
4084
3439
        return true;
4160
3515
        v[7] = v[2]  = v[3]  = 1;
4161
3516
        v[6] = v[10] = v[11] = 0;
4162
3517
 
4163
 
        gen6_vertex_flush(sna);
 
3518
        gen4_vertex_flush(sna);
4164
3519
        kgem_bo_destroy(&sna->kgem, tmp.src.bo);
4165
3520
 
4166
3521
        return true;
4168
3523
 
4169
3524
static void gen6_render_flush(struct sna *sna)
4170
3525
{
4171
 
        gen6_vertex_close(sna);
 
3526
        gen4_vertex_close(sna);
 
3527
 
 
3528
        assert(sna->render.vb_id == 0);
 
3529
        assert(sna->render.vertex_offset == 0);
4172
3530
}
4173
3531
 
4174
3532
static void
4175
3533
gen6_render_context_switch(struct kgem *kgem,
4176
3534
                           int new_mode)
4177
3535
{
4178
 
        if (!new_mode)
4179
 
                return;
4180
 
 
4181
 
         DBG(("%s: from %d to %d\n", __FUNCTION__, kgem->mode, new_mode));
4182
 
 
4183
 
        if (kgem->mode)
4184
 
                kgem_submit(kgem);
 
3536
        if (kgem->nbatch) {
 
3537
                DBG(("%s: from %d to %d\n", __FUNCTION__, kgem->mode, new_mode));
 
3538
                _kgem_submit(kgem);
 
3539
        }
4185
3540
 
4186
3541
        kgem->ring = new_mode;
4187
3542
}
4223
3578
{
4224
3579
        sna->render_state.gen6.needs_invariant = true;
4225
3580
        sna->render_state.gen6.first_state_packet = true;
4226
 
        sna->render_state.gen6.vb_id = 0;
4227
3581
        sna->render_state.gen6.ve_id = 3 << 2;
4228
3582
        sna->render_state.gen6.last_primitive = -1;
4229
3583