~ubuntu-branches/ubuntu/precise/xorg-server/precise-updates

« back to all changes in this revision

Viewing changes to glx/glxcmds.c

Tags: 2:1.10.1-2
* Build xserver-xorg-core-udeb on hurd-i386.  Thanks, Samuel Thibault!
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
#include "glxserver.h"
39
39
#include <GL/glxtokens.h>
40
40
#include <unpack.h>
41
 
#include "g_disptab.h"
42
41
#include <pixmapstr.h>
43
42
#include <windowstr.h>
44
43
#include "glxutil.h"
315
314
 
316
315
int __glXDisp_CreateContext(__GLXclientState *cl, GLbyte *pc)
317
316
{
 
317
    ClientPtr client = cl->client;
318
318
    xGLXCreateContextReq *req = (xGLXCreateContextReq *) pc;
319
319
    __GLXconfig *config;
320
320
    __GLXscreen *pGlxScreen;
321
321
    int err;
322
322
 
 
323
    REQUEST_SIZE_MATCH(xGLXCreateContextReq);
 
324
 
323
325
    if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
324
326
        return err;
325
327
    if (!validGlxVisual(cl->client, pGlxScreen, req->visual, &config, &err))
331
333
 
332
334
int __glXDisp_CreateNewContext(__GLXclientState *cl, GLbyte *pc)
333
335
{
 
336
    ClientPtr client = cl->client;
334
337
    xGLXCreateNewContextReq *req = (xGLXCreateNewContextReq *) pc;
335
338
    __GLXconfig *config;
336
339
    __GLXscreen *pGlxScreen;
337
340
    int err;
338
341
 
 
342
    REQUEST_SIZE_MATCH(xGLXCreateNewContextReq);
 
343
 
339
344
    if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
340
345
        return err;
341
346
    if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err))
347
352
 
348
353
int __glXDisp_CreateContextWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
349
354
{
 
355
    ClientPtr client = cl->client;
350
356
    xGLXCreateContextWithConfigSGIXReq *req = 
351
357
        (xGLXCreateContextWithConfigSGIXReq *) pc;
352
358
    __GLXconfig *config;
353
359
    __GLXscreen *pGlxScreen;
354
360
    int err;
355
361
 
 
362
    REQUEST_SIZE_MATCH(xGLXCreateContextWithConfigSGIXReq);
 
363
 
356
364
    if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
357
365
        return err;
358
366
    if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err))
