Commit 50b10597 by Nicolas Capens Committed by Nicolas Capens

Fix OGLES2HelloAPI and Vulkan build.

Assigning string literals to char* has been deprecated since C++98 and is now an error in Visual Studio. Also, a goto which skips variable nationalizations is an error now. std::min/max are defined in <algorithm> Bug swiftshader:121 Change-Id: Ic087706de810e68849eb021c1e0a9d2f2a960260 Reviewed-on: https://swiftshader-review.googlesource.com/c/21988Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent 38ff8304
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2002
VisualStudioVersion = 15.0.27130.2036
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LLVM", "LLVM", "{B408B98A-E888-4ECF-81E0-7A37A6854B17}"
EndProject
......
......@@ -27,8 +27,10 @@
#include "VkPhysicalDevice.hpp"
#include "VkQueue.hpp"
#include "VkSemaphore.hpp"
#include <cstring>
#include <string>
#include <algorithm>
extern "C"
{
......@@ -1688,7 +1690,7 @@ VKAPI_ATTR void VKAPI_CALL vkGetDeviceQueue2(VkDevice device, const VkDeviceQueu
UNIMPLEMENTED();
}
// The only flag that can be set here is VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT
// The only flag that can be set here is VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT
// According to the Vulkan spec, 4.3.1. Queue Family Properties:
// "VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT specifies that the device queue is a
// protected-capable queue. If the protected memory feature is not enabled,
......
......@@ -4,7 +4,7 @@
@Title OpenGL ES 2.0 HelloAPI Tutorial
@Version
@Version
@Copyright Copyright (c) Imagination Technologies Limited.
......@@ -90,7 +90,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
@Return bool true if no EGL error was detected
@Description Tests for an EGL error and prints it
******************************************************************************/
bool TestEGLError(HWND hWnd, char* pszLocation)
bool TestEGLError(HWND hWnd, const char* pszLocation)
{
/*
eglGetError returns the last error that has happened using egl,
......@@ -110,6 +110,36 @@ bool TestEGLError(HWND hWnd, char* pszLocation)
}
/*!****************************************************************************
@Function Cleanup
@Input eglDisplay Handle to the EGL display
@Input hWnd Handle to the window
@Input hDC Handle to the device context
@Return int result code to OS
@Description Clean up before program termination on error or normal exit
******************************************************************************/
int Cleanup(EGLDisplay eglDisplay, HWND hWnd, HDC hDC)
{
/*
eglTerminate takes care of destroying any context or surface created
with this display, so we don't need to call eglDestroySurface or
eglDestroyContext here.
*/
eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglTerminate(eglDisplay);
/*
Destroy the eglWindow.
This is platform specific and delegated to a separate function.
*/
// Release the device context
if (hDC) ReleaseDC(hWnd, hDC);
return 0;
}
/*!****************************************************************************
@Function WinMain
@Input hInstance Application instance from OS
@Input hPrevInstance Always NULL
......@@ -141,12 +171,12 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TCHAR *lpCmdLin
};
// Fragment and vertex shaders code
char* pszFragShader = "\
const char* pszFragShader = "\
void main (void)\
{\
gl_FragColor = vec4(1.0, 1.0, 0.66 ,1.0);\
}";
char* pszVertShader = "\
const char* pszVertShader = "\
attribute highp vec4 myVertex;\
uniform mediump mat4 myPMVMatrix;\
void main(void)\
......@@ -192,7 +222,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TCHAR *lpCmdLin
if (!hDC)
{
MessageBox(0, _T("Failed to create the device context"), _T("Error"), MB_OK|MB_ICONEXCLAMATION);
goto cleanup;
return Cleanup(eglDisplay, hWnd, hDC);
}
/*
......@@ -220,7 +250,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TCHAR *lpCmdLin
if (!eglInitialize(eglDisplay, &iMajorVersion, &iMinorVersion))
{
MessageBox(0, _T("eglInitialize() failed."), _T("Error"), MB_OK|MB_ICONEXCLAMATION);
goto cleanup;
return Cleanup(eglDisplay, hWnd, hDC);
}
/*
......@@ -232,7 +262,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TCHAR *lpCmdLin
eglBindAPI(EGL_OPENGL_ES_API);
if (!TestEGLError(hWnd, "eglBindAPI"))
{
goto cleanup;
return Cleanup(eglDisplay, hWnd, hDC);
}
/*
......@@ -264,7 +294,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TCHAR *lpCmdLin
if (!eglChooseConfig(eglDisplay, pi32ConfigAttribs, &eglConfig, 1, &iConfigs) || (iConfigs != 1))
{
MessageBox(0, _T("eglChooseConfig() failed."), _T("Error"), MB_OK|MB_ICONEXCLAMATION);
goto cleanup;
return Cleanup(eglDisplay, hWnd, hDC);
}
/*
......@@ -286,7 +316,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TCHAR *lpCmdLin
if (!TestEGLError(hWnd, "eglCreateWindowSurface"))
{
goto cleanup;
return Cleanup(eglDisplay, hWnd, hDC);
}
/*
......@@ -299,7 +329,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TCHAR *lpCmdLin
eglContext = eglCreateContext(eglDisplay, eglConfig, NULL, ai32ContextAttribs);
if (!TestEGLError(hWnd, "eglCreateContext"))
{
goto cleanup;
return Cleanup(eglDisplay, hWnd, hDC);
}
/*
......@@ -315,7 +345,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TCHAR *lpCmdLin
eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext);
if (!TestEGLError(hWnd, "eglMakeCurrent"))
{
goto cleanup;
return Cleanup(eglDisplay, hWnd, hDC);
}
/*
......@@ -355,7 +385,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TCHAR *lpCmdLin
MessageBox(hWnd, i32InfoLogLength ? pszInfoLog : _T(""), _T("Failed to compile fragment shader"), MB_OK|MB_ICONEXCLAMATION);
delete[] pszInfoLog;
goto cleanup;
return Cleanup(eglDisplay, hWnd, hDC);
}
// Loads the vertex shader in the same way
......@@ -375,7 +405,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TCHAR *lpCmdLin
delete[] pszInfoLog;
goto cleanup;
return Cleanup(eglDisplay, hWnd, hDC);
}
// Create the shader program
......@@ -404,7 +434,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TCHAR *lpCmdLin
MessageBox(hWnd, i32InfoLogLength ? pszInfoLog : _T(""), _T("Failed to link program"), MB_OK|MB_ICONEXCLAMATION);
delete[] pszInfoLog;
goto cleanup;
return Cleanup(eglDisplay, hWnd, hDC);
}
// Actually use the created program
......@@ -419,7 +449,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TCHAR *lpCmdLin
// We're going to draw a triangle to the screen so create a vertex buffer object for our triangle
GLuint ui32Vbo; // Vertex buffer object handle
// Interleaved vertex data
GLfloat afVertices[] = { -0.4f,-0.4f,0.0f, // Position
0.4f ,-0.4f,0.0f,
......@@ -482,7 +512,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TCHAR *lpCmdLin
eglSwapBuffers(eglDisplay, eglSurface);
if (!TestEGLError(hWnd, "eglSwapBuffers"))
{
goto cleanup;
return Cleanup(eglDisplay, hWnd, hDC);
}
// Managing the window messages
......@@ -503,24 +533,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TCHAR *lpCmdLin
/*
Step 10 - Terminate OpenGL ES and destroy the window (if present).
eglTerminate takes care of destroying any context or surface created
with this display, so we don't need to call eglDestroySurface or
eglDestroyContext here.
*/
cleanup:
eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
eglTerminate(eglDisplay);
/*
Step 11 - Destroy the eglWindow.
Again, this is platform specific and delegated to a separate function.
*/
// Release the device context
if (hDC) ReleaseDC(hWnd, hDC);
// Destroy the eglWindow
return 0;
return Cleanup(eglDisplay, hWnd, hDC);
}
/******************************************************************************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment