mirror of
https://github.com/godotengine/godot-angle-static.git
synced 2026-01-03 14:09:33 +03:00
Revert "Fix several WGL test failures."
This reverts commit 13a8c4d84e.
Reason for revert: Seems to have led to a flakier situation:
https://ci.chromium.org/p/chromium/builders/ci/Win10%20FYI%20Debug%20%28NVIDIA%29/3006
https://ci.chromium.org/p/chromium/builders/try/win-angle-rel/1231
Original change's description:
> Fix several WGL test failures.
>
> SimpleOperationTest.ClearAndSwap/ES2_WGL failed when run in isolation,
> since getGLWindow()->hasError() would report a previous error,
> instead of result of swapBuffers().
> When running after an OPENGL test, swapBuffers() would clear
> the previous error, but that doesn't happen in isolation.
>
> The previous error is from loading WGL functions, some of which are
> expected not to be present. Clear the error in GetProcAddressWithFallback,
> but verify that there is no error entering it.
>
> This uncovers more errors in angle_perftests:
> DrawCallPerfBenchmark.Run/wgl
> DrawCallPerfBenchmark.Run/wgl_tex_change
> DrawCallPerfBenchmark.Run/wgl_vbo_change
> DrawElementsPerfBenchmark.Run/wgl_ushort
> They come from redundant calls when destroying a window. Fix this as well.
>
> Several more errors where uncovered by debug prints, fix those, too.
>
> Bug: angleproject:3153
> Change-Id: I559c098be9dcdfd3add83f045f745d190250b986
> Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1515602
> Commit-Queue: Yuly Novikov <ynovikov@chromium.org>
> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
TBR=ynovikov@chromium.org,geofflang@chromium.org,syoussefi@chromium.org,jmadill@chromium.org
Change-Id: I095fadc0dd3a2c998c1dc86f3760184ae6fd7309
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: angleproject:3153
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1523527
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
This commit is contained in:
@@ -9,11 +9,9 @@
|
||||
|
||||
#include "util/windows/WGLWindow.h"
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "common/string_utils.h"
|
||||
#include "util/OSWindow.h"
|
||||
#include "util/system_utils.h"
|
||||
#include "util/windows/win32/Win32Window.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@@ -41,44 +39,24 @@ HMODULE gCurrentModule = nullptr;
|
||||
|
||||
angle::GenericProc WINAPI GetProcAddressWithFallback(const char *name)
|
||||
{
|
||||
ASSERT(GetLastError() == ERROR_SUCCESS);
|
||||
angle::GenericProc proc = reinterpret_cast<angle::GenericProc>(gCurrentWGLGetProcAddress(name));
|
||||
// ERROR_INVALID_HANDLE and ERROR_PROC_NOT_FOUND are expected from wglGetProcAddress,
|
||||
// reset last error if they happen.
|
||||
if (GetLastError() != ERROR_SUCCESS && GetLastError() != ERROR_INVALID_HANDLE &&
|
||||
GetLastError() != ERROR_PROC_NOT_FOUND)
|
||||
{
|
||||
std::cerr << "Unexpected error calling wglGetProcAddress: 0x" << std::hex << GetLastError()
|
||||
<< std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
}
|
||||
|
||||
if (proc)
|
||||
{
|
||||
return proc;
|
||||
}
|
||||
|
||||
proc = reinterpret_cast<angle::GenericProc>(GetProcAddress(gCurrentModule, name));
|
||||
// ERROR_PROC_NOT_FOUND is expected from GetProcAddress, reset last error if it happens.
|
||||
if (GetLastError() != ERROR_SUCCESS && GetLastError() != ERROR_PROC_NOT_FOUND)
|
||||
{
|
||||
std::cerr << "Unexpected error calling GetProcAddress: 0x" << std::hex << GetLastError()
|
||||
<< std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetLastError(ERROR_SUCCESS);
|
||||
}
|
||||
return proc;
|
||||
return reinterpret_cast<angle::GenericProc>(GetProcAddress(gCurrentModule, name));
|
||||
}
|
||||
|
||||
bool HasExtension(const std::vector<std::string> &extensions, const char *ext)
|
||||
{
|
||||
return std::find(extensions.begin(), extensions.end(), ext) != extensions.end();
|
||||
}
|
||||
|
||||
void DumpLastWindowsError()
|
||||
{
|
||||
std::cerr << "Last Windows error code: 0x" << std::hex << GetLastError() << std::endl;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
WGLWindow::WGLWindow(int glesMajorVersion, int glesMinorVersion)
|
||||
@@ -104,15 +82,30 @@ bool WGLWindow::initializeGL(OSWindow *osWindow, angle::Library *glWindowingLibr
|
||||
gCurrentModule = reinterpret_cast<HMODULE>(glWindowingLibrary->getNative());
|
||||
angle::LoadWGL(GetProcAddressWithFallback);
|
||||
|
||||
Win32Window *win32Window = static_cast<Win32Window *>(osWindow);
|
||||
if (!win32Window->setPixelFormat(GetDefaultPixelFormatDescriptor()))
|
||||
mWindow = osWindow->getNativeWindow();
|
||||
mDeviceContext = GetDC(mWindow);
|
||||
const PIXELFORMATDESCRIPTOR pixelFormatDescriptor = GetDefaultPixelFormatDescriptor();
|
||||
|
||||
int pixelFormat = ChoosePixelFormat(mDeviceContext, &pixelFormatDescriptor);
|
||||
if (pixelFormat == 0)
|
||||
{
|
||||
std::cerr << "Failed to set default pixel format." << std::endl;
|
||||
std::cerr << "Could not find a compatible pixel format." << std::endl;
|
||||
DumpLastWindowsError();
|
||||
return false;
|
||||
}
|
||||
|
||||
mWindow = osWindow->getNativeWindow();
|
||||
mDeviceContext = GetDC(mWindow);
|
||||
// According to the Windows docs, it is an error to set a pixel format twice.
|
||||
int currentPixelFormat = GetPixelFormat(mDeviceContext);
|
||||
if (currentPixelFormat != pixelFormat)
|
||||
{
|
||||
if (SetPixelFormat(mDeviceContext, pixelFormat, &pixelFormatDescriptor) != TRUE)
|
||||
{
|
||||
std::cerr << "Failed to set the pixel format." << std::endl;
|
||||
DumpLastWindowsError();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
mWGLContext = _wglCreateContext(mDeviceContext);
|
||||
if (!mWGLContext)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user