363
371
}
364
372
int __glXDisp_DestroyContext(__GLXclientState *cl, GLbyte *pc)
365
373
{
 
374
    ClientPtr client = cl->client;
366
375
    xGLXDestroyContextReq *req = (xGLXDestroyContextReq *) pc;
367
376
    __GLXcontext *glxc;
368
377
    int err;
369
378
 
 
379
    REQUEST_SIZE_MATCH(xGLXDestroyContextReq);
 
380
 
370
381
    if (!validGlxContext(cl->client, req->context, DixDestroyAccess,
371
382
                         &glxc, &err))
372
383
            return err;
686
697
 
687
698
int __glXDisp_MakeCurrent(__GLXclientState *cl, GLbyte *pc)
688
699
{
 
700
    ClientPtr client = cl->client;
689
701
    xGLXMakeCurrentReq *req = (xGLXMakeCurrentReq *) pc;
690
702
 
 
703
    REQUEST_SIZE_MATCH(xGLXMakeCurrentReq);
 
704
 
691
705
    return DoMakeCurrent( cl, req->drawable, req->drawable,
692
706
                          req->context, req->oldContextTag );
693
707
}
694
708
 
695
709
int __glXDisp_MakeContextCurrent(__GLXclientState *cl, GLbyte *pc)
696
710
{
 
711
    ClientPtr client = cl->client;
697
712
    xGLXMakeContextCurrentReq *req = (xGLXMakeContextCurrentReq *) pc;
698
713
 
 
714
    REQUEST_SIZE_MATCH(xGLXMakeContextCurrentReq);
 
715
 
699
716
    return DoMakeCurrent( cl, req->drawable, req->readdrawable,
700
717
                          req->context, req->oldContextTag );
701
718
}
702
719
 
703
720
int __glXDisp_MakeCurrentReadSGI(__GLXclientState *cl, GLbyte *pc)
704
721
{
 
722
    ClientPtr client = cl->client;
705
723
    xGLXMakeCurrentReadSGIReq *req = (xGLXMakeCurrentReadSGIReq *) pc;
706
724
 
 
725
    REQUEST_SIZE_MATCH(xGLXMakeCurrentReadSGIReq);
 
726
 
707
727
    return DoMakeCurrent( cl, req->drawable, req->readable,
708
728
                          req->context, req->oldContextTag );
709
729
}
716
736
    __GLXcontext *glxc;
717
737
    int err;
718
738
 
 
739
    REQUEST_SIZE_MATCH(xGLXIsDirectReq);
 
740
 
719
741
    if (!validGlxContext(cl->client, req->context, DixReadAccess, &glxc, &err))
720
742
        return err;
721
743
 
740
762
    xGLXQueryVersionReply reply;
741
763
    GLuint major, minor;
742
764
 
 
765
    REQUEST_SIZE_MATCH(xGLXQueryVersionReq);
 
766
 
743
767
    major = req->majorVersion;
744
768
    minor = req->minorVersion;
745
769
    (void)major;
766
790
 
767
791
int __glXDisp_WaitGL(__GLXclientState *cl, GLbyte *pc)
768
792
{
 
793
    ClientPtr client = cl->client;
769
794
    xGLXWaitGLReq *req = (xGLXWaitGLReq *)pc;
770
 
    GLXContextTag tag = req->contextTag;
 
795
    GLXContextTag tag;
771
796
    __GLXcontext *glxc = NULL;
772
797
    int error;
773
798
 
 
799
    REQUEST_SIZE_MATCH(xGLXWaitGLReq);
 
800
 
 
801
    tag = req->contextTag;
774
802
    if (tag) {
775
803
        glxc = __glXLookupContextByTag(cl, tag);
776
804
        if (!glxc)
790
818
 
791
819
int __glXDisp_WaitX(__GLXclientState *cl, GLbyte *pc)
792
820
{
 
821
    ClientPtr client = cl->client;
793
822
    xGLXWaitXReq *req = (xGLXWaitXReq *)pc;
794
 
    GLXContextTag tag = req->contextTag;
 
823
    GLXContextTag tag;
795
824
    __GLXcontext *glxc = NULL;
796
825
    int error;
797
826
 
 
827
    REQUEST_SIZE_MATCH(xGLXWaitXReq);
 
828
 
 
829
    tag = req->contextTag;
798
830
    if (tag) {
799
831
        glxc = __glXLookupContextByTag(cl, tag);
800
832
        if (!glxc)
814
846
{
815
847
    ClientPtr client = cl->client;
816
848
    xGLXCopyContextReq *req = (xGLXCopyContextReq *) pc;
817
 
    GLXContextID source = req->source;
818
 
    GLXContextID dest = req->dest;
819
 
    GLXContextTag tag = req->contextTag;
820
 
    unsigned long mask = req->mask;
 
849
    GLXContextID source;
 
850
    GLXContextID dest;
 
851
    GLXContextTag tag;
 
852
    unsigned long mask;
821
853
    __GLXcontext *src, *dst;
822
854
    int error;
823
855
 
 
856
    REQUEST_SIZE_MATCH(xGLXCopyContextReq);
 
857
 
 
858
    source = req->source;
 
859
    dest = req->dest;
 
860
    tag = req->contextTag;
 
861
    mask = req->mask;
824
862
    if (!validGlxContext(cl->client, source, DixReadAccess, &src, &error))
825
863
        return error;
826
864
    if (!validGlxContext(cl->client, dest, DixWriteAccess, &dst, &error))
903
941
    __GLX_DECLARE_SWAP_VARIABLES;
904
942
    __GLX_DECLARE_SWAP_ARRAY_VARIABLES;
905
943
 
 
944
    REQUEST_SIZE_MATCH(xGLXGetVisualConfigsReq);
 
945
 
906
946
    if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
907
947
        return err;
908
948
 
1082
1122
 
1083
1123
int __glXDisp_GetFBConfigs(__GLXclientState *cl, GLbyte *pc)
1084
1124
{
 
1125
    ClientPtr client = cl->client;
1085
1126
    xGLXGetFBConfigsReq *req = (xGLXGetFBConfigsReq *) pc;
 
1127
    REQUEST_SIZE_MATCH(xGLXGetFBConfigsReq);
1086
1128
    return DoGetFBConfigs(cl, req->screen);
1087
1129
}
1088
1130
 
1089
1131
int __glXDisp_GetFBConfigsSGIX(__GLXclientState *cl, GLbyte *pc)
1090
1132
{
 
1133
    ClientPtr client = cl->client;
1091
1134
    xGLXGetFBConfigsSGIXReq *req = (xGLXGetFBConfigsSGIXReq *) pc;
 
1135
    /* work around mesa bug, don't use REQUEST_SIZE_MATCH */
 
1136
    REQUEST_AT_LEAST_SIZE(xGLXGetFBConfigsSGIXReq);
1092
1137
    return DoGetFBConfigs(cl, req->screen);
1093
1138
}
1094
1139
 
1214
1259
 
1215
1260
int __glXDisp_CreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
1216
1261
{
 
1262
    ClientPtr client = cl->client;
1217
1263
    xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc;
1218
1264
    __GLXconfig *config;
1219
1265
    __GLXscreen *pGlxScreen;
1220
1266
    int err;
1221
1267
 
 
1268
    REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapReq);
 
1269
 
1222
1270
    if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
1223
1271
        return err;
1224
1272
    if (!validGlxVisual(cl->client, pGlxScreen, req->visual, &config, &err))
1230
1278
 
1231
1279
int __glXDisp_CreatePixmap(__GLXclientState *cl, GLbyte *pc)
1232
1280
{
 
1281
    ClientPtr client = cl->client;
1233
1282
    xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc;
1234
1283
    __GLXconfig *config;
1235
1284
    __GLXscreen *pGlxScreen;
1236
1285
    int err;
1237
1286
 
 
1287
    REQUEST_AT_LEAST_SIZE(xGLXCreatePixmapReq);
 
1288
    if (req->numAttribs > (UINT32_MAX >> 3)) {
 
1289
        client->errorValue = req->numAttribs;
 
1290
        return BadValue;
 
1291
    }
 
1292
    REQUEST_FIXED_SIZE(xGLXCreatePixmapReq, req->numAttribs << 3);
 
1293
 
1238
1294
    if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
1239
1295
        return err;
1240
1296
    if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err))
1253
1309
 
1254
1310
int __glXDisp_CreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
1255
1311
{
 
1312
    ClientPtr client = cl->client;
1256
1313
    xGLXCreateGLXPixmapWithConfigSGIXReq *req = 
1257
1314
        (xGLXCreateGLXPixmapWithConfigSGIXReq *) pc;
1258
1315
    __GLXconfig *config;
1259
1316
    __GLXscreen *pGlxScreen;
1260
1317
    int err;
1261
1318
 
 
1319
    REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapWithConfigSGIXReq);
 
1320
 
1262
1321
    if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
1263
1322
        return err;
1264
1323
    if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err))
1285
1344
 
1286
1345
int __glXDisp_DestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc)
1287
1346
{
 
1347
    ClientPtr client = cl->client;
1288
1348
    xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc;
1289
1349
 
 
1350
    REQUEST_SIZE_MATCH(xGLXDestroyGLXPixmapReq);
 
1351
 
1290
1352
    return DoDestroyDrawable(cl, req->glxpixmap, GLX_DRAWABLE_PIXMAP);
1291
1353
}
1292
1354
 
1293
1355
int __glXDisp_DestroyPixmap(__GLXclientState *cl, GLbyte *pc)
1294
1356
{
 
1357
    ClientPtr client = cl->client;
1295
1358
    xGLXDestroyPixmapReq *req = (xGLXDestroyPixmapReq *) pc;
1296
1359
 
 
1360
    /* should be REQUEST_SIZE_MATCH, but mesa's glXDestroyPixmap used to set
 
1361
     * length to 3 instead of 2 */
 
1362
    REQUEST_AT_LEAST_SIZE(xGLXDestroyPixmapReq);
 
1363
 
1297
1364
    return DoDestroyDrawable(cl, req->glxpixmap, GLX_DRAWABLE_PIXMAP);
1298
1365
}
1299
1366
 
1332
1399
 
1333
1400
int __glXDisp_CreatePbuffer(__GLXclientState *cl, GLbyte *pc)
1334
1401
{
 
1402
    ClientPtr client = cl->client;
1335
1403
    xGLXCreatePbufferReq        *req = (xGLXCreatePbufferReq *) pc;
1336
1404
    CARD32                      *attrs;
1337
1405
    int                          width, height, i;
1338
1406
 
 
1407
    REQUEST_AT_LEAST_SIZE(xGLXCreatePbufferReq);
 
1408
    if (req->numAttribs > (UINT32_MAX >> 3)) {
 
1409
        client->errorValue = req->numAttribs;
 
1410
        return BadValue;
 
1411
    }
 
1412
    REQUEST_FIXED_SIZE(xGLXCreatePbufferReq, req->numAttribs << 3);
 
1413
 
1339
1414
    attrs = (CARD32 *) (req + 1);
1340
1415
    width = 0;
1341
1416
    height = 0;
1361
1436
 
1362
1437
int __glXDisp_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc)
1363
1438
{
 
1439
    ClientPtr client = cl->client;
1364
1440
    xGLXCreateGLXPbufferSGIXReq *req = (xGLXCreateGLXPbufferSGIXReq *) pc;
1365
1441
 
 
1442
    REQUEST_AT_LEAST_SIZE(xGLXCreateGLXPbufferSGIXReq);
 
1443
 
1366
1444
    return DoCreatePbuffer(cl->client, req->screen, req->fbconfig,
1367
1445
                           req->width, req->height, req->pbuffer);
1368
1446
}
1369
1447
 
1370
1448
int __glXDisp_DestroyPbuffer(__GLXclientState *cl, GLbyte *pc)
1371
1449
{
 
1450
    ClientPtr client = cl->client;
1372
1451
    xGLXDestroyPbufferReq *req = (xGLXDestroyPbufferReq *) pc;
1373
1452
 
 
1453
    REQUEST_SIZE_MATCH(xGLXDestroyPbufferReq);
 
1454
 
1374
1455
    return DoDestroyDrawable(cl, req->pbuffer, GLX_DRAWABLE_PBUFFER);
1375
1456
}
1376
1457
 
1377
1458
int __glXDisp_DestroyGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc)
1378
1459
{
 
1460
    ClientPtr client = cl->client;
1379
1461
    xGLXDestroyGLXPbufferSGIXReq *req = (xGLXDestroyGLXPbufferSGIXReq *) pc;
1380
1462
 
 
1463
    REQUEST_SIZE_MATCH(xGLXDestroyGLXPbufferSGIXReq);
 
1464
 
1381
1465
    return DoDestroyDrawable(cl, req->pbuffer, GLX_DRAWABLE_PBUFFER);
1382
1466
}
1383
1467
 
1408
1492
 
1409
1493
int __glXDisp_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
1410
1494
{
 
1495
    ClientPtr client = cl->client;
1411
1496
    xGLXChangeDrawableAttributesReq *req =
1412
1497
        (xGLXChangeDrawableAttributesReq *) pc;
1413
1498
 
 
1499
    REQUEST_AT_LEAST_SIZE(xGLXChangeDrawableAttributesReq);
 
1500
    if (req->numAttribs > (UINT32_MAX >> 3)) {
 
1501
        client->errorValue = req->numAttribs;
 
1502
        return BadValue;
 
1503
    }
 
1504
#if 0
 
1505
    /* mesa sends an additional 8 bytes */
 
1506
    REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3);
 
1507
#else
 
1508
    if (((sizeof(xGLXChangeDrawableAttributesReq) + (req->numAttribs << 3)) >> 2) < client->req_len)
 
1509
            return BadLength;
 
1510
#endif
 
1511
 
1414
1512
    return DoChangeDrawableAttributes(cl->client, req->drawable,
1415
1513
                                      req->numAttribs, (CARD32 *) (req + 1));
1416
1514
}
1417
1515
 
