From 772af1e8971e65bbff314cf696a9f32da79e3485 Mon Sep 17 00:00:00 2001 From: Gregory Popovitch Date: Fri, 9 Aug 2019 19:38:31 -0400 Subject: [PATCH] More fixes for building with vs2019/msvc (#1500) * Update Froxelizer.h Fix this error when building with msvc from vs2019 error C2926: 'filament::details::Froxelizer::FroxelEntry::::offset': a default member initializer is not allowed for a member of an anonymous struct within a union * Fix some compilation issues with vs2019/msvc Program.cpp: 1>C:\greg\github\filament\filament\backend\src\Program.cpp(28,42): error C2610: 'filament::backend::Program::Program(void) noexcept': is not a special member function or comparison operator which can be defaulted 1>C:\greg\github\filament\filament\backend\src\Program.cpp(28,42): message : exception specification does not match the implicitly declared specification. GLUtils.h: __PRETTY_FUNCTION__ macro is clang specific. Use MSVC equivalent Color.h: fix warning * #1493 - inline constructor in definition as requested by @romainguy * #1493 "move this #define inside the #else below" as requested * #1493 revert last change which causes compilation failures on other platforms. provide empty implementation of Program::Program() in Program.cpp * More fixes for building with vs2019/msvc * #1500 use consistent macro definition syntax (@bejado) * #1500 simplify DEBUG_COMMAND macro as requested by @pixelflinger * #1500 use `{ 0 }` which is accepted by Visual Studio (` = 0 ` is not accepted) * #1500 remove incorrect UTILS_RESTRICT alltogether --- filament/backend/include/private/backend/CommandStream.h | 6 +++--- filament/backend/src/opengl/OpenGLDriver.h | 4 ++-- libs/ibl/src/CubemapIBL.cpp | 4 ++-- libs/math/dummy.cpp | 4 +++- libs/utils/include/utils/StructureOfArrays.h | 2 +- samples/app/FilamentApp.cpp | 2 +- samples/app/IcoSphere.cpp | 2 +- 7 files changed, 13 insertions(+), 11 deletions(-) diff --git a/filament/backend/include/private/backend/CommandStream.h b/filament/backend/include/private/backend/CommandStream.h index df1fb78a08..9a528d7401 100644 --- a/filament/backend/include/private/backend/CommandStream.h +++ b/filament/backend/include/private/backend/CommandStream.h @@ -205,12 +205,12 @@ public: // ------------------------------------------------------------------------------------------------ -#ifdef NDEBUG - #define DEBUG_COMMAND(methodName, params...) +#if defined(NDEBUG) + #define DEBUG_COMMAND(methodName, ...) #else // For now, simply pass the method name down as a string and throw away the parameters. // This is good enough for certain debugging needs and we can improve this later. - #define DEBUG_COMMAND(methodName, params...) mDriver->debugCommand(#methodName) + #define DEBUG_COMMAND(methodName, ...) mDriver->debugCommand(#methodName) #endif class CommandStream { diff --git a/filament/backend/src/opengl/OpenGLDriver.h b/filament/backend/src/opengl/OpenGLDriver.h index 6f80af8b7d..c756654984 100644 --- a/filament/backend/src/opengl/OpenGLDriver.h +++ b/filament/backend/src/opengl/OpenGLDriver.h @@ -475,8 +475,8 @@ private: } pack; struct { - vec4gli scissor = 0; - vec4gli viewport = 0; + vec4gli scissor { 0 }; + vec4gli viewport { 0 }; } window; struct { diff --git a/libs/ibl/src/CubemapIBL.cpp b/libs/ibl/src/CubemapIBL.cpp index 404bc2819a..ca1038b246 100644 --- a/libs/ibl/src/CubemapIBL.cpp +++ b/libs/ibl/src/CubemapIBL.cpp @@ -764,7 +764,7 @@ static float2 DFV(float NoV, float linearRoughness, size_t numSamples) { r.y += v * Fc; } } - return r * (4.0 / numSamples); + return r * (4.0f / numSamples); } static float2 DFV_Multiscatter(float NoV, float linearRoughness, size_t numSamples) { @@ -809,7 +809,7 @@ static float2 DFV_Multiscatter(float NoV, float linearRoughness, size_t numSampl r.y += v; } } - return r * (4.0 / numSamples); + return r * (4.0f / numSamples); } static float UTILS_UNUSED DFV_LazanyiTerm(float NoV, float linearRoughness, size_t numSamples) { diff --git a/libs/math/dummy.cpp b/libs/math/dummy.cpp index a4e2d4ba3e..3a6c9c21f3 100644 --- a/libs/math/dummy.cpp +++ b/libs/math/dummy.cpp @@ -15,6 +15,8 @@ */ // Empty symbol used to suppress warnings on Darwin -__attribute__((visibility("hidden"))) +#if __has_attribute(visibility) + __attribute__((visibility("hidden"))) +#endif void e() { } diff --git a/libs/utils/include/utils/StructureOfArrays.h b/libs/utils/include/utils/StructureOfArrays.h index 61fa958476..44240d72aa 100644 --- a/libs/utils/include/utils/StructureOfArrays.h +++ b/libs/utils/include/utils/StructureOfArrays.h @@ -166,7 +166,7 @@ public: template class Iterator { friend class StructureOfArraysBase; - CVQualifiedSOAPointer UTILS_RESTRICT soa; + CVQualifiedSOAPointer soa; // don't use restrict, can have aliases if multiple iterators are created size_t index; Iterator(CVQualifiedSOAPointer soa, size_t index) : soa(soa), index(index) {} diff --git a/samples/app/FilamentApp.cpp b/samples/app/FilamentApp.cpp index b2d5c528a6..f12a6977d0 100644 --- a/samples/app/FilamentApp.cpp +++ b/samples/app/FilamentApp.cpp @@ -677,7 +677,7 @@ void FilamentApp::Window::configureCamerasForWindow() { FilamentApp::CView::CView(Renderer& renderer, std::string name) : engine(*renderer.getEngine()), mName(name) { view = engine.createView(); - view->setClearColor({ 0 }); + view->setClearColor(LinearColorA{ 0 }); view->setName(name.c_str()); } diff --git a/samples/app/IcoSphere.cpp b/samples/app/IcoSphere.cpp index 62e40eb1c7..3cfaa65d81 100644 --- a/samples/app/IcoSphere.cpp +++ b/samples/app/IcoSphere.cpp @@ -46,7 +46,7 @@ IcoSphere::Index IcoSphere::vertex_for_edge( std::swap(key.first, key.second); } - auto inserted = lookup.insert({ key, vertices.size() }); + auto inserted = lookup.insert({ key, (Lookup::mapped_type)vertices.size() }); if (inserted.second) { auto edge0 = vertices[first]; auto edge1 = vertices[second];