mirror of
https://github.com/godotengine/godot-angle-static.git
synced 2026-01-03 14:09:33 +03:00
WGLWindow: Add support for color spaces.
Add WGL_ARB_pixel_format and WGL_EXT_colorspace to generate_loader.py. Call wglChoosePixelFormatARB from WGL_ARB_pixel_format and use enums from WGL_EXT_colorspace. Fall back to ChoosePixelFormat if wglChoosePixelFormatARB is not available or does not find a format. Bug: angleproject:6366 Change-Id: I900f6fd6ee0501d5343f21c303b40f1347a53765 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3181720 Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Lubosz Sarnecki <lubosz.sarnecki@collabora.com>
This commit is contained in:
committed by
Angle LUCI CQ
parent
eb1d5ca5e9
commit
952cb6a1e4
@@ -6,7 +6,7 @@
|
||||
"scripts/egl_angle_ext.xml":
|
||||
"5bcc01462b355d933cf3ada15198fb68",
|
||||
"scripts/generate_loader.py":
|
||||
"b95f0518351e08bf17240279b2681a6c",
|
||||
"e67f4da64ba7f5cff39ba4e8926a05f8",
|
||||
"scripts/gl.xml":
|
||||
"a442a7aeff3a2f0a1fba52ee08089500",
|
||||
"scripts/gl_angle_ext.xml":
|
||||
@@ -36,7 +36,7 @@
|
||||
"util/gles_loader_autogen.h":
|
||||
"062bf269cd1b9a4127c08ca21a3623e9",
|
||||
"util/windows/wgl_loader_autogen.cpp":
|
||||
"0e305ff76ce8e855022f92105362fcdb",
|
||||
"158e6937dd7bd2879bb440983afd5a36",
|
||||
"util/windows/wgl_loader_autogen.h":
|
||||
"9bc9410ff7fd9fe896bbd85b553faca1"
|
||||
"55c8eaf574db083924b7be5a8a8e5f2e"
|
||||
}
|
||||
@@ -234,9 +234,8 @@ def gen_trace_gles_and_egl_loaders():
|
||||
def gen_util_wgl_loader():
|
||||
|
||||
supported_wgl_extensions = [
|
||||
"WGL_ARB_create_context",
|
||||
"WGL_ARB_extensions_string",
|
||||
"WGL_EXT_swap_control",
|
||||
"WGL_ARB_create_context", "WGL_ARB_extensions_string", "WGL_ARB_pixel_format",
|
||||
"WGL_EXT_colorspace", "WGL_EXT_swap_control"
|
||||
]
|
||||
|
||||
source = "wgl.xml"
|
||||
|
||||
@@ -17,6 +17,11 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
constexpr int kColorBits = 24;
|
||||
constexpr int kAlphaBits = 8;
|
||||
constexpr int kDepthBits = 24;
|
||||
constexpr int kStencilBits = 8;
|
||||
|
||||
PIXELFORMATDESCRIPTOR GetDefaultPixelFormatDescriptor()
|
||||
{
|
||||
PIXELFORMATDESCRIPTOR pixelFormatDescriptor = {};
|
||||
@@ -25,10 +30,10 @@ PIXELFORMATDESCRIPTOR GetDefaultPixelFormatDescriptor()
|
||||
pixelFormatDescriptor.dwFlags =
|
||||
PFD_DRAW_TO_WINDOW | PFD_GENERIC_ACCELERATED | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
|
||||
pixelFormatDescriptor.iPixelType = PFD_TYPE_RGBA;
|
||||
pixelFormatDescriptor.cColorBits = 24;
|
||||
pixelFormatDescriptor.cAlphaBits = 8;
|
||||
pixelFormatDescriptor.cDepthBits = 24;
|
||||
pixelFormatDescriptor.cStencilBits = 8;
|
||||
pixelFormatDescriptor.cColorBits = kColorBits;
|
||||
pixelFormatDescriptor.cAlphaBits = kAlphaBits;
|
||||
pixelFormatDescriptor.cDepthBits = kDepthBits;
|
||||
pixelFormatDescriptor.cStencilBits = kStencilBits;
|
||||
pixelFormatDescriptor.iLayerType = PFD_MAIN_PLANE;
|
||||
|
||||
return pixelFormatDescriptor;
|
||||
@@ -57,6 +62,56 @@ void DumpLastWindowsError()
|
||||
{
|
||||
std::cerr << "Last Windows error code: 0x" << std::hex << GetLastError() << std::endl;
|
||||
}
|
||||
|
||||
// Based on GetDefaultPixelFormatAttributes from wgl_utils.cpp
|
||||
std::vector<int> GetPixelFormatAttributes(const ConfigParameters &configParams)
|
||||
{
|
||||
std::vector<int> attribs;
|
||||
attribs.push_back(WGL_DRAW_TO_WINDOW_ARB);
|
||||
attribs.push_back(TRUE);
|
||||
|
||||
attribs.push_back(WGL_ACCELERATION_ARB);
|
||||
attribs.push_back(WGL_FULL_ACCELERATION_ARB);
|
||||
|
||||
attribs.push_back(WGL_SUPPORT_OPENGL_ARB);
|
||||
attribs.push_back(TRUE);
|
||||
|
||||
attribs.push_back(WGL_DOUBLE_BUFFER_ARB);
|
||||
attribs.push_back(TRUE);
|
||||
|
||||
attribs.push_back(WGL_PIXEL_TYPE_ARB);
|
||||
attribs.push_back(WGL_TYPE_RGBA_ARB);
|
||||
|
||||
attribs.push_back(WGL_COLOR_BITS_ARB);
|
||||
attribs.push_back(kColorBits);
|
||||
|
||||
attribs.push_back(WGL_ALPHA_BITS_ARB);
|
||||
attribs.push_back(kAlphaBits);
|
||||
|
||||
attribs.push_back(WGL_DEPTH_BITS_ARB);
|
||||
attribs.push_back(kDepthBits);
|
||||
|
||||
attribs.push_back(WGL_STENCIL_BITS_ARB);
|
||||
attribs.push_back(kStencilBits);
|
||||
|
||||
attribs.push_back(WGL_SWAP_METHOD_ARB);
|
||||
attribs.push_back(WGL_SWAP_UNDEFINED_ARB);
|
||||
|
||||
attribs.push_back(WGL_COLORSPACE_EXT);
|
||||
if (configParams.colorSpace == EGL_COLORSPACE_sRGB)
|
||||
{
|
||||
attribs.push_back(WGL_COLORSPACE_SRGB_EXT);
|
||||
}
|
||||
else
|
||||
{
|
||||
attribs.push_back(WGL_COLORSPACE_LINEAR_EXT);
|
||||
}
|
||||
|
||||
attribs.push_back(0);
|
||||
|
||||
return attribs;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
WGLWindow::WGLWindow(int glesMajorVersion, int glesMinorVersion)
|
||||
@@ -96,7 +151,26 @@ bool WGLWindow::initializeGL(OSWindow *osWindow,
|
||||
mDeviceContext = GetDC(mWindow);
|
||||
const PIXELFORMATDESCRIPTOR pixelFormatDescriptor = GetDefaultPixelFormatDescriptor();
|
||||
|
||||
int pixelFormat = ChoosePixelFormat(mDeviceContext, &pixelFormatDescriptor);
|
||||
int pixelFormat = 0;
|
||||
|
||||
if (!_wglChoosePixelFormatARB)
|
||||
{
|
||||
std::cout << "Driver does not expose wglChoosePixelFormatARB." << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<int> pixelFormatAttribs = GetPixelFormatAttributes(configParams);
|
||||
|
||||
UINT matchingFormats = 0;
|
||||
_wglChoosePixelFormatARB(mDeviceContext, &pixelFormatAttribs[0], nullptr, 1u, &pixelFormat,
|
||||
&matchingFormats);
|
||||
}
|
||||
|
||||
if (pixelFormat == 0)
|
||||
{
|
||||
pixelFormat = ChoosePixelFormat(mDeviceContext, &pixelFormatDescriptor);
|
||||
}
|
||||
|
||||
if (pixelFormat == 0)
|
||||
{
|
||||
std::cerr << "Could not find a compatible pixel format." << std::endl;
|
||||
|
||||
@@ -38,6 +38,9 @@ PFNWGLUSEFONTOUTLINESAPROC l__wglUseFontOutlinesA;
|
||||
PFNWGLUSEFONTOUTLINESWPROC l__wglUseFontOutlinesW;
|
||||
PFNWGLCREATECONTEXTATTRIBSARBPROC l__wglCreateContextAttribsARB;
|
||||
PFNWGLGETEXTENSIONSSTRINGARBPROC l__wglGetExtensionsStringARB;
|
||||
PFNWGLCHOOSEPIXELFORMATARBPROC l__wglChoosePixelFormatARB;
|
||||
PFNWGLGETPIXELFORMATATTRIBFVARBPROC l__wglGetPixelFormatAttribfvARB;
|
||||
PFNWGLGETPIXELFORMATATTRIBIVARBPROC l__wglGetPixelFormatAttribivARB;
|
||||
PFNWGLGETSWAPINTERVALEXTPROC l__wglGetSwapIntervalEXT;
|
||||
PFNWGLSWAPINTERVALEXTPROC l__wglSwapIntervalEXT;
|
||||
|
||||
@@ -92,6 +95,12 @@ void LoadWGL(LoadProc loadProc)
|
||||
reinterpret_cast<PFNWGLCREATECONTEXTATTRIBSARBPROC>(loadProc("wglCreateContextAttribsARB"));
|
||||
l__wglGetExtensionsStringARB =
|
||||
reinterpret_cast<PFNWGLGETEXTENSIONSSTRINGARBPROC>(loadProc("wglGetExtensionsStringARB"));
|
||||
l__wglChoosePixelFormatARB =
|
||||
reinterpret_cast<PFNWGLCHOOSEPIXELFORMATARBPROC>(loadProc("wglChoosePixelFormatARB"));
|
||||
l__wglGetPixelFormatAttribfvARB = reinterpret_cast<PFNWGLGETPIXELFORMATATTRIBFVARBPROC>(
|
||||
loadProc("wglGetPixelFormatAttribfvARB"));
|
||||
l__wglGetPixelFormatAttribivARB = reinterpret_cast<PFNWGLGETPIXELFORMATATTRIBIVARBPROC>(
|
||||
loadProc("wglGetPixelFormatAttribivARB"));
|
||||
l__wglGetSwapIntervalEXT =
|
||||
reinterpret_cast<PFNWGLGETSWAPINTERVALEXTPROC>(loadProc("wglGetSwapIntervalEXT"));
|
||||
l__wglSwapIntervalEXT =
|
||||
|
||||
@@ -46,6 +46,9 @@
|
||||
#define _wglUseFontOutlinesW l__wglUseFontOutlinesW
|
||||
#define _wglCreateContextAttribsARB l__wglCreateContextAttribsARB
|
||||
#define _wglGetExtensionsStringARB l__wglGetExtensionsStringARB
|
||||
#define _wglChoosePixelFormatARB l__wglChoosePixelFormatARB
|
||||
#define _wglGetPixelFormatAttribfvARB l__wglGetPixelFormatAttribfvARB
|
||||
#define _wglGetPixelFormatAttribivARB l__wglGetPixelFormatAttribivARB
|
||||
#define _wglGetSwapIntervalEXT l__wglGetSwapIntervalEXT
|
||||
#define _wglSwapIntervalEXT l__wglSwapIntervalEXT
|
||||
extern PFNCHOOSEPIXELFORMATPROC l__ChoosePixelFormat;
|
||||
@@ -76,6 +79,9 @@ extern PFNWGLUSEFONTOUTLINESAPROC l__wglUseFontOutlinesA;
|
||||
extern PFNWGLUSEFONTOUTLINESWPROC l__wglUseFontOutlinesW;
|
||||
extern PFNWGLCREATECONTEXTATTRIBSARBPROC l__wglCreateContextAttribsARB;
|
||||
extern PFNWGLGETEXTENSIONSSTRINGARBPROC l__wglGetExtensionsStringARB;
|
||||
extern PFNWGLCHOOSEPIXELFORMATARBPROC l__wglChoosePixelFormatARB;
|
||||
extern PFNWGLGETPIXELFORMATATTRIBFVARBPROC l__wglGetPixelFormatAttribfvARB;
|
||||
extern PFNWGLGETPIXELFORMATATTRIBIVARBPROC l__wglGetPixelFormatAttribivARB;
|
||||
extern PFNWGLGETSWAPINTERVALEXTPROC l__wglGetSwapIntervalEXT;
|
||||
extern PFNWGLSWAPINTERVALEXTPROC l__wglSwapIntervalEXT;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user