1418
1516
int __glXDisp_ChangeDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc)
1419
1517
{
 
1518
    ClientPtr client = cl->client;
1420
1519
    xGLXChangeDrawableAttributesSGIXReq *req =
1421
1520
        (xGLXChangeDrawableAttributesSGIXReq *)pc;
1422
1521
 
 
1522
    REQUEST_AT_LEAST_SIZE(xGLXChangeDrawableAttributesSGIXReq);
 
1523
    if (req->numAttribs > (UINT32_MAX >> 3)) {
 
1524
        client->errorValue = req->numAttribs;
 
1525
        return BadValue;
 
1526
    }
 
1527
    REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesSGIXReq, req->numAttribs << 3);
 
1528
 
1423
1529
    return DoChangeDrawableAttributes(cl->client, req->drawable,
1424
1530
                                      req->numAttribs, (CARD32 *) (req + 1));
1425
1531
}
1433
1539
    DrawablePtr          pDraw;
1434
1540
    int                  err;
1435
1541
 
 
1542
    REQUEST_AT_LEAST_SIZE(xGLXCreateWindowReq);
 
1543
    if (req->numAttribs > (UINT32_MAX >> 3)) {
 
1544
        client->errorValue = req->numAttribs;
 
1545
        return BadValue;
 
1546
    }
 
