Saturday, January 8, 2011

Enable X Shared Memory Extension Pixmaps

Definitely not encouraged to use, sometimes this feature is needed for using certain applications what depends on this deprecated X window extension.

Found the solution on http://fxc.noaa.gov/FSD-NVIDIA-OB9-FXC.htm. More precisely, an example illustrating the details with Nvidia series on Fedora 14 is shown as follows.

# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 260.19.29 
# (buildmeister@swio-display-x86-rhel47-04.nvidia.com)  Wed Dec 
# 8 12:27:39 PST 2010


Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0" 0 0
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

Section "Files"
    FontPath        "/usr/share/fonts/default/Type1"
EndSection

Section "InputDevice"

    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/input/mice"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"

    # generated from data in "/etc/sysconfig/keyboard"
    Identifier     "Keyboard0"
    Driver         "kbd"
    Option         "XkbLayout" "us"
    Option         "XkbModel" "pc105"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    HorizSync       28.0 - 33.0
    VertRefresh     43.0 - 72.0
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    Option    "AllowSHMPixmaps" "true"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

The enabling appendix is simply the single line below.
Option "AllowSHMPixmaps" "true"

Then reboot the system to make it effect.

Following code snippet could be used for verifying the availability of this feature:

int vmajor;

int vminor;
bool vpixmap;
bool shm_flag;
if (XShmQueryVersion(window->getDisplay(),&vmajor,&vminor,&vpixmap) != True) { 
    cerr << "X Shared Memory Extension not supported." << endl;
    shm_flag=false;
}
else if (vpixmap != True) { 
    cerr << "X Shared Memory Extension Pixmap not supported." << endl;
    shm_flag=false;
}
else {
    // do what is relying on the MIT-SHM feature from here on
    ......
}

No comments:

Post a Comment