src/java.desktop/unix/native/common/java2d/opengl/GLXGraphicsConfig.c
author ihse
Sat, 03 Mar 2018 08:21:47 +0100
branchihse-warnings-cflags-branch
changeset 56230 489867818774
parent 47216 71c04702a3d5
permissions -rw-r--r--
No longer disable E_OLD_STYLE_FUNC_DEF.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
31661
a5cb86f2253b 7188942: Remove support of pbuffers in OGL Java2d pipeline
serb
parents: 27274
diff changeset
     2
 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 888
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 888
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 888
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 888
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 888
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#include <stdlib.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include <string.h>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "sun_java2d_opengl_GLXGraphicsConfig.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "jni.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "jlong.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "GLXGraphicsConfig.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "GLXSurfaceData.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include "awt_GraphicsEnv.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include "awt_util.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
extern Bool usingXinerama;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * This is a globally shared context used when creating textures.  When any
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * new contexts are created, they specify this context as the "share list"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * context, which means any texture objects created when this shared context
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * is current will be available to any other context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
static GLXContext sharedContext = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * Attempts to initialize GLX and the core OpenGL library.  For this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * to return JNI_TRUE, the following must be true:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 *     - libGL must be loaded successfully (via dlopen)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 *     - all function symbols from libGL must be available and loaded properly
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 *     - the GLX extension must be available through X11
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *     - client GLX version must be >= 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * If any of these requirements are not met, this method will return
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * JNI_FALSE, indicating there is no hope of using GLX/OpenGL for any
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * GraphicsConfig in the environment.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
static jboolean
56230
489867818774 No longer disable E_OLD_STYLE_FUNC_DEF.
ihse
parents: 47216
diff changeset
    62
GLXGC_InitGLX(void)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    int errorbase, eventbase;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    const char *version;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    J2dRlsTraceLn(J2D_TRACE_INFO, "GLXGC_InitGLX");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    if (!OGLFuncs_OpenLibrary()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    if (!OGLFuncs_InitPlatformFuncs() ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        !OGLFuncs_InitBaseFuncs() ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        !OGLFuncs_InitExtFuncs())
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        OGLFuncs_CloseLibrary();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    if (!j2d_glXQueryExtension(awt_display, &errorbase, &eventbase)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                      "GLXGC_InitGLX: GLX extension is not present");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        OGLFuncs_CloseLibrary();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    version = j2d_glXGetClientString(awt_display, GLX_VERSION);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    if (version == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                      "GLXGC_InitGLX: could not query GLX version");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        OGLFuncs_CloseLibrary();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    // we now only verify that the client GLX version is >= 1.3 (if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    // server does not support GLX 1.3, then we will find that out later
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    // when we attempt to create a GLXFBConfig)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    J2dRlsTraceLn1(J2D_TRACE_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                   "GLXGC_InitGLX: client GLX version=%s", version);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    if (!((version[0] == '1' && version[2] >= '3') || (version[0] > '1'))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                      "GLXGC_InitGLX: invalid GLX version; 1.3 is required");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        OGLFuncs_CloseLibrary();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        return JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    return JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 * Returns JNI_TRUE if GLX is available for the current display.  Note that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * this method will attempt to initialize GLX (and all the necessary function
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 * symbols) if it has not been already.  The AWT_LOCK must be acquired before
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 * calling this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
jboolean
56230
489867818774 No longer disable E_OLD_STYLE_FUNC_DEF.
ihse
parents: 47216
diff changeset
   118