1547
    REQUEST_FIXED_SIZE(xGLXCreateWindowReq, req->numAttribs << 3);
 
1548
 
1436
1549
    LEGAL_NEW_RESOURCE(req->glxwindow, client);
1437
1550
 
1438
1551
    if (!validGlxScreen(client, req->screen, &pGlxScreen, &err))
1456
1569
 
1457
1570
int __glXDisp_DestroyWindow(__GLXclientState *cl, GLbyte *pc)
1458
1571
{
 
1572
    ClientPtr client = cl->client;
1459
1573
    xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc;
1460
1574
 
 
1575
    /* mesa's glXDestroyWindow used to set length to 3 instead of 2 */
 
1576
    REQUEST_AT_LEAST_SIZE(xGLXDestroyWindowReq);
 
1577
 
1461
1578
    return DoDestroyDrawable(cl, req->glxwindow, GLX_DRAWABLE_WINDOW);
1462
1579
}
1463
1580
 
1473
1590
{
1474
1591
    ClientPtr client = cl->client;
1475
1592
    xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc;
1476
 
    GLXContextTag tag = req->contextTag;
1477
 
    XID drawId = req->drawable;
 
1593
    GLXContextTag tag;
 
1594
    XID drawId;
1478
1595
    __GLXcontext *glxc = NULL;
1479
1596
    __GLXdrawable *pGlxDraw;
1480
1597
    int error;
1481
1598
 
 
1599
    REQUEST_SIZE_MATCH(xGLXSwapBuffersReq);
 
1600
 
 
1601
    tag = req->contextTag;
 
1602
    drawId = req->drawable;
1482
1603
    if (tag) {
1483
1604
        glxc = __glXLookupContextByTag(cl, tag);
1484
1605
        if (!glxc) {
1559
1680
 
1560
1681
int __glXDisp_QueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc)
1561
1682
{
 
1683
    ClientPtr client = cl->client;
1562
1684
    xGLXQueryContextInfoEXTReq *req = (xGLXQueryContextInfoEXTReq *) pc;
1563
1685
 
 
1686
    REQUEST_SIZE_MATCH(xGLXQueryContextInfoEXTReq);
 
1687
 
1564
1688
    return DoQueryContext(cl, req->context);
1565
1689
}
1566
1690
 
1567
1691
int __glXDisp_QueryContext(__GLXclientState *cl, GLbyte *pc)
1568
1692
{
 
1693
    ClientPtr client = cl->client;
1569
1694
    xGLXQueryContextReq *req = (xGLXQueryContextReq *) pc;
1570
1695
 
 
1696
    REQUEST_SIZE_MATCH(xGLXQueryContextReq);
 
1697
 
1571
1698
    return DoQueryContext(cl, req->context);
1572
1699
}
1573
1700
 
1580
1707
    GLXDrawable          drawId;
1581
1708
    int                  buffer;
1582
1709
    int                  error;
 
1710
    CARD32               num_attribs;
 
1711
 
 
1712
    if ((sizeof(xGLXVendorPrivateReq) + 12) >> 2 > client->req_len)
 
1713
        return BadLength;
1583
1714
 
1584
1715
    pc += __GLX_VENDPRIV_HDR_SIZE;
1585
1716
 
1586
1717
    drawId = *((CARD32 *) (pc));
1587
1718
    buffer = *((INT32 *)  (pc + 4));
 
1719
    num_attribs = *((CARD32 *) (pc + 8));
 
1720
    if (num_attribs > (UINT32_MAX >> 3)) {
 
1721
        client->errorValue = num_attribs;
 
1722
        return BadValue;
 
1723
    }
 
1724
    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 12 + (num_attribs << 3));
1588
1725
 
1589
1726
    if (buffer != GLX_FRONT_LEFT_EXT)
1590
1727
        return __glXError(GLXBadPixmap);
1615
1752
    int                  buffer;
1616
1753
    int                  error;
1617
1754
 
 
1755
    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8);
 
