Hash :
3d890436
Author :
Date :
2015-12-08T11:47:59
Load the WGL_NV_DX_interop entry points in FunctionsWGL. BUG=540829 Change-Id: Iab080789f2a21b900e2641aa97c0e3392d007391 Reviewed-on: https://chromium-review.googlesource.com/316802 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
//
// Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// FunctionsWGL.h: Implements the FuntionsWGL class.
#include "libANGLE/renderer/gl/wgl/FunctionsWGL.h"
#include <algorithm>
#include "common/string_utils.h"
namespace rx
{
template <typename T>
static void GetWGLProcAddress(HMODULE glModule, PFNWGLGETPROCADDRESSPROC getProcAddressWGL,
const std::string &procName, T *outProcAddress)
{
T proc = nullptr;
if (getProcAddressWGL)
{
proc = reinterpret_cast<T>(getProcAddressWGL(procName.c_str()));
}
if (!proc)
{
proc = reinterpret_cast<T>(GetProcAddress(glModule, procName.c_str()));
}
*outProcAddress = proc;
}
template <typename T>
static void GetWGLExtensionProcAddress(HMODULE glModule,
PFNWGLGETPROCADDRESSPROC getProcAddressWGL,
const std::vector<std::string> &extensions,
const std::string &extensionName,
const std::string &procName,
T *outProcAddress)
{
T proc = nullptr;
if (std::find(extensions.begin(), extensions.end(), extensionName) != extensions.end())
{
GetWGLProcAddress(glModule, getProcAddressWGL, procName, &proc);
}
*outProcAddress = proc;
}
FunctionsWGL::FunctionsWGL()
: copyContext(nullptr),
createContext(nullptr),
createLayerContext(nullptr),
deleteContext(nullptr),
getCurrentContext(nullptr),
getCurrentDC(nullptr),
getProcAddress(nullptr),
makeCurrent(nullptr),
shareLists(nullptr),
useFontBitmapsA(nullptr),
useFontBitmapsW(nullptr),
swapBuffers(nullptr),
useFontOutlinesA(nullptr),
useFontOutlinesW(nullptr),
describeLayerPlane(nullptr),
setLayerPaletteEntries(nullptr),
getLayerPaletteEntries(nullptr),
realizeLayerPalette(nullptr),
swapLayerBuffers(nullptr),
swapMultipleBuffers(nullptr),
getExtensionStringEXT(nullptr),
getExtensionStringARB(nullptr),
createContextAttribsARB(nullptr),
getPixelFormatAttribivARB(nullptr),
getPixelFormatAttribfvARB(nullptr),
choosePixelFormatARB(nullptr),
swapIntervalEXT(nullptr),
createPbufferARB(nullptr),
getPbufferDCARB(nullptr),
releasePbufferDCARB(nullptr),
destroyPbufferARB(nullptr),
queryPbufferARB(nullptr),
bindTexImageARB(nullptr),
releaseTexImageARB(nullptr),
setPbufferAttribARB(nullptr),
dxSetResourceShareHandleNV(nullptr),
dxOpenDeviceNV(nullptr),
dxCloseDeviceNV(nullptr),
dxRegisterObjectNV(nullptr),
dxUnregisterObjectNV(nullptr),
dxObjectAccessNV(nullptr),
dxLockObjectsNV(nullptr),
dxUnlockObjectsNV(nullptr)
{
}
void FunctionsWGL::initialize(HMODULE glModule, HDC context)
{
// First grab the wglGetProcAddress function from the gl module
GetWGLProcAddress(glModule, nullptr, "wglGetProcAddress", &getProcAddress);
// Load the core wgl functions
GetWGLProcAddress(glModule, getProcAddress, "wglCopyContext", ©Context);
GetWGLProcAddress(glModule, getProcAddress, "wglCreateContext", &createContext);
GetWGLProcAddress(glModule, getProcAddress, "wglCreateLayerContext", &createLayerContext);
GetWGLProcAddress(glModule, getProcAddress, "wglDeleteContext", &deleteContext);
GetWGLProcAddress(glModule, getProcAddress, "wglGetCurrentContext", &getCurrentContext);
GetWGLProcAddress(glModule, getProcAddress, "wglGetCurrentDC", &getCurrentDC);
GetWGLProcAddress(glModule, getProcAddress, "wglMakeCurrent", &makeCurrent);
GetWGLProcAddress(glModule, getProcAddress, "wglShareLists", &shareLists);
GetWGLProcAddress(glModule, getProcAddress, "wglUseFontBitmapsA", &useFontBitmapsA);
GetWGLProcAddress(glModule, getProcAddress, "wglUseFontBitmapsW", &useFontBitmapsW);
swapBuffers = SwapBuffers; // SwapBuffers is statically linked from GDI
GetWGLProcAddress(glModule, getProcAddress, "wglUseFontOutlinesA", &useFontOutlinesA);
GetWGLProcAddress(glModule, getProcAddress, "wglUseFontOutlinesW", &useFontOutlinesW);
GetWGLProcAddress(glModule, getProcAddress, "wglDescribeLayerPlane", &describeLayerPlane);
GetWGLProcAddress(glModule, getProcAddress, "wglSetLayerPaletteEntries", &setLayerPaletteEntries);
GetWGLProcAddress(glModule, getProcAddress, "wglGetLayerPaletteEntries", &getLayerPaletteEntries);
GetWGLProcAddress(glModule, getProcAddress, "wglRealizeLayerPalette", &realizeLayerPalette);
GetWGLProcAddress(glModule, getProcAddress, "wglSwapLayerBuffers", &swapLayerBuffers);
GetWGLProcAddress(glModule, getProcAddress, "wglSwapMultipleBuffers", &swapMultipleBuffers);
// Load extension string getter functions
GetWGLProcAddress(glModule, getProcAddress, "wglGetExtensionsStringEXT", &getExtensionStringEXT);
GetWGLProcAddress(glModule, getProcAddress, "wglGetExtensionsStringARB", &getExtensionStringARB);
std::string extensionString = "";
if (getExtensionStringEXT)
{
extensionString = getExtensionStringEXT();
}
else if (getExtensionStringARB && context)
{
extensionString = getExtensionStringARB(context);
}
angle::SplitStringAlongWhitespace(extensionString, &extensions);
// Load the wgl extension functions by checking if the context supports the extension first
// WGL_ARB_create_context
GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_ARB_create_context", "wglCreateContextAttribsARB", &createContextAttribsARB);
// WGL_ARB_pixel_format
GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_ARB_pixel_format", "wglGetPixelFormatAttribivARB", &getPixelFormatAttribivARB);
GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_ARB_pixel_format", "wglGetPixelFormatAttribfvARB", &getPixelFormatAttribfvARB);
GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_ARB_pixel_format", "wglChoosePixelFormatARB", &choosePixelFormatARB);
// WGL_EXT_swap_control
GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_EXT_swap_control", "wglSwapIntervalEXT", &swapIntervalEXT);
// WGL_ARB_pbuffer
GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_ARB_pbuffer", "wglCreatePbufferARB", &createPbufferARB);
GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_ARB_pbuffer", "wglGetPbufferDCARB", &getPbufferDCARB);
GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_ARB_pbuffer", "wglReleasePbufferDCARB", &releasePbufferDCARB);
GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_ARB_pbuffer", "wglDestroyPbufferARB", &destroyPbufferARB);
GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_ARB_pbuffer", "wglQueryPbufferARB", &queryPbufferARB);
// WGL_ARB_render_texture
GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_ARB_render_texture", "wglBindTexImageARB", &bindTexImageARB);
GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_ARB_render_texture", "wglReleaseTexImageARB", &releaseTexImageARB);
GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_ARB_render_texture", "wglSetPbufferAttribARB", &setPbufferAttribARB);
// WGL_NV_DX_interop
GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_NV_DX_interop", "wglDXSetResourceShareHandleNV", &dxSetResourceShareHandleNV);
GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_NV_DX_interop", "wglDXOpenDeviceNV", &dxOpenDeviceNV);
GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_NV_DX_interop", "wglDXCloseDeviceNV", &dxCloseDeviceNV);
GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_NV_DX_interop", "wglDXRegisterObjectNV", &dxRegisterObjectNV);
GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_NV_DX_interop", "wglDXUnregisterObjectNV", &dxUnregisterObjectNV);
GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_NV_DX_interop", "wglDXObjectAccessNV", &dxObjectAccessNV);
GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_NV_DX_interop", "wglDXLockObjectsNV", &dxLockObjectsNV);
GetWGLExtensionProcAddress(glModule, getProcAddress, extensions, "WGL_NV_DX_interop", "wglDXUnlockObjectsNV", &dxUnlockObjectsNV);
}
bool FunctionsWGL::hasExtension(const std::string &ext) const
{
return std::find(extensions.begin(), extensions.end(), ext) != extensions.end();
}
}