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

« back to all changes in this revision

Viewing changes to glx/glxcmds.c

  • Committer: Bazaar Package Importer
  • Author(s): Christopher James Halse Rogers
  • Date: 2011-01-31 19:45:19 UTC
  • mfrom: (1.1.38 upstream) (0.1.19 experimental)
  • Revision ID: james.westby@ubuntu.com-20110131194519-fx30d1zsg83invba
Tags: 2:1.9.99.901+git20110131.be3be758-0ubuntu1
* Merge from (unreleased) debian-experimental.  Remaining Ubuntu changes:
  - rules:
    + Disable SELinux, libaudit-dev is not in main yet. (LP: #406226)
    + Enable xcsecurity. (LP: #247537)
    + Add --with-extra-module-dir to support GL alternatives.
  - control: 
    + Xvfb depends on xauth, x11-xkb-utils. (LP: #500102)
    + Add breaks for incompatible drivers. (LP: #614993)
    + Drop libaudit-dev from build-deps.
  - local/xvfb-run*: Add correct docs about error codes. (LP #328205)
  - debian/patches:
    + 100_rethrow_signals.patch:
      When aborting, re-raise signals for apport
    + 109_fix-swcursor-crash.patch:
      Avoid dereferencing null pointer while reloading cursors during
      resume. (LP: #371405)
    + 111_armel-drv-fallbacks.patch:
      Add support for armel driver fallbacks.
    + 121_only_switch_vt_when_active.diff:
      Add a check to prevent the X server from changing the VT when killing
      GDM from the console.
    + 122_xext_fix_card32_overflow_in_xauth.patch:
      Fix server crash when “xauth generate” is called with large timeout.
    + 157_check_null_modes.patch, 162_null_crtc_in_rotation.patch,
      166_nullptr_xinerama_keyrepeat.patch, 167_nullptr_xisbread.patch
      169_mipointer_nullptr_checks.patch,
      172_cwgetbackingpicture_nullptr_check.patch:
      Fix various segfaults in xserver by checking pointers for NULL
      values before dereferencing them.
    + 165_man_xorg_conf_no_device_ident.patch
      Correct man page
    + 168_glibc_trace_to_stderr.patch:
      Report abort traces to stderr instead of terminal
    + 184_virtual_devices_autodetect.patch:
      Use vesa for qemu device, which is not supported by cirrus
    + 188_default_primary_to_first_busid.patch:
      Pick the first device and carry on (LP: #459512)
    + 190_cache-xkbcomp_output_for_fast_start_up.patch:
    + 191-Xorg-add-an-extra-module-path.patch:
      Add support for the alternatives module path.
    + 198_nohwaccess.patch:
      Adds a -nohwaccess argument to make X not access the hardware
      ports directly.
    + 200_randr-null.patch:
      Clarify a pointer initialization.
    + 206_intel_8xx_default_to_fbdev.patch:
      Makes 8xx class intel GPUs default to fbdev for stability. (LP: #633593)
* Refresh 121_only_switch_vt_when_active.diff for new upstream.
* Drop 187_edid_quirk_hp_nc8430.patch; upstream.
* Drop 189_xserver_1.5.0_bg_none_root.patch; functionality now upstream.
* Refresh 190_cache-xkbcomp_output_for_fast_start_up.patch for new upstream.
* Drop 197_xvfb-randr.patch:
  - miRandR, which this used, has been removed from the server. 
* Drop 204_fix-neg-sync-transition.patch; upstream.
* Drop 207_dga_master_device.patch; upstream.
* Drop 208_switch_on_release.diff; upstream.
* debian/patches/209_add_legacy_bgnone_option.patch:
  - Add "-nr" as a synonym for "-background none" to ease the transition from
    the old 189_xserver_1.5.0_bg_none_root.patch patch.  Can be dropped once
    all the ?DM have been updated to use the new option.
* debian/control:
  - Add Breaks: to xserver-xorg-video-8 and current fglrx.  These proprietary
    drivers don't yet have appropriate dependency information, so manually
    handle them here to prevent broken upgrades.

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"
57
56
    /*
58
57
    ** Check if screen exists.
59
58
    */
60
 
    if (screen >= screenInfo.numScreens) {
 
59
    if (screen < 0 || screen >= screenInfo.numScreens) {
61
60
        client->errorValue = screen;
62
61
        *err = BadValue;
63
62
        return FALSE;
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
    REQUEST_SIZE_MATCH(xGLXGetFBConfigsSGIXReq);
1092
1136
    return DoGetFBConfigs(cl, req->screen);
1093
1137
}
1094
1138
 
1214
1258
 
1215
1259
int __glXDisp_CreateGLXPixmap(__GLXclientState *cl, GLbyte *pc)
1216
1260
{
 
1261
    ClientPtr client = cl->client;
1217
1262
    xGLXCreateGLXPixmapReq *req = (xGLXCreateGLXPixmapReq *) pc;
1218
1263
    __GLXconfig *config;
1219
1264
    __GLXscreen *pGlxScreen;
1220
1265
    int err;
1221
1266
 
 
1267
    REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapReq);
 
1268
 
1222
1269
    if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
1223
1270
        return err;
1224
1271
    if (!validGlxVisual(cl->client, pGlxScreen, req->visual, &config, &err))
1230
1277
 
1231
1278
int __glXDisp_CreatePixmap(__GLXclientState *cl, GLbyte *pc)
1232
1279
{
 
1280
    ClientPtr client = cl->client;
1233
1281
    xGLXCreatePixmapReq *req = (xGLXCreatePixmapReq *) pc;
1234
1282
    __GLXconfig *config;
1235
1283
    __GLXscreen *pGlxScreen;
1236
1284
    int err;
1237
1285
 
 
1286
    REQUEST_AT_LEAST_SIZE(xGLXCreatePixmapReq);
 
1287
    if (req->numAttribs > (UINT32_MAX >> 3)) {
 
1288
        client->errorValue = req->numAttribs;
 
1289
        return BadValue;
 
1290
    }
 
1291
    REQUEST_FIXED_SIZE(xGLXCreatePixmapReq, req->numAttribs << 3);
 
1292
 
1238
1293
    if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
1239
1294
        return err;
1240
1295
    if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err))
1253
1308
 
1254
1309
int __glXDisp_CreateGLXPixmapWithConfigSGIX(__GLXclientState *cl, GLbyte *pc)
1255
1310
{
 
1311
    ClientPtr client = cl->client;
1256
1312
    xGLXCreateGLXPixmapWithConfigSGIXReq *req = 
1257
1313
        (xGLXCreateGLXPixmapWithConfigSGIXReq *) pc;
1258
1314
    __GLXconfig *config;
1259
1315
    __GLXscreen *pGlxScreen;
1260
1316
    int err;
1261
1317
 
 
1318
    REQUEST_SIZE_MATCH(xGLXCreateGLXPixmapWithConfigSGIXReq);
 
1319
 
1262
1320
    if (!validGlxScreen(cl->client, req->screen, &pGlxScreen, &err))
1263
1321
        return err;
1264
1322
    if (!validGlxFBConfig(cl->client, pGlxScreen, req->fbconfig, &config, &err))
1285
1343
 
1286
1344
int __glXDisp_DestroyGLXPixmap(__GLXclientState *cl, GLbyte *pc)
1287
1345
{
 
1346
    ClientPtr client = cl->client;
1288
1347
    xGLXDestroyGLXPixmapReq *req = (xGLXDestroyGLXPixmapReq *) pc;
1289
1348
 
 
1349
    REQUEST_SIZE_MATCH(xGLXDestroyGLXPixmapReq);
 
1350
 
1290
1351
    return DoDestroyDrawable(cl, req->glxpixmap, GLX_DRAWABLE_PIXMAP);
1291
1352
}
1292
1353
 
1293
1354
int __glXDisp_DestroyPixmap(__GLXclientState *cl, GLbyte *pc)
1294
1355
{
 
1356
    ClientPtr client = cl->client;
1295
1357
    xGLXDestroyPixmapReq *req = (xGLXDestroyPixmapReq *) pc;
1296
1358
 
 
1359
    REQUEST_SIZE_MATCH(xGLXDestroyPixmapReq);
 
1360
 
1297
1361
    return DoDestroyDrawable(cl, req->glxpixmap, GLX_DRAWABLE_PIXMAP);
1298
1362
}
1299
1363
 
1332
1396
 
1333
1397
int __glXDisp_CreatePbuffer(__GLXclientState *cl, GLbyte *pc)
1334
1398
{
 
1399
    ClientPtr client = cl->client;
1335
1400
    xGLXCreatePbufferReq        *req = (xGLXCreatePbufferReq *) pc;
1336
1401
    CARD32                      *attrs;
1337
1402
    int                          width, height, i;
1338
1403
 
 
1404
    REQUEST_AT_LEAST_SIZE(xGLXCreatePbufferReq);
 
1405
    if (req->numAttribs > (UINT32_MAX >> 3)) {
 
1406
        client->errorValue = req->numAttribs;
 
1407
        return BadValue;
 
1408
    }
 
1409
    REQUEST_FIXED_SIZE(xGLXCreatePbufferReq, req->numAttribs << 3);
 
1410
 
1339
1411
    attrs = (CARD32 *) (req + 1);
1340
1412
    width = 0;
1341
1413
    height = 0;
1361
1433
 
1362
1434
int __glXDisp_CreateGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc)
1363
1435
{
 
1436
    ClientPtr client = cl->client;
1364
1437
    xGLXCreateGLXPbufferSGIXReq *req = (xGLXCreateGLXPbufferSGIXReq *) pc;
1365
1438
 
 
1439
    REQUEST_SIZE_MATCH(xGLXCreateGLXPbufferSGIXReq);
 
1440
 
1366
1441
    return DoCreatePbuffer(cl->client, req->screen, req->fbconfig,
1367
1442
                           req->width, req->height, req->pbuffer);
1368
1443
}
1369
1444
 
1370
1445
int __glXDisp_DestroyPbuffer(__GLXclientState *cl, GLbyte *pc)
1371
1446
{
 
1447
    ClientPtr client = cl->client;
1372
1448
    xGLXDestroyPbufferReq *req = (xGLXDestroyPbufferReq *) pc;
1373
1449
 
 
1450
    REQUEST_SIZE_MATCH(xGLXDestroyPbufferReq);
 
1451
 
1374
1452
    return DoDestroyDrawable(cl, req->pbuffer, GLX_DRAWABLE_PBUFFER);
1375
1453
}
1376
1454
 
1377
1455
int __glXDisp_DestroyGLXPbufferSGIX(__GLXclientState *cl, GLbyte *pc)
1378
1456
{
 
1457
    ClientPtr client = cl->client;
1379
1458
    xGLXDestroyGLXPbufferSGIXReq *req = (xGLXDestroyGLXPbufferSGIXReq *) pc;
1380
1459
 
 
1460
    REQUEST_SIZE_MATCH(xGLXDestroyGLXPbufferSGIXReq);
 
1461
 
1381
1462
    return DoDestroyDrawable(cl, req->pbuffer, GLX_DRAWABLE_PBUFFER);
1382
1463
}
1383
1464
 
1408
1489
 
1409
1490
int __glXDisp_ChangeDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
1410
1491
{
 
1492
    ClientPtr client = cl->client;
1411
1493
    xGLXChangeDrawableAttributesReq *req =
1412
1494
        (xGLXChangeDrawableAttributesReq *) pc;
1413
1495
 
 
1496
    REQUEST_AT_LEAST_SIZE(xGLXChangeDrawableAttributesReq);
 
1497
    if (req->numAttribs > (UINT32_MAX >> 3)) {
 
1498
        client->errorValue = req->numAttribs;
 
1499
        return BadValue;
 
1500
    }
 
1501
    REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesReq, req->numAttribs << 3);
 
1502
 
1414
1503
    return DoChangeDrawableAttributes(cl->client, req->drawable,
1415
1504
                                      req->numAttribs, (CARD32 *) (req + 1));
1416
1505
}
1417
1506
 
1418
1507
int __glXDisp_ChangeDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc)
1419
1508
{
 
1509
    ClientPtr client = cl->client;
1420
1510
    xGLXChangeDrawableAttributesSGIXReq *req =
1421
1511
        (xGLXChangeDrawableAttributesSGIXReq *)pc;
1422
1512
 
 
1513
    REQUEST_AT_LEAST_SIZE(xGLXChangeDrawableAttributesSGIXReq);
 
1514
    if (req->numAttribs > (UINT32_MAX >> 3)) {
 
1515
        client->errorValue = req->numAttribs;
 
1516
        return BadValue;
 
1517
    }
 
1518
    REQUEST_FIXED_SIZE(xGLXChangeDrawableAttributesSGIXReq, req->numAttribs << 3);
 
1519
 
1423
1520
    return DoChangeDrawableAttributes(cl->client, req->drawable,
1424
1521
                                      req->numAttribs, (CARD32 *) (req + 1));
1425
1522
}
1433
1530
    DrawablePtr          pDraw;
1434
1531
    int                  err;
1435
1532
 
 
1533
    REQUEST_AT_LEAST_SIZE(xGLXCreateWindowReq);
 
1534
    if (req->numAttribs > (UINT32_MAX >> 3)) {
 
1535
        client->errorValue = req->numAttribs;
 
1536
        return BadValue;
 
1537
    }
 
1538
    REQUEST_FIXED_SIZE(xGLXCreateWindowReq, req->numAttribs << 3);
 
1539
 
1436
1540
    LEGAL_NEW_RESOURCE(req->glxwindow, client);
1437
1541
 
1438
1542
    if (!validGlxScreen(client, req->screen, &pGlxScreen, &err))
1456
1560
 
1457
1561
int __glXDisp_DestroyWindow(__GLXclientState *cl, GLbyte *pc)
1458
1562
{
 
1563
    ClientPtr client = cl->client;
1459
1564
    xGLXDestroyWindowReq *req = (xGLXDestroyWindowReq *) pc;
1460
1565
 
 
1566
    REQUEST_SIZE_MATCH(xGLXDestroyWindowReq);
 
1567
 
1461
1568
    return DoDestroyDrawable(cl, req->glxwindow, GLX_DRAWABLE_WINDOW);
1462
1569
}
1463
1570
 
1473
1580
{
1474
1581
    ClientPtr client = cl->client;
1475
1582
    xGLXSwapBuffersReq *req = (xGLXSwapBuffersReq *) pc;
1476
 
    GLXContextTag tag = req->contextTag;
1477
 
    XID drawId = req->drawable;
 
1583
    GLXContextTag tag;
 
1584
    XID drawId;
1478
1585
    __GLXcontext *glxc = NULL;
1479
1586
    __GLXdrawable *pGlxDraw;
1480
1587
    int error;
1481
1588
 
 
1589
    REQUEST_SIZE_MATCH(xGLXSwapBuffersReq);
 
1590
 
 
1591
    tag = req->contextTag;
 
1592
    drawId = req->drawable;
1482
1593
    if (tag) {
1483
1594
        glxc = __glXLookupContextByTag(cl, tag);
1484
1595
        if (!glxc) {
1559
1670
 
1560
1671
int __glXDisp_QueryContextInfoEXT(__GLXclientState *cl, GLbyte *pc)
1561
1672
{
 
1673
    ClientPtr client = cl->client;
1562
1674
    xGLXQueryContextInfoEXTReq *req = (xGLXQueryContextInfoEXTReq *) pc;
1563
1675
 
 
1676
    REQUEST_SIZE_MATCH(xGLXQueryContextInfoEXTReq);
 
1677
 
1564
1678
    return DoQueryContext(cl, req->context);
1565
1679
}
1566
1680
 
1567
1681
int __glXDisp_QueryContext(__GLXclientState *cl, GLbyte *pc)
1568
1682
{
 
1683
    ClientPtr client = cl->client;
1569
1684
    xGLXQueryContextReq *req = (xGLXQueryContextReq *) pc;
1570
1685
 
 
1686
    REQUEST_SIZE_MATCH(xGLXQueryContextReq);
 
1687
 
1571
1688
    return DoQueryContext(cl, req->context);
1572
1689
}
1573
1690
 
1581
1698
    int                  buffer;
1582
1699
    int                  error;
1583
1700
 
 
1701
    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8);
 
1702
 
1584
1703
    pc += __GLX_VENDPRIV_HDR_SIZE;
1585
1704
 
1586
1705
    drawId = *((CARD32 *) (pc));
1615
1734
    int                  buffer;
1616
1735
    int                  error;
1617
1736
 
 
1737
    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 8);
 
1738
 
1618
1739
    pc += __GLX_VENDPRIV_HDR_SIZE;
1619
1740
 
1620
1741
    drawId = *((CARD32 *) (pc));
1650
1771
    (void) client;
1651
1772
    (void) req;
1652
1773
 
 
1774
    REQUEST_FIXED_SIZE(xGLXVendorPrivateReq, 20);
 
1775
 
1653
1776
    pc += __GLX_VENDPRIV_HDR_SIZE;
1654
1777
 
1655
1778
    drawId = *((CARD32 *) (pc));
1738
1861
 
1739
1862
int __glXDisp_GetDrawableAttributes(__GLXclientState *cl, GLbyte *pc)
1740
1863
{
 
1864
    ClientPtr client = cl->client;
1741
1865
    xGLXGetDrawableAttributesReq *req = (xGLXGetDrawableAttributesReq *)pc;
1742
1866
 
 
1867
    REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesReq);
 
1868
 
1743
1869
    return DoGetDrawableAttributes(cl, req->drawable);
1744
1870
}
1745
1871
 
1746
1872
int __glXDisp_GetDrawableAttributesSGIX(__GLXclientState *cl, GLbyte *pc)
1747
1873
{
 
1874
    ClientPtr client = cl->client;
1748
1875
    xGLXGetDrawableAttributesSGIXReq *req =
1749
1876
        (xGLXGetDrawableAttributesSGIXReq *)pc;
1750
1877
    
 
1878
    REQUEST_SIZE_MATCH(xGLXGetDrawableAttributesSGIXReq);
 
1879
 
1751
1880
    return DoGetDrawableAttributes(cl, req->drawable);
1752
1881
}
1753
1882
 
1772
1901
    __GLXcontext *glxc;
1773
1902
    __GLX_DECLARE_SWAP_VARIABLES;
1774
1903
 
 
1904
    REQUEST_AT_LEAST_SIZE(xGLXRenderReq);
 
1905
 
1775
1906
    req = (xGLXRenderReq *) pc;
1776
1907
    if (client->swapped) {
1777
1908
        __GLX_SWAP_SHORT(&req->length);
1792
1923
        __GLXdispatchRenderProcPtr proc;
1793
1924
        int err;
1794
1925
 
 
1926
        if (left < sizeof(__GLXrenderHeader))
 
1927
            return BadLength;
 
1928
 
1795
1929
        /*
1796
1930
        ** Verify that the header length and the overall length agree.
1797
1931
        ** Also, each command must be word aligned.
2061
2195
    }
2062
2196
}
2063
2197
 
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
2198
/************************************************************************/
2297
2199
 
2298
2200
/*
2302
2204
 
2303
2205
int __glXDisp_VendorPrivate(__GLXclientState *cl, GLbyte *pc)
2304
2206
{
 
2207
    ClientPtr client = cl->client;
2305
2208
    xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
2306
2209
    GLint vendorcode = req->vendorCode;
2307
2210
    __GLXdispatchVendorPrivProcPtr proc;
2308
2211
 
 
2212
    REQUEST_AT_LEAST_SIZE(xGLXVendorPrivateReq);
2309
2213
 
2310
2214
    proc = (__GLXdispatchVendorPrivProcPtr)
2311
2215
      __glXGetProtocolDecodeFunction(& VendorPriv_dispatch_info,
2321
2225
 
2322
2226
int __glXDisp_VendorPrivateWithReply(__GLXclientState *cl, GLbyte *pc)
2323
2227
{
 
2228
    ClientPtr client = cl->client;
2324
2229
    xGLXVendorPrivateReq *req = (xGLXVendorPrivateReq *) pc;
2325
2230
    GLint vendorcode = req->vendorCode;
2326
2231
    __GLXdispatchVendorPrivProcPtr proc;
2327
2232
 
 
2233
    REQUEST_AT_LEAST_SIZE(xGLXVendorPrivateReq);
2328
2234
 
2329
2235
    proc = (__GLXdispatchVendorPrivProcPtr)
2330
2236
      __glXGetProtocolDecodeFunction(& VendorPriv_dispatch_info,
2347
2253
    char *buf;
2348
2254
    int err;
2349
2255
 
 
2256
    REQUEST_SIZE_MATCH(xGLXQueryExtensionsStringReq);
 
2257
 
2350
2258
    if (!validGlxScreen(client, req->screen, &pGlxScreen, &err))
2351
2259
        return err;
2352
2260
 
2386
2294
    int err;
2387
2295
    char ver_str[16];
2388
2296
 
 
2297
    REQUEST_SIZE_MATCH(xGLXQueryServerStringReq);
 
2298
 
2389
2299
    if (!validGlxScreen(client, req->screen, &pGlxScreen, &err))
2390
2300
        return err;
2391
2301
 
2433
2343
 
2434
2344
int __glXDisp_ClientInfo(__GLXclientState *cl, GLbyte *pc)
2435
2345
{
 
2346
    ClientPtr client = cl->client;
2436
2347
    xGLXClientInfoReq *req = (xGLXClientInfoReq *) pc;
2437
2348
    const char *buf;
2438
2349
   
 
2350
    REQUEST_AT_LEAST_SIZE(xGLXClientInfoReq);
 
2351
 
 
2352
    buf = (const char *)(req+1);
 
2353
    if (!memchr(buf, 0, (client->req_len << 2) - sizeof(xGLXClientInfoReq)))
 
2354
        return BadLength;
 
2355
 
2439
2356
    cl->GLClientmajorVersion = req->major;
2440
2357
    cl->GLClientminorVersion = req->minor;
2441
2358
    free(cl->GLClientextensions);
2442
 
    buf = (const char *)(req+1);
2443
2359
    cl->GLClientextensions = strdup(buf);
2444
2360
 
2445
2361
    return Success;