1756
 
1618
1757
    pc += __GLX_VENDPRIV_HDR_SIZE;
1619
1758
 
1620
1759
    drawId = *((CARD32 *) (pc));
1650
1789
    (void) client;
1651
1790
    (void) req;
1652
1791
 
 
1792
    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 20);
 
1793
 
1653
1794
    pc += __GLX_VENDPRIV_HDR_SIZE;
1654
1795
 
1655
1796
    drawId = *((CARD32 *) (pc));
1738
1879
 
1739
1880
int __glXDisp_GetDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
1740
1881
{
 
1882
    ClientPtr client = cl->client;
1741
1883
    xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc;
1742
1884
 
 
1885
    /* this should be REQUEST_SIZE_MATCH, but mesa sends an additional 4 bytes */
 
1886
    REQUEST_AT_LEAST_SIZE(xGLXGetDrawableAttributesReq);
 
1887
 
1743
1888
    return DoGetDrawableAttributes(cl, req->drawable);
1744
1889
}
1745
1890
 
1746
1891
int __glXDisp_GetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc)
1747
1892
{
 
1893
    ClientPtr client = cl->client;
1748
1894
    xGLXGetDrawableAttributesSGIXReq *req =
1749
1895
        (xGLXGetDrawableAttributesSGIXReq *)pc;
1750
1896
    
 
1897
    REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesSGIXReq);
 
1898
 
1751
1899
    return DoGetDrawableAttributes(cl, req->drawable);
1752
1900
}
1753
1901
 
1772
1920
    __GLXcontext *glxc;
1773
1921
    __GLX_DECLARE_SWAP_VARIABLES;
1774
1922
 
 
1923
    REQUEST_AT_LEAST_SIZE(xGLXRenderReq);
 
1924
 
1775
1925
    req = (xGLXRenderReq *) pc;