GLXGC_IsGLXAvailable(void)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    static jboolean glxAvailable = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    static jboolean firstTime = JNI_TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    J2dTraceLn(J2D_TRACE_INFO, "GLXGC_IsGLXAvailable");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    if (firstTime) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        glxAvailable = GLXGC_InitGLX();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        firstTime = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    return glxAvailable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 * Disposes all memory and resources allocated for the given OGLContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
static void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
GLXGC_DestroyOGLContext(OGLContext *oglc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    GLXCtxInfo *ctxinfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    J2dTraceLn(J2D_TRACE_INFO, "GLXGC_DestroyOGLContext");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    if (oglc == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                      "GLXGC_DestroyOGLContext: context is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    // at this point, this context will be current to its scratch surface
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    // so the following GL/GLX operations should be safe...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    OGLContext_DestroyContextResources(oglc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    ctxinfo = (GLXCtxInfo *)oglc->ctxInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    if (ctxinfo != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        // release the current context before we continue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        j2d_glXMakeContextCurrent(awt_display, None, None, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        if (ctxinfo->context != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            j2d_glXDestroyContext(awt_display, ctxinfo->context);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        if (ctxinfo->scratchSurface != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            j2d_glXDestroyPbuffer(awt_display, ctxinfo->scratchSurface);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        free(ctxinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
    free(oglc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
 * Disposes all memory and resources associated with the given
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
 * GLXGraphicsConfigInfo (including its native OGLContext data).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
void
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
OGLGC_DestroyOGLGraphicsConfig(jlong pConfigInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    GLXGraphicsConfigInfo *glxinfo =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        (GLXGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    J2dTraceLn(J2D_TRACE_INFO, "OGLGC_DestroyOGLGraphicsConfig");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    if (glxinfo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                      "OGLGC_DestroyOGLGraphicsConfig: info is null");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    if (glxinfo->context != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
        GLXGC_DestroyOGLContext(glxinfo->context);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    free(glxinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
 * Attempts to create a new GLXFBConfig for the requested screen and visual.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
 * If visualid is 0, this method will iterate through all GLXFBConfigs (if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
 * any) that match the requested attributes and will attempt to find an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
 * fbconfig with a minimal combined depth+stencil buffer.  Note that we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
 * currently only need depth capabilities (for shape clipping purposes), but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
 * glXChooseFBConfig() will often return a list of fbconfigs with the largest
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
 * depth buffer (and stencil) sizes at the top of the list.  Therefore, we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
 * scan through the whole list to find the most VRAM-efficient fbconfig.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
 * If visualid is non-zero, the GLXFBConfig associated with the given visual
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
 * is chosen (assuming it meets the requested attributes).  If there are no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
 * valid GLXFBConfigs available, this method returns 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
static GLXFBConfig
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
GLXGC_InitFBConfig(JNIEnv *env, jint screennum, VisualID visualid)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    GLXFBConfig *fbconfigs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    GLXFBConfig chosenConfig = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    int nconfs, i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    int attrlist[] = {GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT | GLX_PBUFFER_BIT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                      GLX_RENDER_TYPE, GLX_RGBA_BIT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                      GLX_CONFIG_CAVEAT, GLX_NONE, // avoid "slow" configs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                      GLX_DEPTH_SIZE, 16, // anything >= 16 will work for us
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                      0};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    // this is the initial minimum value for the combined depth+stencil size
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    // (we initialize it to some absurdly high value; realistic values will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    // be much less than this number)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
    int minDepthPlusStencil = 512;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    J2dRlsTraceLn2(J2D_TRACE_INFO, "GLXGC_InitFBConfig: scn=%d vis=0x%x",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                   screennum, visualid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    // find all fbconfigs for this screen with the provided attributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    fbconfigs = j2d_glXChooseFBConfig(awt_display, screennum,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                                      attrlist, &nconfs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
    if ((fbconfigs == NULL) || (nconfs <= 0)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            "GLXGC_InitFBConfig: could not find any valid fbconfigs");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    J2dRlsTraceLn(J2D_TRACE_VERBOSE, "  candidate fbconfigs:");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    // iterate through the list of fbconfigs, looking for the one that matches
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    // the requested VisualID and supports RGBA rendering as well as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    // creation of windows and pbuffers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    for (i = 0; i < nconfs; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        XVisualInfo *xvi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        VisualID fbvisualid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        GLXFBConfig fbc = fbconfigs[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        // get VisualID from GLXFBConfig
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        xvi = j2d_glXGetVisualFromFBConfig(awt_display, fbc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        if (xvi == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        fbvisualid = xvi->visualid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        XFree(xvi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        if (visualid == 0 || visualid == fbvisualid) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            int dtype, rtype, depth, stencil, db, alpha, gamma;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
            // get GLX-specific attributes from GLXFBConfig
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            j2d_glXGetFBConfigAttrib(awt_display, fbc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                                     GLX_DRAWABLE_TYPE, &dtype);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            j2d_glXGetFBConfigAttrib(awt_display, fbc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                                     GLX_RENDER_TYPE, &rtype);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
            j2d_glXGetFBConfigAttrib(awt_display, fbc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                                     GLX_DEPTH_SIZE, &depth);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
            j2d_glXGetFBConfigAttrib(awt_display, fbc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                                     GLX_STENCIL_SIZE, &stencil);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
            // these attributes don't affect our decision, but they are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            // interesting for trace logs, so we will query them anyway
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
            j2d_glXGetFBConfigAttrib(awt_display, fbc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
                                     GLX_DOUBLEBUFFER, &db);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            j2d_glXGetFBConfigAttrib(awt_display, fbc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
                                     GLX_ALPHA_SIZE, &alpha);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            J2dRlsTrace5(J2D_TRACE_VERBOSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
                "[V]     id=0x%x db=%d alpha=%d depth=%d stencil=%d valid=",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                         fbvisualid, db, alpha, depth, stencil);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
#ifdef __sparc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
             * Sun's OpenGL implementation will always
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
             * return at least two GLXFBConfigs (visuals) from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
             * glXChooseFBConfig().  The first will be a linear (gamma
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
             * corrected) visual; the second will have the same capabilities
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
             * as the first, except it will be a non-linear (non-gamma
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
             * corrected) visual, which is the one we want, otherwise
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
             * everything will look "washed out".  So we will reject any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
             * visuals that have gamma values other than 1.0 (the value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
             * returned by glXGetFBConfigAttrib() will be scaled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
             * by 100, so 100 corresponds to a gamma value of 1.0, 220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
             * corresponds to 2.2, and so on).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            j2d_glXGetFBConfigAttrib(awt_display, fbc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
                                     GLX_GAMMA_VALUE_SUN, &gamma);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
            if (gamma != 100) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                J2dRlsTrace(J2D_TRACE_VERBOSE, "false (linear visual)\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
                continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
#endif /* __sparc */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
            if ((dtype & GLX_WINDOW_BIT) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
                (dtype & GLX_PBUFFER_BIT) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
                (rtype & GLX_RGBA_BIT) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
                (depth >= 16))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
                if (visualid == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                    // when visualid == 0, we loop through all configs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                    // looking for an fbconfig that has the smallest combined
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                    // depth+stencil size (this keeps VRAM usage to a minimum)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                    if ((depth + stencil) < minDepthPlusStencil) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                        J2dRlsTrace(J2D_TRACE_VERBOSE, "true\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                        minDepthPlusStencil = depth + stencil;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                        chosenConfig = fbc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                        J2dRlsTrace(J2D_TRACE_VERBOSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                                    "false (large depth)\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
                    continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
                    // in this case, visualid == fbvisualid, which means
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                    // we've found a valid fbconfig corresponding to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                    // requested VisualID, so break out of the loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
                    J2dRlsTrace(J2D_TRACE_VERBOSE, "true\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                    chosenConfig = fbc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                J2dRlsTrace(J2D_TRACE_VERBOSE, "false (bad match)\n");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
    // free the list of fbconfigs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    XFree(fbconfigs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
    if (chosenConfig == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            "GLXGC_InitFBConfig: could not find an appropriate fbconfig");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    return chosenConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
 * Returns the X11 VisualID that corresponds to the best GLXFBConfig for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
 * given screen.  If no valid visual could be found, this method returns zero.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
 * Note that this method will attempt to initialize GLX (and all the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
 * necessary function symbols) if it has not been already.  The AWT_LOCK
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
 * must be acquired before calling this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
VisualID
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
GLXGC_FindBestVisual(JNIEnv *env, jint screen)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    GLXFBConfig fbc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    XVisualInfo *xvi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    VisualID visualid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    J2dRlsTraceLn1(J2D_TRACE_INFO, "GLXGC_FindBestVisual: scn=%d", screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    if (!GLXGC_IsGLXAvailable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
            "GLXGC_FindBestVisual: could not initialize GLX");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
    fbc = GLXGC_InitFBConfig(env, screen, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    if (fbc == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
            "GLXGC_FindBestVisual: could not find best visual");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    xvi = j2d_glXGetVisualFromFBConfig(awt_display, fbc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    if (xvi == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
            "GLXGC_FindBestVisual: could not get visual for fbconfig");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
    visualid = xvi->visualid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    XFree(xvi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    J2dRlsTraceLn2(J2D_TRACE_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        "GLXGC_FindBestVisual: chose 0x%x as the best visual for screen %d",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                   visualid, screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    return visualid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
 * Creates a scratch pbuffer, which can be used to make a context current
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
 * for extension queries, etc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
static GLXPbuffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
GLXGC_InitScratchPbuffer(GLXFBConfig fbconfig)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
{
27274
62de2c957523 8059848: Test java/awt/GraphicsDevice/CloneConfigsTest.java causes JVM crash in OEL 7.0
prr
parents: 26751
diff changeset
   401
    int pbattrlist[] = {GLX_PBUFFER_WIDTH, 4,
62de2c957523 8059848: Test java/awt/GraphicsDevice/CloneConfigsTest.java causes JVM crash in OEL 7.0
prr
parents: 26751
diff changeset
   402
                        GLX_PBUFFER_HEIGHT, 4,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                        GLX_PRESERVED_CONTENTS, GL_FALSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
                        0};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    J2dTraceLn(J2D_TRACE_INFO, "GLXGC_InitScratchPbuffer");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    return j2d_glXCreatePbuffer(awt_display, fbconfig, pbattrlist);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
 * Initializes a new OGLContext, which includes the native GLXContext handle
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
 * and some other important information such as the associated GLXFBConfig.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
static OGLContext *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
GLXGC_InitOGLContext(GLXFBConfig fbconfig, GLXContext context,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
                     GLXPbuffer scratch, jint caps)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
    OGLContext *oglc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    GLXCtxInfo *ctxinfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    J2dTraceLn(J2D_TRACE_INFO, "GLXGC_InitOGLContext");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    oglc = (OGLContext *)malloc(sizeof(OGLContext));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    if (oglc == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
            "GLXGC_InitOGLContext: could not allocate memory for oglc");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    memset(oglc, 0, sizeof(OGLContext));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    ctxinfo = (GLXCtxInfo *)malloc(sizeof(GLXCtxInfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    if (ctxinfo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
            "GLXGC_InitOGLContext: could not allocate memory for ctxinfo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        free(oglc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    ctxinfo->fbconfig = fbconfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    ctxinfo->context = context;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    ctxinfo->scratchSurface = scratch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    oglc->ctxInfo = ctxinfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    oglc->caps = caps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    return oglc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
 * Determines whether the GLX pipeline can be used for a given GraphicsConfig
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
 * provided its screen number and visual ID.  If the minimum requirements are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
 * met, the native GLXGraphicsConfigInfo structure is initialized for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
 * GraphicsConfig with the necessary information (GLXFBConfig, etc.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
 * and a pointer to this structure is returned as a jlong.  If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
 * initialization fails at any point, zero is returned, indicating that GLX
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
 * cannot be used for this GraphicsConfig (we should fallback on the existing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
 * X11 pipeline).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
JNIEXPORT jlong JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
Java_sun_java2d_opengl_GLXGraphicsConfig_getGLXConfigInfo(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                                                          jclass glxgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                                                          jint screennum,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
                                                          jint visnum)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    OGLContext *oglc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    GLXFBConfig fbconfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    GLXContext context;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
    GLXPbuffer scratch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    GLXGraphicsConfigInfo *glxinfo;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   474
    jint caps = CAPS_EMPTY;
31661
a5cb86f2253b 7188942: Remove support of pbuffers in OGL Java2d pipeline
serb
parents: 27274
diff changeset
   475
    int db;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    const unsigned char *versionstr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    J2dRlsTraceLn(J2D_TRACE_INFO, "GLXGraphicsConfig_getGLXConfigInfo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    if (usingXinerama) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        // when Xinerama is enabled, the screen ID needs to be 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        screennum = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    fbconfig = GLXGC_InitFBConfig(env, screennum, (VisualID)visnum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    if (fbconfig == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
            "GLXGraphicsConfig_getGLXConfigInfo: could not create fbconfig");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        return 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    if (sharedContext == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        // create the one shared context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        sharedContext = j2d_glXCreateNewContext(awt_display, fbconfig,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
                                                GLX_RGBA_TYPE, 0, GL_TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        if (sharedContext == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
            J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
                "GLXGraphicsConfig_getGLXConfigInfo: could not create shared context");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
            return 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    // create the GLXContext for this GLXGraphicsConfig
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    context = j2d_glXCreateNewContext(awt_display, fbconfig,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
                                      GLX_RGBA_TYPE, sharedContext,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
                                      GL_TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    if (context == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
            "GLXGraphicsConfig_getGLXConfigInfo: could not create GLX context");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        return 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    // this is pretty sketchy, but it seems to be the easiest way to create
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    // some form of GLXDrawable using only the display and a GLXFBConfig
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
    // (in order to make the context current for checking the version,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    // extensions, etc)...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
    scratch = GLXGC_InitScratchPbuffer(fbconfig);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    if (scratch == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
            "GLXGraphicsConfig_getGLXConfigInfo: could not create scratch pbuffer");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        j2d_glXDestroyContext(awt_display, context);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
        return 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    // the context must be made current before we can query the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    // version and extension strings
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    j2d_glXMakeContextCurrent(awt_display, scratch, scratch, context);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
#ifdef __sparc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     * 6438225: The software rasterizer used by Sun's OpenGL libraries
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
     * for certain boards has quality issues, and besides, performance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
     * of these boards is not high enough to justify the use of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * OpenGL-based Java 2D pipeline.  If we detect one of the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * boards via the GL_RENDERER string, just give up:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     *   - FFB[2[+]] ("Creator[3D]")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     *   - PGX-series ("m64")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     *   - AFB ("Elite3D")
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        const char *renderer = (const char *)j2d_glGetString(GL_RENDERER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
        J2dRlsTraceLn1(J2D_TRACE_VERBOSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
            "GLXGraphicsConfig_getGLXConfigInfo: detected renderer (%s)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
            (renderer == NULL) ? "null" : renderer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        if (renderer == NULL ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
            strncmp(renderer, "Creator", 7) == 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
            strncmp(renderer, "SUNWm64", 7) == 0 ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
            strncmp(renderer, "Elite", 5) == 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
            J2dRlsTraceLn1(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
                "GLXGraphicsConfig_getGLXConfigInfo: unsupported board (%s)",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
                (renderer == NULL) ? "null" : renderer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
            j2d_glXMakeContextCurrent(awt_display, None, None, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
            j2d_glXDestroyPbuffer(awt_display, scratch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
            j2d_glXDestroyContext(awt_display, context);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
            return 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
#endif /* __sparc */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
    versionstr = j2d_glGetString(GL_VERSION);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
    OGLContext_GetExtensionInfo(env, &caps);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
    // destroy the temporary resources
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
    j2d_glXMakeContextCurrent(awt_display, None, None, NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
    J2dRlsTraceLn1(J2D_TRACE_INFO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        "GLXGraphicsConfig_getGLXConfigInfo: OpenGL version=%s",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                   (versionstr == NULL) ? "null" : (char *)versionstr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
    if (!OGLContext_IsVersionSupported(versionstr)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
            "GLXGraphicsConfig_getGLXConfigInfo: OpenGL 1.2 is required");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        j2d_glXDestroyPbuffer(awt_display, scratch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
        j2d_glXDestroyContext(awt_display, context);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        return 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
    // get config-specific capabilities
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    j2d_glXGetFBConfigAttrib(awt_display, fbconfig, GLX_DOUBLEBUFFER, &db);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
    if (db) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   584
        caps |= CAPS_DOUBLEBUFFERED;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
    // initialize the OGLContext, which wraps the GLXFBConfig and GLXContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    oglc = GLXGC_InitOGLContext(fbconfig, context, scratch, caps);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
    if (oglc == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
            "GLXGraphicsConfig_getGLXConfigInfo: could not create oglc");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        j2d_glXDestroyPbuffer(awt_display, scratch);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
        j2d_glXDestroyContext(awt_display, context);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
        return 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    J2dTraceLn(J2D_TRACE_VERBOSE,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
        "GLXGraphicsConfig_getGLXConfigInfo: finished checking dependencies");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
    // create the GLXGraphicsConfigInfo record for this config
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
    glxinfo = (GLXGraphicsConfigInfo *)malloc(sizeof(GLXGraphicsConfigInfo));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    if (glxinfo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        J2dRlsTraceLn(J2D_TRACE_ERROR,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
            "GLXGraphicsConfig_getGLXConfigInfo: could not allocate memory for glxinfo");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        GLXGC_DestroyOGLContext(oglc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
        return 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
    glxinfo->screen = screennum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    glxinfo->visual = visnum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    glxinfo->context = oglc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    glxinfo->fbconfig = fbconfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
    return ptr_to_jlong(glxinfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
    return 0L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
Java_sun_java2d_opengl_GLXGraphicsConfig_initConfig(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
                                                    jobject glxgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
                                                    jlong aData,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
                                                    jlong configInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    GLXGraphicsConfigInfo *glxinfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
    AwtGraphicsConfigDataPtr configData =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        (AwtGraphicsConfigDataPtr)jlong_to_ptr(aData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
    J2dTraceLn(J2D_TRACE_INFO, "GLXGraphicsConfig_initConfig");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
    if (configData == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
        JNU_ThrowNullPointerException(env, "Native GraphicsConfig missing");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    glxinfo = (GLXGraphicsConfigInfo *)jlong_to_ptr(configInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    if (glxinfo == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        JNU_ThrowNullPointerException(env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
                                      "GLXGraphicsConfigInfo data missing");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    configData->glxInfo = glxinfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
Java_sun_java2d_opengl_GLXGraphicsConfig_getOGLCapabilities(JNIEnv *env,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
                                                            jclass glxgc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
                                                            jlong configInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
#ifndef HEADLESS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    GLXGraphicsConfigInfo *glxinfo =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
        (GLXGraphicsConfigInfo *)jlong_to_ptr(configInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    J2dTraceLn(J2D_TRACE_INFO, "GLXGraphicsConfig_getOGLCapabilities");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    if (glxinfo == NULL || glxinfo->context == NULL) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   661
        return CAPS_EMPTY;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    return glxinfo->context->caps;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
#else
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   666
    return CAPS_EMPTY;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
#endif /* !HEADLESS */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
}