1776
1926
    if (client->swapped) {
1777
1927
        __GLX_SWAP_SHORT(&req->length);
1792
1942
        __GLXdispatchRenderProcPtr proc;
1793
1943
        int err;
1794
1944
 
 
1945
        if (left < sizeof(__GLXrenderHeader))
 
1946
            return BadLength;
 
1947
 
1795
1948
        /*
1796
1949
        ** Verify that the header length and the overall length agree.
1797
1950
        ** Also, each command must be word aligned.
2061
2214
    }
2062
2215
}
2063
2216
 
2064
 
extern RESTYPE __glXSwapBarrierRes;
2065
 
 
2066
 
int __glXDisp_BindSwapBarrierSGIX(__GLXclientState *cl, GLbyte *pc)
2067
 
{
2068
 
    ClientPtr client = cl->client;
2069
 
    xGLXBindSwapBarrierSGIXReq *req = (xGLXBindSwapBarrierSGIXReq *) pc;
2070
 
    XID drawable = req->drawable;
2071
 
    int barrier = req->barrier;
2072
 
    DrawablePtr pDraw;
2073
 
    int screen, rc;
2074
 
    __GLXscreen *pGlxScreen;
2075
 
 
2076
 
    rc = dixLookupDrawable(&pDraw, drawable, client, 0, DixGetAttrAccess);
2077
 
    pGlxScreen = glxGetScreen(pDraw->pScreen);
2078
 
    if (rc == Success && (pDraw->type == DRAWABLE_WINDOW)) {
2079
 
        screen = pDraw->pScreen->myNum;
2080
 
        if (pGlxScreen->swapBarrierFuncs) {
2081
 
            int ret = pGlxScreen->swapBarrierFuncs->bindSwapBarrierFunc(screen, drawable, barrier);
2082
 
            if (ret == Success) {
2083
 
                if (barrier)
2084
 
                    /* add source for cleanup when drawable is gone */
2085
 
                    AddResource(drawable, __glXSwapBarrierRes, (pointer)(intptr_t)screen);
2086
 
                else
2087
 
                    /* delete source */
2088
 
                    FreeResourceByType(drawable, __glXSwapBarrierRes, FALSE);
2089
 
            }
2090
 
            return ret;
2091
 
        }
2092
 
    }
2093
 
    client->errorValue = drawable;
2094
 
    return __glXError(GLXBadDrawable);
2095
 
}
2096
 
 
2097
 
 
2098
 
int __glXDisp_QueryMaxSwapBarriersSGIX(__GLXclientState *cl, GLbyte *pc)
2099
 
{
2100
 
    ClientPtr client = cl->client;
2101
 
    xGLXQueryMaxSwapBarriersSGIXReq *req =
2102
 
                                    (xGLXQueryMaxSwapBarriersSGIXReq *) pc;
2103
 
    xGLXQueryMaxSwapBarriersSGIXReply reply;
2104
 
    int screen = req->screen;
2105
 
    __GLXscreen *pGlxScreen;
2106
 
 
2107
 
    pGlxScreen = glxGetScreen(screenInfo.screens[screen]);
2108
 
    if (pGlxScreen->swapBarrierFuncs)
2109
 
        reply.max = pGlxScreen->swapBarrierFuncs->queryMaxSwapBarriersFunc(screen);
2110
 
    else
2111
 
        reply.max = 0;
2112
 
 
2113
 
 
2114
 
    reply.length = 0;
2115
 
    reply.type = X_Reply;
2116
 
    reply.sequenceNumber = client->sequence;
2117
 
 
2118
 
    if (client->swapped) {
2119
 
        __GLX_DECLARE_SWAP_VARIABLES;
2120
 
        __GLX_SWAP_SHORT(&reply.sequenceNumber);
2121
 
    }
2122
 
 
2123
 
    WriteToClient(client, sz_xGLXQueryMaxSwapBarriersSGIXReply,
2124
 
                        (char *) &reply);
2125
 
    return Success;
2126
 
}
2127
 
 
2128
 
#define GLX_BAD_HYPERPIPE_SGIX 92
2129
 
 
2130
 
int __glXDisp_QueryHyperpipeNetworkSGIX(__GLXclientState *cl, GLbyte *pc)
2131
 
{
2132
 
    ClientPtr client = cl->client;
2133
 
    xGLXQueryHyperpipeNetworkSGIXReq * req = (xGLXQueryHyperpipeNetworkSGIXReq *) pc;
2134
 
    xGLXQueryHyperpipeNetworkSGIXReply reply;
2135
 
    int screen = req->screen;
2136
 
    void *rdata = NULL;
2137
 
 
2138
 
    int length=0;
2139
 
    int npipes=0;
2140
 
 
2141
 
    int n= 0;
2142
 
    __GLXscreen *pGlxScreen;
2143
 
 
2144
 
    pGlxScreen = glxGetScreen(screenInfo.screens[screen]);
2145
 
    if (pGlxScreen->hyperpipeFuncs) {
2146
 
        rdata =
2147
 
            (pGlxScreen->hyperpipeFuncs->queryHyperpipeNetworkFunc(screen, &npipes, &n));
2148
 
    }
2149
 
    length = __GLX_PAD(n) >> 2;
2150
 
    reply.type = X_Reply;
2151
 
    reply.sequenceNumber = client->sequence;
2152
 
    reply.length = length;
2153
 
    reply.n = n;
2154
 
    reply.npipes = npipes;
2155
 
 
2156
 
    if (client->swapped) {
2157
 
        __GLX_DECLARE_SWAP_VARIABLES;
2158
 
        __GLX_SWAP_SHORT(&reply.sequenceNumber);
2159
 
        __GLX_SWAP_INT(&reply.length);
2160
 
        __GLX_SWAP_INT(&reply.n);
2161
 
        __GLX_SWAP_INT(&reply.npipes);
2162
 
    }
2163
 
    WriteToClient(client, sz_xGLXQueryHyperpipeNetworkSGIXReply,
2164
 
                  (char *) &reply);
2165
 
 
2166
 
    WriteToClient(client, length << 2, (char *)rdata);
2167
 
 
2168
 
    return Success;
2169
 
}
2170
 
 
2171
 
int __glXDisp_DestroyHyperpipeConfigSGIX (__GLXclientState *cl, GLbyte *pc)
2172
 
{
2173
 
    ClientPtr client = cl->client;
2174
 
    xGLXDestroyHyperpipeConfigSGIXReq * req =
2175
 
        (xGLXDestroyHyperpipeConfigSGIXReq *) pc;
2176
 
    xGLXDestroyHyperpipeConfigSGIXReply reply;
2177
 
    int screen = req->screen;
2178
 
    int  success = GLX_BAD_HYPERPIPE_SGIX;
2179
 
    int hpId ;
2180
 
    __GLXscreen *pGlxScreen;
2181
 
 
2182
 
    hpId = req->hpId;
2183
 
 
2184
 
    pGlxScreen = glxGetScreen(screenInfo.screens[screen]);
2185
 
    if (pGlxScreen->hyperpipeFuncs) {
2186
 
        success = pGlxScreen->hyperpipeFuncs->destroyHyperpipeConfigFunc(screen, hpId);
2187
 
    }
2188
 
 
2189
 
    reply.type = X_Reply;
2190
 
    reply.sequenceNumber = client->sequence;
2191
 
    reply.length = __GLX_PAD(0) >> 2;
2192
 
    reply.n = 0;
2193
 
    reply.success = success;
2194
 
 
2195
 
 
2196
 
    if (client->swapped) {
2197
 
        __GLX_DECLARE_SWAP_VARIABLES;
2198
 
        __GLX_SWAP_SHORT(&reply.sequenceNumber);
2199
 
    }
2200
 
    WriteToClient(client,
2201
 
                  sz_xGLXDestroyHyperpipeConfigSGIXReply,
2202
 
                  (char *) &reply);
2203
 
    return Success;
2204
 
}
2205
 
 
2206
 
int __glXDisp_QueryHyperpipeConfigSGIX(__GLXclientState *cl, GLbyte *pc)
2207
 
{
2208
 
    ClientPtr client = cl->client;
2209
 
    xGLXQueryHyperpipeConfigSGIXReq * req =
2210
 
        (xGLXQueryHyperpipeConfigSGIXReq *) pc;
2211
 
    xGLXQueryHyperpipeConfigSGIXReply reply;
2212
 
    int screen = req->screen;
2213
 
    void *rdata = NULL;
2214
 
    int length;
2215
 
    int npipes=0;
2216
 
    int n= 0;
2217
 
    int hpId;
2218
 
    __GLXscreen *pGlxScreen;
2219
 
 
2220
 
    hpId = req->hpId;
2221
 
 
2222
 
    pGlxScreen = glxGetScreen(screenInfo.screens[screen]);
2223
 
    if (pGlxScreen->hyperpipeFuncs) {
2224
 
        rdata = pGlxScreen->hyperpipeFuncs->queryHyperpipeConfigFunc(screen, hpId,&npipes, &n);
2225
 
    }
2226
 
 
2227
 
    length = __GLX_PAD(n) >> 2;
2228
 
    reply.type = X_Reply;
2229
 
    reply.sequenceNumber = client->sequence;
2230
 
    reply.length = length;
2231
 
    reply.n = n;
2232
 
    reply.npipes = npipes;
2233
 
 
2234
 
 
2235
 
    if (client->swapped) {
2236
 
        __GLX_DECLARE_SWAP_VARIABLES;
2237
 
        __GLX_SWAP_SHORT(&reply.sequenceNumber);
2238
 
        __GLX_SWAP_INT(&reply.length);
2239
 
        __GLX_SWAP_INT(&reply.n);
2240
 
        __GLX_SWAP_INT(&reply.npipes);
2241
 
    }
2242
 
 
2243
 
    WriteToClient(client, sz_xGLXQueryHyperpipeConfigSGIXReply,
2244
 
                  (char *) &reply);
2245
 
 
2246
 
    WriteToClient(client, length << 2, (char *)rdata);
2247
 
 
2248
 
    return Success;
2249
 
}
2250
 
 
2251
 
int __glXDisp_HyperpipeConfigSGIX(__GLXclientState *cl, GLbyte *pc)
2252
 
{
2253
 
    ClientPtr client = cl->client;
2254
 
    xGLXHyperpipeConfigSGIXReq * req =
2255
 
        (xGLXHyperpipeConfigSGIXReq *) pc;
2256
 
    xGLXHyperpipeConfigSGIXReply reply;
2257
 
    int screen = req->screen;
2258
 
    void *rdata;
2259
 
 
2260
 
    int npipes=0, networkId;
2261
 
    int hpId=-1;
2262
 
    __GLXscreen *pGlxScreen;
2263
 
 
2264
 
    pGlxScreen = glxGetScreen(screenInfo.screens[screen]);
2265
 
    networkId = (int)req->networkId;
2266
 
    npipes = (int)req->npipes;
2267
 
    rdata = (void *)(req +1);
2268
 
 
2269
 
    if (pGlxScreen->hyperpipeFuncs) {
2270
 
        pGlxScreen->hyperpipeFuncs->hyperpipeConfigFunc(screen,networkId,
2271
 
                                                        &hpId, &npipes,
2272
 
                                                        (void *) rdata);
2273
 
    }
2274
 
 
2275
 
    reply.type = X_Reply;
2276
 
    reply.sequenceNumber = client->sequence;
2277
 
    reply.length = __GLX_PAD(0) >> 2;
2278
 
    reply.n = 0;
2279
 
    reply.npipes = npipes;
2280
 
    reply.hpId = hpId;
2281
 
 
2282
 
    if (client->swapped) {
2283
 
        __GLX_DECLARE_SWAP_VARIABLES;
2284
 
        __GLX_SWAP_SHORT(&reply.sequenceNumber);
2285
 
        __GLX_SWAP_INT(&reply.npipes);
2286
 
        __GLX_SWAP_INT(&reply.hpId);
2287
 
    }
2288
 
 
2289
 
    WriteToClient(client, sz_xGLXHyperpipeConfigSGIXReply,
2290
 
                  (char *) &reply);
2291
 
 
2292
 
    return Success;
2293
 
}
2294
 
 
2295
 
 
2296
2217
/************************************************************************/
2297
2218
 
2298
2219
/*
2302
2223
 
2303
2224
int __glXDisp_VendorPrivate(__GLXclientState *cl, GLbyte *pc)
2304
2225
{
 
2226
    ClientPtr client = cl->client;
2305
2227
    xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
2306
2228
    GLint vendorcode = req->vendorCode;
2307
2229
    __GLXdispatchVendorPrivProcPtr proc;
2308
2230
 
 
2231
    REQUEST_AT_LEAST_SIZE(xGLXVendorPrivateReq);
2309
2232
 
2310
2233
    proc = (__GLXdispatchVendorPrivProcPtr)
2311
2234
      __glXGetProtocolDecodeFunction(& VendorPriv_dispatch_info,
2321
2244
 
2322
2245
int __glXDisp_VendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc)
2323
2246
{
 
2247
    ClientPtr client = cl->client;
2324
2248
    xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
2325
2249
    GLint vendorcode = req->vendorCode;
2326
2250
    __GLXdispatchVendorPrivProcPtr proc;
2327
2251
 
 
2252
    REQUEST_AT_LEAST_SIZE(xGLXVendorPrivateReq);
2328
2253
 
2329
2254
    proc = (__GLXdispatchVendorPrivProcPtr)
2330
2255
      __glXGetProtocolDecodeFunction(& VendorPriv_dispatch_info,
2347
2272
    char *buf;
2348
2273
    int err;
2349
2274
 
 
2275
    REQUEST_SIZE_MATCH(xGLXQueryExtensionsStringReq);
 
2276
 
2350
2277
    if (!validGlxScreen(client, req->screen, &pGlxScreen, &err))
2351
2278
        return err;
2352
2279
 
2386
2313
    int err;
2387
2314
    char ver_str[16];
2388
2315
 
 
2316
    REQUEST_SIZE_MATCH(xGLXQueryServerStringReq);
 
2317
 
2389
2318
    if (!validGlxScreen(client, req->screen, &pGlxScreen, &err))
2390
2319
        return err;
2391
2320
 
2433
2362
 
2434
2363
int __glXDisp_ClientInfo(__GLXclientState *cl, GLbyte *pc)
2435
2364
{
 
2365
    ClientPtr client = cl->client;
2436
2366
    xGLXClientInfoReq *req = (xGLXClientInfoReq *) pc;
2437
2367
    const char *buf;
2438
2368
   
 
2369
    REQUEST_AT_LEAST_SIZE(xGLXClientInfoReq);
 
2370
 
 
2371
    buf = (const char *)(req+1);
 
2372
    if (!memchr(buf, 0, (client->req_len << 2) - sizeof(xGLXClientInfoReq)))
 
2373
        return BadLength;
 
2374
 
2439
2375
    cl->GLClientmajorVersion = req->major;
2440
2376
    cl->GLClientminorVersion = req->minor;
2441
2377
    free(cl->GLClientextensions);
2442
 
    buf = (const char *)(req+1);
2443
2378
    cl->GLClientextensions = strdup(buf);
2444
2379
 
2445
2380
    return Success;